feat(dashboard): update display of tracking/label URLs on order details (#11613)
### Overview This PR updates the fulfillment label rendering by replacing the deprecated .url field with the new tracking_url and label_url fields, following the MedusaJS FulfillmentLabel model. ### Changes - Implemented conditional rendering for both tracking_url and label_url. - If a tracking_url exists, it is displayed as a clickable link. - Similarly, if a label_url exists, it is displayed as a clickable link. - If neither link is provided, only the tracking number is shown. - Maintained existing styling for interactive elements.  ### Reference This update is based on the MedusaJS FulfillmentLabel model: https://docs.medusajs.com/resources/references/fulfillment/models/FulfillmentLabel Please review the changes and provide feedback for further improvements. Co-authored-by: William Bouchard <46496014+willbouch@users.noreply.github.com>
This commit is contained in:
1 parent
90cc3f42d9
commit
5e5f628d87
2 files changed
+35
-13
No files matched your search
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/dashboard": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat(dashboard): update display of tracking/label URLs on order details
|
||||||
+30
-13
@@ -320,6 +320,8 @@ const Fulfillment = ({
|
|||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isValidUrl = (url?: string) => url && url.length > 0 && url !== "#"
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container className="divide-y p-0">
|
<Container className="divide-y p-0">
|
||||||
<div className="flex items-center justify-between px-6 py-4">
|
<div className="flex items-center justify-between px-6 py-4">
|
||||||
@@ -408,22 +410,37 @@ const Fulfillment = ({
|
|||||||
{fulfillment.labels && fulfillment.labels.length > 0 ? (
|
{fulfillment.labels && fulfillment.labels.length > 0 ? (
|
||||||
<ul>
|
<ul>
|
||||||
{fulfillment.labels.map((tlink) => {
|
{fulfillment.labels.map((tlink) => {
|
||||||
const hasUrl =
|
const hasTrackingUrl = isValidUrl(tlink.tracking_url)
|
||||||
tlink.url && tlink.url.length > 0 && tlink.url !== "#"
|
const hasLabelUrl = isValidUrl(tlink.label_url)
|
||||||
|
|
||||||
if (hasUrl) {
|
if (hasTrackingUrl || hasLabelUrl) {
|
||||||
return (
|
return (
|
||||||
<li key={tlink.tracking_number}>
|
<li key={tlink.tracking_number}>
|
||||||
<a
|
{hasTrackingUrl && (
|
||||||
href={tlink.url}
|
<a
|
||||||
target="_blank"
|
href={tlink.tracking_url}
|
||||||
rel="noopener noreferrer"
|
target="_blank"
|
||||||
className="text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg"
|
rel="noopener noreferrer"
|
||||||
>
|
className="text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg"
|
||||||
<Text size="small" leading="compact">
|
>
|
||||||
{tlink.tracking_number}
|
<Text size="small" leading="compact" as="span">
|
||||||
</Text>
|
{tlink.tracking_number}
|
||||||
</a>
|
</Text>
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
|
{hasTrackingUrl && hasLabelUrl && " - "}
|
||||||
|
{hasLabelUrl && (
|
||||||
|
<a
|
||||||
|
href={tlink.label_url}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
className="text-ui-fg-interactive hover:text-ui-fg-interactive-hover transition-fg"
|
||||||
|
>
|
||||||
|
<Text size="small" leading="compact" as="span">
|
||||||
|
Label
|
||||||
|
</Text>
|
||||||
|
</a>
|
||||||
|
)}
|
||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user