Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Bring the seller parcel screens up to the dashboard's
Damian Legawiec99dadbe04443
diff --git a/docs/api-reference/seller.yaml b/docs/api-reference/seller.yamlindex cea5fa4afb..753228713c 100644--- a/docs/api-reference/seller.yaml+++ b/docs/api-reference/seller.yaml@@ -12792,12 +12792,12 @@ paths:- key: normal_amounttype: decimaldefault: 0- - key: currency- type: string- default: USD- key: discount_amounttype: decimaldefault: 0+ - key: currency+ type: string+ default: USD- type: Spree::Calculator::Shipping::DigitalDeliveryname: Digital Deliverypreference_schema:@@ -13540,8 +13540,8 @@ paths:example:data:- id: prod_UkLWZg9DAJ- name: Product 1573250- slug: product-1573250+ name: Product 1683250+ slug: product-1683250meta_title:meta_description:meta_keywords:@@ -13784,8 +13784,8 @@ paths:application/json:example:id: prod_UkLWZg9DAJ- name: Product 1606710- slug: product-1606710+ name: Product 1716710+ slug: product-1716710meta_title:meta_description:meta_keywords:@@ -13864,7 +13864,7 @@ paths:example:id: prod_UkLWZg9DAJname: Hand-thrown mug, large- slug: product-1638212+ slug: product-1748212meta_title:meta_description:meta_keywords:@@ -14207,6 +14207,7 @@ paths:active: truedefault: falsekind: warehouse+ returns_enabled: truecreated_at: '2026-01-15T12:00:00.000Z'updated_at: '2026-01-15T12:00:00.000Z'meta:@@ -14272,6 +14273,7 @@ paths:active: truedefault: falsekind: warehouse+ returns_enabled: truecreated_at: '2026-01-15T12:00:00.000Z'updated_at: '2026-01-15T12:00:00.000Z'schema:@@ -14387,6 +14389,7 @@ paths:active: truedefault: falsekind: warehouse+ returns_enabled: truecreated_at: '2026-01-15T12:00:00.000Z'updated_at: '2026-01-15T12:00:00.000Z'schema:@@ -14443,6 +14446,7 @@ paths:active: truedefault: falsekind: warehouse+ returns_enabled: truecreated_at: '2026-01-15T12:00:00.000Z'updated_at: '2026-01-15T12:00:00.000Z'schema:@@ -14793,10 +14797,10 @@ paths:application/json:example:direct_upload:- url: http://www.example.com/rails/active_storage/disk/eyJfcmFpbHMiOnsiZGF0YSI6eyJrZXkiOiJuem5oOGdra3VxendvbDc1ODBxNHNwZmpmMjVxIiwiY29udGVudF90eXBlIjoiYXBwbGljYXRpb24vcGRmIiwiY29udGVudF9sZW5ndGgiOjUxMjM0LCJjaGVja3N1bSI6IlZqaHowNGxRdUVHdXY0bkR2aHNhTlE9PSIsInNlcnZpY2VfbmFtZSI6InRlc3QifSwiZXhwIjoiMjAyNi0wMS0xNVQxMjowNTowMC4wMDBaIiwicHVyIjoiYmxvYl90b2tlbiJ9fQ==--af763bb4884a5488e212eee0e3d07ee6a4e74776+ url: http://www.example.com/rails/active_storage/disk/eyJfcmFpbHMiOnsiZGF0YSI6eyJrZXkiOiJuem5oOGdra3VxendvbDc1ODBxNHNwZmpmMjVxIiwiY29udGVudF90eXBlIjoiYXBwbGljYXRpb24vcGRmIiwiY29udGVudF9sZW5ndGgiOjUxMjM0LCJjaGVja3N1bSI6IlZqaHowNGxRdUVHdXY0bkR2aHNhTlE9PSIsInNlcnZpY2VfbmFtZSI6InRlc3QifSwiZXhwIjoiMjAyNi0wMS0xNVQxMjowNTowMC4wMDBaIiwicHVyIjoiYmxvYl90b2tlbiJ9fQ==--b784e5b81a3ca734cf4c2881c4b648e328a18d08headers:Content-Type: application/pdf- signed_id: eyJfcmFpbHMiOnsiZGF0YSI6MSwicHVyIjoiYmxvYl9pZCJ9fQ==--f775c2b1a726398884efebb8c4a9d44c7ddcb413+ signed_id: eyJfcmFpbHMiOnsiZGF0YSI6MSwicHVyIjoiYmxvYl9pZCJ9fQ==--4fe52fe717b009e9c724d3fdc38164f29d11b95fschema:"$ref": "#/components/schemas/DirectUploadResponse"requestBody:@@ -15588,9 +15592,8 @@ paths:status: unfulfilledtracking: U10000tracking_url:- tracking_carrier:- tracking_status:fulfilled_at:+ delivered_at:created_at: '2026-01-15T12:00:00.000Z'updated_at: '2026-01-15T12:00:00.000Z'fulfillment_type: shipping@@ -15601,9 +15604,23 @@ paths:quantity: 1line_item_id: li_UkLWZg9DAJvariant_id: variant_UkLWZg9DAJ- name: Product 1469315- sku: SKU-188+ name: Product 1579315+ sku: SKU-199options_text: ''+ deliveries:+ - id: dlv_UkLWZg9DAJ+ tracking_number: U10000+ carrier:+ carrier_name:+ service:+ status: pending+ tracking_url:+ estimated_delivery_at:+ delivered_at:+ created_at: '2026-01-15T12:00:00.000Z'+ updated_at: '2026-01-15T12:00:00.000Z'+ shipping_label_id:+ labels: []schema:type: objectproperties:@@ -15659,9 +15676,8 @@ paths:status: fulfilledtracking: TRACK-1tracking_url:- tracking_carrier:- tracking_status:fulfilled_at: '2026-01-15T12:00:00.000Z'+ delivered_at:created_at: '2026-01-15T12:00:00.000Z'updated_at: '2026-01-15T12:00:00.000Z'fulfillment_type: shipping@@ -15672,9 +15688,23 @@ paths:quantity: 1line_item_id: li_UkLWZg9DAJvariant_id: variant_UkLWZg9DAJ- name: Product 147961- sku: SKU-189+ name: Product 158961+ sku: SKU-200options_text: ''+ deliveries:+ - id: dlv_UkLWZg9DAJ+ tracking_number: TRACK-1+ carrier:+ carrier_name:+ service:+ status: pending+ tracking_url:+ estimated_delivery_at:+ delivered_at:+ created_at: '2026-01-15T12:00:00.000Z'+ updated_at: '2026-01-15T12:00:00.000Z'+ shipping_label_id:+ labels: []schema:"$ref": "#/components/schemas/Fulfillment"requestBody:@@ -15747,9 +15777,8 @@ paths:status: unfulfilledtracking: TRACK-2tracking_url: https://www.ups.com/track?tracknum=TRACK-2- tracking_carrier: ups- tracking_status:fulfilled_at:+ delivered_at:created_at: '2026-01-15T12:00:00.000Z'updated_at: '2026-01-15T12:00:00.000Z'fulfillment_type: shipping@@ -15760,9 +15789,23 @@ paths:quantity: 1line_item_id: li_UkLWZg9DAJvariant_id: variant_UkLWZg9DAJ- name: Product 1483170- sku: SKU-190+ name: Product 1593170+ sku: SKU-201options_text: ''+ deliveries:+ - id: dlv_UkLWZg9DAJ+ tracking_number: TRACK-2+ carrier: ups+ carrier_name: UPS+ service:+ status: pending+ tracking_url: https://www.ups.com/track?tracknum=TRACK-2+ estimated_delivery_at:+ delivered_at:+ created_at: '2026-01-15T12:00:00.000Z'+ updated_at: '2026-01-15T12:00:00.000Z'+ shipping_label_id:+ labels: []schema:"$ref": "#/components/schemas/Fulfillment"requestBody:@@ -15815,9 +15858,8 @@ paths:status: canceledtracking: U10000tracking_url:- tracking_carrier:- tracking_status:fulfilled_at:+ delivered_at:created_at: '2026-01-15T12:00:00.000Z'updated_at: '2026-01-15T12:00:00.000Z'fulfillment_type: shipping@@ -15828,9 +15870,23 @@ paths:quantity: 1line_item_id: li_UkLWZg9DAJvariant_id: variant_UkLWZg9DAJ- name: Product 1497276- sku: SKU-191+ name: Product 1607276+ sku: SKU-202options_text: ''+ deliveries:+ - id: dlv_UkLWZg9DAJ+ tracking_number: U10000+ carrier:+ carrier_name:+ service:+ status: pending+ tracking_url:+ estimated_delivery_at:+ delivered_at:+ created_at: '2026-01-15T12:00:00.000Z'+ updated_at: '2026-01-15T12:00:00.000Z'+ shipping_label_id:+ labels: []schema:"$ref": "#/components/schemas/Fulfillment""/api/v3/seller/tracking_carriers":@@ -15972,7 +16028,7 @@ paths:display_total: "$110.00"items:- id: li_UkLWZg9DAJ- name: Product 15195+ name: Product 16295options_text: ''quantity: 1currency: USD@@ -15981,7 +16037,7 @@ paths:total: '10.0'display_total: "$10.00"variant_id: variant_UkLWZg9DAJ- sku: SKU-193+ sku: SKU-204thumbnail_url:fulfillments:- id: ful_UkLWZg9DAJ@@ -15989,9 +16045,8 @@ paths:status: unfulfilledtracking: U10000tracking_url:- tracking_carrier:- tracking_status:fulfilled_at:+ delivered_at:created_at: '2026-01-15T12:00:00.000Z'updated_at: '2026-01-15T12:00:00.000Z'fulfillment_type: shipping@@ -16002,16 +16057,30 @@ paths:quantity: 1line_item_id: li_UkLWZg9DAJvariant_id: variant_UkLWZg9DAJ- name: Product 15195- sku: SKU-193+ name: Product 16295+ sku: SKU-204options_text: ''+ deliveries:+ - id: dlv_UkLWZg9DAJ+ tracking_number: U10000+ carrier:+ carrier_name:+ service:+ status: pending+ tracking_url:+ estimated_delivery_at:+ delivered_at:+ created_at: '2026-01-15T12:00:00.000Z'+ updated_at: '2026-01-15T12:00:00.000Z'+ shipping_label_id:+ labels: []shipping_address:id: addr_gbHJdmfrXBlabel:first_name: Johnlast_name: Doefull_name: John Doe- address1: 137 Lovely Street+ address1: 159 Lovely Streetaddress2: Northwestpostal_code: '10118'city: New York@@ -16033,7 +16102,7 @@ paths:first_name: Johnlast_name: Doefull_name: John Doe- address1: 136 Lovely Street+ address1: 158 Lovely Streetaddress2: Northwestpostal_code: '10118'city: New York@@ -16122,7 +16191,7 @@ paths:display_total: "$110.00"items:- id: li_UkLWZg9DAJ- name: Product 1529755+ name: Product 1639755options_text: ''quantity: 1currency: USD@@ -16131,7 +16200,7 @@ paths:total: '10.0'display_total: "$10.00"variant_id: variant_UkLWZg9DAJ- sku: SKU-194+ sku: SKU-205thumbnail_url:fulfillments:- id: ful_UkLWZg9DAJ@@ -16139,9 +16208,8 @@ paths:status: unfulfilledtracking: U10000tracking_url:- tracking_carrier:- tracking_status:fulfilled_at:+ delivered_at:created_at: '2026-01-15T12:00:00.000Z'updated_at: '2026-01-15T12:00:00.000Z'fulfillment_type: shipping@@ -16152,16 +16220,30 @@ paths:quantity: 1line_item_id: li_UkLWZg9DAJvariant_id: variant_UkLWZg9DAJ- name: Product 1529755- sku: SKU-194+ name: Product 1639755+ sku: SKU-205options_text: ''+ deliveries:+ - id: dlv_UkLWZg9DAJ+ tracking_number: U10000+ carrier:+ carrier_name:+ service:+ status: pending+ tracking_url:+ estimated_delivery_at:+ delivered_at:+ created_at: '2026-01-15T12:00:00.000Z'+ updated_at: '2026-01-15T12:00:00.000Z'+ shipping_label_id:+ labels: []shipping_address:id: addr_gbHJdmfrXBlabel:first_name: Johnlast_name: Doefull_name: John Doe- address1: 139 Lovely Street+ address1: 161 Lovely Streetaddress2: Northwestpostal_code: '10118'city: New York@@ -16183,7 +16265,7 @@ paths:first_name: Johnlast_name: Doefull_name: John Doe- address1: 138 Lovely Street+ address1: 160 Lovely Streetaddress2: Northwestpostal_code: '10118'city: New York@@ -16264,7 +16346,7 @@ paths:display_total: "$110.00"items:- id: li_UkLWZg9DAJ- name: Product 1556554+ name: Product 1666554options_text: ''quantity: 1currency: USD@@ -16273,7 +16355,7 @@ paths:total: '10.0'display_total: "$10.00"variant_id: variant_UkLWZg9DAJ- sku: SKU-197+ sku: SKU-208thumbnail_url:fulfillments:- id: ful_UkLWZg9DAJ@@ -16281,9 +16363,8 @@ paths:status: canceledtracking: U10000tracking_url:- tracking_carrier:- tracking_status:fulfilled_at:+ delivered_at:created_at: '2026-01-15T12:00:00.000Z'updated_at: '2026-01-15T12:00:00.000Z'fulfillment_type: shipping@@ -16294,16 +16375,30 @@ paths:quantity: 1line_item_id: li_UkLWZg9DAJvariant_id: variant_UkLWZg9DAJ- name: Product 1556554- sku: SKU-197+ name: Product 1666554+ sku: SKU-208options_text: ''+ deliveries:+ - id: dlv_UkLWZg9DAJ+ tracking_number: U10000+ carrier:+ carrier_name:+ service:+ status: pending+ tracking_url:+ estimated_delivery_at:+ delivered_at:+ created_at: '2026-01-15T12:00:00.000Z'+ updated_at: '2026-01-15T12:00:00.000Z'+ shipping_label_id:+ labels: []shipping_address:id: addr_gbHJdmfrXBlabel:first_name: Johnlast_name: Doefull_name: John Doe- address1: 145 Lovely Street+ address1: 167 Lovely Streetaddress2: Northwestpostal_code: '10118'city: New York@@ -16325,7 +16420,7 @@ paths:first_name: Johnlast_name: Doefull_name: John Doe- address1: 144 Lovely Street+ address1: 166 Lovely Streetaddress2: Northwestpostal_code: '10118'city: New York@@ -16525,7 +16620,7 @@ paths:example:error:code: processing_error- message: Only 1 of Product 1677120 can be returned+ message: Only 1 of Product 1787120 can be returnedrequestBody:content:application/json:@@ -18111,6 +18206,54 @@ components:- default- digitalx-typelizer: true+ Delivery:+ type: object+ properties:+ id:+ type: string+ tracking_number:+ type: string+ carrier:+ type: string+ nullable: true+ carrier_name:+ type: string+ nullable: true+ service:+ type: string+ nullable: true+ status:+ type: string+ tracking_url:+ type: string+ nullable: true+ estimated_delivery_at:+ type: string+ nullable: true+ delivered_at:+ type: string+ nullable: true+ created_at:+ type: string+ updated_at:+ type: string+ shipping_label_id:+ type: string+ nullable: true+ required:+ - id+ - tracking_number+ - carrier+ - carrier_name+ - service+ - status+ - tracking_url+ - estimated_delivery_at+ - delivered_at+ - created_at+ - updated_at+ - shipping_label_id+ x-typelizer: trueDeliveryZone:type: objectproperties:@@ -18331,13 +18474,10 @@ components:tracking_url:type: stringnullable: true- tracking_carrier:+ fulfilled_at:type: stringnullable: true- tracking_status:- type: string- nullable: true- fulfilled_at:+ delivered_at:type: stringnullable: truecreated_at:@@ -18357,21 +18497,30 @@ components:type: arrayitems:"$ref": "#/components/schemas/FulfillmentItem"+ deliveries:+ type: array+ items:+ "$ref": "#/components/schemas/Delivery"+ labels:+ type: array+ items:+ "$ref": "#/components/schemas/ShippingLabel"required:- id- number- status- tracking- tracking_url- - tracking_carrier- - tracking_status- fulfilled_at+ - delivered_at- created_at- updated_at- fulfillment_type- delivery_method_name- stock_location_name- fulfillment_items+ - deliveries+ - labelsx-typelizer: trueImportMapping:type: object@@ -19329,6 +19478,84 @@ components:- refundable_total- display_refunded_totalx-typelizer: true+ ShippingLabel:+ type: object+ properties:+ id:+ type: string+ source:+ type: string+ status:+ type: string+ carrier:+ type: string+ nullable: true+ carrier_name:+ type: string+ nullable: true+ service:+ type: string+ nullable: true+ tracking_number:+ type: string+ nullable: true+ currency:+ type: string+ nullable: true+ format:+ type: string+ nullable: true+ external_id:+ type: string+ nullable: true+ metadata:+ type: object+ refunded_at:+ type: string+ nullable: true+ created_at:+ type: string+ updated_at:+ type: string+ owner_id:+ type: string+ owner_type:+ type: string+ cost:+ type: string+ display_cost:+ type: string+ integration_id:+ type: string+ nullable: true+ file_pending:+ type: boolean+ download_url:+ type: string+ nullable: true+ required:+ - id+ - source+ - status+ - carrier+ - carrier_name+ - service+ - tracking_number+ - currency+ - format+ - external_id+ - metadata+ - refunded_at+ - created_at+ - updated_at+ - owner_id+ - owner_type+ - cost+ - display_cost+ - integration_id+ - file_pending+ - download_url+ x-typelizer: trueStockLevel:type: objectproperties:@@ -19417,6 +19644,8 @@ components:type: booleankind:type: string+ returns_enabled:+ type: booleancreated_at:type: stringupdated_at:@@ -19440,6 +19669,7 @@ components:- active- default- kind+ - returns_enabled- created_at- updated_atx-typelizer: truediff --git a/packages/seller-dashboard/src/components/orders/fulfillment-deliveries.tsx b/packages/seller-dashboard/src/components/orders/fulfillment-deliveries.tsxnew file mode 100644index 0000000000..3d88243f23--- /dev/null+++ b/packages/seller-dashboard/src/components/orders/fulfillment-deliveries.tsx@@ -0,0 +1,117 @@+import {+ Button,+ CardContent,+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+ StatusBadge,+ useConfirm,+} from '@spree/dashboard-ui'+import { EllipsisVerticalIcon, PencilIcon, TrashIcon } from '@spree/dashboard-ui/icons'+import type { Delivery } from '@spree/seller-sdk'+import { useTranslation } from 'react-i18next'+import { useFulfillmentActions } from '../../hooks/use-fulfillments'++/**+ * The tracked consignments of one parcel.+ *+ * A parcel usually travels as one, but three boxes or a pallet under a freight+ * PRO number are the same shape — each with its own tracking number and its+ * own carrier status. Confirming arrival is not here: that a parcel landed is+ * the buyer's word, not the sender's, so it stays with the operator.+ */+export function FulfillmentDeliveries({+ orderId,+ fulfillmentId,+ deliveries,+ onEdit,+}: {+ orderId: string+ fulfillmentId: string+ deliveries: Delivery[]+ onEdit: (delivery: Delivery) => void+}) {+ const { t } = useTranslation()+ const confirm = useConfirm()+ const { deleteDelivery } = useFulfillmentActions(orderId)++ if (deliveries.length === 0) return null++ async function handleDelete(delivery: Delivery) {+ const ok = await confirm({+ message: t('orders.fulfillments.confirm_delete_delivery'),+ variant: 'destructive',+ confirmLabel: t('common.delete'),+ })+ if (!ok) return+ deleteDelivery.mutate({ fulfillmentId, deliveryId: delivery.id })+ }++ return (+ <CardContent className="flex flex-col gap-2 border-b py-3 text-sm">+ {deliveries.map((delivery) => (+ <div key={delivery.id} className="flex flex-wrap items-center justify-between gap-2">+ <div className="flex min-w-0 flex-wrap items-center gap-2">+ <span className="text-muted-foreground">+ {delivery.carrier_name ?? t('orders.tracking_label')}:+ </span>+ {delivery.tracking_url ? (+ <a+ href={delivery.tracking_url}+ target="_blank"+ rel="noopener noreferrer"+ className="truncate underline"+ >+ {delivery.tracking_number}+ </a>+ ) : (+ <span className="truncate">{delivery.tracking_number}</span>+ )}+ <StatusBadge+ status={delivery.status}+ label={t(`orders.fulfillments.carrier_status_${delivery.status}`, {+ defaultValue: delivery.status,+ })}+ />+ </div>++ <DropdownMenu>+ <DropdownMenuTrigger+ render={+ <Button variant="ghost" size="icon" aria-label={t('common.actions')}>+ <EllipsisVerticalIcon className="size-4" />+ </Button>+ }+ />+ <DropdownMenuContent align="end">+ <DropdownMenuItem onClick={() => onEdit(delivery)}>+ <PencilIcon className="size-4" />+ {t('common.edit')}+ </DropdownMenuItem>++ {/* Two consignments are not removable: one a label minted, since+ the label records what was bought, and one that arrived,+ since its arrival is what the returns window counts from. The+ server refuses both; this keeps the menu honest. */}+ {!delivery.shipping_label_id && delivery.status !== 'delivered' && (+ <>+ <DropdownMenuSeparator />+ <DropdownMenuItem+ variant="destructive"+ disabled={deleteDelivery.isPending}+ onClick={() => handleDelete(delivery)}+ >+ <TrashIcon className="size-4" />+ {t('common.delete')}+ </DropdownMenuItem>+ </>+ )}+ </DropdownMenuContent>+ </DropdownMenu>+ </div>+ ))}+ </CardContent>+ )+}diff --git a/packages/seller-dashboard/src/components/orders/fulfillment-delivery-dialog.tsx b/packages/seller-dashboard/src/components/orders/fulfillment-delivery-dialog.tsxnew file mode 100644index 0000000000..1067f5ed6b--- /dev/null+++ b/packages/seller-dashboard/src/components/orders/fulfillment-delivery-dialog.tsx@@ -0,0 +1,205 @@+import { zodResolver } from '@hookform/resolvers/zod'+import { mapSpreeErrorsToForm } from '@spree/dashboard-core'+import {+ Button,+ Combobox,+ ComboboxButtonTrigger,+ ComboboxContent,+ ComboboxEmpty,+ ComboboxItem,+ ComboboxList,+ ComboboxSearch,+ ComboboxTriggerPlaceholder,+ ComboboxValue,+ Dialog,+ DialogBody,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+ Field,+ FieldError,+ FieldLabel,+ Input,+} from '@spree/dashboard-ui'+import type { Delivery } from '@spree/seller-sdk'+import { Controller, useForm } from 'react-hook-form'+import { useTranslation } from 'react-i18next'+import { z } from 'zod/v4'+import { useFulfillmentActions } from '../../hooks/use-fulfillments'+import { useTrackingCarriers } from '../../hooks/use-reasons'++const deliverySchema = z.object({+ tracking_number: z.string().min(1),+ // Free text: a forwarder's own name is as valid as a registered carrier,+ // and an empty value asks the server to detect one from the number.+ carrier: z.string(),+})++type DeliveryFormValues = z.infer<typeof deliverySchema>++/**+ * Adds or corrects one consignment of a parcel.+ *+ * A parcel can travel as several — three boxes, or a pallet under a freight+ * PRO number — and each carries its own tracking number and carrier status.+ */+export function FulfillmentDeliveryDialog({+ orderId,+ fulfillmentId,+ delivery,+ open,+ onOpenChange,+}: {+ orderId: string+ fulfillmentId: string+ delivery?: Delivery+ open: boolean+ onOpenChange: (open: boolean) => void+}) {+ const { t } = useTranslation()+ const { createDelivery, updateDelivery } = useFulfillmentActions(orderId)+ const { data: carriersData } = useTrackingCarriers(open)++ // Options carry the carrier's key, not its display name — seeding the field+ // with a label would rewrite a known carrier to its own name on the next+ // save. Anything not on the list is kept as typed.+ const carrierOptions = (carriersData?.data ?? []).map((carrier) => ({+ value: carrier.id,+ label: carrier.name,+ }))++ const carrierLabel = (value: string) =>+ carrierOptions.find((option) => option.value === value)?.label ?? value++ const form = useForm<DeliveryFormValues>({+ resolver: zodResolver(deliverySchema),+ defaultValues: {+ tracking_number: delivery?.tracking_number ?? '',+ carrier: delivery?.carrier ?? '',+ },+ })++ const pending = createDelivery.isPending || updateDelivery.isPending++ async function onSubmit(values: DeliveryFormValues) {+ const tracking_number = values.tracking_number.trim()+ const carrier = values.carrier.trim()++ try {+ if (delivery) {+ await updateDelivery.mutateAsync({+ fulfillmentId,+ deliveryId: delivery.id,+ tracking_number,+ carrier,+ })+ } else {+ await createDelivery.mutateAsync({+ fulfillmentId,+ tracking_number,+ carrier: carrier || undefined,+ })+ }+ onOpenChange(false)+ } catch (err) {+ if (!mapSpreeErrorsToForm(err, form.setError)) throw err+ }+ }++ return (+ <Dialog open={open} onOpenChange={onOpenChange}>+ <DialogContent>+ <form+ onSubmit={(event) => {+ // The order page renders its cards inside their own forms — without+ // stopping the bubble the browser submits the outer one.+ form.handleSubmit(onSubmit)(event)+ event.stopPropagation()+ }}+ >+ <DialogHeader>+ <DialogTitle>+ {delivery+ ? t('orders.fulfillments.edit_tracking_title')+ : t('orders.fulfillments.add_tracking_title')}+ </DialogTitle>+ <DialogDescription>{t('orders.fulfillments.tracking_description')}</DialogDescription>+ </DialogHeader>++ <DialogBody className="flex flex-col gap-4">+ {form.formState.errors.root?.message && (+ <p className="text-sm text-destructive" role="alert">+ {form.formState.errors.root.message}+ </p>+ )}++ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">+ <Field>+ <FieldLabel htmlFor="delivery-tracking-number">+ {t('orders.tracking_label')}+ </FieldLabel>+ <Input+ id="delivery-tracking-number"+ placeholder={t('orders.tracking_placeholder')}+ aria-invalid={!!form.formState.errors.tracking_number}+ {...form.register('tracking_number')}+ />+ <FieldError errors={[form.formState.errors.tracking_number]} />+ </Field>++ <Field>+ <FieldLabel htmlFor="delivery-carrier">+ {t('orders.fulfillments.carrier_label')}+ </FieldLabel>+ <Controller+ control={form.control}+ name="carrier"+ render={({ field }) => (+ <Combobox+ items={carrierOptions.map((option) => option.value)}+ value={field.value}+ onValueChange={(value: string | null) => field.onChange(value ?? '')}+ itemToStringLabel={carrierLabel}+ >+ <ComboboxButtonTrigger id="delivery-carrier" onBlur={field.onBlur}>+ {field.value ? (+ <ComboboxValue />+ ) : (+ <ComboboxTriggerPlaceholder>+ {t('orders.fulfillments.carrier_auto')}+ </ComboboxTriggerPlaceholder>+ )}+ </ComboboxButtonTrigger>+ <ComboboxContent>+ <ComboboxSearch placeholder={t('orders.fulfillments.carrier_search')} />+ <ComboboxEmpty>{t('common.no_results')}</ComboboxEmpty>+ <ComboboxList>+ {(value: string) => (+ <ComboboxItem key={value} value={value}>+ {carrierLabel(value)}+ </ComboboxItem>+ )}+ </ComboboxList>+ </ComboboxContent>+ </Combobox>+ )}+ />+ </Field>+ </div>+ </DialogBody>++ <DialogFooter>+ <Button type="button" variant="outline" onClick={() => onOpenChange(false)}>+ {t('common.cancel')}+ </Button>+ <Button type="submit" disabled={pending}>+ {pending ? t('common.saving') : t('common.save')}+ </Button>+ </DialogFooter>+ </form>+ </DialogContent>+ </Dialog>+ )+}diff --git a/packages/seller-dashboard/src/components/orders/fulfillment-label-upload-dialog.tsx b/packages/seller-dashboard/src/components/orders/fulfillment-label-upload-dialog.tsxnew file mode 100644index 0000000000..f37f804380--- /dev/null+++ b/packages/seller-dashboard/src/components/orders/fulfillment-label-upload-dialog.tsx@@ -0,0 +1,234 @@+import { zodResolver } from '@hookform/resolvers/zod'+import {+ EMPTY_FILE_UPLOAD_VALUE,+ FileUploadField,+ type FileUploadValue,+ mapSpreeErrorsToForm,+} from '@spree/dashboard-core'+import {+ Button,+ Combobox,+ ComboboxButtonTrigger,+ ComboboxContent,+ ComboboxEmpty,+ ComboboxItem,+ ComboboxList,+ ComboboxSearch,+ ComboboxTriggerPlaceholder,+ ComboboxValue,+ Dialog,+ DialogBody,+ DialogContent,+ DialogDescription,+ DialogFooter,+ DialogHeader,+ DialogTitle,+ Field,+ FieldError,+ FieldLabel,+ Input,+ InputGroup,+ InputGroupAddon,+ InputGroupInput,+ InputGroupText,+} from '@spree/dashboard-ui'+import { useState } from 'react'+import { Controller, useForm } from 'react-hook-form'+import { useTranslation } from 'react-i18next'+import { z } from 'zod/v4'+import { useFulfillmentActions } from '../../hooks/use-fulfillments'+import { useTrackingCarriers } from '../../hooks/use-reasons'++/** What a carrier label plausibly arrives as — mirrors the server allowlist. */+const LABEL_ACCEPT = 'application/pdf,image/png,text/plain'++const uploadSchema = z.object({+ tracking_number: z.string().min(1),+ carrier: z.string(),+ cost: z.string(),+})++type UploadFormValues = z.infer<typeof uploadSchema>++/**+ * Records postage the seller bought elsewhere — from a carrier's own site, or+ * a 3PL's PDF — so the parcel still has its file, its tracking number and what+ * it cost, with no carrier account connected.+ *+ * Buying and refunding are not here: both run through the marketplace's+ * carrier account, and the endpoint refuses them.+ */+export function FulfillmentLabelUploadDialog({+ orderId,+ fulfillmentId,+ currency,+ open,+ onOpenChange,+}: {+ orderId: string+ fulfillmentId: string+ currency: string+ open: boolean+ onOpenChange: (open: boolean) => void+}) {+ const { t } = useTranslation()+ const { uploadLabel } = useFulfillmentActions(orderId)+ const { data: carriersData } = useTrackingCarriers(open)++ // The registry's carriers, stored by key and shown by name. Anything it does+ // not know is kept as typed — a forwarder is as real a carrier — and an+ // empty value asks the server to detect one.+ const carrierOptions = (carriersData?.data ?? []).map((carrier) => ({+ value: carrier.id,+ label: carrier.name,+ }))++ const carrierLabel = (value: string) =>+ carrierOptions.find((option) => option.value === value)?.label ?? value++ const [file, setFile] = useState<FileUploadValue>(EMPTY_FILE_UPLOAD_VALUE)++ const form = useForm<UploadFormValues>({+ resolver: zodResolver(uploadSchema),+ defaultValues: { tracking_number: '', carrier: '', cost: '' },+ })++ async function onSubmit(values: UploadFormValues) {+ // Guarded here as well as on the server: submitting without one would+ // silently record a label with no file behind it.+ if (!file.signedId) {+ form.setError('root', { message: t('orders.fulfillments.upload_label_file') })+ return+ }++ try {+ await uploadLabel.mutateAsync({+ fulfillmentId,+ file: file.signedId,+ tracking_number: values.tracking_number.trim(),+ carrier: values.carrier.trim() || undefined,+ cost: values.cost.trim() || undefined,+ currency: values.cost.trim() ? currency : undefined,+ })+ onOpenChange(false)+ } catch (err) {+ if (!mapSpreeErrorsToForm(err, form.setError)) throw err+ }+ }++ return (+ <Dialog open={open} onOpenChange={onOpenChange}>+ <DialogContent>+ <form+ onSubmit={(event) => {+ // The order page renders its cards inside their own forms — without+ // stopping the bubble the browser submits the outer one.+ form.handleSubmit(onSubmit)(event)+ event.stopPropagation()+ }}+ >+ <DialogHeader>+ <DialogTitle>{t('orders.fulfillments.upload_label_title')}</DialogTitle>+ <DialogDescription>+ {t('orders.fulfillments.upload_label_description')}+ </DialogDescription>+ </DialogHeader>++ <DialogBody className="flex flex-col gap-4">+ {form.formState.errors.root?.message && (+ <p className="text-sm text-destructive" role="alert">+ {form.formState.errors.root.message}+ </p>+ )}++ <Field>+ <FieldLabel>{t('orders.fulfillments.upload_label_file')}</FieldLabel>+ <FileUploadField accept={LABEL_ACCEPT} value={file} onChange={setFile} />+ </Field>++ <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">+ <Field>+ <FieldLabel htmlFor="label-tracking-number">+ {t('orders.tracking_label')}+ </FieldLabel>+ <Input+ id="label-tracking-number"+ placeholder={t('orders.tracking_placeholder')}+ aria-invalid={!!form.formState.errors.tracking_number}+ {...form.register('tracking_number')}+ />+ <FieldError errors={[form.formState.errors.tracking_number]} />+ </Field>++ <Field>+ <FieldLabel htmlFor="label-carrier">+ {t('orders.fulfillments.carrier_label')}+ </FieldLabel>+ <Controller+ control={form.control}+ name="carrier"+ render={({ field }) => (+ <Combobox+ items={carrierOptions.map((option) => option.value)}+ value={field.value}+ onValueChange={(value: string | null) => field.onChange(value ?? '')}+ itemToStringLabel={carrierLabel}+ >+ <ComboboxButtonTrigger id="label-carrier" onBlur={field.onBlur}>+ {field.value ? (+ <ComboboxValue />+ ) : (+ <ComboboxTriggerPlaceholder>+ {t('orders.fulfillments.carrier_auto')}+ </ComboboxTriggerPlaceholder>+ )}+ </ComboboxButtonTrigger>+ <ComboboxContent>+ <ComboboxSearch placeholder={t('orders.fulfillments.carrier_search')} />+ <ComboboxEmpty>{t('common.no_results')}</ComboboxEmpty>+ <ComboboxList>+ {(value: string) => (+ <ComboboxItem key={value} value={value}>+ {carrierLabel(value)}+ </ComboboxItem>+ )}+ </ComboboxList>+ </ComboboxContent>+ </Combobox>+ )}+ />+ </Field>+ </div>++ <Field>+ <FieldLabel htmlFor="label-cost">+ {t('orders.fulfillments.label_cost_label')}+ </FieldLabel>+ <InputGroup>+ <InputGroupAddon>+ <InputGroupText>{currency}</InputGroupText>+ </InputGroupAddon>+ <InputGroupInput+ id="label-cost"+ type="number"+ step="0.01"+ min={0}+ {...form.register('cost')}+ />+ </InputGroup>+ </Field>+ </DialogBody>++ <DialogFooter>+ <Button type="button" variant="outline" onClick={() => onOpenChange(false)}>+ {t('common.cancel')}+ </Button>+ <Button type="submit" disabled={uploadLabel.isPending}>+ {uploadLabel.isPending ? t('common.saving') : t('common.save')}+ </Button>+ </DialogFooter>+ </form>+ </DialogContent>+ </Dialog>+ )+}diff --git a/packages/seller-dashboard/src/components/orders/fulfillment-tracking-dialog.tsx b/packages/seller-dashboard/src/components/orders/fulfillment-tracking-dialog.tsxdeleted file mode 100644index 429b5f2dce..0000000000--- a/packages/seller-dashboard/src/components/orders/fulfillment-tracking-dialog.tsx+++ /dev/null@@ -1,155 +0,0 @@-import { zodResolver } from '@hookform/resolvers/zod'-import { mapSpreeErrorsToForm } from '@spree/dashboard-core'-import {- Button,- Dialog,- DialogBody,- DialogContent,- DialogDescription,- DialogFooter,- DialogHeader,- DialogTitle,- Field,- FieldError,- FieldLabel,- Input,- Select,- SelectContent,- SelectItem,- SelectTrigger,- SelectValue,-} from '@spree/dashboard-ui'-import type { Fulfillment } from '@spree/seller-sdk'-import { Controller, useForm } from 'react-hook-form'-import { useTranslation } from 'react-i18next'-import { useFulfillmentActions } from '../../hooks/use-fulfillments'-import { useTrackingCarriers } from '../../hooks/use-reasons'-import { type TrackingFormValues, trackingFormSchema } from '../../schemas/fulfillment'--/**- * Adds or corrects a parcel's tracking number after it has gone out.- *- * Separate from marking it shipped: a seller who mistyped a number, or who- * only got it from the post office afterwards, is not shipping the parcel- * again.- */-export function FulfillmentTrackingDialog({- orderId,- fulfillment,- open,- onOpenChange,-}: {- orderId: string- fulfillment: Fulfillment- open: boolean- onOpenChange: (open: boolean) => void-}) {- const { t } = useTranslation()- const { update } = useFulfillmentActions(orderId)- const { data: carriersData } = useTrackingCarriers(open)-- const carrierOptions = [- // '' means "work it out from the number" — the server pins the carrier- // itself when the format is recognisable.- { value: '', label: t('orders.fulfillments.carrier_auto') },- ...(carriersData?.data ?? []).map((option) => ({ value: option.id, label: option.name })),- ]-- const form = useForm<TrackingFormValues>({- resolver: zodResolver(trackingFormSchema),- defaultValues: {- tracking: fulfillment.tracking ?? '',- // The carrier lives on the parcel's consignment since 6.0; `tracking`- // on the fulfillment summarizes the first of them.- tracking_carrier: fulfillment.deliveries?.[0]?.carrier ?? '',- },- })-- async function onSubmit(values: TrackingFormValues) {- try {- await update.mutateAsync({- fulfillmentId: fulfillment.id,- tracking: values.tracking.trim(),- tracking_carrier: values.tracking_carrier,- })- onOpenChange(false)- } catch (err) {- if (!mapSpreeErrorsToForm(err, form.setError)) throw err- }- }-- return (- <Dialog open={open} onOpenChange={onOpenChange}>- <DialogContent>- <form onSubmit={form.handleSubmit(onSubmit)}>- <DialogHeader>- <DialogTitle>- {fulfillment.tracking- ? t('orders.fulfillments.edit_tracking_title')- : t('orders.fulfillments.add_tracking_title')}- </DialogTitle>- <DialogDescription>{t('orders.fulfillments.tracking_description')}</DialogDescription>- </DialogHeader>-- <DialogBody>- {form.formState.errors.root?.message && (- <p className="text-sm text-destructive" role="alert">- {form.formState.errors.root.message}- </p>- )}-- <div className="grid grid-cols-1 gap-4 sm:grid-cols-2">- <Field>- <FieldLabel htmlFor="tracking-number">{t('orders.tracking_label')}</FieldLabel>- <Input- id="tracking-number"- placeholder={t('orders.tracking_placeholder')}- aria-invalid={!!form.formState.errors.tracking}- {...form.register('tracking')}- />- <FieldError errors={[form.formState.errors.tracking]} />- </Field>-- <Field>- <FieldLabel htmlFor="tracking-carrier">- {t('orders.fulfillments.carrier_label')}- </FieldLabel>- <Controller- control={form.control}- name="tracking_carrier"- render={({ field }) => (- <Select- items={carrierOptions}- value={field.value}- onValueChange={(value) => field.onChange(value ?? '')}- >- <SelectTrigger id="tracking-carrier">- <SelectValue />- </SelectTrigger>- <SelectContent>- {carrierOptions.map((option) => (- <SelectItem key={option.value} value={option.value}>- {option.label}- </SelectItem>- ))}- </SelectContent>- </Select>- )}- />- </Field>- </div>- </DialogBody>-- <DialogFooter>- <Button type="button" variant="outline" onClick={() => onOpenChange(false)}>- {t('common.cancel')}- </Button>- <Button type="submit" disabled={update.isPending}>- {update.isPending ? t('common.saving') : t('common.save')}- </Button>- </DialogFooter>- </form>- </DialogContent>- </Dialog>- )-}diff --git a/packages/seller-dashboard/src/components/orders/fulfillments-card.tsx b/packages/seller-dashboard/src/components/orders/fulfillments-card.tsxindex 7422ac2919..324bde5ba5 100644--- a/packages/seller-dashboard/src/components/orders/fulfillments-card.tsx+++ b/packages/seller-dashboard/src/components/orders/fulfillments-card.tsx@@ -14,14 +14,17 @@ import {useConfirm,} from '@spree/dashboard-ui'import { EllipsisVerticalIcon, MapPinIcon, TruckIcon } from '@spree/dashboard-ui/icons'-import type { Fulfillment, Order } from '@spree/seller-sdk'+import type { Delivery, Fulfillment, Order } from '@spree/seller-sdk'import { useState } from 'react'import { useTranslation } from 'react-i18next'import { useFulfillmentActions } from '../../hooks/use-fulfillments'+import { FulfillmentDeliveries } from './fulfillment-deliveries'+import { FulfillmentDeliveryDialog } from './fulfillment-delivery-dialog'import { FulfillmentFulfillForm } from './fulfillment-fulfill-form'+import { FulfillmentLabelUploadDialog } from './fulfillment-label-upload-dialog'import { FulfillmentSplitDialog } from './fulfillment-split-dialog'-import { FulfillmentTrackingDialog } from './fulfillment-tracking-dialog'import { unitLabel } from './line-label'+import { ShippingLabelRow } from './shipping-label-row'// A parcel that has not gone out is the only one still to ship or cancel;// one that has is the only one that can be confirmed delivered. Reading@@ -56,7 +59,12 @@ export function FulfillmentsCard({ order }: { order: Order }) {<p className="text-muted-foreground text-sm">{t('orders.fulfillments.empty')}</p>) : (fulfillments.map((fulfillment) => (- <FulfillmentRow key={fulfillment.id} orderId={order.id} fulfillment={fulfillment} />+ <FulfillmentRow+ key={fulfillment.id}+ orderId={order.id}+ currency={order.currency}+ fulfillment={fulfillment}+ />)))}</CardContent>@@ -64,13 +72,23 @@ export function FulfillmentsCard({ order }: { order: Order }) {)}-function FulfillmentRow({ orderId, fulfillment }: { orderId: string; fulfillment: Fulfillment }) {+function FulfillmentRow({+ orderId,+ currency,+ fulfillment,+}: {+ orderId: string+ currency: string+ fulfillment: Fulfillment+}) {const { t } = useTranslation()const confirm = useConfirm()const { cancel } = useFulfillmentActions(orderId)const [shipping, setShipping] = useState(false)- const [trackingOpen, setTrackingOpen] = useState(false)+ const [deliveryOpen, setDeliveryOpen] = useState(false)+ const [editingDelivery, setEditingDelivery] = useState<Delivery | undefined>()+ const [labelOpen, setLabelOpen] = useState(false)const [splitOpen, setSplitOpen] = useState(false)const status = fulfillment.status ?? ''@@ -107,10 +125,16 @@ function FulfillmentRow({ orderId, fulfillment }: { orderId: string; fulfillment}/><DropdownMenuContent align="end">- <DropdownMenuItem onClick={() => setTrackingOpen(true)}>- {fulfillment.tracking- ? t('orders.fulfillments.edit_tracking')- : t('orders.fulfillments.add_tracking')}+ <DropdownMenuItem+ onClick={() => {+ setEditingDelivery(undefined)+ setDeliveryOpen(true)+ }}+ >+ {t('orders.fulfillments.add_delivery')}+ </DropdownMenuItem>+ <DropdownMenuItem onClick={() => setLabelOpen(true)}>+ {t('orders.fulfillments.upload_label')}</DropdownMenuItem>{splittable && (<DropdownMenuItem onClick={() => setSplitOpen(true)}>@@ -134,6 +158,25 @@ function FulfillmentRow({ orderId, fulfillment }: { orderId: string; fulfillment</CardAction></CardHeader>+ {(fulfillment.labels ?? []).map((label) => (+ <ShippingLabelRow+ key={label.id}+ orderId={orderId}+ fulfillmentId={fulfillment.id}+ label={label}+ />+ ))}++ <FulfillmentDeliveries+ orderId={orderId}+ fulfillmentId={fulfillment.id}+ deliveries={fulfillment.deliveries ?? []}+ onEdit={(delivery) => {+ setEditingDelivery(delivery)+ setDeliveryOpen(true)+ }}+ />+<CardContent className="flex flex-col gap-3">{fulfillment.stock_location_name && (<p className="flex items-center gap-1.5 text-muted-foreground text-sm">@@ -161,25 +204,6 @@ function FulfillmentRow({ orderId, fulfillment }: { orderId: string; fulfillment</div>))}- {fulfillment.tracking && (- <p className="text-sm">- {t('orders.tracking', { number: fulfillment.tracking })}- {fulfillment.tracking_url && (- <>- {' · '}- <a- href={fulfillment.tracking_url}- target="_blank"- rel="noreferrer"- className="underline"- >- {t('orders.fulfillments.track_parcel')}- </a>- </>- )}- </p>- )}-{shippable && (<div className="flex justify-end"><Button type="button" onClick={() => setShipping(true)}>@@ -191,16 +215,29 @@ function FulfillmentRow({ orderId, fulfillment }: { orderId: string; fulfillment)}</CardContent>- {/* Mounted only while open, so the form seeds from the parcel as it is- now. Left mounted, its defaults froze at first render — and after- shipping through the fulfil form, "Edit tracking" would open empty- and save that emptiness over a real number. */}- {trackingOpen && (- <FulfillmentTrackingDialog+ {/* Mounted only while open, so each form seeds from the parcel as it is+ now. Left mounted, their defaults froze at first render — and after+ shipping, an edit would open empty and save that emptiness over a+ real number. */}+ {deliveryOpen && (+ <FulfillmentDeliveryDialogorderId={orderId}- fulfillment={fulfillment}+ fulfillmentId={fulfillment.id}+ delivery={editingDelivery}+ open+ onOpenChange={(next) => {+ setDeliveryOpen(next)+ if (!next) setEditingDelivery(undefined)+ }}+ />+ )}+ {labelOpen && (+ <FulfillmentLabelUploadDialog+ orderId={orderId}+ fulfillmentId={fulfillment.id}+ currency={currency}open- onOpenChange={setTrackingOpen}+ onOpenChange={setLabelOpen}/>)}{splittable && (diff --git a/packages/seller-dashboard/src/components/orders/shipping-label-row.tsx b/packages/seller-dashboard/src/components/orders/shipping-label-row.tsxnew file mode 100644index 0000000000..8363acc0d1--- /dev/null+++ b/packages/seller-dashboard/src/components/orders/shipping-label-row.tsx@@ -0,0 +1,116 @@+import { downloadFromApi, getApiClient, useAuth } from '@spree/dashboard-core'+import {+ Badge,+ Button,+ CardContent,+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+ useConfirm,+} from '@spree/dashboard-ui'+import {+ EllipsisVerticalIcon,+ PrinterIcon,+ ReceiptTextIcon,+ TrashIcon,+} from '@spree/dashboard-ui/icons'+import type { ShippingLabel } from '@spree/seller-sdk'+import { useTranslation } from 'react-i18next'+import { useFulfillmentActions } from '../../hooks/use-fulfillments'++/**+ * The label bound to a parcel: what it cost and how to print it.+ *+ * Refunding is absent by design — postage bought through the marketplace's+ * carrier account is the operator's to reverse, and the endpoint refuses it.+ * Only a label the seller uploaded can be removed, since that is the only one+ * no carrier holds a record of.+ */+export function ShippingLabelRow({+ orderId,+ fulfillmentId,+ label,+}: {+ orderId: string+ fulfillmentId: string+ label: ShippingLabel+}) {+ const { t } = useTranslation()+ const { token } = useAuth()+ const confirm = useConfirm()+ const { deleteLabel } = useFulfillmentActions(orderId)++ const deletable = label.source === 'uploaded'++ async function print() {+ if (!label.download_url) return++ await downloadFromApi(+ token,+ label.download_url,+ `${label.tracking_number ?? 'label'}.${label.format ?? 'pdf'}`,+ getApiClient().downloadHeaders?.() ?? {},+ )+ }++ async function handleDelete() {+ const ok = await confirm({+ message: t('orders.fulfillments.confirm_delete_label'),+ variant: 'destructive',+ confirmLabel: t('common.delete'),+ })+ if (!ok) return+ deleteLabel.mutate({ fulfillmentId, labelId: label.id })+ }++ return (+ <CardContent className="flex flex-wrap items-center justify-between gap-2 border-b py-3 text-sm">+ <div className="flex flex-wrap items-center gap-2">+ <ReceiptTextIcon className="size-4 text-muted-foreground" />+ <span className="text-muted-foreground">{t('orders.fulfillments.label_title')}</span>+ {label.source === 'uploaded' && (+ <Badge variant="secondary">{t('orders.fulfillments.label_uploaded')}</Badge>+ )}+ {label.display_cost && (+ <span className="text-muted-foreground">+ {t('orders.fulfillments.label_cost', { amount: label.display_cost })}+ </span>+ )}+ </div>++ <div className="flex items-center gap-1">+ {label.download_url && (+ <Button type="button" variant="outline" size="sm" onClick={print}>+ <PrinterIcon className="size-4" />+ {t('orders.fulfillments.print_label')}+ </Button>+ )}++ {deletable && (+ <DropdownMenu>+ <DropdownMenuTrigger+ render={+ <Button variant="ghost" size="icon" aria-label={t('common.actions')}>+ <EllipsisVerticalIcon className="size-4" />+ </Button>+ }+ />+ <DropdownMenuContent align="end">+ <DropdownMenuSeparator />+ <DropdownMenuItem+ variant="destructive"+ disabled={deleteLabel.isPending}+ onClick={handleDelete}+ >+ <TrashIcon className="size-4" />+ {t('orders.fulfillments.delete_label')}+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ )}+ </div>+ </CardContent>+ )+}diff --git a/packages/seller-dashboard/src/hooks/use-fulfillments.ts b/packages/seller-dashboard/src/hooks/use-fulfillments.tsindex be3a43297a..98f3886a43 100644--- a/packages/seller-dashboard/src/hooks/use-fulfillments.ts+++ b/packages/seller-dashboard/src/hooks/use-fulfillments.ts@@ -72,5 +72,82 @@ export function useFulfillmentActions(orderId: string) {}) => sellerClient().orders.fulfillments.split(orderId, fulfillmentId, params),)- return { fulfill, update, cancel, split }+ // A parcel's consignments. One parcel usually travels as one, but three+ // boxes or a pallet under a freight PRO number are the same shape, and each+ // carries its own tracking number and carrier status.+ const createDelivery = useFulfillmentMutation(+ ({+ fulfillmentId,+ ...params+ }: {+ fulfillmentId: string+ tracking_number: string+ carrier?: string+ service?: string+ tracking_url?: string+ }) => sellerClient().orders.fulfillments.deliveries.create(orderId, fulfillmentId, params),+ )++ const updateDelivery = useFulfillmentMutation(+ ({+ fulfillmentId,+ deliveryId,+ ...params+ }: {+ fulfillmentId: string+ deliveryId: string+ tracking_number?: string+ carrier?: string+ service?: string+ tracking_url?: string+ }) =>+ sellerClient().orders.fulfillments.deliveries.update(+ orderId,+ fulfillmentId,+ deliveryId,+ params,+ ),+ )++ const deleteDelivery = useFulfillmentMutation(+ ({ fulfillmentId, deliveryId }: { fulfillmentId: string; deliveryId: string }) =>+ sellerClient().orders.fulfillments.deliveries.delete(orderId, fulfillmentId, deliveryId),+ )++ // Postage the seller bought elsewhere and is recording here. Buying and+ // refunding run through the operator's carrier account, so neither is+ // offered — the endpoint refuses both.+ const uploadLabel = useFulfillmentMutation(+ ({+ fulfillmentId,+ ...params+ }: {+ fulfillmentId: string+ file: string+ // Required: a label with no tracking number is refused server-side,+ // since nothing could then follow the parcel it prints.+ tracking_number: string+ carrier?: string+ service?: string+ cost?: string+ currency?: string+ }) => sellerClient().orders.fulfillments.labels.create(orderId, fulfillmentId, params),+ )++ const deleteLabel = useFulfillmentMutation(+ ({ fulfillmentId, labelId }: { fulfillmentId: string; labelId: string }) =>+ sellerClient().orders.fulfillments.labels.delete(orderId, fulfillmentId, labelId),+ )++ return {+ fulfill,+ update,+ cancel,+ split,+ createDelivery,+ updateDelivery,+ deleteDelivery,+ uploadLabel,+ deleteLabel,+ }}diff --git a/packages/seller-dashboard/src/hooks/use-stock-locations.ts b/packages/seller-dashboard/src/hooks/use-stock-locations.tsnew file mode 100644index 0000000000..45a16edb5e--- /dev/null+++ b/packages/seller-dashboard/src/hooks/use-stock-locations.ts@@ -0,0 +1,23 @@+import { useResourceKey } from '@spree/dashboard-core'+import { useQuery } from '@tanstack/react-query'+import { sellerClient } from '../api-client'++/**+ * Where this seller keeps stock.+ *+ * Deliberately not `useStockLocations` from `@spree/dashboard-core`: that one+ * reads the admin client and would answer with the marketplace's warehouses+ * too, so a seller moving a parcel could pick a shelf that is not theirs. The+ * seller endpoint is rooted in `current_seller.stock_locations`, so the list+ * is theirs by construction rather than by filtering here.+ *+ * Slow-moving, so one fetch serves every dialog on the page.+ */+export function useStockLocations(enabled = true) {+ return useQuery({+ queryKey: useResourceKey('seller-stock-locations'),+ queryFn: () => sellerClient().stockLocations.list({ limit: 100 }),+ staleTime: 5 * 60 * 1000,+ enabled,+ })+}diff --git a/packages/seller-dashboard/src/locales/en.json b/packages/seller-dashboard/src/locales/en.jsonindex 1a01cea8a4..df7c11b573 100644--- a/packages/seller-dashboard/src/locales/en.json+++ b/packages/seller-dashboard/src/locales/en.json@@ -99,7 +99,8 @@"retry": "Try again","save": "Save","saving": "Saving…",- "actions": "Actions"+ "actions": "Actions",+ "edit": "Edit"},"delivery_methods": {"add": "Add delivery method",@@ -311,7 +312,30 @@"split_item": "Item","split_quantity": "Quantity to move","split_would_empty": "Moving everything would leave this parcel empty.",- "confirm_split": "This takes effect immediately."+ "confirm_split": "This takes effect immediately.",+ "add_delivery": "Add tracking number",+ "carrier_search": "Search carriers…",+ "confirm_delete_delivery": "Remove this tracking number?",+ "carrier_status_pending": "Pending",+ "carrier_status_pre_transit": "Pre-transit",+ "carrier_status_in_transit": "In transit",+ "carrier_status_out_for_delivery": "Out for delivery",+ "carrier_status_available_for_pickup": "Available for pickup",+ "carrier_status_delivered": "Delivered",+ "carrier_status_return_to_sender": "Return to sender",+ "carrier_status_failure": "Failed",+ "carrier_status_unknown": "Unknown",+ "upload_label": "Upload postage",+ "upload_label_title": "Upload postage",+ "upload_label_description": "Record a label you bought elsewhere, so the parcel carries its file and tracking number.",+ "upload_label_file": "Label file",+ "label_title": "Label",+ "label_uploaded": "Uploaded",+ "label_cost": "Cost {{amount}}",+ "label_cost_label": "What it cost",+ "print_label": "Print label",+ "delete_label": "Remove label",+ "confirm_delete_label": "Remove this label? The file is deleted and cannot be printed again."},"summary": {"title": "Summary",diff --git a/packages/seller-dashboard/src/schemas/fulfillment.ts b/packages/seller-dashboard/src/schemas/fulfillment.tsindex fd33b15e2a..b1f999299d 100644--- a/packages/seller-dashboard/src/schemas/fulfillment.ts+++ b/packages/seller-dashboard/src/schemas/fulfillment.ts@@ -29,11 +29,3 @@ export const fulfillItemsFormSchema = z.object({})export type FulfillItemsFormValues = z.infer<typeof fulfillItemsFormSchema>--/** The tracking pair, edited after a parcel has gone out. */-export const trackingFormSchema = z.object({- tracking: z.string(),- tracking_carrier: z.string(),-})--export type TrackingFormValues = z.infer<typeof trackingFormSchema>diff --git a/spree/api/app/controllers/spree/api/v3/seller/orders/fulfillments_controller.rb b/spree/api/app/controllers/spree/api/v3/seller/orders/fulfillments_controller.rbindex c3377ef104..a704e4c91a 100644--- a/spree/api/app/controllers/spree/api/v3/seller/orders/fulfillments_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/seller/orders/fulfillments_controller.rb@@ -62,15 +62,18 @@ module Spree# PATCH /api/v3/seller/orders/:order_id/fulfillments/:id#- # The tracking number and its carrier, and nothing else. Where a- # parcel ships from and which service carries it are the- # marketplace's arrangements, so this deliberately does not accept- # the origin and rate the operator's endpoint does.+ # The tracking pair, and which of the seller's own shelves the+ # parcel ships from — a seller who picks from a different warehouse+ # than the split assumed needs to say so, and the rate is requoted+ # from there.+ #+ # The origin is resolved through `current_seller.stock_locations`,+ # so a marketplace warehouse is unreachable however the id arrives.def updatewith_order_lock dorender_workflow_result(Spree.fulfillment_update_workflow.call(- fulfillment: @fulfillment, fulfillment_attributes: update_params.to_h+ fulfillment: @fulfillment, fulfillment_attributes: update_attributes))end@@ -135,7 +138,24 @@ module Spreeenddef update_params- params.permit(:tracking, :tracking_carrier)+ params.permit(:tracking, :tracking_carrier, :stock_location_id,+ :selected_delivery_rate_id)+ end++ # The payload the workflow gets. The workflow takes a raw+ # `stock_location_id`, so the prefixed id is resolved through the+ # seller's own shelves first — a marketplace warehouse 404s here+ # rather than reaching the assignment.+ def update_attributes+ attributes = update_params.to_h++ if update_params[:stock_location_id].present?+ location = current_seller.stock_locations.+ find_by_prefix_id!(update_params[:stock_location_id])+ attributes['stock_location_id'] = location.id+ end++ attributesend# Where the split half ships from. The seller's own shelves only —diff --git a/spree/api/spec/controllers/spree/api/v3/seller/orders/fulfillments_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/seller/orders/fulfillments_controller_spec.rbindex 535df769d6..1e8c139fad 100644--- a/spree/api/spec/controllers/spree/api/v3/seller/orders/fulfillments_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/seller/orders/fulfillments_controller_spec.rb@@ -111,18 +111,32 @@ RSpec.describe Spree::Api::V3::Seller::Orders::FulfillmentsController, type: :coexpect(fulfillment.tracking_url).to include('TRACK123')end- # Where a parcel ships from and which service carries it are the- # marketplace's arrangements — this endpoint takes the tracking pair only.- it 'ignores an attempt to move the parcel to another origin' do+ # A seller picking from a different shelf than the split assumed needs to+ # say so, and the rate requotes from there.+ it 'moves the parcel to another of the seller’s shelves' doelsewhere = create(:stock_location, store: store, seller: seller)- original = fulfillment.stock_location_idpatch :update, params: {order_id: order.prefixed_id, id: fulfillment.prefixed_id,- tracking: 'TRACK123', stock_location_id: elsewhere.prefixed_id+ stock_location_id: elsewhere.prefixed_id}, as: :jsonexpect(response).to have_http_status(:ok)+ expect(fulfillment.reload.stock_location_id).to eq(elsewhere.id)+ end++ # The marketplace's own warehouses are not the seller's to ship from,+ # whatever id arrives.+ it 'refuses a shelf belonging to the marketplace' do+ theirs = create(:stock_location, store: store)+ original = fulfillment.stock_location_id++ patch :update, params: {+ order_id: order.prefixed_id, id: fulfillment.prefixed_id,+ stock_location_id: theirs.prefixed_id+ }, as: :json++ expect(response).to have_http_status(:not_found)expect(fulfillment.reload.stock_location_id).to eq(original)endend