@open-mercato/core 0.11.1-develop.8557.1.e615240a3e → 0.11.1-develop.8567.1.a167594505
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 +1 -1
- package/dist/modules/api_keys/di.js +6 -2
- package/dist/modules/api_keys/di.js.map +2 -2
- package/dist/modules/api_keys/services/oneTimeIssuerService.js +47 -0
- package/dist/modules/api_keys/services/oneTimeIssuerService.js.map +7 -0
- package/dist/modules/audit_logs/di.js +2 -1
- package/dist/modules/audit_logs/di.js.map +2 -2
- package/dist/modules/audit_logs/services/actionLogService.js +65 -1
- package/dist/modules/audit_logs/services/actionLogService.js.map +2 -2
- package/dist/modules/auth/cli.js +1 -0
- package/dist/modules/auth/cli.js.map +2 -2
- package/dist/modules/auth/commands/users.js +10 -2
- package/dist/modules/auth/commands/users.js.map +2 -2
- package/dist/modules/auth/lib/setup-app.js +19 -5
- package/dist/modules/auth/lib/setup-app.js.map +2 -2
- package/dist/modules/configs/cli.js +26 -29
- package/dist/modules/configs/cli.js.map +2 -2
- package/dist/modules/configs/di.js +3 -1
- package/dist/modules/configs/di.js.map +2 -2
- package/dist/modules/configs/lib/instance-config-initializer.js +44 -0
- package/dist/modules/configs/lib/instance-config-initializer.js.map +7 -0
- package/dist/modules/configs/lib/instance-defaults.js +204 -0
- package/dist/modules/configs/lib/instance-defaults.js.map +7 -0
- package/dist/modules/configs/lib/module-config-service.js +115 -1
- package/dist/modules/configs/lib/module-config-service.js.map +2 -2
- package/dist/modules/entities/api/definitions.batch.js +55 -25
- package/dist/modules/entities/api/definitions.batch.js.map +2 -2
- package/dist/modules/entities/api/definitions.js +35 -8
- package/dist/modules/entities/api/definitions.js.map +2 -2
- package/dist/modules/entities/backend/entities/user/[entityId]/page.js +14 -8
- package/dist/modules/entities/backend/entities/user/[entityId]/page.js.map +2 -2
- package/dist/modules/notifications/lib/deliveryConfig.js +19 -12
- package/dist/modules/notifications/lib/deliveryConfig.js.map +2 -2
- package/dist/modules/notifications/setup.js +10 -0
- package/dist/modules/notifications/setup.js.map +2 -2
- package/dist/modules/translations/components/TranslationManager.js +47 -10
- package/dist/modules/translations/components/TranslationManager.js.map +2 -2
- package/dist/modules/wms/components/backend/CompletePutawayTaskDialog.js +8 -1
- package/dist/modules/wms/components/backend/CompletePutawayTaskDialog.js.map +2 -2
- package/dist/modules/workflows/ai-tools/authoring-pack.js +1 -1
- package/dist/modules/workflows/ai-tools/authoring-pack.js.map +2 -2
- package/dist/modules/workflows/api/instances/[id]/advance/route.js +1 -0
- package/dist/modules/workflows/api/instances/[id]/advance/route.js.map +2 -2
- package/dist/modules/workflows/api/instances/route.js +1 -1
- package/dist/modules/workflows/api/instances/route.js.map +2 -2
- package/dist/modules/workflows/api/instances/validate-start/route.js +3 -1
- package/dist/modules/workflows/api/instances/validate-start/route.js.map +2 -2
- package/dist/modules/workflows/di.js +3 -1
- package/dist/modules/workflows/di.js.map +2 -2
- package/dist/modules/workflows/lib/activity-executor.js +35 -7
- package/dist/modules/workflows/lib/activity-executor.js.map +2 -2
- package/dist/modules/workflows/lib/condition-handler.js +1 -1
- package/dist/modules/workflows/lib/condition-handler.js.map +2 -2
- package/dist/modules/workflows/lib/error-handler.js +1 -1
- package/dist/modules/workflows/lib/error-handler.js.map +2 -2
- package/dist/modules/workflows/lib/event-trigger-service.js +1 -1
- package/dist/modules/workflows/lib/event-trigger-service.js.map +2 -2
- package/dist/modules/workflows/lib/example-definition-authoring.js +90 -0
- package/dist/modules/workflows/lib/example-definition-authoring.js.map +7 -0
- package/dist/modules/workflows/lib/named-rules.js +42 -0
- package/dist/modules/workflows/lib/named-rules.js.map +7 -0
- package/dist/modules/workflows/lib/owned-definition.js +2 -0
- package/dist/modules/workflows/lib/owned-definition.js.map +2 -2
- package/dist/modules/workflows/lib/parallel-handler.js +1 -1
- package/dist/modules/workflows/lib/parallel-handler.js.map +2 -2
- package/dist/modules/workflows/lib/signal-handler.js +1 -0
- package/dist/modules/workflows/lib/signal-handler.js.map +2 -2
- package/dist/modules/workflows/lib/start-validator.js +87 -85
- package/dist/modules/workflows/lib/start-validator.js.map +2 -2
- package/dist/modules/workflows/lib/step-handler.js +1 -1
- package/dist/modules/workflows/lib/step-handler.js.map +2 -2
- package/dist/modules/workflows/lib/task-handler.js +1 -0
- package/dist/modules/workflows/lib/task-handler.js.map +2 -2
- package/dist/modules/workflows/lib/timer-handler.js +1 -0
- package/dist/modules/workflows/lib/timer-handler.js.map +2 -2
- package/dist/modules/workflows/lib/transition-handler.js +48 -166
- package/dist/modules/workflows/lib/transition-handler.js.map +3 -3
- package/dist/modules/workflows/lib/workflow-executor.js +3 -2
- package/dist/modules/workflows/lib/workflow-executor.js.map +2 -2
- package/package.json +8 -8
- package/src/modules/api_keys/di.ts +7 -2
- package/src/modules/api_keys/services/oneTimeIssuerService.ts +61 -0
- package/src/modules/audit_logs/di.ts +1 -0
- package/src/modules/audit_logs/services/actionLogService.ts +132 -1
- package/src/modules/auth/cli.ts +1 -0
- package/src/modules/auth/commands/users.ts +10 -2
- 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/auth/lib/setup-app.ts +30 -7
- package/src/modules/configs/cli.ts +39 -37
- package/src/modules/configs/di.ts +2 -0
- package/src/modules/configs/lib/instance-config-initializer.ts +56 -0
- package/src/modules/configs/lib/instance-defaults.ts +262 -0
- package/src/modules/configs/lib/module-config-service.ts +156 -0
- package/src/modules/entities/api/definitions.batch.ts +65 -27
- package/src/modules/entities/api/definitions.ts +40 -11
- package/src/modules/entities/backend/entities/user/[entityId]/page.tsx +14 -7
- package/src/modules/notifications/lib/deliveryConfig.ts +20 -11
- package/src/modules/notifications/setup.ts +11 -0
- package/src/modules/translations/components/TranslationManager.tsx +49 -10
- package/src/modules/translations/i18n/de.json +1 -0
- package/src/modules/translations/i18n/en.json +1 -0
- package/src/modules/translations/i18n/es.json +1 -0
- package/src/modules/translations/i18n/ko.json +1 -0
- package/src/modules/translations/i18n/pl.json +1 -0
- package/src/modules/wms/components/backend/CompletePutawayTaskDialog.tsx +8 -1
- package/src/modules/wms/i18n/de.json +1 -0
- package/src/modules/wms/i18n/en.json +1 -0
- package/src/modules/wms/i18n/es.json +1 -0
- package/src/modules/wms/i18n/ko.json +1 -0
- package/src/modules/wms/i18n/pl.json +1 -0
- package/src/modules/workflows/ai-tools/authoring-pack.ts +3 -1
- package/src/modules/workflows/api/instances/[id]/advance/route.ts +1 -0
- package/src/modules/workflows/api/instances/route.ts +1 -1
- package/src/modules/workflows/api/instances/validate-start/route.ts +3 -1
- package/src/modules/workflows/di.ts +2 -0
- package/src/modules/workflows/lib/activity-executor.ts +48 -30
- package/src/modules/workflows/lib/condition-handler.ts +1 -1
- package/src/modules/workflows/lib/error-handler.ts +1 -1
- package/src/modules/workflows/lib/event-trigger-service.ts +1 -1
- package/src/modules/workflows/lib/example-definition-authoring.ts +114 -0
- package/src/modules/workflows/lib/named-rules.ts +54 -0
- package/src/modules/workflows/lib/owned-definition.ts +4 -1
- package/src/modules/workflows/lib/parallel-handler.ts +1 -1
- package/src/modules/workflows/lib/signal-handler.ts +1 -0
- package/src/modules/workflows/lib/start-validator.ts +96 -94
- package/src/modules/workflows/lib/step-handler.ts +1 -1
- package/src/modules/workflows/lib/task-handler.ts +1 -0
- package/src/modules/workflows/lib/timer-handler.ts +1 -0
- package/src/modules/workflows/lib/transition-handler.ts +74 -238
- package/src/modules/workflows/lib/workflow-executor.ts +7 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/translations/components/TranslationManager.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { Badge } from '@open-mercato/ui/primitives/badge'\nimport { Tabs, TabsList, TabsTrigger } from '@open-mercato/ui/primitives/tabs'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Textarea } from '@open-mercato/ui/primitives/textarea'\nimport { ComboboxInput } from '@open-mercato/ui/backend/inputs'\nimport { LoadingMessage, ErrorMessage } from '@open-mercato/ui/backend/detail'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { apiCall, readApiResultOrThrow, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'\nimport { raiseCrudError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'\nimport { useCustomFieldDefs } from '@open-mercato/ui/backend/utils/customFieldDefs'\nimport { Save, Plus, X } from 'lucide-react'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { defaultLocale, locales as defaultLocales } from '@open-mercato/shared/lib/i18n/config'\nimport { ISO_639_1, isValidIso639, getIso639Label } from '@open-mercato/shared/lib/i18n/iso639'\nimport { formatEntityLabel, buildEntityListUrl, getRecordLabel, resolveBaseValue } from '../lib/helpers'\nimport { resolveFieldList } from '../lib/resolve-field-list'\nimport type { ResolvedField } from '../lib/resolve-field-list'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('translations').child({ component: 'TranslationManager' })\n\nconst TRANSLATION_MUTATION_CONTEXT_ID = 'translations.entity-translations'\nconst SUPPORTED_LOCALES_MUTATION_CONTEXT_ID = 'translations.supported-locales'\n\ntype TranslationManagerProps = {\n entityType?: string\n recordId?: string\n baseValues?: Record<string, unknown>\n translatableFields?: string[]\n mode?: 'standalone' | 'embedded'\n compact?: boolean\n}\n\ntype EntityOption = { entityId: string; label?: string; source?: string }\n\ntype TranslationsResponse = {\n entityType: string\n entityId: string\n translations: Record<string, Record<string, unknown>>\n createdAt?: string\n updatedAt?: string\n}\n\ntype TranslationLocales = {\n /** The tenant's stored selection: which locales content can be translated into. */\n locales: string[]\n /** Which of those the admin UI itself can be rendered in. Resolved on the server. */\n servable: string[]\n}\n\nfunction useTranslationLocales() {\n return useQuery<TranslationLocales>({\n queryKey: ['translation-locales'],\n queryFn: async () => {\n const res = await apiCall<TranslationLocales>('/api/translations/locales')\n const fallback = { locales: [...defaultLocales], servable: [...defaultLocales] }\n if (!res.ok) return fallback\n const locales = Array.isArray(res.result?.locales) && res.result.locales.length > 0\n ? res.result.locales\n : [...defaultLocales]\n const servable = Array.isArray(res.result?.servable) && res.result.servable.length > 0\n ? res.result.servable\n : [...defaultLocales]\n return { locales, servable }\n },\n staleTime: 60_000,\n })\n}\n\nexport function TranslationManager({\n entityType: propEntityType,\n recordId: propRecordId,\n baseValues: propBaseValues,\n translatableFields: propTranslatableFields,\n mode = 'standalone',\n compact = false,\n}: TranslationManagerProps) {\n const t = useT()\n const scopeVersion = useOrganizationScopeVersion()\n const isEmbedded = mode === 'embedded'\n\n const [selectedEntityType, setSelectedEntityType] = React.useState(propEntityType ?? '')\n const [selectedRecordId, setSelectedRecordId] = React.useState(propRecordId ?? '')\n const [activeLocale, setActiveLocale] = React.useState('')\n const [editedTranslations, setEditedTranslations] = React.useState<Record<string, Record<string, string>>>({})\n const editedTranslationsRef = React.useRef<Record<string, Record<string, string>>>({})\n const [hasUserEdited, setHasUserEdited] = React.useState(false)\n const hasUserEditedRef = React.useRef(false)\n const saveInFlightRef = React.useRef(false)\n\n const entityType = isEmbedded ? (propEntityType ?? '') : selectedEntityType\n const recordId = isEmbedded ? (propRecordId ?? '') : selectedRecordId\n\n const { data: localeData } = useTranslationLocales()\n // Memoized: `locales` feeds effect dependency lists below, and a fresh array\n // on every render while the query is still loading would re-fire them.\n const locales = React.useMemo(() => localeData?.locales ?? [...defaultLocales], [localeData])\n\n React.useEffect(() => {\n if (locales.length > 0 && (!activeLocale || !locales.includes(activeLocale))) {\n setActiveLocale(locales[0])\n }\n }, [locales, activeLocale])\n\n React.useEffect(() => {\n if (isEmbedded && propEntityType) setSelectedEntityType(propEntityType)\n }, [isEmbedded, propEntityType])\n\n React.useEffect(() => {\n if (isEmbedded && propRecordId) setSelectedRecordId(propRecordId)\n }, [isEmbedded, propRecordId])\n\n const { data: entities, isLoading: loadingEntities, error: entitiesError } = useQuery<{ items: EntityOption[] }>({\n queryKey: ['entities-list', scopeVersion],\n enabled: !isEmbedded,\n queryFn: async () =>\n readApiResultOrThrow('/api/entities/entities', undefined, {\n errorMessage: t('translations.manager.errors.loadEntities', 'Failed to load entities'),\n }),\n })\n\n const entitySuggestions = React.useMemo(\n () =>\n (entities?.items || []).map((item) => ({\n value: item.entityId,\n label: formatEntityLabel(item.entityId, item.label),\n description: item.entityId,\n })),\n [entities],\n )\n\n const resolveEntityLabel = React.useCallback(\n (value: string) => {\n const match = entities?.items?.find((e) => e.entityId === value)\n return match ? formatEntityLabel(match.entityId, match.label) : formatEntityLabel(value)\n },\n [entities],\n )\n\n const listUrl = React.useMemo(() => entityType ? buildEntityListUrl(entityType) : null, [entityType])\n\n const loadRecordSuggestions = React.useCallback(\n async (query?: string) => {\n if (!entityType || !listUrl) return []\n const url = `${listUrl}?pageSize=20${query ? `&search=${encodeURIComponent(query)}` : ''}`\n const res = await apiCall<{ items: Array<Record<string, unknown>> }>(url)\n if (!res.ok) return []\n const items = res.result?.items ?? []\n return items.map((item) => ({\n value: String(item.id ?? ''),\n label: getRecordLabel(item),\n }))\n },\n [entityType, listUrl],\n )\n\n const { data: recordData } = useQuery<Record<string, unknown> | null>({\n queryKey: ['translation-record-data', entityType, recordId, listUrl, scopeVersion],\n enabled: !isEmbedded && !!entityType && !!recordId && !!listUrl,\n queryFn: async () => {\n const res = await apiCall<{ items: Array<Record<string, unknown>> }>(\n // Some APIs filter by `id` (catalog), others by `ids` (resources) \u2014 send both so the one recognized by the target route's buildFilters is applied\n `${listUrl}?id=${encodeURIComponent(recordId)}&ids=${encodeURIComponent(recordId)}&pageSize=1`,\n )\n if (!res.ok) return null\n const items = res.result?.items\n return Array.isArray(items) && items.length > 0 ? items[0] : null\n },\n })\n\n const baseValues = isEmbedded ? (propBaseValues ?? {}) : (recordData ?? {})\n\n const resolveRecordLabel = React.useCallback(\n (value: string) => {\n if (recordData) return getRecordLabel(recordData)\n return value\n },\n [recordData],\n )\n\n const { data: fieldDefs = [], isLoading: loadingFieldDefs } = useCustomFieldDefs(entityType ? [entityType] : [], {\n enabled: !!entityType,\n })\n\n const fieldList = React.useMemo(\n () => resolveFieldList(entityType, propTranslatableFields, fieldDefs as Array<{ key: string; kind: string; label?: string }>, baseValues),\n [entityType, propTranslatableFields, fieldDefs, baseValues],\n )\n\n const {\n data: translationData,\n isLoading: loadingTranslation,\n isError: translationError,\n refetch: refetchTranslation,\n } = useQuery<TranslationsResponse | null>({\n queryKey: ['entity-translation', entityType, recordId, scopeVersion],\n enabled: !!entityType && !!recordId,\n queryFn: async () => {\n const res = await apiCall<TranslationsResponse>(\n `/api/translations/${encodeURIComponent(entityType)}/${encodeURIComponent(recordId)}`,\n )\n if (!res.ok) {\n if (res.response?.status === 404) return null\n throw new Error(t('translations.manager.errors.loadTranslation', 'Failed to load translations'))\n }\n return res.result ?? null\n },\n })\n\n // Optimistic lock keys off the TRANSLATION ROW'S OWN version (`updatedAt` from\n // the GET response), not the host entity's: the host's EAV `entityType`\n // (`module:entity`) has no reliable server-side mapping to a registered\n // optimistic-lock reader, so the route enforces against the translation row's\n // own `updated_at`. `null` for a brand-new translation (no existing row \u2192 the\n // header is omitted and the route enforces nothing on insert).\n const translationRowUpdatedAt = React.useMemo(() => {\n const value = translationData?.updatedAt\n return typeof value === 'string' && value.trim().length > 0 ? value : null\n }, [translationData])\n\n const translationSignature = React.useMemo(() => JSON.stringify(translationData ?? null), [translationData])\n const lastTranslationSignatureRef = React.useRef<string | null>(null)\n\n React.useEffect(() => {\n const sig = translationSignature\n if (sig === lastTranslationSignatureRef.current && hasUserEditedRef.current) return\n lastTranslationSignatureRef.current = sig\n\n if (!translationData?.translations) {\n if (!hasUserEditedRef.current) {\n editedTranslationsRef.current = {}\n setEditedTranslations({})\n }\n return\n }\n\n const parsed: Record<string, Record<string, string>> = {}\n for (const [locale, fields] of Object.entries(translationData.translations)) {\n if (!fields || typeof fields !== 'object') continue\n parsed[locale] = {}\n for (const [key, val] of Object.entries(fields)) {\n parsed[locale][key] = typeof val === 'string' ? val : ''\n }\n }\n if (!hasUserEditedRef.current) {\n editedTranslationsRef.current = parsed\n setEditedTranslations(parsed)\n }\n }, [translationSignature, translationData])\n\n const { runMutation, retryLastMutation } = useGuardedMutation<{\n formId: string\n entityType: string\n recordId: string\n resourceKind: string\n resourceId: string\n data: TranslationsResponse | null\n retryLastMutation: () => Promise<boolean>\n }>({ contextId: TRANSLATION_MUTATION_CONTEXT_ID })\n\n const mutation = useMutation({\n mutationFn: async () => {\n if (!entityType || !recordId) {\n throw new Error(t('translations.manager.errors.selectRecord', 'Select an entity and record before saving'))\n }\n const body: Record<string, Record<string, string | null>> = {}\n for (const [locale, fields] of Object.entries(editedTranslationsRef.current)) {\n const localeFields: Record<string, string | null> = {}\n let hasValues = false\n for (const [key, val] of Object.entries(fields)) {\n if (val && val.trim().length > 0) {\n localeFields[key] = val.trim()\n hasValues = true\n }\n }\n if (hasValues) body[locale] = localeFields\n }\n if (Object.keys(body).length === 0) {\n logger.warn('Save skipped: payload is empty \u2014 no locale contains any non-empty field')\n throw new Error(t('translations.manager.errors.nothingToSave', 'Nothing to save \u2014 enter a translation first'))\n }\n return runMutation({\n operation: async () => {\n const res = await withScopedApiRequestHeaders(\n buildOptimisticLockHeader(translationRowUpdatedAt),\n () => apiCall(\n `/api/translations/${encodeURIComponent(entityType)}/${encodeURIComponent(recordId)}`,\n {\n method: 'PUT',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(body),\n },\n ),\n )\n if (!res.ok) {\n await raiseCrudError(res.response, t('translations.manager.errors.save', 'Failed to save translations'))\n }\n return true\n },\n context: {\n formId: TRANSLATION_MUTATION_CONTEXT_ID,\n entityType,\n recordId,\n resourceKind: 'translation',\n resourceId: recordId,\n data: translationData ?? null,\n retryLastMutation,\n },\n mutationPayload: body,\n })\n },\n onSuccess: async () => {\n flash(t('translations.manager.flash.saved', 'Translations saved'), 'success')\n hasUserEditedRef.current = false\n setHasUserEdited(false)\n await refetchTranslation()\n },\n onError: (err: unknown) => {\n if (surfaceRecordConflict(err, t)) return\n const message = err instanceof Error ? err.message : t('translations.manager.errors.save', 'Failed to save translations')\n flash(message, 'error')\n },\n })\n\n const saveTranslations = React.useCallback(() => {\n if (saveInFlightRef.current || !hasUserEditedRef.current || !entityType || !recordId || loadingTranslation || translationError) return\n saveInFlightRef.current = true\n mutation.mutate(undefined, {\n onSettled: () => { saveInFlightRef.current = false },\n })\n }, [entityType, recordId, loadingTranslation, translationError, mutation])\n\n const updateFieldValue = (locale: string, fieldKey: string, value: string) => {\n hasUserEditedRef.current = true\n setHasUserEdited(true)\n const next = {\n ...editedTranslationsRef.current,\n [locale]: {\n ...editedTranslationsRef.current[locale],\n [fieldKey]: value,\n },\n }\n editedTranslationsRef.current = next\n setEditedTranslations(next)\n }\n\n const getBaseValue = (fieldKey: string): string => resolveBaseValue(baseValues, fieldKey)\n\n const renderRecordPicker = () => {\n if (isEmbedded) return null\n\n return (\n <div className=\"space-y-2\">\n <label className=\"text-xs text-muted-foreground\">\n {t('translations.manager.selectRecord', 'Select record')}\n </label>\n <ComboboxInput\n value={selectedRecordId}\n onChange={(next) => {\n setSelectedRecordId(next)\n hasUserEditedRef.current = false\n setHasUserEdited(false)\n }}\n placeholder={t('translations.manager.searchRecords', 'Search records...')}\n loadSuggestions={loadRecordSuggestions}\n resolveLabel={resolveRecordLabel}\n allowCustomValues\n disabled={!entityType}\n />\n </div>\n )\n }\n\n const renderLocaleTabs = () => (\n <Tabs variant=\"underline\" value={activeLocale} onValueChange={setActiveLocale}>\n <TabsList>\n {locales.map((locale) => (\n <TabsTrigger key={locale} value={locale}>\n {locale.toUpperCase()}\n </TabsTrigger>\n ))}\n </TabsList>\n </Tabs>\n )\n\n const renderFieldTable = () => {\n if (!entityType || !recordId) {\n return (\n <div className=\"rounded border bg-background/80 p-4 text-sm text-muted-foreground\">\n {t('translations.manager.selectFirst', 'Select an entity and record to manage translations.')}\n </div>\n )\n }\n if (loadingTranslation || loadingFieldDefs) {\n return (\n <LoadingMessage\n label={t('translations.manager.loadingTranslations', 'Loading translations...')}\n className=\"border-0 bg-transparent p-4\"\n />\n )\n }\n if (translationError) {\n return (\n <ErrorMessage\n label={t('translations.manager.errors.loadTranslation', 'Failed to load translations')}\n action={(\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={() => void refetchTranslation()}>\n {t('translations.manager.actions.retry', 'Retry')}\n </Button>\n )}\n />\n )\n }\n if (!fieldList.length) {\n return (\n <div className=\"rounded border bg-background/80 p-4 text-sm text-muted-foreground\">\n {t('translations.manager.noFields', 'No translatable fields found for this entity type.')}\n </div>\n )\n }\n\n const localeTranslations = editedTranslations[activeLocale] ?? {}\n const translationLabel = `${t('translations.manager.fields.translation', 'Translation')} (${activeLocale.toUpperCase()})`\n\n return (\n <div className=\"min-w-0\">\n <table className=\"block w-full table-fixed text-sm sm:table\">\n <thead className=\"sr-only sm:not-sr-only sm:table-header-group\">\n <tr className=\"text-xs uppercase tracking-wide text-muted-foreground\">\n <th className=\"w-1/4 px-3 py-2 text-left\">\n {t('translations.manager.fields.field', 'Field')}\n </th>\n {!compact && (\n <th className=\"px-3 py-2 text-left\">\n {t('translations.manager.fields.baseValue', 'Base value')}\n </th>\n )}\n <th className=\"w-1/2 px-3 py-2 text-left\">\n {translationLabel}\n </th>\n </tr>\n </thead>\n <tbody className=\"block sm:table-row-group\">\n {fieldList.map((field) => {\n const baseVal = field.baseValue ?? getBaseValue(field.key)\n const translatedVal = localeTranslations[field.key] ?? ''\n const isPropertyTranslation = entityType === 'entities:custom_field_def' || entityType === 'dictionaries:dictionary_entry'\n const fieldLabel = isPropertyTranslation && field.key === 'label'\n ? t('translations.manager.fields.label', 'Label')\n : isPropertyTranslation && field.key === 'description'\n ? t('translations.manager.fields.description', 'Description')\n : field.label\n const inputLabel = `${fieldLabel} \u2014 ${translationLabel}`\n\n return (\n <tr key={field.key} className=\"block border-t py-2 sm:table-row sm:py-0\">\n <td className=\"block break-words px-3 py-1 text-xs font-medium text-muted-foreground sm:table-cell sm:py-2 sm:align-top\">\n {fieldLabel}\n </td>\n {!compact && (\n <td className=\"block break-words px-3 py-1 text-xs text-muted-foreground sm:table-cell sm:py-2 sm:align-top\">\n {baseVal ? (\n <span className=\"line-clamp-3\">{baseVal}</span>\n ) : (\n <span className=\"text-muted-foreground/50\">-</span>\n )}\n </td>\n )}\n <td className=\"block px-3 py-1 sm:table-cell sm:py-2 sm:align-top\">\n {field.multiline ? (\n <Textarea\n aria-label={inputLabel}\n rows={3}\n value={translatedVal}\n onChange={(e) => updateFieldValue(activeLocale, field.key, e.target.value)}\n placeholder={baseVal || field.label}\n />\n ) : (\n <Input\n aria-label={inputLabel}\n value={translatedVal}\n onChange={(e) => updateFieldValue(activeLocale, field.key, e.target.value)}\n placeholder={baseVal || field.label}\n />\n )}\n </td>\n </tr>\n )\n })}\n </tbody>\n </table>\n </div>\n )\n }\n\n React.useEffect(() => {\n const handler = (e: KeyboardEvent) => {\n if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {\n e.preventDefault()\n saveTranslations()\n }\n }\n document.addEventListener('keydown', handler)\n return () => document.removeEventListener('keydown', handler)\n }, [saveTranslations])\n\n if (compact) {\n return (\n <div className=\"space-y-3\">\n {renderLocaleTabs()}\n {renderFieldTable()}\n <div className=\"flex justify-end\">\n <Button\n type=\"button\"\n size=\"sm\"\n onClick={saveTranslations}\n disabled={!hasUserEdited || mutation.isPending || loadingTranslation || translationError || !entityType || !recordId}\n data-testid=\"translations-save\"\n >\n <Save className=\"mr-2 h-3 w-3\" />\n {mutation.isPending\n ? t('translations.manager.actions.saving', 'Saving...')\n : t('translations.manager.actions.save', 'Save translations')}\n </Button>\n </div>\n </div>\n )\n }\n\n return (\n <div className=\"space-y-6\">\n <div className=\"flex flex-col gap-3 rounded-lg border bg-card p-4 shadow-sm\">\n <div className=\"space-y-2\">\n <h2 className=\"text-xl font-semibold\">{t('translations.manager.title', 'Translations')}</h2>\n <p className=\"text-sm text-muted-foreground\">\n {t('translations.manager.description', 'Manage translations for entity records across supported locales.')}\n </p>\n </div>\n\n {!isEmbedded && (\n <div className=\"flex flex-col gap-4 sm:flex-row sm:items-start\">\n <div className=\"flex-1 space-y-3\">\n <div>\n <label className=\"text-xs text-muted-foreground\">\n {t('translations.manager.selectEntity', 'Choose entity')}\n </label>\n <div className=\"mt-1\">\n <ComboboxInput\n value={selectedEntityType}\n onChange={(next) => {\n setSelectedEntityType(next)\n setSelectedRecordId('')\n hasUserEditedRef.current = false\n setHasUserEdited(false)\n }}\n placeholder={t('translations.manager.placeholder', 'Select an entity')}\n suggestions={entitySuggestions}\n resolveLabel={resolveEntityLabel}\n disabled={loadingEntities || !!entitiesError}\n />\n </div>\n {entitiesError && (\n <p className=\"mt-1 text-xs text-destructive\">\n {t('translations.manager.errors.loadEntities', 'Failed to load entities')}\n </p>\n )}\n </div>\n {renderRecordPicker()}\n </div>\n </div>\n )}\n\n <div className=\"rounded-lg border bg-background/80 p-4\">\n {renderLocaleTabs()}\n <div className=\"mt-3\">\n {renderFieldTable()}\n </div>\n </div>\n\n <div className=\"flex justify-end\">\n <Button\n type=\"button\"\n onClick={saveTranslations}\n disabled={!hasUserEdited || mutation.isPending || loadingTranslation || translationError || loadingEntities || !!entitiesError || !entityType || !recordId}\n data-testid=\"translations-save\"\n >\n <Save className=\"mr-2 h-4 w-4\" />\n {mutation.isPending\n ? t('translations.manager.actions.saving', 'Saving...')\n : t('translations.manager.actions.save', 'Save translations')}\n </Button>\n </div>\n </div>\n </div>\n )\n}\n\nexport function LocaleManager() {\n const t = useT()\n const queryClient = useQueryClient()\n const { data: localeData, isLoading } = useTranslationLocales()\n const locales = React.useMemo(() => localeData?.locales ?? [], [localeData])\n const servable = React.useMemo(() => localeData?.servable ?? [], [localeData])\n const [newLocale, setNewLocale] = React.useState('')\n\n const { runMutation, retryLastMutation } = useGuardedMutation<{\n formId: string\n resourceKind: string\n retryLastMutation: () => Promise<boolean>\n }>({ contextId: SUPPORTED_LOCALES_MUTATION_CONTEXT_ID })\n\n const mutation = useMutation({\n mutationFn: async (updatedLocales: string[]) => {\n // optimistic-lock-exempt: single-row tenant supported-locales settings list \u2014 no per-record version / concurrent record edit\n return runMutation({\n operation: async () => {\n const res = await apiCall<{ locales: string[] }>('/api/translations/locales', {\n method: 'PUT',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ locales: updatedLocales }),\n })\n if (!res.ok) throw new Error('Failed to save locales')\n return res.result?.locales ?? updatedLocales\n },\n context: {\n formId: SUPPORTED_LOCALES_MUTATION_CONTEXT_ID,\n resourceKind: 'translation-locales',\n retryLastMutation,\n },\n mutationPayload: { locales: updatedLocales },\n })\n },\n onSuccess: (result) => {\n // The PUT response carries the stored selection only, so `servable` has to\n // come from the cached entry. With no entry to read, defaulting it to `[]`\n // would mark every chip \"Content only\" \u2014 including the shipped locales \u2014\n // which is the one answer that is definitely wrong. Refetch instead.\n const previous = queryClient.getQueryData<TranslationLocales>(['translation-locales'])\n if (previous) {\n queryClient.setQueryData<TranslationLocales>(['translation-locales'], { ...previous, locales: result })\n } else {\n void queryClient.invalidateQueries({ queryKey: ['translation-locales'] })\n }\n flash(t('translations.locales.flash.saved', 'Locales updated'), 'success')\n },\n onError: () => {\n flash(t('translations.locales.flash.error', 'Failed to update locales'), 'error')\n },\n })\n\n // A locale the app has no dictionary for can be translated into, but the admin\n // UI can never be shown in it \u2014 `resolveSupportedLocalesForRequest` intersects\n // the selection with what the app serves. Saying so at the point of action is\n // what keeps the successful-looking add honest.\n const contentOnlyLabel = t('translations.locales.contentOnly', 'Content only')\n const isServable = React.useCallback(\n (code: string) => servable.includes(code.toLowerCase()),\n [servable],\n )\n\n const availableLocales = React.useMemo(\n () => ISO_639_1.filter((entry) => !locales.includes(entry.code)).map((entry) => ({\n value: entry.code,\n label: isServable(entry.code)\n ? `${entry.code.toUpperCase()} \u2014 ${entry.label}`\n : `${entry.code.toUpperCase()} \u2014 ${entry.label} (${contentOnlyLabel})`,\n })),\n [locales, isServable, contentOnlyLabel],\n )\n\n // `resolveSupportedLocalesForRequest` keeps `defaultLocale` in the served set\n // whatever the stored selection says, so a tenant whose saved list omits it\n // still gets it in the language switcher. Rendering the raw selection here\n // would leave this screen and the switcher disagreeing about what is served.\n const chips = React.useMemo(\n () => (locales.includes(defaultLocale) ? locales : [defaultLocale, ...locales]),\n [locales],\n )\n\n const addLocale = () => {\n const code = newLocale.toLowerCase().trim()\n if (!code || !isValidIso639(code) || locales.includes(code)) return\n mutation.mutate([...locales, code])\n setNewLocale('')\n }\n\n const removeLocale = (locale: string) => {\n if (locales.length <= 1) return\n // The default locale stays servable whatever the selection says\n // (`resolveSupportedLocalesForRequest` re-adds it), so letting it be removed\n // here would leave the chip list claiming something untrue.\n if (locale === defaultLocale) return\n mutation.mutate(locales.filter((l) => l !== locale))\n }\n\n if (isLoading) {\n return <LoadingMessage label={t('translations.locales.loading', 'Loading locales...')} className=\"border-0 bg-transparent p-4\" />\n }\n\n return (\n <div className=\"flex flex-col gap-3 rounded-lg border bg-card p-4 shadow-sm\">\n <div className=\"space-y-1\">\n <h3 className=\"text-lg font-semibold\">{t('translations.locales.title', 'Supported locales')}</h3>\n <p className=\"text-sm text-muted-foreground\">\n {t('translations.locales.description', 'Which languages content can be translated into. A language the application ships an interface for is also offered in the admin language switcher; the rest are available for content only.')}\n </p>\n </div>\n\n <div className=\"flex flex-wrap gap-2\">\n {chips.map((locale) => {\n const localeLabel = getIso639Label(locale) ?? locale.toUpperCase()\n const isDefault = locale === defaultLocale\n const isStored = locales.includes(locale)\n const removeLabel = t('translations.locales.remove', 'Remove {{locale}}', { locale: localeLabel })\n const defaultLabel = t(\n 'translations.locales.alwaysServed',\n '{{locale}} is the default language and is always served, so it cannot be removed.',\n { locale: localeLabel },\n )\n return (\n <span\n key={locale}\n className=\"inline-flex items-center gap-1.5 rounded-full border bg-muted/50 px-3 py-1 text-sm font-medium\"\n title={isStored ? (getIso639Label(locale) ?? locale) : defaultLabel}\n >\n {locale.toUpperCase()}{getIso639Label(locale) ? ` \u2014 ${getIso639Label(locale)}` : ''}\n {!isServable(locale) && (\n <Badge variant=\"outline\" size=\"sm\" title={t('translations.locales.contentOnlyHint', 'The application ships no interface for this language, so it is available for content translations only.')}>\n {contentOnlyLabel}\n </Badge>\n )}\n {isStored && locales.length > 1 && (\n <IconButton\n variant=\"ghost\"\n size=\"xs\"\n fullRadius\n aria-label={isDefault ? defaultLabel : removeLabel}\n title={isDefault ? defaultLabel : removeLabel}\n onClick={() => removeLocale(locale)}\n disabled={mutation.isPending || isDefault}\n >\n <X className=\"h-3 w-3\" />\n </IconButton>\n )}\n </span>\n )\n })}\n </div>\n\n <div className=\"flex gap-2 items-center\">\n <div className=\"max-w-[240px] flex-1\">\n <ComboboxInput\n value={newLocale}\n onChange={setNewLocale}\n placeholder={t('translations.locales.addPlaceholder', 'e.g. fr, it, ja...')}\n suggestions={availableLocales}\n resolveLabel={(value) => {\n const label = getIso639Label(value)\n const base = label ? `${value.toUpperCase()} \u2014 ${label}` : value.toUpperCase()\n return isServable(value) ? base : `${base} (${contentOnlyLabel})`\n }}\n />\n </div>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={addLocale}\n disabled={mutation.isPending || !newLocale.trim() || !isValidIso639(newLocale) || locales.includes(newLocale.toLowerCase().trim())}\n >\n <Plus className=\"mr-1 h-3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AQ;AAAA,gBACR,MAAK;AAAA,gBACL,YAAU;AAAA,gBACV,cAAY,YAAY,eAAe;AAAA,gBACvC,OAAO,YAAY,eAAe;AAAA,gBAClC,SAAS,MAAM,aAAa,MAAM;AAAA,gBAClC,UAAU,SAAS,aAAa;AAAA,gBAEhC,8BAAC,KAAE,WAAU,WAAU;AAAA;AAAA,YACzB;AAAA;AAAA;AAAA,QArBG;AAAA,MAuBP;AAAA,IAEJ,CAAC,GACH;AAAA,IAEA,qBAAC,SAAI,WAAU,2BACb;AAAA,0BAAC,SAAI,WAAU,wBACb;AAAA,QAAC;AAAA;AAAA,UACC,OAAO;AAAA,UACP,UAAU;AAAA,UACV,aAAa,EAAE,uCAAuC,oBAAoB;AAAA,UAC1E,aAAa;AAAA,UACb,cAAc,CAAC,UAAU;AACvB,kBAAM,QAAQ,eAAe,KAAK;AAClC,kBAAM,OAAO,QAAQ,GAAG,MAAM,YAAY,CAAC,WAAM,KAAK,KAAK,MAAM,YAAY;AAC7E,mBAAO,WAAW,KAAK,IAAI,OAAO,GAAG,IAAI,KAAK,gBAAgB;AAAA,UAChE;AAAA;AAAA,MACF,GACF;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,SAAS;AAAA,UACT,UAAU,SAAS,aAAa,CAAC,UAAU,KAAK,KAAK,CAAC,cAAc,SAAS,KAAK,QAAQ,SAAS,UAAU,YAAY,EAAE,KAAK,CAAC;AAAA,UAEjI;AAAA,gCAAC,QAAK,WAAU,gBAAe;AAAA,YAC9B,EAAE,4BAA4B,KAAK;AAAA;AAAA;AAAA,MACtC;AAAA,OACF;AAAA,KACF;AAEJ;",
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { IconButton } from '@open-mercato/ui/primitives/icon-button'\nimport { Badge } from '@open-mercato/ui/primitives/badge'\nimport { Tabs, TabsList, TabsTrigger } from '@open-mercato/ui/primitives/tabs'\nimport { Input } from '@open-mercato/ui/primitives/input'\nimport { Textarea } from '@open-mercato/ui/primitives/textarea'\nimport { ComboboxInput } from '@open-mercato/ui/backend/inputs'\nimport { LoadingMessage, ErrorMessage } from '@open-mercato/ui/backend/detail'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { apiCall, readApiResultOrThrow, withScopedApiRequestHeaders } from '@open-mercato/ui/backend/utils/apiCall'\nimport { buildOptimisticLockHeader } from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'\nimport { raiseCrudError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'\nimport { useCustomFieldDefs } from '@open-mercato/ui/backend/utils/customFieldDefs'\nimport { Save, Plus, X } from 'lucide-react'\nimport { parseSelectedOrganizationCookie, parseSelectedTenantCookie } from '@open-mercato/core/modules/directory/utils/scopeCookies'\nimport { readRequestOrganizationScope } from '@open-mercato/shared/lib/frontend/organizationEvents'\nimport { useOrganizationScopeVersion } from '@open-mercato/shared/lib/frontend/useOrganizationScope'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { defaultLocale, locales as defaultLocales } from '@open-mercato/shared/lib/i18n/config'\nimport { ISO_639_1, isValidIso639, getIso639Label } from '@open-mercato/shared/lib/i18n/iso639'\nimport { formatEntityLabel, buildEntityListUrl, getRecordLabel, resolveBaseValue } from '../lib/helpers'\nimport { resolveFieldList } from '../lib/resolve-field-list'\nimport type { ResolvedField } from '../lib/resolve-field-list'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\n\nconst logger = createLogger('translations').child({ component: 'TranslationManager' })\n\nconst TRANSLATION_MUTATION_CONTEXT_ID = 'translations.entity-translations'\nconst SUPPORTED_LOCALES_MUTATION_CONTEXT_ID = 'translations.supported-locales'\n\ntype TranslationManagerProps = {\n entityType?: string\n recordId?: string\n baseValues?: Record<string, unknown>\n translatableFields?: string[]\n mode?: 'standalone' | 'embedded'\n compact?: boolean\n}\n\ntype EntityOption = { entityId: string; label?: string; source?: string }\n\ntype TranslationsResponse = {\n entityType: string\n entityId: string\n translations: Record<string, Record<string, unknown>>\n createdAt?: string\n updatedAt?: string\n}\n\ntype TranslationLocales = {\n /** The tenant's stored selection: which locales content can be translated into. */\n locales: string[]\n /** Which of those the admin UI itself can be rendered in. Resolved on the server. */\n servable: string[]\n}\n\nfunction readTranslationRequestScopeKey(): string {\n const cookies = typeof document === 'undefined' ? null : document.cookie\n return JSON.stringify([\n parseSelectedTenantCookie(cookies),\n parseSelectedOrganizationCookie(cookies),\n readRequestOrganizationScope() !== null,\n ])\n}\n\nfunction useTranslationLocales() {\n return useQuery<TranslationLocales>({\n queryKey: ['translation-locales'],\n queryFn: async () => {\n const res = await apiCall<TranslationLocales>('/api/translations/locales')\n const fallback = { locales: [...defaultLocales], servable: [...defaultLocales] }\n if (!res.ok) return fallback\n const locales = Array.isArray(res.result?.locales) && res.result.locales.length > 0\n ? res.result.locales\n : [...defaultLocales]\n const servable = Array.isArray(res.result?.servable) && res.result.servable.length > 0\n ? res.result.servable\n : [...defaultLocales]\n return { locales, servable }\n },\n staleTime: 60_000,\n })\n}\n\nexport function TranslationManager({\n entityType: propEntityType,\n recordId: propRecordId,\n baseValues: propBaseValues,\n translatableFields: propTranslatableFields,\n mode = 'standalone',\n compact = false,\n}: TranslationManagerProps) {\n const t = useT()\n const scopeVersion = useOrganizationScopeVersion()\n const isEmbedded = mode === 'embedded'\n const [openedScopeKey] = React.useState(readTranslationRequestScopeKey)\n const hasEditorScopeChanged = () => isEmbedded && readTranslationRequestScopeKey() !== openedScopeKey\n const scopeChangedMessage = t(\n 'translations.manager.errors.organizationChanged',\n 'The organization selection changed. Close and reopen the translation editor to continue.',\n )\n const assertEditorScope = () => {\n if (hasEditorScopeChanged()) throw new Error(scopeChangedMessage)\n }\n\n const [selectedEntityType, setSelectedEntityType] = React.useState(propEntityType ?? '')\n const [selectedRecordId, setSelectedRecordId] = React.useState(propRecordId ?? '')\n const [activeLocale, setActiveLocale] = React.useState('')\n const [editedTranslations, setEditedTranslations] = React.useState<Record<string, Record<string, string>>>({})\n const editedTranslationsRef = React.useRef<Record<string, Record<string, string>>>({})\n const [hasUserEdited, setHasUserEdited] = React.useState(false)\n const hasUserEditedRef = React.useRef(false)\n const saveInFlightRef = React.useRef(false)\n\n const entityType = isEmbedded ? (propEntityType ?? '') : selectedEntityType\n const recordId = isEmbedded ? (propRecordId ?? '') : selectedRecordId\n\n const { data: localeData } = useTranslationLocales()\n // Memoized: `locales` feeds effect dependency lists below, and a fresh array\n // on every render while the query is still loading would re-fire them.\n const locales = React.useMemo(() => localeData?.locales ?? [...defaultLocales], [localeData])\n\n React.useEffect(() => {\n if (locales.length > 0 && (!activeLocale || !locales.includes(activeLocale))) {\n setActiveLocale(locales[0])\n }\n }, [locales, activeLocale])\n\n React.useEffect(() => {\n if (isEmbedded && propEntityType) setSelectedEntityType(propEntityType)\n }, [isEmbedded, propEntityType])\n\n React.useEffect(() => {\n if (isEmbedded && propRecordId) setSelectedRecordId(propRecordId)\n }, [isEmbedded, propRecordId])\n\n const { data: entities, isLoading: loadingEntities, error: entitiesError } = useQuery<{ items: EntityOption[] }>({\n queryKey: ['entities-list', scopeVersion],\n enabled: !isEmbedded,\n queryFn: async () =>\n readApiResultOrThrow('/api/entities/entities', undefined, {\n errorMessage: t('translations.manager.errors.loadEntities', 'Failed to load entities'),\n }),\n })\n\n const entitySuggestions = React.useMemo(\n () =>\n (entities?.items || []).map((item) => ({\n value: item.entityId,\n label: formatEntityLabel(item.entityId, item.label),\n description: item.entityId,\n })),\n [entities],\n )\n\n const resolveEntityLabel = React.useCallback(\n (value: string) => {\n const match = entities?.items?.find((e) => e.entityId === value)\n return match ? formatEntityLabel(match.entityId, match.label) : formatEntityLabel(value)\n },\n [entities],\n )\n\n const listUrl = React.useMemo(() => entityType ? buildEntityListUrl(entityType) : null, [entityType])\n\n const loadRecordSuggestions = React.useCallback(\n async (query?: string) => {\n if (!entityType || !listUrl) return []\n const url = `${listUrl}?pageSize=20${query ? `&search=${encodeURIComponent(query)}` : ''}`\n const res = await apiCall<{ items: Array<Record<string, unknown>> }>(url)\n if (!res.ok) return []\n const items = res.result?.items ?? []\n return items.map((item) => ({\n value: String(item.id ?? ''),\n label: getRecordLabel(item),\n }))\n },\n [entityType, listUrl],\n )\n\n const { data: recordData } = useQuery<Record<string, unknown> | null>({\n queryKey: ['translation-record-data', entityType, recordId, listUrl, scopeVersion],\n enabled: !isEmbedded && !!entityType && !!recordId && !!listUrl,\n queryFn: async () => {\n const res = await apiCall<{ items: Array<Record<string, unknown>> }>(\n // Some APIs filter by `id` (catalog), others by `ids` (resources) \u2014 send both so the one recognized by the target route's buildFilters is applied\n `${listUrl}?id=${encodeURIComponent(recordId)}&ids=${encodeURIComponent(recordId)}&pageSize=1`,\n )\n if (!res.ok) return null\n const items = res.result?.items\n return Array.isArray(items) && items.length > 0 ? items[0] : null\n },\n })\n\n const baseValues = isEmbedded ? (propBaseValues ?? {}) : (recordData ?? {})\n\n const resolveRecordLabel = React.useCallback(\n (value: string) => {\n if (recordData) return getRecordLabel(recordData)\n return value\n },\n [recordData],\n )\n\n const { data: fieldDefs = [], isLoading: loadingFieldDefs } = useCustomFieldDefs(entityType ? [entityType] : [], {\n enabled: !!entityType,\n })\n\n const fieldList = React.useMemo(\n () => resolveFieldList(entityType, propTranslatableFields, fieldDefs as Array<{ key: string; kind: string; label?: string }>, baseValues),\n [entityType, propTranslatableFields, fieldDefs, baseValues],\n )\n\n const {\n data: translationData,\n isLoading: loadingTranslation,\n isError: translationError,\n refetch: refetchTranslation,\n } = useQuery<TranslationsResponse | null>({\n queryKey: ['entity-translation', entityType, recordId, scopeVersion, isEmbedded ? openedScopeKey : null],\n enabled: !!entityType && !!recordId,\n queryFn: async () => {\n assertEditorScope()\n const res = await apiCall<TranslationsResponse>(\n `/api/translations/${encodeURIComponent(entityType)}/${encodeURIComponent(recordId)}`,\n )\n if (!res.ok) {\n if (res.response?.status === 404) return null\n throw new Error(t('translations.manager.errors.loadTranslation', 'Failed to load translations'))\n }\n return res.result ?? null\n },\n })\n\n // Optimistic lock keys off the TRANSLATION ROW'S OWN version (`updatedAt` from\n // the GET response), not the host entity's: the host's EAV `entityType`\n // (`module:entity`) has no reliable server-side mapping to a registered\n // optimistic-lock reader, so the route enforces against the translation row's\n // own `updated_at`. `null` for a brand-new translation (no existing row \u2192 the\n // header is omitted and the route enforces nothing on insert).\n const translationRowUpdatedAt = React.useMemo(() => {\n const value = translationData?.updatedAt\n return typeof value === 'string' && value.trim().length > 0 ? value : null\n }, [translationData])\n\n const translationSignature = React.useMemo(() => JSON.stringify(translationData ?? null), [translationData])\n const lastTranslationSignatureRef = React.useRef<string | null>(null)\n\n React.useEffect(() => {\n const sig = translationSignature\n if (sig === lastTranslationSignatureRef.current && hasUserEditedRef.current) return\n lastTranslationSignatureRef.current = sig\n\n if (!translationData?.translations) {\n if (!hasUserEditedRef.current) {\n editedTranslationsRef.current = {}\n setEditedTranslations({})\n }\n return\n }\n\n const parsed: Record<string, Record<string, string>> = {}\n for (const [locale, fields] of Object.entries(translationData.translations)) {\n if (!fields || typeof fields !== 'object') continue\n parsed[locale] = {}\n for (const [key, val] of Object.entries(fields)) {\n parsed[locale][key] = typeof val === 'string' ? val : ''\n }\n }\n if (!hasUserEditedRef.current) {\n editedTranslationsRef.current = parsed\n setEditedTranslations(parsed)\n }\n }, [translationSignature, translationData])\n\n const { runMutation, retryLastMutation } = useGuardedMutation<{\n formId: string\n entityType: string\n recordId: string\n resourceKind: string\n resourceId: string\n data: TranslationsResponse | null\n retryLastMutation: () => Promise<boolean>\n }>({ contextId: TRANSLATION_MUTATION_CONTEXT_ID })\n\n const retryInEditorScope = async () => {\n if (!hasEditorScopeChanged()) {\n const succeeded = await retryLastMutation()\n if (succeeded || !hasEditorScopeChanged()) return succeeded\n }\n flash(scopeChangedMessage, 'error')\n return false\n }\n\n const mutation = useMutation({\n mutationFn: async () => {\n if (!entityType || !recordId) {\n throw new Error(t('translations.manager.errors.selectRecord', 'Select an entity and record before saving'))\n }\n const body: Record<string, Record<string, string | null>> = {}\n for (const [locale, fields] of Object.entries(editedTranslationsRef.current)) {\n const localeFields: Record<string, string | null> = {}\n let hasValues = false\n for (const [key, val] of Object.entries(fields)) {\n if (val && val.trim().length > 0) {\n localeFields[key] = val.trim()\n hasValues = true\n }\n }\n if (hasValues) body[locale] = localeFields\n }\n if (Object.keys(body).length === 0) {\n logger.warn('Save skipped: payload is empty \u2014 no locale contains any non-empty field')\n throw new Error(t('translations.manager.errors.nothingToSave', 'Nothing to save \u2014 enter a translation first'))\n }\n assertEditorScope()\n return runMutation({\n operation: async () => {\n const res = await withScopedApiRequestHeaders(\n buildOptimisticLockHeader(translationRowUpdatedAt),\n () => {\n assertEditorScope()\n return apiCall(\n `/api/translations/${encodeURIComponent(entityType)}/${encodeURIComponent(recordId)}`,\n {\n method: 'PUT',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(body),\n },\n )\n },\n )\n if (!res.ok) {\n await raiseCrudError(res.response, t('translations.manager.errors.save', 'Failed to save translations'))\n }\n return true\n },\n context: {\n formId: TRANSLATION_MUTATION_CONTEXT_ID,\n entityType,\n recordId,\n resourceKind: 'translation',\n resourceId: recordId,\n data: translationData ?? null,\n retryLastMutation: isEmbedded ? retryInEditorScope : retryLastMutation,\n },\n mutationPayload: body,\n })\n },\n onSuccess: async () => {\n flash(t('translations.manager.flash.saved', 'Translations saved'), 'success')\n hasUserEditedRef.current = false\n setHasUserEdited(false)\n await refetchTranslation()\n },\n onError: (err: unknown) => {\n if (hasEditorScopeChanged()) {\n flash(scopeChangedMessage, 'error')\n return\n }\n if (surfaceRecordConflict(err, t)) return\n const message = err instanceof Error ? err.message : t('translations.manager.errors.save', 'Failed to save translations')\n flash(message, 'error')\n },\n })\n\n const saveTranslations = React.useCallback(() => {\n if (saveInFlightRef.current || !hasUserEditedRef.current || !entityType || !recordId || loadingTranslation || translationError) return\n saveInFlightRef.current = true\n mutation.mutate(undefined, {\n onSettled: () => { saveInFlightRef.current = false },\n })\n }, [entityType, recordId, loadingTranslation, translationError, mutation])\n\n const updateFieldValue = (locale: string, fieldKey: string, value: string) => {\n hasUserEditedRef.current = true\n setHasUserEdited(true)\n const next = {\n ...editedTranslationsRef.current,\n [locale]: {\n ...editedTranslationsRef.current[locale],\n [fieldKey]: value,\n },\n }\n editedTranslationsRef.current = next\n setEditedTranslations(next)\n }\n\n const getBaseValue = (fieldKey: string): string => resolveBaseValue(baseValues, fieldKey)\n\n const renderRecordPicker = () => {\n if (isEmbedded) return null\n\n return (\n <div className=\"space-y-2\">\n <label className=\"text-xs text-muted-foreground\">\n {t('translations.manager.selectRecord', 'Select record')}\n </label>\n <ComboboxInput\n value={selectedRecordId}\n onChange={(next) => {\n setSelectedRecordId(next)\n hasUserEditedRef.current = false\n setHasUserEdited(false)\n }}\n placeholder={t('translations.manager.searchRecords', 'Search records...')}\n loadSuggestions={loadRecordSuggestions}\n resolveLabel={resolveRecordLabel}\n allowCustomValues\n disabled={!entityType}\n />\n </div>\n )\n }\n\n const renderLocaleTabs = () => (\n <Tabs variant=\"underline\" value={activeLocale} onValueChange={setActiveLocale}>\n <TabsList>\n {locales.map((locale) => (\n <TabsTrigger key={locale} value={locale}>\n {locale.toUpperCase()}\n </TabsTrigger>\n ))}\n </TabsList>\n </Tabs>\n )\n\n const renderFieldTable = () => {\n if (!entityType || !recordId) {\n return (\n <div className=\"rounded border bg-background/80 p-4 text-sm text-muted-foreground\">\n {t('translations.manager.selectFirst', 'Select an entity and record to manage translations.')}\n </div>\n )\n }\n if (loadingTranslation || loadingFieldDefs) {\n return (\n <LoadingMessage\n label={t('translations.manager.loadingTranslations', 'Loading translations...')}\n className=\"border-0 bg-transparent p-4\"\n />\n )\n }\n if (translationError) {\n if (hasEditorScopeChanged()) return <ErrorMessage label={scopeChangedMessage} />\n return (\n <ErrorMessage\n label={t('translations.manager.errors.loadTranslation', 'Failed to load translations')}\n action={(\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={() => void refetchTranslation()}>\n {t('translations.manager.actions.retry', 'Retry')}\n </Button>\n )}\n />\n )\n }\n if (!fieldList.length) {\n return (\n <div className=\"rounded border bg-background/80 p-4 text-sm text-muted-foreground\">\n {t('translations.manager.noFields', 'No translatable fields found for this entity type.')}\n </div>\n )\n }\n\n const localeTranslations = editedTranslations[activeLocale] ?? {}\n const translationLabel = `${t('translations.manager.fields.translation', 'Translation')} (${activeLocale.toUpperCase()})`\n\n return (\n <div className=\"min-w-0\">\n <table className=\"block w-full table-fixed text-sm sm:table\">\n <thead className=\"sr-only sm:not-sr-only sm:table-header-group\">\n <tr className=\"text-xs uppercase tracking-wide text-muted-foreground\">\n <th className=\"w-1/4 px-3 py-2 text-left\">\n {t('translations.manager.fields.field', 'Field')}\n </th>\n {!compact && (\n <th className=\"px-3 py-2 text-left\">\n {t('translations.manager.fields.baseValue', 'Base value')}\n </th>\n )}\n <th className=\"w-1/2 px-3 py-2 text-left\">\n {translationLabel}\n </th>\n </tr>\n </thead>\n <tbody className=\"block sm:table-row-group\">\n {fieldList.map((field) => {\n const baseVal = field.baseValue ?? getBaseValue(field.key)\n const translatedVal = localeTranslations[field.key] ?? ''\n const isPropertyTranslation = entityType === 'entities:custom_field_def' || entityType === 'dictionaries:dictionary_entry'\n const fieldLabel = isPropertyTranslation && field.key === 'label'\n ? t('translations.manager.fields.label', 'Label')\n : isPropertyTranslation && field.key === 'description'\n ? t('translations.manager.fields.description', 'Description')\n : field.label\n const inputLabel = `${fieldLabel} \u2014 ${translationLabel}`\n\n return (\n <tr key={field.key} className=\"block border-t py-2 sm:table-row sm:py-0\">\n <td className=\"block break-words px-3 py-1 text-xs font-medium text-muted-foreground sm:table-cell sm:py-2 sm:align-top\">\n {fieldLabel}\n </td>\n {!compact && (\n <td className=\"block break-words px-3 py-1 text-xs text-muted-foreground sm:table-cell sm:py-2 sm:align-top\">\n {baseVal ? (\n <span className=\"line-clamp-3\">{baseVal}</span>\n ) : (\n <span className=\"text-muted-foreground/50\">-</span>\n )}\n </td>\n )}\n <td className=\"block px-3 py-1 sm:table-cell sm:py-2 sm:align-top\">\n {field.multiline ? (\n <Textarea\n aria-label={inputLabel}\n rows={3}\n value={translatedVal}\n onChange={(e) => updateFieldValue(activeLocale, field.key, e.target.value)}\n placeholder={baseVal || field.label}\n />\n ) : (\n <Input\n aria-label={inputLabel}\n value={translatedVal}\n onChange={(e) => updateFieldValue(activeLocale, field.key, e.target.value)}\n placeholder={baseVal || field.label}\n />\n )}\n </td>\n </tr>\n )\n })}\n </tbody>\n </table>\n </div>\n )\n }\n\n React.useEffect(() => {\n const handler = (e: KeyboardEvent) => {\n if ((e.metaKey || e.ctrlKey) && e.key === 'Enter') {\n e.preventDefault()\n saveTranslations()\n }\n }\n document.addEventListener('keydown', handler)\n return () => document.removeEventListener('keydown', handler)\n }, [saveTranslations])\n\n if (compact) {\n return (\n <div className=\"space-y-3\">\n {renderLocaleTabs()}\n {renderFieldTable()}\n <div className=\"flex justify-end\">\n <Button\n type=\"button\"\n size=\"sm\"\n onClick={saveTranslations}\n disabled={!hasUserEdited || mutation.isPending || loadingTranslation || translationError || !entityType || !recordId}\n data-testid=\"translations-save\"\n >\n <Save className=\"mr-2 h-3 w-3\" />\n {mutation.isPending\n ? t('translations.manager.actions.saving', 'Saving...')\n : t('translations.manager.actions.save', 'Save translations')}\n </Button>\n </div>\n </div>\n )\n }\n\n return (\n <div className=\"space-y-6\">\n <div className=\"flex flex-col gap-3 rounded-lg border bg-card p-4 shadow-sm\">\n <div className=\"space-y-2\">\n <h2 className=\"text-xl font-semibold\">{t('translations.manager.title', 'Translations')}</h2>\n <p className=\"text-sm text-muted-foreground\">\n {t('translations.manager.description', 'Manage translations for entity records across supported locales.')}\n </p>\n </div>\n\n {!isEmbedded && (\n <div className=\"flex flex-col gap-4 sm:flex-row sm:items-start\">\n <div className=\"flex-1 space-y-3\">\n <div>\n <label className=\"text-xs text-muted-foreground\">\n {t('translations.manager.selectEntity', 'Choose entity')}\n </label>\n <div className=\"mt-1\">\n <ComboboxInput\n value={selectedEntityType}\n onChange={(next) => {\n setSelectedEntityType(next)\n setSelectedRecordId('')\n hasUserEditedRef.current = false\n setHasUserEdited(false)\n }}\n placeholder={t('translations.manager.placeholder', 'Select an entity')}\n suggestions={entitySuggestions}\n resolveLabel={resolveEntityLabel}\n disabled={loadingEntities || !!entitiesError}\n />\n </div>\n {entitiesError && (\n <p className=\"mt-1 text-xs text-destructive\">\n {t('translations.manager.errors.loadEntities', 'Failed to load entities')}\n </p>\n )}\n </div>\n {renderRecordPicker()}\n </div>\n </div>\n )}\n\n <div className=\"rounded-lg border bg-background/80 p-4\">\n {renderLocaleTabs()}\n <div className=\"mt-3\">\n {renderFieldTable()}\n </div>\n </div>\n\n <div className=\"flex justify-end\">\n <Button\n type=\"button\"\n onClick={saveTranslations}\n disabled={!hasUserEdited || mutation.isPending || loadingTranslation || translationError || loadingEntities || !!entitiesError || !entityType || !recordId}\n data-testid=\"translations-save\"\n >\n <Save className=\"mr-2 h-4 w-4\" />\n {mutation.isPending\n ? t('translations.manager.actions.saving', 'Saving...')\n : t('translations.manager.actions.save', 'Save translations')}\n </Button>\n </div>\n </div>\n </div>\n )\n}\n\nexport function LocaleManager() {\n const t = useT()\n const queryClient = useQueryClient()\n const { data: localeData, isLoading } = useTranslationLocales()\n const locales = React.useMemo(() => localeData?.locales ?? [], [localeData])\n const servable = React.useMemo(() => localeData?.servable ?? [], [localeData])\n const [newLocale, setNewLocale] = React.useState('')\n\n const { runMutation, retryLastMutation } = useGuardedMutation<{\n formId: string\n resourceKind: string\n retryLastMutation: () => Promise<boolean>\n }>({ contextId: SUPPORTED_LOCALES_MUTATION_CONTEXT_ID })\n\n const mutation = useMutation({\n mutationFn: async (updatedLocales: string[]) => {\n // optimistic-lock-exempt: single-row tenant supported-locales settings list \u2014 no per-record version / concurrent record edit\n return runMutation({\n operation: async () => {\n const res = await apiCall<{ locales: string[] }>('/api/translations/locales', {\n method: 'PUT',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ locales: updatedLocales }),\n })\n if (!res.ok) throw new Error('Failed to save locales')\n return res.result?.locales ?? updatedLocales\n },\n context: {\n formId: SUPPORTED_LOCALES_MUTATION_CONTEXT_ID,\n resourceKind: 'translation-locales',\n retryLastMutation,\n },\n mutationPayload: { locales: updatedLocales },\n })\n },\n onSuccess: (result) => {\n // The PUT response carries the stored selection only, so `servable` has to\n // come from the cached entry. With no entry to read, defaulting it to `[]`\n // would mark every chip \"Content only\" \u2014 including the shipped locales \u2014\n // which is the one answer that is definitely wrong. Refetch instead.\n const previous = queryClient.getQueryData<TranslationLocales>(['translation-locales'])\n if (previous) {\n queryClient.setQueryData<TranslationLocales>(['translation-locales'], { ...previous, locales: result })\n } else {\n void queryClient.invalidateQueries({ queryKey: ['translation-locales'] })\n }\n flash(t('translations.locales.flash.saved', 'Locales updated'), 'success')\n },\n onError: () => {\n flash(t('translations.locales.flash.error', 'Failed to update locales'), 'error')\n },\n })\n\n // A locale the app has no dictionary for can be translated into, but the admin\n // UI can never be shown in it \u2014 `resolveSupportedLocalesForRequest` intersects\n // the selection with what the app serves. Saying so at the point of action is\n // what keeps the successful-looking add honest.\n const contentOnlyLabel = t('translations.locales.contentOnly', 'Content only')\n const isServable = React.useCallback(\n (code: string) => servable.includes(code.toLowerCase()),\n [servable],\n )\n\n const availableLocales = React.useMemo(\n () => ISO_639_1.filter((entry) => !locales.includes(entry.code)).map((entry) => ({\n value: entry.code,\n label: isServable(entry.code)\n ? `${entry.code.toUpperCase()} \u2014 ${entry.label}`\n : `${entry.code.toUpperCase()} \u2014 ${entry.label} (${contentOnlyLabel})`,\n })),\n [locales, isServable, contentOnlyLabel],\n )\n\n // `resolveSupportedLocalesForRequest` keeps `defaultLocale` in the served set\n // whatever the stored selection says, so a tenant whose saved list omits it\n // still gets it in the language switcher. Rendering the raw selection here\n // would leave this screen and the switcher disagreeing about what is served.\n const chips = React.useMemo(\n () => (locales.includes(defaultLocale) ? locales : [defaultLocale, ...locales]),\n [locales],\n )\n\n const addLocale = () => {\n const code = newLocale.toLowerCase().trim()\n if (!code || !isValidIso639(code) || locales.includes(code)) return\n mutation.mutate([...locales, code])\n setNewLocale('')\n }\n\n const removeLocale = (locale: string) => {\n if (locales.length <= 1) return\n // The default locale stays servable whatever the selection says\n // (`resolveSupportedLocalesForRequest` re-adds it), so letting it be removed\n // here would leave the chip list claiming something untrue.\n if (locale === defaultLocale) return\n mutation.mutate(locales.filter((l) => l !== locale))\n }\n\n if (isLoading) {\n return <LoadingMessage label={t('translations.locales.loading', 'Loading locales...')} className=\"border-0 bg-transparent p-4\" />\n }\n\n return (\n <div className=\"flex flex-col gap-3 rounded-lg border bg-card p-4 shadow-sm\">\n <div className=\"space-y-1\">\n <h3 className=\"text-lg font-semibold\">{t('translations.locales.title', 'Supported locales')}</h3>\n <p className=\"text-sm text-muted-foreground\">\n {t('translations.locales.description', 'Which languages content can be translated into. A language the application ships an interface for is also offered in the admin language switcher; the rest are available for content only.')}\n </p>\n </div>\n\n <div className=\"flex flex-wrap gap-2\">\n {chips.map((locale) => {\n const localeLabel = getIso639Label(locale) ?? locale.toUpperCase()\n const isDefault = locale === defaultLocale\n const isStored = locales.includes(locale)\n const removeLabel = t('translations.locales.remove', 'Remove {{locale}}', { locale: localeLabel })\n const defaultLabel = t(\n 'translations.locales.alwaysServed',\n '{{locale}} is the default language and is always served, so it cannot be removed.',\n { locale: localeLabel },\n )\n return (\n <span\n key={locale}\n className=\"inline-flex items-center gap-1.5 rounded-full border bg-muted/50 px-3 py-1 text-sm font-medium\"\n title={isStored ? (getIso639Label(locale) ?? locale) : defaultLabel}\n >\n {locale.toUpperCase()}{getIso639Label(locale) ? ` \u2014 ${getIso639Label(locale)}` : ''}\n {!isServable(locale) && (\n <Badge variant=\"outline\" size=\"sm\" title={t('translations.locales.contentOnlyHint', 'The application ships no interface for this language, so it is available for content translations only.')}>\n {contentOnlyLabel}\n </Badge>\n )}\n {isStored && locales.length > 1 && (\n <IconButton\n variant=\"ghost\"\n size=\"xs\"\n fullRadius\n aria-label={isDefault ? defaultLabel : removeLabel}\n title={isDefault ? defaultLabel : removeLabel}\n onClick={() => removeLocale(locale)}\n disabled={mutation.isPending || isDefault}\n >\n <X className=\"h-3 w-3\" />\n </IconButton>\n )}\n </span>\n )\n })}\n </div>\n\n <div className=\"flex gap-2 items-center\">\n <div className=\"max-w-[240px] flex-1\">\n <ComboboxInput\n value={newLocale}\n onChange={setNewLocale}\n placeholder={t('translations.locales.addPlaceholder', 'e.g. fr, it, ja...')}\n suggestions={availableLocales}\n resolveLabel={(value) => {\n const label = getIso639Label(value)\n const base = label ? `${value.toUpperCase()} \u2014 ${label}` : value.toUpperCase()\n return isServable(value) ? base : `${base} (${contentOnlyLabel})`\n }}\n />\n </div>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={addLocale}\n disabled={mutation.isPending || !newLocale.trim() || !isValidIso639(newLocale) || locales.includes(newLocale.toLowerCase().trim())}\n >\n <Plus className=\"mr-1 h-3 w-3\" />\n {t('translations.locales.add', 'Add')}\n </Button>\n </div>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAgZM,SACE,KADF;AA9YN,YAAY,WAAW;AACvB,SAAS,UAAU,aAAa,sBAAsB;AACtD,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB,SAAS,MAAM,UAAU,mBAAmB;AAC5C,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,SAAS,gBAAgB,oBAAoB;AAC7C,SAAS,aAAa;AACtB,SAAS,SAAS,sBAAsB,mCAAmC;AAC3E,SAAS,iCAAiC;AAC1C,SAAS,6BAA6B;AACtC,SAAS,sBAAsB;AAC/B,SAAS,0BAA0B;AACnC,SAA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,UACL,SAAS;AAAA,UACT,UAAU,SAAS,aAAa,CAAC,UAAU,KAAK,KAAK,CAAC,cAAc,SAAS,KAAK,QAAQ,SAAS,UAAU,YAAY,EAAE,KAAK,CAAC;AAAA,UAEjI;AAAA,gCAAC,QAAK,WAAU,gBAAe;AAAA,YAC9B,EAAE,4BAA4B,KAAK;AAAA;AAAA;AAAA,MACtC;AAAA,OACF;AAAA,KACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -108,13 +108,19 @@ function CompletePutawayTaskDialog({
|
|
|
108
108
|
if (!nextErrors[key]) nextErrors[key] = t(issue.message, issue.message);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
+
if (confirmedQuantity > task.quantity + 1e-6) {
|
|
112
|
+
nextErrors.confirmedQuantity = t(
|
|
113
|
+
"wms.backend.putaway.complete.errors.quantityExceedsTask",
|
|
114
|
+
"Confirmed quantity cannot exceed the task quantity."
|
|
115
|
+
);
|
|
116
|
+
}
|
|
111
117
|
if (expectedSerial && serialConfirmation.trim() !== expectedSerial) {
|
|
112
118
|
nextErrors.serialConfirmation = t(
|
|
113
119
|
"wms.backend.putaway.complete.errors.serialMismatch",
|
|
114
120
|
"The scanned serial does not match this task."
|
|
115
121
|
);
|
|
116
122
|
}
|
|
117
|
-
if (!parsed.success || nextErrors.
|
|
123
|
+
if (!parsed.success || Object.keys(nextErrors).length > 0) {
|
|
118
124
|
setFieldErrors(nextErrors);
|
|
119
125
|
return;
|
|
120
126
|
}
|
|
@@ -267,6 +273,7 @@ function CompletePutawayTaskDialog({
|
|
|
267
273
|
type: "number",
|
|
268
274
|
min: 1e-4,
|
|
269
275
|
step: "any",
|
|
276
|
+
readOnly: Boolean(expectedSerial) && task?.quantity === 1,
|
|
270
277
|
value: confirmedQuantity,
|
|
271
278
|
onChange: (event) => setConfirmedQuantity(Number(event.target.value)),
|
|
272
279
|
disabled: submitting,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/modules/wms/components/backend/CompletePutawayTaskDialog.tsx"],
|
|
4
|
-
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { z } from 'zod'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { flashMutationError } from '../../lib/flashMutationError'\nimport { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'\nimport { ComboboxInput } from '@open-mercato/ui/backend/inputs/ComboboxInput'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport {\n buildOptimisticLockHeader,\n extractOptimisticLockConflict,\n} from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { raiseCrudError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'\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 { Input } from '@open-mercato/ui/primitives/input'\nimport { KbdShortcut } from '@open-mercato/ui/primitives/kbd'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport {\n loadBinLocationOptions,\n resolveLocationLabel,\n} from './inventoryMutationLoaders'\nimport type { WmsInventoryMutationAccess } from './useWmsInventoryMutationAccess'\n\nexport type PutawayTaskTarget = {\n id: string\n warehouseId: string\n quantity: number\n targetLocationId?: string | null\n catalogVariantId?: string | null\n sourceLocationId?: string | null\n serialNumber?: string | null\n updatedAt?: string | null\n}\n\ntype CompletePutawayTaskDialogProps = {\n open: boolean\n onOpenChange: (open: boolean) => void\n access: WmsInventoryMutationAccess\n task: PutawayTaskTarget | null\n onSuccess?: () => void\n}\n\nconst formSchema = z.object({\n confirmedQuantity: z.number().positive('wms.backend.putaway.complete.errors.quantityPositive'),\n targetLocationId: z.string().uuid('wms.backend.putaway.complete.errors.targetRequired'),\n})\n\nexport function CompletePutawayTaskDialog({\n open,\n onOpenChange,\n access,\n task,\n onSuccess,\n}: CompletePutawayTaskDialogProps) {\n const t = useT()\n const queryClient = useQueryClient()\n const { runMutation, retryLastMutation } = useGuardedMutation<{\n retryLastMutation: () => Promise<boolean>\n }>({\n contextId: 'wms-putaway-complete',\n })\n const mutationContext = React.useMemo(\n () => ({ retryLastMutation }),\n [retryLastMutation],\n )\n\n const [confirmedQuantity, setConfirmedQuantity] = React.useState(1)\n const [targetLocationId, setTargetLocationId] = React.useState('')\n const [serialConfirmation, setSerialConfirmation] = React.useState('')\n const [fieldErrors, setFieldErrors] = React.useState<Record<string, string>>({})\n const [submitting, setSubmitting] = React.useState(false)\n const [lockUpdatedAt, setLockUpdatedAt] = React.useState<string | null>(null)\n /** Fresh If-Match after 409; ref so guarded retry reads latest without re-seed. */\n const lockUpdatedAtRef = React.useRef<string | null>(null)\n\n const closeDialog = React.useCallback(() => {\n if (submitting) return\n onOpenChange(false)\n }, [onOpenChange, submitting])\n\n const warehouseId = task?.warehouseId?.trim() || ''\n const expectedSerial = task?.serialNumber?.trim() ?? ''\n\n // Stable identity so ComboboxInput's debounced suggestion effect is not torn\n // down on every parent re-render (queue refetch / access churn) \u2014 an inline\n // arrow would recreate each render and can starve the fetch, leaving the\n // portaled list stuck on \"Loading suggestions\u2026\" with no selectable options.\n const loadTargetLocationSuggestions = React.useCallback(\n async (query?: string) => (warehouseId ? loadBinLocationOptions(warehouseId, query) : []),\n [warehouseId],\n )\n\n const resolveTargetLocationLabel = React.useCallback(\n async (value: string) => (await resolveLocationLabel(value)) ?? value,\n [],\n )\n\n React.useEffect(() => {\n if (!open || !task) return\n setConfirmedQuantity(task.quantity > 0 ? task.quantity : 1)\n setTargetLocationId(task.targetLocationId?.trim() || '')\n setSerialConfirmation('')\n setFieldErrors({})\n setSubmitting(false)\n const seed = task.updatedAt ?? null\n lockUpdatedAtRef.current = seed\n setLockUpdatedAt(seed)\n }, [open, task])\n\n const handleSubmit = React.useCallback(\n async (event?: React.FormEvent) => {\n event?.preventDefault()\n if (!task) return\n if (!access.scopeReady || !access.organizationId || !access.tenantId || !access.userId) {\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 const parsed = formSchema.safeParse({\n confirmedQuantity,\n targetLocationId: targetLocationId.trim(),\n })\n const nextErrors: Record<string, string> = {}\n if (!parsed.success) {\n for (const issue of parsed.error.issues) {\n const key = String(issue.path[0] ?? 'form')\n if (!nextErrors[key]) nextErrors[key] = t(issue.message, issue.message)\n }\n }\n if (expectedSerial && serialConfirmation.trim() !== expectedSerial) {\n nextErrors.serialConfirmation = t(\n 'wms.backend.putaway.complete.errors.serialMismatch',\n 'The scanned serial does not match this task.',\n )\n }\n if (!parsed.success || nextErrors.serialConfirmation) {\n setFieldErrors(nextErrors)\n return\n }\n\n setSubmitting(true)\n setFieldErrors({})\n const payload = {\n organizationId: access.organizationId,\n tenantId: access.tenantId,\n confirmedQuantity: parsed.data.confirmedQuantity,\n targetLocationId: parsed.data.targetLocationId,\n performedBy: access.userId,\n }\n\n try {\n let conflictHandled = false\n await runMutation({\n operation: async () => {\n const call = await apiCall<{ ok?: boolean }>(\n `/api/wms/putaway-tasks/${encodeURIComponent(task.id)}/complete`,\n {\n method: 'POST',\n headers: {\n 'content-type': 'application/json',\n ...buildOptimisticLockHeader(lockUpdatedAtRef.current ?? undefined),\n },\n body: JSON.stringify(payload),\n },\n )\n if (!call.ok) {\n const refreshLockFromConflict = () => {\n const conflict = extractOptimisticLockConflict({\n status: call.status,\n body: call.result,\n })\n if (conflict?.currentUpdatedAt) {\n lockUpdatedAtRef.current = conflict.currentUpdatedAt\n setLockUpdatedAt(conflict.currentUpdatedAt)\n }\n void queryClient.invalidateQueries({ queryKey: ['wms-putaway-queue'] })\n }\n if (\n surfaceRecordConflict({ status: call.status, body: call.result }, t, {\n onRefresh: refreshLockFromConflict,\n })\n ) {\n refreshLockFromConflict()\n conflictHandled = true\n return {}\n }\n await raiseCrudError(\n call.response,\n t('wms.backend.putaway.complete.errors.submit', 'Failed to complete putaway task.'),\n )\n }\n return call.result ?? {}\n },\n context: mutationContext,\n mutationPayload: payload,\n })\n\n if (conflictHandled) return\n\n flash(t('wms.backend.putaway.complete.flash.success', 'Putaway completed'), 'success')\n await queryClient.invalidateQueries({ queryKey: ['wms-putaway-queue'] })\n closeDialog()\n onSuccess?.()\n } catch (error) {\n flashMutationError(\n error,\n t('wms.backend.putaway.complete.errors.submit', 'Failed to complete putaway task.'),\n t,\n )\n } finally {\n setSubmitting(false)\n }\n },\n [\n access,\n closeDialog,\n confirmedQuantity,\n expectedSerial,\n lockUpdatedAt,\n serialConfirmation,\n mutationContext,\n onSuccess,\n queryClient,\n runMutation,\n t,\n targetLocationId,\n task,\n ],\n )\n\n const handleKeyDown = 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 (!submitting) void handleSubmit()\n }\n },\n [closeDialog, handleSubmit, submitting],\n )\n\n if (!task) return null\n\n return (\n <Dialog open={open} onOpenChange={(next) => (next ? onOpenChange(true) : closeDialog())}>\n <DialogContent className=\"max-w-lg gap-0 overflow-hidden p-0\" onKeyDown={handleKeyDown}>\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.putaway.complete.dialog.title', 'Complete putaway')}\n </DialogTitle>\n <DialogDescription>\n {t(\n 'wms.backend.putaway.complete.dialog.description',\n 'Confirm quantity and destination bin to move stock from staging.',\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 {expectedSerial ? (\n <>\n <p className=\"text-sm text-muted-foreground\" data-testid=\"complete-putaway-expected-serial\">\n {t('wms.backend.putaway.complete.form.serial', 'Serial')}: {expectedSerial}\n </p>\n <FormField\n label={t('wms.backend.putaway.complete.form.serialConfirm', 'Confirm serial')}\n required\n disabled={submitting}\n error={fieldErrors.serialConfirmation}\n description={t(\n 'wms.backend.putaway.complete.form.serialConfirmHint',\n 'Scan or type the serial on the unit. It must match this task.',\n )}\n >\n <Input\n value={serialConfirmation}\n onChange={(event) => setSerialConfirmation(event.target.value)}\n data-testid=\"complete-putaway-serial\"\n />\n </FormField>\n </>\n ) : null}\n <FormField\n label={t('wms.backend.putaway.complete.form.quantity', 'Confirmed quantity')}\n required\n error={fieldErrors.confirmedQuantity}\n >\n <Input\n type=\"number\"\n min={0.0001}\n step=\"any\"\n value={confirmedQuantity}\n onChange={(event) => setConfirmedQuantity(Number(event.target.value))}\n disabled={submitting}\n data-testid=\"complete-putaway-qty\"\n />\n </FormField>\n\n <FormField\n label={t('wms.backend.putaway.complete.form.target', 'Target location')}\n required\n error={fieldErrors.targetLocationId}\n >\n <ComboboxInput\n value={targetLocationId}\n onChange={setTargetLocationId}\n loadSuggestions={loadTargetLocationSuggestions}\n resolveLabel={resolveTargetLocationLabel}\n placeholder={t(\n 'wms.backend.putaway.complete.form.targetPlaceholder',\n 'Select destination bin',\n )}\n allowCustomValues={false}\n disabled={submitting}\n />\n </FormField>\n </div>\n\n <DialogFooter bordered={false} className=\"border-t px-6 py-4 sm:justify-between\">\n <span className=\"hidden text-xs text-muted-foreground sm:inline\">\n <KbdShortcut keys={['Ctrl/\u2318', 'Enter']} />{' '}\n {t('wms.backend.putaway.complete.dialog.shortcutHint', 'to complete')}\n </span>\n <div className=\"flex gap-2\">\n <Button type=\"button\" variant=\"outline\" onClick={closeDialog} disabled={submitting}>\n {t('wms.backend.putaway.complete.dialog.cancel', 'Cancel')}\n </Button>\n <Button\n type=\"submit\"\n disabled={submitting || access.loading || !access.scopeReady}\n data-testid=\"complete-putaway-submit\"\n >\n {t('wms.backend.putaway.complete.dialog.submit', 'Complete putaway')}\n </Button>\n </div>\n </DialogFooter>\n </form>\n </DialogContent>\n </Dialog>\n )\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["\"use client\"\n\nimport * as React from 'react'\nimport { z } from 'zod'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { flashMutationError } from '../../lib/flashMutationError'\nimport { useGuardedMutation } from '@open-mercato/ui/backend/injection/useGuardedMutation'\nimport { ComboboxInput } from '@open-mercato/ui/backend/inputs/ComboboxInput'\nimport { apiCall } from '@open-mercato/ui/backend/utils/apiCall'\nimport {\n buildOptimisticLockHeader,\n extractOptimisticLockConflict,\n} from '@open-mercato/ui/backend/utils/optimisticLock'\nimport { raiseCrudError } from '@open-mercato/ui/backend/utils/serverErrors'\nimport { surfaceRecordConflict } from '@open-mercato/ui/backend/conflicts'\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 { Input } from '@open-mercato/ui/primitives/input'\nimport { KbdShortcut } from '@open-mercato/ui/primitives/kbd'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport {\n loadBinLocationOptions,\n resolveLocationLabel,\n} from './inventoryMutationLoaders'\nimport type { WmsInventoryMutationAccess } from './useWmsInventoryMutationAccess'\n\nexport type PutawayTaskTarget = {\n id: string\n warehouseId: string\n quantity: number\n targetLocationId?: string | null\n catalogVariantId?: string | null\n sourceLocationId?: string | null\n serialNumber?: string | null\n updatedAt?: string | null\n}\n\ntype CompletePutawayTaskDialogProps = {\n open: boolean\n onOpenChange: (open: boolean) => void\n access: WmsInventoryMutationAccess\n task: PutawayTaskTarget | null\n onSuccess?: () => void\n}\n\nconst formSchema = z.object({\n confirmedQuantity: z.number().positive('wms.backend.putaway.complete.errors.quantityPositive'),\n targetLocationId: z.string().uuid('wms.backend.putaway.complete.errors.targetRequired'),\n})\n\nexport function CompletePutawayTaskDialog({\n open,\n onOpenChange,\n access,\n task,\n onSuccess,\n}: CompletePutawayTaskDialogProps) {\n const t = useT()\n const queryClient = useQueryClient()\n const { runMutation, retryLastMutation } = useGuardedMutation<{\n retryLastMutation: () => Promise<boolean>\n }>({\n contextId: 'wms-putaway-complete',\n })\n const mutationContext = React.useMemo(\n () => ({ retryLastMutation }),\n [retryLastMutation],\n )\n\n const [confirmedQuantity, setConfirmedQuantity] = React.useState(1)\n const [targetLocationId, setTargetLocationId] = React.useState('')\n const [serialConfirmation, setSerialConfirmation] = React.useState('')\n const [fieldErrors, setFieldErrors] = React.useState<Record<string, string>>({})\n const [submitting, setSubmitting] = React.useState(false)\n const [lockUpdatedAt, setLockUpdatedAt] = React.useState<string | null>(null)\n /** Fresh If-Match after 409; ref so guarded retry reads latest without re-seed. */\n const lockUpdatedAtRef = React.useRef<string | null>(null)\n\n const closeDialog = React.useCallback(() => {\n if (submitting) return\n onOpenChange(false)\n }, [onOpenChange, submitting])\n\n const warehouseId = task?.warehouseId?.trim() || ''\n const expectedSerial = task?.serialNumber?.trim() ?? ''\n\n // Stable identity so ComboboxInput's debounced suggestion effect is not torn\n // down on every parent re-render (queue refetch / access churn) \u2014 an inline\n // arrow would recreate each render and can starve the fetch, leaving the\n // portaled list stuck on \"Loading suggestions\u2026\" with no selectable options.\n const loadTargetLocationSuggestions = React.useCallback(\n async (query?: string) => (warehouseId ? loadBinLocationOptions(warehouseId, query) : []),\n [warehouseId],\n )\n\n const resolveTargetLocationLabel = React.useCallback(\n async (value: string) => (await resolveLocationLabel(value)) ?? value,\n [],\n )\n\n React.useEffect(() => {\n if (!open || !task) return\n setConfirmedQuantity(task.quantity > 0 ? task.quantity : 1)\n setTargetLocationId(task.targetLocationId?.trim() || '')\n setSerialConfirmation('')\n setFieldErrors({})\n setSubmitting(false)\n const seed = task.updatedAt ?? null\n lockUpdatedAtRef.current = seed\n setLockUpdatedAt(seed)\n }, [open, task])\n\n const handleSubmit = React.useCallback(\n async (event?: React.FormEvent) => {\n event?.preventDefault()\n if (!task) return\n if (!access.scopeReady || !access.organizationId || !access.tenantId || !access.userId) {\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 const parsed = formSchema.safeParse({\n confirmedQuantity,\n targetLocationId: targetLocationId.trim(),\n })\n const nextErrors: Record<string, string> = {}\n if (!parsed.success) {\n for (const issue of parsed.error.issues) {\n const key = String(issue.path[0] ?? 'form')\n if (!nextErrors[key]) nextErrors[key] = t(issue.message, issue.message)\n }\n }\n if (confirmedQuantity > task.quantity + 0.000001) {\n nextErrors.confirmedQuantity = t(\n 'wms.backend.putaway.complete.errors.quantityExceedsTask',\n 'Confirmed quantity cannot exceed the task quantity.',\n )\n }\n if (expectedSerial && serialConfirmation.trim() !== expectedSerial) {\n nextErrors.serialConfirmation = t(\n 'wms.backend.putaway.complete.errors.serialMismatch',\n 'The scanned serial does not match this task.',\n )\n }\n if (!parsed.success || Object.keys(nextErrors).length > 0) {\n setFieldErrors(nextErrors)\n return\n }\n\n setSubmitting(true)\n setFieldErrors({})\n const payload = {\n organizationId: access.organizationId,\n tenantId: access.tenantId,\n confirmedQuantity: parsed.data.confirmedQuantity,\n targetLocationId: parsed.data.targetLocationId,\n performedBy: access.userId,\n }\n\n try {\n let conflictHandled = false\n await runMutation({\n operation: async () => {\n const call = await apiCall<{ ok?: boolean }>(\n `/api/wms/putaway-tasks/${encodeURIComponent(task.id)}/complete`,\n {\n method: 'POST',\n headers: {\n 'content-type': 'application/json',\n ...buildOptimisticLockHeader(lockUpdatedAtRef.current ?? undefined),\n },\n body: JSON.stringify(payload),\n },\n )\n if (!call.ok) {\n const refreshLockFromConflict = () => {\n const conflict = extractOptimisticLockConflict({\n status: call.status,\n body: call.result,\n })\n if (conflict?.currentUpdatedAt) {\n lockUpdatedAtRef.current = conflict.currentUpdatedAt\n setLockUpdatedAt(conflict.currentUpdatedAt)\n }\n void queryClient.invalidateQueries({ queryKey: ['wms-putaway-queue'] })\n }\n if (\n surfaceRecordConflict({ status: call.status, body: call.result }, t, {\n onRefresh: refreshLockFromConflict,\n })\n ) {\n refreshLockFromConflict()\n conflictHandled = true\n return {}\n }\n await raiseCrudError(\n call.response,\n t('wms.backend.putaway.complete.errors.submit', 'Failed to complete putaway task.'),\n )\n }\n return call.result ?? {}\n },\n context: mutationContext,\n mutationPayload: payload,\n })\n\n if (conflictHandled) return\n\n flash(t('wms.backend.putaway.complete.flash.success', 'Putaway completed'), 'success')\n await queryClient.invalidateQueries({ queryKey: ['wms-putaway-queue'] })\n closeDialog()\n onSuccess?.()\n } catch (error) {\n flashMutationError(\n error,\n t('wms.backend.putaway.complete.errors.submit', 'Failed to complete putaway task.'),\n t,\n )\n } finally {\n setSubmitting(false)\n }\n },\n [\n access,\n closeDialog,\n confirmedQuantity,\n expectedSerial,\n lockUpdatedAt,\n serialConfirmation,\n mutationContext,\n onSuccess,\n queryClient,\n runMutation,\n t,\n targetLocationId,\n task,\n ],\n )\n\n const handleKeyDown = 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 (!submitting) void handleSubmit()\n }\n },\n [closeDialog, handleSubmit, submitting],\n )\n\n if (!task) return null\n\n return (\n <Dialog open={open} onOpenChange={(next) => (next ? onOpenChange(true) : closeDialog())}>\n <DialogContent className=\"max-w-lg gap-0 overflow-hidden p-0\" onKeyDown={handleKeyDown}>\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.putaway.complete.dialog.title', 'Complete putaway')}\n </DialogTitle>\n <DialogDescription>\n {t(\n 'wms.backend.putaway.complete.dialog.description',\n 'Confirm quantity and destination bin to move stock from staging.',\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 {expectedSerial ? (\n <>\n <p className=\"text-sm text-muted-foreground\" data-testid=\"complete-putaway-expected-serial\">\n {t('wms.backend.putaway.complete.form.serial', 'Serial')}: {expectedSerial}\n </p>\n <FormField\n label={t('wms.backend.putaway.complete.form.serialConfirm', 'Confirm serial')}\n required\n disabled={submitting}\n error={fieldErrors.serialConfirmation}\n description={t(\n 'wms.backend.putaway.complete.form.serialConfirmHint',\n 'Scan or type the serial on the unit. It must match this task.',\n )}\n >\n <Input\n value={serialConfirmation}\n onChange={(event) => setSerialConfirmation(event.target.value)}\n data-testid=\"complete-putaway-serial\"\n />\n </FormField>\n </>\n ) : null}\n <FormField\n label={t('wms.backend.putaway.complete.form.quantity', 'Confirmed quantity')}\n required\n error={fieldErrors.confirmedQuantity}\n >\n <Input\n type=\"number\"\n min={0.0001}\n step=\"any\"\n readOnly={Boolean(expectedSerial) && task?.quantity === 1}\n value={confirmedQuantity}\n onChange={(event) => setConfirmedQuantity(Number(event.target.value))}\n disabled={submitting}\n data-testid=\"complete-putaway-qty\"\n />\n </FormField>\n\n <FormField\n label={t('wms.backend.putaway.complete.form.target', 'Target location')}\n required\n error={fieldErrors.targetLocationId}\n >\n <ComboboxInput\n value={targetLocationId}\n onChange={setTargetLocationId}\n loadSuggestions={loadTargetLocationSuggestions}\n resolveLabel={resolveTargetLocationLabel}\n placeholder={t(\n 'wms.backend.putaway.complete.form.targetPlaceholder',\n 'Select destination bin',\n )}\n allowCustomValues={false}\n disabled={submitting}\n />\n </FormField>\n </div>\n\n <DialogFooter bordered={false} className=\"border-t px-6 py-4 sm:justify-between\">\n <span className=\"hidden text-xs text-muted-foreground sm:inline\">\n <KbdShortcut keys={['Ctrl/\u2318', 'Enter']} />{' '}\n {t('wms.backend.putaway.complete.dialog.shortcutHint', 'to complete')}\n </span>\n <div className=\"flex gap-2\">\n <Button type=\"button\" variant=\"outline\" onClick={closeDialog} disabled={submitting}>\n {t('wms.backend.putaway.complete.dialog.cancel', 'Cancel')}\n </Button>\n <Button\n type=\"submit\"\n disabled={submitting || access.loading || !access.scopeReady}\n data-testid=\"complete-putaway-submit\"\n >\n {t('wms.backend.putaway.complete.dialog.submit', 'Complete putaway')}\n </Button>\n </div>\n </DialogFooter>\n </form>\n </DialogContent>\n </Dialog>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAmRU,SAgBI,UAfF,KADF;AAjRV,YAAY,WAAW;AACvB,SAAS,SAAS;AAClB,SAAS,sBAAsB;AAC/B,SAAS,aAAa;AACtB,SAAS,0BAA0B;AACnC,SAAS,0BAA0B;AACnC,SAAS,qBAAqB;AAC9B,SAAS,eAAe;AACxB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAC/B,SAAS,6BAA6B;AACtC,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB;AAC1B,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,YAAY;AACrB;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAsBP,MAAM,aAAa,EAAE,OAAO;AAAA,EAC1B,mBAAmB,EAAE,OAAO,EAAE,SAAS,sDAAsD;AAAA,EAC7F,kBAAkB,EAAE,OAAO,EAAE,KAAK,oDAAoD;AACxF,CAAC;AAEM,SAAS,0BAA0B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAAmC;AACjC,QAAM,IAAI,KAAK;AACf,QAAM,cAAc,eAAe;AACnC,QAAM,EAAE,aAAa,k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,WACtE;AAAA,QACA,qBAAC,SAAI,WAAU,cACb;AAAA,8BAAC,UAAO,MAAK,UAAS,SAAQ,WAAU,SAAS,aAAa,UAAU,YACrE,YAAE,8CAA8C,QAAQ,GAC3D;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,UAAU,cAAc,OAAO,WAAW,CAAC,OAAO;AAAA,cAClD,eAAY;AAAA,cAEX,YAAE,8CAA8C,kBAAkB;AAAA;AAAA,UACrE;AAAA,WACF;AAAA,SACF;AAAA,OACF;AAAA,KACF,GACF;AAEJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -463,7 +463,7 @@ const startTestRunTool = {
|
|
|
463
463
|
isDryRun: true,
|
|
464
464
|
tenantId: scope.tenantId,
|
|
465
465
|
organizationId: scope.organizationId
|
|
466
|
-
});
|
|
466
|
+
}, ctx.container);
|
|
467
467
|
let executionError = null;
|
|
468
468
|
try {
|
|
469
469
|
await workflowExecutor.executeWorkflow(em, ctx.container, instance.id, {
|