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
Fulfil items from the order page, and edit the order separately
Damian Legawiec0ad1b429eb87
diff --git a/packages/dashboard-starter/src/routeTree.gen.ts b/packages/dashboard-starter/src/routeTree.gen.tsindex 631be42ea1..96223b3e80 100644--- a/packages/dashboard-starter/src/routeTree.gen.ts+++ b/packages/dashboard-starter/src/routeTree.gen.ts@@ -53,7 +53,6 @@ import { Route as ProductsNewRouteImport } from './../../dashboard/src/routes/_aimport { Route as ProductsProductIdRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/$productId'import { Route as OrdersNewRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/orders/new'import { Route as OrdersDraftsRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/orders/drafts'-import { Route as OrdersOrderIdRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/orders/$orderId'import { Route as CustomersGroupsRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/customers/groups'import { Route as CustomersCustomerIdRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/customers/$customerId'import { Route as BrandsDotbrandIdRouteImport } from './../../dashboard-plugin-example/src/routes/brands.$brandId'@@ -63,12 +62,14 @@ import { Route as SettingsDeliveryProfilesIndexRouteImport } from './../../dashbimport { Route as ProductsPriceListsIndexRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/price-lists/index'import { Route as ProductsCollectionsIndexRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/collections/index'import { Route as ProductsCategoriesIndexRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/categories/index'+import { Route as OrdersOrderIdIndexRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/orders/$orderId/index'import { Route as SettingsWebhooksWebhookEndpointIdRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/webhooks/$webhookEndpointId'import { Route as ProductsPriceListsNewRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/price-lists/new'import { Route as ProductsCollectionsNewRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/collections/new'import { Route as ProductsCollectionsCollectionIdRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/collections/$collectionId'import { Route as ProductsCategoriesNewRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/categories/new'import { Route as ProductsCategoriesCategoryIdRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/categories/$categoryId'+import { Route as OrdersOrderIdEditRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/orders/$orderId/edit'import { Route as SettingsDeliveryProfilesProfileIdIndexRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/index'import { Route as ProductsPriceListsPriceListIdIndexRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/price-lists/$priceListId/index'import { Route as SettingsDeliveryProfilesProfileIdMethodsNewRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new'@@ -295,11 +296,6 @@ const OrdersDraftsRoute = OrdersDraftsRouteImport.update({path: '/orders/drafts',getParentRoute: () => authenticatedStoreIdRoute,} as any)-const OrdersOrderIdRoute = OrdersOrderIdRouteImport.update({- id: '/orders/$orderId',- path: '/orders/$orderId',- getParentRoute: () => authenticatedStoreIdRoute,-} as any)const CustomersGroupsRoute = CustomersGroupsRouteImport.update({id: '/customers/groups',path: '/customers/groups',@@ -347,6 +343,11 @@ const ProductsCategoriesIndexRoute = ProductsCategoriesIndexRouteImport.update({path: '/products/categories/',getParentRoute: () => authenticatedStoreIdRoute,} as any)+const OrdersOrderIdIndexRoute = OrdersOrderIdIndexRouteImport.update({+ id: '/orders/$orderId/',+ path: '/orders/$orderId/',+ getParentRoute: () => authenticatedStoreIdRoute,+} as any)const SettingsWebhooksWebhookEndpointIdRoute =SettingsWebhooksWebhookEndpointIdRouteImport.update({id: '/webhooks/$webhookEndpointId',@@ -380,6 +381,11 @@ const ProductsCategoriesCategoryIdRoute =path: '/products/categories/$categoryId',getParentRoute: () => authenticatedStoreIdRoute,} as any)+const OrdersOrderIdEditRoute = OrdersOrderIdEditRouteImport.update({+ id: '/orders/$orderId/edit',+ path: '/orders/$orderId/edit',+ getParentRoute: () => authenticatedStoreIdRoute,+} as any)const SettingsDeliveryProfilesProfileIdIndexRoute =SettingsDeliveryProfilesProfileIdIndexRouteImport.update({id: '/delivery-profiles/$profileId/',@@ -422,7 +428,6 @@ export interface FileRoutesByFullPath {'/$storeId/brands/$brandId': typeof BrandsDotbrandIdRoute'/$storeId/customers/$customerId': typeof CustomersCustomerIdRoute'/$storeId/customers/groups': typeof CustomersGroupsRoute- '/$storeId/orders/$orderId': typeof OrdersOrderIdRoute'/$storeId/orders/drafts': typeof OrdersDraftsRoute'/$storeId/orders/new': typeof OrdersNewRoute'/$storeId/products/$productId': typeof ProductsProductIdRoute@@ -453,12 +458,14 @@ export interface FileRoutesByFullPath {'/$storeId/products/': typeof ProductsIndexRoute'/$storeId/promotions/': typeof PromotionsIndexRoute'/$storeId/settings/': typeof SettingsIndexRoute+ '/$storeId/orders/$orderId/edit': typeof OrdersOrderIdEditRoute'/$storeId/products/categories/$categoryId': typeof ProductsCategoriesCategoryIdRoute'/$storeId/products/categories/new': typeof ProductsCategoriesNewRoute'/$storeId/products/collections/$collectionId': typeof ProductsCollectionsCollectionIdRoute'/$storeId/products/collections/new': typeof ProductsCollectionsNewRoute'/$storeId/products/price-lists/new': typeof ProductsPriceListsNewRoute'/$storeId/settings/webhooks/$webhookEndpointId': typeof SettingsWebhooksWebhookEndpointIdRoute+ '/$storeId/orders/$orderId/': typeof OrdersOrderIdIndexRoute'/$storeId/products/categories/': typeof ProductsCategoriesIndexRoute'/$storeId/products/collections/': typeof ProductsCollectionsIndexRoute'/$storeId/products/price-lists/': typeof ProductsPriceListsIndexRoute@@ -485,7 +492,6 @@ export interface FileRoutesByTo {'/$storeId/brands/$brandId': typeof BrandsDotbrandIdRoute'/$storeId/customers/$customerId': typeof CustomersCustomerIdRoute'/$storeId/customers/groups': typeof CustomersGroupsRoute- '/$storeId/orders/$orderId': typeof OrdersOrderIdRoute'/$storeId/orders/drafts': typeof OrdersDraftsRoute'/$storeId/orders/new': typeof OrdersNewRoute'/$storeId/products/$productId': typeof ProductsProductIdRoute@@ -516,12 +522,14 @@ export interface FileRoutesByTo {'/$storeId/products': typeof ProductsIndexRoute'/$storeId/promotions': typeof PromotionsIndexRoute'/$storeId/settings': typeof SettingsIndexRoute+ '/$storeId/orders/$orderId/edit': typeof OrdersOrderIdEditRoute'/$storeId/products/categories/$categoryId': typeof ProductsCategoriesCategoryIdRoute'/$storeId/products/categories/new': typeof ProductsCategoriesNewRoute'/$storeId/products/collections/$collectionId': typeof ProductsCollectionsCollectionIdRoute'/$storeId/products/collections/new': typeof ProductsCollectionsNewRoute'/$storeId/products/price-lists/new': typeof ProductsPriceListsNewRoute'/$storeId/settings/webhooks/$webhookEndpointId': typeof SettingsWebhooksWebhookEndpointIdRoute+ '/$storeId/orders/$orderId': typeof OrdersOrderIdIndexRoute'/$storeId/products/categories': typeof ProductsCategoriesIndexRoute'/$storeId/products/collections': typeof ProductsCollectionsIndexRoute'/$storeId/products/price-lists': typeof ProductsPriceListsIndexRoute@@ -552,7 +560,6 @@ export interface FileRoutesById {'/_authenticated/$storeId/brands/$brandId': typeof BrandsDotbrandIdRoute'/_authenticated/$storeId/customers/$customerId': typeof CustomersCustomerIdRoute'/_authenticated/$storeId/customers/groups': typeof CustomersGroupsRoute- '/_authenticated/$storeId/orders/$orderId': typeof OrdersOrderIdRoute'/_authenticated/$storeId/orders/drafts': typeof OrdersDraftsRoute'/_authenticated/$storeId/orders/new': typeof OrdersNewRoute'/_authenticated/$storeId/products/$productId': typeof ProductsProductIdRoute@@ -583,12 +590,14 @@ export interface FileRoutesById {'/_authenticated/$storeId/products/': typeof ProductsIndexRoute'/_authenticated/$storeId/promotions/': typeof PromotionsIndexRoute'/_authenticated/$storeId/settings/': typeof SettingsIndexRoute+ '/_authenticated/$storeId/orders/$orderId/edit': typeof OrdersOrderIdEditRoute'/_authenticated/$storeId/products/categories/$categoryId': typeof ProductsCategoriesCategoryIdRoute'/_authenticated/$storeId/products/categories/new': typeof ProductsCategoriesNewRoute'/_authenticated/$storeId/products/collections/$collectionId': typeof ProductsCollectionsCollectionIdRoute'/_authenticated/$storeId/products/collections/new': typeof ProductsCollectionsNewRoute'/_authenticated/$storeId/products/price-lists/new': typeof ProductsPriceListsNewRoute'/_authenticated/$storeId/settings/webhooks/$webhookEndpointId': typeof SettingsWebhooksWebhookEndpointIdRoute+ '/_authenticated/$storeId/orders/$orderId/': typeof OrdersOrderIdIndexRoute'/_authenticated/$storeId/products/categories/': typeof ProductsCategoriesIndexRoute'/_authenticated/$storeId/products/collections/': typeof ProductsCollectionsIndexRoute'/_authenticated/$storeId/products/price-lists/': typeof ProductsPriceListsIndexRoute@@ -619,7 +628,6 @@ export interface FileRouteTypes {| '/$storeId/brands/$brandId'| '/$storeId/customers/$customerId'| '/$storeId/customers/groups'- | '/$storeId/orders/$orderId'| '/$storeId/orders/drafts'| '/$storeId/orders/new'| '/$storeId/products/$productId'@@ -650,12 +658,14 @@ export interface FileRouteTypes {| '/$storeId/products/'| '/$storeId/promotions/'| '/$storeId/settings/'+ | '/$storeId/orders/$orderId/edit'| '/$storeId/products/categories/$categoryId'| '/$storeId/products/categories/new'| '/$storeId/products/collections/$collectionId'| '/$storeId/products/collections/new'| '/$storeId/products/price-lists/new'| '/$storeId/settings/webhooks/$webhookEndpointId'+ | '/$storeId/orders/$orderId/'| '/$storeId/products/categories/'| '/$storeId/products/collections/'| '/$storeId/products/price-lists/'@@ -682,7 +692,6 @@ export interface FileRouteTypes {| '/$storeId/brands/$brandId'| '/$storeId/customers/$customerId'| '/$storeId/customers/groups'- | '/$storeId/orders/$orderId'| '/$storeId/orders/drafts'| '/$storeId/orders/new'| '/$storeId/products/$productId'@@ -713,12 +722,14 @@ export interface FileRouteTypes {| '/$storeId/products'| '/$storeId/promotions'| '/$storeId/settings'+ | '/$storeId/orders/$orderId/edit'| '/$storeId/products/categories/$categoryId'| '/$storeId/products/categories/new'| '/$storeId/products/collections/$collectionId'| '/$storeId/products/collections/new'| '/$storeId/products/price-lists/new'| '/$storeId/settings/webhooks/$webhookEndpointId'+ | '/$storeId/orders/$orderId'| '/$storeId/products/categories'| '/$storeId/products/collections'| '/$storeId/products/price-lists'@@ -748,7 +759,6 @@ export interface FileRouteTypes {| '/_authenticated/$storeId/brands/$brandId'| '/_authenticated/$storeId/customers/$customerId'| '/_authenticated/$storeId/customers/groups'- | '/_authenticated/$storeId/orders/$orderId'| '/_authenticated/$storeId/orders/drafts'| '/_authenticated/$storeId/orders/new'| '/_authenticated/$storeId/products/$productId'@@ -779,12 +789,14 @@ export interface FileRouteTypes {| '/_authenticated/$storeId/products/'| '/_authenticated/$storeId/promotions/'| '/_authenticated/$storeId/settings/'+ | '/_authenticated/$storeId/orders/$orderId/edit'| '/_authenticated/$storeId/products/categories/$categoryId'| '/_authenticated/$storeId/products/categories/new'| '/_authenticated/$storeId/products/collections/$collectionId'| '/_authenticated/$storeId/products/collections/new'| '/_authenticated/$storeId/products/price-lists/new'| '/_authenticated/$storeId/settings/webhooks/$webhookEndpointId'+ | '/_authenticated/$storeId/orders/$orderId/'| '/_authenticated/$storeId/products/categories/'| '/_authenticated/$storeId/products/collections/'| '/_authenticated/$storeId/products/price-lists/'@@ -1115,13 +1127,6 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof OrdersDraftsRouteImportparentRoute: typeof authenticatedStoreIdRoute}- '/_authenticated/$storeId/orders/$orderId': {- id: '/_authenticated/$storeId/orders/$orderId'- path: '/orders/$orderId'- fullPath: '/$storeId/orders/$orderId'- preLoaderRoute: typeof OrdersOrderIdRouteImport- parentRoute: typeof authenticatedStoreIdRoute- }'/_authenticated/$storeId/customers/groups': {id: '/_authenticated/$storeId/customers/groups'path: '/customers/groups'@@ -1185,6 +1190,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof ProductsCategoriesIndexRouteImportparentRoute: typeof authenticatedStoreIdRoute}+ '/_authenticated/$storeId/orders/$orderId/': {+ id: '/_authenticated/$storeId/orders/$orderId/'+ path: '/orders/$orderId'+ fullPath: '/$storeId/orders/$orderId/'+ preLoaderRoute: typeof OrdersOrderIdIndexRouteImport+ parentRoute: typeof authenticatedStoreIdRoute+ }'/_authenticated/$storeId/settings/webhooks/$webhookEndpointId': {id: '/_authenticated/$storeId/settings/webhooks/$webhookEndpointId'path: '/webhooks/$webhookEndpointId'@@ -1227,6 +1239,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof ProductsCategoriesCategoryIdRouteImportparentRoute: typeof authenticatedStoreIdRoute}+ '/_authenticated/$storeId/orders/$orderId/edit': {+ id: '/_authenticated/$storeId/orders/$orderId/edit'+ path: '/orders/$orderId/edit'+ fullPath: '/$storeId/orders/$orderId/edit'+ preLoaderRoute: typeof OrdersOrderIdEditRouteImport+ parentRoute: typeof authenticatedStoreIdRoute+ }'/_authenticated/$storeId/settings/delivery-profiles/$profileId/': {id: '/_authenticated/$storeId/settings/delivery-profiles/$profileId/'path: '/delivery-profiles/$profileId'@@ -1329,7 +1348,6 @@ interface authenticatedStoreIdRouteChildren {BrandsDotbrandIdRoute: typeof BrandsDotbrandIdRouteCustomersCustomerIdRoute: typeof CustomersCustomerIdRouteCustomersGroupsRoute: typeof CustomersGroupsRoute- OrdersOrderIdRoute: typeof OrdersOrderIdRouteOrdersDraftsRoute: typeof OrdersDraftsRouteOrdersNewRoute: typeof OrdersNewRouteProductsProductIdRoute: typeof ProductsProductIdRoute@@ -1344,11 +1362,13 @@ interface authenticatedStoreIdRouteChildren {OrdersIndexRoute: typeof OrdersIndexRouteProductsIndexRoute: typeof ProductsIndexRoutePromotionsIndexRoute: typeof PromotionsIndexRoute+ OrdersOrderIdEditRoute: typeof OrdersOrderIdEditRouteProductsCategoriesCategoryIdRoute: typeof ProductsCategoriesCategoryIdRouteProductsCategoriesNewRoute: typeof ProductsCategoriesNewRouteProductsCollectionsCollectionIdRoute: typeof ProductsCollectionsCollectionIdRouteProductsCollectionsNewRoute: typeof ProductsCollectionsNewRouteProductsPriceListsNewRoute: typeof ProductsPriceListsNewRoute+ OrdersOrderIdIndexRoute: typeof OrdersOrderIdIndexRouteProductsCategoriesIndexRoute: typeof ProductsCategoriesIndexRouteProductsCollectionsIndexRoute: typeof ProductsCollectionsIndexRouteProductsPriceListsIndexRoute: typeof ProductsPriceListsIndexRoute@@ -1366,7 +1386,6 @@ const authenticatedStoreIdRouteChildren: authenticatedStoreIdRouteChildren = {BrandsDotbrandIdRoute: BrandsDotbrandIdRoute,CustomersCustomerIdRoute: CustomersCustomerIdRoute,CustomersGroupsRoute: CustomersGroupsRoute,- OrdersOrderIdRoute: OrdersOrderIdRoute,OrdersDraftsRoute: OrdersDraftsRoute,OrdersNewRoute: OrdersNewRoute,ProductsProductIdRoute: ProductsProductIdRoute,@@ -1381,11 +1400,13 @@ const authenticatedStoreIdRouteChildren: authenticatedStoreIdRouteChildren = {OrdersIndexRoute: OrdersIndexRoute,ProductsIndexRoute: ProductsIndexRoute,PromotionsIndexRoute: PromotionsIndexRoute,+ OrdersOrderIdEditRoute: OrdersOrderIdEditRoute,ProductsCategoriesCategoryIdRoute: ProductsCategoriesCategoryIdRoute,ProductsCategoriesNewRoute: ProductsCategoriesNewRoute,ProductsCollectionsCollectionIdRoute: ProductsCollectionsCollectionIdRoute,ProductsCollectionsNewRoute: ProductsCollectionsNewRoute,ProductsPriceListsNewRoute: ProductsPriceListsNewRoute,+ OrdersOrderIdIndexRoute: OrdersOrderIdIndexRoute,ProductsCategoriesIndexRoute: ProductsCategoriesIndexRoute,ProductsCollectionsIndexRoute: ProductsCollectionsIndexRoute,ProductsPriceListsIndexRoute: ProductsPriceListsIndexRoute,diff --git a/packages/dashboard/e2e/order-fulfillments.spec.ts b/packages/dashboard/e2e/order-fulfillments.spec.tsindex 064be7180c..48f0d7c88e 100644--- a/packages/dashboard/e2e/order-fulfillments.spec.ts+++ b/packages/dashboard/e2e/order-fulfillments.spec.ts@@ -50,8 +50,7 @@ test.describe('order fulfillments', () => {// Manual creation is a completed-order operation — Spree::Fulfillments::Create// rejects it otherwise — so the card must not offer an action that can only- // fail. A draft's fulfillments come from the delivery step instead. "Add- // item" sits in the same header and stays available.+ // fail. A draft's fulfillments come from the delivery step instead.test('does not offer manual creation on an incomplete order', async ({ page }) => {const creds = await login(page)await createDraftOrder(page, creds.store_id)@@ -59,25 +58,18 @@ test.describe('order fulfillments', () => {const card = fulfillmentsCard(page)await expect(card.getByText(/unfulfilled \(\d+\)/i)).toBeVisible({ timeout: 15_000 })await expect(card.getByRole('button', { name: /^add fulfillment$/i })).toHaveCount(0)- await expect(card.getByRole('button', { name: /^add item$/i })).toBeVisible()})- // The item menus are the only route to editing a quantity or removing a line- // item now that the Items card is gone, and a type-clean refactor once left- // them off every row inside a fulfillment. Drive one to keep that honest.- test('offers edit and remove on an item row', async ({ page }) => {+ // Changing what an order contains after placement belongs to the order edit+ // screen, so the card's item rows are read-only: they still say what ships+ // where, but carry no per-row menu.+ test('lists item rows without per-row actions', async ({ page }) => {const creds = await login(page)await createDraftOrder(page, creds.store_id)const card = fulfillmentsCard(page)await expect(card.getByText(/unfulfilled \(\d+\)/i)).toBeVisible({ timeout: 15_000 })-- await card- .getByRole('button', { name: /actions for/i })- .first()- .click()-- await expect(page.getByRole('menuitem', { name: /edit quantity/i })).toBeVisible()- await expect(page.getByRole('menuitem', { name: /^remove$/i })).toBeVisible()+ await expect(card.getByText(new RegExp(FIXTURE_PROMO_PRODUCT, 'i')).first()).toBeVisible()+ await expect(card.getByRole('button', { name: /actions for/i })).toHaveCount(0)})})diff --git a/packages/dashboard/src/components/spree/orders/fulfillment-fulfill-form.tsx b/packages/dashboard/src/components/spree/orders/fulfillment-fulfill-form.tsxnew file mode 100644index 0000000000..bfb5af2e60--- /dev/null+++ b/packages/dashboard/src/components/spree/orders/fulfillment-fulfill-form.tsx@@ -0,0 +1,284 @@+import { zodResolver } from '@hookform/resolvers/zod'+import type { Fulfillment, Order } from '@spree/admin-sdk'+import { mapSpreeErrorsToForm } from '@spree/dashboard-core'+import { Button, Checkbox, Field, FieldLabel, Input } from '@spree/dashboard-ui'+import { PackageIcon } from 'lucide-react'+import { useEffect, useRef } from 'react'+import { Controller, type UseFormReturn, useForm } from 'react-hook-form'+import { useTranslation } from 'react-i18next'+import { useFulfillmentActions } from '../../../hooks/use-fulfillments'+import { type FulfillmentItemRow, fulfillmentItemRows } from '../../../lib/fulfillment-items'+import { type FulfillItemsFormValues, fulfillItemsFormSchema } from '../../../schemas/fulfillment'++/** A row the merchant can pick a quantity for, and the line item it addresses. */+interface FulfillableRow extends FulfillmentItemRow {+ itemId: string+}++/**+ * Rows whose fulfillment item no longer maps to a line item are dropped: the+ * fulfill endpoint addresses items by line item, so there is nothing to send+ * for them. They still ship — selecting everything else sends no `items` at+ * all, which ships the whole fulfillment including them.+ */+function fulfillableRows(rows: FulfillmentItemRow[]): FulfillableRow[] {+ return rows.flatMap((row) => (row.lineItem ? [{ ...row, itemId: row.lineItem.id }] : []))+}++function ItemQuantityRow({+ row,+ index,+ selected,+ idPrefix,+ form,+}: {+ row: FulfillableRow+ index: number+ selected: boolean+ /** Scopes the field ids, since an order can show several of these forms. */+ idPrefix: string+ form: UseFormReturn<FulfillItemsFormValues>+}) {+ const { t } = useTranslation()+ const checkboxId = `${idPrefix}-item-${index}`++ return (+ <div className="flex items-center gap-3 py-3">+ <Controller+ control={form.control}+ name={`items.${index}.selected`}+ render={({ field }) => (+ <Checkbox+ id={checkboxId}+ checked={field.value}+ aria-label={t('admin.orders.fulfill.include_item', { name: row.name })}+ onCheckedChange={(checked) => {+ const include = checked === true+ field.onChange(include)+ // Re-checking restores the full held quantity, so the merchant+ // never has to retype what they just excluded.+ form.setValue(`items.${index}.quantity`, include ? row.quantity : 0, {+ shouldDirty: true,+ })+ }}+ />+ )}+ />++ {row.thumbnailUrl ? (+ <img+ src={row.thumbnailUrl}+ alt={row.name}+ className="size-12 shrink-0 rounded-lg border object-cover"+ />+ ) : (+ <div className="flex size-12 shrink-0 items-center justify-center rounded-lg border bg-muted">+ <PackageIcon className="size-5 text-muted-foreground" />+ </div>+ )}++ <div className="min-w-0 flex-1">+ <div className="truncate text-sm font-medium">{row.name}</div>+ {row.optionsText && (+ <div className="truncate text-xs text-muted-foreground">{row.optionsText}</div>+ )}+ {row.displayPrice && (+ <div className="text-xs text-muted-foreground">{row.displayPrice}</div>+ )}+ </div>++ <Controller+ control={form.control}+ name={`items.${index}.quantity`}+ render={({ field }) => (+ <div className="flex shrink-0 items-center gap-2">+ <Input+ type="number"+ min={0}+ max={row.quantity}+ className="w-20 text-right"+ disabled={!selected}+ aria-label={t('admin.orders.fulfill.quantity_for', { name: row.name })}+ value={field.value}+ onChange={(event) => {+ const parsed = Number(event.target.value)+ const quantity = Number.isFinite(parsed)+ ? Math.max(0, Math.min(parsed, row.quantity))+ : 0+ field.onChange(quantity)+ // Typing the quantity down to zero is the same statement as+ // unticking the row, so keep the two in step.+ form.setValue(`items.${index}.selected`, quantity > 0, { shouldDirty: true })+ }}+ onBlur={field.onBlur}+ />+ <span className="w-16 text-sm whitespace-nowrap text-muted-foreground">+ {t('admin.orders.fulfill.of_units', { count: row.quantity })}+ </span>+ </div>+ )}+ />+ </div>+ )+}++/**+ * Picks what to ship out of one fulfillment, in place of the card's normal+ * contents. Shipping everything is the default; lowering a quantity or+ * unticking an item splits the chosen units into a new fulfillment that ships,+ * leaving the rest of this one open.+ */+export function FulfillmentFulfillForm({+ order,+ fulfillment,+ onDone,+}: {+ order: Order+ fulfillment: Fulfillment+ onDone: () => void+}) {+ const { t } = useTranslation()+ const { fulfill } = useFulfillmentActions(order.id)++ const idPrefix = `fulfill-${fulfillment.id}`+ const rows = fulfillableRows(fulfillmentItemRows(fulfillment, order.items ?? []))++ const form = useForm<FulfillItemsFormValues>({+ resolver: zodResolver(fulfillItemsFormSchema),+ defaultValues: {+ items: rows.map((row) => ({ item_id: row.itemId, selected: true, quantity: row.quantity })),+ tracking: fulfillment.tracking ?? '',+ notify_customer: true,+ },+ })+ const { errors } = form.formState++ // A refetch re-renders this form with fresh rows, so the values it mirrors+ // have to follow. The effect keys on the fulfillment's composition, not on+ // the rows array itself, so a refetch that returns the same units does not+ // wipe what the merchant typed. The ref carries the rows across without+ // making them a dependency.+ const rowsRef = useRef(rows)+ rowsRef.current = rows+ const rowsKey = rows.map((row) => `${row.itemId}:${row.quantity}`).join('|')+ const seededKey = useRef(rowsKey)++ useEffect(() => {+ if (seededKey.current === rowsKey) return+ seededKey.current = rowsKey+ form.reset({+ ...form.getValues(),+ items: rowsRef.current.map((row) => ({+ item_id: row.itemId,+ selected: true,+ quantity: row.quantity,+ })),+ })+ }, [rowsKey, form])++ const watched = form.watch('items')+ const totalSelected = watched.reduce(+ (sum, item) => sum + (item.selected ? item.quantity || 0 : 0),+ 0,+ )+ const totalAvailable = rows.reduce((sum, row) => sum + row.quantity, 0)+ const shipsEverything = totalSelected === totalAvailable++ async function onSubmit(values: FulfillItemsFormValues) {+ const items = values.items+ .filter((item) => item.selected && item.quantity > 0)+ .map((item) => ({ item_id: item.item_id, quantity: item.quantity }))+ if (items.length === 0) return++ // Recomputed from the submitted values rather than reusing the watched+ // total, so the branch is decided by exactly what is being sent.+ const everything = items.reduce((sum, item) => sum + item.quantity, 0) === totalAvailable+ const tracking = values.tracking.trim()++ try {+ // Omitting `items` is the documented way to ship the whole fulfillment,+ // and it avoids a pointless split when every unit was selected anyway.+ await fulfill.mutateAsync({+ fulfillmentId: fulfillment.id,+ items: everything ? undefined : items,+ tracking: tracking || undefined,+ notify_customer: values.notify_customer,+ })+ onDone()+ } catch (err) {+ if (!mapSpreeErrorsToForm(err, form.setError)) throw err+ }+ }++ return (+ <form onSubmit={form.handleSubmit(onSubmit)} className="flex flex-col gap-4">+ {errors.root?.message && (+ <p className="text-sm text-destructive" role="alert">+ {errors.root.message}+ </p>+ )}++ {rows.length === 0 ? (+ <p className="py-6 text-center text-muted-foreground">{t('admin.orders.fulfill.empty')}</p>+ ) : (+ <div className="divide-y">+ {rows.map((row, index) => (+ <ItemQuantityRow+ key={row.key}+ row={row}+ index={index}+ selected={watched[index]?.selected ?? true}+ idPrefix={idPrefix}+ form={form}+ />+ ))}+ </div>+ )}++ <Field>+ <FieldLabel htmlFor={`${idPrefix}-tracking`}>+ {t('admin.orders.fulfill.tracking_label')}+ </FieldLabel>+ <Input+ id={`${idPrefix}-tracking`}+ placeholder={t('admin.orders.fulfill.tracking_placeholder')}+ {...form.register('tracking')}+ />+ </Field>++ <Controller+ control={form.control}+ name="notify_customer"+ render={({ field }) => (+ <label+ htmlFor={`${idPrefix}-notify`}+ className="flex cursor-pointer items-center gap-2 text-sm"+ >+ <Checkbox+ id={`${idPrefix}-notify`}+ checked={field.value}+ onCheckedChange={(checked) => field.onChange(checked === true)}+ />+ {t('admin.orders.fulfill.notify_customer')}+ </label>+ )}+ />++ {!shipsEverything && totalSelected > 0 && (+ <p className="text-xs text-muted-foreground">{t('admin.orders.fulfill.partial_hint')}</p>+ )}++ <div className="flex items-center justify-end gap-2">+ <span className="mr-auto text-sm text-muted-foreground">+ {t('admin.orders.fulfill.units_selected')}: {totalSelected} / {totalAvailable}+ </span>+ <Button type="button" variant="outline" onClick={onDone}>+ {t('admin.actions.cancel')}+ </Button>+ <Button type="submit" disabled={totalSelected === 0 || fulfill.isPending}>+ {fulfill.isPending ? t('admin.actions.saving') : t('admin.orders.fulfill.submit')}+ </Button>+ </div>+ </form>+ )+}diff --git a/packages/dashboard/src/components/spree/orders/fulfillment-item-list.tsx b/packages/dashboard/src/components/spree/orders/fulfillment-item-list.tsxindex 50bcd70b73..1edcd5b683 100644--- a/packages/dashboard/src/components/spree/orders/fulfillment-item-list.tsx+++ b/packages/dashboard/src/components/spree/orders/fulfillment-item-list.tsx@@ -1,37 +1,12 @@-import {- Button,- DropdownMenu,- DropdownMenuContent,- DropdownMenuItem,- DropdownMenuSeparator,- DropdownMenuTrigger,- useConfirm,-} from '@spree/dashboard-ui'-import { EllipsisVerticalIcon, PackageIcon, PencilIcon, TrashIcon } from 'lucide-react'-import { useTranslation } from 'react-i18next'-import { type FulfillmentItemRow, isRemovableRow } from '../../../lib/fulfillment-items'+import { PackageIcon } from 'lucide-react'+import type { FulfillmentItemRow } from '../../../lib/fulfillment-items'/*** One item inside a fulfillment group: what it looks like, what it costs and- * how many units this group holds. Editing quantity and removing act on the- * underlying line item, so they are offered wherever that line item shows up.+ * how many units this group holds. Read-only — changing what an order contains+ * after placement belongs to the order edit screen, not here.*/-function ItemRow({- row,- onEdit,- onRemove,-}: {- row: FulfillmentItemRow- // Required, like on the exported list: making these optional once let a- // caller render rows with no menu at all, which silently removed the only- // route to editing or removing a line item.- onEdit: (row: FulfillmentItemRow) => void- onRemove: (row: FulfillmentItemRow) => void-}) {- const { t } = useTranslation()- const confirm = useConfirm()- const hasMenu = !!row.lineItem-+function ItemRow({ row }: { row: FulfillmentItemRow }) {return (<div className="flex items-center gap-3 py-3">{row.thumbnailUrl ? (@@ -62,79 +37,18 @@ function ItemRow({<span>× {row.quantity}</span>)}</div>-- {hasMenu && (- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button- variant="ghost"- size="icon-xs"- aria-label={t('admin.orders.detail.items_table.item_actions', { name: row.name })}- >- <EllipsisVerticalIcon className="size-4" />- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="end">- {row.lineItem && (- <DropdownMenuItem onClick={() => onEdit(row)}>- <PencilIcon className="size-4" />- {t('admin.orders.detail.dropdown.edit_quantity')}- </DropdownMenuItem>- )}- {isRemovableRow(row) && <DropdownMenuSeparator />}- {isRemovableRow(row) && (- <DropdownMenuItem- className="text-destructive focus:text-destructive"- onClick={async () => {- if (- await confirm({- message: t('admin.orders.detail.confirm.remove_item_message'),- variant: 'destructive',- confirmLabel: t('admin.actions.remove'),- })- ) {- onRemove(row)- }- }}- >- <TrashIcon className="size-4" />- {t('admin.actions.remove')}- </DropdownMenuItem>- )}- </DropdownMenuContent>- </DropdownMenu>- )}</div>)}-/**- * The item list rendered inside a fulfillment group.- *- * Every row that still maps to a line item can have its quantity edited and be- * removed — those act on the order's line item, which exists whichever group- * the row happens to be displayed in. Removal is withheld only when the row- * shows part of a line item whose other units sit elsewhere, since deleting- * would take those too.- *- * @param onEdit opens the quantity dialog for the row's line item- * @param onRemove deletes the row's line item from the order- */-export function FulfillmentItemList({- rows,- onEdit,- onRemove,-}: {- rows: FulfillmentItemRow[]- onEdit: (row: FulfillmentItemRow) => void- onRemove: (row: FulfillmentItemRow) => void-}) {+/** The item list rendered inside a fulfillment group. */+export function FulfillmentItemList({ rows }: { rows: FulfillmentItemRow[] }) {if (rows.length === 0) return nullreturn (<div className="divide-y">{rows.map((row) => (- <ItemRow key={row.key} row={row} onEdit={onEdit} onRemove={onRemove} />+ <ItemRow key={row.key} row={row} />))}</div>)diff --git a/packages/dashboard/src/components/spree/orders/fulfillments-card.tsx b/packages/dashboard/src/components/spree/orders/fulfillments-card.tsxindex 0977c3d341..1280a91038 100644--- a/packages/dashboard/src/components/spree/orders/fulfillments-card.tsx+++ b/packages/dashboard/src/components/spree/orders/fulfillments-card.tsx@@ -1,5 +1,4 @@import type { Fulfillment, Order } from '@spree/admin-sdk'-import { adminClient } from '@spree/dashboard-core'import {Badge,Button,@@ -42,14 +41,12 @@ import {PlusIcon,RotateCcwIcon,SplitIcon,- TagIcon,TruckIcon,XCircleIcon,} from 'lucide-react'import { useState } from 'react'import { useTranslation } from 'react-i18next'import { useFulfillmentActions } from '../../../hooks/use-fulfillments'-import { useOrderMutation } from '../../../hooks/use-order'import { useStockLocations } from '../../../hooks/use-stock-locations'import {type FulfillmentItemRow,@@ -58,8 +55,8 @@ import {unfulfilledItemRows,} from '../../../lib/fulfillment-items'import { FulfillmentEditDialog } from './fulfillment-edit-dialog'+import { FulfillmentFulfillForm } from './fulfillment-fulfill-form'import { FulfillmentItemList } from './fulfillment-item-list'-import { AddLineItemDialog, EditQuantityDialog } from './line-item-dialogs'/*** A unit sitting in one fulfillment. Splitting moves units per variant rather@@ -97,62 +94,6 @@ function orderUnits(order: Order): Array<{ itemId: string; label: string; quanti}))}-function EditTrackingDialog({- orderId,- fulfillment,- open,- onOpenChange,-}: {- orderId: string- fulfillment: Fulfillment- open: boolean- onOpenChange: (open: boolean) => void-}) {- const { t } = useTranslation()- const { update } = useFulfillmentActions(orderId)- const [tracking, setTracking] = useState(fulfillment.tracking ?? '')-- return (- <Dialog open={open} onOpenChange={onOpenChange}>- <DialogContent>- <DialogHeader>- <DialogTitle>{t('admin.orders.detail.tracking.edit_title')}</DialogTitle>- <DialogDescription>{t('admin.orders.detail.tracking.description')}</DialogDescription>- </DialogHeader>- <DialogBody>- <FieldGroup>- <Field>- <FieldLabel htmlFor="tracking">{t('admin.orders.detail.tracking.label')}</FieldLabel>- <Input- id="tracking"- value={tracking}- onChange={(event) => setTracking(event.target.value)}- />- </Field>- </FieldGroup>- </DialogBody>- <DialogFooter>- <Button type="button" variant="outline" onClick={() => onOpenChange(false)}>- {t('admin.actions.cancel')}- </Button>- <Button- type="button"- disabled={update.isPending}- onClick={() =>- update.mutate(- { fulfillmentId: fulfillment.id, tracking },- { onSuccess: () => onOpenChange(false) },- )- }- >- {update.isPending ? t('admin.actions.saving') : t('admin.actions.save')}- </Button>- </DialogFooter>- </DialogContent>- </Dialog>- )-}-/*** Moves units into a new fulfillment. One variant per submit, because that is* the granularity the backend's transfer works at — splitting several variants@@ -440,42 +381,25 @@ function CreateFulfillmentDialog({)}-// Which transitions the backend's state machine actually offers, so the menu+// Which transitions the backend's state machine actually offers, so the card// does not present an action that can only 422.const CAN_SHIP = ['ready', 'ready_for_pickup']const CAN_CANCEL = ['pending', 'ready', 'ready_for_pickup']const CAN_EDIT = ['pending', 'ready', 'ready_for_pickup']-/**- * Editing a line item is an order-level operation, so one set of handlers is- * shared by every group that displays that line item rather than each group- * owning its own dialog and mutation.- */-type LineItemActions = {- edit: (row: FulfillmentItemRow) => void- remove: (row: FulfillmentItemRow) => void-}--function FulfillmentRow({- order,- fulfillment,- itemActions,-}: {- order: Order- fulfillment: Fulfillment- itemActions: LineItemActions-}) {+function FulfillmentRow({ order, fulfillment }: { order: Order; fulfillment: Fulfillment }) {const { t } = useTranslation()const confirm = useConfirm()const orderId = order.id- const { fulfill, cancel, resume } = useFulfillmentActions(orderId)+ const { cancel, resume } = useFulfillmentActions(orderId)const [editOpen, setEditOpen] = useState(false)- const [trackingOpen, setTrackingOpen] = useState(false)const [splitOpen, setSplitOpen] = useState(false)+ const [fulfilling, setFulfilling] = useState(false)const editable = CAN_EDIT.includes(fulfillment.status)const splittable = editable && unitsOf(fulfillment).length > 0+ const shippable = CAN_SHIP.includes(fulfillment.status)return (<div className="rounded-lg border p-4 flex flex-col gap-3">@@ -498,13 +422,6 @@ function FulfillmentRow({</DropdownMenuItem>)}- <DropdownMenuItem onClick={() => setTrackingOpen(true)}>- <TagIcon className="size-4" />- {fulfillment.tracking- ? t('admin.orders.detail.tracking.edit_title')- : t('admin.orders.detail.tracking.add_title')}- </DropdownMenuItem>-{splittable && (<DropdownMenuItem onClick={() => setSplitOpen(true)}><SplitIcon className="size-4" />@@ -512,25 +429,6 @@ function FulfillmentRow({</DropdownMenuItem>)}- {CAN_SHIP.includes(fulfillment.status) && (- <DropdownMenuItem- onClick={async () => {- if (- await confirm({- message: t('admin.orders.detail.confirm.ship_message'),- variant: 'default',- confirmLabel: t('admin.pages.orders.detail.actions.ship'),- })- ) {- fulfill.mutate(fulfillment.id)- }- }}- >- <TruckIcon className="size-4" />- {t('admin.pages.orders.detail.actions.ship')}- </DropdownMenuItem>- )}-{fulfillment.status === 'canceled' && (<DropdownMenuItem onClick={() => resume.mutate(fulfillment.id)}><RotateCcwIcon className="size-4" />@@ -580,7 +478,7 @@ function FulfillmentRow({</div>)}- {fulfillment.tracking && (+ {fulfillment.tracking && !fulfilling && (<div className="text-sm"><span className="text-muted-foreground">{t('admin.orders.detail.tracking.prefix')}:{' '}@@ -610,11 +508,26 @@ function FulfillmentRow({</span>)}- <FulfillmentItemList- rows={fulfillmentItemRows(fulfillment, order.items ?? [])}- onEdit={itemActions.edit}- onRemove={itemActions.remove}- />+ {fulfilling ? (+ <FulfillmentFulfillForm+ order={order}+ fulfillment={fulfillment}+ onDone={() => setFulfilling(false)}+ />+ ) : (+ <>+ <FulfillmentItemList rows={fulfillmentItemRows(fulfillment, order.items ?? [])} />++ {shippable && (+ <div className="flex justify-end">+ <Button type="button" size="sm" onClick={() => setFulfilling(true)}>+ <TruckIcon data-icon="inline-start" />+ {t('admin.orders.fulfill.action')}+ </Button>+ </div>+ )}+ </>+ )}{editOpen && (<FulfillmentEditDialog@@ -625,15 +538,6 @@ function FulfillmentRow({/>)}- {trackingOpen && (- <EditTrackingDialog- orderId={orderId}- fulfillment={fulfillment}- open={trackingOpen}- onOpenChange={setTrackingOpen}- />- )}-{splitOpen && (<SplitFulfillmentDialogorderId={orderId}@@ -651,13 +555,7 @@ function FulfillmentRow({* so the eye can compare it against the real ones, minus the status and number* it does not have.*/-function UnfulfilledGroup({- rows,- itemActions,-}: {- rows: FulfillmentItemRow[]- itemActions: LineItemActions-}) {+function UnfulfilledGroup({ rows }: { rows: FulfillmentItemRow[] }) {const { t } = useTranslation()const totalUnits = rows.reduce((sum, row) => sum + row.quantity, 0)@@ -671,7 +569,7 @@ function UnfulfilledGroup({</span></div>- <FulfillmentItemList rows={rows} onEdit={itemActions.edit} onRemove={itemActions.remove} />+ <FulfillmentItemList rows={rows} /></div>)}@@ -689,25 +587,11 @@ function UnfulfilledGroup({export function FulfillmentsCard({ order }: { order: Order }) {const { t } = useTranslation()const [createOpen, setCreateOpen] = useState(false)- const [addItemOpen, setAddItemOpen] = useState(false)- const [editItem, setEditItem] = useState<{ id: string; quantity: number } | null>(null)const fulfillments = order.fulfillments ?? []const lineItems = order.items ?? []const unfulfilled = unfulfilledItemRows(lineItems, fulfillments)- const deleteMutation = useOrderMutation(order.id, (lineItemId: string) =>- adminClient.orders.items.delete(order.id, lineItemId),- )-- // Shared by every group: the row shows units, but both actions act on the- // line item behind them, which is the same record wherever it is displayed.- const itemActions: LineItemActions = {- edit: (row) =>- row.lineItem && setEditItem({ id: row.lineItem.id, quantity: row.lineItem.quantity }),- remove: (row) => row.lineItem && deleteMutation.mutate(row.lineItem.id),- }-// Manual creation is a completed-order operation: Fulfillments::Create// rejects it otherwise ("Fulfillments can only be created manually on// completed orders"). A draft's fulfillments come from the delivery step.@@ -728,10 +612,6 @@ export function FulfillmentsCard({ order }: { order: Order }) {</CardTitle><CardAction className="flex items-center gap-2">{order.fulfillment_status && <StatusBadge status={order.fulfillment_status} />}- <Button size="sm" variant="outline" onClick={() => setAddItemOpen(true)}>- <PlusIcon data-icon="inline-start" />- {t('admin.orders.detail.fulfillments.add_item')}- </Button>{canCreate && (<Button size="sm" variant="outline" onClick={() => setCreateOpen(true)}><PlusIcon data-icon="inline-start" />@@ -748,16 +628,9 @@ export function FulfillmentsCard({ order }: { order: Order }) {</CardContent>) : (<CardContent className="flex flex-col gap-4">- {unfulfilled.length > 0 && (- <UnfulfilledGroup rows={unfulfilled} itemActions={itemActions} />- )}+ {unfulfilled.length > 0 && <UnfulfilledGroup rows={unfulfilled} />}{fulfillments.map((fulfillment) => (- <FulfillmentRow- key={fulfillment.id}- order={order}- fulfillment={fulfillment}- itemActions={itemActions}- />+ <FulfillmentRow key={fulfillment.id} order={order} fulfillment={fulfillment} />))}</CardContent>)}@@ -766,18 +639,6 @@ export function FulfillmentsCard({ order }: { order: Order }) {{createOpen && (<CreateFulfillmentDialog order={order} open={createOpen} onOpenChange={setCreateOpen} />)}-- <AddLineItemDialog orderId={order.id} open={addItemOpen} onOpenChange={setAddItemOpen} />-- {editItem && (- <EditQuantityDialog- orderId={order.id}- lineItemId={editItem.id}- currentQuantity={editItem.quantity}- open={!!editItem}- onOpenChange={(open) => !open && setEditItem(null)}- />- )}</>)}diff --git a/packages/dashboard/src/hooks/use-fulfillments.ts b/packages/dashboard/src/hooks/use-fulfillments.tsindex a504c25eb6..4c41d5f8eb 100644--- a/packages/dashboard/src/hooks/use-fulfillments.ts+++ b/packages/dashboard/src/hooks/use-fulfillments.ts@@ -1,4 +1,9 @@-import type { FulfillmentCreateParams, FulfillmentSplitParams } from '@spree/admin-sdk'+import {+ type FulfillmentCreateParams,+ type FulfillmentFulfillParams,+ type FulfillmentSplitParams,+ SpreeError,+} from '@spree/admin-sdk'import { adminClient, useResourceKeyBuilder } from '@spree/dashboard-core'import { useMutation, useQueryClient } from '@tanstack/react-query'import { toast } from 'sonner'@@ -7,6 +12,9 @@ import { toast } from 'sonner'* A fulfillment mutation refreshes the order itself — every one of these moves* units, re-prices the fulfillment, or both, and the order totals and* fulfillment status are derived from that.+ *+ * A 422 is left untoasted: the caller is a form that renders the same message+ * next to the offending input, so toasting it too would say it twice.*/function useFulfillmentMutation<TParams>(orderId: string,@@ -21,6 +29,7 @@ function useFulfillmentMutation<TParams>(queryClient.invalidateQueries({ queryKey: buildKey('orders', orderId) })},onError: (error) => {+ if (error instanceof SpreeError && error.status === 422) returntoast.error(error instanceof Error ? error.message : String(error))},})@@ -55,8 +64,19 @@ export function useFulfillmentActions(orderId: string) {adminClient.orders.fulfillments.split(orderId, fulfillmentId, params),)- const fulfill = useFulfillmentMutation(orderId, (fulfillmentId: string) =>- adminClient.orders.fulfillments.fulfill(orderId, fulfillmentId),+ // Accepts a bare id (ship everything) or an id plus the quantities to ship,+ // the tracking number and whether the customer is notified. Passing items+ // splits them off into a new fulfillment which is the one that ships, so the+ // response's id is not the one that was addressed.+ const fulfill = useFulfillmentMutation(+ orderId,+ (params: string | ({ fulfillmentId: string } & FulfillmentFulfillParams)) => {+ if (typeof params === 'string') {+ return adminClient.orders.fulfillments.fulfill(orderId, params)+ }+ const { fulfillmentId, ...rest } = params+ return adminClient.orders.fulfillments.fulfill(orderId, fulfillmentId, rest)+ },)const cancel = useFulfillmentMutation(orderId, (fulfillmentId: string) =>diff --git a/packages/dashboard/src/lib/fulfillment-items.test.ts b/packages/dashboard/src/lib/fulfillment-items.test.tsindex 494d662c9d..4879231d1f 100644--- a/packages/dashboard/src/lib/fulfillment-items.test.ts+++ b/packages/dashboard/src/lib/fulfillment-items.test.ts@@ -4,7 +4,6 @@ import {type GroupableFulfillment,type GroupableLineItem,hasFulfillableUnits,- isRemovableRow,unfulfilledItemRows,} from './fulfillment-items'@@ -150,37 +149,6 @@ describe('unfulfilledItemRows', () => {})})-describe('isRemovableRow', () => {- it('allows removing a row holding every unit of its line item', () => {- const [row] = fulfillmentItemRows(- fulfillment({ fulfillment_items: [{ line_item_id: 'li_1', quantity: 2 }] }),- [lineItem({ quantity: 2 })],- )-- expect(isRemovableRow(row)).toBe(true)- })-- // The other units live in a different group; deleting the line item would- // silently take those too.- it('refuses a row holding only part of its line item', () => {- const [row] = fulfillmentItemRows(- fulfillment({ fulfillment_items: [{ line_item_id: 'li_1', quantity: 1 }] }),- [lineItem({ quantity: 3 })],- )-- expect(isRemovableRow(row)).toBe(false)- })-- it('refuses a row with no line item behind it', () => {- const [row] = fulfillmentItemRows(- fulfillment({ fulfillment_items: [{ variant_id: 'variant_9', quantity: 1 }] }),- [],- )-- expect(isRemovableRow(row)).toBe(false)- })-})-describe('hasFulfillableUnits', () => {it('is true while units remain unclaimed', () => {expect(hasFulfillableUnits([lineItem({ quantity: 2 })], [])).toBe(true)diff --git a/packages/dashboard/src/lib/fulfillment-items.ts b/packages/dashboard/src/lib/fulfillment-items.tsindex f5e26b888d..59edd42ce3 100644--- a/packages/dashboard/src/lib/fulfillment-items.ts+++ b/packages/dashboard/src/lib/fulfillment-items.ts@@ -150,16 +150,6 @@ export function unfulfilledItemRows(})}-/**- * Whether removing this row would delete only the units it displays. Removal- * acts on the whole line item, so a row showing part of one — the rest sitting- * in another group — would take those other units with it. Offering removal- * only on whole line items keeps the action honest about its blast radius.- */-export function isRemovableRow(row: FulfillmentItemRow): boolean {- return !!row.lineItem && row.quantity === row.lineItem.quantity-}-/*** Whether anything is left to put into a new fulfillment: either units nobody* has claimed, or units sitting in a fulfillment that has not shipped yet anddiff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.jsonindex 14e11fec97..95c3342755 100644--- a/packages/dashboard/src/locales/ar.json+++ b/packages/dashboard/src/locales/ar.json@@ -1822,7 +1822,6 @@"resume_failed": "فشل في استئناف الطلب"},"fulfillments": {- "add_item": "إضافة عنصر","confirm_split": "نقل هذه الوحدات إلى شحنة جديدة؟ يسري هذا فوراً.","create_description": "تنشئ شحنة وتنقل إليها الكميات المختارة.","create_items": "العناصر",@@ -1857,9 +1856,6 @@"store_credit_label": "Store credit","title": "الخصومات والرصيد"},- "items_table": {- "item_actions": "إجراءات لـ {{name}}"- },"load_failed_message": "لم نتمكن من تحميل الطلب {{orderId}}.","messages": {"approved": "تمت الموافقة على الطلب",@@ -1903,10 +1899,6 @@"tax_included": "الضريبة (متضمنة)"},"tracking": {- "add_title": "Add Tracking",- "description": "قم بتحديث رقم التتبع لهذه الشحنة.",- "edit_title": "Edit Tracking",- "label": "Tracking الرقم","prefix": "Tracking","shipped_prefix": "تم الشحن"},@@ -1918,6 +1910,46 @@"sku_prefix": "SKU"}},+ "edit": {+ "action_label": "تعديل الطلب",+ "actions": {+ "add_product": "إضافة منتج",+ "edit_quantity_for": "تعديل كمية {{name}}",+ "remove": "إزالة",+ "remove_item": "إزالة {{name}}"+ },+ "columns": {+ "line_total": "إجمالي السطر",+ "product": "المنتج",+ "unit_price": "سعر الوحدة"+ },+ "confirm": {+ "remove_message": "إزالة \"{{name}}\" من هذا الطلب؟ يسري هذا فوراً ويُعاد احتساب إجماليات الطلب.",+ "remove_title": "إزالة السطر"+ },+ "empty": "لا يحتوي هذا الطلب على أي عناصر.",+ "items_title": "العناصر",+ "subtitle": "الطلب {{number}}",+ "title": "تعديل الطلب",+ "totals_hint": "يُعيد الخادم احتساب الإجماليات بعد كل تغيير.",+ "totals_title": "الإجماليات"+ },+ "fulfill": {+ "action": "وضع علامة كمشحون",+ "empty": "لا تحتوي هذه الشحنة على عناصر قابلة للشحن.",+ "include_item": "شحن {{name}}",+ "notify_customer": "إرسال إشعار الشحن إلى العميل",+ "of_units": "من {{count}}",+ "partial_hint": "تنتقل الوحدات المختارة إلى شحنة جديدة تُشحن الآن، ويبقى الباقي في هذه الشحنة وهي ما زالت مفتوحة.",+ "quantity_for": "الكمية المراد شحنها من {{name}}",+ "submit": "شحن العناصر",+ "tracking_label": "رقم التتبع",+ "tracking_placeholder": "رقم التتبع أو الرابط",+ "units_selected": "الوحدات المراد شحنها",+ "validation": {+ "quantity_invalid": "أدخل عددًا صحيحًا من الوحدات."+ }+ },"fulfillment_statuses": {"backorder": "طلب متأخر","canceled": "تم الإلغاء",diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.jsonindex 319d0c3efc..b9c73ab763 100644--- a/packages/dashboard/src/locales/de.json+++ b/packages/dashboard/src/locales/de.json@@ -1811,7 +1811,6 @@"resume_failed": "Auftrag konnte nicht wieder aufgenommen werden"},"fulfillments": {- "add_item": "Artikel hinzufügen","confirm_split": "Diese Einheiten in eine neue Sendung verschieben? Die Änderung wird sofort wirksam.","create_description": "Erstellt eine Sendung und verschiebt die gewählten Mengen hinein.","create_items": "Artikel",@@ -1847,9 +1846,6 @@"store_credit_label": "Guthaben","title": "Rabatte & Guthaben"},- "items_table": {- "item_actions": "Aktionen für {{name}}"- },"load_failed_message": "Auftrag {{orderId}} konnte nicht geladen werden.","messages": {"approved": "Auftrag genehmigt",@@ -1893,10 +1889,6 @@"tax_included": "Steuer (inklusive)"},"tracking": {- "add_title": "Sendungsverfolgung hinzufügen",- "description": "Aktualisieren Sie die Sendungsnummer für diese Lieferung.",- "edit_title": "Sendungsverfolgung bearbeiten",- "label": "Sendungsnummer","prefix": "Tracking","shipped_prefix": "Versendet"},@@ -1908,6 +1900,46 @@"sku_prefix": "SKU"}},+ "edit": {+ "action_label": "Bestellung bearbeiten",+ "actions": {+ "add_product": "Produkt hinzufügen",+ "edit_quantity_for": "Menge von {{name}} bearbeiten",+ "remove": "Entfernen",+ "remove_item": "{{name}} entfernen"+ },+ "columns": {+ "line_total": "Positionssumme",+ "product": "Produkt",+ "unit_price": "Einzelpreis"+ },+ "confirm": {+ "remove_message": "„{{name}}“ aus dieser Bestellung entfernen? Dies wird sofort wirksam und die Bestellsummen werden neu berechnet.",+ "remove_title": "Position entfernen"+ },+ "empty": "Diese Bestellung enthält keine Artikel.",+ "items_title": "Artikel",+ "subtitle": "Bestellung {{number}}",+ "title": "Bestellung bearbeiten",+ "totals_hint": "Die Summen werden nach jeder Änderung vom Server neu berechnet.",+ "totals_title": "Summen"+ },+ "fulfill": {+ "action": "Als versendet markieren",+ "empty": "Diese Sendung enthält keine versandfähigen Artikel.",+ "include_item": "{{name}} versenden",+ "notify_customer": "Versandbenachrichtigung an Kundin oder Kunden senden",+ "of_units": "von {{count}}",+ "partial_hint": "Die ausgewählten Einheiten wandern in eine neue Sendung, die jetzt versendet wird. Der Rest bleibt offen in dieser Sendung.",+ "quantity_for": "Zu versendende Menge von {{name}}",+ "submit": "Artikel versenden",+ "tracking_label": "Sendungsnummer",+ "tracking_placeholder": "Sendungsnummer oder Link",+ "units_selected": "Zu versendende Einheiten",+ "validation": {+ "quantity_invalid": "Bitte eine ganze Zahl an Einheiten eingeben."+ }+ },"fulfillment_statuses": {"backorder": "Lieferrückstand","canceled": "Storniert",diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.jsonindex 14c7dbf2f3..a881a42de5 100644--- a/packages/dashboard/src/locales/en.json+++ b/packages/dashboard/src/locales/en.json@@ -1811,7 +1811,6 @@"resume_failed": "Failed to resume order"},"fulfillments": {- "add_item": "Add item","confirm_split": "Move these units into a new fulfillment? This takes effect immediately.","create_description": "Creates a fulfillment and moves the chosen quantities into it.","create_items": "Items",@@ -1847,9 +1846,6 @@"store_credit_label": "Store credit","title": "Discounts & Credit"},- "items_table": {- "item_actions": "Actions for {{name}}"- },"load_failed_message": "We couldn't load order {{orderId}}.","messages": {"approved": "Order approved",@@ -1893,10 +1889,6 @@"tax_included": "Tax (included)"},"tracking": {- "add_title": "Add Tracking",- "description": "Update the tracking number for this shipment.",- "edit_title": "Edit Tracking",- "label": "Tracking Number","prefix": "Tracking","shipped_prefix": "Shipped"},@@ -1908,6 +1900,46 @@"sku_prefix": "SKU"}},+ "edit": {+ "action_label": "Edit order",+ "actions": {+ "add_product": "Add product",+ "edit_quantity_for": "Edit quantity of {{name}}",+ "remove": "Remove",+ "remove_item": "Remove {{name}}"+ },+ "columns": {+ "line_total": "Line total",+ "product": "Product",+ "unit_price": "Unit price"+ },+ "confirm": {+ "remove_message": "Remove \"{{name}}\" from this order? This takes effect immediately and the order totals are recalculated.",+ "remove_title": "Remove line item"+ },+ "empty": "This order has no items.",+ "items_title": "Items",+ "subtitle": "Order {{number}}",+ "title": "Edit order",+ "totals_hint": "Totals are recalculated by the server after each change.",+ "totals_title": "Totals"+ },+ "fulfill": {+ "action": "Mark as fulfilled",+ "empty": "This fulfillment holds no items that can be shipped.",+ "include_item": "Ship {{name}}",+ "notify_customer": "Send shipment notification to customer",+ "of_units": "of {{count}}",+ "partial_hint": "The units you picked move into a new fulfillment that ships now. The rest stay on this one, still open.",+ "quantity_for": "Quantity to ship of {{name}}",+ "submit": "Fulfill items",+ "tracking_label": "Tracking number",+ "tracking_placeholder": "Tracking number or link",+ "units_selected": "Units to ship",+ "validation": {+ "quantity_invalid": "Enter a whole number of units."+ }+ },"fulfillment_statuses": {"backorder": "Backorder","canceled": "Canceled",diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.jsonindex 7763fbedca..77f2459e42 100644--- a/packages/dashboard/src/locales/fr.json+++ b/packages/dashboard/src/locales/fr.json@@ -1811,7 +1811,6 @@"resume_failed": "Échec de la reprise de la commande"},"fulfillments": {- "add_item": "Ajouter un article","confirm_split": "Déplacer ces unités vers une nouvelle expédition ? L'effet est immédiat.","create_description": "Crée une expédition et y déplace les quantités choisies.","create_items": "Articles",@@ -1847,9 +1846,6 @@"store_credit_label": "Avoir","title": "Remises et avoirs"},- "items_table": {- "item_actions": "Actions pour {{name}}"- },"load_failed_message": "Impossible de charger la commande {{orderId}}.","messages": {"approved": "Commande approuvée",@@ -1893,10 +1889,6 @@"tax_included": "Taxe (incluse)"},"tracking": {- "add_title": "Ajouter un suivi",- "description": "Mettez à jour le numéro de suivi de cet envoi.",- "edit_title": "Modifier le suivi",- "label": "Numéro de suivi","prefix": "Suivi","shipped_prefix": "Expédié"},@@ -1908,6 +1900,46 @@"sku_prefix": "SKU"}},+ "edit": {+ "action_label": "Modifier la commande",+ "actions": {+ "add_product": "Ajouter un produit",+ "edit_quantity_for": "Modifier la quantité de {{name}}",+ "remove": "Retirer",+ "remove_item": "Retirer {{name}}"+ },+ "columns": {+ "line_total": "Total de la ligne",+ "product": "Produit",+ "unit_price": "Prix unitaire"+ },+ "confirm": {+ "remove_message": "Retirer « {{name}} » de cette commande ? Cela prend effet immédiatement et les totaux de la commande sont recalculés.",+ "remove_title": "Retirer la ligne"+ },+ "empty": "Cette commande ne contient aucun article.",+ "items_title": "Articles",+ "subtitle": "Commande {{number}}",+ "title": "Modifier la commande",+ "totals_hint": "Les totaux sont recalculés par le serveur après chaque modification.",+ "totals_title": "Totaux"+ },+ "fulfill": {+ "action": "Marquer comme expédié",+ "empty": "Cette expédition ne contient aucun article expédiable.",+ "include_item": "Expédier {{name}}",+ "notify_customer": "Envoyer la notification d'expédition au client",+ "of_units": "sur {{count}}",+ "partial_hint": "Les unités choisies passent dans une nouvelle expédition qui part maintenant. Le reste demeure sur celle-ci, toujours ouverte.",+ "quantity_for": "Quantité à expédier de {{name}}",+ "submit": "Expédier des articles",+ "tracking_label": "Numéro de suivi",+ "tracking_placeholder": "Numéro de suivi ou lien",+ "units_selected": "Unités à expédier",+ "validation": {+ "quantity_invalid": "Saisissez un nombre entier d'unités."+ }+ },"fulfillment_statuses": {"backorder": "Commande en attente","canceled": "Annulé",diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.jsonindex a311985e4d..18939ba7e0 100644--- a/packages/dashboard/src/locales/pl.json+++ b/packages/dashboard/src/locales/pl.json@@ -1827,7 +1827,6 @@"resume_failed": "Nie udało się wznowić zamówienia"},"fulfillments": {- "add_item": "Dodaj pozycję","confirm_split": "Przenieść te sztuki do nowej przesyłki? Zmiana zadziała natychmiast.","create_description": "Tworzy przesyłkę i przenosi do niej wybrane ilości.","create_items": "Pozycje",@@ -1865,9 +1864,6 @@"store_credit_label": "Kredyt sklepowy","title": "Rabaty i środki"},- "items_table": {- "item_actions": "Akcje dla {{name}}"- },"load_failed_message": "Nie udało się załadować zamówienia {{orderId}}.","messages": {"approved": "Zamówienie zatwierdzone",@@ -1911,10 +1907,6 @@"tax_included": "Podatek (wliczony)"},"tracking": {- "add_title": "Dodaj śledzenie",- "description": "Zaktualizuj numer śledzenia dla tej przesyłki.",- "edit_title": "Edytuj śledzenie",- "label": "Numer śledzenia","prefix": "Śledzenie","shipped_prefix": "Wysłano"},@@ -1926,6 +1918,46 @@"sku_prefix": "SKU"}},+ "edit": {+ "action_label": "Edytuj zamówienie",+ "actions": {+ "add_product": "Dodaj produkt",+ "edit_quantity_for": "Edytuj ilość dla {{name}}",+ "remove": "Usuń",+ "remove_item": "Usuń {{name}}"+ },+ "columns": {+ "line_total": "Wartość pozycji",+ "product": "Produkt",+ "unit_price": "Cena jednostkowa"+ },+ "confirm": {+ "remove_message": "Usunąć „{{name}}” z tego zamówienia? Zmiana zostanie zastosowana natychmiast, a sumy zamówienia zostaną przeliczone.",+ "remove_title": "Usuń pozycję"+ },+ "empty": "To zamówienie nie zawiera pozycji.",+ "items_title": "Pozycje",+ "subtitle": "Zamówienie {{number}}",+ "title": "Edytuj zamówienie",+ "totals_hint": "Sumy są przeliczane przez serwer po każdej zmianie.",+ "totals_title": "Sumy"+ },+ "fulfill": {+ "action": "Oznacz jako wysłane",+ "empty": "Ta przesyłka nie zawiera pozycji, które można wysłać.",+ "include_item": "Wyślij: {{name}}",+ "notify_customer": "Wyślij klientowi powiadomienie o wysyłce",+ "of_units": "z {{count}}",+ "partial_hint": "Wybrane sztuki trafią do nowej przesyłki, która zostanie wysłana teraz. Reszta pozostanie w tej przesyłce, wciąż otwartej.",+ "quantity_for": "Liczba sztuk do wysłania: {{name}}",+ "submit": "Wyślij pozycje",+ "tracking_label": "Numer śledzenia",+ "tracking_placeholder": "Numer śledzenia lub link",+ "units_selected": "Sztuki do wysłania",+ "validation": {+ "quantity_invalid": "Podaj całkowitą liczbę sztuk."+ }+ },"fulfillment_statuses": {"backorder": "Zamówienie oczekujące","canceled": "Anulowane",diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.jsonindex b4b958fb8d..588e5750bc 100644--- a/packages/dashboard/src/locales/zh-CN.json+++ b/packages/dashboard/src/locales/zh-CN.json@@ -1808,7 +1808,6 @@"resume_failed": "恢复订单失败"},"fulfillments": {- "add_item": "添加商品","confirm_split": "将这些数量移入新的发货单?此操作立即生效。","create_description": "创建发货单并将所选数量移入其中。","create_items": "商品项",@@ -1843,9 +1842,6 @@"store_credit_label": "店铺积分","title": "折扣与余额"},- "items_table": {- "item_actions": "{{name}} 的操作"- },"load_failed_message": "无法加载订单 {{orderId}}。","messages": {"approved": "订单已批准",@@ -1889,10 +1885,6 @@"tax_included": "税(含)"},"tracking": {- "add_title": "添加物流单号",- "description": "更新此发货单的物流单号。",- "edit_title": "编辑物流单号",- "label": "物流单号","prefix": "物流","shipped_prefix": "已发货"},@@ -1904,6 +1896,46 @@"sku_prefix": "SKU"}},+ "edit": {+ "action_label": "编辑订单",+ "actions": {+ "add_product": "添加商品",+ "edit_quantity_for": "编辑 {{name}} 的数量",+ "remove": "移除",+ "remove_item": "移除 {{name}}"+ },+ "columns": {+ "line_total": "小计",+ "product": "商品",+ "unit_price": "单价"+ },+ "confirm": {+ "remove_message": "要从此订单中移除“{{name}}”吗?此操作将立即生效,订单金额会重新计算。",+ "remove_title": "移除订单行"+ },+ "empty": "此订单没有商品。",+ "items_title": "商品",+ "subtitle": "订单 {{number}}",+ "title": "编辑订单",+ "totals_hint": "每次更改后,服务器都会重新计算金额。",+ "totals_title": "金额"+ },+ "fulfill": {+ "action": "标记为已发货",+ "empty": "此发货单中没有可发货的商品。",+ "include_item": "发货 {{name}}",+ "notify_customer": "向客户发送发货通知",+ "of_units": "共 {{count}}",+ "partial_hint": "所选数量将移入一个新的发货单并立即发货,其余部分留在当前发货单中并保持开启。",+ "quantity_for": "{{name}} 的发货数量",+ "submit": "发货商品",+ "tracking_label": "物流单号",+ "tracking_placeholder": "物流单号或链接",+ "units_selected": "待发货数量",+ "validation": {+ "quantity_invalid": "请输入整数数量。"+ }+ },"fulfillment_statuses": {"backorder": "缺货补订","canceled": "已取消",diff --git a/packages/dashboard/src/routeTree.gen.ts b/packages/dashboard/src/routeTree.gen.tsindex a72318e050..1b6b0cd495 100644--- a/packages/dashboard/src/routeTree.gen.ts+++ b/packages/dashboard/src/routeTree.gen.ts@@ -52,7 +52,6 @@ import { Route as ProductsNewRouteImport } from './routes/_authenticated/$storeIimport { Route as ProductsProductIdRouteImport } from './routes/_authenticated/$storeId/products/$productId'import { Route as OrdersNewRouteImport } from './routes/_authenticated/$storeId/orders/new'import { Route as OrdersDraftsRouteImport } from './routes/_authenticated/$storeId/orders/drafts'-import { Route as OrdersOrderIdRouteImport } from './routes/_authenticated/$storeId/orders/$orderId'import { Route as CustomersGroupsRouteImport } from './routes/_authenticated/$storeId/customers/groups'import { Route as CustomersCustomerIdRouteImport } from './routes/_authenticated/$storeId/customers/$customerId'import { Route as SettingsWebhooksIndexRouteImport } from './routes/_authenticated/$storeId/settings/webhooks/index'@@ -61,12 +60,14 @@ import { Route as SettingsDeliveryProfilesIndexRouteImport } from './routes/_autimport { Route as ProductsPriceListsIndexRouteImport } from './routes/_authenticated/$storeId/products/price-lists/index'import { Route as ProductsCollectionsIndexRouteImport } from './routes/_authenticated/$storeId/products/collections/index'import { Route as ProductsCategoriesIndexRouteImport } from './routes/_authenticated/$storeId/products/categories/index'+import { Route as OrdersOrderIdIndexRouteImport } from './routes/_authenticated/$storeId/orders/$orderId/index'import { Route as SettingsWebhooksWebhookEndpointIdRouteImport } from './routes/_authenticated/$storeId/settings/webhooks/$webhookEndpointId'import { Route as ProductsPriceListsNewRouteImport } from './routes/_authenticated/$storeId/products/price-lists/new'import { Route as ProductsCollectionsNewRouteImport } from './routes/_authenticated/$storeId/products/collections/new'import { Route as ProductsCollectionsCollectionIdRouteImport } from './routes/_authenticated/$storeId/products/collections/$collectionId'import { Route as ProductsCategoriesNewRouteImport } from './routes/_authenticated/$storeId/products/categories/new'import { Route as ProductsCategoriesCategoryIdRouteImport } from './routes/_authenticated/$storeId/products/categories/$categoryId'+import { Route as OrdersOrderIdEditRouteImport } from './routes/_authenticated/$storeId/orders/$orderId/edit'import { Route as SettingsDeliveryProfilesProfileIdIndexRouteImport } from './routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/index'import { Route as ProductsPriceListsPriceListIdIndexRouteImport } from './routes/_authenticated/$storeId/products/price-lists/$priceListId/index'import { Route as SettingsDeliveryProfilesProfileIdMethodsNewRouteImport } from './routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new'@@ -288,11 +289,6 @@ const OrdersDraftsRoute = OrdersDraftsRouteImport.update({path: '/orders/drafts',getParentRoute: () => authenticatedStoreIdRoute,} as any)-const OrdersOrderIdRoute = OrdersOrderIdRouteImport.update({- id: '/orders/$orderId',- path: '/orders/$orderId',- getParentRoute: () => authenticatedStoreIdRoute,-} as any)const CustomersGroupsRoute = CustomersGroupsRouteImport.update({id: '/customers/groups',path: '/customers/groups',@@ -335,6 +331,11 @@ const ProductsCategoriesIndexRoute = ProductsCategoriesIndexRouteImport.update({path: '/products/categories/',getParentRoute: () => authenticatedStoreIdRoute,} as any)+const OrdersOrderIdIndexRoute = OrdersOrderIdIndexRouteImport.update({+ id: '/orders/$orderId/',+ path: '/orders/$orderId/',+ getParentRoute: () => authenticatedStoreIdRoute,+} as any)const SettingsWebhooksWebhookEndpointIdRoute =SettingsWebhooksWebhookEndpointIdRouteImport.update({id: '/webhooks/$webhookEndpointId',@@ -368,6 +369,11 @@ const ProductsCategoriesCategoryIdRoute =path: '/products/categories/$categoryId',getParentRoute: () => authenticatedStoreIdRoute,} as any)+const OrdersOrderIdEditRoute = OrdersOrderIdEditRouteImport.update({+ id: '/orders/$orderId/edit',+ path: '/orders/$orderId/edit',+ getParentRoute: () => authenticatedStoreIdRoute,+} as any)const SettingsDeliveryProfilesProfileIdIndexRoute =SettingsDeliveryProfilesProfileIdIndexRouteImport.update({id: '/delivery-profiles/$profileId/',@@ -409,7 +415,6 @@ export interface FileRoutesByFullPath {'/$storeId/': typeof IndexRoute'/$storeId/customers/$customerId': typeof CustomersCustomerIdRoute'/$storeId/customers/groups': typeof CustomersGroupsRoute- '/$storeId/orders/$orderId': typeof OrdersOrderIdRoute'/$storeId/orders/drafts': typeof OrdersDraftsRoute'/$storeId/orders/new': typeof OrdersNewRoute'/$storeId/products/$productId': typeof ProductsProductIdRoute@@ -439,12 +444,14 @@ export interface FileRoutesByFullPath {'/$storeId/products/': typeof ProductsIndexRoute'/$storeId/promotions/': typeof PromotionsIndexRoute'/$storeId/settings/': typeof SettingsIndexRoute+ '/$storeId/orders/$orderId/edit': typeof OrdersOrderIdEditRoute'/$storeId/products/categories/$categoryId': typeof ProductsCategoriesCategoryIdRoute'/$storeId/products/categories/new': typeof ProductsCategoriesNewRoute'/$storeId/products/collections/$collectionId': typeof ProductsCollectionsCollectionIdRoute'/$storeId/products/collections/new': typeof ProductsCollectionsNewRoute'/$storeId/products/price-lists/new': typeof ProductsPriceListsNewRoute'/$storeId/settings/webhooks/$webhookEndpointId': typeof SettingsWebhooksWebhookEndpointIdRoute+ '/$storeId/orders/$orderId/': typeof OrdersOrderIdIndexRoute'/$storeId/products/categories/': typeof ProductsCategoriesIndexRoute'/$storeId/products/collections/': typeof ProductsCollectionsIndexRoute'/$storeId/products/price-lists/': typeof ProductsPriceListsIndexRoute@@ -470,7 +477,6 @@ export interface FileRoutesByTo {'/$storeId': typeof IndexRoute'/$storeId/customers/$customerId': typeof CustomersCustomerIdRoute'/$storeId/customers/groups': typeof CustomersGroupsRoute- '/$storeId/orders/$orderId': typeof OrdersOrderIdRoute'/$storeId/orders/drafts': typeof OrdersDraftsRoute'/$storeId/orders/new': typeof OrdersNewRoute'/$storeId/products/$productId': typeof ProductsProductIdRoute@@ -500,12 +506,14 @@ export interface FileRoutesByTo {'/$storeId/products': typeof ProductsIndexRoute'/$storeId/promotions': typeof PromotionsIndexRoute'/$storeId/settings': typeof SettingsIndexRoute+ '/$storeId/orders/$orderId/edit': typeof OrdersOrderIdEditRoute'/$storeId/products/categories/$categoryId': typeof ProductsCategoriesCategoryIdRoute'/$storeId/products/categories/new': typeof ProductsCategoriesNewRoute'/$storeId/products/collections/$collectionId': typeof ProductsCollectionsCollectionIdRoute'/$storeId/products/collections/new': typeof ProductsCollectionsNewRoute'/$storeId/products/price-lists/new': typeof ProductsPriceListsNewRoute'/$storeId/settings/webhooks/$webhookEndpointId': typeof SettingsWebhooksWebhookEndpointIdRoute+ '/$storeId/orders/$orderId': typeof OrdersOrderIdIndexRoute'/$storeId/products/categories': typeof ProductsCategoriesIndexRoute'/$storeId/products/collections': typeof ProductsCollectionsIndexRoute'/$storeId/products/price-lists': typeof ProductsPriceListsIndexRoute@@ -535,7 +543,6 @@ export interface FileRoutesById {'/_authenticated/$storeId/': typeof IndexRoute'/_authenticated/$storeId/customers/$customerId': typeof CustomersCustomerIdRoute'/_authenticated/$storeId/customers/groups': typeof CustomersGroupsRoute- '/_authenticated/$storeId/orders/$orderId': typeof OrdersOrderIdRoute'/_authenticated/$storeId/orders/drafts': typeof OrdersDraftsRoute'/_authenticated/$storeId/orders/new': typeof OrdersNewRoute'/_authenticated/$storeId/products/$productId': typeof ProductsProductIdRoute@@ -565,12 +572,14 @@ export interface FileRoutesById {'/_authenticated/$storeId/products/': typeof ProductsIndexRoute'/_authenticated/$storeId/promotions/': typeof PromotionsIndexRoute'/_authenticated/$storeId/settings/': typeof SettingsIndexRoute+ '/_authenticated/$storeId/orders/$orderId/edit': typeof OrdersOrderIdEditRoute'/_authenticated/$storeId/products/categories/$categoryId': typeof ProductsCategoriesCategoryIdRoute'/_authenticated/$storeId/products/categories/new': typeof ProductsCategoriesNewRoute'/_authenticated/$storeId/products/collections/$collectionId': typeof ProductsCollectionsCollectionIdRoute'/_authenticated/$storeId/products/collections/new': typeof ProductsCollectionsNewRoute'/_authenticated/$storeId/products/price-lists/new': typeof ProductsPriceListsNewRoute'/_authenticated/$storeId/settings/webhooks/$webhookEndpointId': typeof SettingsWebhooksWebhookEndpointIdRoute+ '/_authenticated/$storeId/orders/$orderId/': typeof OrdersOrderIdIndexRoute'/_authenticated/$storeId/products/categories/': typeof ProductsCategoriesIndexRoute'/_authenticated/$storeId/products/collections/': typeof ProductsCollectionsIndexRoute'/_authenticated/$storeId/products/price-lists/': typeof ProductsPriceListsIndexRoute@@ -600,7 +609,6 @@ export interface FileRouteTypes {| '/$storeId/'| '/$storeId/customers/$customerId'| '/$storeId/customers/groups'- | '/$storeId/orders/$orderId'| '/$storeId/orders/drafts'| '/$storeId/orders/new'| '/$storeId/products/$productId'@@ -630,12 +638,14 @@ export interface FileRouteTypes {| '/$storeId/products/'| '/$storeId/promotions/'| '/$storeId/settings/'+ | '/$storeId/orders/$orderId/edit'| '/$storeId/products/categories/$categoryId'| '/$storeId/products/categories/new'| '/$storeId/products/collections/$collectionId'| '/$storeId/products/collections/new'| '/$storeId/products/price-lists/new'| '/$storeId/settings/webhooks/$webhookEndpointId'+ | '/$storeId/orders/$orderId/'| '/$storeId/products/categories/'| '/$storeId/products/collections/'| '/$storeId/products/price-lists/'@@ -661,7 +671,6 @@ export interface FileRouteTypes {| '/$storeId'| '/$storeId/customers/$customerId'| '/$storeId/customers/groups'- | '/$storeId/orders/$orderId'| '/$storeId/orders/drafts'| '/$storeId/orders/new'| '/$storeId/products/$productId'@@ -691,12 +700,14 @@ export interface FileRouteTypes {| '/$storeId/products'| '/$storeId/promotions'| '/$storeId/settings'+ | '/$storeId/orders/$orderId/edit'| '/$storeId/products/categories/$categoryId'| '/$storeId/products/categories/new'| '/$storeId/products/collections/$collectionId'| '/$storeId/products/collections/new'| '/$storeId/products/price-lists/new'| '/$storeId/settings/webhooks/$webhookEndpointId'+ | '/$storeId/orders/$orderId'| '/$storeId/products/categories'| '/$storeId/products/collections'| '/$storeId/products/price-lists'@@ -725,7 +736,6 @@ export interface FileRouteTypes {| '/_authenticated/$storeId/'| '/_authenticated/$storeId/customers/$customerId'| '/_authenticated/$storeId/customers/groups'- | '/_authenticated/$storeId/orders/$orderId'| '/_authenticated/$storeId/orders/drafts'| '/_authenticated/$storeId/orders/new'| '/_authenticated/$storeId/products/$productId'@@ -755,12 +765,14 @@ export interface FileRouteTypes {| '/_authenticated/$storeId/products/'| '/_authenticated/$storeId/promotions/'| '/_authenticated/$storeId/settings/'+ | '/_authenticated/$storeId/orders/$orderId/edit'| '/_authenticated/$storeId/products/categories/$categoryId'| '/_authenticated/$storeId/products/categories/new'| '/_authenticated/$storeId/products/collections/$collectionId'| '/_authenticated/$storeId/products/collections/new'| '/_authenticated/$storeId/products/price-lists/new'| '/_authenticated/$storeId/settings/webhooks/$webhookEndpointId'+ | '/_authenticated/$storeId/orders/$orderId/'| '/_authenticated/$storeId/products/categories/'| '/_authenticated/$storeId/products/collections/'| '/_authenticated/$storeId/products/price-lists/'@@ -1084,13 +1096,6 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof OrdersDraftsRouteImportparentRoute: typeof authenticatedStoreIdRoute}- '/_authenticated/$storeId/orders/$orderId': {- id: '/_authenticated/$storeId/orders/$orderId'- path: '/orders/$orderId'- fullPath: '/$storeId/orders/$orderId'- preLoaderRoute: typeof OrdersOrderIdRouteImport- parentRoute: typeof authenticatedStoreIdRoute- }'/_authenticated/$storeId/customers/groups': {id: '/_authenticated/$storeId/customers/groups'path: '/customers/groups'@@ -1147,6 +1152,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof ProductsCategoriesIndexRouteImportparentRoute: typeof authenticatedStoreIdRoute}+ '/_authenticated/$storeId/orders/$orderId/': {+ id: '/_authenticated/$storeId/orders/$orderId/'+ path: '/orders/$orderId'+ fullPath: '/$storeId/orders/$orderId/'+ preLoaderRoute: typeof OrdersOrderIdIndexRouteImport+ parentRoute: typeof authenticatedStoreIdRoute+ }'/_authenticated/$storeId/settings/webhooks/$webhookEndpointId': {id: '/_authenticated/$storeId/settings/webhooks/$webhookEndpointId'path: '/webhooks/$webhookEndpointId'@@ -1189,6 +1201,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof ProductsCategoriesCategoryIdRouteImportparentRoute: typeof authenticatedStoreIdRoute}+ '/_authenticated/$storeId/orders/$orderId/edit': {+ id: '/_authenticated/$storeId/orders/$orderId/edit'+ path: '/orders/$orderId/edit'+ fullPath: '/$storeId/orders/$orderId/edit'+ preLoaderRoute: typeof OrdersOrderIdEditRouteImport+ parentRoute: typeof authenticatedStoreIdRoute+ }'/_authenticated/$storeId/settings/delivery-profiles/$profileId/': {id: '/_authenticated/$storeId/settings/delivery-profiles/$profileId/'path: '/delivery-profiles/$profileId'@@ -1290,7 +1309,6 @@ interface authenticatedStoreIdRouteChildren {IndexRoute: typeof IndexRouteCustomersCustomerIdRoute: typeof CustomersCustomerIdRouteCustomersGroupsRoute: typeof CustomersGroupsRoute- OrdersOrderIdRoute: typeof OrdersOrderIdRouteOrdersDraftsRoute: typeof OrdersDraftsRouteOrdersNewRoute: typeof OrdersNewRouteProductsProductIdRoute: typeof ProductsProductIdRoute@@ -1304,11 +1322,13 @@ interface authenticatedStoreIdRouteChildren {OrdersIndexRoute: typeof OrdersIndexRouteProductsIndexRoute: typeof ProductsIndexRoutePromotionsIndexRoute: typeof PromotionsIndexRoute+ OrdersOrderIdEditRoute: typeof OrdersOrderIdEditRouteProductsCategoriesCategoryIdRoute: typeof ProductsCategoriesCategoryIdRouteProductsCategoriesNewRoute: typeof ProductsCategoriesNewRouteProductsCollectionsCollectionIdRoute: typeof ProductsCollectionsCollectionIdRouteProductsCollectionsNewRoute: typeof ProductsCollectionsNewRouteProductsPriceListsNewRoute: typeof ProductsPriceListsNewRoute+ OrdersOrderIdIndexRoute: typeof OrdersOrderIdIndexRouteProductsCategoriesIndexRoute: typeof ProductsCategoriesIndexRouteProductsCollectionsIndexRoute: typeof ProductsCollectionsIndexRouteProductsPriceListsIndexRoute: typeof ProductsPriceListsIndexRoute@@ -1325,7 +1345,6 @@ const authenticatedStoreIdRouteChildren: authenticatedStoreIdRouteChildren = {IndexRoute: IndexRoute,CustomersCustomerIdRoute: CustomersCustomerIdRoute,CustomersGroupsRoute: CustomersGroupsRoute,- OrdersOrderIdRoute: OrdersOrderIdRoute,OrdersDraftsRoute: OrdersDraftsRoute,OrdersNewRoute: OrdersNewRoute,ProductsProductIdRoute: ProductsProductIdRoute,@@ -1339,11 +1358,13 @@ const authenticatedStoreIdRouteChildren: authenticatedStoreIdRouteChildren = {OrdersIndexRoute: OrdersIndexRoute,ProductsIndexRoute: ProductsIndexRoute,PromotionsIndexRoute: PromotionsIndexRoute,+ OrdersOrderIdEditRoute: OrdersOrderIdEditRoute,ProductsCategoriesCategoryIdRoute: ProductsCategoriesCategoryIdRoute,ProductsCategoriesNewRoute: ProductsCategoriesNewRoute,ProductsCollectionsCollectionIdRoute: ProductsCollectionsCollectionIdRoute,ProductsCollectionsNewRoute: ProductsCollectionsNewRoute,ProductsPriceListsNewRoute: ProductsPriceListsNewRoute,+ OrdersOrderIdIndexRoute: OrdersOrderIdIndexRoute,ProductsCategoriesIndexRoute: ProductsCategoriesIndexRoute,ProductsCollectionsIndexRoute: ProductsCollectionsIndexRoute,ProductsPriceListsIndexRoute: ProductsPriceListsIndexRoute,diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId/edit.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId/edit.tsxnew file mode 100644index 0000000000..02c66108fe--- /dev/null+++ b/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId/edit.tsx@@ -0,0 +1,275 @@+import type { LineItem, Order } from '@spree/admin-sdk'+import { adminClient, PageHeader } from '@spree/dashboard-core'+import {+ Button,+ Card,+ CardContent,+ CardHeader,+ CardTitle,+ cn,+ ErrorState,+ ResourceLayout,+ Separator,+ Table,+ TableBody,+ TableCell,+ TableHead,+ TableHeader,+ TableRow,+ useConfirm,+} from '@spree/dashboard-ui'+import { createFileRoute } from '@tanstack/react-router'+import { PackageIcon, PencilIcon, PlusIcon, Trash2Icon } from 'lucide-react'+import { type ReactNode, useState } from 'react'+import { useTranslation } from 'react-i18next'+import {+ AddLineItemDialog,+ EditQuantityDialog,+} from '../../../../../components/spree/orders/line-item-dialogs'+import { useOrder, useOrderMutation } from '../../../../../hooks/use-order'++export const Route = createFileRoute('/_authenticated/$storeId/orders/$orderId/edit')({+ component: OrderEditPage,+})++/**+ * One row of the items table. Every action fires its own request against the+ * line-item endpoints and the order re-reads from the server — there is no+ * pending-edit buffer, so totals only move once a write has landed.+ */+function LineItemRow({ orderId, item }: { orderId: string; item: LineItem }) {+ const { t } = useTranslation()+ const confirm = useConfirm()+ const [editingQuantity, setEditingQuantity] = useState(false)++ const removeMutation = useOrderMutation(orderId, () =>+ adminClient.orders.items.delete(orderId, item.id),+ )++ async function handleRemove() {+ const confirmed = await confirm({+ title: t('admin.orders.edit.confirm.remove_title'),+ message: t('admin.orders.edit.confirm.remove_message', { name: item.name }),+ confirmLabel: t('admin.orders.edit.actions.remove'),+ variant: 'destructive',+ })+ if (confirmed) removeMutation.mutate(undefined)+ }++ return (+ <>+ <TableRow>+ <TableCell>+ <div className="flex items-center gap-3">+ {item.thumbnail_url ? (+ <img+ src={item.thumbnail_url}+ alt={item.name}+ className="size-12 shrink-0 rounded-lg border object-cover"+ />+ ) : (+ <div className="flex size-12 shrink-0 items-center justify-center rounded-lg border bg-muted">+ <PackageIcon className="size-5 text-muted-foreground" />+ </div>+ )}+ <div className="min-w-0">+ <div className="truncate text-sm font-medium">{item.name}</div>+ {item.options_text && (+ <div className="truncate text-xs text-muted-foreground">{item.options_text}</div>+ )}+ </div>+ </div>+ </TableCell>+ <TableCell className="text-right whitespace-nowrap">{item.display_price}</TableCell>+ <TableCell className="text-right">{item.quantity}</TableCell>+ <TableCell className="text-right whitespace-nowrap">{item.display_total}</TableCell>+ <TableCell className="text-right">+ <div className="flex items-center justify-end gap-1">+ <Button+ variant="ghost"+ size="icon"+ onClick={() => setEditingQuantity(true)}+ aria-label={t('admin.orders.edit.actions.edit_quantity_for', { name: item.name })}+ >+ <PencilIcon className="size-4" />+ </Button>+ <Button+ variant="ghost"+ size="icon"+ onClick={handleRemove}+ disabled={removeMutation.isPending}+ aria-label={t('admin.orders.edit.actions.remove_item', { name: item.name })}+ >+ <Trash2Icon className="size-4 text-destructive" />+ </Button>+ </div>+ </TableCell>+ </TableRow>++ {editingQuantity && (+ <EditQuantityDialog+ orderId={orderId}+ lineItemId={item.id}+ currentQuantity={item.quantity}+ open={editingQuantity}+ onOpenChange={setEditingQuantity}+ />+ )}+ </>+ )+}++function TotalRow({ label, value, bold }: { label: string; value: ReactNode; bold?: boolean }) {+ return (+ <div className="flex items-center justify-between px-5 py-2.5">+ <span className="text-sm">{label}</span>+ <span className={cn('text-sm', bold && 'font-bold')}>{value}</span>+ </div>+ )+}++/**+ * The order's totals as the server currently has them. Deliberately not a+ * projection: 6.0 cannot compute what an edit would cost without writing the+ * rows, so this only ever reflects writes that already landed.+ */+function OrderTotalsCard({ order }: { order: Order }) {+ const { t } = useTranslation()++ return (+ <Card className="gap-0 py-0">+ <CardHeader className="px-5 py-4">+ <CardTitle>{t('admin.orders.edit.totals_title')}</CardTitle>+ </CardHeader>++ <Separator />++ <div className="py-2">+ <TotalRow label={t('admin.fields.subtotal.label')} value={order.display_item_total} />++ {Number.parseFloat(order.delivery_total) > 0 && (+ <TotalRow label={t('admin.fields.shipping.label')} value={order.display_delivery_total} />+ )}++ {Number.parseFloat(order.discount_total) !== 0 && (+ <TotalRow+ label={t('admin.orders.detail.summary.promotions')}+ value={order.display_discount_total}+ />+ )}++ {Number.parseFloat(order.included_tax_total) > 0 && (+ <TotalRow+ label={t('admin.orders.detail.summary.tax_included')}+ value={order.display_included_tax_total}+ />+ )}++ {Number.parseFloat(order.additional_tax_total) > 0 && (+ <TotalRow+ label={t('admin.orders.detail.summary.tax_additional')}+ value={order.display_additional_tax_total}+ />+ )}++ <Separator />++ <TotalRow label={t('admin.fields.total.label')} value={order.display_total} bold />+ </div>++ <Separator />++ <CardContent className="px-5 py-4">+ <p className="text-xs text-muted-foreground">{t('admin.orders.edit.totals_hint')}</p>+ </CardContent>+ </Card>+ )+}++/**+ * Post-placement line-item management: add a product, change a quantity,+ * remove an item. Each interaction is one request, immediately applied.+ */+function OrderEditPage() {+ const { t } = useTranslation()+ const { storeId, orderId } = Route.useParams()+ const { data: order, isLoading, error, refetch } = useOrder(orderId)+ const [addingItem, setAddingItem] = useState(false)++ if (!order && isLoading) return null++ if (error || !order) {+ return (+ <ErrorState+ title={t('admin.errors.failed_to_load_order')}+ description={t('admin.orders.detail.load_failed_message', { orderId })}+ error={error as Error | undefined}+ onRetry={() => refetch()}+ />+ )+ }++ const items = order.items ?? []++ return (+ <>+ <ResourceLayout+ header={+ <PageHeader+ title={t('admin.orders.edit.title')}+ subtitle={t('admin.orders.edit.subtitle', { number: order.number })}+ backTo={`${storeId}/orders/${orderId}`}+ actions={+ <Button onClick={() => setAddingItem(true)}>+ <PlusIcon className="size-4" />+ {t('admin.orders.edit.actions.add_product')}+ </Button>+ }+ />+ }+ main={+ <Card>+ <CardHeader>+ <CardTitle>{t('admin.orders.edit.items_title')}</CardTitle>+ </CardHeader>+ <CardContent>+ {items.length === 0 ? (+ <p className="py-8 text-center text-muted-foreground">+ {t('admin.orders.edit.empty')}+ </p>+ ) : (+ <Table>+ <TableHeader>+ <TableRow>+ <TableHead>{t('admin.orders.edit.columns.product')}</TableHead>+ <TableHead className="text-right">+ {t('admin.orders.edit.columns.unit_price')}+ </TableHead>+ <TableHead className="text-right">+ {t('admin.fields.quantity.label')}+ </TableHead>+ <TableHead className="text-right">+ {t('admin.orders.edit.columns.line_total')}+ </TableHead>+ <TableHead className="w-24" />+ </TableRow>+ </TableHeader>+ <TableBody>+ {items.map((item) => (+ <LineItemRow key={item.id} orderId={orderId} item={item} />+ ))}+ </TableBody>+ </Table>+ )}+ </CardContent>+ </Card>+ }+ sidebar={<OrderTotalsCard order={order} />}+ />++ {addingItem && (+ <AddLineItemDialog orderId={orderId} open={addingItem} onOpenChange={setAddingItem} />+ )}+ </>+ )+}diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId/index.tsxsimilarity index 98%rename from packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId.tsxrename to packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId/index.tsxindex 94832b9d1d..d485f2238b 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/orders/$orderId/index.tsx@@ -84,13 +84,13 @@ import { useTranslation } from 'react-i18next'import {CustomFieldsInlineCard,EditableApiCustomFieldsProvider,-} from '../../../../components/spree/custom-fields/custom-fields-inline'+} from '../../../../../components/spree/custom-fields/custom-fields-inline'import {OrderClaimsCard,OrderExchangesCard,-} from '../../../../components/spree/order-post-sale-cards'-import { OrderReturnsCard } from '../../../../components/spree/order-returns-card'-import { FulfillmentsCard } from '../../../../components/spree/orders/fulfillments-card'+} from '../../../../../components/spree/order-post-sale-cards'+import { OrderReturnsCard } from '../../../../../components/spree/order-returns-card'+import { FulfillmentsCard } from '../../../../../components/spree/orders/fulfillments-card'import {orderQueryKey,useOrder,@@ -99,11 +99,11 @@ import {useOrderFees,useOrderMutation,useOrderTaxLines,-} from '../../../../hooks/use-order'-import { spreeJsonLinkResolver } from '../../../../lib/json-link-resolver'-import { FEE_KINDS } from '../../../../schemas/order'+} from '../../../../../hooks/use-order'+import { spreeJsonLinkResolver } from '../../../../../lib/json-link-resolver'+import { FEE_KINDS } from '../../../../../schemas/order'-export const Route = createFileRoute('/_authenticated/$storeId/orders/$orderId')({+export const Route = createFileRoute('/_authenticated/$storeId/orders/$orderId/')({component: OrderDetailPage,})@@ -342,6 +342,14 @@ function OrderHeader({ order }: { order: Order }) {subtitle={subtitle}backTo={backFallback}badges={badges}+ actions={+ <Button asChild variant="outline">+ <Link to="/$storeId/orders/$orderId/edit" params={{ storeId, orderId }}>+ <PencilIcon className="size-4" />+ {t('admin.orders.edit.action_label')}+ </Link>+ </Button>+ }dropdownItems={dropdownItems}resource={{ id: order.id, number: order.number }}jsonPreview={{diff --git a/packages/dashboard/src/schemas/fulfillment.ts b/packages/dashboard/src/schemas/fulfillment.tsnew file mode 100644index 0000000000..2ec7f38b1c--- /dev/null+++ b/packages/dashboard/src/schemas/fulfillment.ts@@ -0,0 +1,33 @@+import { i18n } from '@spree/dashboard-core'+import { z } from 'zod/v4'++/**+ * What the merchant chose to ship out of one fulfillment: per-item quantities+ * plus the tracking number and whether the customer hears about it.+ *+ * Every item the fulfillment holds gets a row, so an unselected row means+ * "leave this one behind" rather than being absent — the payload drops the+ * unselected rows on submit.+ *+ * The upper bound is per row (how many units that fulfillment holds), so it+ * lives on the field rather than in the schema; the schema only enforces that+ * a quantity is a whole number that is not negative. Shipping nothing at all+ * is prevented by disabling the submit, since it is a no-op rather than a+ * validation failure.+ */+export const fulfillItemsFormSchema = z.object({+ items: z.array(+ z.object({+ item_id: z.string(),+ selected: z.boolean(),+ quantity: z+ .number({ error: () => i18n.t('admin.orders.fulfill.validation.quantity_invalid') })+ .int({ error: () => i18n.t('admin.orders.fulfill.validation.quantity_invalid') })+ .min(0, { error: () => i18n.t('admin.orders.fulfill.validation.quantity_invalid') }),+ }),+ ),+ tracking: z.string(),+ notify_customer: z.boolean(),+})++export type FulfillItemsFormValues = z.infer<typeof fulfillItemsFormSchema>