@open-mercato/core 0.10.1-develop.7709.1.046124599c → 0.10.1-develop.7714.1.9dbb8200d8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -2
- package/dist/generated/entities/asn/index.js +19 -0
- package/dist/generated/entities/asn/index.js.map +7 -0
- package/dist/generated/entities/putaway_task/index.js +25 -0
- package/dist/generated/entities/putaway_task/index.js.map +7 -0
- package/dist/generated/entities/receiving_line/index.js +21 -0
- package/dist/generated/entities/receiving_line/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +4 -1
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +34 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/modules/communication_channels/lib/sanitize-channel-html.js +22 -3
- package/dist/modules/communication_channels/lib/sanitize-channel-html.js.map +2 -2
- package/dist/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.client.js +40 -11
- package/dist/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.client.js.map +2 -2
- package/dist/modules/customers/components/calendar/CalendarEventEditor.js +13 -2
- package/dist/modules/customers/components/calendar/CalendarEventEditor.js.map +2 -2
- package/dist/modules/wms/acl.js +2 -0
- package/dist/modules/wms/acl.js.map +2 -2
- package/dist/modules/wms/api/asns/[id]/complete/route.js +61 -0
- package/dist/modules/wms/api/asns/[id]/complete/route.js.map +7 -0
- package/dist/modules/wms/api/asns/[id]/receive/route.js +68 -0
- package/dist/modules/wms/api/asns/[id]/receive/route.js.map +7 -0
- package/dist/modules/wms/api/asns/route.js +197 -0
- package/dist/modules/wms/api/asns/route.js.map +7 -0
- package/dist/modules/wms/api/inventory/helpers.js +42 -34
- package/dist/modules/wms/api/inventory/helpers.js.map +2 -2
- package/dist/modules/wms/api/inventory/receive/route.js +1 -1
- package/dist/modules/wms/api/inventory/receive/route.js.map +2 -2
- package/dist/modules/wms/api/listEnrichers.js +23 -0
- package/dist/modules/wms/api/listEnrichers.js.map +2 -2
- package/dist/modules/wms/api/putaway-tasks/[id]/assign/route.js +56 -0
- package/dist/modules/wms/api/putaway-tasks/[id]/assign/route.js.map +7 -0
- package/dist/modules/wms/api/putaway-tasks/[id]/cancel/route.js +56 -0
- package/dist/modules/wms/api/putaway-tasks/[id]/cancel/route.js.map +7 -0
- package/dist/modules/wms/api/putaway-tasks/[id]/complete/route.js +65 -0
- package/dist/modules/wms/api/putaway-tasks/[id]/complete/route.js.map +7 -0
- package/dist/modules/wms/api/putaway-tasks/[id]/start/route.js +56 -0
- package/dist/modules/wms/api/putaway-tasks/[id]/start/route.js.map +7 -0
- package/dist/modules/wms/api/putaway-tasks/create-from-balance/route.js +51 -0
- package/dist/modules/wms/api/putaway-tasks/create-from-balance/route.js.map +7 -0
- package/dist/modules/wms/api/putaway-tasks/route.js +192 -0
- package/dist/modules/wms/api/putaway-tasks/route.js.map +7 -0
- package/dist/modules/wms/api/receiving-lines/route.js +180 -0
- package/dist/modules/wms/api/receiving-lines/route.js.map +7 -0
- package/dist/modules/wms/api/scan/putaway/route.js +104 -0
- package/dist/modules/wms/api/scan/putaway/route.js.map +7 -0
- package/dist/modules/wms/api/scan/receive/route.js +109 -0
- package/dist/modules/wms/api/scan/receive/route.js.map +7 -0
- package/dist/modules/wms/api/scan/resolve-location/route.js +89 -0
- package/dist/modules/wms/api/scan/resolve-location/route.js.map +7 -0
- package/dist/modules/wms/api/scan/resolve-lot/route.js +89 -0
- package/dist/modules/wms/api/scan/resolve-lot/route.js.map +7 -0
- package/dist/modules/wms/backend/wms/asns/[id]/page.js +9 -0
- package/dist/modules/wms/backend/wms/asns/[id]/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/asns/[id]/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/asns/[id]/page.meta.js.map +7 -0
- package/dist/modules/wms/backend/wms/asns/page.js +9 -0
- package/dist/modules/wms/backend/wms/asns/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/asns/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/asns/page.meta.js.map +7 -0
- package/dist/modules/wms/backend/wms/putaway/page.js +9 -0
- package/dist/modules/wms/backend/wms/putaway/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/putaway/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/putaway/page.meta.js.map +7 -0
- package/dist/modules/wms/backend/wms/receiving/page.js +8 -0
- package/dist/modules/wms/backend/wms/receiving/page.js.map +7 -0
- package/dist/modules/wms/backend/wms/receiving/page.meta.js +18 -0
- package/dist/modules/wms/backend/wms/receiving/page.meta.js.map +7 -0
- package/dist/modules/wms/ce.js +27 -0
- package/dist/modules/wms/ce.js.map +2 -2
- package/dist/modules/wms/commands/asn.js +1746 -0
- package/dist/modules/wms/commands/asn.js.map +7 -0
- package/dist/modules/wms/commands/index.js +2 -0
- package/dist/modules/wms/commands/index.js.map +2 -2
- package/dist/modules/wms/commands/inventory-actions.js +347 -243
- package/dist/modules/wms/commands/inventory-actions.js.map +2 -2
- package/dist/modules/wms/commands/putaway.js +945 -0
- package/dist/modules/wms/commands/putaway.js.map +7 -0
- package/dist/modules/wms/commands/shared.js +51 -0
- package/dist/modules/wms/commands/shared.js.map +2 -2
- package/dist/modules/wms/components/backend/AssignPutawayTaskDialog.js +278 -0
- package/dist/modules/wms/components/backend/AssignPutawayTaskDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/CompletePutawayTaskDialog.js +327 -0
- package/dist/modules/wms/components/backend/CompletePutawayTaskDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/CreateAsnDialog.js +404 -0
- package/dist/modules/wms/components/backend/CreateAsnDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/InventoryOperationsSection.js +16 -3
- package/dist/modules/wms/components/backend/InventoryOperationsSection.js.map +2 -2
- package/dist/modules/wms/components/backend/ReceiveAsnLineDialog.js +476 -0
- package/dist/modules/wms/components/backend/ReceiveAsnLineDialog.js.map +7 -0
- package/dist/modules/wms/components/backend/ReceiveInventoryDialog.js +2 -2
- package/dist/modules/wms/components/backend/ReceiveInventoryDialog.js.map +2 -2
- package/dist/modules/wms/components/backend/WmsAsnDetailPage.js +524 -0
- package/dist/modules/wms/components/backend/WmsAsnDetailPage.js.map +7 -0
- package/dist/modules/wms/components/backend/WmsAsnsListPage.js +339 -0
- package/dist/modules/wms/components/backend/WmsAsnsListPage.js.map +7 -0
- package/dist/modules/wms/components/backend/WmsLocationDetailPage.js +5 -6
- package/dist/modules/wms/components/backend/WmsLocationDetailPage.js.map +2 -2
- package/dist/modules/wms/components/backend/WmsLotDetailPage.js +5 -6
- package/dist/modules/wms/components/backend/WmsLotDetailPage.js.map +2 -2
- package/dist/modules/wms/components/backend/WmsOperationalDashboardPage.js +14 -10
- package/dist/modules/wms/components/backend/WmsOperationalDashboardPage.js.map +2 -2
- package/dist/modules/wms/components/backend/WmsPutawayQueuePage.js +598 -0
- package/dist/modules/wms/components/backend/WmsPutawayQueuePage.js.map +7 -0
- package/dist/modules/wms/components/backend/WmsSkuDetailPage.js +5 -6
- package/dist/modules/wms/components/backend/WmsSkuDetailPage.js.map +2 -2
- package/dist/modules/wms/components/backend/asnCompleteOptimisticLock.js +32 -0
- package/dist/modules/wms/components/backend/asnCompleteOptimisticLock.js.map +7 -0
- package/dist/modules/wms/components/backend/asnReceivingLinesLoader.js +36 -0
- package/dist/modules/wms/components/backend/asnReceivingLinesLoader.js.map +7 -0
- package/dist/modules/wms/components/backend/inboundStatusUi.js +106 -0
- package/dist/modules/wms/components/backend/inboundStatusUi.js.map +7 -0
- package/dist/modules/wms/components/backend/inventoryMutationLoaders.js +17 -0
- package/dist/modules/wms/components/backend/inventoryMutationLoaders.js.map +2 -2
- package/dist/modules/wms/components/backend/putawayQueueOptimisticLock.js +14 -0
- package/dist/modules/wms/components/backend/putawayQueueOptimisticLock.js.map +7 -0
- package/dist/modules/wms/components/backend/useWmsInventoryMutationAccess.js +4 -0
- package/dist/modules/wms/components/backend/useWmsInventoryMutationAccess.js.map +2 -2
- package/dist/modules/wms/data/enrichers.js +117 -12
- package/dist/modules/wms/data/enrichers.js.map +2 -2
- package/dist/modules/wms/data/entities.js +150 -1
- package/dist/modules/wms/data/entities.js.map +2 -2
- package/dist/modules/wms/data/validators.js +214 -0
- package/dist/modules/wms/data/validators.js.map +2 -2
- package/dist/modules/wms/events.js +12 -1
- package/dist/modules/wms/events.js.map +2 -2
- package/dist/modules/wms/extension-points.js +3 -1
- package/dist/modules/wms/extension-points.js.map +2 -2
- package/dist/modules/wms/lib/asnReceiving.js +124 -0
- package/dist/modules/wms/lib/asnReceiving.js.map +7 -0
- package/dist/modules/wms/lib/asnVendor.js +52 -0
- package/dist/modules/wms/lib/asnVendor.js.map +7 -0
- package/dist/modules/wms/lib/flashMutationError.js +4 -0
- package/dist/modules/wms/lib/flashMutationError.js.map +2 -2
- package/dist/modules/wms/lib/inventoryDisplayUi.js +24 -0
- package/dist/modules/wms/lib/inventoryDisplayUi.js.map +2 -2
- package/dist/modules/wms/lib/inventoryPolicy.js +17 -0
- package/dist/modules/wms/lib/inventoryPolicy.js.map +2 -2
- package/dist/modules/wms/lib/loadOperationalDashboard.js +67 -1
- package/dist/modules/wms/lib/loadOperationalDashboard.js.map +2 -2
- package/dist/modules/wms/lib/putaway.js +141 -0
- package/dist/modules/wms/lib/putaway.js.map +7 -0
- package/dist/modules/wms/lib/roleFeatures.js +3 -1
- package/dist/modules/wms/lib/roleFeatures.js.map +2 -2
- package/dist/modules/wms/lib/salesOrderInventoryAutomation.js +99 -1
- package/dist/modules/wms/lib/salesOrderInventoryAutomation.js.map +2 -2
- package/dist/modules/wms/lib/scanResolve.js +147 -0
- package/dist/modules/wms/lib/scanResolve.js.map +7 -0
- package/dist/modules/wms/lib/wmsIntegrationToggles.js +1 -1
- package/dist/modules/wms/lib/wmsIntegrationToggles.js.map +2 -2
- package/dist/modules/wms/migrations/Migration20260812120000.js +43 -0
- package/dist/modules/wms/migrations/Migration20260812120000.js.map +7 -0
- package/dist/modules/wms/migrations/Migration20260812130000.js +30 -0
- package/dist/modules/wms/migrations/Migration20260812130000.js.map +7 -0
- package/dist/modules/wms/migrations/Migration20260822120000.js +17 -0
- package/dist/modules/wms/migrations/Migration20260822120000.js.map +7 -0
- package/dist/modules/wms/migrations/Migration20260822130000.js +17 -0
- package/dist/modules/wms/migrations/Migration20260822130000.js.map +7 -0
- package/dist/modules/wms/migrations/Migration20261029120000.js +13 -0
- package/dist/modules/wms/migrations/Migration20261029120000.js.map +7 -0
- package/dist/modules/wms/search.js +85 -0
- package/dist/modules/wms/search.js.map +2 -2
- package/dist/modules/wms/subscribers/asn-line-received-reevaluate-reservations.js +14 -0
- package/dist/modules/wms/subscribers/asn-line-received-reevaluate-reservations.js.map +7 -0
- package/dist/modules/wms/subscribers/invalidate-enricher-cache-asn.js +12 -0
- package/dist/modules/wms/subscribers/invalidate-enricher-cache-asn.js.map +7 -0
- package/dist/modules/wms/subscribers/procurement-goods-receipt-created.js +163 -0
- package/dist/modules/wms/subscribers/procurement-goods-receipt-created.js.map +7 -0
- package/dist/modules/wms/subscribers/putaway-completed-reevaluate-reservations.js +14 -0
- package/dist/modules/wms/subscribers/putaway-completed-reevaluate-reservations.js.map +7 -0
- package/dist/modules/wms/widgets/injection/sales-order-stock-context/widget.client.js +37 -8
- package/dist/modules/wms/widgets/injection/sales-order-stock-context/widget.client.js.map +2 -2
- package/generated/entities/asn/index.ts +8 -0
- package/generated/entities/putaway_task/index.ts +11 -0
- package/generated/entities/receiving_line/index.ts +9 -0
- package/generated/entities.ids.generated.ts +4 -1
- package/generated/entity-fields-registry.ts +34 -0
- package/package.json +7 -7
- package/src/modules/auth/i18n/de.json +2 -0
- package/src/modules/auth/i18n/en.json +2 -0
- package/src/modules/auth/i18n/es.json +2 -0
- package/src/modules/auth/i18n/ko.json +2 -0
- package/src/modules/auth/i18n/pl.json +2 -0
- package/src/modules/communication_channels/i18n/de.json +2 -0
- package/src/modules/communication_channels/i18n/en.json +2 -0
- package/src/modules/communication_channels/i18n/es.json +2 -0
- package/src/modules/communication_channels/i18n/ko.json +2 -0
- package/src/modules/communication_channels/i18n/pl.json +2 -0
- package/src/modules/communication_channels/lib/sanitize-channel-html.ts +23 -3
- package/src/modules/communication_channels/widgets/injection/channel-payload-renderer/widget.client.tsx +44 -12
- package/src/modules/customers/components/calendar/CalendarEventEditor.tsx +16 -2
- package/src/modules/wms/acl.ts +2 -0
- package/src/modules/wms/api/asns/[id]/complete/route.ts +62 -0
- package/src/modules/wms/api/asns/[id]/receive/route.ts +74 -0
- package/src/modules/wms/api/asns/route.ts +200 -0
- package/src/modules/wms/api/inventory/helpers.ts +57 -34
- package/src/modules/wms/api/inventory/receive/route.ts +2 -1
- package/src/modules/wms/api/listEnrichers.ts +38 -0
- package/src/modules/wms/api/putaway-tasks/[id]/assign/route.ts +56 -0
- package/src/modules/wms/api/putaway-tasks/[id]/cancel/route.ts +56 -0
- package/src/modules/wms/api/putaway-tasks/[id]/complete/route.ts +66 -0
- package/src/modules/wms/api/putaway-tasks/[id]/start/route.ts +56 -0
- package/src/modules/wms/api/putaway-tasks/create-from-balance/route.ts +50 -0
- package/src/modules/wms/api/putaway-tasks/route.ts +199 -0
- package/src/modules/wms/api/receiving-lines/route.ts +180 -0
- package/src/modules/wms/api/scan/putaway/route.ts +108 -0
- package/src/modules/wms/api/scan/receive/route.ts +118 -0
- package/src/modules/wms/api/scan/resolve-location/route.ts +92 -0
- package/src/modules/wms/api/scan/resolve-lot/route.ts +92 -0
- package/src/modules/wms/backend/wms/asns/[id]/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/asns/[id]/page.tsx +5 -0
- package/src/modules/wms/backend/wms/asns/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/asns/page.tsx +5 -0
- package/src/modules/wms/backend/wms/putaway/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/putaway/page.tsx +5 -0
- package/src/modules/wms/backend/wms/receiving/page.meta.ts +14 -0
- package/src/modules/wms/backend/wms/receiving/page.tsx +5 -0
- package/src/modules/wms/ce.ts +27 -0
- package/src/modules/wms/commands/asn.ts +2122 -0
- package/src/modules/wms/commands/index.ts +2 -0
- package/src/modules/wms/commands/inventory-actions.ts +413 -243
- package/src/modules/wms/commands/putaway.ts +1169 -0
- package/src/modules/wms/commands/shared.ts +51 -0
- package/src/modules/wms/components/backend/AssignPutawayTaskDialog.tsx +328 -0
- package/src/modules/wms/components/backend/CompletePutawayTaskDialog.tsx +366 -0
- package/src/modules/wms/components/backend/CreateAsnDialog.tsx +427 -0
- package/src/modules/wms/components/backend/InventoryOperationsSection.tsx +20 -2
- package/src/modules/wms/components/backend/ReceiveAsnLineDialog.tsx +535 -0
- package/src/modules/wms/components/backend/ReceiveInventoryDialog.tsx +2 -2
- package/src/modules/wms/components/backend/WmsAsnDetailPage.tsx +647 -0
- package/src/modules/wms/components/backend/WmsAsnsListPage.tsx +407 -0
- package/src/modules/wms/components/backend/WmsLocationDetailPage.tsx +4 -5
- package/src/modules/wms/components/backend/WmsLotDetailPage.tsx +4 -5
- package/src/modules/wms/components/backend/WmsOperationalDashboardPage.tsx +12 -8
- package/src/modules/wms/components/backend/WmsPutawayQueuePage.tsx +677 -0
- package/src/modules/wms/components/backend/WmsSkuDetailPage.tsx +4 -5
- package/src/modules/wms/components/backend/asnCompleteOptimisticLock.ts +52 -0
- package/src/modules/wms/components/backend/asnReceivingLinesLoader.ts +83 -0
- package/src/modules/wms/components/backend/inboundStatusUi.ts +154 -0
- package/src/modules/wms/components/backend/inventoryMutationLoaders.ts +20 -0
- package/src/modules/wms/components/backend/putawayQueueOptimisticLock.ts +20 -0
- package/src/modules/wms/components/backend/useWmsInventoryMutationAccess.ts +4 -0
- package/src/modules/wms/data/enrichers.ts +175 -13
- package/src/modules/wms/data/entities.ts +155 -0
- package/src/modules/wms/data/validators.ts +256 -0
- package/src/modules/wms/events.ts +11 -0
- package/src/modules/wms/extension-points.ts +2 -0
- package/src/modules/wms/i18n/de.json +205 -3
- package/src/modules/wms/i18n/en.json +205 -3
- package/src/modules/wms/i18n/es.json +205 -3
- package/src/modules/wms/i18n/ko.json +205 -3
- package/src/modules/wms/i18n/pl.json +205 -3
- package/src/modules/wms/lib/asnReceiving.ts +226 -0
- package/src/modules/wms/lib/asnVendor.ts +80 -0
- package/src/modules/wms/lib/flashMutationError.ts +4 -0
- package/src/modules/wms/lib/inventoryDisplayUi.ts +46 -0
- package/src/modules/wms/lib/inventoryPolicy.ts +31 -1
- package/src/modules/wms/lib/loadOperationalDashboard.ts +89 -1
- package/src/modules/wms/lib/putaway.ts +210 -0
- package/src/modules/wms/lib/roleFeatures.ts +2 -0
- package/src/modules/wms/lib/salesOrderInventoryAutomation.ts +150 -1
- package/src/modules/wms/lib/scanResolve.ts +185 -0
- package/src/modules/wms/lib/wmsIntegrationToggles.ts +2 -1
- package/src/modules/wms/migrations/.snapshot-open-mercato.json +1000 -0
- package/src/modules/wms/migrations/Migration20260812120000.ts +43 -0
- package/src/modules/wms/migrations/Migration20260812130000.ts +28 -0
- package/src/modules/wms/migrations/Migration20260822120000.ts +17 -0
- package/src/modules/wms/migrations/Migration20260822130000.ts +15 -0
- package/src/modules/wms/migrations/Migration20261029120000.ts +11 -0
- package/src/modules/wms/search.ts +95 -0
- package/src/modules/wms/subscribers/asn-line-received-reevaluate-reservations.ts +21 -0
- package/src/modules/wms/subscribers/invalidate-enricher-cache-asn.ts +12 -0
- package/src/modules/wms/subscribers/procurement-goods-receipt-created.ts +238 -0
- package/src/modules/wms/subscribers/putaway-completed-reevaluate-reservations.ts +21 -0
- package/src/modules/wms/widgets/injection/sales-order-stock-context/widget.client.tsx +63 -13
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { z } from 'zod'
|
|
5
|
+
import { useQueryClient } from '@tanstack/react-query'
|
|
6
|
+
import { flash } from '@open-mercato/ui/backend/FlashMessages'
|
|
7
|
+
import { flashMutationError } from '../../lib/flashMutationError'
|
|
8
|
+
import { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'
|
|
9
|
+
import { ComboboxInput } from '@open-mercato/ui/backend/inputs/ComboboxInput'
|
|
10
|
+
import { apiCall } from '@open-mercato/ui/backend/utils/apiCall'
|
|
11
|
+
import {
|
|
12
|
+
buildOptimisticLockHeader,
|
|
13
|
+
extractOptimisticLockConflict,
|
|
14
|
+
} from '@open-mercato/ui/backend/utils/optimisticLock'
|
|
15
|
+
import { raiseCrudError } from '@open-mercato/ui/backend/utils/serverErrors'
|
|
16
|
+
import { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'
|
|
17
|
+
import { Button } from '@open-mercato/ui/primitives/button'
|
|
18
|
+
import {
|
|
19
|
+
Dialog,
|
|
20
|
+
DialogContent,
|
|
21
|
+
DialogDescription,
|
|
22
|
+
DialogFooter,
|
|
23
|
+
DialogHeader,
|
|
24
|
+
DialogTitle,
|
|
25
|
+
} from '@open-mercato/ui/primitives/dialog'
|
|
26
|
+
import { FormField } from '@open-mercato/ui/primitives/form-field'
|
|
27
|
+
import { Input } from '@open-mercato/ui/primitives/input'
|
|
28
|
+
import { KbdShortcut } from '@open-mercato/ui/primitives/kbd'
|
|
29
|
+
import { useT } from '@open-mercato/shared/lib/i18n/context'
|
|
30
|
+
import {
|
|
31
|
+
loadBinLocationOptions,
|
|
32
|
+
resolveLocationLabel,
|
|
33
|
+
} from './inventoryMutationLoaders'
|
|
34
|
+
import type { WmsInventoryMutationAccess } from './useWmsInventoryMutationAccess'
|
|
35
|
+
|
|
36
|
+
export type PutawayTaskTarget = {
|
|
37
|
+
id: string
|
|
38
|
+
warehouseId: string
|
|
39
|
+
quantity: number
|
|
40
|
+
targetLocationId?: string | null
|
|
41
|
+
catalogVariantId?: string | null
|
|
42
|
+
sourceLocationId?: string | null
|
|
43
|
+
serialNumber?: string | null
|
|
44
|
+
updatedAt?: string | null
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
type CompletePutawayTaskDialogProps = {
|
|
48
|
+
open: boolean
|
|
49
|
+
onOpenChange: (open: boolean) => void
|
|
50
|
+
access: WmsInventoryMutationAccess
|
|
51
|
+
task: PutawayTaskTarget | null
|
|
52
|
+
onSuccess?: () => void
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const formSchema = z.object({
|
|
56
|
+
confirmedQuantity: z.number().positive(),
|
|
57
|
+
targetLocationId: z.string().uuid(),
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
export function CompletePutawayTaskDialog({
|
|
61
|
+
open,
|
|
62
|
+
onOpenChange,
|
|
63
|
+
access,
|
|
64
|
+
task,
|
|
65
|
+
onSuccess,
|
|
66
|
+
}: CompletePutawayTaskDialogProps) {
|
|
67
|
+
const t = useT()
|
|
68
|
+
const queryClient = useQueryClient()
|
|
69
|
+
const { runMutation, retryLastMutation } = useGuardedMutation<{
|
|
70
|
+
retryLastMutation: () => Promise<boolean>
|
|
71
|
+
}>({
|
|
72
|
+
contextId: 'wms-putaway-complete',
|
|
73
|
+
})
|
|
74
|
+
const mutationContext = React.useMemo(
|
|
75
|
+
() => ({ retryLastMutation }),
|
|
76
|
+
[retryLastMutation],
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
const [confirmedQuantity, setConfirmedQuantity] = React.useState(1)
|
|
80
|
+
const [targetLocationId, setTargetLocationId] = React.useState('')
|
|
81
|
+
const [serialConfirmation, setSerialConfirmation] = React.useState('')
|
|
82
|
+
const [fieldErrors, setFieldErrors] = React.useState<Record<string, string>>({})
|
|
83
|
+
const [submitting, setSubmitting] = React.useState(false)
|
|
84
|
+
const [lockUpdatedAt, setLockUpdatedAt] = React.useState<string | null>(null)
|
|
85
|
+
/** Fresh If-Match after 409; ref so guarded retry reads latest without re-seed. */
|
|
86
|
+
const lockUpdatedAtRef = React.useRef<string | null>(null)
|
|
87
|
+
|
|
88
|
+
const closeDialog = React.useCallback(() => {
|
|
89
|
+
if (submitting) return
|
|
90
|
+
onOpenChange(false)
|
|
91
|
+
}, [onOpenChange, submitting])
|
|
92
|
+
|
|
93
|
+
const warehouseId = task?.warehouseId?.trim() || ''
|
|
94
|
+
const expectedSerial = task?.serialNumber?.trim() ?? ''
|
|
95
|
+
|
|
96
|
+
// Stable identity so ComboboxInput's debounced suggestion effect is not torn
|
|
97
|
+
// down on every parent re-render (queue refetch / access churn) — an inline
|
|
98
|
+
// arrow would recreate each render and can starve the fetch, leaving the
|
|
99
|
+
// portaled list stuck on "Loading suggestions…" with no selectable options.
|
|
100
|
+
const loadTargetLocationSuggestions = React.useCallback(
|
|
101
|
+
async (query?: string) => (warehouseId ? loadBinLocationOptions(warehouseId, query) : []),
|
|
102
|
+
[warehouseId],
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
const resolveTargetLocationLabel = React.useCallback(
|
|
106
|
+
async (value: string) => (await resolveLocationLabel(value)) ?? value,
|
|
107
|
+
[],
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
React.useEffect(() => {
|
|
111
|
+
if (!open || !task) return
|
|
112
|
+
setConfirmedQuantity(task.quantity > 0 ? task.quantity : 1)
|
|
113
|
+
setTargetLocationId(task.targetLocationId?.trim() || '')
|
|
114
|
+
setSerialConfirmation('')
|
|
115
|
+
setFieldErrors({})
|
|
116
|
+
setSubmitting(false)
|
|
117
|
+
const seed = task.updatedAt ?? null
|
|
118
|
+
lockUpdatedAtRef.current = seed
|
|
119
|
+
setLockUpdatedAt(seed)
|
|
120
|
+
}, [open, task])
|
|
121
|
+
|
|
122
|
+
const handleSubmit = React.useCallback(
|
|
123
|
+
async (event?: React.FormEvent) => {
|
|
124
|
+
event?.preventDefault()
|
|
125
|
+
if (!task) return
|
|
126
|
+
if (!access.scopeReady || !access.organizationId || !access.tenantId || !access.userId) {
|
|
127
|
+
flash(
|
|
128
|
+
t(
|
|
129
|
+
'wms.backend.inventory.mutations.errors.scope',
|
|
130
|
+
'Select an organization and sign in before posting inventory changes.',
|
|
131
|
+
),
|
|
132
|
+
'error',
|
|
133
|
+
)
|
|
134
|
+
return
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const parsed = formSchema.safeParse({
|
|
138
|
+
confirmedQuantity,
|
|
139
|
+
targetLocationId: targetLocationId.trim(),
|
|
140
|
+
})
|
|
141
|
+
const nextErrors: Record<string, string> = {}
|
|
142
|
+
if (!parsed.success) {
|
|
143
|
+
for (const issue of parsed.error.issues) {
|
|
144
|
+
const key = String(issue.path[0] ?? 'form')
|
|
145
|
+
if (!nextErrors[key]) nextErrors[key] = t(issue.message, issue.message)
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (expectedSerial && serialConfirmation.trim() !== expectedSerial) {
|
|
149
|
+
nextErrors.serialConfirmation = t(
|
|
150
|
+
'wms.backend.putaway.complete.errors.serialMismatch',
|
|
151
|
+
'The scanned serial does not match this task.',
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
if (!parsed.success || nextErrors.serialConfirmation) {
|
|
155
|
+
setFieldErrors(nextErrors)
|
|
156
|
+
return
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
setSubmitting(true)
|
|
160
|
+
setFieldErrors({})
|
|
161
|
+
const payload = {
|
|
162
|
+
organizationId: access.organizationId,
|
|
163
|
+
tenantId: access.tenantId,
|
|
164
|
+
confirmedQuantity: parsed.data.confirmedQuantity,
|
|
165
|
+
targetLocationId: parsed.data.targetLocationId,
|
|
166
|
+
performedBy: access.userId,
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
try {
|
|
170
|
+
let conflictHandled = false
|
|
171
|
+
await runMutation({
|
|
172
|
+
operation: async () => {
|
|
173
|
+
const call = await apiCall<{ ok?: boolean }>(
|
|
174
|
+
`/api/wms/putaway-tasks/${encodeURIComponent(task.id)}/complete`,
|
|
175
|
+
{
|
|
176
|
+
method: 'POST',
|
|
177
|
+
headers: {
|
|
178
|
+
'content-type': 'application/json',
|
|
179
|
+
...buildOptimisticLockHeader(lockUpdatedAtRef.current ?? undefined),
|
|
180
|
+
},
|
|
181
|
+
body: JSON.stringify(payload),
|
|
182
|
+
},
|
|
183
|
+
)
|
|
184
|
+
if (!call.ok) {
|
|
185
|
+
const refreshLockFromConflict = () => {
|
|
186
|
+
const conflict = extractOptimisticLockConflict({
|
|
187
|
+
status: call.status,
|
|
188
|
+
body: call.result,
|
|
189
|
+
})
|
|
190
|
+
if (conflict?.currentUpdatedAt) {
|
|
191
|
+
lockUpdatedAtRef.current = conflict.currentUpdatedAt
|
|
192
|
+
setLockUpdatedAt(conflict.currentUpdatedAt)
|
|
193
|
+
}
|
|
194
|
+
void queryClient.invalidateQueries({ queryKey: ['wms-putaway-queue'] })
|
|
195
|
+
}
|
|
196
|
+
if (
|
|
197
|
+
surfaceRecordConflict({ status: call.status, body: call.result }, t, {
|
|
198
|
+
onRefresh: refreshLockFromConflict,
|
|
199
|
+
})
|
|
200
|
+
) {
|
|
201
|
+
refreshLockFromConflict()
|
|
202
|
+
conflictHandled = true
|
|
203
|
+
return {}
|
|
204
|
+
}
|
|
205
|
+
await raiseCrudError(
|
|
206
|
+
call.response,
|
|
207
|
+
t('wms.backend.putaway.complete.errors.submit', 'Failed to complete putaway task.'),
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
return call.result ?? {}
|
|
211
|
+
},
|
|
212
|
+
context: mutationContext,
|
|
213
|
+
mutationPayload: payload,
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
if (conflictHandled) return
|
|
217
|
+
|
|
218
|
+
flash(t('wms.backend.putaway.complete.flash.success', 'Putaway completed'), 'success')
|
|
219
|
+
await queryClient.invalidateQueries({ queryKey: ['wms-putaway-queue'] })
|
|
220
|
+
closeDialog()
|
|
221
|
+
onSuccess?.()
|
|
222
|
+
} catch (error) {
|
|
223
|
+
flashMutationError(
|
|
224
|
+
error,
|
|
225
|
+
t('wms.backend.putaway.complete.errors.submit', 'Failed to complete putaway task.'),
|
|
226
|
+
t,
|
|
227
|
+
)
|
|
228
|
+
} finally {
|
|
229
|
+
setSubmitting(false)
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
[
|
|
233
|
+
access,
|
|
234
|
+
closeDialog,
|
|
235
|
+
confirmedQuantity,
|
|
236
|
+
expectedSerial,
|
|
237
|
+
lockUpdatedAt,
|
|
238
|
+
serialConfirmation,
|
|
239
|
+
mutationContext,
|
|
240
|
+
onSuccess,
|
|
241
|
+
queryClient,
|
|
242
|
+
runMutation,
|
|
243
|
+
t,
|
|
244
|
+
targetLocationId,
|
|
245
|
+
task,
|
|
246
|
+
],
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
const handleKeyDown = React.useCallback(
|
|
250
|
+
(event: React.KeyboardEvent<HTMLDivElement>) => {
|
|
251
|
+
if (event.key === 'Escape') {
|
|
252
|
+
event.preventDefault()
|
|
253
|
+
closeDialog()
|
|
254
|
+
return
|
|
255
|
+
}
|
|
256
|
+
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
257
|
+
event.preventDefault()
|
|
258
|
+
if (!submitting) void handleSubmit()
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
[closeDialog, handleSubmit, submitting],
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
if (!task) return null
|
|
265
|
+
|
|
266
|
+
return (
|
|
267
|
+
<Dialog open={open} onOpenChange={(next) => (next ? onOpenChange(true) : closeDialog())}>
|
|
268
|
+
<DialogContent className="max-w-lg gap-0 overflow-hidden p-0" onKeyDown={handleKeyDown}>
|
|
269
|
+
<div className="border-b px-6 py-4 pr-12">
|
|
270
|
+
<DialogHeader className="space-y-1 text-left">
|
|
271
|
+
<DialogTitle>
|
|
272
|
+
{t('wms.backend.putaway.complete.dialog.title', 'Complete putaway')}
|
|
273
|
+
</DialogTitle>
|
|
274
|
+
<DialogDescription>
|
|
275
|
+
{t(
|
|
276
|
+
'wms.backend.putaway.complete.dialog.description',
|
|
277
|
+
'Confirm quantity and destination bin to move stock from staging.',
|
|
278
|
+
)}
|
|
279
|
+
</DialogDescription>
|
|
280
|
+
</DialogHeader>
|
|
281
|
+
</div>
|
|
282
|
+
|
|
283
|
+
<form onSubmit={handleSubmit} className="flex min-h-0 flex-1 flex-col">
|
|
284
|
+
<div className="flex flex-col gap-5 overflow-y-auto px-6 py-6">
|
|
285
|
+
{expectedSerial ? (
|
|
286
|
+
<>
|
|
287
|
+
<p className="text-sm text-muted-foreground" data-testid="complete-putaway-expected-serial">
|
|
288
|
+
{t('wms.backend.putaway.complete.form.serial', 'Serial')}: {expectedSerial}
|
|
289
|
+
</p>
|
|
290
|
+
<FormField
|
|
291
|
+
label={t('wms.backend.putaway.complete.form.serialConfirm', 'Confirm serial')}
|
|
292
|
+
required
|
|
293
|
+
disabled={submitting}
|
|
294
|
+
error={fieldErrors.serialConfirmation}
|
|
295
|
+
description={t(
|
|
296
|
+
'wms.backend.putaway.complete.form.serialConfirmHint',
|
|
297
|
+
'Scan or type the serial on the unit. It must match this task.',
|
|
298
|
+
)}
|
|
299
|
+
>
|
|
300
|
+
<Input
|
|
301
|
+
value={serialConfirmation}
|
|
302
|
+
onChange={(event) => setSerialConfirmation(event.target.value)}
|
|
303
|
+
data-testid="complete-putaway-serial"
|
|
304
|
+
/>
|
|
305
|
+
</FormField>
|
|
306
|
+
</>
|
|
307
|
+
) : null}
|
|
308
|
+
<FormField
|
|
309
|
+
label={t('wms.backend.putaway.complete.form.quantity', 'Confirmed quantity')}
|
|
310
|
+
required
|
|
311
|
+
error={fieldErrors.confirmedQuantity}
|
|
312
|
+
>
|
|
313
|
+
<Input
|
|
314
|
+
type="number"
|
|
315
|
+
min={0.0001}
|
|
316
|
+
step="any"
|
|
317
|
+
value={confirmedQuantity}
|
|
318
|
+
onChange={(event) => setConfirmedQuantity(Number(event.target.value))}
|
|
319
|
+
disabled={submitting}
|
|
320
|
+
data-testid="complete-putaway-qty"
|
|
321
|
+
/>
|
|
322
|
+
</FormField>
|
|
323
|
+
|
|
324
|
+
<FormField
|
|
325
|
+
label={t('wms.backend.putaway.complete.form.target', 'Target location')}
|
|
326
|
+
required
|
|
327
|
+
error={fieldErrors.targetLocationId}
|
|
328
|
+
>
|
|
329
|
+
<ComboboxInput
|
|
330
|
+
value={targetLocationId}
|
|
331
|
+
onChange={setTargetLocationId}
|
|
332
|
+
loadSuggestions={loadTargetLocationSuggestions}
|
|
333
|
+
resolveLabel={resolveTargetLocationLabel}
|
|
334
|
+
placeholder={t(
|
|
335
|
+
'wms.backend.putaway.complete.form.targetPlaceholder',
|
|
336
|
+
'Select destination bin',
|
|
337
|
+
)}
|
|
338
|
+
allowCustomValues={false}
|
|
339
|
+
disabled={submitting}
|
|
340
|
+
/>
|
|
341
|
+
</FormField>
|
|
342
|
+
</div>
|
|
343
|
+
|
|
344
|
+
<DialogFooter bordered={false} className="border-t px-6 py-4 sm:justify-between">
|
|
345
|
+
<span className="hidden text-xs text-muted-foreground sm:inline">
|
|
346
|
+
<KbdShortcut keys={['Ctrl/⌘', 'Enter']} />{' '}
|
|
347
|
+
{t('wms.backend.putaway.complete.dialog.shortcutHint', 'to complete')}
|
|
348
|
+
</span>
|
|
349
|
+
<div className="flex gap-2">
|
|
350
|
+
<Button type="button" variant="outline" onClick={closeDialog} disabled={submitting}>
|
|
351
|
+
{t('wms.backend.putaway.complete.dialog.cancel', 'Cancel')}
|
|
352
|
+
</Button>
|
|
353
|
+
<Button
|
|
354
|
+
type="submit"
|
|
355
|
+
disabled={submitting || access.loading || !access.scopeReady}
|
|
356
|
+
data-testid="complete-putaway-submit"
|
|
357
|
+
>
|
|
358
|
+
{t('wms.backend.putaway.complete.dialog.submit', 'Complete putaway')}
|
|
359
|
+
</Button>
|
|
360
|
+
</div>
|
|
361
|
+
</DialogFooter>
|
|
362
|
+
</form>
|
|
363
|
+
</DialogContent>
|
|
364
|
+
</Dialog>
|
|
365
|
+
)
|
|
366
|
+
}
|