@open-mercato/core 0.6.8-develop.6998.1.d2bc46c56c → 0.6.8-develop.7001.1.03608ab252
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +2 -2
- package/dist/generated/entities/warranty_claim/index.js +105 -0
- package/dist/generated/entities/warranty_claim/index.js.map +7 -0
- package/dist/generated/entities/warranty_claim_event/index.js +25 -0
- package/dist/generated/entities/warranty_claim_event/index.js.map +7 -0
- package/dist/generated/entities/warranty_claim_line/index.js +77 -0
- package/dist/generated/entities/warranty_claim_line/index.js.map +7 -0
- package/dist/generated/entities/warranty_claim_registration/index.js +43 -0
- package/dist/generated/entities/warranty_claim_registration/index.js.map +7 -0
- package/dist/generated/entities/warranty_claim_sequence/index.js +17 -0
- package/dist/generated/entities/warranty_claim_sequence/index.js.map +7 -0
- package/dist/generated/entities/warranty_claim_settings/index.js +43 -0
- package/dist/generated/entities/warranty_claim_settings/index.js.map +7 -0
- package/dist/generated/entities/warranty_claim_sla_signal/index.js +25 -0
- package/dist/generated/entities/warranty_claim_sla_signal/index.js.map +7 -0
- package/dist/generated/entities/warranty_troubleshooting_guide/index.js +25 -0
- package/dist/generated/entities/warranty_troubleshooting_guide/index.js.map +7 -0
- package/dist/generated/entities/warranty_vendor_policy/index.js +31 -0
- package/dist/generated/entities/warranty_vendor_policy/index.js.map +7 -0
- package/dist/generated/entities.ids.generated.js +12 -0
- package/dist/generated/entities.ids.generated.js.map +2 -2
- package/dist/generated/entity-fields-registry.js +200 -0
- package/dist/generated/entity-fields-registry.js.map +2 -2
- package/dist/helpers/integration/api.js +3 -2
- package/dist/helpers/integration/api.js.map +2 -2
- package/dist/helpers/integration/salesFixtures.js +13 -6
- package/dist/helpers/integration/salesFixtures.js.map +2 -2
- package/dist/modules/attachments/di.js +18 -0
- package/dist/modules/attachments/di.js.map +2 -2
- package/dist/modules/attachments/fields/attachment.js +186 -26
- package/dist/modules/attachments/fields/attachment.js.map +2 -2
- package/dist/modules/attachments/lib/scoped-upload-service.js +202 -0
- package/dist/modules/attachments/lib/scoped-upload-service.js.map +7 -0
- package/dist/modules/attachments/lib/target-access-service.js +39 -0
- package/dist/modules/attachments/lib/target-access-service.js.map +7 -0
- package/dist/modules/auth/api/logout.js +37 -10
- package/dist/modules/auth/api/logout.js.map +2 -2
- package/dist/modules/auth/api/reset/confirm.js +7 -0
- package/dist/modules/auth/api/reset/confirm.js.map +2 -2
- package/dist/modules/auth/api/reset.js +7 -0
- package/dist/modules/auth/api/reset.js.map +2 -2
- package/dist/modules/auth/commands/users.js +13 -0
- package/dist/modules/auth/commands/users.js.map +2 -2
- package/dist/modules/auth/events.js +15 -0
- package/dist/modules/auth/events.js.map +2 -2
- package/dist/modules/customers/api/companies/route.js +1 -0
- package/dist/modules/customers/api/companies/route.js.map +2 -2
- package/dist/modules/customers/backend/customers/companies-v2/[id]/page.js +2 -2
- package/dist/modules/customers/backend/customers/companies-v2/[id]/page.js.map +2 -2
- package/dist/modules/customers/backend/customers/people-v2/[id]/page.js +2 -2
- package/dist/modules/customers/backend/customers/people-v2/[id]/page.js.map +2 -2
- package/dist/modules/customers/components/detail/assignableStaff.js +6 -69
- package/dist/modules/customers/components/detail/assignableStaff.js.map +2 -2
- package/dist/modules/customers/lib/assignableStaff.js +76 -0
- package/dist/modules/customers/lib/assignableStaff.js.map +7 -0
- package/dist/modules/data_sync/lib/batch-stream.js +56 -0
- package/dist/modules/data_sync/lib/batch-stream.js.map +7 -0
- package/dist/modules/data_sync/lib/sync-engine.js +165 -103
- package/dist/modules/data_sync/lib/sync-engine.js.map +2 -2
- package/dist/modules/inbox_ops/api/emails/[id]/reprocess/route.js +4 -0
- package/dist/modules/inbox_ops/api/emails/[id]/reprocess/route.js.map +2 -2
- package/dist/modules/inbox_ops/api/extract/route.js +4 -0
- package/dist/modules/inbox_ops/api/extract/route.js.map +2 -2
- package/dist/modules/inbox_ops/api/webhook/inbound.js +4 -0
- package/dist/modules/inbox_ops/api/webhook/inbound.js.map +2 -2
- package/dist/modules/sales/commands/documents.js +8 -8
- package/dist/modules/sales/commands/documents.js.map +2 -2
- package/dist/modules/warranty_claims/acl.js +75 -0
- package/dist/modules/warranty_claims/acl.js.map +7 -0
- package/dist/modules/warranty_claims/ai-agents.js +161 -0
- package/dist/modules/warranty_claims/ai-agents.js.map +7 -0
- package/dist/modules/warranty_claims/ai-tools.js +591 -0
- package/dist/modules/warranty_claims/ai-tools.js.map +7 -0
- package/dist/modules/warranty_claims/api/ai/assess/route.js +304 -0
- package/dist/modules/warranty_claims/api/ai/assess/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/ai/draft-reply/route.js +127 -0
- package/dist/modules/warranty_claims/api/ai/draft-reply/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/ai/suggest/route.js +177 -0
- package/dist/modules/warranty_claims/api/ai/suggest/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/assign/route.js +124 -0
- package/dist/modules/warranty_claims/api/assign/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/assignees/route.js +97 -0
- package/dist/modules/warranty_claims/api/assignees/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/credit-memo/route.js +152 -0
- package/dist/modules/warranty_claims/api/credit-memo/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/entitlement/route.js +145 -0
- package/dist/modules/warranty_claims/api/entitlement/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/events/route.js +199 -0
- package/dist/modules/warranty_claims/api/events/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/external/claims/route.js +446 -0
- package/dist/modules/warranty_claims/api/external/claims/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/lines/route.js +258 -0
- package/dist/modules/warranty_claims/api/lines/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/openapi.js +27 -0
- package/dist/modules/warranty_claims/api/openapi.js.map +7 -0
- package/dist/modules/warranty_claims/api/portal/attachments/route.js +490 -0
- package/dist/modules/warranty_claims/api/portal/attachments/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/portal/claims/[id]/route.js +178 -0
- package/dist/modules/warranty_claims/api/portal/claims/[id]/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/portal/claims/[id]/shared.js +101 -0
- package/dist/modules/warranty_claims/api/portal/claims/[id]/shared.js.map +7 -0
- package/dist/modules/warranty_claims/api/portal/claims/[id]/submit/route.js +78 -0
- package/dist/modules/warranty_claims/api/portal/claims/[id]/submit/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/portal/claims/[id]/withdraw/route.js +81 -0
- package/dist/modules/warranty_claims/api/portal/claims/[id]/withdraw/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/portal/claims/route.js +462 -0
- package/dist/modules/warranty_claims/api/portal/claims/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/portal/events/route.js +228 -0
- package/dist/modules/warranty_claims/api/portal/events/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/portal/options/route.js +91 -0
- package/dist/modules/warranty_claims/api/portal/options/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/portal/orders/lines/route.js +172 -0
- package/dist/modules/warranty_claims/api/portal/orders/lines/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/portal/orders/route.js +151 -0
- package/dist/modules/warranty_claims/api/portal/orders/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/portal/troubleshooting/route.js +121 -0
- package/dist/modules/warranty_claims/api/portal/troubleshooting/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/receiving/route.js +176 -0
- package/dist/modules/warranty_claims/api/receiving/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/registrations/route.js +382 -0
- package/dist/modules/warranty_claims/api/registrations/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/replacement-order/route.js +150 -0
- package/dist/modules/warranty_claims/api/replacement-order/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/return-label/route.js +235 -0
- package/dist/modules/warranty_claims/api/return-label/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/risk/route.js +101 -0
- package/dist/modules/warranty_claims/api/risk/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/route.js +482 -0
- package/dist/modules/warranty_claims/api/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/sales-return/route.js +151 -0
- package/dist/modules/warranty_claims/api/sales-return/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/settings-general/route.js +195 -0
- package/dist/modules/warranty_claims/api/settings-general/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/stats/route.js +199 -0
- package/dist/modules/warranty_claims/api/stats/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/submit/route.js +120 -0
- package/dist/modules/warranty_claims/api/submit/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/transition/route.js +126 -0
- package/dist/modules/warranty_claims/api/transition/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/troubleshooting-guides/route.js +261 -0
- package/dist/modules/warranty_claims/api/troubleshooting-guides/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/vendor-policies/route.js +311 -0
- package/dist/modules/warranty_claims/api/vendor-policies/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/vendor-recovery/route.js +130 -0
- package/dist/modules/warranty_claims/api/vendor-recovery/route.js.map +7 -0
- package/dist/modules/warranty_claims/api/vendor-recovery-suggestions/route.js +153 -0
- package/dist/modules/warranty_claims/api/vendor-recovery-suggestions/route.js.map +7 -0
- package/dist/modules/warranty_claims/backend/components/AiAssessButtons.js +268 -0
- package/dist/modules/warranty_claims/backend/components/AiAssessButtons.js.map +7 -0
- package/dist/modules/warranty_claims/backend/components/ClaimStageProgress.js +54 -0
- package/dist/modules/warranty_claims/backend/components/ClaimStageProgress.js.map +7 -0
- package/dist/modules/warranty_claims/backend/components/ClaimStatusBadge.js +87 -0
- package/dist/modules/warranty_claims/backend/components/ClaimStatusBadge.js.map +7 -0
- package/dist/modules/warranty_claims/backend/components/ClaimsKpiStrip.js +120 -0
- package/dist/modules/warranty_claims/backend/components/ClaimsKpiStrip.js.map +7 -0
- package/dist/modules/warranty_claims/backend/components/EntitlementLookupBadge.js +135 -0
- package/dist/modules/warranty_claims/backend/components/EntitlementLookupBadge.js.map +7 -0
- package/dist/modules/warranty_claims/backend/components/ReceivingPanel.js +218 -0
- package/dist/modules/warranty_claims/backend/components/ReceivingPanel.js.map +7 -0
- package/dist/modules/warranty_claims/backend/components/ReturnLabelPanel.js +231 -0
- package/dist/modules/warranty_claims/backend/components/ReturnLabelPanel.js.map +7 -0
- package/dist/modules/warranty_claims/backend/components/TroubleshootingWalker.js +82 -0
- package/dist/modules/warranty_claims/backend/components/TroubleshootingWalker.js.map +7 -0
- package/dist/modules/warranty_claims/backend/components/VendorRecoverySuggestionsPanel.js +136 -0
- package/dist/modules/warranty_claims/backend/components/VendorRecoverySuggestionsPanel.js.map +7 -0
- package/dist/modules/warranty_claims/backend/components/WarrantyWorkspace.js +41 -0
- package/dist/modules/warranty_claims/backend/components/WarrantyWorkspace.js.map +7 -0
- package/dist/modules/warranty_claims/backend/components/claimReasonOptions.js +45 -0
- package/dist/modules/warranty_claims/backend/components/claimReasonOptions.js.map +7 -0
- package/dist/modules/warranty_claims/backend/components/claimSla.js +92 -0
- package/dist/modules/warranty_claims/backend/components/claimSla.js.map +7 -0
- package/dist/modules/warranty_claims/backend/components/orderLookup.js +81 -0
- package/dist/modules/warranty_claims/backend/components/orderLookup.js.map +7 -0
- package/dist/modules/warranty_claims/backend/components/productLookup.js +317 -0
- package/dist/modules/warranty_claims/backend/components/productLookup.js.map +7 -0
- package/dist/modules/warranty_claims/backend/components/useUserDisplayNames.js +61 -0
- package/dist/modules/warranty_claims/backend/components/useUserDisplayNames.js.map +7 -0
- package/dist/modules/warranty_claims/backend/page.js +1088 -0
- package/dist/modules/warranty_claims/backend/page.js.map +7 -0
- package/dist/modules/warranty_claims/backend/page.meta.js +16 -0
- package/dist/modules/warranty_claims/backend/page.meta.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/[id]/edit/page.js +427 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/[id]/edit/page.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/[id]/edit/page.meta.js +16 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/[id]/edit/page.meta.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/[id]/page.js +2101 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/[id]/page.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/[id]/page.meta.js +16 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/[id]/page.meta.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/create/page.js +1249 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/create/page.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/create/page.meta.js +16 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/create/page.meta.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/registrations/[id]/edit/page.js +110 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/registrations/[id]/edit/page.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/registrations/[id]/edit/page.meta.js +17 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/registrations/[id]/edit/page.meta.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/registrations/create/page.js +49 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/registrations/create/page.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/registrations/create/page.meta.js +17 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/registrations/create/page.meta.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/registrations/page.js +485 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/registrations/page.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/registrations/page.meta.js +19 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/registrations/page.meta.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/registrations/registrationForm.js +253 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/registrations/registrationForm.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/settings/page.js +1565 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/settings/page.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/settings/page.meta.js +19 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/settings/page.meta.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/TroubleshootingTreeBuilder.js +472 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/TroubleshootingTreeBuilder.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/[id]/edit/page.js +115 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/[id]/edit/page.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/[id]/edit/page.meta.js +19 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/[id]/edit/page.meta.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/create/page.js +54 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/create/page.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/create/page.meta.js +19 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/create/page.meta.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/page.js +414 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/page.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/page.meta.js +21 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/page.meta.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/troubleshootingGuideForm.js +171 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/troubleshootingGuideForm.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/[id]/edit/page.js +111 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/[id]/edit/page.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/[id]/edit/page.meta.js +19 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/[id]/edit/page.meta.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/create/page.js +48 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/create/page.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/create/page.meta.js +19 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/create/page.meta.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/page.js +429 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/page.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/page.meta.js +21 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/page.meta.js.map +7 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/vendorPolicyForm.js +182 -0
- package/dist/modules/warranty_claims/backend/warranty_claims/vendor-policies/vendorPolicyForm.js.map +7 -0
- package/dist/modules/warranty_claims/ce.js +48 -0
- package/dist/modules/warranty_claims/ce.js.map +7 -0
- package/dist/modules/warranty_claims/commands/claim-lines.js +911 -0
- package/dist/modules/warranty_claims/commands/claim-lines.js.map +7 -0
- package/dist/modules/warranty_claims/commands/claims.js +2577 -0
- package/dist/modules/warranty_claims/commands/claims.js.map +7 -0
- package/dist/modules/warranty_claims/commands/index.js +4 -0
- package/dist/modules/warranty_claims/commands/index.js.map +7 -0
- package/dist/modules/warranty_claims/commands/settings.js +169 -0
- package/dist/modules/warranty_claims/commands/settings.js.map +7 -0
- package/dist/modules/warranty_claims/commands/shared.js +162 -0
- package/dist/modules/warranty_claims/commands/shared.js.map +7 -0
- package/dist/modules/warranty_claims/data/constants.js +35 -0
- package/dist/modules/warranty_claims/data/constants.js.map +7 -0
- package/dist/modules/warranty_claims/data/enrichers.js +97 -0
- package/dist/modules/warranty_claims/data/enrichers.js.map +7 -0
- package/dist/modules/warranty_claims/data/entities.js +731 -0
- package/dist/modules/warranty_claims/data/entities.js.map +7 -0
- package/dist/modules/warranty_claims/data/validators.js +488 -0
- package/dist/modules/warranty_claims/data/validators.js.map +7 -0
- package/dist/modules/warranty_claims/di.js +29 -0
- package/dist/modules/warranty_claims/di.js.map +7 -0
- package/dist/modules/warranty_claims/encryption.js +28 -0
- package/dist/modules/warranty_claims/encryption.js.map +7 -0
- package/dist/modules/warranty_claims/events.js +81 -0
- package/dist/modules/warranty_claims/events.js.map +7 -0
- package/dist/modules/warranty_claims/extension-points.js +19 -0
- package/dist/modules/warranty_claims/extension-points.js.map +7 -0
- package/dist/modules/warranty_claims/frontend/[orgSlug]/portal/claims/[id]/page.js +825 -0
- package/dist/modules/warranty_claims/frontend/[orgSlug]/portal/claims/[id]/page.js.map +7 -0
- package/dist/modules/warranty_claims/frontend/[orgSlug]/portal/claims/[id]/page.meta.js +11 -0
- package/dist/modules/warranty_claims/frontend/[orgSlug]/portal/claims/[id]/page.meta.js.map +7 -0
- package/dist/modules/warranty_claims/frontend/[orgSlug]/portal/claims/new/page.js +1139 -0
- package/dist/modules/warranty_claims/frontend/[orgSlug]/portal/claims/new/page.js.map +7 -0
- package/dist/modules/warranty_claims/frontend/[orgSlug]/portal/claims/new/page.meta.js +11 -0
- package/dist/modules/warranty_claims/frontend/[orgSlug]/portal/claims/new/page.meta.js.map +7 -0
- package/dist/modules/warranty_claims/frontend/[orgSlug]/portal/claims/page.js +253 -0
- package/dist/modules/warranty_claims/frontend/[orgSlug]/portal/claims/page.js.map +7 -0
- package/dist/modules/warranty_claims/frontend/[orgSlug]/portal/claims/page.meta.js +18 -0
- package/dist/modules/warranty_claims/frontend/[orgSlug]/portal/claims/page.meta.js.map +7 -0
- package/dist/modules/warranty_claims/index.js +15 -0
- package/dist/modules/warranty_claims/index.js.map +7 -0
- package/dist/modules/warranty_claims/lib/aiAssist.js +496 -0
- package/dist/modules/warranty_claims/lib/aiAssist.js.map +7 -0
- package/dist/modules/warranty_claims/lib/apiIdsFilter.js +11 -0
- package/dist/modules/warranty_claims/lib/apiIdsFilter.js.map +7 -0
- package/dist/modules/warranty_claims/lib/assigneeNames.js +153 -0
- package/dist/modules/warranty_claims/lib/assigneeNames.js.map +7 -0
- package/dist/modules/warranty_claims/lib/attachmentVisibility.js +9 -0
- package/dist/modules/warranty_claims/lib/attachmentVisibility.js.map +7 -0
- package/dist/modules/warranty_claims/lib/bulkFeedback.js +8 -0
- package/dist/modules/warranty_claims/lib/bulkFeedback.js.map +7 -0
- package/dist/modules/warranty_claims/lib/businessHours.js +250 -0
- package/dist/modules/warranty_claims/lib/businessHours.js.map +7 -0
- package/dist/modules/warranty_claims/lib/businessHoursForm.js +146 -0
- package/dist/modules/warranty_claims/lib/businessHoursForm.js.map +7 -0
- package/dist/modules/warranty_claims/lib/claimTypeConfig.js +39 -0
- package/dist/modules/warranty_claims/lib/claimTypeConfig.js.map +7 -0
- package/dist/modules/warranty_claims/lib/decryptionSafety.js +17 -0
- package/dist/modules/warranty_claims/lib/decryptionSafety.js.map +7 -0
- package/dist/modules/warranty_claims/lib/deskFilters.js +88 -0
- package/dist/modules/warranty_claims/lib/deskFilters.js.map +7 -0
- package/dist/modules/warranty_claims/lib/dictionaries.js +157 -0
- package/dist/modules/warranty_claims/lib/dictionaries.js.map +7 -0
- package/dist/modules/warranty_claims/lib/dictionaryLabels.js +12 -0
- package/dist/modules/warranty_claims/lib/dictionaryLabels.js.map +7 -0
- package/dist/modules/warranty_claims/lib/emailIntake.js +87 -0
- package/dist/modules/warranty_claims/lib/emailIntake.js.map +7 -0
- package/dist/modules/warranty_claims/lib/escalation.js +58 -0
- package/dist/modules/warranty_claims/lib/escalation.js.map +7 -0
- package/dist/modules/warranty_claims/lib/externalIntake.js +233 -0
- package/dist/modules/warranty_claims/lib/externalIntake.js.map +7 -0
- package/dist/modules/warranty_claims/lib/grading.js +21 -0
- package/dist/modules/warranty_claims/lib/grading.js.map +7 -0
- package/dist/modules/warranty_claims/lib/listSegments.js +18 -0
- package/dist/modules/warranty_claims/lib/listSegments.js.map +7 -0
- package/dist/modules/warranty_claims/lib/orderOwnership.js +25 -0
- package/dist/modules/warranty_claims/lib/orderOwnership.js.map +7 -0
- package/dist/modules/warranty_claims/lib/portalAttachmentUpload.js +11 -0
- package/dist/modules/warranty_claims/lib/portalAttachmentUpload.js.map +7 -0
- package/dist/modules/warranty_claims/lib/portalAttachmentValidation.js +108 -0
- package/dist/modules/warranty_claims/lib/portalAttachmentValidation.js.map +7 -0
- package/dist/modules/warranty_claims/lib/portalClaimAccess.js +26 -0
- package/dist/modules/warranty_claims/lib/portalClaimAccess.js.map +7 -0
- package/dist/modules/warranty_claims/lib/quantity.js +19 -0
- package/dist/modules/warranty_claims/lib/quantity.js.map +7 -0
- package/dist/modules/warranty_claims/lib/risk.js +204 -0
- package/dist/modules/warranty_claims/lib/risk.js.map +7 -0
- package/dist/modules/warranty_claims/lib/settings.js +55 -0
- package/dist/modules/warranty_claims/lib/settings.js.map +7 -0
- package/dist/modules/warranty_claims/lib/stateMachine.js +88 -0
- package/dist/modules/warranty_claims/lib/stateMachine.js.map +7 -0
- package/dist/modules/warranty_claims/lib/timelineFilters.js +16 -0
- package/dist/modules/warranty_claims/lib/timelineFilters.js.map +7 -0
- package/dist/modules/warranty_claims/lib/triage.js +241 -0
- package/dist/modules/warranty_claims/lib/triage.js.map +7 -0
- package/dist/modules/warranty_claims/lib/troubleshooting.js +111 -0
- package/dist/modules/warranty_claims/lib/troubleshooting.js.map +7 -0
- package/dist/modules/warranty_claims/lib/tryResolve.js +11 -0
- package/dist/modules/warranty_claims/lib/tryResolve.js.map +7 -0
- package/dist/modules/warranty_claims/lib/vendorPolicyRecovery.js +101 -0
- package/dist/modules/warranty_claims/lib/vendorPolicyRecovery.js.map +7 -0
- package/dist/modules/warranty_claims/lib/warrantyPreview.js +18 -0
- package/dist/modules/warranty_claims/lib/warrantyPreview.js.map +7 -0
- package/dist/modules/warranty_claims/migrations/Migration20260703191537_warranty_claims.js +32 -0
- package/dist/modules/warranty_claims/migrations/Migration20260703191537_warranty_claims.js.map +7 -0
- package/dist/modules/warranty_claims/migrations/Migration20260704115605_warranty_claims.js +16 -0
- package/dist/modules/warranty_claims/migrations/Migration20260704115605_warranty_claims.js.map +7 -0
- package/dist/modules/warranty_claims/migrations/Migration20260704230000_warranty_claims.js +17 -0
- package/dist/modules/warranty_claims/migrations/Migration20260704230000_warranty_claims.js.map +7 -0
- package/dist/modules/warranty_claims/migrations/Migration20260705121601_warranty_claims.js +29 -0
- package/dist/modules/warranty_claims/migrations/Migration20260705121601_warranty_claims.js.map +7 -0
- package/dist/modules/warranty_claims/migrations/Migration20260709120000_warranty_claims.js +25 -0
- package/dist/modules/warranty_claims/migrations/Migration20260709120000_warranty_claims.js.map +7 -0
- package/dist/modules/warranty_claims/migrations/Migration20260710023607_warranty_claims.js +13 -0
- package/dist/modules/warranty_claims/migrations/Migration20260710023607_warranty_claims.js.map +7 -0
- package/dist/modules/warranty_claims/migrations/Migration20260716203936_warranty_claims.js +15 -0
- package/dist/modules/warranty_claims/migrations/Migration20260716203936_warranty_claims.js.map +7 -0
- package/dist/modules/warranty_claims/migrations/Migration20260717150000_warranty_claims.js +13 -0
- package/dist/modules/warranty_claims/migrations/Migration20260717150000_warranty_claims.js.map +7 -0
- package/dist/modules/warranty_claims/migrations/Migration20260719120000_warranty_claims.js +13 -0
- package/dist/modules/warranty_claims/migrations/Migration20260719120000_warranty_claims.js.map +7 -0
- package/dist/modules/warranty_claims/migrations/Migration20260813103053_warranty_claims.js +12 -0
- package/dist/modules/warranty_claims/migrations/Migration20260813103053_warranty_claims.js.map +7 -0
- package/dist/modules/warranty_claims/notifications.client.js +67 -0
- package/dist/modules/warranty_claims/notifications.client.js.map +7 -0
- package/dist/modules/warranty_claims/notifications.js +103 -0
- package/dist/modules/warranty_claims/notifications.js.map +7 -0
- package/dist/modules/warranty_claims/search.js +174 -0
- package/dist/modules/warranty_claims/search.js.map +7 -0
- package/dist/modules/warranty_claims/services/adjudicationEvaluator.js +202 -0
- package/dist/modules/warranty_claims/services/adjudicationEvaluator.js.map +7 -0
- package/dist/modules/warranty_claims/services/claimNumberGenerator.js +58 -0
- package/dist/modules/warranty_claims/services/claimNumberGenerator.js.map +7 -0
- package/dist/modules/warranty_claims/services/entitlementResolver.js +69 -0
- package/dist/modules/warranty_claims/services/entitlementResolver.js.map +7 -0
- package/dist/modules/warranty_claims/services/returnLabelProvider.js +14 -0
- package/dist/modules/warranty_claims/services/returnLabelProvider.js.map +7 -0
- package/dist/modules/warranty_claims/setup.js +121 -0
- package/dist/modules/warranty_claims/setup.js.map +7 -0
- package/dist/modules/warranty_claims/subscribers/auto-vendor-recovery.js +119 -0
- package/dist/modules/warranty_claims/subscribers/auto-vendor-recovery.js.map +7 -0
- package/dist/modules/warranty_claims/subscribers/claim-assigned-notification.js +47 -0
- package/dist/modules/warranty_claims/subscribers/claim-assigned-notification.js.map +7 -0
- package/dist/modules/warranty_claims/subscribers/claim-customer-reply-notification.js +60 -0
- package/dist/modules/warranty_claims/subscribers/claim-customer-reply-notification.js.map +7 -0
- package/dist/modules/warranty_claims/subscribers/claim-status-notification.js +83 -0
- package/dist/modules/warranty_claims/subscribers/claim-status-notification.js.map +7 -0
- package/dist/modules/warranty_claims/subscribers/claim-submitted-notification.js +46 -0
- package/dist/modules/warranty_claims/subscribers/claim-submitted-notification.js.map +7 -0
- package/dist/modules/warranty_claims/subscribers/email-to-claim.js +135 -0
- package/dist/modules/warranty_claims/subscribers/email-to-claim.js.map +7 -0
- package/dist/modules/warranty_claims/subscribers/return-shipment-tracking.js +164 -0
- package/dist/modules/warranty_claims/subscribers/return-shipment-tracking.js.map +7 -0
- package/dist/modules/warranty_claims/subscribers/vendor-recovery-reconciliation-undo.js +24 -0
- package/dist/modules/warranty_claims/subscribers/vendor-recovery-reconciliation-undo.js.map +7 -0
- package/dist/modules/warranty_claims/subscribers/vendor-recovery-reconciliation.js +26 -0
- package/dist/modules/warranty_claims/subscribers/vendor-recovery-reconciliation.js.map +7 -0
- package/dist/modules/warranty_claims/widgets/dashboard/claims-queue/config.js +15 -0
- package/dist/modules/warranty_claims/widgets/dashboard/claims-queue/config.js.map +7 -0
- package/dist/modules/warranty_claims/widgets/dashboard/claims-queue/widget.client.js +197 -0
- package/dist/modules/warranty_claims/widgets/dashboard/claims-queue/widget.client.js.map +7 -0
- package/dist/modules/warranty_claims/widgets/dashboard/claims-queue/widget.js +28 -0
- package/dist/modules/warranty_claims/widgets/dashboard/claims-queue/widget.js.map +7 -0
- package/dist/modules/warranty_claims/widgets/injection/claims-ai-trigger/widget.client.js +418 -0
- package/dist/modules/warranty_claims/widgets/injection/claims-ai-trigger/widget.client.js.map +7 -0
- package/dist/modules/warranty_claims/widgets/injection/claims-ai-trigger/widget.js +18 -0
- package/dist/modules/warranty_claims/widgets/injection/claims-ai-trigger/widget.js.map +7 -0
- package/dist/modules/warranty_claims/widgets/injection/customer-claims-tab/widget.js +17 -0
- package/dist/modules/warranty_claims/widgets/injection/customer-claims-tab/widget.js.map +7 -0
- package/dist/modules/warranty_claims/widgets/injection/customer-claims-tab.js +146 -0
- package/dist/modules/warranty_claims/widgets/injection/customer-claims-tab.js.map +7 -0
- package/dist/modules/warranty_claims/widgets/injection/order-claims-tab/widget.js +17 -0
- package/dist/modules/warranty_claims/widgets/injection/order-claims-tab/widget.js.map +7 -0
- package/dist/modules/warranty_claims/widgets/injection/order-claims-tab.js +147 -0
- package/dist/modules/warranty_claims/widgets/injection/order-claims-tab.js.map +7 -0
- package/dist/modules/warranty_claims/widgets/injection-table.js +38 -0
- package/dist/modules/warranty_claims/widgets/injection-table.js.map +7 -0
- package/dist/modules/warranty_claims/widgets/notifications/WarrantyClaimNotificationRenderer.js +223 -0
- package/dist/modules/warranty_claims/widgets/notifications/WarrantyClaimNotificationRenderer.js.map +7 -0
- package/dist/modules/warranty_claims/widgets/notifications/index.js +5 -0
- package/dist/modules/warranty_claims/widgets/notifications/index.js.map +7 -0
- package/dist/modules/warranty_claims/workers/sla-escalation-sweep.js +334 -0
- package/dist/modules/warranty_claims/workers/sla-escalation-sweep.js.map +7 -0
- package/generated/entities/warranty_claim/index.ts +51 -0
- package/generated/entities/warranty_claim_event/index.ts +11 -0
- package/generated/entities/warranty_claim_line/index.ts +37 -0
- package/generated/entities/warranty_claim_registration/index.ts +20 -0
- package/generated/entities/warranty_claim_sequence/index.ts +7 -0
- package/generated/entities/warranty_claim_settings/index.ts +20 -0
- package/generated/entities/warranty_claim_sla_signal/index.ts +11 -0
- package/generated/entities/warranty_troubleshooting_guide/index.ts +11 -0
- package/generated/entities/warranty_vendor_policy/index.ts +14 -0
- package/generated/entities.ids.generated.ts +12 -0
- package/generated/entity-fields-registry.ts +200 -0
- package/package.json +7 -7
- package/src/helpers/integration/api.ts +10 -3
- package/src/helpers/integration/salesFixtures.ts +17 -7
- package/src/modules/attachments/di.ts +30 -1
- package/src/modules/attachments/fields/attachment.tsx +215 -23
- package/src/modules/attachments/i18n/de.json +5 -0
- package/src/modules/attachments/i18n/en.json +5 -0
- package/src/modules/attachments/i18n/es.json +5 -0
- package/src/modules/attachments/i18n/ko.json +5 -0
- package/src/modules/attachments/i18n/pl.json +5 -0
- package/src/modules/attachments/lib/scoped-upload-service.ts +257 -0
- package/src/modules/attachments/lib/target-access-service.ts +57 -0
- package/src/modules/auth/api/logout.ts +46 -10
- package/src/modules/auth/api/reset/confirm.ts +7 -0
- package/src/modules/auth/api/reset.ts +7 -0
- package/src/modules/auth/commands/users.ts +22 -0
- package/src/modules/auth/events.ts +15 -0
- package/src/modules/customers/api/companies/route.ts +1 -0
- package/src/modules/customers/backend/customers/companies-v2/[id]/page.tsx +4 -2
- package/src/modules/customers/backend/customers/people-v2/[id]/page.tsx +4 -2
- package/src/modules/customers/components/detail/assignableStaff.ts +14 -177
- package/src/modules/customers/lib/assignableStaff.ts +177 -0
- package/src/modules/data_sync/AGENTS.md +3 -0
- package/src/modules/data_sync/lib/batch-stream.ts +117 -0
- package/src/modules/data_sync/lib/sync-engine.ts +190 -115
- package/src/modules/inbox_ops/api/emails/[id]/reprocess/route.ts +4 -0
- package/src/modules/inbox_ops/api/extract/route.ts +4 -0
- package/src/modules/inbox_ops/api/webhook/inbound.ts +4 -0
- package/src/modules/sales/commands/documents.ts +16 -8
- package/src/modules/warranty_claims/AGENTS.md +49 -0
- package/src/modules/warranty_claims/acl.ts +71 -0
- package/src/modules/warranty_claims/ai-agents.ts +189 -0
- package/src/modules/warranty_claims/ai-tools.ts +711 -0
- package/src/modules/warranty_claims/api/ai/assess/route.ts +371 -0
- package/src/modules/warranty_claims/api/ai/draft-reply/route.ts +149 -0
- package/src/modules/warranty_claims/api/ai/suggest/route.ts +190 -0
- package/src/modules/warranty_claims/api/assign/route.ts +142 -0
- package/src/modules/warranty_claims/api/assignees/route.ts +102 -0
- package/src/modules/warranty_claims/api/credit-memo/route.ts +191 -0
- package/src/modules/warranty_claims/api/entitlement/route.ts +224 -0
- package/src/modules/warranty_claims/api/events/route.ts +226 -0
- package/src/modules/warranty_claims/api/external/claims/route.ts +528 -0
- package/src/modules/warranty_claims/api/lines/route.ts +275 -0
- package/src/modules/warranty_claims/api/openapi.ts +28 -0
- package/src/modules/warranty_claims/api/portal/attachments/route.ts +547 -0
- package/src/modules/warranty_claims/api/portal/claims/[id]/route.ts +195 -0
- package/src/modules/warranty_claims/api/portal/claims/[id]/shared.ts +125 -0
- package/src/modules/warranty_claims/api/portal/claims/[id]/submit/route.ts +82 -0
- package/src/modules/warranty_claims/api/portal/claims/[id]/withdraw/route.ts +87 -0
- package/src/modules/warranty_claims/api/portal/claims/route.ts +579 -0
- package/src/modules/warranty_claims/api/portal/events/route.ts +260 -0
- package/src/modules/warranty_claims/api/portal/options/route.ts +113 -0
- package/src/modules/warranty_claims/api/portal/orders/lines/route.ts +258 -0
- package/src/modules/warranty_claims/api/portal/orders/route.ts +206 -0
- package/src/modules/warranty_claims/api/portal/troubleshooting/route.ts +151 -0
- package/src/modules/warranty_claims/api/receiving/route.ts +215 -0
- package/src/modules/warranty_claims/api/registrations/route.ts +417 -0
- package/src/modules/warranty_claims/api/replacement-order/route.ts +188 -0
- package/src/modules/warranty_claims/api/return-label/route.ts +291 -0
- package/src/modules/warranty_claims/api/risk/route.ts +112 -0
- package/src/modules/warranty_claims/api/route.ts +543 -0
- package/src/modules/warranty_claims/api/sales-return/route.ts +183 -0
- package/src/modules/warranty_claims/api/settings-general/route.ts +230 -0
- package/src/modules/warranty_claims/api/stats/route.ts +306 -0
- package/src/modules/warranty_claims/api/submit/route.ts +146 -0
- package/src/modules/warranty_claims/api/transition/route.ts +144 -0
- package/src/modules/warranty_claims/api/troubleshooting-guides/route.ts +295 -0
- package/src/modules/warranty_claims/api/vendor-policies/route.ts +351 -0
- package/src/modules/warranty_claims/api/vendor-recovery/route.ts +148 -0
- package/src/modules/warranty_claims/api/vendor-recovery-suggestions/route.ts +167 -0
- package/src/modules/warranty_claims/backend/components/AiAssessButtons.tsx +389 -0
- package/src/modules/warranty_claims/backend/components/ClaimStageProgress.tsx +65 -0
- package/src/modules/warranty_claims/backend/components/ClaimStatusBadge.tsx +137 -0
- package/src/modules/warranty_claims/backend/components/ClaimsKpiStrip.tsx +169 -0
- package/src/modules/warranty_claims/backend/components/EntitlementLookupBadge.tsx +203 -0
- package/src/modules/warranty_claims/backend/components/ReceivingPanel.tsx +300 -0
- package/src/modules/warranty_claims/backend/components/ReturnLabelPanel.tsx +292 -0
- package/src/modules/warranty_claims/backend/components/TroubleshootingWalker.tsx +125 -0
- package/src/modules/warranty_claims/backend/components/VendorRecoverySuggestionsPanel.tsx +217 -0
- package/src/modules/warranty_claims/backend/components/WarrantyWorkspace.tsx +66 -0
- package/src/modules/warranty_claims/backend/components/claimReasonOptions.ts +57 -0
- package/src/modules/warranty_claims/backend/components/claimSla.tsx +127 -0
- package/src/modules/warranty_claims/backend/components/orderLookup.ts +109 -0
- package/src/modules/warranty_claims/backend/components/productLookup.tsx +433 -0
- package/src/modules/warranty_claims/backend/components/useUserDisplayNames.ts +66 -0
- package/src/modules/warranty_claims/backend/page.meta.ts +12 -0
- package/src/modules/warranty_claims/backend/page.tsx +1302 -0
- package/src/modules/warranty_claims/backend/warranty_claims/[id]/edit/page.meta.ts +12 -0
- package/src/modules/warranty_claims/backend/warranty_claims/[id]/edit/page.tsx +531 -0
- package/src/modules/warranty_claims/backend/warranty_claims/[id]/page.meta.ts +12 -0
- package/src/modules/warranty_claims/backend/warranty_claims/[id]/page.tsx +2599 -0
- package/src/modules/warranty_claims/backend/warranty_claims/create/page.meta.ts +12 -0
- package/src/modules/warranty_claims/backend/warranty_claims/create/page.tsx +1533 -0
- package/src/modules/warranty_claims/backend/warranty_claims/registrations/[id]/edit/page.meta.ts +13 -0
- package/src/modules/warranty_claims/backend/warranty_claims/registrations/[id]/edit/page.tsx +136 -0
- package/src/modules/warranty_claims/backend/warranty_claims/registrations/create/page.meta.ts +13 -0
- package/src/modules/warranty_claims/backend/warranty_claims/registrations/create/page.tsx +52 -0
- package/src/modules/warranty_claims/backend/warranty_claims/registrations/page.meta.ts +15 -0
- package/src/modules/warranty_claims/backend/warranty_claims/registrations/page.tsx +555 -0
- package/src/modules/warranty_claims/backend/warranty_claims/registrations/registrationForm.tsx +295 -0
- package/src/modules/warranty_claims/backend/warranty_claims/settings/page.meta.ts +15 -0
- package/src/modules/warranty_claims/backend/warranty_claims/settings/page.tsx +1903 -0
- package/src/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/TroubleshootingTreeBuilder.tsx +550 -0
- package/src/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/[id]/edit/page.meta.ts +15 -0
- package/src/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/[id]/edit/page.tsx +141 -0
- package/src/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/create/page.meta.ts +15 -0
- package/src/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/create/page.tsx +57 -0
- package/src/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/page.meta.ts +17 -0
- package/src/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/page.tsx +477 -0
- package/src/modules/warranty_claims/backend/warranty_claims/troubleshooting-guides/troubleshootingGuideForm.tsx +214 -0
- package/src/modules/warranty_claims/backend/warranty_claims/vendor-policies/[id]/edit/page.meta.ts +15 -0
- package/src/modules/warranty_claims/backend/warranty_claims/vendor-policies/[id]/edit/page.tsx +137 -0
- package/src/modules/warranty_claims/backend/warranty_claims/vendor-policies/create/page.meta.ts +15 -0
- package/src/modules/warranty_claims/backend/warranty_claims/vendor-policies/create/page.tsx +51 -0
- package/src/modules/warranty_claims/backend/warranty_claims/vendor-policies/page.meta.ts +17 -0
- package/src/modules/warranty_claims/backend/warranty_claims/vendor-policies/page.tsx +506 -0
- package/src/modules/warranty_claims/backend/warranty_claims/vendor-policies/vendorPolicyForm.tsx +220 -0
- package/src/modules/warranty_claims/ce.ts +44 -0
- package/src/modules/warranty_claims/commands/claim-lines.ts +1082 -0
- package/src/modules/warranty_claims/commands/claims.ts +3364 -0
- package/src/modules/warranty_claims/commands/index.ts +3 -0
- package/src/modules/warranty_claims/commands/settings.ts +198 -0
- package/src/modules/warranty_claims/commands/shared.ts +212 -0
- package/src/modules/warranty_claims/data/constants.ts +37 -0
- package/src/modules/warranty_claims/data/enrichers.ts +165 -0
- package/src/modules/warranty_claims/data/entities.ts +663 -0
- package/src/modules/warranty_claims/data/validators.ts +634 -0
- package/src/modules/warranty_claims/di.ts +34 -0
- package/src/modules/warranty_claims/encryption.ts +26 -0
- package/src/modules/warranty_claims/events.ts +81 -0
- package/src/modules/warranty_claims/extension-points.ts +16 -0
- package/src/modules/warranty_claims/frontend/[orgSlug]/portal/claims/[id]/page.meta.ts +9 -0
- package/src/modules/warranty_claims/frontend/[orgSlug]/portal/claims/[id]/page.tsx +1037 -0
- package/src/modules/warranty_claims/frontend/[orgSlug]/portal/claims/new/page.meta.ts +9 -0
- package/src/modules/warranty_claims/frontend/[orgSlug]/portal/claims/new/page.tsx +1409 -0
- package/src/modules/warranty_claims/frontend/[orgSlug]/portal/claims/page.meta.ts +16 -0
- package/src/modules/warranty_claims/frontend/[orgSlug]/portal/claims/page.tsx +304 -0
- package/src/modules/warranty_claims/i18n/de.json +1270 -0
- package/src/modules/warranty_claims/i18n/en.json +1270 -0
- package/src/modules/warranty_claims/i18n/es.json +1270 -0
- package/src/modules/warranty_claims/i18n/ko.json +1270 -0
- package/src/modules/warranty_claims/i18n/pl.json +1270 -0
- package/src/modules/warranty_claims/index.ts +13 -0
- package/src/modules/warranty_claims/lib/aiAssist.ts +677 -0
- package/src/modules/warranty_claims/lib/apiIdsFilter.ts +12 -0
- package/src/modules/warranty_claims/lib/assigneeNames.ts +184 -0
- package/src/modules/warranty_claims/lib/attachmentVisibility.ts +5 -0
- package/src/modules/warranty_claims/lib/bulkFeedback.ts +6 -0
- package/src/modules/warranty_claims/lib/businessHours.ts +333 -0
- package/src/modules/warranty_claims/lib/businessHoursForm.ts +206 -0
- package/src/modules/warranty_claims/lib/claimTypeConfig.ts +49 -0
- package/src/modules/warranty_claims/lib/decryptionSafety.ts +19 -0
- package/src/modules/warranty_claims/lib/deskFilters.ts +131 -0
- package/src/modules/warranty_claims/lib/dictionaries.ts +212 -0
- package/src/modules/warranty_claims/lib/dictionaryLabels.ts +16 -0
- package/src/modules/warranty_claims/lib/emailIntake.ts +123 -0
- package/src/modules/warranty_claims/lib/escalation.ts +83 -0
- package/src/modules/warranty_claims/lib/externalIntake.ts +362 -0
- package/src/modules/warranty_claims/lib/grading.ts +23 -0
- package/src/modules/warranty_claims/lib/listSegments.ts +19 -0
- package/src/modules/warranty_claims/lib/orderOwnership.ts +58 -0
- package/src/modules/warranty_claims/lib/portalAttachmentUpload.ts +11 -0
- package/src/modules/warranty_claims/lib/portalAttachmentValidation.ts +115 -0
- package/src/modules/warranty_claims/lib/portalClaimAccess.ts +37 -0
- package/src/modules/warranty_claims/lib/quantity.ts +15 -0
- package/src/modules/warranty_claims/lib/risk.ts +371 -0
- package/src/modules/warranty_claims/lib/settings.ts +76 -0
- package/src/modules/warranty_claims/lib/stateMachine.ts +130 -0
- package/src/modules/warranty_claims/lib/timelineFilters.ts +22 -0
- package/src/modules/warranty_claims/lib/triage.ts +366 -0
- package/src/modules/warranty_claims/lib/troubleshooting.ts +157 -0
- package/src/modules/warranty_claims/lib/tryResolve.ts +7 -0
- package/src/modules/warranty_claims/lib/vendorPolicyRecovery.ts +182 -0
- package/src/modules/warranty_claims/lib/warrantyPreview.ts +20 -0
- package/src/modules/warranty_claims/migrations/.snapshot-open-mercato.json +3525 -0
- package/src/modules/warranty_claims/migrations/Migration20260703191537_warranty_claims.ts +38 -0
- package/src/modules/warranty_claims/migrations/Migration20260704115605_warranty_claims.ts +17 -0
- package/src/modules/warranty_claims/migrations/Migration20260704230000_warranty_claims.ts +17 -0
- package/src/modules/warranty_claims/migrations/Migration20260705121601_warranty_claims.ts +37 -0
- package/src/modules/warranty_claims/migrations/Migration20260709120000_warranty_claims.ts +25 -0
- package/src/modules/warranty_claims/migrations/Migration20260710023607_warranty_claims.ts +13 -0
- package/src/modules/warranty_claims/migrations/Migration20260716203936_warranty_claims.ts +15 -0
- package/src/modules/warranty_claims/migrations/Migration20260717150000_warranty_claims.ts +13 -0
- package/src/modules/warranty_claims/migrations/Migration20260719120000_warranty_claims.ts +13 -0
- package/src/modules/warranty_claims/migrations/Migration20260813103053_warranty_claims.ts +11 -0
- package/src/modules/warranty_claims/notifications.client.ts +78 -0
- package/src/modules/warranty_claims/notifications.ts +101 -0
- package/src/modules/warranty_claims/search.ts +199 -0
- package/src/modules/warranty_claims/services/adjudicationEvaluator.ts +344 -0
- package/src/modules/warranty_claims/services/claimNumberGenerator.ts +69 -0
- package/src/modules/warranty_claims/services/entitlementResolver.ts +102 -0
- package/src/modules/warranty_claims/services/returnLabelProvider.ts +30 -0
- package/src/modules/warranty_claims/setup.ts +154 -0
- package/src/modules/warranty_claims/subscribers/auto-vendor-recovery.ts +140 -0
- package/src/modules/warranty_claims/subscribers/claim-assigned-notification.ts +54 -0
- package/src/modules/warranty_claims/subscribers/claim-customer-reply-notification.ts +68 -0
- package/src/modules/warranty_claims/subscribers/claim-status-notification.ts +100 -0
- package/src/modules/warranty_claims/subscribers/claim-submitted-notification.ts +53 -0
- package/src/modules/warranty_claims/subscribers/email-to-claim.ts +175 -0
- package/src/modules/warranty_claims/subscribers/return-shipment-tracking.ts +226 -0
- package/src/modules/warranty_claims/subscribers/vendor-recovery-reconciliation-undo.ts +28 -0
- package/src/modules/warranty_claims/subscribers/vendor-recovery-reconciliation.ts +31 -0
- package/src/modules/warranty_claims/widgets/dashboard/claims-queue/config.ts +15 -0
- package/src/modules/warranty_claims/widgets/dashboard/claims-queue/widget.client.tsx +237 -0
- package/src/modules/warranty_claims/widgets/dashboard/claims-queue/widget.ts +27 -0
- package/src/modules/warranty_claims/widgets/injection/claims-ai-trigger/widget.client.tsx +527 -0
- package/src/modules/warranty_claims/widgets/injection/claims-ai-trigger/widget.ts +37 -0
- package/src/modules/warranty_claims/widgets/injection/customer-claims-tab/widget.ts +21 -0
- package/src/modules/warranty_claims/widgets/injection/customer-claims-tab.tsx +210 -0
- package/src/modules/warranty_claims/widgets/injection/order-claims-tab/widget.ts +21 -0
- package/src/modules/warranty_claims/widgets/injection/order-claims-tab.tsx +210 -0
- package/src/modules/warranty_claims/widgets/injection-table.ts +36 -0
- package/src/modules/warranty_claims/widgets/notifications/WarrantyClaimNotificationRenderer.tsx +253 -0
- package/src/modules/warranty_claims/widgets/notifications/index.ts +1 -0
- package/src/modules/warranty_claims/workers/sla-escalation-sweep.ts +450 -0
|
@@ -0,0 +1,1565 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { ChevronDown, ChevronRight, Plus, RefreshCw, Save, Trash2 } from "lucide-react";
|
|
5
|
+
import { Page, PageBody } from "@open-mercato/ui/backend/Page";
|
|
6
|
+
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@open-mercato/ui/primitives/dialog";
|
|
7
|
+
import { flash } from "@open-mercato/ui/backend/FlashMessages";
|
|
8
|
+
import { useConfirmDialog } from "@open-mercato/ui/backend/confirm-dialog";
|
|
9
|
+
import { LoadingMessage, ErrorMessage } from "@open-mercato/ui/backend/detail";
|
|
10
|
+
import { apiCall, readApiResultOrThrow, withScopedApiRequestHeaders } from "@open-mercato/ui/backend/utils/apiCall";
|
|
11
|
+
import { buildOptimisticLockHeader } from "@open-mercato/ui/backend/utils/optimisticLock";
|
|
12
|
+
import { surfaceRecordConflict } from "@open-mercato/ui/backend/conflicts";
|
|
13
|
+
import { raiseCrudError } from "@open-mercato/ui/backend/utils/serverErrors";
|
|
14
|
+
import { useGuardedMutation } from "@open-mercato/ui/backend/injection/useGuardedMutation";
|
|
15
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
16
|
+
import { Checkbox } from "@open-mercato/ui/primitives/checkbox";
|
|
17
|
+
import { IconButton } from "@open-mercato/ui/primitives/icon-button";
|
|
18
|
+
import { Input } from "@open-mercato/ui/primitives/input";
|
|
19
|
+
import { Label } from "@open-mercato/ui/primitives/label";
|
|
20
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@open-mercato/ui/primitives/select";
|
|
21
|
+
import { Switch } from "@open-mercato/ui/primitives/switch";
|
|
22
|
+
import { Textarea } from "@open-mercato/ui/primitives/textarea";
|
|
23
|
+
import { ComboboxInput } from "@open-mercato/ui/backend/inputs/ComboboxInput";
|
|
24
|
+
import { useOrganizationScopeVersion } from "@open-mercato/shared/lib/frontend/useOrganizationScope";
|
|
25
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
26
|
+
import { ICON_SUGGESTIONS } from "@open-mercato/core/modules/dictionaries/components/dictionaryAppearance";
|
|
27
|
+
import {
|
|
28
|
+
DictionaryForm
|
|
29
|
+
} from "@open-mercato/core/modules/dictionaries/components/DictionaryForm";
|
|
30
|
+
import {
|
|
31
|
+
DictionaryTable
|
|
32
|
+
} from "@open-mercato/core/modules/dictionaries/components/DictionaryTable";
|
|
33
|
+
import {
|
|
34
|
+
fetchAssignableStaffMembersPage
|
|
35
|
+
} from "@open-mercato/core/modules/customers/lib/assignableStaff";
|
|
36
|
+
import { localizeDictionaryLabel } from "../../../lib/dictionaryLabels.js";
|
|
37
|
+
import { parseEscalationTiers } from "../../../lib/escalation.js";
|
|
38
|
+
import {
|
|
39
|
+
buildBusinessHoursFormValue,
|
|
40
|
+
createBusinessHoursIntervalRow,
|
|
41
|
+
nextBusinessHoursRowKey,
|
|
42
|
+
serializeBusinessHoursRecord,
|
|
43
|
+
stringifyJsonValue,
|
|
44
|
+
validateBusinessHoursValue
|
|
45
|
+
} from "../../../lib/businessHoursForm.js";
|
|
46
|
+
const DEFAULT_FORM_VALUES = {
|
|
47
|
+
value: "",
|
|
48
|
+
label: "",
|
|
49
|
+
color: null,
|
|
50
|
+
icon: null
|
|
51
|
+
};
|
|
52
|
+
const SAVE_CONTEXT_ID = "warranty-claims-settings";
|
|
53
|
+
const GENERAL_SETTINGS_FORM_ID = "warranty-claims-general-settings";
|
|
54
|
+
const QUARANTINE_GRADE_OPTIONS = ["A", "B", "C", "D"];
|
|
55
|
+
const DEFAULT_GENERAL_SETTINGS = {
|
|
56
|
+
slaHours: 48,
|
|
57
|
+
slaPauseOnInfoRequested: true,
|
|
58
|
+
slaAtRiskThresholdPct: 75,
|
|
59
|
+
defaultWarrantyMonths: null,
|
|
60
|
+
returnWindowDays: null,
|
|
61
|
+
autoApproveEnabled: false,
|
|
62
|
+
autoApproveMaxAmount: null,
|
|
63
|
+
autoApproveCurrencyCode: null,
|
|
64
|
+
autoApproveRequireInWarranty: true,
|
|
65
|
+
updatedAt: null,
|
|
66
|
+
businessHours: null,
|
|
67
|
+
escalationTiers: null,
|
|
68
|
+
adjudicationUseRules: false,
|
|
69
|
+
quarantineGrades: null,
|
|
70
|
+
returnLabelProvider: null
|
|
71
|
+
};
|
|
72
|
+
const DICTIONARY_LABEL_KINDS = {
|
|
73
|
+
"warranty-claim-fault-code": "fault",
|
|
74
|
+
"warranty-claim-reason": "reason",
|
|
75
|
+
"warranty-claim-rejection-reason": "rejection"
|
|
76
|
+
};
|
|
77
|
+
const SECTIONS = [
|
|
78
|
+
{
|
|
79
|
+
kind: "warranty-claim-fault-code",
|
|
80
|
+
dictionaryKey: "warranty_claims.warranty_claim_fault_code",
|
|
81
|
+
titleKey: "warranty_claims.settings.dictionary.faultCodes",
|
|
82
|
+
descriptionKey: "warranty_claims.settings.dictionary.faultCodes.description"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
kind: "warranty-claim-reason",
|
|
86
|
+
dictionaryKey: "warranty_claims.warranty_claim_reason",
|
|
87
|
+
titleKey: "warranty_claims.settings.dictionary.claimReasons",
|
|
88
|
+
descriptionKey: "warranty_claims.settings.dictionary.claimReasons.description"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
kind: "warranty-claim-rejection-reason",
|
|
92
|
+
dictionaryKey: "warranty_claims.warranty_claim_rejection_reason",
|
|
93
|
+
titleKey: "warranty_claims.settings.dictionary.rejectionReasons",
|
|
94
|
+
descriptionKey: "warranty_claims.settings.dictionary.rejectionReasons.description"
|
|
95
|
+
}
|
|
96
|
+
];
|
|
97
|
+
function isRecord(value) {
|
|
98
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
99
|
+
}
|
|
100
|
+
function toStringOrNull(value) {
|
|
101
|
+
return typeof value === "string" && value.trim().length ? value.trim() : null;
|
|
102
|
+
}
|
|
103
|
+
function parseNullableJsonObject(value) {
|
|
104
|
+
const trimmed = value.trim();
|
|
105
|
+
if (!trimmed) return { ok: true, value: null };
|
|
106
|
+
try {
|
|
107
|
+
const parsed = JSON.parse(trimmed);
|
|
108
|
+
if (isRecord(parsed)) return { ok: true, value: parsed };
|
|
109
|
+
} catch {
|
|
110
|
+
return { ok: false };
|
|
111
|
+
}
|
|
112
|
+
return { ok: false };
|
|
113
|
+
}
|
|
114
|
+
let escalationTierRowSeq = 0;
|
|
115
|
+
function nextEscalationTierRowKey() {
|
|
116
|
+
escalationTierRowSeq += 1;
|
|
117
|
+
return `escalation-tier-${escalationTierRowSeq}`;
|
|
118
|
+
}
|
|
119
|
+
function buildEscalationTierRows(raw) {
|
|
120
|
+
return parseEscalationTiers(raw).map((tier) => ({
|
|
121
|
+
key: nextEscalationTierRowKey(),
|
|
122
|
+
atPct: String(tier.atPct),
|
|
123
|
+
action: tier.action,
|
|
124
|
+
toUserId: tier.toUserId ?? ""
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
const ESCALATION_TIER_MIN_PCT = 1;
|
|
128
|
+
const ESCALATION_TIER_MAX_PCT = 1e3;
|
|
129
|
+
function validateEscalationTierRows(rows, translations) {
|
|
130
|
+
const rowErrors = {};
|
|
131
|
+
const parsed = [];
|
|
132
|
+
for (const row of rows) {
|
|
133
|
+
const atPctNumber = Number(row.atPct);
|
|
134
|
+
const rowError = {};
|
|
135
|
+
if (!Number.isInteger(atPctNumber) || atPctNumber < ESCALATION_TIER_MIN_PCT || atPctNumber > ESCALATION_TIER_MAX_PCT) {
|
|
136
|
+
rowError.atPct = translations.error.atPct;
|
|
137
|
+
}
|
|
138
|
+
const toUserId = row.toUserId.trim();
|
|
139
|
+
if (row.action === "reassign" && !toUserId) {
|
|
140
|
+
rowError.toUserId = translations.error.toUserId;
|
|
141
|
+
}
|
|
142
|
+
if (Object.keys(rowError).length) {
|
|
143
|
+
rowErrors[row.key] = rowError;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
parsed.push(row.action === "reassign" ? { atPct: atPctNumber, action: row.action, toUserId } : { atPct: atPctNumber, action: row.action });
|
|
147
|
+
}
|
|
148
|
+
if (Object.keys(rowErrors).length) return { ok: false, rowErrors };
|
|
149
|
+
const sorted = [...parsed].sort((left, right) => left.atPct - right.atPct);
|
|
150
|
+
return { ok: true, value: sorted.length ? sorted : null };
|
|
151
|
+
}
|
|
152
|
+
function normalizeEntry(item) {
|
|
153
|
+
if (!isRecord(item)) return null;
|
|
154
|
+
const id = toStringOrNull(item.id);
|
|
155
|
+
const value = toStringOrNull(item.value);
|
|
156
|
+
if (!id || !value) return null;
|
|
157
|
+
return {
|
|
158
|
+
id,
|
|
159
|
+
value,
|
|
160
|
+
label: toStringOrNull(item.label) ?? value,
|
|
161
|
+
color: toStringOrNull(item.color),
|
|
162
|
+
icon: toStringOrNull(item.icon),
|
|
163
|
+
organizationId: toStringOrNull(item.organizationId),
|
|
164
|
+
tenantId: toStringOrNull(item.tenantId),
|
|
165
|
+
isInherited: item.isInherited === true,
|
|
166
|
+
createdAt: toStringOrNull(item.createdAt),
|
|
167
|
+
updatedAt: toStringOrNull(item.updatedAt)
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function buildGeneralFormValues(settings) {
|
|
171
|
+
return {
|
|
172
|
+
slaHours: String(settings.slaHours),
|
|
173
|
+
slaPauseOnInfoRequested: settings.slaPauseOnInfoRequested,
|
|
174
|
+
slaAtRiskThresholdPct: String(settings.slaAtRiskThresholdPct),
|
|
175
|
+
autoApproveEnabled: settings.autoApproveEnabled,
|
|
176
|
+
autoApproveMaxAmount: settings.autoApproveMaxAmount === null ? "" : String(settings.autoApproveMaxAmount),
|
|
177
|
+
autoApproveCurrencyCode: settings.autoApproveCurrencyCode ?? "",
|
|
178
|
+
autoApproveRequireInWarranty: settings.autoApproveRequireInWarranty,
|
|
179
|
+
defaultWarrantyMonths: settings.defaultWarrantyMonths === null ? "" : String(settings.defaultWarrantyMonths),
|
|
180
|
+
returnWindowDays: settings.returnWindowDays === null ? "" : String(settings.returnWindowDays),
|
|
181
|
+
businessHours: buildBusinessHoursFormValue(settings.businessHours),
|
|
182
|
+
escalationTiers: buildEscalationTierRows(settings.escalationTiers),
|
|
183
|
+
adjudicationUseRules: settings.adjudicationUseRules,
|
|
184
|
+
quarantineGrades: settings.quarantineGrades ?? [],
|
|
185
|
+
returnLabelProvider: settings.returnLabelProvider ?? ""
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
function normalizeCurrencyCodeInput(value) {
|
|
189
|
+
return value.toUpperCase().replace(/[^A-Z]/g, "").slice(0, 3);
|
|
190
|
+
}
|
|
191
|
+
function translateApiErrorMessage(call, fallbackMessage, translate) {
|
|
192
|
+
const payload = isRecord(call.result) ? call.result : {};
|
|
193
|
+
const message = typeof payload.error === "string" ? payload.error : null;
|
|
194
|
+
if (!message) return fallbackMessage;
|
|
195
|
+
if (message === "warranty_claims.errors.autoApproveConfigIncomplete") {
|
|
196
|
+
return translate(message, "Auto-approve requires both a maximum amount and currency.");
|
|
197
|
+
}
|
|
198
|
+
if (message.startsWith("warranty_claims.")) return translate(message, fallbackMessage);
|
|
199
|
+
return message;
|
|
200
|
+
}
|
|
201
|
+
function buildConflictError(call, fallbackMessage, translate) {
|
|
202
|
+
const payload = isRecord(call.result) ? call.result : {};
|
|
203
|
+
const message = translate ? translateApiErrorMessage(call, fallbackMessage, translate) : typeof payload.error === "string" ? payload.error : fallbackMessage;
|
|
204
|
+
return Object.assign(new Error(message), { status: call.status }, payload);
|
|
205
|
+
}
|
|
206
|
+
function GeneralNumberField({
|
|
207
|
+
id,
|
|
208
|
+
label,
|
|
209
|
+
description,
|
|
210
|
+
value,
|
|
211
|
+
min,
|
|
212
|
+
max,
|
|
213
|
+
step = "1",
|
|
214
|
+
disabled,
|
|
215
|
+
onChange
|
|
216
|
+
}) {
|
|
217
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
218
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: id, children: label }),
|
|
219
|
+
/* @__PURE__ */ jsx(
|
|
220
|
+
Input,
|
|
221
|
+
{
|
|
222
|
+
id,
|
|
223
|
+
type: "number",
|
|
224
|
+
min,
|
|
225
|
+
max,
|
|
226
|
+
step,
|
|
227
|
+
value,
|
|
228
|
+
disabled,
|
|
229
|
+
onChange: (event) => onChange(event.target.value)
|
|
230
|
+
}
|
|
231
|
+
),
|
|
232
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: description })
|
|
233
|
+
] });
|
|
234
|
+
}
|
|
235
|
+
function GeneralTextField({
|
|
236
|
+
id,
|
|
237
|
+
label,
|
|
238
|
+
description,
|
|
239
|
+
value,
|
|
240
|
+
maxLength,
|
|
241
|
+
disabled,
|
|
242
|
+
onChange
|
|
243
|
+
}) {
|
|
244
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
245
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: id, children: label }),
|
|
246
|
+
/* @__PURE__ */ jsx(
|
|
247
|
+
Input,
|
|
248
|
+
{
|
|
249
|
+
id,
|
|
250
|
+
value,
|
|
251
|
+
maxLength,
|
|
252
|
+
disabled,
|
|
253
|
+
onChange: (event) => onChange(event.target.value)
|
|
254
|
+
}
|
|
255
|
+
),
|
|
256
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: description })
|
|
257
|
+
] });
|
|
258
|
+
}
|
|
259
|
+
function GeneralSwitchField({
|
|
260
|
+
id,
|
|
261
|
+
label,
|
|
262
|
+
description,
|
|
263
|
+
checked,
|
|
264
|
+
disabled,
|
|
265
|
+
onCheckedChange
|
|
266
|
+
}) {
|
|
267
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-4 rounded-lg border border-border bg-background px-4 py-3", children: [
|
|
268
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
269
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: id, children: label }),
|
|
270
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: description })
|
|
271
|
+
] }),
|
|
272
|
+
/* @__PURE__ */ jsx(
|
|
273
|
+
Switch,
|
|
274
|
+
{
|
|
275
|
+
id,
|
|
276
|
+
checked,
|
|
277
|
+
disabled,
|
|
278
|
+
"aria-label": label,
|
|
279
|
+
onCheckedChange
|
|
280
|
+
}
|
|
281
|
+
)
|
|
282
|
+
] });
|
|
283
|
+
}
|
|
284
|
+
function BusinessHoursField({
|
|
285
|
+
id,
|
|
286
|
+
label,
|
|
287
|
+
description,
|
|
288
|
+
value,
|
|
289
|
+
rowErrors,
|
|
290
|
+
error,
|
|
291
|
+
disabled,
|
|
292
|
+
translations,
|
|
293
|
+
onChange
|
|
294
|
+
}) {
|
|
295
|
+
const [advancedOpen, setAdvancedOpen] = React.useState(false);
|
|
296
|
+
const advancedVisible = advancedOpen || value.rawDirty;
|
|
297
|
+
const controlsDisabled = disabled || value.rawDirty;
|
|
298
|
+
const advancedRegionId = `${id}-advanced`;
|
|
299
|
+
const timezoneOptions = React.useMemo(() => {
|
|
300
|
+
const zones = typeof Intl.supportedValuesOf === "function" ? Intl.supportedValuesOf("timeZone") : [];
|
|
301
|
+
return Array.from(/* @__PURE__ */ new Set(["UTC", ...zones])).map((zone) => ({ value: zone, label: zone }));
|
|
302
|
+
}, []);
|
|
303
|
+
const applyStructuredChange = React.useCallback((patch) => {
|
|
304
|
+
const next = { ...value, ...patch };
|
|
305
|
+
onChange({ ...next, raw: stringifyJsonValue(serializeBusinessHoursRecord(next)), rawDirty: false });
|
|
306
|
+
}, [onChange, value]);
|
|
307
|
+
const handleRawChange = React.useCallback((text) => {
|
|
308
|
+
const parsed = parseNullableJsonObject(text);
|
|
309
|
+
if (!parsed.ok) {
|
|
310
|
+
onChange({ ...value, raw: text, rawDirty: true });
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
onChange({ ...buildBusinessHoursFormValue(parsed.value), raw: text });
|
|
314
|
+
}, [onChange, value]);
|
|
315
|
+
const toggleDay = React.useCallback((weekday, enabled) => {
|
|
316
|
+
applyStructuredChange({
|
|
317
|
+
days: value.days.map((day) => day.weekday === weekday ? { ...day, enabled } : day)
|
|
318
|
+
});
|
|
319
|
+
}, [applyStructuredChange, value.days]);
|
|
320
|
+
const updateInterval = React.useCallback((weekday, key, patch) => {
|
|
321
|
+
applyStructuredChange({
|
|
322
|
+
days: value.days.map((day) => day.weekday === weekday ? { ...day, intervals: day.intervals.map((interval) => interval.key === key ? { ...interval, ...patch } : interval) } : day)
|
|
323
|
+
});
|
|
324
|
+
}, [applyStructuredChange, value.days]);
|
|
325
|
+
const addInterval = React.useCallback((weekday) => {
|
|
326
|
+
applyStructuredChange({
|
|
327
|
+
days: value.days.map((day) => day.weekday === weekday ? { ...day, intervals: [...day.intervals, createBusinessHoursIntervalRow("", "")] } : day)
|
|
328
|
+
});
|
|
329
|
+
}, [applyStructuredChange, value.days]);
|
|
330
|
+
const removeInterval = React.useCallback((weekday, key) => {
|
|
331
|
+
applyStructuredChange({
|
|
332
|
+
days: value.days.map((day) => day.weekday === weekday ? { ...day, intervals: day.intervals.filter((interval) => interval.key !== key) } : day)
|
|
333
|
+
});
|
|
334
|
+
}, [applyStructuredChange, value.days]);
|
|
335
|
+
const addHoliday = React.useCallback(() => {
|
|
336
|
+
applyStructuredChange({
|
|
337
|
+
holidays: [...value.holidays, { key: nextBusinessHoursRowKey(), date: "" }]
|
|
338
|
+
});
|
|
339
|
+
}, [applyStructuredChange, value.holidays]);
|
|
340
|
+
const updateHoliday = React.useCallback((key, date) => {
|
|
341
|
+
applyStructuredChange({
|
|
342
|
+
holidays: value.holidays.map((row) => row.key === key ? { ...row, date } : row)
|
|
343
|
+
});
|
|
344
|
+
}, [applyStructuredChange, value.holidays]);
|
|
345
|
+
const removeHoliday = React.useCallback((key) => {
|
|
346
|
+
applyStructuredChange({
|
|
347
|
+
holidays: value.holidays.filter((row) => row.key !== key)
|
|
348
|
+
});
|
|
349
|
+
}, [applyStructuredChange, value.holidays]);
|
|
350
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
351
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
352
|
+
/* @__PURE__ */ jsx("h4", { className: "text-sm font-medium", children: label }),
|
|
353
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: description })
|
|
354
|
+
] }),
|
|
355
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2 sm:max-w-sm", children: [
|
|
356
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-timezone`, children: translations.timezoneLabel }),
|
|
357
|
+
/* @__PURE__ */ jsx(
|
|
358
|
+
ComboboxInput,
|
|
359
|
+
{
|
|
360
|
+
value: value.timezone,
|
|
361
|
+
onChange: (timezone) => applyStructuredChange({ timezone }),
|
|
362
|
+
placeholder: translations.timezonePlaceholder,
|
|
363
|
+
suggestions: timezoneOptions,
|
|
364
|
+
allowCustomValues: true,
|
|
365
|
+
clearable: true,
|
|
366
|
+
disabled: controlsDisabled
|
|
367
|
+
}
|
|
368
|
+
),
|
|
369
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: translations.timezoneHelp })
|
|
370
|
+
] }),
|
|
371
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: value.days.map((day) => {
|
|
372
|
+
const dayCheckboxId = `${id}-${day.weekday}-enabled`;
|
|
373
|
+
return /* @__PURE__ */ jsx("div", { className: "rounded-md border border-border bg-background p-3", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-start gap-4", children: [
|
|
374
|
+
/* @__PURE__ */ jsxs("div", { className: "flex w-28 items-center gap-2 pt-1.5", children: [
|
|
375
|
+
/* @__PURE__ */ jsx(
|
|
376
|
+
Checkbox,
|
|
377
|
+
{
|
|
378
|
+
id: dayCheckboxId,
|
|
379
|
+
checked: day.enabled,
|
|
380
|
+
disabled: controlsDisabled,
|
|
381
|
+
onCheckedChange: (checked) => toggleDay(day.weekday, checked === true)
|
|
382
|
+
}
|
|
383
|
+
),
|
|
384
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: dayCheckboxId, className: "text-sm font-normal", children: translations.dayLabels[day.weekday] })
|
|
385
|
+
] }),
|
|
386
|
+
day.enabled ? /* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-2", children: [
|
|
387
|
+
day.intervals.map((interval) => {
|
|
388
|
+
const intervalError = rowErrors?.[interval.key];
|
|
389
|
+
const startInputId = `${id}-${day.weekday}-${interval.key}-start`;
|
|
390
|
+
const endInputId = `${id}-${day.weekday}-${interval.key}-end`;
|
|
391
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
392
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
|
|
393
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
394
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: startInputId, className: "text-xs text-muted-foreground", children: translations.startLabel }),
|
|
395
|
+
/* @__PURE__ */ jsx(
|
|
396
|
+
Input,
|
|
397
|
+
{
|
|
398
|
+
id: startInputId,
|
|
399
|
+
type: "time",
|
|
400
|
+
className: "w-32",
|
|
401
|
+
value: interval.start,
|
|
402
|
+
disabled: controlsDisabled,
|
|
403
|
+
"aria-invalid": intervalError ? true : void 0,
|
|
404
|
+
onChange: (event) => updateInterval(day.weekday, interval.key, { start: event.target.value })
|
|
405
|
+
}
|
|
406
|
+
)
|
|
407
|
+
] }),
|
|
408
|
+
/* @__PURE__ */ jsx("span", { className: "pb-2 text-sm text-muted-foreground", "aria-hidden": "true", children: "\u2013" }),
|
|
409
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
410
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: endInputId, className: "text-xs text-muted-foreground", children: translations.endLabel }),
|
|
411
|
+
/* @__PURE__ */ jsx(
|
|
412
|
+
Input,
|
|
413
|
+
{
|
|
414
|
+
id: endInputId,
|
|
415
|
+
type: "time",
|
|
416
|
+
className: "w-32",
|
|
417
|
+
value: interval.end,
|
|
418
|
+
disabled: controlsDisabled,
|
|
419
|
+
"aria-invalid": intervalError ? true : void 0,
|
|
420
|
+
onChange: (event) => updateInterval(day.weekday, interval.key, { end: event.target.value })
|
|
421
|
+
}
|
|
422
|
+
)
|
|
423
|
+
] }),
|
|
424
|
+
day.intervals.length > 1 ? /* @__PURE__ */ jsx(
|
|
425
|
+
IconButton,
|
|
426
|
+
{
|
|
427
|
+
type: "button",
|
|
428
|
+
variant: "ghost",
|
|
429
|
+
size: "sm",
|
|
430
|
+
"aria-label": translations.removeWindow,
|
|
431
|
+
disabled: controlsDisabled,
|
|
432
|
+
onClick: () => removeInterval(day.weekday, interval.key),
|
|
433
|
+
children: /* @__PURE__ */ jsx(Trash2, { className: "size-4", "aria-hidden": "true" })
|
|
434
|
+
}
|
|
435
|
+
) : null
|
|
436
|
+
] }),
|
|
437
|
+
intervalError ? /* @__PURE__ */ jsx("p", { className: "text-sm text-status-error-text", children: intervalError }) : null
|
|
438
|
+
] }, interval.key);
|
|
439
|
+
}),
|
|
440
|
+
/* @__PURE__ */ jsxs(
|
|
441
|
+
Button,
|
|
442
|
+
{
|
|
443
|
+
type: "button",
|
|
444
|
+
variant: "outline",
|
|
445
|
+
size: "sm",
|
|
446
|
+
disabled: controlsDisabled,
|
|
447
|
+
onClick: () => addInterval(day.weekday),
|
|
448
|
+
children: [
|
|
449
|
+
/* @__PURE__ */ jsx(Plus, { className: "size-4", "aria-hidden": "true" }),
|
|
450
|
+
translations.addWindow
|
|
451
|
+
]
|
|
452
|
+
}
|
|
453
|
+
)
|
|
454
|
+
] }) : /* @__PURE__ */ jsx("p", { className: "pt-1.5 text-sm text-muted-foreground", children: translations.closed })
|
|
455
|
+
] }) }, day.weekday);
|
|
456
|
+
}) }),
|
|
457
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
458
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
459
|
+
/* @__PURE__ */ jsx(Label, { children: translations.holidaysLabel }),
|
|
460
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: translations.holidaysHelp })
|
|
461
|
+
] }),
|
|
462
|
+
value.holidays.map((row) => {
|
|
463
|
+
const holidayError = rowErrors?.[row.key];
|
|
464
|
+
const holidayInputId = `${id}-${row.key}-holiday`;
|
|
465
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
466
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
|
|
467
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
468
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: holidayInputId, className: "text-xs text-muted-foreground", children: translations.holidayDateLabel }),
|
|
469
|
+
/* @__PURE__ */ jsx(
|
|
470
|
+
Input,
|
|
471
|
+
{
|
|
472
|
+
id: holidayInputId,
|
|
473
|
+
type: "date",
|
|
474
|
+
className: "w-44",
|
|
475
|
+
value: row.date,
|
|
476
|
+
disabled: controlsDisabled,
|
|
477
|
+
"aria-invalid": holidayError ? true : void 0,
|
|
478
|
+
onChange: (event) => updateHoliday(row.key, event.target.value)
|
|
479
|
+
}
|
|
480
|
+
)
|
|
481
|
+
] }),
|
|
482
|
+
/* @__PURE__ */ jsx(
|
|
483
|
+
IconButton,
|
|
484
|
+
{
|
|
485
|
+
type: "button",
|
|
486
|
+
variant: "ghost",
|
|
487
|
+
size: "sm",
|
|
488
|
+
"aria-label": translations.removeHoliday,
|
|
489
|
+
disabled: controlsDisabled,
|
|
490
|
+
onClick: () => removeHoliday(row.key),
|
|
491
|
+
children: /* @__PURE__ */ jsx(Trash2, { className: "size-4", "aria-hidden": "true" })
|
|
492
|
+
}
|
|
493
|
+
)
|
|
494
|
+
] }),
|
|
495
|
+
holidayError ? /* @__PURE__ */ jsx("p", { className: "text-sm text-status-error-text", children: holidayError }) : null
|
|
496
|
+
] }, row.key);
|
|
497
|
+
}),
|
|
498
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", size: "sm", disabled: controlsDisabled, onClick: addHoliday, children: [
|
|
499
|
+
/* @__PURE__ */ jsx(Plus, { className: "size-4", "aria-hidden": "true" }),
|
|
500
|
+
translations.addHoliday
|
|
501
|
+
] })
|
|
502
|
+
] }),
|
|
503
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
504
|
+
/* @__PURE__ */ jsxs(
|
|
505
|
+
Button,
|
|
506
|
+
{
|
|
507
|
+
type: "button",
|
|
508
|
+
variant: "ghost",
|
|
509
|
+
size: "sm",
|
|
510
|
+
"aria-expanded": advancedVisible,
|
|
511
|
+
"aria-controls": advancedRegionId,
|
|
512
|
+
disabled,
|
|
513
|
+
onClick: () => setAdvancedOpen((open) => !open),
|
|
514
|
+
children: [
|
|
515
|
+
advancedVisible ? /* @__PURE__ */ jsx(ChevronDown, { className: "size-4", "aria-hidden": "true" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "size-4", "aria-hidden": "true" }),
|
|
516
|
+
translations.advancedToggle
|
|
517
|
+
]
|
|
518
|
+
}
|
|
519
|
+
),
|
|
520
|
+
advancedVisible ? /* @__PURE__ */ jsxs("div", { id: advancedRegionId, className: "space-y-2", children: [
|
|
521
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${id}-raw`, children: translations.advancedLabel }),
|
|
522
|
+
/* @__PURE__ */ jsx(
|
|
523
|
+
Textarea,
|
|
524
|
+
{
|
|
525
|
+
id: `${id}-raw`,
|
|
526
|
+
rows: 6,
|
|
527
|
+
value: value.raw,
|
|
528
|
+
disabled,
|
|
529
|
+
"aria-invalid": error ? true : void 0,
|
|
530
|
+
onChange: (event) => handleRawChange(event.target.value)
|
|
531
|
+
}
|
|
532
|
+
),
|
|
533
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: translations.advancedHelp })
|
|
534
|
+
] }) : null
|
|
535
|
+
] }),
|
|
536
|
+
error ? /* @__PURE__ */ jsx(ErrorMessage, { label: error }) : null
|
|
537
|
+
] });
|
|
538
|
+
}
|
|
539
|
+
function GeneralQuarantineGradesField({
|
|
540
|
+
id,
|
|
541
|
+
label,
|
|
542
|
+
description,
|
|
543
|
+
selected,
|
|
544
|
+
disabled,
|
|
545
|
+
onToggle
|
|
546
|
+
}) {
|
|
547
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
548
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
549
|
+
/* @__PURE__ */ jsx(Label, { id: `${id}-label`, children: label }),
|
|
550
|
+
/* @__PURE__ */ jsx("p", { id: `${id}-description`, className: "text-xs text-muted-foreground", children: description })
|
|
551
|
+
] }),
|
|
552
|
+
/* @__PURE__ */ jsx(
|
|
553
|
+
"div",
|
|
554
|
+
{
|
|
555
|
+
role: "group",
|
|
556
|
+
"aria-labelledby": `${id}-label`,
|
|
557
|
+
"aria-describedby": `${id}-description`,
|
|
558
|
+
className: "grid gap-2 sm:grid-cols-4",
|
|
559
|
+
children: QUARANTINE_GRADE_OPTIONS.map((grade) => {
|
|
560
|
+
const checkboxId = `${id}-${grade.toLowerCase()}`;
|
|
561
|
+
return /* @__PURE__ */ jsxs(
|
|
562
|
+
"div",
|
|
563
|
+
{
|
|
564
|
+
className: "flex items-center gap-2 rounded-md border border-border bg-background p-3",
|
|
565
|
+
children: [
|
|
566
|
+
/* @__PURE__ */ jsx(
|
|
567
|
+
Checkbox,
|
|
568
|
+
{
|
|
569
|
+
id: checkboxId,
|
|
570
|
+
checked: selected.includes(grade),
|
|
571
|
+
disabled,
|
|
572
|
+
onCheckedChange: (checked) => onToggle(grade, checked === true)
|
|
573
|
+
}
|
|
574
|
+
),
|
|
575
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: checkboxId, className: "text-sm font-normal", children: grade })
|
|
576
|
+
]
|
|
577
|
+
},
|
|
578
|
+
grade
|
|
579
|
+
);
|
|
580
|
+
})
|
|
581
|
+
}
|
|
582
|
+
)
|
|
583
|
+
] });
|
|
584
|
+
}
|
|
585
|
+
function EscalationTiersField({
|
|
586
|
+
id,
|
|
587
|
+
label,
|
|
588
|
+
description,
|
|
589
|
+
rows,
|
|
590
|
+
rowErrors,
|
|
591
|
+
error,
|
|
592
|
+
disabled,
|
|
593
|
+
translations,
|
|
594
|
+
loadStaffOptions,
|
|
595
|
+
resolveStaffLabel,
|
|
596
|
+
onAddRow,
|
|
597
|
+
onRemoveRow,
|
|
598
|
+
onAtPctChange,
|
|
599
|
+
onActionChange,
|
|
600
|
+
onUserChange
|
|
601
|
+
}) {
|
|
602
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
603
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
604
|
+
/* @__PURE__ */ jsx("h4", { className: "text-sm font-medium", children: label }),
|
|
605
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: description })
|
|
606
|
+
] }),
|
|
607
|
+
rows.length === 0 ? /* @__PURE__ */ jsx("p", { className: "rounded-md border border-dashed border-border bg-background p-4 text-sm text-muted-foreground", children: translations.empty }) : /* @__PURE__ */ jsx("div", { className: "space-y-3", children: rows.map((row, index) => {
|
|
608
|
+
const rowError = rowErrors?.[row.key];
|
|
609
|
+
const atPctFieldId = `${id}-${row.key}-atPct`;
|
|
610
|
+
const actionFieldId = `${id}-${row.key}-action`;
|
|
611
|
+
const toUserFieldId = `${id}-${row.key}-toUserId`;
|
|
612
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-3 rounded-md border border-border bg-background p-4", children: [
|
|
613
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
|
|
614
|
+
/* @__PURE__ */ jsx("h5", { className: "text-sm font-medium", children: translations.rowLabel(index + 1) }),
|
|
615
|
+
/* @__PURE__ */ jsx(
|
|
616
|
+
IconButton,
|
|
617
|
+
{
|
|
618
|
+
type: "button",
|
|
619
|
+
variant: "ghost",
|
|
620
|
+
size: "sm",
|
|
621
|
+
"aria-label": translations.removeRow,
|
|
622
|
+
disabled,
|
|
623
|
+
onClick: () => onRemoveRow(row.key),
|
|
624
|
+
children: /* @__PURE__ */ jsx(Trash2, { className: "size-4", "aria-hidden": "true" })
|
|
625
|
+
}
|
|
626
|
+
)
|
|
627
|
+
] }),
|
|
628
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 sm:grid-cols-3", children: [
|
|
629
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
630
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: atPctFieldId, children: translations.atPctLabel }),
|
|
631
|
+
/* @__PURE__ */ jsx(
|
|
632
|
+
Input,
|
|
633
|
+
{
|
|
634
|
+
id: atPctFieldId,
|
|
635
|
+
type: "number",
|
|
636
|
+
min: ESCALATION_TIER_MIN_PCT,
|
|
637
|
+
max: ESCALATION_TIER_MAX_PCT,
|
|
638
|
+
value: row.atPct,
|
|
639
|
+
disabled,
|
|
640
|
+
"aria-invalid": rowError?.atPct ? true : void 0,
|
|
641
|
+
onChange: (event) => onAtPctChange(row.key, event.target.value)
|
|
642
|
+
}
|
|
643
|
+
),
|
|
644
|
+
rowError?.atPct ? /* @__PURE__ */ jsx("p", { className: "text-sm text-status-error-text", children: rowError.atPct }) : null
|
|
645
|
+
] }),
|
|
646
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
647
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: actionFieldId, children: translations.actionLabel }),
|
|
648
|
+
/* @__PURE__ */ jsxs(
|
|
649
|
+
Select,
|
|
650
|
+
{
|
|
651
|
+
value: row.action,
|
|
652
|
+
onValueChange: (value) => onActionChange(row.key, value === "reassign" ? "reassign" : "notify"),
|
|
653
|
+
children: [
|
|
654
|
+
/* @__PURE__ */ jsx(SelectTrigger, { id: actionFieldId, disabled, children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
655
|
+
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
656
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "notify", children: translations.actionNotify }),
|
|
657
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "reassign", children: translations.actionReassign })
|
|
658
|
+
] })
|
|
659
|
+
]
|
|
660
|
+
}
|
|
661
|
+
)
|
|
662
|
+
] }),
|
|
663
|
+
row.action === "reassign" ? /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
664
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: toUserFieldId, children: translations.toUserLabel }),
|
|
665
|
+
/* @__PURE__ */ jsx(
|
|
666
|
+
ComboboxInput,
|
|
667
|
+
{
|
|
668
|
+
value: row.toUserId,
|
|
669
|
+
onChange: (value) => onUserChange(row.key, value),
|
|
670
|
+
placeholder: translations.toUserPlaceholder,
|
|
671
|
+
loadSuggestions: loadStaffOptions,
|
|
672
|
+
resolveLabel: resolveStaffLabel,
|
|
673
|
+
allowCustomValues: false,
|
|
674
|
+
disabled
|
|
675
|
+
}
|
|
676
|
+
),
|
|
677
|
+
rowError?.toUserId ? /* @__PURE__ */ jsx("p", { className: "text-sm text-status-error-text", children: rowError.toUserId }) : null
|
|
678
|
+
] }) : null
|
|
679
|
+
] })
|
|
680
|
+
] }, row.key);
|
|
681
|
+
}) }),
|
|
682
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", size: "sm", disabled, onClick: onAddRow, children: [
|
|
683
|
+
/* @__PURE__ */ jsx(Plus, { className: "size-4", "aria-hidden": "true" }),
|
|
684
|
+
translations.addRow
|
|
685
|
+
] }),
|
|
686
|
+
error ? /* @__PURE__ */ jsx(ErrorMessage, { label: error }) : null
|
|
687
|
+
] });
|
|
688
|
+
}
|
|
689
|
+
function GeneralSettingsSubsection({
|
|
690
|
+
title,
|
|
691
|
+
children
|
|
692
|
+
}) {
|
|
693
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
694
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium", children: title }),
|
|
695
|
+
children
|
|
696
|
+
] });
|
|
697
|
+
}
|
|
698
|
+
function WarrantyClaimSettingsPage() {
|
|
699
|
+
const t = useT();
|
|
700
|
+
const scopeVersion = useOrganizationScopeVersion();
|
|
701
|
+
const { confirm, ConfirmDialogElement } = useConfirmDialog();
|
|
702
|
+
const [entriesByKind, setEntriesByKind] = React.useState({
|
|
703
|
+
"warranty-claim-fault-code": [],
|
|
704
|
+
"warranty-claim-reason": [],
|
|
705
|
+
"warranty-claim-rejection-reason": []
|
|
706
|
+
});
|
|
707
|
+
const [dictionaryIds, setDictionaryIds] = React.useState({
|
|
708
|
+
"warranty-claim-fault-code": null,
|
|
709
|
+
"warranty-claim-reason": null,
|
|
710
|
+
"warranty-claim-rejection-reason": null
|
|
711
|
+
});
|
|
712
|
+
const [loadingKind, setLoadingKind] = React.useState({
|
|
713
|
+
"warranty-claim-fault-code": false,
|
|
714
|
+
"warranty-claim-reason": false,
|
|
715
|
+
"warranty-claim-rejection-reason": false
|
|
716
|
+
});
|
|
717
|
+
const [dialog, setDialog] = React.useState(null);
|
|
718
|
+
const [submitting, setSubmitting] = React.useState(false);
|
|
719
|
+
const [generalSettings, setGeneralSettings] = React.useState(null);
|
|
720
|
+
const [generalForm, setGeneralForm] = React.useState(() => buildGeneralFormValues(DEFAULT_GENERAL_SETTINGS));
|
|
721
|
+
const [generalLoading, setGeneralLoading] = React.useState(true);
|
|
722
|
+
const [generalSaving, setGeneralSaving] = React.useState(false);
|
|
723
|
+
const [generalLoadError, setGeneralLoadError] = React.useState(null);
|
|
724
|
+
const [generalSaveError, setGeneralSaveError] = React.useState(null);
|
|
725
|
+
const [generalFieldErrors, setGeneralFieldErrors] = React.useState({});
|
|
726
|
+
const { runMutation, retryLastMutation } = useGuardedMutation({
|
|
727
|
+
contextId: SAVE_CONTEXT_ID,
|
|
728
|
+
blockedMessage: t("warranty_claims.common.saveBlocked")
|
|
729
|
+
});
|
|
730
|
+
const mutationContext = React.useMemo(() => ({
|
|
731
|
+
formId: SAVE_CONTEXT_ID,
|
|
732
|
+
resourceKind: "warranty_claims.dictionaries",
|
|
733
|
+
retryLastMutation
|
|
734
|
+
}), [retryLastMutation]);
|
|
735
|
+
const generalMutationContext = React.useMemo(() => ({
|
|
736
|
+
formId: GENERAL_SETTINGS_FORM_ID,
|
|
737
|
+
resourceKind: "warranty_claims.settings",
|
|
738
|
+
retryLastMutation
|
|
739
|
+
}), [retryLastMutation]);
|
|
740
|
+
const generalTranslations = React.useMemo(() => ({
|
|
741
|
+
title: t("warranty_claims.settings.general.title", "General"),
|
|
742
|
+
description: t("warranty_claims.settings.general.description", "Configure SLA timing and light auto-approval defaults for warranty claims."),
|
|
743
|
+
loading: t("warranty_claims.settings.general.loading", "Loading general settings..."),
|
|
744
|
+
saveError: t("warranty_claims.settings.general.error.save", "Failed to save general settings."),
|
|
745
|
+
loadError: t("warranty_claims.settings.general.error.load", "Failed to load general settings."),
|
|
746
|
+
invalidError: t("warranty_claims.settings.general.error.invalid", "Review the highlighted numeric and currency limits."),
|
|
747
|
+
success: t("warranty_claims.settings.general.success.save", "General settings saved."),
|
|
748
|
+
refresh: t("warranty_claims.settings.general.actions.refresh", "Refresh"),
|
|
749
|
+
save: t("warranty_claims.settings.general.actions.save", "Save settings"),
|
|
750
|
+
saving: t("warranty_claims.settings.general.actions.saving", "Saving..."),
|
|
751
|
+
sections: {
|
|
752
|
+
slaEscalation: t("warranty_claims.settings.general.sections.slaEscalation", "SLA escalation"),
|
|
753
|
+
adjudication: t("warranty_claims.settings.general.sections.adjudication", "Adjudication"),
|
|
754
|
+
receiving: t("warranty_claims.settings.general.sections.receiving", "Receiving"),
|
|
755
|
+
returns: t("warranty_claims.settings.general.sections.returns", "Returns")
|
|
756
|
+
},
|
|
757
|
+
jsonErrors: {
|
|
758
|
+
businessHours: t("warranty_claims.settings.general.error.businessHoursJson", "Invalid business hours JSON"),
|
|
759
|
+
escalationTiers: t("warranty_claims.settings.general.error.escalationTiersInvalid", "Fix the highlighted escalation tier rows.")
|
|
760
|
+
},
|
|
761
|
+
fields: {
|
|
762
|
+
slaHours: t("warranty_claims.settings.general.fields.slaHours.label", "SLA hours"),
|
|
763
|
+
slaHoursHelp: t("warranty_claims.settings.general.fields.slaHours.help", "Target response window in hours, from 1 to 8760."),
|
|
764
|
+
slaPauseOnInfoRequested: t("warranty_claims.settings.general.fields.slaPauseOnInfoRequested.label", "Pause SLA while info is requested"),
|
|
765
|
+
slaPauseOnInfoRequestedHelp: t("warranty_claims.settings.general.fields.slaPauseOnInfoRequested.help", "Stop the SLA clock when a claim waits on customer information."),
|
|
766
|
+
slaAtRiskThresholdPct: t("warranty_claims.settings.general.fields.slaAtRiskThresholdPct.label", "SLA at-risk threshold"),
|
|
767
|
+
slaAtRiskThresholdPctHelp: t("warranty_claims.settings.general.fields.slaAtRiskThresholdPct.help", "Percent of the SLA window elapsed before a claim is marked at risk."),
|
|
768
|
+
defaultWarrantyMonths: t("warranty_claims.settings.general.fields.defaultWarrantyMonths.label", "Default warranty months"),
|
|
769
|
+
defaultWarrantyMonthsHelp: t("warranty_claims.settings.general.fields.defaultWarrantyMonths.help", "Prefills warranty months on new claim lines and estimates portal entitlement. Leave empty to disable."),
|
|
770
|
+
returnWindowDays: t("warranty_claims.settings.returnWindowDays.label", "Return window (days)"),
|
|
771
|
+
returnWindowDaysHelp: t("warranty_claims.settings.returnWindowDays.help", "Flag return and core-return claims submitted after this many days from order placement. Leave empty to disable."),
|
|
772
|
+
autoApproveEnabled: t("warranty_claims.settings.general.fields.autoApproveEnabled.label", "Enable auto-approve"),
|
|
773
|
+
autoApproveEnabledHelp: t("warranty_claims.settings.general.fields.autoApproveEnabled.help", "Automatically approve eligible submitted claims when all configured limits match."),
|
|
774
|
+
autoApproveMaxAmount: t("warranty_claims.settings.general.fields.autoApproveMaxAmount.label", "Auto-approve max amount"),
|
|
775
|
+
autoApproveMaxAmountHelp: t("warranty_claims.settings.general.fields.autoApproveMaxAmount.help", "Maximum claimed total allowed for auto-approval."),
|
|
776
|
+
autoApproveCurrencyCode: t("warranty_claims.settings.general.fields.autoApproveCurrencyCode.label", "Auto-approve currency"),
|
|
777
|
+
autoApproveCurrencyCodeHelp: t("warranty_claims.settings.general.fields.autoApproveCurrencyCode.help", "Three-letter uppercase currency code used by the auto-approval limit."),
|
|
778
|
+
autoApproveRequireInWarranty: t("warranty_claims.settings.general.fields.autoApproveRequireInWarranty.label", "Require in-warranty lines"),
|
|
779
|
+
autoApproveRequireInWarrantyHelp: t("warranty_claims.settings.general.fields.autoApproveRequireInWarranty.help", "Only auto-approve when every line is still in warranty."),
|
|
780
|
+
businessHours: t("warranty_claims.settings.general.fields.businessHoursEditor.label", "Business hours"),
|
|
781
|
+
businessHoursHelp: t("warranty_claims.settings.general.fields.businessHoursEditor.help", "Working windows per weekday used by SLA timing. Leave every day unchecked to count wall-clock time."),
|
|
782
|
+
escalationTiers: t("warranty_claims.settings.general.fields.escalationTiersEditor.label", "Escalation tiers"),
|
|
783
|
+
escalationTiersHelp: t("warranty_claims.settings.general.fields.escalationTiersEditor.help", "Notify or reassign a claim once its SLA has elapsed past a percentage threshold. Tiers apply in ascending order. Leave empty to disable."),
|
|
784
|
+
adjudicationUseRules: t("warranty_claims.settings.general.fields.adjudicationUseRules.label", "Use business rules for adjudication"),
|
|
785
|
+
adjudicationUseRulesHelp: t("warranty_claims.settings.general.fields.adjudicationUseRules.help", "When on and the business_rules module is present, claim submission is evaluated by the rule engine; otherwise the built-in light rule is used."),
|
|
786
|
+
quarantineGrades: t("warranty_claims.settings.general.fields.quarantineGrades.label", "Quarantine grades"),
|
|
787
|
+
quarantineGradesHelp: t("warranty_claims.settings.general.fields.quarantineGrades.help", "Grades that automatically hold a claim on receiving."),
|
|
788
|
+
returnLabelProvider: t("warranty_claims.settings.general.fields.returnLabelProvider.label", "Return label provider"),
|
|
789
|
+
returnLabelProviderHelp: t("warranty_claims.settings.general.fields.returnLabelProvider.help", "Optional provider key for the return-label seam. Leave empty for manual entry only.")
|
|
790
|
+
},
|
|
791
|
+
escalationTiers: {
|
|
792
|
+
rowLabel: (index) => t("warranty_claims.settings.general.escalationTiers.rowLabel", "Tier {number}", { number: index }),
|
|
793
|
+
atPctLabel: t("warranty_claims.settings.general.escalationTiers.atPctLabel", "SLA elapsed (%)"),
|
|
794
|
+
actionLabel: t("warranty_claims.settings.general.escalationTiers.actionLabel", "Action"),
|
|
795
|
+
actionNotify: t("warranty_claims.settings.general.escalationTiers.action.notify", "Notify"),
|
|
796
|
+
actionReassign: t("warranty_claims.settings.general.escalationTiers.action.reassign", "Reassign"),
|
|
797
|
+
toUserLabel: t("warranty_claims.settings.general.escalationTiers.toUserLabel", "Reassign to"),
|
|
798
|
+
toUserPlaceholder: t("warranty_claims.settings.general.escalationTiers.toUserPlaceholder", "Search staff"),
|
|
799
|
+
addRow: t("warranty_claims.settings.general.escalationTiers.addRow", "Add tier"),
|
|
800
|
+
removeRow: t("warranty_claims.settings.general.escalationTiers.removeRow", "Remove tier"),
|
|
801
|
+
empty: t("warranty_claims.settings.general.escalationTiers.empty", "No escalation tiers configured. Claims will not auto-escalate."),
|
|
802
|
+
error: {
|
|
803
|
+
atPct: t("warranty_claims.settings.general.escalationTiers.error.atPct", "Enter a whole number between 1 and 1000."),
|
|
804
|
+
toUserId: t("warranty_claims.settings.general.escalationTiers.error.toUserId", "Select a staff member to reassign to.")
|
|
805
|
+
}
|
|
806
|
+
},
|
|
807
|
+
businessHours: {
|
|
808
|
+
dayLabels: {
|
|
809
|
+
mon: t("warranty_claims.settings.general.businessHours.day.mon", "Monday"),
|
|
810
|
+
tue: t("warranty_claims.settings.general.businessHours.day.tue", "Tuesday"),
|
|
811
|
+
wed: t("warranty_claims.settings.general.businessHours.day.wed", "Wednesday"),
|
|
812
|
+
thu: t("warranty_claims.settings.general.businessHours.day.thu", "Thursday"),
|
|
813
|
+
fri: t("warranty_claims.settings.general.businessHours.day.fri", "Friday"),
|
|
814
|
+
sat: t("warranty_claims.settings.general.businessHours.day.sat", "Saturday"),
|
|
815
|
+
sun: t("warranty_claims.settings.general.businessHours.day.sun", "Sunday")
|
|
816
|
+
},
|
|
817
|
+
timezoneLabel: t("warranty_claims.settings.general.businessHours.timezoneLabel", "Timezone"),
|
|
818
|
+
timezonePlaceholder: t("warranty_claims.settings.general.businessHours.timezonePlaceholder", "UTC"),
|
|
819
|
+
timezoneHelp: t("warranty_claims.settings.general.businessHours.timezoneHelp", "IANA timezone the weekly windows are evaluated in. Leave empty for UTC."),
|
|
820
|
+
startLabel: t("warranty_claims.settings.general.businessHours.startLabel", "Opens at"),
|
|
821
|
+
endLabel: t("warranty_claims.settings.general.businessHours.endLabel", "Closes at"),
|
|
822
|
+
addWindow: t("warranty_claims.settings.general.businessHours.addWindow", "Add window"),
|
|
823
|
+
removeWindow: t("warranty_claims.settings.general.businessHours.removeWindow", "Remove window"),
|
|
824
|
+
closed: t("warranty_claims.settings.general.businessHours.closed", "Closed"),
|
|
825
|
+
holidaysLabel: t("warranty_claims.settings.general.businessHours.holidaysLabel", "Holidays"),
|
|
826
|
+
holidaysHelp: t("warranty_claims.settings.general.businessHours.holidaysHelp", "Dates skipped entirely when counting SLA business hours."),
|
|
827
|
+
addHoliday: t("warranty_claims.settings.general.businessHours.addHoliday", "Add holiday"),
|
|
828
|
+
removeHoliday: t("warranty_claims.settings.general.businessHours.removeHoliday", "Remove holiday"),
|
|
829
|
+
holidayDateLabel: t("warranty_claims.settings.general.businessHours.holidayDateLabel", "Holiday date"),
|
|
830
|
+
advancedToggle: t("warranty_claims.settings.general.businessHours.advancedToggle", "Advanced: edit raw JSON"),
|
|
831
|
+
advancedLabel: t("warranty_claims.settings.general.fields.businessHours.label", "Business hours JSON"),
|
|
832
|
+
advancedHelp: t("warranty_claims.settings.general.fields.businessHours.help", "Shape: { timezone, week: { mon:[{start,end}], ... }, holidays:[...] }. Leave empty to disable."),
|
|
833
|
+
error: {
|
|
834
|
+
window: t("warranty_claims.settings.general.businessHours.error.window", "Enter a start time earlier than the end time."),
|
|
835
|
+
holiday: t("warranty_claims.settings.general.businessHours.error.holiday", "Pick a holiday date."),
|
|
836
|
+
rows: t("warranty_claims.settings.general.businessHours.error.rows", "Fix the highlighted business hours entries.")
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}), [t]);
|
|
840
|
+
const applyGeneralSettings = React.useCallback((settings) => {
|
|
841
|
+
setGeneralSettings(settings);
|
|
842
|
+
setGeneralForm(buildGeneralFormValues(settings));
|
|
843
|
+
setGeneralFieldErrors({});
|
|
844
|
+
}, []);
|
|
845
|
+
const loadGeneralSettings = React.useCallback(async () => {
|
|
846
|
+
setGeneralLoading(true);
|
|
847
|
+
setGeneralLoadError(null);
|
|
848
|
+
try {
|
|
849
|
+
const call = await apiCall("/api/warranty_claims/settings-general");
|
|
850
|
+
const settings = call.result?.result ?? null;
|
|
851
|
+
if (!call.ok || !settings) {
|
|
852
|
+
setGeneralLoadError(translateApiErrorMessage(call, generalTranslations.loadError, t));
|
|
853
|
+
return;
|
|
854
|
+
}
|
|
855
|
+
applyGeneralSettings(settings);
|
|
856
|
+
setGeneralSaveError(null);
|
|
857
|
+
} catch (err) {
|
|
858
|
+
const message = err instanceof Error ? err.message : generalTranslations.loadError;
|
|
859
|
+
setGeneralLoadError(message);
|
|
860
|
+
} finally {
|
|
861
|
+
setGeneralLoading(false);
|
|
862
|
+
}
|
|
863
|
+
}, [applyGeneralSettings, generalTranslations.loadError, t]);
|
|
864
|
+
const updateGeneralForm = React.useCallback((patch) => {
|
|
865
|
+
setGeneralForm((prev) => ({ ...prev, ...patch }));
|
|
866
|
+
}, []);
|
|
867
|
+
const updateBusinessHours = React.useCallback((next) => {
|
|
868
|
+
setGeneralForm((prev) => ({ ...prev, businessHours: next }));
|
|
869
|
+
setGeneralFieldErrors((prev) => {
|
|
870
|
+
if (!prev.businessHours && !prev.businessHoursRowErrors) return prev;
|
|
871
|
+
return { ...prev, businessHours: void 0, businessHoursRowErrors: void 0 };
|
|
872
|
+
});
|
|
873
|
+
}, []);
|
|
874
|
+
const staffOptionLabel = React.useCallback((member) => member.email && member.email !== member.displayName ? `${member.displayName} (${member.email})` : member.displayName, []);
|
|
875
|
+
const loadEscalationStaffOptions = React.useCallback(async (query) => {
|
|
876
|
+
const page = await fetchAssignableStaffMembersPage(query ?? "", { pageSize: 24 });
|
|
877
|
+
return page.items.map((member) => ({ value: member.userId, label: staffOptionLabel(member) }));
|
|
878
|
+
}, [staffOptionLabel]);
|
|
879
|
+
const resolveStaffUserLabel = React.useCallback(async (userId) => {
|
|
880
|
+
const unknownUserLabel = t("warranty_claims.detail.unknownUser");
|
|
881
|
+
const response = await apiCall(
|
|
882
|
+
`/api/warranty_claims/assignees?ids=${encodeURIComponent(userId)}`
|
|
883
|
+
);
|
|
884
|
+
if (!response.ok || !response.result) return unknownUserLabel;
|
|
885
|
+
const user = (response.result.items ?? [])[0];
|
|
886
|
+
if (!user) return unknownUserLabel;
|
|
887
|
+
return toStringOrNull(user.name) ?? unknownUserLabel;
|
|
888
|
+
}, [t]);
|
|
889
|
+
const addEscalationTierRow = React.useCallback(() => {
|
|
890
|
+
setGeneralForm((prev) => ({
|
|
891
|
+
...prev,
|
|
892
|
+
escalationTiers: [
|
|
893
|
+
...prev.escalationTiers,
|
|
894
|
+
{ key: nextEscalationTierRowKey(), atPct: "", action: "notify", toUserId: "" }
|
|
895
|
+
]
|
|
896
|
+
}));
|
|
897
|
+
}, []);
|
|
898
|
+
const clearEscalationTierRowError = React.useCallback((key, field) => {
|
|
899
|
+
setGeneralFieldErrors((prev) => {
|
|
900
|
+
if (!prev.escalationTierRowErrors?.[key]?.[field]) return prev;
|
|
901
|
+
const nextRowErrors = { ...prev.escalationTierRowErrors, [key]: { ...prev.escalationTierRowErrors[key], [field]: void 0 } };
|
|
902
|
+
const hasRemainingErrors = Object.values(nextRowErrors).some((rowError) => rowError?.atPct || rowError?.toUserId);
|
|
903
|
+
return { ...prev, escalationTierRowErrors: nextRowErrors, escalationTiers: hasRemainingErrors ? prev.escalationTiers : void 0 };
|
|
904
|
+
});
|
|
905
|
+
}, []);
|
|
906
|
+
const removeEscalationTierRow = React.useCallback((key) => {
|
|
907
|
+
setGeneralForm((prev) => ({
|
|
908
|
+
...prev,
|
|
909
|
+
escalationTiers: prev.escalationTiers.filter((row) => row.key !== key)
|
|
910
|
+
}));
|
|
911
|
+
setGeneralFieldErrors((prev) => {
|
|
912
|
+
if (!prev.escalationTierRowErrors?.[key]) return prev;
|
|
913
|
+
const nextRowErrors = { ...prev.escalationTierRowErrors };
|
|
914
|
+
delete nextRowErrors[key];
|
|
915
|
+
const hasRemainingErrors = Object.values(nextRowErrors).some((rowError) => rowError?.atPct || rowError?.toUserId);
|
|
916
|
+
return { ...prev, escalationTierRowErrors: nextRowErrors, escalationTiers: hasRemainingErrors ? prev.escalationTiers : void 0 };
|
|
917
|
+
});
|
|
918
|
+
}, []);
|
|
919
|
+
const updateEscalationTierAtPct = React.useCallback((key, value) => {
|
|
920
|
+
setGeneralForm((prev) => ({
|
|
921
|
+
...prev,
|
|
922
|
+
escalationTiers: prev.escalationTiers.map((row) => row.key === key ? { ...row, atPct: value } : row)
|
|
923
|
+
}));
|
|
924
|
+
clearEscalationTierRowError(key, "atPct");
|
|
925
|
+
}, [clearEscalationTierRowError]);
|
|
926
|
+
const updateEscalationTierAction = React.useCallback((key, value) => {
|
|
927
|
+
setGeneralForm((prev) => ({
|
|
928
|
+
...prev,
|
|
929
|
+
escalationTiers: prev.escalationTiers.map((row) => row.key === key ? { ...row, action: value } : row)
|
|
930
|
+
}));
|
|
931
|
+
clearEscalationTierRowError(key, "toUserId");
|
|
932
|
+
}, [clearEscalationTierRowError]);
|
|
933
|
+
const updateEscalationTierUser = React.useCallback((key, value) => {
|
|
934
|
+
setGeneralForm((prev) => ({
|
|
935
|
+
...prev,
|
|
936
|
+
escalationTiers: prev.escalationTiers.map((row) => row.key === key ? { ...row, toUserId: value } : row)
|
|
937
|
+
}));
|
|
938
|
+
clearEscalationTierRowError(key, "toUserId");
|
|
939
|
+
}, [clearEscalationTierRowError]);
|
|
940
|
+
const handleGeneralSubmit = React.useCallback(async (event) => {
|
|
941
|
+
event.preventDefault();
|
|
942
|
+
setGeneralSaveError(null);
|
|
943
|
+
setGeneralFieldErrors({});
|
|
944
|
+
const slaHours = Number(generalForm.slaHours);
|
|
945
|
+
const slaAtRiskThresholdPct = Number(generalForm.slaAtRiskThresholdPct);
|
|
946
|
+
const amountText = generalForm.autoApproveMaxAmount.trim();
|
|
947
|
+
const autoApproveMaxAmount = amountText.length ? Number(amountText) : null;
|
|
948
|
+
const warrantyMonthsText = generalForm.defaultWarrantyMonths.trim();
|
|
949
|
+
const defaultWarrantyMonths = warrantyMonthsText.length ? Number(warrantyMonthsText) : null;
|
|
950
|
+
const returnWindowDaysText = generalForm.returnWindowDays.trim();
|
|
951
|
+
const returnWindowDays = returnWindowDaysText.length ? Number(returnWindowDaysText) : null;
|
|
952
|
+
const currencyCode = toStringOrNull(generalForm.autoApproveCurrencyCode)?.toUpperCase() ?? null;
|
|
953
|
+
const businessHoursResult = validateBusinessHoursValue(generalForm.businessHours, generalTranslations.businessHours);
|
|
954
|
+
const escalationTiersResult = validateEscalationTierRows(generalForm.escalationTiers, generalTranslations.escalationTiers);
|
|
955
|
+
const returnLabelProvider = toStringOrNull(generalForm.returnLabelProvider);
|
|
956
|
+
const quarantineGrades = Array.from(new Set(
|
|
957
|
+
generalForm.quarantineGrades.map((grade) => grade.trim()).filter((grade) => grade.length > 0)
|
|
958
|
+
));
|
|
959
|
+
if (!businessHoursResult.ok || !escalationTiersResult.ok) {
|
|
960
|
+
setGeneralFieldErrors({
|
|
961
|
+
businessHours: businessHoursResult.ok ? void 0 : businessHoursResult.reason === "json" ? generalTranslations.jsonErrors.businessHours : generalTranslations.businessHours.error.rows,
|
|
962
|
+
businessHoursRowErrors: !businessHoursResult.ok && businessHoursResult.reason === "rows" ? businessHoursResult.rowErrors : void 0,
|
|
963
|
+
escalationTiers: escalationTiersResult.ok ? void 0 : generalTranslations.jsonErrors.escalationTiers,
|
|
964
|
+
escalationTierRowErrors: escalationTiersResult.ok ? void 0 : escalationTiersResult.rowErrors
|
|
965
|
+
});
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
968
|
+
if (!Number.isInteger(slaHours) || slaHours < 1 || slaHours > 8760 || !Number.isInteger(slaAtRiskThresholdPct) || slaAtRiskThresholdPct < 1 || slaAtRiskThresholdPct > 100 || autoApproveMaxAmount !== null && (!Number.isFinite(autoApproveMaxAmount) || autoApproveMaxAmount < 0) || defaultWarrantyMonths !== null && (!Number.isInteger(defaultWarrantyMonths) || defaultWarrantyMonths < 0 || defaultWarrantyMonths > 600) || returnWindowDays !== null && (!Number.isInteger(returnWindowDays) || returnWindowDays < 1 || returnWindowDays > 3650) || currencyCode !== null && !/^[A-Z]{3}$/.test(currencyCode)) {
|
|
969
|
+
setGeneralSaveError(generalTranslations.invalidError);
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
const payload = {
|
|
973
|
+
slaHours,
|
|
974
|
+
slaPauseOnInfoRequested: generalForm.slaPauseOnInfoRequested,
|
|
975
|
+
slaAtRiskThresholdPct,
|
|
976
|
+
autoApproveEnabled: generalForm.autoApproveEnabled,
|
|
977
|
+
autoApproveMaxAmount,
|
|
978
|
+
autoApproveCurrencyCode: currencyCode,
|
|
979
|
+
autoApproveRequireInWarranty: generalForm.autoApproveRequireInWarranty,
|
|
980
|
+
defaultWarrantyMonths,
|
|
981
|
+
returnWindowDays,
|
|
982
|
+
businessHours: businessHoursResult.value,
|
|
983
|
+
escalationTiers: escalationTiersResult.value,
|
|
984
|
+
adjudicationUseRules: generalForm.adjudicationUseRules,
|
|
985
|
+
quarantineGrades,
|
|
986
|
+
returnLabelProvider
|
|
987
|
+
};
|
|
988
|
+
setGeneralSaving(true);
|
|
989
|
+
try {
|
|
990
|
+
await runMutation({
|
|
991
|
+
operation: async () => {
|
|
992
|
+
const save = () => apiCall("/api/warranty_claims/settings-general", {
|
|
993
|
+
method: "PUT",
|
|
994
|
+
headers: { "content-type": "application/json" },
|
|
995
|
+
body: JSON.stringify(payload)
|
|
996
|
+
});
|
|
997
|
+
const updatedAt = generalSettings?.updatedAt ?? null;
|
|
998
|
+
const call = updatedAt ? await withScopedApiRequestHeaders(buildOptimisticLockHeader(updatedAt), save) : await save();
|
|
999
|
+
if (!call.ok) throw buildConflictError(call, generalTranslations.saveError, t);
|
|
1000
|
+
const settings = call.result?.result ?? null;
|
|
1001
|
+
if (!settings) throw new Error(generalTranslations.saveError);
|
|
1002
|
+
return settings;
|
|
1003
|
+
},
|
|
1004
|
+
context: generalMutationContext,
|
|
1005
|
+
mutationPayload: payload
|
|
1006
|
+
});
|
|
1007
|
+
flash(generalTranslations.success, "success");
|
|
1008
|
+
await loadGeneralSettings();
|
|
1009
|
+
} catch (err) {
|
|
1010
|
+
if (surfaceRecordConflict(err, t, { onRefresh: () => {
|
|
1011
|
+
void loadGeneralSettings();
|
|
1012
|
+
} })) return;
|
|
1013
|
+
const message = err instanceof Error ? err.message : generalTranslations.saveError;
|
|
1014
|
+
setGeneralSaveError(message);
|
|
1015
|
+
flash(message, "error");
|
|
1016
|
+
} finally {
|
|
1017
|
+
setGeneralSaving(false);
|
|
1018
|
+
}
|
|
1019
|
+
}, [
|
|
1020
|
+
generalForm,
|
|
1021
|
+
generalMutationContext,
|
|
1022
|
+
generalSettings?.updatedAt,
|
|
1023
|
+
generalTranslations.businessHours,
|
|
1024
|
+
generalTranslations.escalationTiers,
|
|
1025
|
+
generalTranslations.invalidError,
|
|
1026
|
+
generalTranslations.jsonErrors.businessHours,
|
|
1027
|
+
generalTranslations.jsonErrors.escalationTiers,
|
|
1028
|
+
generalTranslations.saveError,
|
|
1029
|
+
generalTranslations.success,
|
|
1030
|
+
loadGeneralSettings,
|
|
1031
|
+
runMutation,
|
|
1032
|
+
t
|
|
1033
|
+
]);
|
|
1034
|
+
React.useEffect(() => {
|
|
1035
|
+
void loadGeneralSettings();
|
|
1036
|
+
}, [loadGeneralSettings, scopeVersion]);
|
|
1037
|
+
const loadEntries = React.useCallback(async (section) => {
|
|
1038
|
+
setLoadingKind((prev) => ({ ...prev, [section.kind]: true }));
|
|
1039
|
+
try {
|
|
1040
|
+
const dictionaries = await readApiResultOrThrow(
|
|
1041
|
+
"/api/dictionaries",
|
|
1042
|
+
void 0,
|
|
1043
|
+
{
|
|
1044
|
+
fallback: { items: [] },
|
|
1045
|
+
errorMessage: t("warranty_claims.settings.error.load")
|
|
1046
|
+
}
|
|
1047
|
+
);
|
|
1048
|
+
const dictionary = (dictionaries.items ?? []).find((item) => item.key === section.dictionaryKey);
|
|
1049
|
+
const dictionaryId = dictionary?.id ?? null;
|
|
1050
|
+
setDictionaryIds((prev) => ({ ...prev, [section.kind]: dictionaryId }));
|
|
1051
|
+
if (!dictionaryId) {
|
|
1052
|
+
setEntriesByKind((prev) => ({ ...prev, [section.kind]: [] }));
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
const entries = await readApiResultOrThrow(
|
|
1056
|
+
`/api/dictionaries/${encodeURIComponent(dictionaryId)}/entries`,
|
|
1057
|
+
void 0,
|
|
1058
|
+
{
|
|
1059
|
+
fallback: { items: [] },
|
|
1060
|
+
errorMessage: t("warranty_claims.settings.error.load")
|
|
1061
|
+
}
|
|
1062
|
+
);
|
|
1063
|
+
setEntriesByKind((prev) => ({
|
|
1064
|
+
...prev,
|
|
1065
|
+
[section.kind]: (entries.items ?? []).map(normalizeEntry).filter((entry) => entry !== null)
|
|
1066
|
+
}));
|
|
1067
|
+
} catch (err) {
|
|
1068
|
+
const message = err instanceof Error ? err.message : t("warranty_claims.settings.error.load");
|
|
1069
|
+
flash(message, "error");
|
|
1070
|
+
} finally {
|
|
1071
|
+
setLoadingKind((prev) => ({ ...prev, [section.kind]: false }));
|
|
1072
|
+
}
|
|
1073
|
+
}, [t]);
|
|
1074
|
+
React.useEffect(() => {
|
|
1075
|
+
for (const section of SECTIONS) {
|
|
1076
|
+
void loadEntries(section);
|
|
1077
|
+
}
|
|
1078
|
+
}, [loadEntries, scopeVersion]);
|
|
1079
|
+
const tableTranslations = React.useMemo(() => ({
|
|
1080
|
+
valueColumn: t("warranty_claims.settings.table.value"),
|
|
1081
|
+
labelColumn: t("warranty_claims.settings.table.label"),
|
|
1082
|
+
appearanceColumn: t("warranty_claims.settings.table.appearance"),
|
|
1083
|
+
addLabel: t("warranty_claims.settings.actions.add"),
|
|
1084
|
+
editLabel: t("warranty_claims.settings.actions.edit"),
|
|
1085
|
+
deleteLabel: t("warranty_claims.settings.actions.delete"),
|
|
1086
|
+
refreshLabel: t("warranty_claims.settings.actions.refresh"),
|
|
1087
|
+
inheritedLabel: t("warranty_claims.settings.table.inherited"),
|
|
1088
|
+
inheritedTooltip: t("warranty_claims.settings.table.inheritedTooltip"),
|
|
1089
|
+
emptyLabel: t("warranty_claims.settings.table.empty"),
|
|
1090
|
+
searchPlaceholder: t("warranty_claims.settings.table.search")
|
|
1091
|
+
}), [t]);
|
|
1092
|
+
const formTranslations = React.useMemo(() => ({
|
|
1093
|
+
createTitle: t("warranty_claims.settings.dialog.createTitle"),
|
|
1094
|
+
editTitle: t("warranty_claims.settings.dialog.editTitle"),
|
|
1095
|
+
valueLabel: t("warranty_claims.settings.dialog.valueLabel"),
|
|
1096
|
+
labelLabel: t("warranty_claims.settings.dialog.labelLabel"),
|
|
1097
|
+
saveLabel: t("warranty_claims.settings.dialog.save"),
|
|
1098
|
+
cancelLabel: t("warranty_claims.settings.dialog.cancel"),
|
|
1099
|
+
appearance: {
|
|
1100
|
+
colorLabel: t("warranty_claims.settings.dialog.colorLabel"),
|
|
1101
|
+
colorHelp: t("warranty_claims.settings.dialog.colorHelp"),
|
|
1102
|
+
colorClearLabel: t("warranty_claims.settings.dialog.colorClear"),
|
|
1103
|
+
iconLabel: t("warranty_claims.settings.dialog.iconLabel"),
|
|
1104
|
+
iconPlaceholder: t("warranty_claims.settings.dialog.iconPlaceholder"),
|
|
1105
|
+
iconPickerTriggerLabel: t("warranty_claims.settings.dialog.iconBrowse"),
|
|
1106
|
+
iconSearchPlaceholder: t("warranty_claims.settings.dialog.iconSearchPlaceholder"),
|
|
1107
|
+
iconSearchEmptyLabel: t("warranty_claims.settings.dialog.iconSearchEmpty"),
|
|
1108
|
+
iconSuggestionsLabel: t("warranty_claims.settings.dialog.iconSuggestions"),
|
|
1109
|
+
iconClearLabel: t("warranty_claims.settings.dialog.iconClear"),
|
|
1110
|
+
previewEmptyLabel: t("warranty_claims.settings.dialog.previewEmpty")
|
|
1111
|
+
}
|
|
1112
|
+
}), [t]);
|
|
1113
|
+
const closeDialog = React.useCallback(() => {
|
|
1114
|
+
setDialog(null);
|
|
1115
|
+
}, []);
|
|
1116
|
+
const startCreate = React.useCallback((kind) => {
|
|
1117
|
+
setDialog({ mode: "create", kind });
|
|
1118
|
+
}, []);
|
|
1119
|
+
const resolveRawEntry = React.useCallback(
|
|
1120
|
+
(kind, entry) => (entriesByKind[kind] ?? []).find((row) => row.id === entry.id) ?? entry,
|
|
1121
|
+
[entriesByKind]
|
|
1122
|
+
);
|
|
1123
|
+
const startEdit = React.useCallback((kind, entry) => {
|
|
1124
|
+
setDialog({ mode: "edit", kind, entry });
|
|
1125
|
+
}, []);
|
|
1126
|
+
const sectionByKind = React.useCallback((kind) => {
|
|
1127
|
+
return SECTIONS.find((section) => section.kind === kind) ?? null;
|
|
1128
|
+
}, []);
|
|
1129
|
+
const deleteEntry = React.useCallback(async (kind, entry) => {
|
|
1130
|
+
const section = sectionByKind(kind);
|
|
1131
|
+
const dictionaryId = dictionaryIds[kind];
|
|
1132
|
+
if (!section || !dictionaryId) return;
|
|
1133
|
+
const confirmed = await confirm({
|
|
1134
|
+
title: t("warranty_claims.settings.confirm.delete", void 0, { value: entry.label || entry.value }),
|
|
1135
|
+
variant: "destructive"
|
|
1136
|
+
});
|
|
1137
|
+
if (!confirmed) return;
|
|
1138
|
+
try {
|
|
1139
|
+
let conflictSurfaced = false;
|
|
1140
|
+
await runMutation({
|
|
1141
|
+
operation: async () => {
|
|
1142
|
+
const call = await withScopedApiRequestHeaders(
|
|
1143
|
+
buildOptimisticLockHeader(entry.updatedAt),
|
|
1144
|
+
() => apiCall(`/api/dictionaries/${encodeURIComponent(dictionaryId)}/entries/${encodeURIComponent(entry.id)}`, {
|
|
1145
|
+
method: "DELETE"
|
|
1146
|
+
})
|
|
1147
|
+
);
|
|
1148
|
+
if (!call.ok) {
|
|
1149
|
+
const errorObject = buildConflictError(call, t("warranty_claims.settings.error.save"));
|
|
1150
|
+
if (surfaceRecordConflict(errorObject, t, { onRefresh: () => {
|
|
1151
|
+
void loadEntries(section);
|
|
1152
|
+
} })) {
|
|
1153
|
+
conflictSurfaced = true;
|
|
1154
|
+
return call;
|
|
1155
|
+
}
|
|
1156
|
+
await raiseCrudError(call.response, t("warranty_claims.settings.error.delete"));
|
|
1157
|
+
}
|
|
1158
|
+
return call;
|
|
1159
|
+
},
|
|
1160
|
+
context: mutationContext,
|
|
1161
|
+
mutationPayload: { action: "delete", kind, id: entry.id }
|
|
1162
|
+
});
|
|
1163
|
+
if (conflictSurfaced) return;
|
|
1164
|
+
flash(t("warranty_claims.settings.success.delete"), "success");
|
|
1165
|
+
await loadEntries(section);
|
|
1166
|
+
} catch (err) {
|
|
1167
|
+
if (surfaceRecordConflict(err, t, { onRefresh: () => {
|
|
1168
|
+
void loadEntries(section);
|
|
1169
|
+
} })) return;
|
|
1170
|
+
const message = err instanceof Error ? err.message : t("warranty_claims.settings.error.delete");
|
|
1171
|
+
flash(message, "error");
|
|
1172
|
+
}
|
|
1173
|
+
}, [confirm, dictionaryIds, loadEntries, mutationContext, runMutation, sectionByKind, t]);
|
|
1174
|
+
const submitForm = React.useCallback(async (values) => {
|
|
1175
|
+
if (!dialog) return;
|
|
1176
|
+
const section = sectionByKind(dialog.kind);
|
|
1177
|
+
const dictionaryId = dictionaryIds[dialog.kind];
|
|
1178
|
+
if (!section || !dictionaryId) return;
|
|
1179
|
+
setSubmitting(true);
|
|
1180
|
+
try {
|
|
1181
|
+
if (dialog.mode === "create") {
|
|
1182
|
+
await runMutation({
|
|
1183
|
+
operation: async () => {
|
|
1184
|
+
const call = await apiCall(`/api/dictionaries/${encodeURIComponent(dictionaryId)}/entries`, {
|
|
1185
|
+
method: "POST",
|
|
1186
|
+
headers: { "content-type": "application/json" },
|
|
1187
|
+
body: JSON.stringify(values)
|
|
1188
|
+
});
|
|
1189
|
+
if (!call.ok) await raiseCrudError(call.response, t("warranty_claims.settings.error.save"));
|
|
1190
|
+
return call;
|
|
1191
|
+
},
|
|
1192
|
+
context: mutationContext,
|
|
1193
|
+
mutationPayload: { action: "create", kind: dialog.kind, ...values }
|
|
1194
|
+
});
|
|
1195
|
+
} else {
|
|
1196
|
+
const entry = dialog.entry;
|
|
1197
|
+
const payload = {};
|
|
1198
|
+
if (values.value !== entry.value) payload.value = values.value;
|
|
1199
|
+
if (values.label !== entry.label) payload.label = values.label;
|
|
1200
|
+
if ((values.color ?? null) !== (entry.color ?? null)) payload.color = values.color ?? null;
|
|
1201
|
+
if ((values.icon ?? null) !== (entry.icon ?? null)) payload.icon = values.icon ?? null;
|
|
1202
|
+
let conflictSurfaced = false;
|
|
1203
|
+
await runMutation({
|
|
1204
|
+
operation: async () => {
|
|
1205
|
+
const call = await withScopedApiRequestHeaders(
|
|
1206
|
+
buildOptimisticLockHeader(entry.updatedAt),
|
|
1207
|
+
() => apiCall(`/api/dictionaries/${encodeURIComponent(dictionaryId)}/entries/${encodeURIComponent(entry.id)}`, {
|
|
1208
|
+
method: "PATCH",
|
|
1209
|
+
headers: { "content-type": "application/json" },
|
|
1210
|
+
body: JSON.stringify(payload)
|
|
1211
|
+
})
|
|
1212
|
+
);
|
|
1213
|
+
if (!call.ok) {
|
|
1214
|
+
const errorObject = buildConflictError(call, t("warranty_claims.settings.error.save"));
|
|
1215
|
+
if (surfaceRecordConflict(errorObject, t, { onRefresh: () => {
|
|
1216
|
+
void loadEntries(section);
|
|
1217
|
+
} })) {
|
|
1218
|
+
conflictSurfaced = true;
|
|
1219
|
+
return call;
|
|
1220
|
+
}
|
|
1221
|
+
await raiseCrudError(call.response, t("warranty_claims.settings.error.save"));
|
|
1222
|
+
}
|
|
1223
|
+
return call;
|
|
1224
|
+
},
|
|
1225
|
+
context: mutationContext,
|
|
1226
|
+
mutationPayload: { action: "update", kind: dialog.kind, id: entry.id, ...payload }
|
|
1227
|
+
});
|
|
1228
|
+
if (conflictSurfaced) return;
|
|
1229
|
+
}
|
|
1230
|
+
flash(t("warranty_claims.settings.success.save"), "success");
|
|
1231
|
+
closeDialog();
|
|
1232
|
+
await loadEntries(section);
|
|
1233
|
+
} catch (err) {
|
|
1234
|
+
if (surfaceRecordConflict(err, t, { onRefresh: () => {
|
|
1235
|
+
void loadEntries(section);
|
|
1236
|
+
} })) return;
|
|
1237
|
+
const message = err instanceof Error ? err.message : t("warranty_claims.settings.error.save");
|
|
1238
|
+
flash(message, "error");
|
|
1239
|
+
throw err instanceof Error ? err : new Error(message);
|
|
1240
|
+
} finally {
|
|
1241
|
+
setSubmitting(false);
|
|
1242
|
+
}
|
|
1243
|
+
}, [closeDialog, dialog, dictionaryIds, loadEntries, mutationContext, runMutation, sectionByKind, t]);
|
|
1244
|
+
const currentValues = React.useMemo(() => {
|
|
1245
|
+
if (dialog?.mode === "edit") {
|
|
1246
|
+
return {
|
|
1247
|
+
value: dialog.entry.value,
|
|
1248
|
+
label: dialog.entry.label,
|
|
1249
|
+
color: dialog.entry.color,
|
|
1250
|
+
icon: dialog.entry.icon
|
|
1251
|
+
};
|
|
1252
|
+
}
|
|
1253
|
+
return DEFAULT_FORM_VALUES;
|
|
1254
|
+
}, [dialog]);
|
|
1255
|
+
return /* @__PURE__ */ jsxs(Page, { children: [
|
|
1256
|
+
/* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsxs("div", { className: "overflow-hidden rounded-xl border border-border bg-card text-card-foreground", children: [
|
|
1257
|
+
/* @__PURE__ */ jsx("div", { className: "border-b border-border px-7 py-4", children: /* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-foreground", children: t("warranty_claims.settings.title", "Claim settings") }) }),
|
|
1258
|
+
/* @__PURE__ */ jsxs("section", { children: [
|
|
1259
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1 border-b border-border px-6 py-4", children: [
|
|
1260
|
+
/* @__PURE__ */ jsx("h2", { className: "text-lg font-medium", children: generalTranslations.title }),
|
|
1261
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: generalTranslations.description })
|
|
1262
|
+
] }),
|
|
1263
|
+
/* @__PURE__ */ jsx("div", { className: "px-6 py-4", children: generalLoading ? /* @__PURE__ */ jsx(LoadingMessage, { label: generalTranslations.loading }) : generalLoadError ? /* @__PURE__ */ jsx(
|
|
1264
|
+
ErrorMessage,
|
|
1265
|
+
{
|
|
1266
|
+
label: generalLoadError,
|
|
1267
|
+
action: /* @__PURE__ */ jsxs(
|
|
1268
|
+
Button,
|
|
1269
|
+
{
|
|
1270
|
+
type: "button",
|
|
1271
|
+
variant: "outline",
|
|
1272
|
+
size: "sm",
|
|
1273
|
+
onClick: () => {
|
|
1274
|
+
void loadGeneralSettings();
|
|
1275
|
+
},
|
|
1276
|
+
children: [
|
|
1277
|
+
/* @__PURE__ */ jsx(RefreshCw, { className: "size-4", "aria-hidden": "true" }),
|
|
1278
|
+
generalTranslations.refresh
|
|
1279
|
+
]
|
|
1280
|
+
}
|
|
1281
|
+
)
|
|
1282
|
+
}
|
|
1283
|
+
) : /* @__PURE__ */ jsxs("form", { id: GENERAL_SETTINGS_FORM_ID, className: "space-y-6", noValidate: true, onSubmit: handleGeneralSubmit, children: [
|
|
1284
|
+
generalSaveError ? /* @__PURE__ */ jsx(ErrorMessage, { label: generalSaveError }) : null,
|
|
1285
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [
|
|
1286
|
+
/* @__PURE__ */ jsx(
|
|
1287
|
+
GeneralNumberField,
|
|
1288
|
+
{
|
|
1289
|
+
id: "warranty-claims-sla-hours",
|
|
1290
|
+
label: generalTranslations.fields.slaHours,
|
|
1291
|
+
description: generalTranslations.fields.slaHoursHelp,
|
|
1292
|
+
value: generalForm.slaHours,
|
|
1293
|
+
min: 1,
|
|
1294
|
+
max: 8760,
|
|
1295
|
+
disabled: generalSaving,
|
|
1296
|
+
onChange: (value) => updateGeneralForm({ slaHours: value })
|
|
1297
|
+
}
|
|
1298
|
+
),
|
|
1299
|
+
/* @__PURE__ */ jsx(
|
|
1300
|
+
GeneralNumberField,
|
|
1301
|
+
{
|
|
1302
|
+
id: "warranty-claims-sla-threshold",
|
|
1303
|
+
label: generalTranslations.fields.slaAtRiskThresholdPct,
|
|
1304
|
+
description: generalTranslations.fields.slaAtRiskThresholdPctHelp,
|
|
1305
|
+
value: generalForm.slaAtRiskThresholdPct,
|
|
1306
|
+
min: 1,
|
|
1307
|
+
max: 100,
|
|
1308
|
+
disabled: generalSaving,
|
|
1309
|
+
onChange: (value) => updateGeneralForm({ slaAtRiskThresholdPct: value })
|
|
1310
|
+
}
|
|
1311
|
+
),
|
|
1312
|
+
/* @__PURE__ */ jsx(
|
|
1313
|
+
GeneralNumberField,
|
|
1314
|
+
{
|
|
1315
|
+
id: "warranty-claims-default-warranty-months",
|
|
1316
|
+
label: generalTranslations.fields.defaultWarrantyMonths,
|
|
1317
|
+
description: generalTranslations.fields.defaultWarrantyMonthsHelp,
|
|
1318
|
+
value: generalForm.defaultWarrantyMonths,
|
|
1319
|
+
min: 0,
|
|
1320
|
+
max: 600,
|
|
1321
|
+
disabled: generalSaving,
|
|
1322
|
+
onChange: (value) => updateGeneralForm({ defaultWarrantyMonths: value })
|
|
1323
|
+
}
|
|
1324
|
+
),
|
|
1325
|
+
/* @__PURE__ */ jsx(
|
|
1326
|
+
GeneralNumberField,
|
|
1327
|
+
{
|
|
1328
|
+
id: "warranty-claims-return-window-days",
|
|
1329
|
+
label: generalTranslations.fields.returnWindowDays,
|
|
1330
|
+
description: generalTranslations.fields.returnWindowDaysHelp,
|
|
1331
|
+
value: generalForm.returnWindowDays,
|
|
1332
|
+
min: 1,
|
|
1333
|
+
max: 3650,
|
|
1334
|
+
disabled: generalSaving,
|
|
1335
|
+
onChange: (value) => updateGeneralForm({ returnWindowDays: value })
|
|
1336
|
+
}
|
|
1337
|
+
),
|
|
1338
|
+
/* @__PURE__ */ jsx(
|
|
1339
|
+
GeneralSwitchField,
|
|
1340
|
+
{
|
|
1341
|
+
id: "warranty-claims-sla-pause",
|
|
1342
|
+
label: generalTranslations.fields.slaPauseOnInfoRequested,
|
|
1343
|
+
description: generalTranslations.fields.slaPauseOnInfoRequestedHelp,
|
|
1344
|
+
checked: generalForm.slaPauseOnInfoRequested,
|
|
1345
|
+
disabled: generalSaving,
|
|
1346
|
+
onCheckedChange: (checked) => updateGeneralForm({ slaPauseOnInfoRequested: checked })
|
|
1347
|
+
}
|
|
1348
|
+
)
|
|
1349
|
+
] }),
|
|
1350
|
+
/* @__PURE__ */ jsx(GeneralSettingsSubsection, { title: generalTranslations.sections.slaEscalation, children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
1351
|
+
/* @__PURE__ */ jsx(
|
|
1352
|
+
BusinessHoursField,
|
|
1353
|
+
{
|
|
1354
|
+
id: "warranty-claims-business-hours",
|
|
1355
|
+
label: generalTranslations.fields.businessHours,
|
|
1356
|
+
description: generalTranslations.fields.businessHoursHelp,
|
|
1357
|
+
value: generalForm.businessHours,
|
|
1358
|
+
rowErrors: generalFieldErrors.businessHoursRowErrors,
|
|
1359
|
+
error: generalFieldErrors.businessHours,
|
|
1360
|
+
disabled: generalSaving,
|
|
1361
|
+
translations: generalTranslations.businessHours,
|
|
1362
|
+
onChange: updateBusinessHours
|
|
1363
|
+
}
|
|
1364
|
+
),
|
|
1365
|
+
/* @__PURE__ */ jsx(
|
|
1366
|
+
EscalationTiersField,
|
|
1367
|
+
{
|
|
1368
|
+
id: "warranty-claims-escalation-tiers",
|
|
1369
|
+
label: generalTranslations.fields.escalationTiers,
|
|
1370
|
+
description: generalTranslations.fields.escalationTiersHelp,
|
|
1371
|
+
rows: generalForm.escalationTiers,
|
|
1372
|
+
rowErrors: generalFieldErrors.escalationTierRowErrors,
|
|
1373
|
+
error: generalFieldErrors.escalationTiers,
|
|
1374
|
+
disabled: generalSaving,
|
|
1375
|
+
translations: generalTranslations.escalationTiers,
|
|
1376
|
+
loadStaffOptions: loadEscalationStaffOptions,
|
|
1377
|
+
resolveStaffLabel: resolveStaffUserLabel,
|
|
1378
|
+
onAddRow: addEscalationTierRow,
|
|
1379
|
+
onRemoveRow: removeEscalationTierRow,
|
|
1380
|
+
onAtPctChange: updateEscalationTierAtPct,
|
|
1381
|
+
onActionChange: updateEscalationTierAction,
|
|
1382
|
+
onUserChange: updateEscalationTierUser
|
|
1383
|
+
}
|
|
1384
|
+
)
|
|
1385
|
+
] }) }),
|
|
1386
|
+
/* @__PURE__ */ jsx(GeneralSettingsSubsection, { title: generalTranslations.sections.adjudication, children: /* @__PURE__ */ jsx(
|
|
1387
|
+
GeneralSwitchField,
|
|
1388
|
+
{
|
|
1389
|
+
id: "warranty-claims-adjudication-use-rules",
|
|
1390
|
+
label: generalTranslations.fields.adjudicationUseRules,
|
|
1391
|
+
description: generalTranslations.fields.adjudicationUseRulesHelp,
|
|
1392
|
+
checked: generalForm.adjudicationUseRules,
|
|
1393
|
+
disabled: generalSaving,
|
|
1394
|
+
onCheckedChange: (checked) => updateGeneralForm({ adjudicationUseRules: checked })
|
|
1395
|
+
}
|
|
1396
|
+
) }),
|
|
1397
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [
|
|
1398
|
+
/* @__PURE__ */ jsx(
|
|
1399
|
+
GeneralSwitchField,
|
|
1400
|
+
{
|
|
1401
|
+
id: "warranty-claims-auto-approve-enabled",
|
|
1402
|
+
label: generalTranslations.fields.autoApproveEnabled,
|
|
1403
|
+
description: generalTranslations.fields.autoApproveEnabledHelp,
|
|
1404
|
+
checked: generalForm.autoApproveEnabled,
|
|
1405
|
+
disabled: generalSaving,
|
|
1406
|
+
onCheckedChange: (checked) => updateGeneralForm({ autoApproveEnabled: checked })
|
|
1407
|
+
}
|
|
1408
|
+
),
|
|
1409
|
+
/* @__PURE__ */ jsx(
|
|
1410
|
+
GeneralSwitchField,
|
|
1411
|
+
{
|
|
1412
|
+
id: "warranty-claims-auto-approve-require-warranty",
|
|
1413
|
+
label: generalTranslations.fields.autoApproveRequireInWarranty,
|
|
1414
|
+
description: generalTranslations.fields.autoApproveRequireInWarrantyHelp,
|
|
1415
|
+
checked: generalForm.autoApproveRequireInWarranty,
|
|
1416
|
+
disabled: generalSaving || !generalForm.autoApproveEnabled,
|
|
1417
|
+
onCheckedChange: (checked) => updateGeneralForm({ autoApproveRequireInWarranty: checked })
|
|
1418
|
+
}
|
|
1419
|
+
)
|
|
1420
|
+
] }),
|
|
1421
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [
|
|
1422
|
+
/* @__PURE__ */ jsx(
|
|
1423
|
+
GeneralNumberField,
|
|
1424
|
+
{
|
|
1425
|
+
id: "warranty-claims-auto-approve-max-amount",
|
|
1426
|
+
label: generalTranslations.fields.autoApproveMaxAmount,
|
|
1427
|
+
description: generalTranslations.fields.autoApproveMaxAmountHelp,
|
|
1428
|
+
value: generalForm.autoApproveMaxAmount,
|
|
1429
|
+
min: 0,
|
|
1430
|
+
step: "0.01",
|
|
1431
|
+
disabled: generalSaving || !generalForm.autoApproveEnabled,
|
|
1432
|
+
onChange: (value) => updateGeneralForm({ autoApproveMaxAmount: value })
|
|
1433
|
+
}
|
|
1434
|
+
),
|
|
1435
|
+
/* @__PURE__ */ jsx(
|
|
1436
|
+
GeneralTextField,
|
|
1437
|
+
{
|
|
1438
|
+
id: "warranty-claims-auto-approve-currency",
|
|
1439
|
+
label: generalTranslations.fields.autoApproveCurrencyCode,
|
|
1440
|
+
description: generalTranslations.fields.autoApproveCurrencyCodeHelp,
|
|
1441
|
+
value: generalForm.autoApproveCurrencyCode,
|
|
1442
|
+
maxLength: 3,
|
|
1443
|
+
disabled: generalSaving || !generalForm.autoApproveEnabled,
|
|
1444
|
+
onChange: (value) => updateGeneralForm({ autoApproveCurrencyCode: normalizeCurrencyCodeInput(value) })
|
|
1445
|
+
}
|
|
1446
|
+
)
|
|
1447
|
+
] }),
|
|
1448
|
+
/* @__PURE__ */ jsx(GeneralSettingsSubsection, { title: generalTranslations.sections.receiving, children: /* @__PURE__ */ jsx(
|
|
1449
|
+
GeneralQuarantineGradesField,
|
|
1450
|
+
{
|
|
1451
|
+
id: "warranty-claims-quarantine-grades",
|
|
1452
|
+
label: generalTranslations.fields.quarantineGrades,
|
|
1453
|
+
description: generalTranslations.fields.quarantineGradesHelp,
|
|
1454
|
+
selected: generalForm.quarantineGrades,
|
|
1455
|
+
disabled: generalSaving,
|
|
1456
|
+
onToggle: (grade, checked) => updateGeneralForm({
|
|
1457
|
+
quarantineGrades: checked ? Array.from(/* @__PURE__ */ new Set([...generalForm.quarantineGrades, grade])) : generalForm.quarantineGrades.filter((item) => item !== grade)
|
|
1458
|
+
})
|
|
1459
|
+
}
|
|
1460
|
+
) }),
|
|
1461
|
+
/* @__PURE__ */ jsx(GeneralSettingsSubsection, { title: generalTranslations.sections.returns, children: /* @__PURE__ */ jsx("div", { className: "grid gap-4 md:grid-cols-2", children: /* @__PURE__ */ jsx(
|
|
1462
|
+
GeneralTextField,
|
|
1463
|
+
{
|
|
1464
|
+
id: "warranty-claims-return-label-provider",
|
|
1465
|
+
label: generalTranslations.fields.returnLabelProvider,
|
|
1466
|
+
description: generalTranslations.fields.returnLabelProviderHelp,
|
|
1467
|
+
value: generalForm.returnLabelProvider,
|
|
1468
|
+
maxLength: 120,
|
|
1469
|
+
disabled: generalSaving,
|
|
1470
|
+
onChange: (value) => updateGeneralForm({ returnLabelProvider: value })
|
|
1471
|
+
}
|
|
1472
|
+
) }) }),
|
|
1473
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap justify-end gap-2 border-t border-border pt-4", children: [
|
|
1474
|
+
/* @__PURE__ */ jsxs(
|
|
1475
|
+
Button,
|
|
1476
|
+
{
|
|
1477
|
+
type: "button",
|
|
1478
|
+
variant: "outline",
|
|
1479
|
+
disabled: generalSaving,
|
|
1480
|
+
onClick: () => {
|
|
1481
|
+
void loadGeneralSettings();
|
|
1482
|
+
},
|
|
1483
|
+
children: [
|
|
1484
|
+
/* @__PURE__ */ jsx(RefreshCw, { className: "size-4", "aria-hidden": "true" }),
|
|
1485
|
+
generalTranslations.refresh
|
|
1486
|
+
]
|
|
1487
|
+
}
|
|
1488
|
+
),
|
|
1489
|
+
/* @__PURE__ */ jsxs(Button, { type: "submit", disabled: generalSaving, children: [
|
|
1490
|
+
/* @__PURE__ */ jsx(Save, { className: "size-4", "aria-hidden": "true" }),
|
|
1491
|
+
generalSaving ? generalTranslations.saving : generalTranslations.save
|
|
1492
|
+
] })
|
|
1493
|
+
] })
|
|
1494
|
+
] }) })
|
|
1495
|
+
] }),
|
|
1496
|
+
SECTIONS.map((section) => /* @__PURE__ */ jsxs("section", { className: "border-t border-border bg-card text-card-foreground", children: [
|
|
1497
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1 border-b border-border px-6 py-4", children: [
|
|
1498
|
+
/* @__PURE__ */ jsx("h2", { className: "text-lg font-medium", children: t(section.titleKey) }),
|
|
1499
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t(section.descriptionKey) })
|
|
1500
|
+
] }),
|
|
1501
|
+
/* @__PURE__ */ jsx("div", { className: "px-2 py-4 sm:px-4", children: /* @__PURE__ */ jsx(
|
|
1502
|
+
DictionaryTable,
|
|
1503
|
+
{
|
|
1504
|
+
entries: (entriesByKind[section.kind] ?? []).map((entry) => ({
|
|
1505
|
+
...entry,
|
|
1506
|
+
label: localizeDictionaryLabel(t, DICTIONARY_LABEL_KINDS[section.kind], entry.value, entry.label)
|
|
1507
|
+
})),
|
|
1508
|
+
loading: loadingKind[section.kind] ?? false,
|
|
1509
|
+
canManage: true,
|
|
1510
|
+
onCreate: () => startCreate(section.kind),
|
|
1511
|
+
onEdit: (entry) => startEdit(section.kind, resolveRawEntry(section.kind, entry)),
|
|
1512
|
+
onDelete: (entry) => {
|
|
1513
|
+
void deleteEntry(section.kind, resolveRawEntry(section.kind, entry));
|
|
1514
|
+
},
|
|
1515
|
+
onRefresh: () => {
|
|
1516
|
+
void loadEntries(section);
|
|
1517
|
+
},
|
|
1518
|
+
translations: { ...tableTranslations, title: t(section.titleKey) }
|
|
1519
|
+
}
|
|
1520
|
+
) })
|
|
1521
|
+
] }, section.kind))
|
|
1522
|
+
] }) }),
|
|
1523
|
+
/* @__PURE__ */ jsx(Dialog, { open: dialog !== null, onOpenChange: (open) => {
|
|
1524
|
+
if (!open) closeDialog();
|
|
1525
|
+
}, children: /* @__PURE__ */ jsxs(
|
|
1526
|
+
DialogContent,
|
|
1527
|
+
{
|
|
1528
|
+
className: "max-w-lg",
|
|
1529
|
+
onKeyDown: (event) => {
|
|
1530
|
+
if ((event.metaKey || event.ctrlKey) && event.key === "Enter") {
|
|
1531
|
+
event.preventDefault();
|
|
1532
|
+
event.currentTarget.querySelector("form")?.requestSubmit();
|
|
1533
|
+
}
|
|
1534
|
+
},
|
|
1535
|
+
children: [
|
|
1536
|
+
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: dialog?.mode === "edit" ? formTranslations.editTitle : formTranslations.createTitle }) }),
|
|
1537
|
+
/* @__PURE__ */ jsx(
|
|
1538
|
+
DictionaryForm,
|
|
1539
|
+
{
|
|
1540
|
+
mode: dialog?.mode === "edit" ? "edit" : "create",
|
|
1541
|
+
initialValues: currentValues,
|
|
1542
|
+
onSubmit: submitForm,
|
|
1543
|
+
onCancel: closeDialog,
|
|
1544
|
+
submitting,
|
|
1545
|
+
translations: {
|
|
1546
|
+
title: dialog?.mode === "edit" ? formTranslations.editTitle : formTranslations.createTitle,
|
|
1547
|
+
valueLabel: formTranslations.valueLabel,
|
|
1548
|
+
labelLabel: formTranslations.labelLabel,
|
|
1549
|
+
saveLabel: formTranslations.saveLabel,
|
|
1550
|
+
cancelLabel: formTranslations.cancelLabel,
|
|
1551
|
+
appearance: formTranslations.appearance
|
|
1552
|
+
},
|
|
1553
|
+
iconSuggestions: ICON_SUGGESTIONS
|
|
1554
|
+
}
|
|
1555
|
+
)
|
|
1556
|
+
]
|
|
1557
|
+
}
|
|
1558
|
+
) }),
|
|
1559
|
+
ConfirmDialogElement
|
|
1560
|
+
] });
|
|
1561
|
+
}
|
|
1562
|
+
export {
|
|
1563
|
+
WarrantyClaimSettingsPage as default
|
|
1564
|
+
};
|
|
1565
|
+
//# sourceMappingURL=page.js.map
|