@open-mercato/core 0.10.1-develop.7825.1.185c04f3b7 → 0.10.1-develop.7827.1.5c631908e4
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/dist/modules/query_index/lib/engine.js +14 -3
- package/dist/modules/query_index/lib/engine.js.map +2 -2
- package/dist/modules/wms/components/backend/ReleaseReservationDialog.js +33 -19
- package/dist/modules/wms/components/backend/ReleaseReservationDialog.js.map +2 -2
- package/package.json +7 -7
- package/src/modules/query_index/lib/engine.ts +13 -2
- package/src/modules/wms/components/backend/ReleaseReservationDialog.tsx +8 -2
|
@@ -313,25 +313,39 @@ function ReleaseReservationDialog({
|
|
|
313
313
|
) })
|
|
314
314
|
] }),
|
|
315
315
|
/* @__PURE__ */ jsxs(DialogFooter, { bordered: false, className: "border-t px-6 py-4 sm:justify-between", children: [
|
|
316
|
-
/* @__PURE__ */ jsxs(
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
316
|
+
/* @__PURE__ */ jsxs(
|
|
317
|
+
"p",
|
|
318
|
+
{
|
|
319
|
+
className: "hidden text-xs text-muted-foreground sm:inline-flex sm:min-w-0 sm:flex-wrap sm:items-center sm:gap-1.5",
|
|
320
|
+
"data-testid": "wms-inventory-release-shortcut-hint",
|
|
321
|
+
children: [
|
|
322
|
+
/* @__PURE__ */ jsx(KbdShortcut, { keys: ["\u2318", "Enter"] }),
|
|
323
|
+
/* @__PURE__ */ jsx("span", { children: "/" }),
|
|
324
|
+
/* @__PURE__ */ jsx(KbdShortcut, { keys: ["Ctrl", "Enter"] }),
|
|
325
|
+
/* @__PURE__ */ jsx("span", { children: t("wms.backend.inventory.release.dialog.shortcutSave", "to confirm") })
|
|
326
|
+
]
|
|
327
|
+
}
|
|
328
|
+
),
|
|
329
|
+
/* @__PURE__ */ jsxs(
|
|
330
|
+
"div",
|
|
331
|
+
{
|
|
332
|
+
className: "flex w-full flex-col-reverse gap-2 sm:w-auto sm:shrink-0 sm:flex-row",
|
|
333
|
+
"data-testid": "wms-inventory-release-actions",
|
|
334
|
+
children: [
|
|
335
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: closeDialog, disabled: submitting, children: t("common.cancel", "Cancel") }),
|
|
336
|
+
/* @__PURE__ */ jsx(
|
|
337
|
+
Button,
|
|
338
|
+
{
|
|
339
|
+
type: "submit",
|
|
340
|
+
variant: "destructive-solid",
|
|
341
|
+
disabled: submitDisabled,
|
|
342
|
+
"data-testid": "wms-inventory-release-submit",
|
|
343
|
+
children: t("wms.backend.inventory.release.dialog.submit", "Release reservation")
|
|
344
|
+
}
|
|
345
|
+
)
|
|
346
|
+
]
|
|
347
|
+
}
|
|
348
|
+
)
|
|
335
349
|
] })
|
|
336
350
|
] })
|
|
337
351
|
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/modules/wms/components/backend/ReleaseReservationDialog.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { z } from 'zod'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { ShieldOff } from 'lucide-react'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { flashMutationError } from '../../lib/flashMutationError'\nimport { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { raiseCrudError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from '@open-mercato/ui/primitives/dialog'\nimport { FormField } from '@open-mercato/ui/primitives/form-field'\nimport { KbdShortcut } from '@open-mercato/ui/primitives/kbd'\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@open-mercato/ui/primitives/select'\nimport { Textarea } from '@open-mercato/ui/primitives/textarea'\nimport { useLocale, useT } from '@open-mercato/shared/lib/i18n/context'\nimport {\n createInventoryQuantityFormatter,\n formatReservationSourceLabel,\n} from '../../lib/inventoryDisplayUi'\nimport { parseInventoryQuantity } from '../../lib/inventoryMutationUi'\nimport type { WmsInventoryMutationAccess } from './useWmsInventoryMutationAccess'\n\nconst RELEASE_REASON_CODES = ['order_cancelled', 'manual_release', 'correction', 'other'] as const\n\ntype ReleaseReasonCode = (typeof RELEASE_REASON_CODES)[number]\n\ntype ReservationSummary = {\n id: string\n warehouse_name?: string | null\n warehouse_code?: string | null\n variant_name?: string | null\n variant_sku?: string | null\n quantity?: string | number | null\n source_type?: string | null\n source_id?: string | null\n source_label?: string | null\n status?: string | null\n}\n\ntype ReleaseReservationDialogProps = {\n open: boolean\n onOpenChange: (open: boolean) => void\n access: WmsInventoryMutationAccess\n reservation: ReservationSummary | null\n onSuccess?: () => void\n}\n\nfunction formatVariantLabel(\n row: ReservationSummary,\n notAvailableLabel: string,\n): string {\n const name = (row.variant_name ?? '').trim()\n const sku = (row.variant_sku ?? '').trim()\n if (name && sku) return `${name} (${sku})`\n if (name) return name\n if (sku) return sku\n return notAvailableLabel\n}\n\nfunction formatWarehouseLabel(\n row: ReservationSummary,\n notAvailableLabel: string,\n): string {\n return (\n row.warehouse_name?.trim() ||\n row.warehouse_code?.trim() ||\n notAvailableLabel\n )\n}\n\nexport function ReleaseReservationDialog({\n open,\n onOpenChange,\n access,\n reservation,\n onSuccess,\n}: ReleaseReservationDialogProps) {\n const t = useT()\n const locale = useLocale()\n const quantityFormatter = React.useMemo(\n () => createInventoryQuantityFormatter(locale),\n [locale],\n )\n const notAvailableLabel = t('wms.backend.inventory.common.notAvailable', '\u2014')\n const queryClient = useQueryClient()\n const { runMutation, retryLastMutation } = useGuardedMutation<{\n retryLastMutation: () => Promise<boolean>\n }>({\n contextId: 'wms-inventory-release',\n })\n const mutationContext = React.useMemo(\n () => ({ retryLastMutation }),\n [retryLastMutation],\n )\n const releaseFormSchema = React.useMemo(\n () =>\n z.object({\n reasonCode: z.enum(RELEASE_REASON_CODES),\n notes: z.string().trim().max(500).optional(),\n }),\n [],\n )\n const [submitting, setSubmitting] = React.useState(false)\n const [reasonCode, setReasonCode] = React.useState<ReleaseReasonCode | ''>('')\n const [notes, setNotes] = React.useState('')\n const [fieldErrors, setFieldErrors] = React.useState<Record<string, string>>({})\n\n const reasonLabel = React.useCallback(\n (code: ReleaseReasonCode) => {\n const fallbacks: Record<ReleaseReasonCode, string> = {\n order_cancelled: 'Order cancelled',\n manual_release: 'Manual release',\n correction: 'Correction',\n other: 'Other',\n }\n return t(`wms.backend.inventory.release.reasons.${code}`, fallbacks[code])\n },\n [t],\n )\n\n const resetDialog = React.useCallback(() => {\n setReasonCode('')\n setNotes('')\n setFieldErrors({})\n setSubmitting(false)\n }, [])\n\n React.useEffect(() => {\n if (!open || !reservation?.id) return\n setReasonCode('manual_release')\n setNotes('')\n setFieldErrors({})\n setSubmitting(false)\n }, [open, reservation?.id])\n\n const closeDialog = React.useCallback(() => {\n onOpenChange(false)\n resetDialog()\n }, [onOpenChange, resetDialog])\n\n const handleSubmit = React.useCallback(\n async (event?: React.FormEvent) => {\n event?.preventDefault()\n if (!reservation?.id) {\n flash(\n t(\n 'wms.backend.inventory.release.errors.missingReservation',\n 'Reservation context is missing. Close the dialog and try again from the reservations table.',\n ),\n 'error',\n )\n return\n }\n\n const parsed = releaseFormSchema.safeParse({\n reasonCode,\n notes: notes.trim() || undefined,\n })\n if (!parsed.success) {\n const nextErrors: Record<string, string> = {}\n for (const issue of parsed.error.issues) {\n const key = String(issue.path[0] ?? 'form')\n if (!nextErrors[key]) nextErrors[key] = issue.message\n }\n setFieldErrors(nextErrors)\n return\n }\n\n if (!access.scopeReady || !access.organizationId || !access.tenantId) {\n flash(\n t(\n 'wms.backend.inventory.mutations.errors.scope',\n 'Select an organization and sign in before posting inventory changes.',\n ),\n 'error',\n )\n return\n }\n\n setSubmitting(true)\n try {\n const reasonParts = [reasonLabel(parsed.data.reasonCode)]\n if (parsed.data.notes?.trim()) reasonParts.push(parsed.data.notes.trim())\n const payload = {\n organizationId: access.organizationId,\n tenantId: access.tenantId,\n reservationId: reservation.id,\n reason: reasonParts.join(' \u2014 ').slice(0, 120),\n reasonCode: parsed.data.reasonCode,\n }\n\n await runMutation({\n operation: async () => {\n const call = await apiCall<{ ok?: boolean }>('/api/wms/inventory/release', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(payload),\n })\n if (!call.ok) {\n if (call.response.status === 409 && (call.result as { error?: string } | null)?.error === 'balance_integrity_violation') {\n flash(\n t(\n 'wms.backend.inventory.release.errors.balanceIntegrityViolation',\n 'Balance integrity error \u2014 run \"mercato wms verify-balances --repair\" to diagnose and fix drift before retrying.',\n ),\n 'error',\n )\n return {}\n }\n await raiseCrudError(\n call.response,\n t('wms.backend.inventory.release.errors.submit', 'Failed to release reservation.'),\n )\n }\n return call.result ?? {}\n },\n context: mutationContext,\n mutationPayload: payload,\n })\n\n flash(t('wms.backend.inventory.release.flash.success', 'Reservation released'), 'success')\n await queryClient.invalidateQueries({ queryKey: ['wms-inventory-console'] })\n await queryClient.invalidateQueries({ queryKey: ['wms-sku-detail'] })\n await queryClient.invalidateQueries({ queryKey: ['wms-location-detail'] })\n await queryClient.invalidateQueries({ queryKey: ['wms-lot-detail'] })\n closeDialog()\n onSuccess?.()\n } catch (error) {\n flashMutationError(error, t('wms.backend.inventory.release.errors.submit', 'Failed to release reservation.'), t)\n } finally {\n setSubmitting(false)\n }\n },\n [\n access,\n closeDialog,\n mutationContext,\n notes,\n onSuccess,\n queryClient,\n reasonCode,\n reasonLabel,\n releaseFormSchema,\n reservation,\n runMutation,\n t,\n ],\n )\n\n const submitDisabled = submitting || access.loading || !access.scopeReady\n\n const handleDialogKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n event.preventDefault()\n closeDialog()\n return\n }\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {\n event.preventDefault()\n if (!submitDisabled) void handleSubmit()\n }\n },\n [closeDialog, handleSubmit, submitDisabled],\n )\n\n if (!reservation) return null\n\n return (\n <Dialog open={open} onOpenChange={(next) => (next ? onOpenChange(true) : closeDialog())}>\n <DialogContent\n className=\"max-w-lg gap-0 overflow-hidden p-0\"\n onKeyDown={handleDialogKeyDown}\n >\n <div className=\"border-b px-6 py-4 pr-12\">\n <DialogHeader className=\"space-y-1 text-left\">\n <DialogTitle>\n {t('wms.backend.inventory.release.dialog.title', 'Release reservation')}\n </DialogTitle>\n <DialogDescription>\n {t(\n 'wms.backend.inventory.release.dialog.description',\n 'Return reserved quantity to available stock for this bucket.',\n )}\n </DialogDescription>\n </DialogHeader>\n </div>\n\n <form onSubmit={handleSubmit} className=\"flex min-h-0 flex-1 flex-col\">\n <div className=\"flex flex-col gap-5 overflow-y-auto px-6 py-6\">\n <div className=\"rounded-lg border bg-muted/40 px-4 py-3.5\">\n <div className=\"flex items-start gap-3\">\n <ShieldOff className=\"mt-0.5 size-4 text-muted-foreground\" aria-hidden=\"true\" />\n <dl className=\"grid gap-2 text-sm\">\n <div className=\"flex flex-wrap gap-x-2\">\n <dt className=\"text-muted-foreground\">\n {t('wms.backend.inventory.release.summary.variant', 'Variant')}\n </dt>\n <dd className=\"font-medium\">\n {formatVariantLabel(reservation, notAvailableLabel)}\n </dd>\n </div>\n <div className=\"flex flex-wrap gap-x-2\">\n <dt className=\"text-muted-foreground\">\n {t('wms.backend.inventory.release.summary.warehouse', 'Warehouse')}\n </dt>\n <dd className=\"font-medium\">\n {formatWarehouseLabel(reservation, notAvailableLabel)}\n </dd>\n </div>\n <div className=\"flex flex-wrap gap-x-2\">\n <dt className=\"text-muted-foreground\">\n {t('wms.backend.inventory.release.summary.quantity', 'Quantity')}\n </dt>\n <dd className=\"font-medium tabular-nums\">\n {quantityFormatter.format(parseInventoryQuantity(reservation.quantity))}\n </dd>\n </div>\n <div className=\"flex flex-wrap gap-x-2\">\n <dt className=\"text-muted-foreground\">\n {t('wms.backend.inventory.release.summary.source', 'Source')}\n </dt>\n <dd className=\"font-medium\">\n {formatReservationSourceLabel(reservation, t) || notAvailableLabel}\n </dd>\n </div>\n </dl>\n </div>\n </div>\n\n <p className=\"rounded-lg border border-status-warning-border bg-status-warning-bg px-3 py-2.5 text-sm text-status-warning-text\">\n {t(\n 'wms.backend.inventory.release.warning',\n 'This action cannot be undone \u2014 the reserved quantity will be released immediately.',\n )}\n </p>\n\n <FormField\n label={t('wms.backend.inventory.release.form.reason', 'Reason')}\n required\n error={fieldErrors.reasonCode}\n >\n <Select\n value={reasonCode || undefined}\n onValueChange={(next) => {\n setReasonCode(next as ReleaseReasonCode)\n setFieldErrors({})\n }}\n disabled={submitting}\n >\n <SelectTrigger>\n <SelectValue\n placeholder={t(\n 'wms.backend.inventory.release.form.reasonPlaceholder',\n 'Select reason',\n )}\n />\n </SelectTrigger>\n <SelectContent>\n {RELEASE_REASON_CODES.map((code) => (\n <SelectItem key={code} value={code}>\n {reasonLabel(code)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </FormField>\n\n <FormField label={t('wms.backend.inventory.release.form.notes', 'Notes')}>\n <Textarea\n value={notes}\n onChange={(event) => setNotes(event.target.value)}\n placeholder={t(\n 'wms.backend.inventory.release.form.notesPlaceholder',\n 'Optional \u2014 additional context',\n )}\n rows={3}\n disabled={submitting}\n />\n </FormField>\n </div>\n\n <DialogFooter bordered={false} className=\"border-t px-6 py-4 sm:justify-between\">\n <p className=\"hidden text-xs text-muted-foreground sm:inline-flex sm:items-center sm:gap-1.5\">\n <KbdShortcut keys={['\u2318', 'Enter']} />\n <span>/</span>\n <KbdShortcut keys={['Ctrl', 'Enter']} />\n <span>{t('wms.backend.inventory.release.dialog.shortcutSave', 'to confirm')}</span>\n </p>\n <div className=\"flex w-full flex-col-reverse gap-2 sm:w-auto sm:flex-row\">\n <Button type=\"button\" variant=\"outline\" onClick={closeDialog} disabled={submitting}>\n {t('common.cancel', 'Cancel')}\n </Button>\n <Button\n type=\"submit\"\n variant=\"destructive-solid\"\n disabled={submitDisabled}\n data-testid=\"wms-inventory-release-submit\"\n >\n {t('wms.backend.inventory.release.dialog.submit', 'Release reservation')}\n </Button>\n </div>\n </DialogFooter>\n </form>\n </DialogContent>\n </Dialog>\n )\n}\n"],
|
|
5
|
-
"mappings": ";AAmSU,SACE,KADF;AAjSV,YAAY,WAAW;AACvB,SAAS,SAAS;AAClB,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AACnC,SAAS,eAAe;AACxB,SAAS,sBAAsB;AAC/B,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB;AACzB,SAAS,WAAW,YAAY;AAChC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AAGvC,MAAM,uBAAuB,CAAC,mBAAmB,kBAAkB,cAAc,OAAO;AAyBxF,SAAS,mBACP,KACA,mBACQ;AACR,QAAM,QAAQ,IAAI,gBAAgB,IAAI,KAAK;AAC3C,QAAM,OAAO,IAAI,eAAe,IAAI,KAAK;AACzC,MAAI,QAAQ,IAAK,QAAO,GAAG,IAAI,KAAK,GAAG;AACvC,MAAI,KAAM,QAAO;AACjB,MAAI,IAAK,QAAO;AAChB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AAA,4BACA;AAAA,0BACF;AAAA;AAAA,sBACF,GACF;AAAA,sBACA,oBAAC,iBACE,+BAAqB,IAAI,CAAC,SACzB,oBAAC,cAAsB,OAAO,MAC3B,sBAAY,IAAI,KADF,IAEjB,CACD,GACH;AAAA;AAAA;AAAA,gBACF;AAAA;AAAA,YACF;AAAA,YAEA,oBAAC,aAAU,OAAO,EAAE,4CAA4C,OAAO,GACrE;AAAA,cAAC;AAAA;AAAA,gBACC,OAAO;AAAA,gBACP,UAAU,CAAC,UAAU,SAAS,MAAM,OAAO,KAAK;AAAA,gBAChD,aAAa;AAAA,kBACX;AAAA,kBACA;AAAA,gBACF;AAAA,gBACA,MAAM;AAAA,gBACN,UAAU;AAAA;AAAA,YACZ,GACF;AAAA,aACF;AAAA,UAEA,qBAAC,gBAAa,UAAU,OAAO,WAAU,yCACvC;AAAA,
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { z } from 'zod'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { ShieldOff } from 'lucide-react'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { flashMutationError } from '../../lib/flashMutationError'\nimport { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport { raiseCrudError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from '@open-mercato/ui/primitives/dialog'\nimport { FormField } from '@open-mercato/ui/primitives/form-field'\nimport { KbdShortcut } from '@open-mercato/ui/primitives/kbd'\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@open-mercato/ui/primitives/select'\nimport { Textarea } from '@open-mercato/ui/primitives/textarea'\nimport { useLocale, useT } from '@open-mercato/shared/lib/i18n/context'\nimport {\n createInventoryQuantityFormatter,\n formatReservationSourceLabel,\n} from '../../lib/inventoryDisplayUi'\nimport { parseInventoryQuantity } from '../../lib/inventoryMutationUi'\nimport type { WmsInventoryMutationAccess } from './useWmsInventoryMutationAccess'\n\nconst RELEASE_REASON_CODES = ['order_cancelled', 'manual_release', 'correction', 'other'] as const\n\ntype ReleaseReasonCode = (typeof RELEASE_REASON_CODES)[number]\n\ntype ReservationSummary = {\n id: string\n warehouse_name?: string | null\n warehouse_code?: string | null\n variant_name?: string | null\n variant_sku?: string | null\n quantity?: string | number | null\n source_type?: string | null\n source_id?: string | null\n source_label?: string | null\n status?: string | null\n}\n\ntype ReleaseReservationDialogProps = {\n open: boolean\n onOpenChange: (open: boolean) => void\n access: WmsInventoryMutationAccess\n reservation: ReservationSummary | null\n onSuccess?: () => void\n}\n\nfunction formatVariantLabel(\n row: ReservationSummary,\n notAvailableLabel: string,\n): string {\n const name = (row.variant_name ?? '').trim()\n const sku = (row.variant_sku ?? '').trim()\n if (name && sku) return `${name} (${sku})`\n if (name) return name\n if (sku) return sku\n return notAvailableLabel\n}\n\nfunction formatWarehouseLabel(\n row: ReservationSummary,\n notAvailableLabel: string,\n): string {\n return (\n row.warehouse_name?.trim() ||\n row.warehouse_code?.trim() ||\n notAvailableLabel\n )\n}\n\nexport function ReleaseReservationDialog({\n open,\n onOpenChange,\n access,\n reservation,\n onSuccess,\n}: ReleaseReservationDialogProps) {\n const t = useT()\n const locale = useLocale()\n const quantityFormatter = React.useMemo(\n () => createInventoryQuantityFormatter(locale),\n [locale],\n )\n const notAvailableLabel = t('wms.backend.inventory.common.notAvailable', '\u2014')\n const queryClient = useQueryClient()\n const { runMutation, retryLastMutation } = useGuardedMutation<{\n retryLastMutation: () => Promise<boolean>\n }>({\n contextId: 'wms-inventory-release',\n })\n const mutationContext = React.useMemo(\n () => ({ retryLastMutation }),\n [retryLastMutation],\n )\n const releaseFormSchema = React.useMemo(\n () =>\n z.object({\n reasonCode: z.enum(RELEASE_REASON_CODES),\n notes: z.string().trim().max(500).optional(),\n }),\n [],\n )\n const [submitting, setSubmitting] = React.useState(false)\n const [reasonCode, setReasonCode] = React.useState<ReleaseReasonCode | ''>('')\n const [notes, setNotes] = React.useState('')\n const [fieldErrors, setFieldErrors] = React.useState<Record<string, string>>({})\n\n const reasonLabel = React.useCallback(\n (code: ReleaseReasonCode) => {\n const fallbacks: Record<ReleaseReasonCode, string> = {\n order_cancelled: 'Order cancelled',\n manual_release: 'Manual release',\n correction: 'Correction',\n other: 'Other',\n }\n return t(`wms.backend.inventory.release.reasons.${code}`, fallbacks[code])\n },\n [t],\n )\n\n const resetDialog = React.useCallback(() => {\n setReasonCode('')\n setNotes('')\n setFieldErrors({})\n setSubmitting(false)\n }, [])\n\n React.useEffect(() => {\n if (!open || !reservation?.id) return\n setReasonCode('manual_release')\n setNotes('')\n setFieldErrors({})\n setSubmitting(false)\n }, [open, reservation?.id])\n\n const closeDialog = React.useCallback(() => {\n onOpenChange(false)\n resetDialog()\n }, [onOpenChange, resetDialog])\n\n const handleSubmit = React.useCallback(\n async (event?: React.FormEvent) => {\n event?.preventDefault()\n if (!reservation?.id) {\n flash(\n t(\n 'wms.backend.inventory.release.errors.missingReservation',\n 'Reservation context is missing. Close the dialog and try again from the reservations table.',\n ),\n 'error',\n )\n return\n }\n\n const parsed = releaseFormSchema.safeParse({\n reasonCode,\n notes: notes.trim() || undefined,\n })\n if (!parsed.success) {\n const nextErrors: Record<string, string> = {}\n for (const issue of parsed.error.issues) {\n const key = String(issue.path[0] ?? 'form')\n if (!nextErrors[key]) nextErrors[key] = issue.message\n }\n setFieldErrors(nextErrors)\n return\n }\n\n if (!access.scopeReady || !access.organizationId || !access.tenantId) {\n flash(\n t(\n 'wms.backend.inventory.mutations.errors.scope',\n 'Select an organization and sign in before posting inventory changes.',\n ),\n 'error',\n )\n return\n }\n\n setSubmitting(true)\n try {\n const reasonParts = [reasonLabel(parsed.data.reasonCode)]\n if (parsed.data.notes?.trim()) reasonParts.push(parsed.data.notes.trim())\n const payload = {\n organizationId: access.organizationId,\n tenantId: access.tenantId,\n reservationId: reservation.id,\n reason: reasonParts.join(' \u2014 ').slice(0, 120),\n reasonCode: parsed.data.reasonCode,\n }\n\n await runMutation({\n operation: async () => {\n const call = await apiCall<{ ok?: boolean }>('/api/wms/inventory/release', {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(payload),\n })\n if (!call.ok) {\n if (call.response.status === 409 && (call.result as { error?: string } | null)?.error === 'balance_integrity_violation') {\n flash(\n t(\n 'wms.backend.inventory.release.errors.balanceIntegrityViolation',\n 'Balance integrity error \u2014 run \"mercato wms verify-balances --repair\" to diagnose and fix drift before retrying.',\n ),\n 'error',\n )\n return {}\n }\n await raiseCrudError(\n call.response,\n t('wms.backend.inventory.release.errors.submit', 'Failed to release reservation.'),\n )\n }\n return call.result ?? {}\n },\n context: mutationContext,\n mutationPayload: payload,\n })\n\n flash(t('wms.backend.inventory.release.flash.success', 'Reservation released'), 'success')\n await queryClient.invalidateQueries({ queryKey: ['wms-inventory-console'] })\n await queryClient.invalidateQueries({ queryKey: ['wms-sku-detail'] })\n await queryClient.invalidateQueries({ queryKey: ['wms-location-detail'] })\n await queryClient.invalidateQueries({ queryKey: ['wms-lot-detail'] })\n closeDialog()\n onSuccess?.()\n } catch (error) {\n flashMutationError(error, t('wms.backend.inventory.release.errors.submit', 'Failed to release reservation.'), t)\n } finally {\n setSubmitting(false)\n }\n },\n [\n access,\n closeDialog,\n mutationContext,\n notes,\n onSuccess,\n queryClient,\n reasonCode,\n reasonLabel,\n releaseFormSchema,\n reservation,\n runMutation,\n t,\n ],\n )\n\n const submitDisabled = submitting || access.loading || !access.scopeReady\n\n const handleDialogKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (event.key === 'Escape') {\n event.preventDefault()\n closeDialog()\n return\n }\n if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {\n event.preventDefault()\n if (!submitDisabled) void handleSubmit()\n }\n },\n [closeDialog, handleSubmit, submitDisabled],\n )\n\n if (!reservation) return null\n\n return (\n <Dialog open={open} onOpenChange={(next) => (next ? onOpenChange(true) : closeDialog())}>\n <DialogContent\n className=\"max-w-lg gap-0 overflow-hidden p-0\"\n onKeyDown={handleDialogKeyDown}\n >\n <div className=\"border-b px-6 py-4 pr-12\">\n <DialogHeader className=\"space-y-1 text-left\">\n <DialogTitle>\n {t('wms.backend.inventory.release.dialog.title', 'Release reservation')}\n </DialogTitle>\n <DialogDescription>\n {t(\n 'wms.backend.inventory.release.dialog.description',\n 'Return reserved quantity to available stock for this bucket.',\n )}\n </DialogDescription>\n </DialogHeader>\n </div>\n\n <form onSubmit={handleSubmit} className=\"flex min-h-0 flex-1 flex-col\">\n <div className=\"flex flex-col gap-5 overflow-y-auto px-6 py-6\">\n <div className=\"rounded-lg border bg-muted/40 px-4 py-3.5\">\n <div className=\"flex items-start gap-3\">\n <ShieldOff className=\"mt-0.5 size-4 text-muted-foreground\" aria-hidden=\"true\" />\n <dl className=\"grid gap-2 text-sm\">\n <div className=\"flex flex-wrap gap-x-2\">\n <dt className=\"text-muted-foreground\">\n {t('wms.backend.inventory.release.summary.variant', 'Variant')}\n </dt>\n <dd className=\"font-medium\">\n {formatVariantLabel(reservation, notAvailableLabel)}\n </dd>\n </div>\n <div className=\"flex flex-wrap gap-x-2\">\n <dt className=\"text-muted-foreground\">\n {t('wms.backend.inventory.release.summary.warehouse', 'Warehouse')}\n </dt>\n <dd className=\"font-medium\">\n {formatWarehouseLabel(reservation, notAvailableLabel)}\n </dd>\n </div>\n <div className=\"flex flex-wrap gap-x-2\">\n <dt className=\"text-muted-foreground\">\n {t('wms.backend.inventory.release.summary.quantity', 'Quantity')}\n </dt>\n <dd className=\"font-medium tabular-nums\">\n {quantityFormatter.format(parseInventoryQuantity(reservation.quantity))}\n </dd>\n </div>\n <div className=\"flex flex-wrap gap-x-2\">\n <dt className=\"text-muted-foreground\">\n {t('wms.backend.inventory.release.summary.source', 'Source')}\n </dt>\n <dd className=\"font-medium\">\n {formatReservationSourceLabel(reservation, t) || notAvailableLabel}\n </dd>\n </div>\n </dl>\n </div>\n </div>\n\n <p className=\"rounded-lg border border-status-warning-border bg-status-warning-bg px-3 py-2.5 text-sm text-status-warning-text\">\n {t(\n 'wms.backend.inventory.release.warning',\n 'This action cannot be undone \u2014 the reserved quantity will be released immediately.',\n )}\n </p>\n\n <FormField\n label={t('wms.backend.inventory.release.form.reason', 'Reason')}\n required\n error={fieldErrors.reasonCode}\n >\n <Select\n value={reasonCode || undefined}\n onValueChange={(next) => {\n setReasonCode(next as ReleaseReasonCode)\n setFieldErrors({})\n }}\n disabled={submitting}\n >\n <SelectTrigger>\n <SelectValue\n placeholder={t(\n 'wms.backend.inventory.release.form.reasonPlaceholder',\n 'Select reason',\n )}\n />\n </SelectTrigger>\n <SelectContent>\n {RELEASE_REASON_CODES.map((code) => (\n <SelectItem key={code} value={code}>\n {reasonLabel(code)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </FormField>\n\n <FormField label={t('wms.backend.inventory.release.form.notes', 'Notes')}>\n <Textarea\n value={notes}\n onChange={(event) => setNotes(event.target.value)}\n placeholder={t(\n 'wms.backend.inventory.release.form.notesPlaceholder',\n 'Optional \u2014 additional context',\n )}\n rows={3}\n disabled={submitting}\n />\n </FormField>\n </div>\n\n <DialogFooter bordered={false} className=\"border-t px-6 py-4 sm:justify-between\">\n <p\n className=\"hidden text-xs text-muted-foreground sm:inline-flex sm:min-w-0 sm:flex-wrap sm:items-center sm:gap-1.5\"\n data-testid=\"wms-inventory-release-shortcut-hint\"\n >\n <KbdShortcut keys={['\u2318', 'Enter']} />\n <span>/</span>\n <KbdShortcut keys={['Ctrl', 'Enter']} />\n <span>{t('wms.backend.inventory.release.dialog.shortcutSave', 'to confirm')}</span>\n </p>\n <div\n className=\"flex w-full flex-col-reverse gap-2 sm:w-auto sm:shrink-0 sm:flex-row\"\n data-testid=\"wms-inventory-release-actions\"\n >\n <Button type=\"button\" variant=\"outline\" onClick={closeDialog} disabled={submitting}>\n {t('common.cancel', 'Cancel')}\n </Button>\n <Button\n type=\"submit\"\n variant=\"destructive-solid\"\n disabled={submitDisabled}\n data-testid=\"wms-inventory-release-submit\"\n >\n {t('wms.backend.inventory.release.dialog.submit', 'Release reservation')}\n </Button>\n </div>\n </DialogFooter>\n </form>\n </DialogContent>\n </Dialog>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAmSU,SACE,KADF;AAjSV,YAAY,WAAW;AACvB,SAAS,SAAS;AAClB,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AACnC,SAAS,eAAe;AACxB,SAAS,sBAAsB;AAC/B,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB;AACzB,SAAS,WAAW,YAAY;AAChC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,8BAA8B;AAGvC,MAAM,uBAAuB,CAAC,mBAAmB,kBAAkB,cAAc,OAAO;AAyBxF,SAAS,mBACP,KACA,mBACQ;AACR,QAAM,QAAQ,IAAI,gBAAgB,IAAI,KAAK;AAC3C,QAAM,OAAO,IAAI,eAAe,IAAI,KAAK;AACzC,MAAI,QAAQ,IAAK,QAAO,GAAG,IAAI,KAAK,GAAG;AACvC,MAAI,KAAM,QAAO;AACjB,MAAI,IAAK,QAAO;AAChB,SAAO;AACT;AAEA,SAAS,qBACP,KACA,mBACQ;AACR,SACE,IAAI,gBAAgB,KAAK,KACzB,IAAI,gBAAgB,KAAK,KACzB;AAEJ;AAEO,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;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0.10.1-develop.7827.1.5c631908e4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -266,16 +266,16 @@
|
|
|
266
266
|
"zod": "^4.6.6"
|
|
267
267
|
},
|
|
268
268
|
"peerDependencies": {
|
|
269
|
-
"@open-mercato/ai-assistant": "0.10.1-develop.
|
|
270
|
-
"@open-mercato/shared": "0.10.1-develop.
|
|
271
|
-
"@open-mercato/ui": "0.10.1-develop.
|
|
269
|
+
"@open-mercato/ai-assistant": "0.10.1-develop.7827.1.5c631908e4",
|
|
270
|
+
"@open-mercato/shared": "0.10.1-develop.7827.1.5c631908e4",
|
|
271
|
+
"@open-mercato/ui": "0.10.1-develop.7827.1.5c631908e4",
|
|
272
272
|
"react": "^19.0.0",
|
|
273
273
|
"react-dom": "^19.0.0"
|
|
274
274
|
},
|
|
275
275
|
"devDependencies": {
|
|
276
|
-
"@open-mercato/ai-assistant": "0.10.1-develop.
|
|
277
|
-
"@open-mercato/shared": "0.10.1-develop.
|
|
278
|
-
"@open-mercato/ui": "0.10.1-develop.
|
|
276
|
+
"@open-mercato/ai-assistant": "0.10.1-develop.7827.1.5c631908e4",
|
|
277
|
+
"@open-mercato/shared": "0.10.1-develop.7827.1.5c631908e4",
|
|
278
|
+
"@open-mercato/ui": "0.10.1-develop.7827.1.5c631908e4",
|
|
279
279
|
"@testing-library/dom": "^10.4.1",
|
|
280
280
|
"@testing-library/jest-dom": "^7.0.1",
|
|
281
281
|
"@testing-library/react": "^16.3.3",
|
|
@@ -58,7 +58,7 @@ import {
|
|
|
58
58
|
import { tokenizeText } from '@open-mercato/shared/lib/search/tokenize'
|
|
59
59
|
import { buildContainmentPatterns } from '@open-mercato/shared/lib/search/containment'
|
|
60
60
|
import { runBeforeQueryPipeline, runAfterQueryPipeline, type QueryExtensionContext } from '@open-mercato/shared/lib/query/query-extension-runner'
|
|
61
|
-
import { warnOnCiphertextLikeFallback } from '@open-mercato/shared/lib/query/ciphertext-search-warning'
|
|
61
|
+
import { warnOnCiphertextLikeFallback, type CiphertextSearchWarning } from '@open-mercato/shared/lib/query/ciphertext-search-warning'
|
|
62
62
|
import {
|
|
63
63
|
matchEncryptedSortFields,
|
|
64
64
|
resolveEncryptedFieldNames,
|
|
@@ -452,12 +452,17 @@ export class HybridQueryEngine implements QueryEngine {
|
|
|
452
452
|
const applyAfterExtensions = async <R>(queryResult: QueryResult<R>): Promise<QueryResult<R>> => {
|
|
453
453
|
if (!ext || !hybridExtCtx) return queryResult
|
|
454
454
|
const diCtx = ext.resolve ? { resolve: ext.resolve } : noopDi
|
|
455
|
-
|
|
455
|
+
const ciphertextSearchWarnings = queryResult.meta?.ciphertextSearchWarnings
|
|
456
|
+
const result = await runAfterQueryPipeline(
|
|
456
457
|
queryResult as QueryResult<Record<string, unknown>>,
|
|
457
458
|
opts,
|
|
458
459
|
hybridExtCtx,
|
|
459
460
|
diCtx,
|
|
460
461
|
) as QueryResult<R>
|
|
462
|
+
if (ciphertextSearchWarnings?.length) {
|
|
463
|
+
result.meta = { ...result.meta, ciphertextSearchWarnings }
|
|
464
|
+
}
|
|
465
|
+
return result
|
|
461
466
|
}
|
|
462
467
|
|
|
463
468
|
try {
|
|
@@ -727,6 +732,7 @@ export class HybridQueryEngine implements QueryEngine {
|
|
|
727
732
|
searchRuntime.encryptedFields = null
|
|
728
733
|
}
|
|
729
734
|
}
|
|
735
|
+
const ciphertextSearchWarnings: CiphertextSearchWarning[] = []
|
|
730
736
|
if (searchFilters.length) {
|
|
731
737
|
this.logSearchDebug('search:init', {
|
|
732
738
|
entity,
|
|
@@ -768,6 +774,7 @@ export class HybridQueryEngine implements QueryEngine {
|
|
|
768
774
|
? 'no-indexable-tokens'
|
|
769
775
|
: searchConfig.enabled ? 'no-search-tokens' : 'search-disabled',
|
|
770
776
|
service: this.getEncryptionService(),
|
|
777
|
+
onDiagnostic: (warning) => ciphertextSearchWarnings.push(warning),
|
|
771
778
|
})
|
|
772
779
|
}
|
|
773
780
|
}
|
|
@@ -791,6 +798,7 @@ export class HybridQueryEngine implements QueryEngine {
|
|
|
791
798
|
? 'no-indexable-tokens'
|
|
792
799
|
: searchConfig.enabled ? 'no-search-tokens' : 'search-disabled',
|
|
793
800
|
service: this.getEncryptionService(),
|
|
801
|
+
onDiagnostic: (warning) => ciphertextSearchWarnings.push(warning),
|
|
794
802
|
})
|
|
795
803
|
}
|
|
796
804
|
const hasNonBaseSearchSource = searchSources.some(
|
|
@@ -1597,6 +1605,9 @@ export class HybridQueryEngine implements QueryEngine {
|
|
|
1597
1605
|
}
|
|
1598
1606
|
|
|
1599
1607
|
result = await applyAfterExtensions(result)
|
|
1608
|
+
if (ciphertextSearchWarnings.length) {
|
|
1609
|
+
result.meta = { ...result.meta, ciphertextSearchWarnings }
|
|
1610
|
+
}
|
|
1600
1611
|
finishProfile({
|
|
1601
1612
|
result: 'ok', total, page, pageSize,
|
|
1602
1613
|
itemCount: Array.isArray(items) ? items.length : undefined,
|
|
@@ -397,13 +397,19 @@ export function ReleaseReservationDialog({
|
|
|
397
397
|
</div>
|
|
398
398
|
|
|
399
399
|
<DialogFooter bordered={false} className="border-t px-6 py-4 sm:justify-between">
|
|
400
|
-
<p
|
|
400
|
+
<p
|
|
401
|
+
className="hidden text-xs text-muted-foreground sm:inline-flex sm:min-w-0 sm:flex-wrap sm:items-center sm:gap-1.5"
|
|
402
|
+
data-testid="wms-inventory-release-shortcut-hint"
|
|
403
|
+
>
|
|
401
404
|
<KbdShortcut keys={['⌘', 'Enter']} />
|
|
402
405
|
<span>/</span>
|
|
403
406
|
<KbdShortcut keys={['Ctrl', 'Enter']} />
|
|
404
407
|
<span>{t('wms.backend.inventory.release.dialog.shortcutSave', 'to confirm')}</span>
|
|
405
408
|
</p>
|
|
406
|
-
<div
|
|
409
|
+
<div
|
|
410
|
+
className="flex w-full flex-col-reverse gap-2 sm:w-auto sm:shrink-0 sm:flex-row"
|
|
411
|
+
data-testid="wms-inventory-release-actions"
|
|
412
|
+
>
|
|
407
413
|
<Button type="button" variant="outline" onClick={closeDialog} disabled={submitting}>
|
|
408
414
|
{t('common.cancel', 'Cancel')}
|
|
409
415
|
</Button>
|