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
Let a merchant correct a draft transfer or order
Łukasz Adamczykc7ba193b1660
diff --git a/packages/admin-sdk/src/params.ts b/packages/admin-sdk/src/params.tsindex 7a75096afc..790deadf65 100644--- a/packages/admin-sdk/src/params.ts+++ b/packages/admin-sdk/src/params.ts@@ -1497,9 +1497,9 @@ export interface StockTransferItemParams {export interface StockTransferCreateParams {source_location_id: stringdestination_location_id: string- /** The merchant's own label for the trip. */- reference?: string- notes?: string+ /** The merchant's own label for the trip. `null` clears it. */+ reference?: string | null+ notes?: string | null/*** A draft may open empty and gain lines as the merchant packs. Sending the* list replaces whatever the draft currently holds.@@ -1561,11 +1561,11 @@ export interface PurchaseOrderCreateParams {destination_location_id: string/** Defaults to the store's currency; set it for a foreign-currency order. */currency?: string- /** The day the supplier promised, as `yyyy-mm-dd`. */- expected_at?: string- /** The supplier's own order number. */- reference?: string- notes?: string+ /** The day the supplier promised, as `yyyy-mm-dd`. `null` clears it. */+ expected_at?: string | null+ /** The supplier's own order number. `null` clears it. */+ reference?: string | null+ notes?: string | nullitems?: PurchaseOrderItemParams[]metadata?: Record<string, unknown>}diff --git a/packages/dashboard-starter/src/routeTree.gen.ts b/packages/dashboard-starter/src/routeTree.gen.tsindex 80c85bf1fe..2a4e8eb1d2 100644--- a/packages/dashboard-starter/src/routeTree.gen.ts+++ b/packages/dashboard-starter/src/routeTree.gen.ts@@ -34,6 +34,7 @@ import { Route as CompaniesIndexRouteImport } from './../../dashboard/src/routesimport { Route as BrandsDotindexRouteImport } from './../../dashboard-plugin-example/src/routes/brands.index'import { Route as SettingsTaxRatesRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/tax-rates'import { Route as SettingsTaxCategoriesRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/tax-categories'+import { Route as SettingsSuppliersRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/suppliers'import { Route as SettingsStoreRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/store'import { Route as SettingsStockLocationsRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/stock-locations'import { Route as SettingsStaffRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/staff'@@ -73,6 +74,8 @@ import { Route as SettingsWebhooksIndexRouteImport } from './../../dashboard/srcimport { Route as SettingsImportsIndexRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/imports/index'import { Route as SettingsDeliveryProfilesIndexRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/delivery-profiles/index'import { Route as SellersPayoutsIndexRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/sellers/payouts/index'+import { Route as ProductsTransfersIndexRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/transfers/index'+import { Route as ProductsPurchaseOrdersIndexRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/index'import { 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'@@ -80,6 +83,8 @@ import { Route as ProductsCatalogsIndexRouteImport } from './../../dashboard/srcimport { 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 SellersPayoutsPayoutIdRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/sellers/payouts/$payoutId'+import { Route as ProductsTransfersNewRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/transfers/new'+import { Route as ProductsPurchaseOrdersNewRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/new'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'@@ -88,7 +93,11 @@ import { Route as ProductsCategoriesCategoryIdRouteImport } from './../../dashboimport { Route as ProductsCatalogsCatalogIdRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/catalogs/$catalogId'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 ProductsTransfersTransferIdIndexRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/transfers/$transferId/index'+import { Route as ProductsPurchaseOrdersPurchaseOrderIdIndexRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/index'import { Route as ProductsPriceListsPriceListIdIndexRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/price-lists/$priceListId/index'+import { Route as ProductsTransfersTransferIdEditRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/transfers/$transferId/edit'+import { Route as ProductsPurchaseOrdersPurchaseOrderIdEditRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/edit'import { Route as SettingsDeliveryProfilesProfileIdMethodsNewRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new'import { Route as SettingsDeliveryProfilesProfileIdMethodsMethodIdRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/$methodId'@@ -217,6 +226,11 @@ const SettingsTaxCategoriesRoute = SettingsTaxCategoriesRouteImport.update({path: '/tax-categories',getParentRoute: () => SettingsRoute,} as any)+const SettingsSuppliersRoute = SettingsSuppliersRouteImport.update({+ id: '/suppliers',+ path: '/suppliers',+ getParentRoute: () => SettingsRoute,+} as any)const SettingsStoreRoute = SettingsStoreRouteImport.update({id: '/store',path: '/store',@@ -415,6 +429,17 @@ const SellersPayoutsIndexRoute = SellersPayoutsIndexRouteImport.update({path: '/sellers/payouts/',getParentRoute: () => authenticatedStoreIdRoute,} as any)+const ProductsTransfersIndexRoute = ProductsTransfersIndexRouteImport.update({+ id: '/products/transfers/',+ path: '/products/transfers/',+ getParentRoute: () => authenticatedStoreIdRoute,+} as any)+const ProductsPurchaseOrdersIndexRoute =+ ProductsPurchaseOrdersIndexRouteImport.update({+ id: '/products/purchase-orders/',+ path: '/products/purchase-orders/',+ getParentRoute: () => authenticatedStoreIdRoute,+ } as any)const ProductsPriceListsIndexRoute = ProductsPriceListsIndexRouteImport.update({id: '/products/price-lists/',path: '/products/price-lists/',@@ -452,6 +477,17 @@ const SellersPayoutsPayoutIdRoute = SellersPayoutsPayoutIdRouteImport.update({path: '/sellers/payouts/$payoutId',getParentRoute: () => authenticatedStoreIdRoute,} as any)+const ProductsTransfersNewRoute = ProductsTransfersNewRouteImport.update({+ id: '/products/transfers/new',+ path: '/products/transfers/new',+ getParentRoute: () => authenticatedStoreIdRoute,+} as any)+const ProductsPurchaseOrdersNewRoute =+ ProductsPurchaseOrdersNewRouteImport.update({+ id: '/products/purchase-orders/new',+ path: '/products/purchase-orders/new',+ getParentRoute: () => authenticatedStoreIdRoute,+ } as any)const ProductsPriceListsNewRoute = ProductsPriceListsNewRouteImport.update({id: '/products/price-lists/new',path: '/products/price-lists/new',@@ -496,12 +532,36 @@ const SettingsDeliveryProfilesProfileIdIndexRoute =path: '/delivery-profiles/$profileId/',getParentRoute: () => SettingsRoute,} as any)+const ProductsTransfersTransferIdIndexRoute =+ ProductsTransfersTransferIdIndexRouteImport.update({+ id: '/products/transfers/$transferId/',+ path: '/products/transfers/$transferId/',+ getParentRoute: () => authenticatedStoreIdRoute,+ } as any)+const ProductsPurchaseOrdersPurchaseOrderIdIndexRoute =+ ProductsPurchaseOrdersPurchaseOrderIdIndexRouteImport.update({+ id: '/products/purchase-orders/$purchaseOrderId/',+ path: '/products/purchase-orders/$purchaseOrderId/',+ getParentRoute: () => authenticatedStoreIdRoute,+ } as any)const ProductsPriceListsPriceListIdIndexRoute =ProductsPriceListsPriceListIdIndexRouteImport.update({id: '/products/price-lists/$priceListId/',path: '/products/price-lists/$priceListId/',getParentRoute: () => authenticatedStoreIdRoute,} as any)+const ProductsTransfersTransferIdEditRoute =+ ProductsTransfersTransferIdEditRouteImport.update({+ id: '/products/transfers/$transferId/edit',+ path: '/products/transfers/$transferId/edit',+ getParentRoute: () => authenticatedStoreIdRoute,+ } as any)+const ProductsPurchaseOrdersPurchaseOrderIdEditRoute =+ ProductsPurchaseOrdersPurchaseOrderIdEditRouteImport.update({+ id: '/products/purchase-orders/$purchaseOrderId/edit',+ path: '/products/purchase-orders/$purchaseOrderId/edit',+ getParentRoute: () => authenticatedStoreIdRoute,+ } as any)const SettingsDeliveryProfilesProfileIdMethodsNewRoute =SettingsDeliveryProfilesProfileIdMethodsNewRouteImport.update({id: '/delivery-profiles/$profileId/methods/new',@@ -565,6 +625,7 @@ export interface FileRoutesByFullPath {'/$storeId/settings/staff': typeof SettingsStaffRoute'/$storeId/settings/stock-locations': typeof SettingsStockLocationsRoute'/$storeId/settings/store': typeof SettingsStoreRoute+ '/$storeId/settings/suppliers': typeof SettingsSuppliersRoute'/$storeId/settings/tax-categories': typeof SettingsTaxCategoriesRoute'/$storeId/settings/tax-rates': typeof SettingsTaxRatesRoute'/$storeId/brands/': typeof BrandsDotindexRoute@@ -582,6 +643,8 @@ export interface FileRoutesByFullPath {'/$storeId/products/collections/$collectionId': typeof ProductsCollectionsCollectionIdRoute'/$storeId/products/collections/new': typeof ProductsCollectionsNewRoute'/$storeId/products/price-lists/new': typeof ProductsPriceListsNewRoute+ '/$storeId/products/purchase-orders/new': typeof ProductsPurchaseOrdersNewRoute+ '/$storeId/products/transfers/new': typeof ProductsTransfersNewRoute'/$storeId/sellers/payouts/$payoutId': typeof SellersPayoutsPayoutIdRoute'/$storeId/settings/webhooks/$webhookEndpointId': typeof SettingsWebhooksWebhookEndpointIdRoute'/$storeId/orders/$orderId/': typeof OrdersOrderIdIndexRoute@@ -589,11 +652,17 @@ export interface FileRoutesByFullPath {'/$storeId/products/categories/': typeof ProductsCategoriesIndexRoute'/$storeId/products/collections/': typeof ProductsCollectionsIndexRoute'/$storeId/products/price-lists/': typeof ProductsPriceListsIndexRoute+ '/$storeId/products/purchase-orders/': typeof ProductsPurchaseOrdersIndexRoute+ '/$storeId/products/transfers/': typeof ProductsTransfersIndexRoute'/$storeId/sellers/payouts/': typeof SellersPayoutsIndexRoute'/$storeId/settings/delivery-profiles/': typeof SettingsDeliveryProfilesIndexRoute'/$storeId/settings/imports/': typeof SettingsImportsIndexRoute'/$storeId/settings/webhooks/': typeof SettingsWebhooksIndexRoute+ '/$storeId/products/purchase-orders/$purchaseOrderId/edit': typeof ProductsPurchaseOrdersPurchaseOrderIdEditRoute+ '/$storeId/products/transfers/$transferId/edit': typeof ProductsTransfersTransferIdEditRoute'/$storeId/products/price-lists/$priceListId/': typeof ProductsPriceListsPriceListIdIndexRoute+ '/$storeId/products/purchase-orders/$purchaseOrderId/': typeof ProductsPurchaseOrdersPurchaseOrderIdIndexRoute+ '/$storeId/products/transfers/$transferId/': typeof ProductsTransfersTransferIdIndexRoute'/$storeId/settings/delivery-profiles/$profileId/': typeof SettingsDeliveryProfilesProfileIdIndexRoute'/$storeId/settings/delivery-profiles/$profileId/methods/$methodId': typeof SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute'/$storeId/settings/delivery-profiles/$profileId/methods/new': typeof SettingsDeliveryProfilesProfileIdMethodsNewRoute@@ -646,6 +715,7 @@ export interface FileRoutesByTo {'/$storeId/settings/staff': typeof SettingsStaffRoute'/$storeId/settings/stock-locations': typeof SettingsStockLocationsRoute'/$storeId/settings/store': typeof SettingsStoreRoute+ '/$storeId/settings/suppliers': typeof SettingsSuppliersRoute'/$storeId/settings/tax-categories': typeof SettingsTaxCategoriesRoute'/$storeId/settings/tax-rates': typeof SettingsTaxRatesRoute'/$storeId/brands': typeof BrandsDotindexRoute@@ -663,6 +733,8 @@ export interface FileRoutesByTo {'/$storeId/products/collections/$collectionId': typeof ProductsCollectionsCollectionIdRoute'/$storeId/products/collections/new': typeof ProductsCollectionsNewRoute'/$storeId/products/price-lists/new': typeof ProductsPriceListsNewRoute+ '/$storeId/products/purchase-orders/new': typeof ProductsPurchaseOrdersNewRoute+ '/$storeId/products/transfers/new': typeof ProductsTransfersNewRoute'/$storeId/sellers/payouts/$payoutId': typeof SellersPayoutsPayoutIdRoute'/$storeId/settings/webhooks/$webhookEndpointId': typeof SettingsWebhooksWebhookEndpointIdRoute'/$storeId/orders/$orderId': typeof OrdersOrderIdIndexRoute@@ -670,11 +742,17 @@ export interface FileRoutesByTo {'/$storeId/products/categories': typeof ProductsCategoriesIndexRoute'/$storeId/products/collections': typeof ProductsCollectionsIndexRoute'/$storeId/products/price-lists': typeof ProductsPriceListsIndexRoute+ '/$storeId/products/purchase-orders': typeof ProductsPurchaseOrdersIndexRoute+ '/$storeId/products/transfers': typeof ProductsTransfersIndexRoute'/$storeId/sellers/payouts': typeof SellersPayoutsIndexRoute'/$storeId/settings/delivery-profiles': typeof SettingsDeliveryProfilesIndexRoute'/$storeId/settings/imports': typeof SettingsImportsIndexRoute'/$storeId/settings/webhooks': typeof SettingsWebhooksIndexRoute+ '/$storeId/products/purchase-orders/$purchaseOrderId/edit': typeof ProductsPurchaseOrdersPurchaseOrderIdEditRoute+ '/$storeId/products/transfers/$transferId/edit': typeof ProductsTransfersTransferIdEditRoute'/$storeId/products/price-lists/$priceListId': typeof ProductsPriceListsPriceListIdIndexRoute+ '/$storeId/products/purchase-orders/$purchaseOrderId': typeof ProductsPurchaseOrdersPurchaseOrderIdIndexRoute+ '/$storeId/products/transfers/$transferId': typeof ProductsTransfersTransferIdIndexRoute'/$storeId/settings/delivery-profiles/$profileId': typeof SettingsDeliveryProfilesProfileIdIndexRoute'/$storeId/settings/delivery-profiles/$profileId/methods/$methodId': typeof SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute'/$storeId/settings/delivery-profiles/$profileId/methods/new': typeof SettingsDeliveryProfilesProfileIdMethodsNewRoute@@ -731,6 +809,7 @@ export interface FileRoutesById {'/_authenticated/$storeId/settings/staff': typeof SettingsStaffRoute'/_authenticated/$storeId/settings/stock-locations': typeof SettingsStockLocationsRoute'/_authenticated/$storeId/settings/store': typeof SettingsStoreRoute+ '/_authenticated/$storeId/settings/suppliers': typeof SettingsSuppliersRoute'/_authenticated/$storeId/settings/tax-categories': typeof SettingsTaxCategoriesRoute'/_authenticated/$storeId/settings/tax-rates': typeof SettingsTaxRatesRoute'/_authenticated/$storeId/brands/': typeof BrandsDotindexRoute@@ -748,6 +827,8 @@ export interface FileRoutesById {'/_authenticated/$storeId/products/collections/$collectionId': typeof ProductsCollectionsCollectionIdRoute'/_authenticated/$storeId/products/collections/new': typeof ProductsCollectionsNewRoute'/_authenticated/$storeId/products/price-lists/new': typeof ProductsPriceListsNewRoute+ '/_authenticated/$storeId/products/purchase-orders/new': typeof ProductsPurchaseOrdersNewRoute+ '/_authenticated/$storeId/products/transfers/new': typeof ProductsTransfersNewRoute'/_authenticated/$storeId/sellers/payouts/$payoutId': typeof SellersPayoutsPayoutIdRoute'/_authenticated/$storeId/settings/webhooks/$webhookEndpointId': typeof SettingsWebhooksWebhookEndpointIdRoute'/_authenticated/$storeId/orders/$orderId/': typeof OrdersOrderIdIndexRoute@@ -755,11 +836,17 @@ export interface FileRoutesById {'/_authenticated/$storeId/products/categories/': typeof ProductsCategoriesIndexRoute'/_authenticated/$storeId/products/collections/': typeof ProductsCollectionsIndexRoute'/_authenticated/$storeId/products/price-lists/': typeof ProductsPriceListsIndexRoute+ '/_authenticated/$storeId/products/purchase-orders/': typeof ProductsPurchaseOrdersIndexRoute+ '/_authenticated/$storeId/products/transfers/': typeof ProductsTransfersIndexRoute'/_authenticated/$storeId/sellers/payouts/': typeof SellersPayoutsIndexRoute'/_authenticated/$storeId/settings/delivery-profiles/': typeof SettingsDeliveryProfilesIndexRoute'/_authenticated/$storeId/settings/imports/': typeof SettingsImportsIndexRoute'/_authenticated/$storeId/settings/webhooks/': typeof SettingsWebhooksIndexRoute+ '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/edit': typeof ProductsPurchaseOrdersPurchaseOrderIdEditRoute+ '/_authenticated/$storeId/products/transfers/$transferId/edit': typeof ProductsTransfersTransferIdEditRoute'/_authenticated/$storeId/products/price-lists/$priceListId/': typeof ProductsPriceListsPriceListIdIndexRoute+ '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/': typeof ProductsPurchaseOrdersPurchaseOrderIdIndexRoute+ '/_authenticated/$storeId/products/transfers/$transferId/': typeof ProductsTransfersTransferIdIndexRoute'/_authenticated/$storeId/settings/delivery-profiles/$profileId/': typeof SettingsDeliveryProfilesProfileIdIndexRoute'/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/$methodId': typeof SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute'/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new': typeof SettingsDeliveryProfilesProfileIdMethodsNewRoute@@ -816,6 +903,7 @@ export interface FileRouteTypes {| '/$storeId/settings/staff'| '/$storeId/settings/stock-locations'| '/$storeId/settings/store'+ | '/$storeId/settings/suppliers'| '/$storeId/settings/tax-categories'| '/$storeId/settings/tax-rates'| '/$storeId/brands/'@@ -833,6 +921,8 @@ export interface FileRouteTypes {| '/$storeId/products/collections/$collectionId'| '/$storeId/products/collections/new'| '/$storeId/products/price-lists/new'+ | '/$storeId/products/purchase-orders/new'+ | '/$storeId/products/transfers/new'| '/$storeId/sellers/payouts/$payoutId'| '/$storeId/settings/webhooks/$webhookEndpointId'| '/$storeId/orders/$orderId/'@@ -840,11 +930,17 @@ export interface FileRouteTypes {| '/$storeId/products/categories/'| '/$storeId/products/collections/'| '/$storeId/products/price-lists/'+ | '/$storeId/products/purchase-orders/'+ | '/$storeId/products/transfers/'| '/$storeId/sellers/payouts/'| '/$storeId/settings/delivery-profiles/'| '/$storeId/settings/imports/'| '/$storeId/settings/webhooks/'+ | '/$storeId/products/purchase-orders/$purchaseOrderId/edit'+ | '/$storeId/products/transfers/$transferId/edit'| '/$storeId/products/price-lists/$priceListId/'+ | '/$storeId/products/purchase-orders/$purchaseOrderId/'+ | '/$storeId/products/transfers/$transferId/'| '/$storeId/settings/delivery-profiles/$profileId/'| '/$storeId/settings/delivery-profiles/$profileId/methods/$methodId'| '/$storeId/settings/delivery-profiles/$profileId/methods/new'@@ -897,6 +993,7 @@ export interface FileRouteTypes {| '/$storeId/settings/staff'| '/$storeId/settings/stock-locations'| '/$storeId/settings/store'+ | '/$storeId/settings/suppliers'| '/$storeId/settings/tax-categories'| '/$storeId/settings/tax-rates'| '/$storeId/brands'@@ -914,6 +1011,8 @@ export interface FileRouteTypes {| '/$storeId/products/collections/$collectionId'| '/$storeId/products/collections/new'| '/$storeId/products/price-lists/new'+ | '/$storeId/products/purchase-orders/new'+ | '/$storeId/products/transfers/new'| '/$storeId/sellers/payouts/$payoutId'| '/$storeId/settings/webhooks/$webhookEndpointId'| '/$storeId/orders/$orderId'@@ -921,11 +1020,17 @@ export interface FileRouteTypes {| '/$storeId/products/categories'| '/$storeId/products/collections'| '/$storeId/products/price-lists'+ | '/$storeId/products/purchase-orders'+ | '/$storeId/products/transfers'| '/$storeId/sellers/payouts'| '/$storeId/settings/delivery-profiles'| '/$storeId/settings/imports'| '/$storeId/settings/webhooks'+ | '/$storeId/products/purchase-orders/$purchaseOrderId/edit'+ | '/$storeId/products/transfers/$transferId/edit'| '/$storeId/products/price-lists/$priceListId'+ | '/$storeId/products/purchase-orders/$purchaseOrderId'+ | '/$storeId/products/transfers/$transferId'| '/$storeId/settings/delivery-profiles/$profileId'| '/$storeId/settings/delivery-profiles/$profileId/methods/$methodId'| '/$storeId/settings/delivery-profiles/$profileId/methods/new'@@ -981,6 +1086,7 @@ export interface FileRouteTypes {| '/_authenticated/$storeId/settings/staff'| '/_authenticated/$storeId/settings/stock-locations'| '/_authenticated/$storeId/settings/store'+ | '/_authenticated/$storeId/settings/suppliers'| '/_authenticated/$storeId/settings/tax-categories'| '/_authenticated/$storeId/settings/tax-rates'| '/_authenticated/$storeId/brands/'@@ -998,6 +1104,8 @@ export interface FileRouteTypes {| '/_authenticated/$storeId/products/collections/$collectionId'| '/_authenticated/$storeId/products/collections/new'| '/_authenticated/$storeId/products/price-lists/new'+ | '/_authenticated/$storeId/products/purchase-orders/new'+ | '/_authenticated/$storeId/products/transfers/new'| '/_authenticated/$storeId/sellers/payouts/$payoutId'| '/_authenticated/$storeId/settings/webhooks/$webhookEndpointId'| '/_authenticated/$storeId/orders/$orderId/'@@ -1005,11 +1113,17 @@ export interface FileRouteTypes {| '/_authenticated/$storeId/products/categories/'| '/_authenticated/$storeId/products/collections/'| '/_authenticated/$storeId/products/price-lists/'+ | '/_authenticated/$storeId/products/purchase-orders/'+ | '/_authenticated/$storeId/products/transfers/'| '/_authenticated/$storeId/sellers/payouts/'| '/_authenticated/$storeId/settings/delivery-profiles/'| '/_authenticated/$storeId/settings/imports/'| '/_authenticated/$storeId/settings/webhooks/'+ | '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/edit'+ | '/_authenticated/$storeId/products/transfers/$transferId/edit'| '/_authenticated/$storeId/products/price-lists/$priceListId/'+ | '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/'+ | '/_authenticated/$storeId/products/transfers/$transferId/'| '/_authenticated/$storeId/settings/delivery-profiles/$profileId/'| '/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/$methodId'| '/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new'@@ -1201,6 +1315,13 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof SettingsTaxCategoriesRouteImportparentRoute: typeof SettingsRoute}+ '/_authenticated/$storeId/settings/suppliers': {+ id: '/_authenticated/$storeId/settings/suppliers'+ path: '/suppliers'+ fullPath: '/$storeId/settings/suppliers'+ preLoaderRoute: typeof SettingsSuppliersRouteImport+ parentRoute: typeof SettingsRoute+ }'/_authenticated/$storeId/settings/store': {id: '/_authenticated/$storeId/settings/store'path: '/store'@@ -1474,6 +1595,20 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof SellersPayoutsIndexRouteImportparentRoute: typeof authenticatedStoreIdRoute}+ '/_authenticated/$storeId/products/transfers/': {+ id: '/_authenticated/$storeId/products/transfers/'+ path: '/products/transfers'+ fullPath: '/$storeId/products/transfers/'+ preLoaderRoute: typeof ProductsTransfersIndexRouteImport+ parentRoute: typeof authenticatedStoreIdRoute+ }+ '/_authenticated/$storeId/products/purchase-orders/': {+ id: '/_authenticated/$storeId/products/purchase-orders/'+ path: '/products/purchase-orders'+ fullPath: '/$storeId/products/purchase-orders/'+ preLoaderRoute: typeof ProductsPurchaseOrdersIndexRouteImport+ parentRoute: typeof authenticatedStoreIdRoute+ }'/_authenticated/$storeId/products/price-lists/': {id: '/_authenticated/$storeId/products/price-lists/'path: '/products/price-lists'@@ -1523,6 +1658,20 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof SellersPayoutsPayoutIdRouteImportparentRoute: typeof authenticatedStoreIdRoute}+ '/_authenticated/$storeId/products/transfers/new': {+ id: '/_authenticated/$storeId/products/transfers/new'+ path: '/products/transfers/new'+ fullPath: '/$storeId/products/transfers/new'+ preLoaderRoute: typeof ProductsTransfersNewRouteImport+ parentRoute: typeof authenticatedStoreIdRoute+ }+ '/_authenticated/$storeId/products/purchase-orders/new': {+ id: '/_authenticated/$storeId/products/purchase-orders/new'+ path: '/products/purchase-orders/new'+ fullPath: '/$storeId/products/purchase-orders/new'+ preLoaderRoute: typeof ProductsPurchaseOrdersNewRouteImport+ parentRoute: typeof authenticatedStoreIdRoute+ }'/_authenticated/$storeId/products/price-lists/new': {id: '/_authenticated/$storeId/products/price-lists/new'path: '/products/price-lists/new'@@ -1579,6 +1728,20 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof SettingsDeliveryProfilesProfileIdIndexRouteImportparentRoute: typeof SettingsRoute}+ '/_authenticated/$storeId/products/transfers/$transferId/': {+ id: '/_authenticated/$storeId/products/transfers/$transferId/'+ path: '/products/transfers/$transferId'+ fullPath: '/$storeId/products/transfers/$transferId/'+ preLoaderRoute: typeof ProductsTransfersTransferIdIndexRouteImport+ parentRoute: typeof authenticatedStoreIdRoute+ }+ '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/': {+ id: '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/'+ path: '/products/purchase-orders/$purchaseOrderId'+ fullPath: '/$storeId/products/purchase-orders/$purchaseOrderId/'+ preLoaderRoute: typeof ProductsPurchaseOrdersPurchaseOrderIdIndexRouteImport+ parentRoute: typeof authenticatedStoreIdRoute+ }'/_authenticated/$storeId/products/price-lists/$priceListId/': {id: '/_authenticated/$storeId/products/price-lists/$priceListId/'path: '/products/price-lists/$priceListId'@@ -1586,6 +1749,20 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof ProductsPriceListsPriceListIdIndexRouteImportparentRoute: typeof authenticatedStoreIdRoute}+ '/_authenticated/$storeId/products/transfers/$transferId/edit': {+ id: '/_authenticated/$storeId/products/transfers/$transferId/edit'+ path: '/products/transfers/$transferId/edit'+ fullPath: '/$storeId/products/transfers/$transferId/edit'+ preLoaderRoute: typeof ProductsTransfersTransferIdEditRouteImport+ parentRoute: typeof authenticatedStoreIdRoute+ }+ '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/edit': {+ id: '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/edit'+ path: '/products/purchase-orders/$purchaseOrderId/edit'+ fullPath: '/$storeId/products/purchase-orders/$purchaseOrderId/edit'+ preLoaderRoute: typeof ProductsPurchaseOrdersPurchaseOrderIdEditRouteImport+ parentRoute: typeof authenticatedStoreIdRoute+ }'/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new': {id: '/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new'path: '/delivery-profiles/$profileId/methods/new'@@ -1623,6 +1800,7 @@ interface SettingsRouteChildren {SettingsStaffRoute: typeof SettingsStaffRouteSettingsStockLocationsRoute: typeof SettingsStockLocationsRouteSettingsStoreRoute: typeof SettingsStoreRoute+ SettingsSuppliersRoute: typeof SettingsSuppliersRouteSettingsTaxCategoriesRoute: typeof SettingsTaxCategoriesRouteSettingsTaxRatesRoute: typeof SettingsTaxRatesRouteSettingsIndexRoute: typeof SettingsIndexRoute@@ -1655,6 +1833,7 @@ const SettingsRouteChildren: SettingsRouteChildren = {SettingsStaffRoute: SettingsStaffRoute,SettingsStockLocationsRoute: SettingsStockLocationsRoute,SettingsStoreRoute: SettingsStoreRoute,+ SettingsSuppliersRoute: SettingsSuppliersRoute,SettingsTaxCategoriesRoute: SettingsTaxCategoriesRoute,SettingsTaxRatesRoute: SettingsTaxRatesRoute,SettingsIndexRoute: SettingsIndexRoute,@@ -1713,14 +1892,22 @@ interface authenticatedStoreIdRouteChildren {ProductsCollectionsCollectionIdRoute: typeof ProductsCollectionsCollectionIdRouteProductsCollectionsNewRoute: typeof ProductsCollectionsNewRouteProductsPriceListsNewRoute: typeof ProductsPriceListsNewRoute+ ProductsPurchaseOrdersNewRoute: typeof ProductsPurchaseOrdersNewRoute+ ProductsTransfersNewRoute: typeof ProductsTransfersNewRouteSellersPayoutsPayoutIdRoute: typeof SellersPayoutsPayoutIdRouteOrdersOrderIdIndexRoute: typeof OrdersOrderIdIndexRouteProductsCatalogsIndexRoute: typeof ProductsCatalogsIndexRouteProductsCategoriesIndexRoute: typeof ProductsCategoriesIndexRouteProductsCollectionsIndexRoute: typeof ProductsCollectionsIndexRouteProductsPriceListsIndexRoute: typeof ProductsPriceListsIndexRoute+ ProductsPurchaseOrdersIndexRoute: typeof ProductsPurchaseOrdersIndexRoute+ ProductsTransfersIndexRoute: typeof ProductsTransfersIndexRouteSellersPayoutsIndexRoute: typeof SellersPayoutsIndexRoute+ ProductsPurchaseOrdersPurchaseOrderIdEditRoute: typeof ProductsPurchaseOrdersPurchaseOrderIdEditRoute+ ProductsTransfersTransferIdEditRoute: typeof ProductsTransfersTransferIdEditRouteProductsPriceListsPriceListIdIndexRoute: typeof ProductsPriceListsPriceListIdIndexRoute+ ProductsPurchaseOrdersPurchaseOrderIdIndexRoute: typeof ProductsPurchaseOrdersPurchaseOrderIdIndexRoute+ ProductsTransfersTransferIdIndexRoute: typeof ProductsTransfersTransferIdIndexRoute}const authenticatedStoreIdRouteChildren: authenticatedStoreIdRouteChildren = {@@ -1761,15 +1948,25 @@ const authenticatedStoreIdRouteChildren: authenticatedStoreIdRouteChildren = {ProductsCollectionsCollectionIdRoute: ProductsCollectionsCollectionIdRoute,ProductsCollectionsNewRoute: ProductsCollectionsNewRoute,ProductsPriceListsNewRoute: ProductsPriceListsNewRoute,+ ProductsPurchaseOrdersNewRoute: ProductsPurchaseOrdersNewRoute,+ ProductsTransfersNewRoute: ProductsTransfersNewRoute,SellersPayoutsPayoutIdRoute: SellersPayoutsPayoutIdRoute,OrdersOrderIdIndexRoute: OrdersOrderIdIndexRoute,ProductsCatalogsIndexRoute: ProductsCatalogsIndexRoute,ProductsCategoriesIndexRoute: ProductsCategoriesIndexRoute,ProductsCollectionsIndexRoute: ProductsCollectionsIndexRoute,ProductsPriceListsIndexRoute: ProductsPriceListsIndexRoute,+ ProductsPurchaseOrdersIndexRoute: ProductsPurchaseOrdersIndexRoute,+ ProductsTransfersIndexRoute: ProductsTransfersIndexRoute,SellersPayoutsIndexRoute: SellersPayoutsIndexRoute,+ ProductsPurchaseOrdersPurchaseOrderIdEditRoute:+ ProductsPurchaseOrdersPurchaseOrderIdEditRoute,+ ProductsTransfersTransferIdEditRoute: ProductsTransfersTransferIdEditRoute,ProductsPriceListsPriceListIdIndexRoute:ProductsPriceListsPriceListIdIndexRoute,+ ProductsPurchaseOrdersPurchaseOrderIdIndexRoute:+ ProductsPurchaseOrdersPurchaseOrderIdIndexRoute,+ ProductsTransfersTransferIdIndexRoute: ProductsTransfersTransferIdIndexRoute,}const authenticatedStoreIdRouteWithChildren =diff --git a/packages/dashboard/e2e/stock-transfers.spec.ts b/packages/dashboard/e2e/stock-transfers.spec.tsindex 4c5f2bb590..23445ac585 100644--- a/packages/dashboard/e2e/stock-transfers.spec.ts+++ b/packages/dashboard/e2e/stock-transfers.spec.ts@@ -68,6 +68,36 @@ test.describe('stock transfers', () => {await expect(page.getByText('8 received of 10 shipped')).toBeVisible()})+ test('a draft can be corrected, a shipped one cannot', async ({ page }) => {+ const creds = await login(page)+ const draft = await createDraftTransfer(page, creds.accessToken, 3)++ await page.goto(`${TRANSFERS_PATH(creds.store_id)}/${draft.id}`)+ await expect(page.getByRole('heading', { name: draft.number })).toBeVisible({+ timeout: 15_000,+ })++ await page.getByRole('link', { name: /^edit$/i }).click()+ await expect(+ page.getByRole('heading', { name: new RegExp(`edit transfer ${draft.number}`, 'i') }),+ ).toBeVisible()++ const reference = `Corrected ${Date.now()}`+ await page.getByLabel(/^reference$/i).fill(reference)+ await page.getByRole('button', { name: /^save$/i }).click()++ await expect(page.getByText(reference)).toBeVisible({ timeout: 15_000 })++ // Once it has shipped there is nothing to correct: what is in the box is a+ // matter of record.+ const shipped = await createInTransitTransfer(page, creds.accessToken, 2)+ await page.goto(`${TRANSFERS_PATH(creds.store_id)}/${shipped.id}`)+ await expect(page.getByRole('heading', { name: shipped.number })).toBeVisible({+ timeout: 15_000,+ })+ await expect(page.getByRole('link', { name: /^edit$/i })).toHaveCount(0)+ })+test('makes the merchant say what happened to units already gone', async ({ page }) => {const creds = await login(page)const transfer = await createInTransitTransfer(page, creds.accessToken, 4)@@ -151,3 +181,37 @@ async function createInTransitTransfer(return transfer}++/** The same fixture transfer, left as a draft. */+async function createDraftTransfer(+ page: import('@playwright/test').Page,+ accessToken: string,+ quantity: number,+) {+ const headers = { Authorization: `Bearer ${accessToken}` }++ const locations = await page.request+ .get('/api/v3/admin/stock_locations', { headers, params: { limit: 100 } })+ .then((res) => res.json())+ const source = locations.data.find((l: { name: string }) => l.name === FIXTURE_TRANSFER_SOURCE)+ const destination = locations.data.find(+ (l: { name: string }) => l.name === FIXTURE_TRANSFER_DESTINATION,+ )++ const variants = await page.request+ .get('/api/v3/admin/variants', { headers, params: { 'q[sku_eq]': FIXTURE_TRANSFER_SKU } })+ .then((res) => res.json())++ const created = await page.request.post('/api/v3/admin/stock_transfers', {+ headers,+ data: {+ source_location_id: source.id,+ destination_location_id: destination.id,+ reference: `E2E draft ${Date.now()}`,+ items: [{ variant_id: variants.data[0].id, quantity_shipped: quantity }],+ },+ })+ expect(created.status(), await created.text()).toBe(201)++ return created.json()+}diff --git a/packages/dashboard/src/components/spree/purchase-order-form.tsx b/packages/dashboard/src/components/spree/purchase-order-form.tsxnew file mode 100644index 0000000000..398846bdae--- /dev/null+++ b/packages/dashboard/src/components/spree/purchase-order-form.tsx@@ -0,0 +1,240 @@+import type { Supplier } from '@spree/admin-sdk'+import {+ CurrencySelect,+ ResourceCombobox,+ StoreDatePicker,+ useStockLocations,+} from '@spree/dashboard-core'+import {+ Button,+ Card,+ CardContent,+ CardHeader,+ CardTitle,+ Field,+ FieldDescription,+ FieldGroup,+ FieldLabel,+ Input,+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+ Textarea,+} from '@spree/dashboard-ui'+import { useState } from 'react'+import { useTranslation } from 'react-i18next'+import { supplierAutocompleteProps } from '../../hooks/use-suppliers'+import { type VariantLine, VariantLineEditor } from './variant-line-editor'++export interface PurchaseOrderFormValues {+ supplierId: string+ destinationId: string+ currency?: string+ expectedAt?: string+ reference: string+ notes: string+ lines: VariantLine[]+}++export const EMPTY_PURCHASE_ORDER: PurchaseOrderFormValues = {+ supplierId: '',+ destinationId: '',+ currency: undefined,+ expectedAt: undefined,+ reference: '',+ notes: '',+ lines: [],+}++/**+ * What a draft purchase order is made of, for the screen that opens one and+ * the screen that corrects it.+ *+ * Shared because the two are the same form: an order is editable for exactly+ * as long as it is a draft, so "create" and "edit" differ only in where the+ * values start and what the button says.+ */+export function PurchaseOrderForm({+ initial,+ currencyLocked = false,+ submitLabel,+ pendingLabel,+ pending,+ onSubmit,+ onCancel,+}: {+ initial: PurchaseOrderFormValues+ /**+ * Fix the currency. Every line cost is denominated in it, so changing it on+ * a saved order would silently reprice the whole document.+ */+ currencyLocked?: boolean+ submitLabel: string+ pendingLabel: string+ pending: boolean+ onSubmit: (values: PurchaseOrderFormValues) => void+ onCancel: () => void+}) {+ const { t } = useTranslation()+ const { data: stockLocations } = useStockLocations({ limit: 100 })+ const locations = stockLocations?.data ?? []++ const [supplierId, setSupplierId] = useState(initial.supplierId)+ const [destinationId, setDestinationId] = useState(initial.destinationId)+ const [currency, setCurrency] = useState<string | undefined>(initial.currency)+ const [expectedAt, setExpectedAt] = useState<string | undefined>(initial.expectedAt)+ const [reference, setReference] = useState(initial.reference)+ const [notes, setNotes] = useState(initial.notes)+ const [lines, setLines] = useState<VariantLine[]>(initial.lines)++ const canSubmit =+ !!supplierId &&+ !!destinationId &&+ // A cleared cost input is not zero — it is nothing, which the server+ // rejects field-by-field. Catch it here, where the field is.+ lines.every((line) => line.quantity > 0 && Number.isFinite(Number(line.unitCost)))++ return (+ <>+ <Card>+ <CardHeader>+ <CardTitle>{t('admin.purchase_orders.details_title')}</CardTitle>+ </CardHeader>+ <CardContent>+ <FieldGroup>+ <Field>+ <FieldLabel htmlFor="supplier">+ {t('admin.purchase_orders.fields.supplier')}+ </FieldLabel>+ {/* Searchable rather than a capped list: a wholesaler can hold+ more suppliers than one page of a Select would show, and a+ Select says nothing about the ones it left out. */}+ <ResourceCombobox<Supplier>+ {...supplierAutocompleteProps('purchase-order-supplier-picker')}+ id="supplier"+ value={supplierId}+ onChange={(id) => setSupplierId(id ?? '')}+ placeholder={t('admin.purchase_orders.fields.supplier_placeholder')}+ />+ </Field>++ <Field>+ <FieldLabel htmlFor="destination">+ {t('admin.purchase_orders.fields.destination')}+ </FieldLabel>+ <Select value={destinationId} onValueChange={setDestinationId}>+ <SelectTrigger id="destination">+ <SelectValue+ placeholder={t('admin.purchase_orders.fields.destination_placeholder')}+ >+ {(value) => locations.find((l) => l.id === value)?.name ?? (value as string)}+ </SelectValue>+ </SelectTrigger>+ <SelectContent>+ {locations.map((location) => (+ <SelectItem key={location.id} value={location.id}>+ {location.name}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </Field>++ <Field>+ <FieldLabel htmlFor="currency">+ {t('admin.purchase_orders.fields.currency')}+ </FieldLabel>+ {/* A foreign-currency purchase order is legitimate; leaving+ this alone takes the store's own currency. */}+ <CurrencySelect+ id="currency"+ value={currency}+ onChange={setCurrency}+ disabled={currencyLocked}+ />+ {currencyLocked && (+ <FieldDescription>+ {t('admin.purchase_orders.fields.currency_locked')}+ </FieldDescription>+ )}+ </Field>++ <Field>+ <FieldLabel>{t('admin.purchase_orders.fields.expected_at')}</FieldLabel>+ {/* A calendar date, not an instant: the day the supplier+ promised means the same day in every timezone. */}+ <StoreDatePicker+ value={expectedAt}+ onChange={(value) => setExpectedAt(value ?? undefined)}+ placeholder={t('admin.purchase_orders.fields.expected_at_placeholder')}+ />+ </Field>++ <Field>+ <FieldLabel htmlFor="reference">+ {t('admin.purchase_orders.fields.reference')}+ </FieldLabel>+ <Input+ id="reference"+ placeholder={t('admin.purchase_orders.fields.reference_placeholder')}+ value={reference}+ onChange={(event) => setReference(event.target.value)}+ />+ </Field>++ <Field>+ <FieldLabel htmlFor="notes">{t('admin.purchase_orders.fields.notes')}</FieldLabel>+ <Textarea+ id="notes"+ value={notes}+ onChange={(event) => setNotes(event.target.value)}+ />+ </Field>+ </FieldGroup>+ </CardContent>+ </Card>++ <Card>+ <CardHeader>+ <CardTitle>{t('admin.purchase_orders.items_title')}</CardTitle>+ </CardHeader>+ <CardContent>+ {/* No warehouse filter, unlike a transfer: buying stock in is how a+ merchant gets what they do not have. */}+ <VariantLineEditor+ lines={lines}+ onChange={setLines}+ currency={currency}+ quantityLabel={t('admin.purchase_orders.columns.quantity_ordered')}+ withCost+ />+ </CardContent>+ </Card>++ <div className="flex justify-end gap-2">+ <Button type="button" variant="outline" onClick={onCancel}>+ {t('admin.actions.cancel')}+ </Button>+ <Button+ type="button"+ onClick={() =>+ onSubmit({+ supplierId,+ destinationId,+ currency,+ expectedAt,+ reference,+ notes,+ lines,+ })+ }+ disabled={!canSubmit || pending}+ >+ {pending ? pendingLabel : submitLabel}+ </Button>+ </div>+ </>+ )+}diff --git a/packages/dashboard/src/components/spree/stock-transfer-form.tsx b/packages/dashboard/src/components/spree/stock-transfer-form.tsxnew file mode 100644index 0000000000..57a68daa2b--- /dev/null+++ b/packages/dashboard/src/components/spree/stock-transfer-form.tsx@@ -0,0 +1,196 @@+import { useStockLocations } from '@spree/dashboard-core'+import {+ Button,+ Card,+ CardContent,+ CardHeader,+ CardTitle,+ Field,+ FieldDescription,+ FieldError,+ FieldGroup,+ FieldLabel,+ Input,+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+ Textarea,+} from '@spree/dashboard-ui'+import { useState } from 'react'+import { useTranslation } from 'react-i18next'+import { type VariantLine, VariantLineEditor } from './variant-line-editor'++export interface StockTransferFormValues {+ sourceId: string+ destinationId: string+ reference: string+ notes: string+ lines: VariantLine[]+}++export const EMPTY_STOCK_TRANSFER: StockTransferFormValues = {+ sourceId: '',+ destinationId: '',+ reference: '',+ notes: '',+ lines: [],+}++/**+ * What a draft transfer is made of, for the screen that opens one and the+ * screen that corrects it.+ *+ * Shared because the two are the same form: a transfer is editable for exactly+ * as long as it is a draft, so "create" and "edit" differ only in where the+ * values start and what the button says.+ */+export function StockTransferForm({+ initial,+ submitLabel,+ pendingLabel,+ pending,+ onSubmit,+ onCancel,+}: {+ initial: StockTransferFormValues+ submitLabel: string+ pendingLabel: string+ pending: boolean+ onSubmit: (values: StockTransferFormValues) => void+ onCancel: () => void+}) {+ const { t } = useTranslation()+ const { data: stockLocations } = useStockLocations({ limit: 100 })+ const locations = stockLocations?.data ?? []++ const [sourceId, setSourceId] = useState(initial.sourceId)+ const [destinationId, setDestinationId] = useState(initial.destinationId)+ const [reference, setReference] = useState(initial.reference)+ const [notes, setNotes] = useState(initial.notes)+ const [lines, setLines] = useState<VariantLine[]>(initial.lines)++ const sameLocation = !!sourceId && sourceId === destinationId+ // Lines were picked for the shelf they are leaving, so the source is fixed+ // once there are any: changing it would silently keep SKUs the new source+ // may hold none of. Emptying the list frees it again.+ const sourceLocked = lines.length > 0 && !!initial.sourceId+ const canSubmit =+ !!sourceId && !!destinationId && !sameLocation && lines.every((line) => line.quantity > 0)++ return (+ <>+ <Card>+ <CardHeader>+ <CardTitle>{t('admin.stock_transfers.details_title')}</CardTitle>+ </CardHeader>+ <CardContent>+ <FieldGroup>+ <Field>+ <FieldLabel htmlFor="source">{t('admin.stock_transfers.fields.source')}</FieldLabel>+ <Select value={sourceId} onValueChange={setSourceId} disabled={sourceLocked}>+ <SelectTrigger id="source">+ <SelectValue placeholder={t('admin.stock_transfers.fields.source_placeholder')}>+ {(value) => locations.find((l) => l.id === value)?.name ?? (value as string)}+ </SelectValue>+ </SelectTrigger>+ <SelectContent>+ {locations.map((location) => (+ <SelectItem key={location.id} value={location.id}>+ {location.name}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ {sourceLocked && (+ <FieldDescription>+ {t('admin.stock_transfers.fields.source_locked')}+ </FieldDescription>+ )}+ </Field>++ <Field>+ <FieldLabel htmlFor="destination">+ {t('admin.stock_transfers.fields.destination')}+ </FieldLabel>+ <Select value={destinationId} onValueChange={setDestinationId}>+ <SelectTrigger id="destination">+ <SelectValue+ placeholder={t('admin.stock_transfers.fields.destination_placeholder')}+ >+ {(value) => locations.find((l) => l.id === value)?.name ?? (value as string)}+ </SelectValue>+ </SelectTrigger>+ <SelectContent>+ {locations+ .filter((location) => location.id !== sourceId)+ .map((location) => (+ <SelectItem key={location.id} value={location.id}>+ {location.name}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ {sameLocation && (+ <FieldError>{t('admin.stock_transfers.errors.same_location')}</FieldError>+ )}+ </Field>++ <Field>+ <FieldLabel htmlFor="reference">+ {t('admin.stock_transfers.fields.reference')}+ </FieldLabel>+ <Input+ id="reference"+ placeholder={t('admin.stock_transfers.fields.reference_placeholder')}+ value={reference}+ onChange={(event) => setReference(event.target.value)}+ />+ </Field>++ <Field>+ <FieldLabel htmlFor="notes">{t('admin.stock_transfers.fields.notes')}</FieldLabel>+ <Textarea+ id="notes"+ value={notes}+ onChange={(event) => setNotes(event.target.value)}+ />+ </Field>+ </FieldGroup>+ </CardContent>+ </Card>++ <Card>+ <CardHeader>+ <CardTitle>{t('admin.stock_transfers.items_title')}</CardTitle>+ </CardHeader>+ <CardContent>+ {/* A draft may hold no lines at all and gain them as the merchant+ packs, so there is nothing to enforce here. The picker offers only+ what the source can send and stays shut until one is chosen. */}+ <VariantLineEditor+ lines={lines}+ onChange={setLines}+ quantityLabel={t('admin.stock_transfers.columns.quantity_shipped')}+ stockLocationId={sourceId || null}+ requireStockLocation+ />+ </CardContent>+ </Card>++ <div className="flex justify-end gap-2">+ <Button type="button" variant="outline" onClick={onCancel}>+ {t('admin.actions.cancel')}+ </Button>+ <Button+ type="button"+ onClick={() => onSubmit({ sourceId, destinationId, reference, notes, lines })}+ disabled={!canSubmit || pending}+ >+ {pending ? pendingLabel : submitLabel}+ </Button>+ </div>+ </>+ )+}diff --git a/packages/dashboard/src/components/spree/variant-line-editor.tsx b/packages/dashboard/src/components/spree/variant-line-editor.tsxindex 42b7ab69cf..781faaa94c 100644--- a/packages/dashboard/src/components/spree/variant-line-editor.tsx+++ b/packages/dashboard/src/components/spree/variant-line-editor.tsx@@ -22,9 +22,23 @@ import { useRef } from 'react'import { useTranslation } from 'react-i18next'import { VariantLink } from './variant-link'+/**+ * What a line needs to render: enough of a variant to name and picture it.+ *+ * Structural rather than the SDK's `Variant`, so a line can be seeded from a+ * saved document's items — those carry the same four facts under their own+ * names and are not variants. A search result satisfies it as it stands.+ */+export interface VariantLineVariant {+ id: string+ sku?: string | null+ product_name?: string | null+ thumbnail_url?: string | null+}+/** One SKU the merchant is putting on a transfer or a purchase order. */export interface VariantLine {- variant: Variant+ variant: VariantLineVariantquantity: number/** Only purchase orders have a cost; transfers move stock already owned. */unitCost?: stringdiff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.jsonindex f4f3a22e22..83c2a58610 100644--- a/packages/dashboard/src/locales/ar.json+++ b/packages/dashboard/src/locales/ar.json@@ -5086,7 +5086,8 @@"failed_to_mark_ready": "تعذّر تعيين التحويل كجاهز للإرسال","failed_to_mark_in_transit": "تعذّر تعيين التحويل كفي الطريق","failed_to_receive": "تعذّر استلام التحويل",- "failed_to_cancel": "تعذّر إلغاء التحويل"+ "failed_to_cancel": "تعذّر إلغاء التحويل",+ "not_editable": "تم تجهيز هذا النقل، ومحتواه الآن سجل ثابت. ألغِه إذا لم يكن ينبغي إرساله."},"messages": {"deleted": "تم حذف التحويل",@@ -5141,7 +5142,8 @@"units": "الوحدات","shipped_at": "تاريخ الإرسال","received_at": "تاريخ الاستلام",- "in_transit_resolution": "الوحدات غادرت المستودع بالفعل. ماذا حدث لها؟"+ "in_transit_resolution": "الوحدات غادرت المستودع بالفعل. ماذا حدث لها؟",+ "source_locked": "ثابت ما دامت هناك بنود: اختيرت لهذا المستودع. أزلها لتغييره."},"actions": {"create_draft": "إنشاء مسودة",@@ -5168,7 +5170,8 @@"message": "لم يتحرك أي مخزون بعد، لذا لن يُعاد أي شيء.","in_flight_restock": "ستعود الوحدات إلى رفّ المستودع المصدر، كأن التحويل لم يُرسَل أبدًا.","in_flight_write_off": "تبقى الوحدات مشطوبة كخسارة. لن يُضاف أي شيء في أي مكان."- }+ },+ "edit_title": "تعديل النقل {{number}}"},"store": {"load_failed_title": "فشل تحميل إعدادات المتجر",@@ -5529,7 +5532,8 @@"units": "الوحدات","subtotal": "الإجمالي","ordered_at": "تاريخ الطلب",- "received_at": "تاريخ الاستلام"+ "received_at": "تاريخ الاستلام",+ "currency_locked": "ثابتة بعد إنشاء الأمر: كل بند مُسعَّر بها."},"actions": {"create_draft": "إنشاء مسودة",@@ -5551,7 +5555,8 @@"failed_to_delete": "تعذّر حذف أمر الشراء","failed_to_order": "تعذّر إرسال أمر الشراء","failed_to_receive": "تعذّر تسجيل التوريد",- "failed_to_cancel": "تعذّر إلغاء أمر الشراء"+ "failed_to_cancel": "تعذّر إلغاء أمر الشراء",+ "not_editable": "أُرسل هذا الأمر إلى المورّد، وبنوده الآن التزام بين شركتين. ألغِه إذا لم يكن ينبغي أن يستمر."},"delete_confirm": {"title": "حذف أمر الشراء هذا؟",@@ -5564,7 +5569,8 @@"cancel_confirm": {"title": "إلغاء أمر الشراء هذا؟","message": "يُلغى ما تبقّى غير مستلَم. الوحدات المستلَمة بالفعل تبقى في المخزون."- }+ },+ "edit_title": "تعديل أمر الشراء {{number}}"},"suppliers": {"title": "الموردون",diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.jsonindex 180533fd04..a85443c3dd 100644--- a/packages/dashboard/src/locales/de.json+++ b/packages/dashboard/src/locales/de.json@@ -5064,7 +5064,8 @@"failed_to_mark_ready": "Umlagerung konnte nicht als versandbereit markiert werden","failed_to_mark_in_transit": "Umlagerung konnte nicht als unterwegs markiert werden","failed_to_receive": "Wareneingang konnte nicht gebucht werden",- "failed_to_cancel": "Umlagerung konnte nicht abgebrochen werden"+ "failed_to_cancel": "Umlagerung konnte nicht abgebrochen werden",+ "not_editable": "Diese Umbuchung ist gepackt, ihr Inhalt ist damit dokumentiert. Storniere sie, wenn sie nicht gehen soll."},"messages": {"deleted": "Umlagerung gelöscht",@@ -5119,7 +5120,8 @@"units": "Einheiten","shipped_at": "Versandt","received_at": "Eingegangen",- "in_transit_resolution": "Die Einheiten haben das Lager verlassen. Was ist mit ihnen passiert?"+ "in_transit_resolution": "Die Einheiten haben das Lager verlassen. Was ist mit ihnen passiert?",+ "source_locked": "Fest, solange Positionen vorhanden sind: sie wurden für dieses Lager gewählt. Zum Ändern zuerst entfernen."},"actions": {"create_draft": "Entwurf erstellen",@@ -5142,7 +5144,8 @@"message": "Es wurde noch kein Bestand bewegt, es wird also nichts zurückgebucht.","in_flight_restock": "Die Einheiten werden zurück ins Quelllager gebucht, als wäre die Umlagerung nie versandt worden.","in_flight_write_off": "Die Einheiten bleiben als Verlust ausgebucht. Es wird nirgends etwas zurückgebucht."- }+ },+ "edit_title": "Umbuchung {{number}} bearbeiten"},"store": {"load_failed_title": "Laden der Store-Einstellungen fehlgeschlagen",@@ -5500,7 +5503,8 @@"units": "Einheiten","subtotal": "Gesamt","ordered_at": "Bestellt",- "received_at": "Eingegangen"+ "received_at": "Eingegangen",+ "currency_locked": "Fest nach dem Anlegen: jede Position ist in dieser Währung bepreist."},"actions": {"create_draft": "Entwurf erstellen",@@ -5522,7 +5526,8 @@"failed_to_delete": "Bestellung konnte nicht gelöscht werden","failed_to_order": "Bestellung konnte nicht aufgegeben werden","failed_to_receive": "Lieferung konnte nicht eingebucht werden",- "failed_to_cancel": "Bestellung konnte nicht abgebrochen werden"+ "failed_to_cancel": "Bestellung konnte nicht abgebrochen werden",+ "not_editable": "Diese Bestellung liegt beim Lieferanten, ihre Positionen sind damit verbindlich. Storniere sie, wenn sie nicht gelten soll."},"delete_confirm": {"title": "Diese Bestellung löschen?",@@ -5535,7 +5540,8 @@"cancel_confirm": {"title": "Diese Bestellung abbrechen?","message": "Alles Offene wird abgesagt. Bereits eingegangene Einheiten bleiben im Bestand."- }+ },+ "edit_title": "Bestellung {{number}} bearbeiten"},"suppliers": {"title": "Lieferanten",diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.jsonindex 353a9c37b6..9832a04222 100644--- a/packages/dashboard/src/locales/en.json+++ b/packages/dashboard/src/locales/en.json@@ -5064,7 +5064,8 @@"failed_to_mark_ready": "Failed to mark the transfer ready","failed_to_mark_in_transit": "Failed to mark the transfer in transit","failed_to_receive": "Failed to receive the transfer",- "failed_to_cancel": "Failed to cancel the transfer"+ "failed_to_cancel": "Failed to cancel the transfer",+ "not_editable": "This transfer has been packed, so what is in it is now a matter of record. Cancel it if it should not go."},"messages": {"deleted": "Transfer deleted",@@ -5119,7 +5120,8 @@"units": "Units","shipped_at": "Shipped","received_at": "Received",- "in_transit_resolution": "The units have already left. What happened to them?"+ "in_transit_resolution": "The units have already left. What happened to them?",+ "source_locked": "Fixed while the transfer has lines: they were picked for this warehouse. Remove them to change it."},"actions": {"create_draft": "Create draft",@@ -5142,7 +5144,8 @@"message": "No stock has moved yet, so nothing will be reversed.","in_flight_restock": "The units will go back onto the source warehouse's shelf, as if the transfer had never shipped.","in_flight_write_off": "The units stay off the books as lost. Nothing is added back anywhere."- }+ },+ "edit_title": "Edit transfer {{number}}"},"store": {"load_failed_title": "Failed to load store settings",@@ -5500,7 +5503,8 @@"units": "Units","subtotal": "Total","ordered_at": "Ordered",- "received_at": "Received"+ "received_at": "Received",+ "currency_locked": "Fixed after the order is opened: every line cost is priced in it."},"actions": {"create_draft": "Create draft",@@ -5522,7 +5526,8 @@"failed_to_delete": "Failed to delete the purchase order","failed_to_order": "Failed to place the purchase order","failed_to_receive": "Failed to book in the delivery",- "failed_to_cancel": "Failed to cancel the purchase order"+ "failed_to_cancel": "Failed to cancel the purchase order",+ "not_editable": "This order has gone to the supplier, so its lines are a matter of record between two businesses. Cancel it if it should not stand."},"delete_confirm": {"title": "Delete this purchase order?",@@ -5535,7 +5540,8 @@"cancel_confirm": {"title": "Cancel this purchase order?","message": "What is still outstanding is called off. Units already received stay on the shelf."- }+ },+ "edit_title": "Edit order {{number}}"},"suppliers": {"title": "Suppliers",diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.jsonindex 160be4c0cb..04ae0aff21 100644--- a/packages/dashboard/src/locales/fr.json+++ b/packages/dashboard/src/locales/fr.json@@ -5064,7 +5064,8 @@"failed_to_mark_ready": "Impossible de marquer le transfert prêt à expédier","failed_to_mark_in_transit": "Impossible de marquer le transfert en transit","failed_to_receive": "Échec de la réception du transfert",- "failed_to_cancel": "Échec de l'annulation du transfert"+ "failed_to_cancel": "Échec de l'annulation du transfert",+ "not_editable": "Ce transfert est emballé : son contenu fait désormais foi. Annulez-le s'il ne doit pas partir."},"messages": {"deleted": "Transfert supprimé",@@ -5119,7 +5120,8 @@"units": "Unités","shipped_at": "Expédié","received_at": "Reçu",- "in_transit_resolution": "Les unités sont déjà parties. Que leur est-il arrivé ?"+ "in_transit_resolution": "Les unités sont déjà parties. Que leur est-il arrivé ?",+ "source_locked": "Figé tant qu'il y a des lignes : elles ont été choisies pour cet entrepôt. Retirez-les pour le changer."},"actions": {"create_draft": "Créer le brouillon",@@ -5142,7 +5144,8 @@"message": "Aucun stock n'a encore bougé, rien ne sera donc annulé.","in_flight_restock": "Les unités retourneront dans l'entrepôt d'origine, comme si le transfert n'avait jamais été expédié.","in_flight_write_off": "Les unités restent sorties du stock, en perte. Rien n'est réintégré."- }+ },+ "edit_title": "Modifier le transfert {{number}}"},"store": {"load_failed_title": "Échec du chargement des paramètres de la boutique",@@ -5500,7 +5503,8 @@"units": "Unités","subtotal": "Total","ordered_at": "Commandé",- "received_at": "Reçu"+ "received_at": "Reçu",+ "currency_locked": "Figée après l'ouverture : chaque ligne est chiffrée dans cette devise."},"actions": {"create_draft": "Créer le brouillon",@@ -5522,7 +5526,8 @@"failed_to_delete": "Échec de la suppression du bon de commande","failed_to_order": "Échec du passage de la commande","failed_to_receive": "Échec de l'enregistrement de la livraison",- "failed_to_cancel": "Échec de l'annulation du bon de commande"+ "failed_to_cancel": "Échec de l'annulation du bon de commande",+ "not_editable": "Ce bon est parti chez le fournisseur : ses lignes engagent les deux parties. Annulez-le s'il ne doit pas tenir."},"delete_confirm": {"title": "Supprimer ce bon de commande ?",@@ -5535,7 +5540,8 @@"cancel_confirm": {"title": "Annuler ce bon de commande ?","message": "Ce qui reste dû est annulé. Les unités déjà reçues restent en stock."- }+ },+ "edit_title": "Modifier le bon de commande {{number}}"},"suppliers": {"title": "Fournisseurs",diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.jsonindex cb271b1726..1b1c30c54a 100644--- a/packages/dashboard/src/locales/pl.json+++ b/packages/dashboard/src/locales/pl.json@@ -5122,7 +5122,8 @@"failed_to_mark_ready": "Nie udało się oznaczyć przesunięcia jako gotowego","failed_to_mark_in_transit": "Nie udało się oznaczyć przesunięcia jako w drodze","failed_to_receive": "Nie udało się przyjąć przesunięcia",- "failed_to_cancel": "Nie udało się anulować przesunięcia"+ "failed_to_cancel": "Nie udało się anulować przesunięcia",+ "not_editable": "Ten transfer jest zapakowany, więc jego zawartość jest już zapisem. Anuluj go, jeśli nie ma jechać."},"messages": {"deleted": "Przesunięcie usunięte",@@ -5177,7 +5178,8 @@"units": "Jednostki","shipped_at": "Wysłano","received_at": "Przyjęto",- "in_transit_resolution": "Jednostki już wyjechały. Co się z nimi stało?"+ "in_transit_resolution": "Jednostki już wyjechały. Co się z nimi stało?",+ "source_locked": "Zablokowany, dopóki są pozycje: wybrano je dla tego magazynu. Usuń je, aby zmienić."},"actions": {"create_draft": "Utwórz szkic",@@ -5202,7 +5204,8 @@"message": "Stan jeszcze się nie zmienił, więc nic nie zostanie wycofane.","in_flight_restock": "Jednostki wrócą na półkę magazynu źródłowego, tak jakby przesunięcie nigdy nie wyjechało.","in_flight_write_off": "Jednostki pozostaną odpisane jako strata. Nic nie zostanie nigdzie dodane."- }+ },+ "edit_title": "Edytuj transfer {{number}}"},"store": {"load_failed_title": "Nie udało się załadować ustawień sklepu",@@ -5562,7 +5565,8 @@"units": "Jednostki","subtotal": "Razem","ordered_at": "Zamówiono",- "received_at": "Przyjęto"+ "received_at": "Przyjęto",+ "currency_locked": "Zablokowana po utworzeniu: każda pozycja jest w niej wyceniona."},"actions": {"create_draft": "Utwórz szkic",@@ -5584,7 +5588,8 @@"failed_to_delete": "Nie udało się usunąć zamówienia zakupu","failed_to_order": "Nie udało się złożyć zamówienia","failed_to_receive": "Nie udało się zaksięgować dostawy",- "failed_to_cancel": "Nie udało się anulować zamówienia zakupu"+ "failed_to_cancel": "Nie udało się anulować zamówienia zakupu",+ "not_editable": "To zamówienie trafiło do dostawcy, więc jego pozycje wiążą obie strony. Anuluj je, jeśli nie ma obowiązywać."},"delete_confirm": {"title": "Usunąć to zamówienie zakupu?",@@ -5597,7 +5602,8 @@"cancel_confirm": {"title": "Anulować to zamówienie zakupu?","message": "To, co pozostało niedostarczone, zostanie odwołane. Przyjęte jednostki zostają w magazynie."- }+ },+ "edit_title": "Edytuj zamówienie {{number}}"},"suppliers": {"title": "Dostawcy",diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.jsonindex fe1d016d20..b8da18866b 100644--- a/packages/dashboard/src/locales/zh-CN.json+++ b/packages/dashboard/src/locales/zh-CN.json@@ -5055,7 +5055,8 @@"failed_to_mark_ready": "标记调拨为待发出失败","failed_to_mark_in_transit": "标记调拨为在途失败","failed_to_receive": "调拨收货失败",- "failed_to_cancel": "取消调拨失败"+ "failed_to_cancel": "取消调拨失败",+ "not_editable": "该调拨已打包,内容已成为记录。如果不该发出,请取消它。"},"messages": {"deleted": "调拨已删除",@@ -5110,7 +5111,8 @@"units": "数量","shipped_at": "发出时间","received_at": "收货时间",- "in_transit_resolution": "货物已经离库。它们怎么了?"+ "in_transit_resolution": "货物已经离库。它们怎么了?",+ "source_locked": "有商品行时不可更改:这些商品是为该仓库挑选的。移除后才能更改。"},"actions": {"create_draft": "创建草稿",@@ -5132,7 +5134,8 @@"message": "库存尚未变动,因此无需回退。","in_flight_restock": "数量将回到来源仓库的货架,如同从未发出。","in_flight_write_off": "数量保持核销为丢失,任何仓库都不会补回。"- }+ },+ "edit_title": "编辑调拨 {{number}}"},"store": {"load_failed_title": "加载店铺设置失败",@@ -5489,7 +5492,8 @@"units": "数量","subtotal": "合计","ordered_at": "下单时间",- "received_at": "收货时间"+ "received_at": "收货时间",+ "currency_locked": "创建后固定:每一行的成本都以该货币计价。"},"actions": {"create_draft": "创建草稿",@@ -5511,7 +5515,8 @@"failed_to_delete": "删除采购订单失败","failed_to_order": "下单失败","failed_to_receive": "到货入库失败",- "failed_to_cancel": "取消采购订单失败"+ "failed_to_cancel": "取消采购订单失败",+ "not_editable": "该订单已发给供应商,其商品行是两家企业之间的约定。如果不该继续,请取消它。"},"delete_confirm": {"title": "删除此采购订单?",@@ -5524,7 +5529,8 @@"cancel_confirm": {"title": "取消此采购订单?","message": "尚未到货的部分将被取消。已收到的数量仍留在库存中。"- }+ },+ "edit_title": "编辑采购订单 {{number}}"},"suppliers": {"title": "供应商",diff --git a/packages/dashboard/src/routeTree.gen.ts b/packages/dashboard/src/routeTree.gen.tsindex b06bb3e124..c440afef99 100644--- a/packages/dashboard/src/routeTree.gen.ts+++ b/packages/dashboard/src/routeTree.gen.ts@@ -82,9 +82,7 @@ import { Route as OrdersOrderIdIndexRouteImport } from './routes/_authenticated/import { Route as SettingsWebhooksWebhookEndpointIdRouteImport } from './routes/_authenticated/$storeId/settings/webhooks/$webhookEndpointId'import { Route as SellersPayoutsPayoutIdRouteImport } from './routes/_authenticated/$storeId/sellers/payouts/$payoutId'import { Route as ProductsTransfersNewRouteImport } from './routes/_authenticated/$storeId/products/transfers/new'-import { Route as ProductsTransfersTransferIdRouteImport } from './routes/_authenticated/$storeId/products/transfers/$transferId'import { Route as ProductsPurchaseOrdersNewRouteImport } from './routes/_authenticated/$storeId/products/purchase-orders/new'-import { Route as ProductsPurchaseOrdersPurchaseOrderIdRouteImport } from './routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId'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'@@ -93,7 +91,11 @@ import { Route as ProductsCategoriesCategoryIdRouteImport } from './routes/_authimport { Route as ProductsCatalogsCatalogIdRouteImport } from './routes/_authenticated/$storeId/products/catalogs/$catalogId'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 ProductsTransfersTransferIdIndexRouteImport } from './routes/_authenticated/$storeId/products/transfers/$transferId/index'+import { Route as ProductsPurchaseOrdersPurchaseOrderIdIndexRouteImport } from './routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/index'import { Route as ProductsPriceListsPriceListIdIndexRouteImport } from './routes/_authenticated/$storeId/products/price-lists/$priceListId/index'+import { Route as ProductsTransfersTransferIdEditRouteImport } from './routes/_authenticated/$storeId/products/transfers/$transferId/edit'+import { Route as ProductsPurchaseOrdersPurchaseOrderIdEditRouteImport } from './routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/edit'import { Route as SettingsDeliveryProfilesProfileIdMethodsNewRouteImport } from './routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new'import { Route as SettingsDeliveryProfilesProfileIdMethodsMethodIdRouteImport } from './routes/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/$methodId'@@ -468,24 +470,12 @@ const ProductsTransfersNewRoute = ProductsTransfersNewRouteImport.update({path: '/products/transfers/new',getParentRoute: () => authenticatedStoreIdRoute,} as any)-const ProductsTransfersTransferIdRoute =- ProductsTransfersTransferIdRouteImport.update({- id: '/products/transfers/$transferId',- path: '/products/transfers/$transferId',- getParentRoute: () => authenticatedStoreIdRoute,- } as any)const ProductsPurchaseOrdersNewRoute =ProductsPurchaseOrdersNewRouteImport.update({id: '/products/purchase-orders/new',path: '/products/purchase-orders/new',getParentRoute: () => authenticatedStoreIdRoute,} as any)-const ProductsPurchaseOrdersPurchaseOrderIdRoute =- ProductsPurchaseOrdersPurchaseOrderIdRouteImport.update({- id: '/products/purchase-orders/$purchaseOrderId',- path: '/products/purchase-orders/$purchaseOrderId',- getParentRoute: () => authenticatedStoreIdRoute,- } as any)const ProductsPriceListsNewRoute = ProductsPriceListsNewRouteImport.update({id: '/products/price-lists/new',path: '/products/price-lists/new',@@ -530,12 +520,36 @@ const SettingsDeliveryProfilesProfileIdIndexRoute =path: '/delivery-profiles/$profileId/',getParentRoute: () => SettingsRoute,} as any)+const ProductsTransfersTransferIdIndexRoute =+ ProductsTransfersTransferIdIndexRouteImport.update({+ id: '/products/transfers/$transferId/',+ path: '/products/transfers/$transferId/',+ getParentRoute: () => authenticatedStoreIdRoute,+ } as any)+const ProductsPurchaseOrdersPurchaseOrderIdIndexRoute =+ ProductsPurchaseOrdersPurchaseOrderIdIndexRouteImport.update({+ id: '/products/purchase-orders/$purchaseOrderId/',+ path: '/products/purchase-orders/$purchaseOrderId/',+ getParentRoute: () => authenticatedStoreIdRoute,+ } as any)const ProductsPriceListsPriceListIdIndexRoute =ProductsPriceListsPriceListIdIndexRouteImport.update({id: '/products/price-lists/$priceListId/',path: '/products/price-lists/$priceListId/',getParentRoute: () => authenticatedStoreIdRoute,} as any)+const ProductsTransfersTransferIdEditRoute =+ ProductsTransfersTransferIdEditRouteImport.update({+ id: '/products/transfers/$transferId/edit',+ path: '/products/transfers/$transferId/edit',+ getParentRoute: () => authenticatedStoreIdRoute,+ } as any)+const ProductsPurchaseOrdersPurchaseOrderIdEditRoute =+ ProductsPurchaseOrdersPurchaseOrderIdEditRouteImport.update({+ id: '/products/purchase-orders/$purchaseOrderId/edit',+ path: '/products/purchase-orders/$purchaseOrderId/edit',+ getParentRoute: () => authenticatedStoreIdRoute,+ } as any)const SettingsDeliveryProfilesProfileIdMethodsNewRoute =SettingsDeliveryProfilesProfileIdMethodsNewRouteImport.update({id: '/delivery-profiles/$profileId/methods/new',@@ -615,9 +629,7 @@ export interface FileRoutesByFullPath {'/$storeId/products/collections/$collectionId': typeof ProductsCollectionsCollectionIdRoute'/$storeId/products/collections/new': typeof ProductsCollectionsNewRoute'/$storeId/products/price-lists/new': typeof ProductsPriceListsNewRoute- '/$storeId/products/purchase-orders/$purchaseOrderId': typeof ProductsPurchaseOrdersPurchaseOrderIdRoute'/$storeId/products/purchase-orders/new': typeof ProductsPurchaseOrdersNewRoute- '/$storeId/products/transfers/$transferId': typeof ProductsTransfersTransferIdRoute'/$storeId/products/transfers/new': typeof ProductsTransfersNewRoute'/$storeId/sellers/payouts/$payoutId': typeof SellersPayoutsPayoutIdRoute'/$storeId/settings/webhooks/$webhookEndpointId': typeof SettingsWebhooksWebhookEndpointIdRoute@@ -632,7 +644,11 @@ export interface FileRoutesByFullPath {'/$storeId/settings/delivery-profiles/': typeof SettingsDeliveryProfilesIndexRoute'/$storeId/settings/imports/': typeof SettingsImportsIndexRoute'/$storeId/settings/webhooks/': typeof SettingsWebhooksIndexRoute+ '/$storeId/products/purchase-orders/$purchaseOrderId/edit': typeof ProductsPurchaseOrdersPurchaseOrderIdEditRoute+ '/$storeId/products/transfers/$transferId/edit': typeof ProductsTransfersTransferIdEditRoute'/$storeId/products/price-lists/$priceListId/': typeof ProductsPriceListsPriceListIdIndexRoute+ '/$storeId/products/purchase-orders/$purchaseOrderId/': typeof ProductsPurchaseOrdersPurchaseOrderIdIndexRoute+ '/$storeId/products/transfers/$transferId/': typeof ProductsTransfersTransferIdIndexRoute'/$storeId/settings/delivery-profiles/$profileId/': typeof SettingsDeliveryProfilesProfileIdIndexRoute'/$storeId/settings/delivery-profiles/$profileId/methods/$methodId': typeof SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute'/$storeId/settings/delivery-profiles/$profileId/methods/new': typeof SettingsDeliveryProfilesProfileIdMethodsNewRoute@@ -701,9 +717,7 @@ export interface FileRoutesByTo {'/$storeId/products/collections/$collectionId': typeof ProductsCollectionsCollectionIdRoute'/$storeId/products/collections/new': typeof ProductsCollectionsNewRoute'/$storeId/products/price-lists/new': typeof ProductsPriceListsNewRoute- '/$storeId/products/purchase-orders/$purchaseOrderId': typeof ProductsPurchaseOrdersPurchaseOrderIdRoute'/$storeId/products/purchase-orders/new': typeof ProductsPurchaseOrdersNewRoute- '/$storeId/products/transfers/$transferId': typeof ProductsTransfersTransferIdRoute'/$storeId/products/transfers/new': typeof ProductsTransfersNewRoute'/$storeId/sellers/payouts/$payoutId': typeof SellersPayoutsPayoutIdRoute'/$storeId/settings/webhooks/$webhookEndpointId': typeof SettingsWebhooksWebhookEndpointIdRoute@@ -718,7 +732,11 @@ export interface FileRoutesByTo {'/$storeId/settings/delivery-profiles': typeof SettingsDeliveryProfilesIndexRoute'/$storeId/settings/imports': typeof SettingsImportsIndexRoute'/$storeId/settings/webhooks': typeof SettingsWebhooksIndexRoute+ '/$storeId/products/purchase-orders/$purchaseOrderId/edit': typeof ProductsPurchaseOrdersPurchaseOrderIdEditRoute+ '/$storeId/products/transfers/$transferId/edit': typeof ProductsTransfersTransferIdEditRoute'/$storeId/products/price-lists/$priceListId': typeof ProductsPriceListsPriceListIdIndexRoute+ '/$storeId/products/purchase-orders/$purchaseOrderId': typeof ProductsPurchaseOrdersPurchaseOrderIdIndexRoute+ '/$storeId/products/transfers/$transferId': typeof ProductsTransfersTransferIdIndexRoute'/$storeId/settings/delivery-profiles/$profileId': typeof SettingsDeliveryProfilesProfileIdIndexRoute'/$storeId/settings/delivery-profiles/$profileId/methods/$methodId': typeof SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute'/$storeId/settings/delivery-profiles/$profileId/methods/new': typeof SettingsDeliveryProfilesProfileIdMethodsNewRoute@@ -791,9 +809,7 @@ export interface FileRoutesById {'/_authenticated/$storeId/products/collections/$collectionId': typeof ProductsCollectionsCollectionIdRoute'/_authenticated/$storeId/products/collections/new': typeof ProductsCollectionsNewRoute'/_authenticated/$storeId/products/price-lists/new': typeof ProductsPriceListsNewRoute- '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId': typeof ProductsPurchaseOrdersPurchaseOrderIdRoute'/_authenticated/$storeId/products/purchase-orders/new': typeof ProductsPurchaseOrdersNewRoute- '/_authenticated/$storeId/products/transfers/$transferId': typeof ProductsTransfersTransferIdRoute'/_authenticated/$storeId/products/transfers/new': typeof ProductsTransfersNewRoute'/_authenticated/$storeId/sellers/payouts/$payoutId': typeof SellersPayoutsPayoutIdRoute'/_authenticated/$storeId/settings/webhooks/$webhookEndpointId': typeof SettingsWebhooksWebhookEndpointIdRoute@@ -808,7 +824,11 @@ export interface FileRoutesById {'/_authenticated/$storeId/settings/delivery-profiles/': typeof SettingsDeliveryProfilesIndexRoute'/_authenticated/$storeId/settings/imports/': typeof SettingsImportsIndexRoute'/_authenticated/$storeId/settings/webhooks/': typeof SettingsWebhooksIndexRoute+ '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/edit': typeof ProductsPurchaseOrdersPurchaseOrderIdEditRoute+ '/_authenticated/$storeId/products/transfers/$transferId/edit': typeof ProductsTransfersTransferIdEditRoute'/_authenticated/$storeId/products/price-lists/$priceListId/': typeof ProductsPriceListsPriceListIdIndexRoute+ '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/': typeof ProductsPurchaseOrdersPurchaseOrderIdIndexRoute+ '/_authenticated/$storeId/products/transfers/$transferId/': typeof ProductsTransfersTransferIdIndexRoute'/_authenticated/$storeId/settings/delivery-profiles/$profileId/': typeof SettingsDeliveryProfilesProfileIdIndexRoute'/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/$methodId': typeof SettingsDeliveryProfilesProfileIdMethodsMethodIdRoute'/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new': typeof SettingsDeliveryProfilesProfileIdMethodsNewRoute@@ -881,9 +901,7 @@ export interface FileRouteTypes {| '/$storeId/products/collections/$collectionId'| '/$storeId/products/collections/new'| '/$storeId/products/price-lists/new'- | '/$storeId/products/purchase-orders/$purchaseOrderId'| '/$storeId/products/purchase-orders/new'- | '/$storeId/products/transfers/$transferId'| '/$storeId/products/transfers/new'| '/$storeId/sellers/payouts/$payoutId'| '/$storeId/settings/webhooks/$webhookEndpointId'@@ -898,7 +916,11 @@ export interface FileRouteTypes {| '/$storeId/settings/delivery-profiles/'| '/$storeId/settings/imports/'| '/$storeId/settings/webhooks/'+ | '/$storeId/products/purchase-orders/$purchaseOrderId/edit'+ | '/$storeId/products/transfers/$transferId/edit'| '/$storeId/products/price-lists/$priceListId/'+ | '/$storeId/products/purchase-orders/$purchaseOrderId/'+ | '/$storeId/products/transfers/$transferId/'| '/$storeId/settings/delivery-profiles/$profileId/'| '/$storeId/settings/delivery-profiles/$profileId/methods/$methodId'| '/$storeId/settings/delivery-profiles/$profileId/methods/new'@@ -967,9 +989,7 @@ export interface FileRouteTypes {| '/$storeId/products/collections/$collectionId'| '/$storeId/products/collections/new'| '/$storeId/products/price-lists/new'- | '/$storeId/products/purchase-orders/$purchaseOrderId'| '/$storeId/products/purchase-orders/new'- | '/$storeId/products/transfers/$transferId'| '/$storeId/products/transfers/new'| '/$storeId/sellers/payouts/$payoutId'| '/$storeId/settings/webhooks/$webhookEndpointId'@@ -984,7 +1004,11 @@ export interface FileRouteTypes {| '/$storeId/settings/delivery-profiles'| '/$storeId/settings/imports'| '/$storeId/settings/webhooks'+ | '/$storeId/products/purchase-orders/$purchaseOrderId/edit'+ | '/$storeId/products/transfers/$transferId/edit'| '/$storeId/products/price-lists/$priceListId'+ | '/$storeId/products/purchase-orders/$purchaseOrderId'+ | '/$storeId/products/transfers/$transferId'| '/$storeId/settings/delivery-profiles/$profileId'| '/$storeId/settings/delivery-profiles/$profileId/methods/$methodId'| '/$storeId/settings/delivery-profiles/$profileId/methods/new'@@ -1056,9 +1080,7 @@ export interface FileRouteTypes {| '/_authenticated/$storeId/products/collections/$collectionId'| '/_authenticated/$storeId/products/collections/new'| '/_authenticated/$storeId/products/price-lists/new'- | '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId'| '/_authenticated/$storeId/products/purchase-orders/new'- | '/_authenticated/$storeId/products/transfers/$transferId'| '/_authenticated/$storeId/products/transfers/new'| '/_authenticated/$storeId/sellers/payouts/$payoutId'| '/_authenticated/$storeId/settings/webhooks/$webhookEndpointId'@@ -1073,7 +1095,11 @@ export interface FileRouteTypes {| '/_authenticated/$storeId/settings/delivery-profiles/'| '/_authenticated/$storeId/settings/imports/'| '/_authenticated/$storeId/settings/webhooks/'+ | '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/edit'+ | '/_authenticated/$storeId/products/transfers/$transferId/edit'| '/_authenticated/$storeId/products/price-lists/$priceListId/'+ | '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/'+ | '/_authenticated/$storeId/products/transfers/$transferId/'| '/_authenticated/$storeId/settings/delivery-profiles/$profileId/'| '/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/$methodId'| '/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new'@@ -1601,13 +1627,6 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof ProductsTransfersNewRouteImportparentRoute: typeof authenticatedStoreIdRoute}- '/_authenticated/$storeId/products/transfers/$transferId': {- id: '/_authenticated/$storeId/products/transfers/$transferId'- path: '/products/transfers/$transferId'- fullPath: '/$storeId/products/transfers/$transferId'- preLoaderRoute: typeof ProductsTransfersTransferIdRouteImport- parentRoute: typeof authenticatedStoreIdRoute- }'/_authenticated/$storeId/products/purchase-orders/new': {id: '/_authenticated/$storeId/products/purchase-orders/new'path: '/products/purchase-orders/new'@@ -1615,13 +1634,6 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof ProductsPurchaseOrdersNewRouteImportparentRoute: typeof authenticatedStoreIdRoute}- '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId': {- id: '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId'- path: '/products/purchase-orders/$purchaseOrderId'- fullPath: '/$storeId/products/purchase-orders/$purchaseOrderId'- preLoaderRoute: typeof ProductsPurchaseOrdersPurchaseOrderIdRouteImport- parentRoute: typeof authenticatedStoreIdRoute- }'/_authenticated/$storeId/products/price-lists/new': {id: '/_authenticated/$storeId/products/price-lists/new'path: '/products/price-lists/new'@@ -1678,6 +1690,20 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof SettingsDeliveryProfilesProfileIdIndexRouteImportparentRoute: typeof SettingsRoute}+ '/_authenticated/$storeId/products/transfers/$transferId/': {+ id: '/_authenticated/$storeId/products/transfers/$transferId/'+ path: '/products/transfers/$transferId'+ fullPath: '/$storeId/products/transfers/$transferId/'+ preLoaderRoute: typeof ProductsTransfersTransferIdIndexRouteImport+ parentRoute: typeof authenticatedStoreIdRoute+ }+ '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/': {+ id: '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/'+ path: '/products/purchase-orders/$purchaseOrderId'+ fullPath: '/$storeId/products/purchase-orders/$purchaseOrderId/'+ preLoaderRoute: typeof ProductsPurchaseOrdersPurchaseOrderIdIndexRouteImport+ parentRoute: typeof authenticatedStoreIdRoute+ }'/_authenticated/$storeId/products/price-lists/$priceListId/': {id: '/_authenticated/$storeId/products/price-lists/$priceListId/'path: '/products/price-lists/$priceListId'@@ -1685,6 +1711,20 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof ProductsPriceListsPriceListIdIndexRouteImportparentRoute: typeof authenticatedStoreIdRoute}+ '/_authenticated/$storeId/products/transfers/$transferId/edit': {+ id: '/_authenticated/$storeId/products/transfers/$transferId/edit'+ path: '/products/transfers/$transferId/edit'+ fullPath: '/$storeId/products/transfers/$transferId/edit'+ preLoaderRoute: typeof ProductsTransfersTransferIdEditRouteImport+ parentRoute: typeof authenticatedStoreIdRoute+ }+ '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/edit': {+ id: '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/edit'+ path: '/products/purchase-orders/$purchaseOrderId/edit'+ fullPath: '/$storeId/products/purchase-orders/$purchaseOrderId/edit'+ preLoaderRoute: typeof ProductsPurchaseOrdersPurchaseOrderIdEditRouteImport+ parentRoute: typeof authenticatedStoreIdRoute+ }'/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new': {id: '/_authenticated/$storeId/settings/delivery-profiles/$profileId/methods/new'path: '/delivery-profiles/$profileId/methods/new'@@ -1812,9 +1852,7 @@ interface authenticatedStoreIdRouteChildren {ProductsCollectionsCollectionIdRoute: typeof ProductsCollectionsCollectionIdRouteProductsCollectionsNewRoute: typeof ProductsCollectionsNewRouteProductsPriceListsNewRoute: typeof ProductsPriceListsNewRoute- ProductsPurchaseOrdersPurchaseOrderIdRoute: typeof ProductsPurchaseOrdersPurchaseOrderIdRouteProductsPurchaseOrdersNewRoute: typeof ProductsPurchaseOrdersNewRoute- ProductsTransfersTransferIdRoute: typeof ProductsTransfersTransferIdRouteProductsTransfersNewRoute: typeof ProductsTransfersNewRouteSellersPayoutsPayoutIdRoute: typeof SellersPayoutsPayoutIdRouteOrdersOrderIdIndexRoute: typeof OrdersOrderIdIndexRoute@@ -1825,7 +1863,11 @@ interface authenticatedStoreIdRouteChildren {ProductsPurchaseOrdersIndexRoute: typeof ProductsPurchaseOrdersIndexRouteProductsTransfersIndexRoute: typeof ProductsTransfersIndexRouteSellersPayoutsIndexRoute: typeof SellersPayoutsIndexRoute+ ProductsPurchaseOrdersPurchaseOrderIdEditRoute: typeof ProductsPurchaseOrdersPurchaseOrderIdEditRoute+ ProductsTransfersTransferIdEditRoute: typeof ProductsTransfersTransferIdEditRouteProductsPriceListsPriceListIdIndexRoute: typeof ProductsPriceListsPriceListIdIndexRoute+ ProductsPurchaseOrdersPurchaseOrderIdIndexRoute: typeof ProductsPurchaseOrdersPurchaseOrderIdIndexRoute+ ProductsTransfersTransferIdIndexRoute: typeof ProductsTransfersTransferIdIndexRoute}const authenticatedStoreIdRouteChildren: authenticatedStoreIdRouteChildren = {@@ -1864,10 +1906,7 @@ const authenticatedStoreIdRouteChildren: authenticatedStoreIdRouteChildren = {ProductsCollectionsCollectionIdRoute: ProductsCollectionsCollectionIdRoute,ProductsCollectionsNewRoute: ProductsCollectionsNewRoute,ProductsPriceListsNewRoute: ProductsPriceListsNewRoute,- ProductsPurchaseOrdersPurchaseOrderIdRoute:- ProductsPurchaseOrdersPurchaseOrderIdRoute,ProductsPurchaseOrdersNewRoute: ProductsPurchaseOrdersNewRoute,- ProductsTransfersTransferIdRoute: ProductsTransfersTransferIdRoute,ProductsTransfersNewRoute: ProductsTransfersNewRoute,SellersPayoutsPayoutIdRoute: SellersPayoutsPayoutIdRoute,OrdersOrderIdIndexRoute: OrdersOrderIdIndexRoute,@@ -1878,8 +1917,14 @@ const authenticatedStoreIdRouteChildren: authenticatedStoreIdRouteChildren = {ProductsPurchaseOrdersIndexRoute: ProductsPurchaseOrdersIndexRoute,ProductsTransfersIndexRoute: ProductsTransfersIndexRoute,SellersPayoutsIndexRoute: SellersPayoutsIndexRoute,+ ProductsPurchaseOrdersPurchaseOrderIdEditRoute:+ ProductsPurchaseOrdersPurchaseOrderIdEditRoute,+ ProductsTransfersTransferIdEditRoute: ProductsTransfersTransferIdEditRoute,ProductsPriceListsPriceListIdIndexRoute:ProductsPriceListsPriceListIdIndexRoute,+ ProductsPurchaseOrdersPurchaseOrderIdIndexRoute:+ ProductsPurchaseOrdersPurchaseOrderIdIndexRoute,+ ProductsTransfersTransferIdIndexRoute: ProductsTransfersTransferIdIndexRoute,}const authenticatedStoreIdRouteWithChildren =diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/edit.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/edit.tsxnew file mode 100644index 0000000000..dc36845690--- /dev/null+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/edit.tsx@@ -0,0 +1,115 @@+import { PageHeader } from '@spree/dashboard-core'+import { Alert, AlertDescription } from '@spree/dashboard-ui'+import { createFileRoute, useNavigate } from '@tanstack/react-router'+import { useTranslation } from 'react-i18next'+import {+ PurchaseOrderForm,+ type PurchaseOrderFormValues,+} from '../../../../../../components/spree/purchase-order-form'+import {+ usePurchaseOrder,+ useUpdatePurchaseOrder,+} from '../../../../../../hooks/use-purchase-orders'++export const Route = createFileRoute(+ '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/edit',+)({+ component: EditPurchaseOrderPage,+})++function EditPurchaseOrderPage() {+ const { t } = useTranslation()+ const { storeId, purchaseOrderId } = Route.useParams()+ const navigate = useNavigate()+ const { data: purchaseOrder, isLoading } = usePurchaseOrder(purchaseOrderId)+ const updateMutation = useUpdatePurchaseOrder(purchaseOrderId)++ const backToOrder = () =>+ navigate({+ to: '/$storeId/products/purchase-orders/$purchaseOrderId',+ params: { storeId, purchaseOrderId },+ })++ if (isLoading || !purchaseOrder) {+ return <div className="p-4 text-muted-foreground text-sm">{t('admin.common.loading')}</div>+ }++ // The endpoint refuses the write once the order has gone to the supplier, so+ // the screen says so rather than offering a form whose Save cannot succeed.+ // Reachable by URL even though the header hides the button by then.+ if (!purchaseOrder.editable) {+ return (+ <div className="mx-auto flex w-full max-w-3xl flex-col gap-4 p-4">+ <PageHeader+ title={t('admin.purchase_orders.edit_title', { number: purchaseOrder.number })}+ backTo={`products/purchase-orders/${purchaseOrderId}`}+ />+ <Alert>+ <AlertDescription>{t('admin.purchase_orders.errors.not_editable')}</AlertDescription>+ </Alert>+ </div>+ )+ }++ async function handleSubmit(values: PurchaseOrderFormValues) {+ const saved = await updateMutation+ .mutateAsync({+ supplier_id: values.supplierId,+ destination_location_id: values.destinationId,+ // Cleared rather than omitted: an emptied field has to survive the+ // round trip, and omitting it would leave the old value in place.+ expected_at: values.expectedAt ?? null,+ reference: values.reference.trim() || null,+ notes: values.notes.trim() || null,+ items: values.lines.map((line) => ({+ variant_id: line.variant.id,+ quantity_ordered: line.quantity,+ unit_cost: line.unitCost,+ })),+ })+ .catch(() => undefined)+ if (!saved) return++ backToOrder()+ }++ return (+ <div className="mx-auto flex w-full max-w-3xl flex-col gap-4 p-4">+ <PageHeader+ title={t('admin.purchase_orders.edit_title', { number: purchaseOrder.number })}+ backTo={`products/purchase-orders/${purchaseOrderId}`}+ />++ <PurchaseOrderForm+ initial={{+ supplierId: purchaseOrder.supplier_id ?? '',+ destinationId: purchaseOrder.destination_location_id ?? '',+ currency: purchaseOrder.currency,+ expectedAt: purchaseOrder.expected_at ?? undefined,+ reference: purchaseOrder.reference ?? '',+ notes: purchaseOrder.notes ?? '',+ // The saved lines carry the same facts a search result does, under+ // their own names, plus the cost the merchant agreed.+ lines: (purchaseOrder.items ?? []).map((item) => ({+ variant: {+ id: item.variant_id ?? '',+ sku: item.variant_sku,+ product_name: item.variant_name,+ thumbnail_url: item.thumbnail_url,+ },+ quantity: item.quantity_ordered,+ unitCost: item.unit_cost ?? '0.00',+ })),+ }}+ // Every line cost is denominated in it, so changing it now would+ // silently reprice the order.+ currencyLocked+ submitLabel={t('admin.actions.save')}+ pendingLabel={t('admin.actions.saving')}+ pending={updateMutation.isPending}+ onSubmit={handleSubmit}+ onCancel={backToOrder}+ />+ </div>+ )+}diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/index.tsxsimilarity index 88%rename from packages/dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId.tsxrename to packages/dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/index.tsxindex 45f9b5d1c2..a5f4b74a19 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/index.tsx@@ -16,24 +16,24 @@ import {TableRow,useConfirm,} from '@spree/dashboard-ui'-import { XCircleIcon } from '@spree/dashboard-ui/icons'+import { PencilIcon, XCircleIcon } from '@spree/dashboard-ui/icons'import { createFileRoute, Link } from '@tanstack/react-router'import { useState } from 'react'import { useTranslation } from 'react-i18next'-import { InventoryStatusBadge } from '../../../../../components/spree/inventory-status-badge'-import { QuantityCell, QuantityHead } from '../../../../../components/spree/quantity-cell'-import { StockHistoryCard } from '../../../../../components/spree/stock-history-card'-import { VariantLink } from '../../../../../components/spree/variant-link'+import { InventoryStatusBadge } from '../../../../../../components/spree/inventory-status-badge'+import { QuantityCell, QuantityHead } from '../../../../../../components/spree/quantity-cell'+import { StockHistoryCard } from '../../../../../../components/spree/stock-history-card'+import { VariantLink } from '../../../../../../components/spree/variant-link'import {useCancelPurchaseOrder,useMarkPurchaseOrderOrdered,usePurchaseOrder,useReceivePurchaseOrder,-} from '../../../../../hooks/use-purchase-orders'-import { isClosed } from '../../../../../schemas/inventory-operations'+} from '../../../../../../hooks/use-purchase-orders'+import { isClosed } from '../../../../../../schemas/inventory-operations'export const Route = createFileRoute(- '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId',+ '/_authenticated/$storeId/products/purchase-orders/$purchaseOrderId/',)({component: PurchaseOrderDetailPage,})@@ -296,6 +296,7 @@ function ItemRow({*/function PurchaseOrderHeader({ purchaseOrder }: { purchaseOrder: PurchaseOrder }) {const { t } = useTranslation()+ const { storeId } = useStore()const confirm = useConfirm()const markOrdered = useMarkPurchaseOrderOrdered(purchaseOrder.id)const cancelOrder = useCancelPurchaseOrder(purchaseOrder.id)@@ -331,16 +332,30 @@ function PurchaseOrderHeader({ purchaseOrder }: { purchaseOrder: PurchaseOrder }backTo="products/purchase-orders"badges={<InventoryStatusBadge status={purchaseOrder.status} resource="purchase_orders" />}actions={- open &&- purchaseOrder.status === 'draft' && (+ open && (<Can I="update" a={Subject.PurchaseOrder}>- <Button- type="button"- onClick={handleOrder}- disabled={markOrdered.isPending || (purchaseOrder.items_count ?? 0) === 0}- >- {t('admin.purchase_orders.actions.mark_ordered')}- </Button>+ {/* A draft is the only order whose lines are still a plan rather+ than a commitment to a supplier, which `editable` reports. */}+ {purchaseOrder.editable && (+ <Button variant="outline" asChild>+ <Link+ to="/$storeId/products/purchase-orders/$purchaseOrderId/edit"+ params={{ storeId, purchaseOrderId: purchaseOrder.id }}+ >+ <PencilIcon className="size-4" />+ {t('admin.actions.edit')}+ </Link>+ </Button>+ )}+ {purchaseOrder.status === 'draft' && (+ <Button+ type="button"+ onClick={handleOrder}+ disabled={markOrdered.isPending || (purchaseOrder.items_count ?? 0) === 0}+ >+ {t('admin.purchase_orders.actions.mark_ordered')}+ </Button>+ )}</Can>)}diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/new.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/new.tsxindex e767905a50..350883d858 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/new.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/purchase-orders/new.tsx@@ -1,37 +1,12 @@-import type { Supplier } from '@spree/admin-sdk'-import {- CurrencySelect,- PageHeader,- ResourceCombobox,- StoreDatePicker,- useStockLocations,-} from '@spree/dashboard-core'-import {- Button,- Card,- CardContent,- CardHeader,- CardTitle,- Field,- FieldGroup,- FieldLabel,- Input,- Select,- SelectContent,- SelectItem,- SelectTrigger,- SelectValue,- Textarea,-} from '@spree/dashboard-ui'+import { PageHeader } from '@spree/dashboard-core'import { createFileRoute, useNavigate } from '@tanstack/react-router'-import { useState } from 'react'import { useTranslation } from 'react-i18next'import {- type VariantLine,- VariantLineEditor,-} from '../../../../../components/spree/variant-line-editor'+ EMPTY_PURCHASE_ORDER,+ PurchaseOrderForm,+ type PurchaseOrderFormValues,+} from '../../../../../components/spree/purchase-order-form'import { useCreatePurchaseOrder } from '../../../../../hooks/use-purchase-orders'-import { supplierAutocompleteProps } from '../../../../../hooks/use-suppliers'export const Route = createFileRoute('/_authenticated/$storeId/products/purchase-orders/new')({component: NewPurchaseOrderPage,@@ -42,37 +17,18 @@ function NewPurchaseOrderPage() {const { storeId } = Route.useParams()const navigate = useNavigate()const createMutation = useCreatePurchaseOrder()- const { data: stockLocations } = useStockLocations({ limit: 100 })- const locations = stockLocations?.data ?? []-- const [supplierId, setSupplierId] = useState('')- const [destinationId, setDestinationId] = useState('')- const [currency, setCurrency] = useState<string | undefined>(undefined)- const [expectedAt, setExpectedAt] = useState<string | undefined>(undefined)- const [reference, setReference] = useState('')- const [notes, setNotes] = useState('')- const [lines, setLines] = useState<VariantLine[]>([])-- const canSubmit =- !!supplierId &&- !!destinationId &&- // A cleared cost input is not zero — it is nothing, which the server- // rejects field-by-field. Catch it here, where the field is.- lines.every((line) => line.quantity > 0 && Number.isFinite(Number(line.unitCost)))-- async function handleSubmit() {- if (!canSubmit) return+ async function handleSubmit(values: PurchaseOrderFormValues) {// The hook toasts the refusal; navigating would hide it.const purchaseOrder = await createMutation.mutateAsync({- supplier_id: supplierId,- destination_location_id: destinationId,- currency,- expected_at: expectedAt,- reference: reference.trim() || undefined,- notes: notes.trim() || undefined,- items: lines.map((line) => ({+ supplier_id: values.supplierId,+ destination_location_id: values.destinationId,+ currency: values.currency,+ expected_at: values.expectedAt,+ reference: values.reference.trim() || undefined,+ notes: values.notes.trim() || undefined,+ items: values.lines.map((line) => ({variant_id: line.variant.id,quantity_ordered: line.quantity,unit_cost: line.unitCost,@@ -91,129 +47,14 @@ function NewPurchaseOrderPage() {<div className="mx-auto flex w-full max-w-3xl flex-col gap-4 p-4"><PageHeader title={t('admin.purchase_orders.new_title')} backTo="products/purchase-orders" />- <Card>- <CardHeader>- <CardTitle>{t('admin.purchase_orders.details_title')}</CardTitle>- </CardHeader>- <CardContent>- <FieldGroup>- <Field>- <FieldLabel htmlFor="supplier">- {t('admin.purchase_orders.fields.supplier')}- </FieldLabel>- {/* Searchable rather than a capped list: a wholesaler can hold- more suppliers than one page of a Select would show, and a- Select says nothing about the ones it left out. */}- <ResourceCombobox<Supplier>- {...supplierAutocompleteProps('purchase-order-supplier-picker')}- id="supplier"- value={supplierId}- onChange={(id) => setSupplierId(id ?? '')}- placeholder={t('admin.purchase_orders.fields.supplier_placeholder')}- />- </Field>-- <Field>- <FieldLabel htmlFor="destination">- {t('admin.purchase_orders.fields.destination')}- </FieldLabel>- <Select value={destinationId} onValueChange={setDestinationId}>- <SelectTrigger id="destination">- <SelectValue- placeholder={t('admin.purchase_orders.fields.destination_placeholder')}- >- {(value) => locations.find((l) => l.id === value)?.name ?? (value as string)}- </SelectValue>- </SelectTrigger>- <SelectContent>- {locations.map((location) => (- <SelectItem key={location.id} value={location.id}>- {location.name}- </SelectItem>- ))}- </SelectContent>- </Select>- </Field>-- <Field>- <FieldLabel htmlFor="currency">- {t('admin.purchase_orders.fields.currency')}- </FieldLabel>- {/* A foreign-currency purchase order is legitimate; leaving- this alone takes the store's own currency. */}- <CurrencySelect id="currency" value={currency} onChange={setCurrency} />- </Field>-- <Field>- <FieldLabel>{t('admin.purchase_orders.fields.expected_at')}</FieldLabel>- {/* A calendar date, not an instant: the day the supplier- promised means the same day in every timezone. */}- <StoreDatePicker- value={expectedAt}- onChange={(value) => setExpectedAt(value ?? undefined)}- placeholder={t('admin.purchase_orders.fields.expected_at_placeholder')}- />- </Field>-- <Field>- <FieldLabel htmlFor="reference">- {t('admin.purchase_orders.fields.reference')}- </FieldLabel>- <Input- id="reference"- placeholder={t('admin.purchase_orders.fields.reference_placeholder')}- value={reference}- onChange={(event) => setReference(event.target.value)}- />- </Field>-- <Field>- <FieldLabel htmlFor="notes">{t('admin.purchase_orders.fields.notes')}</FieldLabel>- <Textarea- id="notes"- value={notes}- onChange={(event) => setNotes(event.target.value)}- />- </Field>- </FieldGroup>- </CardContent>- </Card>-- <Card>- <CardHeader>- <CardTitle>{t('admin.purchase_orders.items_title')}</CardTitle>- </CardHeader>- <CardContent>- <VariantLineEditor- lines={lines}- onChange={setLines}- currency={currency}- quantityLabel={t('admin.purchase_orders.columns.quantity_ordered')}- withCost- />- </CardContent>- </Card>-- <div className="flex justify-end gap-2">- <Button- type="button"- variant="outline"- onClick={() =>- navigate({ to: '/$storeId/products/purchase-orders', params: { storeId } })- }- >- {t('admin.actions.cancel')}- </Button>- <Button- type="button"- onClick={handleSubmit}- disabled={!canSubmit || createMutation.isPending}- >- {createMutation.isPending- ? t('admin.actions.creating')- : t('admin.purchase_orders.actions.create_draft')}- </Button>- </div>+ <PurchaseOrderForm+ initial={EMPTY_PURCHASE_ORDER}+ submitLabel={t('admin.purchase_orders.actions.create_draft')}+ pendingLabel={t('admin.actions.creating')}+ pending={createMutation.isPending}+ onSubmit={handleSubmit}+ onCancel={() => navigate({ to: '/$storeId/products/purchase-orders', params: { storeId } })}+ /></div>)}diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/transfers/$transferId/edit.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/transfers/$transferId/edit.tsxnew file mode 100644index 0000000000..9dcf5c8bab--- /dev/null+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/transfers/$transferId/edit.tsx@@ -0,0 +1,102 @@+import { PageHeader } from '@spree/dashboard-core'+import { Alert, AlertDescription } from '@spree/dashboard-ui'+import { createFileRoute, useNavigate } from '@tanstack/react-router'+import { useTranslation } from 'react-i18next'+import {+ StockTransferForm,+ type StockTransferFormValues,+} from '../../../../../../components/spree/stock-transfer-form'+import {+ useStockTransfer,+ useUpdateStockTransfer,+} from '../../../../../../hooks/use-stock-transfers'++export const Route = createFileRoute(+ '/_authenticated/$storeId/products/transfers/$transferId/edit',+)({ component: EditStockTransferPage })++function EditStockTransferPage() {+ const { t } = useTranslation()+ const { storeId, transferId } = Route.useParams()+ const navigate = useNavigate()+ const { data: transfer, isLoading } = useStockTransfer(transferId)+ const updateMutation = useUpdateStockTransfer(transferId)++ const backToTransfer = () =>+ navigate({ to: '/$storeId/products/transfers/$transferId', params: { storeId, transferId } })++ if (isLoading || !transfer) {+ return <div className="p-4 text-muted-foreground text-sm">{t('admin.common.loading')}</div>+ }++ // The endpoint refuses the write past draft, so the screen says so rather+ // than offering a form whose Save cannot succeed. Reachable by URL even+ // though the header hides the button once the transfer is packed.+ if (!transfer.editable) {+ return (+ <div className="mx-auto flex w-full max-w-3xl flex-col gap-4 p-4">+ <PageHeader+ title={t('admin.stock_transfers.edit_title', { number: transfer.number })}+ backTo={`products/transfers/${transferId}`}+ />+ <Alert>+ <AlertDescription>{t('admin.stock_transfers.errors.not_editable')}</AlertDescription>+ </Alert>+ </div>+ )+ }++ async function handleSubmit(values: StockTransferFormValues) {+ const saved = await updateMutation+ .mutateAsync({+ source_location_id: values.sourceId,+ destination_location_id: values.destinationId,+ // Cleared rather than omitted: an emptied field has to survive the+ // round trip, and omitting it would leave the old value in place.+ reference: values.reference.trim() || null,+ notes: values.notes.trim() || null,+ items: values.lines.map((line) => ({+ variant_id: line.variant.id,+ quantity_shipped: line.quantity,+ })),+ })+ .catch(() => undefined)+ if (!saved) return++ backToTransfer()+ }++ return (+ <div className="mx-auto flex w-full max-w-3xl flex-col gap-4 p-4">+ <PageHeader+ title={t('admin.stock_transfers.edit_title', { number: transfer.number })}+ backTo={`products/transfers/${transferId}`}+ />++ <StockTransferForm+ initial={{+ sourceId: transfer.source_location_id ?? '',+ destinationId: transfer.destination_location_id ?? '',+ reference: transfer.reference ?? '',+ notes: transfer.notes ?? '',+ // The saved lines carry the same four facts a search result does,+ // under their own names.+ lines: (transfer.items ?? []).map((item) => ({+ variant: {+ id: item.variant_id ?? '',+ sku: item.variant_sku,+ product_name: item.variant_name,+ thumbnail_url: item.thumbnail_url,+ },+ quantity: item.quantity_shipped,+ })),+ }}+ submitLabel={t('admin.actions.save')}+ pendingLabel={t('admin.actions.saving')}+ pending={updateMutation.isPending}+ onSubmit={handleSubmit}+ onCancel={backToTransfer}+ />+ </div>+ )+}diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/transfers/$transferId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/transfers/$transferId/index.tsxsimilarity index 92%rename from packages/dashboard/src/routes/_authenticated/$storeId/products/transfers/$transferId.tsxrename to packages/dashboard/src/routes/_authenticated/$storeId/products/transfers/$transferId/index.tsxindex 467c65a6f1..f2334ad988 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/transfers/$transferId.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/transfers/$transferId/index.tsx@@ -21,28 +21,28 @@ import {TableRow,useConfirm,} from '@spree/dashboard-ui'-import { XCircleIcon } from '@spree/dashboard-ui/icons'+import { PencilIcon, XCircleIcon } from '@spree/dashboard-ui/icons'import { createFileRoute, Link } from '@tanstack/react-router'import { useMemo, useState } from 'react'import { useTranslation } from 'react-i18next'-import { InventoryStatusBadge } from '../../../../../components/spree/inventory-status-badge'-import { QuantityCell, QuantityHead } from '../../../../../components/spree/quantity-cell'-import { StockHistoryCard } from '../../../../../components/spree/stock-history-card'-import { TransferCancelDialog } from '../../../../../components/spree/transfer-cancel-dialog'-import { VariantLink } from '../../../../../components/spree/variant-link'+import { InventoryStatusBadge } from '../../../../../../components/spree/inventory-status-badge'+import { QuantityCell, QuantityHead } from '../../../../../../components/spree/quantity-cell'+import { StockHistoryCard } from '../../../../../../components/spree/stock-history-card'+import { TransferCancelDialog } from '../../../../../../components/spree/transfer-cancel-dialog'+import { VariantLink } from '../../../../../../components/spree/variant-link'import {useMarkStockTransferInTransit,useMarkStockTransferReady,useReceiveStockTransfer,useStockTransfer,-} from '../../../../../hooks/use-stock-transfers'+} from '../../../../../../hooks/use-stock-transfers'import {DISCREPANCY_REASONS,isClosed,isInFlight,-} from '../../../../../schemas/inventory-operations'+} from '../../../../../../schemas/inventory-operations'-export const Route = createFileRoute('/_authenticated/$storeId/products/transfers/$transferId')({+export const Route = createFileRoute('/_authenticated/$storeId/products/transfers/$transferId/')({component: StockTransferDetailPage,})@@ -407,6 +407,7 @@ function ReceiveRow({*/function TransferHeader({ transfer }: { transfer: StockTransfer }) {const { t } = useTranslation()+ const { storeId } = useStore()const confirm = useConfirm()const markReady = useMarkStockTransferReady(transfer.id)const markInTransit = useMarkStockTransferInTransit(transfer.id)@@ -439,6 +440,19 @@ function TransferHeader({ transfer }: { transfer: StockTransfer }) {actions={open && (<Can I="update" a={Subject.StockTransfer}>+ {/* A draft is the only transfer whose contents are still a plan+ rather than a record, which is what `editable` reports. */}+ {transfer.editable && (+ <Button variant="outline" asChild>+ <Link+ to="/$storeId/products/transfers/$transferId/edit"+ params={{ storeId, transferId: transfer.id }}+ >+ <PencilIcon className="size-4" />+ {t('admin.actions.edit')}+ </Link>+ </Button>+ )}{/* Packing a draft is optional — a merchant already loading thevan can go straight to in transit — so it is the quieter ofthe two. */}diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/transfers/new.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/transfers/new.tsxindex 80fb719dbf..1e8baf9e00 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/transfers/new.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/transfers/new.tsx@@ -1,29 +1,11 @@-import { PageHeader, useStockLocations } from '@spree/dashboard-core'-import {- Button,- Card,- CardContent,- CardHeader,- CardTitle,- Field,- FieldError,- FieldGroup,- FieldLabel,- Input,- Select,- SelectContent,- SelectItem,- SelectTrigger,- SelectValue,- Textarea,-} from '@spree/dashboard-ui'+import { PageHeader } from '@spree/dashboard-core'import { createFileRoute, useNavigate } from '@tanstack/react-router'-import { useState } from 'react'import { useTranslation } from 'react-i18next'import {- type VariantLine,- VariantLineEditor,-} from '../../../../../components/spree/variant-line-editor'+ EMPTY_STOCK_TRANSFER,+ StockTransferForm,+ type StockTransferFormValues,+} from '../../../../../components/spree/stock-transfer-form'import { useCreateStockTransfer } from '../../../../../hooks/use-stock-transfers'export const Route = createFileRoute('/_authenticated/$storeId/products/transfers/new')({@@ -35,31 +17,17 @@ function NewStockTransferPage() {const { storeId } = Route.useParams()const navigate = useNavigate()const createMutation = useCreateStockTransfer()- const { data: stockLocations } = useStockLocations({ limit: 100 })- const locations = stockLocations?.data ?? []-- const [sourceId, setSourceId] = useState('')- const [destinationId, setDestinationId] = useState('')- const [reference, setReference] = useState('')- const [notes, setNotes] = useState('')- const [lines, setLines] = useState<VariantLine[]>([])-- const sameLocation = !!sourceId && sourceId === destinationId- const canSubmit =- !!sourceId && !!destinationId && !sameLocation && lines.every((line) => line.quantity > 0)-- async function handleSubmit() {- if (!canSubmit) return+ async function handleSubmit(values: StockTransferFormValues) {// The hook toasts the refusal; there is nowhere inline to put it on a// page that has no form errors, and navigating would hide it.const transfer = await createMutation.mutateAsync({- source_location_id: sourceId,- destination_location_id: destinationId,- reference: reference.trim() || undefined,- notes: notes.trim() || undefined,- items: lines.map((line) => ({+ source_location_id: values.sourceId,+ destination_location_id: values.destinationId,+ reference: values.reference.trim() || undefined,+ notes: values.notes.trim() || undefined,+ items: values.lines.map((line) => ({variant_id: line.variant.id,quantity_shipped: line.quantity,})),@@ -77,119 +45,14 @@ function NewStockTransferPage() {<div className="mx-auto flex w-full max-w-3xl flex-col gap-4 p-4"><PageHeader title={t('admin.stock_transfers.new_title')} backTo="products/transfers" />- <Card>- <CardHeader>- <CardTitle>{t('admin.stock_transfers.details_title')}</CardTitle>- </CardHeader>- <CardContent>- <FieldGroup>- <Field>- <FieldLabel htmlFor="source">{t('admin.stock_transfers.fields.source')}</FieldLabel>- <Select value={sourceId} onValueChange={setSourceId}>- <SelectTrigger id="source">- <SelectValue placeholder={t('admin.stock_transfers.fields.source_placeholder')}>- {(value) => locations.find((l) => l.id === value)?.name ?? (value as string)}- </SelectValue>- </SelectTrigger>- <SelectContent>- {locations.map((location) => (- <SelectItem key={location.id} value={location.id}>- {location.name}- </SelectItem>- ))}- </SelectContent>- </Select>- </Field>-- <Field>- <FieldLabel htmlFor="destination">- {t('admin.stock_transfers.fields.destination')}- </FieldLabel>- <Select value={destinationId} onValueChange={setDestinationId}>- <SelectTrigger id="destination">- <SelectValue- placeholder={t('admin.stock_transfers.fields.destination_placeholder')}- >- {(value) => locations.find((l) => l.id === value)?.name ?? (value as string)}- </SelectValue>- </SelectTrigger>- <SelectContent>- {locations- .filter((location) => location.id !== sourceId)- .map((location) => (- <SelectItem key={location.id} value={location.id}>- {location.name}- </SelectItem>- ))}- </SelectContent>- </Select>- {sameLocation && (- <FieldError>{t('admin.stock_transfers.errors.same_location')}</FieldError>- )}- </Field>-- <Field>- <FieldLabel htmlFor="reference">- {t('admin.stock_transfers.fields.reference')}- </FieldLabel>- <Input- id="reference"- placeholder={t('admin.stock_transfers.fields.reference_placeholder')}- value={reference}- onChange={(event) => setReference(event.target.value)}- />- </Field>-- <Field>- <FieldLabel htmlFor="notes">{t('admin.stock_transfers.fields.notes')}</FieldLabel>- <Textarea- id="notes"- value={notes}- onChange={(event) => setNotes(event.target.value)}- />- </Field>- </FieldGroup>- </CardContent>- </Card>-- <Card>- <CardHeader>- <CardTitle>{t('admin.stock_transfers.items_title')}</CardTitle>- </CardHeader>- <CardContent>- {/* A draft may open empty and gain lines as the merchant packs, so- there is nothing to enforce here. */}- {/* The picker offers only what the source can send, and stays shut- until one is chosen: a line the source has none of is refused- later, per line, when the transfer is marked in transit. */}- <VariantLineEditor- lines={lines}- onChange={setLines}- quantityLabel={t('admin.stock_transfers.columns.quantity_shipped')}- stockLocationId={sourceId || null}- requireStockLocation- />- </CardContent>- </Card>-- <div className="flex justify-end gap-2">- <Button- type="button"- variant="outline"- onClick={() => navigate({ to: '/$storeId/products/transfers', params: { storeId } })}- >- {t('admin.actions.cancel')}- </Button>- <Button- type="button"- onClick={handleSubmit}- disabled={!canSubmit || createMutation.isPending}- >- {createMutation.isPending- ? t('admin.actions.creating')- : t('admin.stock_transfers.actions.create_draft')}- </Button>- </div>+ <StockTransferForm+ initial={EMPTY_STOCK_TRANSFER}+ submitLabel={t('admin.stock_transfers.actions.create_draft')}+ pendingLabel={t('admin.actions.creating')}+ pending={createMutation.isPending}+ onSubmit={handleSubmit}+ onCancel={() => navigate({ to: '/$storeId/products/transfers', params: { storeId } })}+ /></div>)}