@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,1249 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useRouter, useSearchParams } from "next/navigation";
|
|
5
|
+
import { CheckCircle2, Plus, ShieldCheck } from "lucide-react";
|
|
6
|
+
import { Page, PageBody } from "@open-mercato/ui/backend/Page";
|
|
7
|
+
import { CrudForm } from "@open-mercato/ui/backend/CrudForm";
|
|
8
|
+
import { DataTable } from "@open-mercato/ui/backend/DataTable";
|
|
9
|
+
import { RowActions } from "@open-mercato/ui/backend/RowActions";
|
|
10
|
+
import { createCrud } from "@open-mercato/ui/backend/utils/crud";
|
|
11
|
+
import { createCrudFormError } from "@open-mercato/ui/backend/utils/serverErrors";
|
|
12
|
+
import { apiCall, readApiResultOrThrow } from "@open-mercato/ui/backend/utils/apiCall";
|
|
13
|
+
import { flash } from "@open-mercato/ui/backend/FlashMessages";
|
|
14
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
15
|
+
import { Checkbox } from "@open-mercato/ui/primitives/checkbox";
|
|
16
|
+
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@open-mercato/ui/primitives/dialog";
|
|
17
|
+
import { EmptyState } from "@open-mercato/ui/primitives/empty-state";
|
|
18
|
+
import { Input } from "@open-mercato/ui/primitives/input";
|
|
19
|
+
import { Label } from "@open-mercato/ui/primitives/label";
|
|
20
|
+
import { Spinner } from "@open-mercato/ui/primitives/spinner";
|
|
21
|
+
import {
|
|
22
|
+
Select,
|
|
23
|
+
SelectContent,
|
|
24
|
+
SelectItem,
|
|
25
|
+
SelectTrigger,
|
|
26
|
+
SelectValue
|
|
27
|
+
} from "@open-mercato/ui/primitives/select";
|
|
28
|
+
import { Textarea } from "@open-mercato/ui/primitives/textarea";
|
|
29
|
+
import { CollapsibleSection } from "@open-mercato/ui/backend/SectionHeader";
|
|
30
|
+
import { useT } from "@open-mercato/shared/lib/i18n/context";
|
|
31
|
+
import {
|
|
32
|
+
ClaimLineProductPicker,
|
|
33
|
+
EntitlementChip,
|
|
34
|
+
computeEntitlementPreview
|
|
35
|
+
} from "../../components/productLookup.js";
|
|
36
|
+
import {
|
|
37
|
+
loadOrderOptions as loadOrderOptionsShared,
|
|
38
|
+
resolveOrderLabel
|
|
39
|
+
} from "../../components/orderLookup.js";
|
|
40
|
+
import { EntitlementLookupBadge } from "../../components/EntitlementLookupBadge.js";
|
|
41
|
+
import { TroubleshootingWalker } from "../../components/TroubleshootingWalker.js";
|
|
42
|
+
import { resolveClaimTypeUiConfig } from "../../../lib/claimTypeConfig.js";
|
|
43
|
+
import { formatQuantity, parseQuantity } from "../../../lib/quantity.js";
|
|
44
|
+
import { localizeDictionaryLabel } from "../../../lib/dictionaryLabels.js";
|
|
45
|
+
import {
|
|
46
|
+
parseGuideSteps,
|
|
47
|
+
selectBestGuide
|
|
48
|
+
} from "../../../lib/troubleshooting.js";
|
|
49
|
+
const ORDER_LINE_PAGE_SIZE = 100;
|
|
50
|
+
const ORDER_LINE_MAX_FETCH = 2e3;
|
|
51
|
+
const MAX_CLAIM_LINES = 200;
|
|
52
|
+
const LINE_PAGE_SIZE = 20;
|
|
53
|
+
const CLAIM_TYPES = ["warranty", "return", "core_return"];
|
|
54
|
+
const CLAIM_PRIORITIES = ["low", "normal", "high", "urgent"];
|
|
55
|
+
const DICTIONARY_KEYS = {
|
|
56
|
+
faultCodes: "warranty_claims.warranty_claim_fault_code",
|
|
57
|
+
claimReasons: "warranty_claims.warranty_claim_reason"
|
|
58
|
+
};
|
|
59
|
+
function normalizeClaimType(value) {
|
|
60
|
+
return CLAIM_TYPES.find((claimType) => claimType === value) ?? "warranty";
|
|
61
|
+
}
|
|
62
|
+
function isRecord(value) {
|
|
63
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
64
|
+
}
|
|
65
|
+
function toStringOrNull(value) {
|
|
66
|
+
return typeof value === "string" && value.trim().length ? value.trim() : null;
|
|
67
|
+
}
|
|
68
|
+
function normalizeOption(item, t) {
|
|
69
|
+
if (!isRecord(item)) return null;
|
|
70
|
+
const id = toStringOrNull(item.id);
|
|
71
|
+
if (!id) return null;
|
|
72
|
+
const label = toStringOrNull(item.label) ?? toStringOrNull(item.displayName) ?? toStringOrNull(item.display_name) ?? toStringOrNull(item.name) ?? t("warranty_claims.form.customerUnnamed", "Unnamed customer");
|
|
73
|
+
const email = toStringOrNull(item.primaryEmail) ?? toStringOrNull(item.primary_email);
|
|
74
|
+
return { value: id, label: email ? `${label} (${email})` : label };
|
|
75
|
+
}
|
|
76
|
+
function normalizeDictionaryOption(item) {
|
|
77
|
+
if (!isRecord(item)) return null;
|
|
78
|
+
const value = toStringOrNull(item.value);
|
|
79
|
+
if (!value) return null;
|
|
80
|
+
const label = toStringOrNull(item.label) ?? value;
|
|
81
|
+
return { value, label };
|
|
82
|
+
}
|
|
83
|
+
function readBoolean(value) {
|
|
84
|
+
return value === true || value === "true" || value === 1 || value === "1";
|
|
85
|
+
}
|
|
86
|
+
function normalizeTroubleshootingGuideCandidate(item) {
|
|
87
|
+
if (!isRecord(item)) return null;
|
|
88
|
+
const id = toStringOrNull(item.id);
|
|
89
|
+
const title = toStringOrNull(item.title);
|
|
90
|
+
if (!id || !title) return null;
|
|
91
|
+
return {
|
|
92
|
+
id,
|
|
93
|
+
title,
|
|
94
|
+
claimType: toStringOrNull(item.claimType) ?? toStringOrNull(item.claim_type),
|
|
95
|
+
reasonCode: toStringOrNull(item.reasonCode) ?? toStringOrNull(item.reason_code),
|
|
96
|
+
isActive: readBoolean(item.isActive ?? item.is_active)
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function normalizeTroubleshootingGuideDetail(item) {
|
|
100
|
+
const candidate = normalizeTroubleshootingGuideCandidate(item);
|
|
101
|
+
if (!candidate || !isRecord(item)) return null;
|
|
102
|
+
return {
|
|
103
|
+
...candidate,
|
|
104
|
+
steps: parseGuideSteps(item.steps)
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
async function loadStaffTroubleshootingGuide(claimType, reasonCode) {
|
|
108
|
+
if (!claimType) return null;
|
|
109
|
+
const listParams = new URLSearchParams({
|
|
110
|
+
isActive: "true",
|
|
111
|
+
page: "1",
|
|
112
|
+
pageSize: "100",
|
|
113
|
+
sortField: "updatedAt",
|
|
114
|
+
sortDir: "desc"
|
|
115
|
+
});
|
|
116
|
+
const listCall = await apiCall(
|
|
117
|
+
`/api/warranty_claims/troubleshooting-guides?${listParams.toString()}`,
|
|
118
|
+
void 0,
|
|
119
|
+
{ fallback: { items: [] } }
|
|
120
|
+
);
|
|
121
|
+
if (!listCall.ok) return null;
|
|
122
|
+
const candidates = (listCall.result?.items ?? []).map(normalizeTroubleshootingGuideCandidate).filter((guide) => guide !== null);
|
|
123
|
+
const selected = selectBestGuide(candidates, claimType, reasonCode);
|
|
124
|
+
if (!selected) return null;
|
|
125
|
+
const detailParams = new URLSearchParams({
|
|
126
|
+
ids: selected.id,
|
|
127
|
+
page: "1",
|
|
128
|
+
pageSize: "1"
|
|
129
|
+
});
|
|
130
|
+
const detailCall = await apiCall(
|
|
131
|
+
`/api/warranty_claims/troubleshooting-guides?${detailParams.toString()}`,
|
|
132
|
+
void 0,
|
|
133
|
+
{ fallback: { items: [] } }
|
|
134
|
+
);
|
|
135
|
+
if (!detailCall.ok) return null;
|
|
136
|
+
const detail = normalizeTroubleshootingGuideDetail(detailCall.result?.items?.[0]);
|
|
137
|
+
if (!detail?.steps) return null;
|
|
138
|
+
return { title: detail.title, steps: detail.steps };
|
|
139
|
+
}
|
|
140
|
+
function readCatalogSnapshotName(value) {
|
|
141
|
+
if (!isRecord(value)) return null;
|
|
142
|
+
const product = isRecord(value.product) ? value.product : null;
|
|
143
|
+
const variant = isRecord(value.variant) ? value.variant : null;
|
|
144
|
+
return toStringOrNull(variant?.title) ?? toStringOrNull(product?.title) ?? null;
|
|
145
|
+
}
|
|
146
|
+
function normalizeSalesOrderLine(item) {
|
|
147
|
+
if (!isRecord(item)) return null;
|
|
148
|
+
const id = toStringOrNull(item.id);
|
|
149
|
+
if (!id) return null;
|
|
150
|
+
const kind = toStringOrNull(item.kind);
|
|
151
|
+
if (kind !== "product") return null;
|
|
152
|
+
return {
|
|
153
|
+
id,
|
|
154
|
+
productId: toStringOrNull(item.product_id) ?? toStringOrNull(item.productId),
|
|
155
|
+
variantId: toStringOrNull(item.product_variant_id) ?? toStringOrNull(item.productVariantId),
|
|
156
|
+
sku: toStringOrNull(item.sku),
|
|
157
|
+
name: toStringOrNull(item.name) ?? readCatalogSnapshotName(item.catalog_snapshot ?? item.catalogSnapshot),
|
|
158
|
+
quantity: typeof item.quantity === "number" || typeof item.quantity === "string" ? item.quantity : null
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function nullableText(value) {
|
|
162
|
+
const next = toStringOrNull(value);
|
|
163
|
+
return next ?? null;
|
|
164
|
+
}
|
|
165
|
+
function stringifyFieldValue(value) {
|
|
166
|
+
if (typeof value === "number") return String(value);
|
|
167
|
+
if (typeof value === "string") return value;
|
|
168
|
+
return "";
|
|
169
|
+
}
|
|
170
|
+
function dateInputValue(value) {
|
|
171
|
+
if (typeof value !== "string") return "";
|
|
172
|
+
const trimmed = value.trim();
|
|
173
|
+
return trimmed.length >= 10 ? trimmed.slice(0, 10) : trimmed;
|
|
174
|
+
}
|
|
175
|
+
function dateFromInputValue(value) {
|
|
176
|
+
const dateValue = dateInputValue(value);
|
|
177
|
+
if (!dateValue) return null;
|
|
178
|
+
const date = /* @__PURE__ */ new Date(`${dateValue}T00:00:00.000Z`);
|
|
179
|
+
return Number.isNaN(date.getTime()) ? null : date;
|
|
180
|
+
}
|
|
181
|
+
function parsePositiveNumber(value) {
|
|
182
|
+
if (typeof value === "number") return Number.isFinite(value) && value > 0 ? value : null;
|
|
183
|
+
if (typeof value !== "string") return null;
|
|
184
|
+
const trimmed = value.trim();
|
|
185
|
+
if (!trimmed) return null;
|
|
186
|
+
const parsed = Number(trimmed);
|
|
187
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
|
|
188
|
+
}
|
|
189
|
+
function parseWarrantyMonths(value) {
|
|
190
|
+
if (typeof value === "number") return Number.isInteger(value) && value >= 0 ? value : null;
|
|
191
|
+
if (typeof value !== "string") return null;
|
|
192
|
+
const trimmed = value.trim();
|
|
193
|
+
if (!trimmed) return null;
|
|
194
|
+
const parsed = Number(trimmed);
|
|
195
|
+
return Number.isInteger(parsed) && parsed >= 0 ? parsed : null;
|
|
196
|
+
}
|
|
197
|
+
function isWarrantyMonthsEmpty(value) {
|
|
198
|
+
if (value === null || value === void 0) return true;
|
|
199
|
+
return typeof value === "string" && !value.trim();
|
|
200
|
+
}
|
|
201
|
+
function normalizeDateOnly(value) {
|
|
202
|
+
const normalized = dateInputValue(value);
|
|
203
|
+
return normalized || null;
|
|
204
|
+
}
|
|
205
|
+
function assignStringIfSet(payload, key, value) {
|
|
206
|
+
const normalized = nullableText(value);
|
|
207
|
+
if (normalized) payload[key] = normalized;
|
|
208
|
+
}
|
|
209
|
+
function readDefaultWarrantyMonths(value) {
|
|
210
|
+
if (!isRecord(value)) return null;
|
|
211
|
+
const settings = isRecord(value.result) ? value.result : value;
|
|
212
|
+
const months = parseWarrantyMonths(settings.defaultWarrantyMonths ?? settings.default_warranty_months);
|
|
213
|
+
return months;
|
|
214
|
+
}
|
|
215
|
+
function matchesLineSearch(line, term) {
|
|
216
|
+
if (!term) return true;
|
|
217
|
+
const haystack = [line.productName, line.sku, line.serialNumber].map((value) => nullableText(value) ?? "").join(" ").toLowerCase();
|
|
218
|
+
return haystack.includes(term);
|
|
219
|
+
}
|
|
220
|
+
async function loadAllOrderProductLines(orderId) {
|
|
221
|
+
const encodedOrderId = encodeURIComponent(orderId);
|
|
222
|
+
const collected = [];
|
|
223
|
+
for (let page = 1; ; page += 1) {
|
|
224
|
+
const call = await apiCall(
|
|
225
|
+
`/api/sales/order-lines?orderId=${encodedOrderId}&page=${page}&pageSize=${ORDER_LINE_PAGE_SIZE}`
|
|
226
|
+
);
|
|
227
|
+
if (call.status === 403) return { status: "forbidden" };
|
|
228
|
+
if (!call.ok) {
|
|
229
|
+
return page === 1 ? { status: "error" } : { status: "ok", lines: collected, truncated: true };
|
|
230
|
+
}
|
|
231
|
+
const items = Array.isArray(call.result?.items) ? call.result.items : [];
|
|
232
|
+
for (const item of items) {
|
|
233
|
+
const line = normalizeSalesOrderLine(item);
|
|
234
|
+
if (line) collected.push(line);
|
|
235
|
+
}
|
|
236
|
+
if (items.length < ORDER_LINE_PAGE_SIZE) return { status: "ok", lines: collected, truncated: false };
|
|
237
|
+
if (page * ORDER_LINE_PAGE_SIZE >= ORDER_LINE_MAX_FETCH) {
|
|
238
|
+
return { status: "ok", lines: collected, truncated: true };
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
function createDefaultLine() {
|
|
243
|
+
return {
|
|
244
|
+
productId: null,
|
|
245
|
+
variantId: null,
|
|
246
|
+
orderLineId: null,
|
|
247
|
+
productName: "",
|
|
248
|
+
sku: "",
|
|
249
|
+
serialNumber: "",
|
|
250
|
+
purchaseDate: "",
|
|
251
|
+
warrantyMonths: "",
|
|
252
|
+
faultCode: null,
|
|
253
|
+
faultDescription: "",
|
|
254
|
+
qtyClaimed: 1
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function normalizeLineValue(value) {
|
|
258
|
+
if (!isRecord(value)) return createDefaultLine();
|
|
259
|
+
return {
|
|
260
|
+
productId: nullableText(value.productId),
|
|
261
|
+
variantId: nullableText(value.variantId),
|
|
262
|
+
orderLineId: nullableText(value.orderLineId),
|
|
263
|
+
productName: stringifyFieldValue(value.productName),
|
|
264
|
+
sku: stringifyFieldValue(value.sku),
|
|
265
|
+
serialNumber: stringifyFieldValue(value.serialNumber),
|
|
266
|
+
purchaseDate: dateInputValue(value.purchaseDate),
|
|
267
|
+
warrantyMonths: typeof value.warrantyMonths === "number" || typeof value.warrantyMonths === "string" ? value.warrantyMonths : "",
|
|
268
|
+
faultCode: nullableText(value.faultCode),
|
|
269
|
+
faultDescription: stringifyFieldValue(value.faultDescription),
|
|
270
|
+
qtyClaimed: typeof value.qtyClaimed === "number" || typeof value.qtyClaimed === "string" ? value.qtyClaimed : ""
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
function readLineValues(value) {
|
|
274
|
+
if (!Array.isArray(value)) return [createDefaultLine()];
|
|
275
|
+
const rows = value.map(normalizeLineValue);
|
|
276
|
+
return rows.length ? rows : [createDefaultLine()];
|
|
277
|
+
}
|
|
278
|
+
function readSubmittedLineValues(value) {
|
|
279
|
+
if (!Array.isArray(value)) return [];
|
|
280
|
+
return value.map(normalizeLineValue);
|
|
281
|
+
}
|
|
282
|
+
function lineHasContentBeyondQuantity(line) {
|
|
283
|
+
return Boolean(
|
|
284
|
+
nullableText(line.productId) || nullableText(line.variantId) || nullableText(line.orderLineId) || nullableText(line.productName) || nullableText(line.sku) || nullableText(line.serialNumber) || normalizeDateOnly(line.purchaseDate) || parseWarrantyMonths(line.warrantyMonths) !== null || nullableText(line.faultCode) || nullableText(line.faultDescription)
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
function lineHasContent(line) {
|
|
288
|
+
return Boolean(
|
|
289
|
+
nullableText(line.productId) || nullableText(line.variantId) || nullableText(line.orderLineId) || nullableText(line.productName) || nullableText(line.sku) || nullableText(line.serialNumber) || normalizeDateOnly(line.purchaseDate) || parseWarrantyMonths(line.warrantyMonths) !== null || nullableText(line.faultCode) || nullableText(line.faultDescription) || parsePositiveNumber(line.qtyClaimed) !== null
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
function normalizeLinePayload(line) {
|
|
293
|
+
const payload = {
|
|
294
|
+
qtyClaimed: parsePositiveNumber(line.qtyClaimed) ?? 1
|
|
295
|
+
};
|
|
296
|
+
assignStringIfSet(payload, "productId", line.productId);
|
|
297
|
+
assignStringIfSet(payload, "variantId", line.variantId);
|
|
298
|
+
assignStringIfSet(payload, "orderLineId", line.orderLineId);
|
|
299
|
+
assignStringIfSet(payload, "productName", line.productName);
|
|
300
|
+
assignStringIfSet(payload, "sku", line.sku);
|
|
301
|
+
assignStringIfSet(payload, "serialNumber", line.serialNumber);
|
|
302
|
+
assignStringIfSet(payload, "faultCode", line.faultCode);
|
|
303
|
+
assignStringIfSet(payload, "faultDescription", line.faultDescription);
|
|
304
|
+
const purchaseDate = normalizeDateOnly(line.purchaseDate);
|
|
305
|
+
if (purchaseDate) payload.purchaseDate = purchaseDate;
|
|
306
|
+
const warrantyMonths = parseWarrantyMonths(line.warrantyMonths);
|
|
307
|
+
if (warrantyMonths !== null) payload.warrantyMonths = warrantyMonths;
|
|
308
|
+
return payload;
|
|
309
|
+
}
|
|
310
|
+
function CustomerSelectionObserver({
|
|
311
|
+
value,
|
|
312
|
+
onChange
|
|
313
|
+
}) {
|
|
314
|
+
const customerId = nullableText(value);
|
|
315
|
+
React.useEffect(() => {
|
|
316
|
+
onChange(customerId);
|
|
317
|
+
}, [customerId, onChange]);
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
function ClaimTypeSelectionObserver({
|
|
321
|
+
value,
|
|
322
|
+
onChange
|
|
323
|
+
}) {
|
|
324
|
+
const claimType = nullableText(value) ?? "warranty";
|
|
325
|
+
React.useEffect(() => {
|
|
326
|
+
onChange((current) => current === claimType ? current : claimType);
|
|
327
|
+
}, [claimType, onChange]);
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
function ReasonCodeSelectionObserver({
|
|
331
|
+
value,
|
|
332
|
+
onChange
|
|
333
|
+
}) {
|
|
334
|
+
const reasonCode = nullableText(value);
|
|
335
|
+
React.useEffect(() => {
|
|
336
|
+
onChange((current) => current === reasonCode ? current : reasonCode);
|
|
337
|
+
}, [reasonCode, onChange]);
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
340
|
+
function GuidedTroubleshootingSection({
|
|
341
|
+
claimType,
|
|
342
|
+
reasonCode,
|
|
343
|
+
onResolve,
|
|
344
|
+
t
|
|
345
|
+
}) {
|
|
346
|
+
const [guide, setGuide] = React.useState(null);
|
|
347
|
+
const [loading, setLoading] = React.useState(false);
|
|
348
|
+
React.useEffect(() => {
|
|
349
|
+
if (!claimType) {
|
|
350
|
+
setGuide(null);
|
|
351
|
+
setLoading(false);
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
let cancelled = false;
|
|
355
|
+
const timer = window.setTimeout(() => {
|
|
356
|
+
setLoading(true);
|
|
357
|
+
void loadStaffTroubleshootingGuide(claimType, reasonCode).then((nextGuide) => {
|
|
358
|
+
if (!cancelled) setGuide(nextGuide);
|
|
359
|
+
}).catch(() => {
|
|
360
|
+
if (!cancelled) setGuide(null);
|
|
361
|
+
}).finally(() => {
|
|
362
|
+
if (!cancelled) setLoading(false);
|
|
363
|
+
});
|
|
364
|
+
}, 300);
|
|
365
|
+
return () => {
|
|
366
|
+
cancelled = true;
|
|
367
|
+
window.clearTimeout(timer);
|
|
368
|
+
};
|
|
369
|
+
}, [claimType, reasonCode]);
|
|
370
|
+
if (!guide && !loading) return null;
|
|
371
|
+
return /* @__PURE__ */ jsx(
|
|
372
|
+
CollapsibleSection,
|
|
373
|
+
{
|
|
374
|
+
title: t("warranty_claims.form.troubleshooting.title", "Guided troubleshooting"),
|
|
375
|
+
defaultCollapsed: true,
|
|
376
|
+
contentClassName: "rounded-lg border border-border bg-muted/30 p-4",
|
|
377
|
+
children: loading && !guide ? /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-2 text-sm text-muted-foreground", children: [
|
|
378
|
+
/* @__PURE__ */ jsx(Spinner, { size: "sm" }),
|
|
379
|
+
t("warranty_claims.form.troubleshooting.loading", "Loading guide...")
|
|
380
|
+
] }) : /* @__PURE__ */ jsx(TroubleshootingWalker, { guide, onResolve })
|
|
381
|
+
}
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
function LineItemsEditor({
|
|
385
|
+
value,
|
|
386
|
+
setLines,
|
|
387
|
+
orderId,
|
|
388
|
+
defaultWarrantyMonths,
|
|
389
|
+
error,
|
|
390
|
+
faultCodeOptions,
|
|
391
|
+
translations,
|
|
392
|
+
t
|
|
393
|
+
}) {
|
|
394
|
+
const lines = readLineValues(value);
|
|
395
|
+
const noValue = t("warranty_claims.common.noValue");
|
|
396
|
+
const [orderDialogOpen, setOrderDialogOpen] = React.useState(false);
|
|
397
|
+
const [orderLines, setOrderLines] = React.useState([]);
|
|
398
|
+
const [selectedOrderLineIds, setSelectedOrderLineIds] = React.useState(/* @__PURE__ */ new Set());
|
|
399
|
+
const [orderPurchaseDate, setOrderPurchaseDate] = React.useState(null);
|
|
400
|
+
const [orderLinesLoading, setOrderLinesLoading] = React.useState(false);
|
|
401
|
+
const [orderLinesTruncated, setOrderLinesTruncated] = React.useState(false);
|
|
402
|
+
const [orderLineSearch, setOrderLineSearch] = React.useState("");
|
|
403
|
+
const [hideOrderImport, setHideOrderImport] = React.useState(false);
|
|
404
|
+
const [lineSearch, setLineSearch] = React.useState("");
|
|
405
|
+
const [linePage, setLinePage] = React.useState(1);
|
|
406
|
+
const [lineDialog, setLineDialog] = React.useState(null);
|
|
407
|
+
const [lineDraft, setLineDraft] = React.useState(createDefaultLine);
|
|
408
|
+
const editorRef = React.useRef(null);
|
|
409
|
+
React.useEffect(() => {
|
|
410
|
+
if (defaultWarrantyMonths === null) return;
|
|
411
|
+
let changed = false;
|
|
412
|
+
const next = lines.map((line) => {
|
|
413
|
+
if (!normalizeDateOnly(line.purchaseDate) || !isWarrantyMonthsEmpty(line.warrantyMonths)) return line;
|
|
414
|
+
changed = true;
|
|
415
|
+
return { ...line, warrantyMonths: defaultWarrantyMonths };
|
|
416
|
+
});
|
|
417
|
+
if (changed) setLines(next);
|
|
418
|
+
}, [defaultWarrantyMonths, lines, setLines]);
|
|
419
|
+
const searchTerm = lineSearch.trim().toLowerCase();
|
|
420
|
+
const rows = lines.map((line, index) => ({
|
|
421
|
+
...line,
|
|
422
|
+
id: `claim-line-${index}`,
|
|
423
|
+
index,
|
|
424
|
+
lineNo: index + 1
|
|
425
|
+
}));
|
|
426
|
+
const filteredRows = searchTerm ? rows.filter((row) => matchesLineSearch(row, searchTerm)) : rows;
|
|
427
|
+
const totalPages = Math.max(1, Math.ceil(filteredRows.length / LINE_PAGE_SIZE));
|
|
428
|
+
const currentPage = Math.min(Math.max(1, linePage), totalPages);
|
|
429
|
+
const pageRows = filteredRows.slice((currentPage - 1) * LINE_PAGE_SIZE, currentPage * LINE_PAGE_SIZE);
|
|
430
|
+
const exceedsLineCap = React.useCallback((currentCount, addingCount) => {
|
|
431
|
+
if (currentCount + addingCount <= MAX_CLAIM_LINES) return false;
|
|
432
|
+
flash(
|
|
433
|
+
t("warranty_claims.form.lines.error.maxLines", "A claim can hold at most {max} lines. Remove some lines or select fewer.", {
|
|
434
|
+
max: String(MAX_CLAIM_LINES)
|
|
435
|
+
}),
|
|
436
|
+
"error"
|
|
437
|
+
);
|
|
438
|
+
return true;
|
|
439
|
+
}, [t]);
|
|
440
|
+
const revealLastPage = React.useCallback((total) => {
|
|
441
|
+
setLineSearch("");
|
|
442
|
+
setLinePage(Math.max(1, Math.ceil(total / LINE_PAGE_SIZE)));
|
|
443
|
+
requestAnimationFrame(() => {
|
|
444
|
+
editorRef.current?.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
445
|
+
});
|
|
446
|
+
}, []);
|
|
447
|
+
const handleSearchChange = React.useCallback((next) => {
|
|
448
|
+
setLineSearch(next);
|
|
449
|
+
setLinePage(1);
|
|
450
|
+
}, []);
|
|
451
|
+
const updateDraft = React.useCallback((patch) => {
|
|
452
|
+
setLineDraft((current) => ({ ...current, ...patch }));
|
|
453
|
+
}, []);
|
|
454
|
+
const updateDraftPurchaseDate = React.useCallback((purchaseDate) => {
|
|
455
|
+
setLineDraft((current) => {
|
|
456
|
+
const next = { ...current, purchaseDate };
|
|
457
|
+
if (purchaseDate && defaultWarrantyMonths !== null && isWarrantyMonthsEmpty(current.warrantyMonths)) {
|
|
458
|
+
next.warrantyMonths = defaultWarrantyMonths;
|
|
459
|
+
}
|
|
460
|
+
return next;
|
|
461
|
+
});
|
|
462
|
+
}, [defaultWarrantyMonths]);
|
|
463
|
+
const openCreateDialog = React.useCallback(() => {
|
|
464
|
+
if (exceedsLineCap(lines.length, 1)) return;
|
|
465
|
+
setLineDraft(createDefaultLine());
|
|
466
|
+
setLineDialog({ mode: "create" });
|
|
467
|
+
}, [exceedsLineCap, lines.length]);
|
|
468
|
+
const openEditDialog = React.useCallback((row) => {
|
|
469
|
+
setLineDraft(lines[row.index] ?? createDefaultLine());
|
|
470
|
+
setLineDialog({ mode: "edit", index: row.index });
|
|
471
|
+
}, [lines]);
|
|
472
|
+
const submitLineDialog = React.useCallback(() => {
|
|
473
|
+
if (!lineDialog) return;
|
|
474
|
+
if (lineDialog.mode === "edit") {
|
|
475
|
+
setLines(lines.map((line, index) => index === lineDialog.index ? lineDraft : line));
|
|
476
|
+
setLineDialog(null);
|
|
477
|
+
return;
|
|
478
|
+
}
|
|
479
|
+
const nextLines = [...lines, lineDraft];
|
|
480
|
+
setLines(nextLines);
|
|
481
|
+
setLineDialog(null);
|
|
482
|
+
revealLastPage(nextLines.length);
|
|
483
|
+
}, [lineDialog, lineDraft, lines, revealLastPage, setLines]);
|
|
484
|
+
const removeLine = React.useCallback((index) => {
|
|
485
|
+
if (lines.length <= 1) return;
|
|
486
|
+
setLines(lines.filter((_, lineIndex) => lineIndex !== index));
|
|
487
|
+
setLinePage((current) => Math.min(current, Math.max(1, Math.ceil((filteredRows.length - 1) / LINE_PAGE_SIZE))));
|
|
488
|
+
}, [filteredRows.length, lines, setLines]);
|
|
489
|
+
const faultCodeLabels = React.useMemo(() => {
|
|
490
|
+
const labels = /* @__PURE__ */ new Map();
|
|
491
|
+
for (const option of faultCodeOptions) labels.set(option.value, option.label);
|
|
492
|
+
return labels;
|
|
493
|
+
}, [faultCodeOptions]);
|
|
494
|
+
const columns = React.useMemo(() => [
|
|
495
|
+
{
|
|
496
|
+
accessorKey: "lineNo",
|
|
497
|
+
header: t("warranty_claims.form.lineNo"),
|
|
498
|
+
meta: { maxWidth: "80px" },
|
|
499
|
+
cell: ({ row }) => /* @__PURE__ */ jsx("span", { className: "font-mono text-xs", children: row.original.lineNo })
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
accessorKey: "productName",
|
|
503
|
+
header: translations.productName,
|
|
504
|
+
meta: { maxWidth: "240px" },
|
|
505
|
+
cell: ({ row }) => /* @__PURE__ */ jsx("span", { className: "font-medium", children: nullableText(row.original.productName) ?? nullableText(row.original.sku) ?? noValue })
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
accessorKey: "serialNumber",
|
|
509
|
+
header: translations.serialNumber,
|
|
510
|
+
meta: { maxWidth: "180px" },
|
|
511
|
+
cell: ({ row }) => nullableText(row.original.serialNumber) ?? noValue
|
|
512
|
+
},
|
|
513
|
+
{
|
|
514
|
+
accessorKey: "qtyClaimed",
|
|
515
|
+
header: t("warranty_claims.lines.header.qtyClaimed"),
|
|
516
|
+
meta: { maxWidth: "120px" },
|
|
517
|
+
cell: ({ row }) => formatQuantity(parseQuantity(stringifyFieldValue(row.original.qtyClaimed)), noValue)
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
accessorKey: "faultCode",
|
|
521
|
+
header: translations.faultCode,
|
|
522
|
+
meta: { maxWidth: "200px" },
|
|
523
|
+
cell: ({ row }) => {
|
|
524
|
+
const faultCode = nullableText(row.original.faultCode);
|
|
525
|
+
if (!faultCode) return noValue;
|
|
526
|
+
return faultCodeLabels.get(faultCode) ?? faultCode;
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
], [faultCodeLabels, noValue, t, translations.faultCode, translations.productName, translations.serialNumber]);
|
|
530
|
+
const openOrderImportDialog = React.useCallback(async () => {
|
|
531
|
+
if (!orderId) return;
|
|
532
|
+
setOrderDialogOpen(true);
|
|
533
|
+
setOrderLinesLoading(true);
|
|
534
|
+
setOrderLines([]);
|
|
535
|
+
setSelectedOrderLineIds(/* @__PURE__ */ new Set());
|
|
536
|
+
setOrderPurchaseDate(null);
|
|
537
|
+
setOrderLinesTruncated(false);
|
|
538
|
+
setOrderLineSearch("");
|
|
539
|
+
const encodedOrderId = encodeURIComponent(orderId);
|
|
540
|
+
try {
|
|
541
|
+
const [linesFetch, orderCall] = await Promise.all([
|
|
542
|
+
loadAllOrderProductLines(orderId),
|
|
543
|
+
apiCall(`/api/sales/orders?id=${encodedOrderId}&pageSize=1`)
|
|
544
|
+
]);
|
|
545
|
+
if (linesFetch.status === "forbidden" || orderCall.status === 403) {
|
|
546
|
+
setHideOrderImport(true);
|
|
547
|
+
setOrderDialogOpen(false);
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
if (linesFetch.status === "error" || !orderCall.ok) {
|
|
551
|
+
flash(t("warranty_claims.form.addFromOrder.error"), "error");
|
|
552
|
+
setOrderDialogOpen(false);
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
const order = Array.isArray(orderCall.result?.items) ? orderCall.result.items[0] : null;
|
|
556
|
+
const placedAt = isRecord(order) ? toStringOrNull(order.placed_at) ?? toStringOrNull(order.placedAt) : null;
|
|
557
|
+
setOrderLines(linesFetch.lines);
|
|
558
|
+
setOrderLinesTruncated(linesFetch.truncated);
|
|
559
|
+
setSelectedOrderLineIds(new Set(linesFetch.lines.map((line) => line.id)));
|
|
560
|
+
setOrderPurchaseDate(placedAt ? placedAt.slice(0, 10) : null);
|
|
561
|
+
} finally {
|
|
562
|
+
setOrderLinesLoading(false);
|
|
563
|
+
}
|
|
564
|
+
}, [orderId, t]);
|
|
565
|
+
const insertSelectedOrderLines = React.useCallback(() => {
|
|
566
|
+
const selectedRows = orderLines.filter((line) => selectedOrderLineIds.has(line.id));
|
|
567
|
+
if (!selectedRows.length) {
|
|
568
|
+
setOrderDialogOpen(false);
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
const retainedLines = lines.filter(lineHasContentBeyondQuantity);
|
|
572
|
+
if (exceedsLineCap(retainedLines.length, selectedRows.length)) return;
|
|
573
|
+
const nextRows = selectedRows.map((line) => ({
|
|
574
|
+
...createDefaultLine(),
|
|
575
|
+
productId: line.productId,
|
|
576
|
+
variantId: line.variantId,
|
|
577
|
+
sku: line.sku ?? "",
|
|
578
|
+
productName: line.name ?? "",
|
|
579
|
+
qtyClaimed: parseQuantity(line.quantity) ?? 1,
|
|
580
|
+
orderLineId: line.id,
|
|
581
|
+
purchaseDate: orderPurchaseDate ?? "",
|
|
582
|
+
warrantyMonths: orderPurchaseDate && defaultWarrantyMonths !== null ? defaultWarrantyMonths : ""
|
|
583
|
+
}));
|
|
584
|
+
const nextLines = [...retainedLines, ...nextRows];
|
|
585
|
+
setLines(nextLines);
|
|
586
|
+
setOrderDialogOpen(false);
|
|
587
|
+
flash(t("warranty_claims.form.addFromOrder.added", "{count} line(s) added from order", { count: String(nextRows.length) }), "success");
|
|
588
|
+
revealLastPage(nextLines.length);
|
|
589
|
+
}, [defaultWarrantyMonths, exceedsLineCap, lines, orderLines, orderPurchaseDate, revealLastPage, selectedOrderLineIds, setLines, t]);
|
|
590
|
+
const visibleOrderLines = React.useMemo(() => {
|
|
591
|
+
const term = orderLineSearch.trim().toLowerCase();
|
|
592
|
+
if (!term) return orderLines;
|
|
593
|
+
return orderLines.filter((line) => `${line.name ?? ""} ${line.sku ?? ""}`.toLowerCase().includes(term));
|
|
594
|
+
}, [orderLineSearch, orderLines]);
|
|
595
|
+
const toggleAllVisibleOrderLines = React.useCallback((selected) => {
|
|
596
|
+
setSelectedOrderLineIds((current) => {
|
|
597
|
+
const next = new Set(current);
|
|
598
|
+
for (const line of visibleOrderLines) {
|
|
599
|
+
if (selected) next.add(line.id);
|
|
600
|
+
else next.delete(line.id);
|
|
601
|
+
}
|
|
602
|
+
return next;
|
|
603
|
+
});
|
|
604
|
+
}, [visibleOrderLines]);
|
|
605
|
+
const toggleOrderLine = React.useCallback((lineId, selected) => {
|
|
606
|
+
setSelectedOrderLineIds((current) => {
|
|
607
|
+
const next = new Set(current);
|
|
608
|
+
if (selected) next.add(lineId);
|
|
609
|
+
else next.delete(lineId);
|
|
610
|
+
return next;
|
|
611
|
+
});
|
|
612
|
+
}, []);
|
|
613
|
+
const draftWarrantyStatus = computeEntitlementPreview(
|
|
614
|
+
dateFromInputValue(lineDraft.purchaseDate),
|
|
615
|
+
parseWarrantyMonths(lineDraft.warrantyMonths)
|
|
616
|
+
);
|
|
617
|
+
const draftDialogId = "warranty-claim-line-draft";
|
|
618
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-4", ref: editorRef, children: [
|
|
619
|
+
/* @__PURE__ */ jsx(
|
|
620
|
+
DataTable,
|
|
621
|
+
{
|
|
622
|
+
embedded: true,
|
|
623
|
+
columns,
|
|
624
|
+
data: pageRows,
|
|
625
|
+
stickyActionsColumn: true,
|
|
626
|
+
searchValue: lineSearch,
|
|
627
|
+
onSearchChange: handleSearchChange,
|
|
628
|
+
searchPlaceholder: t("warranty_claims.form.lines.search", "Search product, SKU or serial number"),
|
|
629
|
+
pagination: {
|
|
630
|
+
page: currentPage,
|
|
631
|
+
pageSize: LINE_PAGE_SIZE,
|
|
632
|
+
total: filteredRows.length,
|
|
633
|
+
totalPages,
|
|
634
|
+
onPageChange: setLinePage
|
|
635
|
+
},
|
|
636
|
+
actions: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
637
|
+
orderId && !hideOrderImport ? /* @__PURE__ */ jsxs(Button, { type: "button", variant: "outline", onClick: () => {
|
|
638
|
+
void openOrderImportDialog();
|
|
639
|
+
}, children: [
|
|
640
|
+
/* @__PURE__ */ jsx(Plus, { className: "size-4", "aria-hidden": "true" }),
|
|
641
|
+
t("warranty_claims.form.addFromOrder")
|
|
642
|
+
] }) : null,
|
|
643
|
+
/* @__PURE__ */ jsxs(Button, { type: "button", onClick: openCreateDialog, children: [
|
|
644
|
+
/* @__PURE__ */ jsx(Plus, { className: "size-4", "aria-hidden": "true" }),
|
|
645
|
+
translations.addLine
|
|
646
|
+
] })
|
|
647
|
+
] }),
|
|
648
|
+
emptyState: /* @__PURE__ */ jsx(
|
|
649
|
+
EmptyState,
|
|
650
|
+
{
|
|
651
|
+
title: searchTerm ? t("warranty_claims.form.lines.empty.noMatches", "No claim lines match your search") : t("warranty_claims.form.lines.empty.title", "No claim lines yet"),
|
|
652
|
+
description: searchTerm ? void 0 : t("warranty_claims.form.lines.empty.description", "Add a claim line or import them from the linked order."),
|
|
653
|
+
variant: "subtle"
|
|
654
|
+
}
|
|
655
|
+
),
|
|
656
|
+
rowActions: (row) => {
|
|
657
|
+
const items = [
|
|
658
|
+
{
|
|
659
|
+
id: "edit",
|
|
660
|
+
label: t("warranty_claims.form.lines.edit", "Edit line"),
|
|
661
|
+
onSelect: () => openEditDialog(row)
|
|
662
|
+
}
|
|
663
|
+
];
|
|
664
|
+
if (lines.length > 1) {
|
|
665
|
+
items.push({
|
|
666
|
+
id: "delete",
|
|
667
|
+
label: translations.removeLine,
|
|
668
|
+
destructive: true,
|
|
669
|
+
onSelect: () => removeLine(row.index)
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
return /* @__PURE__ */ jsx(RowActions, { items });
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
),
|
|
676
|
+
error ? /* @__PURE__ */ jsx("p", { className: "text-sm text-status-error-text", children: error }) : null,
|
|
677
|
+
/* @__PURE__ */ jsx(Dialog, { open: lineDialog !== null, onOpenChange: (open) => {
|
|
678
|
+
if (!open) setLineDialog(null);
|
|
679
|
+
}, children: /* @__PURE__ */ jsxs(
|
|
680
|
+
DialogContent,
|
|
681
|
+
{
|
|
682
|
+
className: "sm:max-w-3xl",
|
|
683
|
+
onKeyDown: (event) => {
|
|
684
|
+
if ((event.metaKey || event.ctrlKey) && event.key === "Enter") {
|
|
685
|
+
event.preventDefault();
|
|
686
|
+
submitLineDialog();
|
|
687
|
+
}
|
|
688
|
+
if (event.key === "Escape") {
|
|
689
|
+
setLineDialog(null);
|
|
690
|
+
}
|
|
691
|
+
},
|
|
692
|
+
children: [
|
|
693
|
+
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: lineDialog?.mode === "edit" ? t("warranty_claims.form.lines.edit", "Edit line") : translations.addLine }) }),
|
|
694
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 md:grid-cols-2", children: [
|
|
695
|
+
/* @__PURE__ */ jsx("div", { className: "md:col-span-2", children: /* @__PURE__ */ jsx(
|
|
696
|
+
ClaimLineProductPicker,
|
|
697
|
+
{
|
|
698
|
+
value: {
|
|
699
|
+
productId: lineDraft.productId,
|
|
700
|
+
productName: lineDraft.productName,
|
|
701
|
+
sku: lineDraft.sku,
|
|
702
|
+
variantId: lineDraft.variantId
|
|
703
|
+
},
|
|
704
|
+
onPick: (pick) => updateDraft({
|
|
705
|
+
productId: pick.productId,
|
|
706
|
+
variantId: pick.variantId,
|
|
707
|
+
sku: pick.sku,
|
|
708
|
+
productName: pick.productName
|
|
709
|
+
}),
|
|
710
|
+
onClear: () => updateDraft({ productId: null, variantId: null })
|
|
711
|
+
}
|
|
712
|
+
) }),
|
|
713
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
714
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${draftDialogId}-productName`, children: translations.productName }),
|
|
715
|
+
/* @__PURE__ */ jsx(
|
|
716
|
+
Input,
|
|
717
|
+
{
|
|
718
|
+
id: `${draftDialogId}-productName`,
|
|
719
|
+
value: stringifyFieldValue(lineDraft.productName),
|
|
720
|
+
onChange: (event) => updateDraft({ productName: event.target.value })
|
|
721
|
+
}
|
|
722
|
+
)
|
|
723
|
+
] }),
|
|
724
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
725
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${draftDialogId}-sku`, children: translations.sku }),
|
|
726
|
+
/* @__PURE__ */ jsx(
|
|
727
|
+
Input,
|
|
728
|
+
{
|
|
729
|
+
id: `${draftDialogId}-sku`,
|
|
730
|
+
value: stringifyFieldValue(lineDraft.sku),
|
|
731
|
+
onChange: (event) => updateDraft({ sku: event.target.value })
|
|
732
|
+
}
|
|
733
|
+
)
|
|
734
|
+
] }),
|
|
735
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
736
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${draftDialogId}-serialNumber`, children: translations.serialNumber }),
|
|
737
|
+
/* @__PURE__ */ jsx(
|
|
738
|
+
Input,
|
|
739
|
+
{
|
|
740
|
+
id: `${draftDialogId}-serialNumber`,
|
|
741
|
+
value: stringifyFieldValue(lineDraft.serialNumber),
|
|
742
|
+
onChange: (event) => updateDraft({ serialNumber: event.target.value })
|
|
743
|
+
}
|
|
744
|
+
)
|
|
745
|
+
] }),
|
|
746
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
747
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${draftDialogId}-qtyClaimed`, children: translations.qtyClaimed }),
|
|
748
|
+
/* @__PURE__ */ jsx(
|
|
749
|
+
Input,
|
|
750
|
+
{
|
|
751
|
+
id: `${draftDialogId}-qtyClaimed`,
|
|
752
|
+
type: "number",
|
|
753
|
+
min: 1,
|
|
754
|
+
step: "1",
|
|
755
|
+
value: stringifyFieldValue(lineDraft.qtyClaimed),
|
|
756
|
+
onChange: (event) => updateDraft({ qtyClaimed: event.target.value })
|
|
757
|
+
}
|
|
758
|
+
)
|
|
759
|
+
] }),
|
|
760
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
761
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${draftDialogId}-purchaseDate`, children: t("warranty_claims.form.purchaseDate") }),
|
|
762
|
+
/* @__PURE__ */ jsx(
|
|
763
|
+
Input,
|
|
764
|
+
{
|
|
765
|
+
id: `${draftDialogId}-purchaseDate`,
|
|
766
|
+
type: "date",
|
|
767
|
+
value: dateInputValue(lineDraft.purchaseDate),
|
|
768
|
+
onChange: (event) => updateDraftPurchaseDate(event.target.value)
|
|
769
|
+
}
|
|
770
|
+
)
|
|
771
|
+
] }),
|
|
772
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
773
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${draftDialogId}-warrantyMonths`, children: t("warranty_claims.form.warrantyMonths") }),
|
|
774
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
775
|
+
/* @__PURE__ */ jsx(
|
|
776
|
+
Input,
|
|
777
|
+
{
|
|
778
|
+
id: `${draftDialogId}-warrantyMonths`,
|
|
779
|
+
type: "number",
|
|
780
|
+
min: 0,
|
|
781
|
+
step: "1",
|
|
782
|
+
value: stringifyFieldValue(lineDraft.warrantyMonths),
|
|
783
|
+
onChange: (event) => updateDraft({ warrantyMonths: event.target.value }),
|
|
784
|
+
className: "min-w-28 flex-1"
|
|
785
|
+
}
|
|
786
|
+
),
|
|
787
|
+
/* @__PURE__ */ jsx(EntitlementChip, { status: draftWarrantyStatus, t }),
|
|
788
|
+
/* @__PURE__ */ jsx(
|
|
789
|
+
EntitlementLookupBadge,
|
|
790
|
+
{
|
|
791
|
+
claim: { orderId },
|
|
792
|
+
lines: [{
|
|
793
|
+
productId: nullableText(lineDraft.productId),
|
|
794
|
+
sku: nullableText(lineDraft.sku),
|
|
795
|
+
serialNumber: nullableText(lineDraft.serialNumber),
|
|
796
|
+
purchaseDate: normalizeDateOnly(lineDraft.purchaseDate)
|
|
797
|
+
}]
|
|
798
|
+
}
|
|
799
|
+
)
|
|
800
|
+
] })
|
|
801
|
+
] }),
|
|
802
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2 md:col-span-2", children: [
|
|
803
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${draftDialogId}-faultCode`, children: translations.faultCode }),
|
|
804
|
+
/* @__PURE__ */ jsxs(
|
|
805
|
+
Select,
|
|
806
|
+
{
|
|
807
|
+
value: nullableText(lineDraft.faultCode) ?? "",
|
|
808
|
+
onValueChange: (next) => updateDraft({ faultCode: next }),
|
|
809
|
+
children: [
|
|
810
|
+
/* @__PURE__ */ jsx(SelectTrigger, { id: `${draftDialogId}-faultCode`, children: /* @__PURE__ */ jsx(SelectValue, { placeholder: translations.faultCodePlaceholder }) }),
|
|
811
|
+
/* @__PURE__ */ jsx(SelectContent, { children: faultCodeOptions.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: option.label }, option.value)) })
|
|
812
|
+
]
|
|
813
|
+
}
|
|
814
|
+
)
|
|
815
|
+
] }),
|
|
816
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2 md:col-span-2", children: [
|
|
817
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${draftDialogId}-faultDescription`, children: translations.faultDescription }),
|
|
818
|
+
/* @__PURE__ */ jsx(
|
|
819
|
+
Textarea,
|
|
820
|
+
{
|
|
821
|
+
id: `${draftDialogId}-faultDescription`,
|
|
822
|
+
rows: 4,
|
|
823
|
+
value: stringifyFieldValue(lineDraft.faultDescription),
|
|
824
|
+
onChange: (event) => updateDraft({ faultDescription: event.target.value })
|
|
825
|
+
}
|
|
826
|
+
)
|
|
827
|
+
] })
|
|
828
|
+
] }),
|
|
829
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [
|
|
830
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: () => setLineDialog(null), children: t("common.cancel", "Cancel") }),
|
|
831
|
+
/* @__PURE__ */ jsx(Button, { type: "button", onClick: submitLineDialog, children: t("common.save", "Save") })
|
|
832
|
+
] })
|
|
833
|
+
]
|
|
834
|
+
}
|
|
835
|
+
) }),
|
|
836
|
+
/* @__PURE__ */ jsx(Dialog, { open: orderDialogOpen, onOpenChange: setOrderDialogOpen, children: /* @__PURE__ */ jsxs(
|
|
837
|
+
DialogContent,
|
|
838
|
+
{
|
|
839
|
+
className: "sm:max-w-2xl",
|
|
840
|
+
onKeyDown: (event) => {
|
|
841
|
+
if ((event.metaKey || event.ctrlKey) && event.key === "Enter") {
|
|
842
|
+
event.preventDefault();
|
|
843
|
+
if (selectedOrderLineIds.size) insertSelectedOrderLines();
|
|
844
|
+
}
|
|
845
|
+
if (event.key === "Escape") {
|
|
846
|
+
setOrderDialogOpen(false);
|
|
847
|
+
}
|
|
848
|
+
},
|
|
849
|
+
children: [
|
|
850
|
+
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: t("warranty_claims.form.addFromOrder") }) }),
|
|
851
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
852
|
+
orderLinesLoading ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("warranty_claims.form.addFromOrder.loading") }) : null,
|
|
853
|
+
!orderLinesLoading && orderLines.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: t("warranty_claims.form.addFromOrder.empty") }) : null,
|
|
854
|
+
!orderLinesLoading && orderLines.length ? /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
855
|
+
/* @__PURE__ */ jsx(
|
|
856
|
+
Input,
|
|
857
|
+
{
|
|
858
|
+
type: "search",
|
|
859
|
+
value: orderLineSearch,
|
|
860
|
+
onChange: (event) => setOrderLineSearch(event.target.value),
|
|
861
|
+
placeholder: t("warranty_claims.form.addFromOrder.search", "Filter by product or SKU"),
|
|
862
|
+
"aria-label": t("warranty_claims.form.addFromOrder.search", "Filter by product or SKU")
|
|
863
|
+
}
|
|
864
|
+
),
|
|
865
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2 text-xs text-muted-foreground", children: [
|
|
866
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
867
|
+
t("warranty_claims.form.addFromOrder.count", "{shown} of {total} lines", {
|
|
868
|
+
shown: String(visibleOrderLines.length),
|
|
869
|
+
total: String(orderLines.length)
|
|
870
|
+
}),
|
|
871
|
+
orderLinesTruncated ? ` \u2014 ${t("warranty_claims.form.addFromOrder.truncated", "first {limit} only", { limit: String(ORDER_LINE_MAX_FETCH) })}` : "",
|
|
872
|
+
selectedOrderLineIds.size ? ` \u2014 ${t("warranty_claims.form.addFromOrder.selected", "{count} selected", { count: String(selectedOrderLineIds.size) })}` : ""
|
|
873
|
+
] }),
|
|
874
|
+
/* @__PURE__ */ jsxs("span", { className: "flex gap-3", children: [
|
|
875
|
+
/* @__PURE__ */ jsx(
|
|
876
|
+
Button,
|
|
877
|
+
{
|
|
878
|
+
type: "button",
|
|
879
|
+
variant: "link",
|
|
880
|
+
size: "sm",
|
|
881
|
+
onClick: () => toggleAllVisibleOrderLines(true),
|
|
882
|
+
children: t("warranty_claims.form.addFromOrder.selectAll", "Select all")
|
|
883
|
+
}
|
|
884
|
+
),
|
|
885
|
+
/* @__PURE__ */ jsx(
|
|
886
|
+
Button,
|
|
887
|
+
{
|
|
888
|
+
type: "button",
|
|
889
|
+
variant: "link",
|
|
890
|
+
size: "sm",
|
|
891
|
+
onClick: () => setSelectedOrderLineIds(/* @__PURE__ */ new Set()),
|
|
892
|
+
children: t("warranty_claims.form.addFromOrder.clear", "Clear")
|
|
893
|
+
}
|
|
894
|
+
)
|
|
895
|
+
] })
|
|
896
|
+
] })
|
|
897
|
+
] }) : null,
|
|
898
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-[50vh] space-y-3 overflow-y-auto pr-1", children: visibleOrderLines.map((line) => {
|
|
899
|
+
const checked = selectedOrderLineIds.has(line.id);
|
|
900
|
+
const label = line.name ?? line.sku ?? t("warranty_claims.form.lines.unnamed", "Unnamed line");
|
|
901
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 rounded-md border border-border p-3", children: [
|
|
902
|
+
/* @__PURE__ */ jsx(
|
|
903
|
+
Checkbox,
|
|
904
|
+
{
|
|
905
|
+
checked,
|
|
906
|
+
onCheckedChange: (next) => toggleOrderLine(line.id, next === true),
|
|
907
|
+
"aria-label": t("warranty_claims.form.addFromOrder.selectLine", void 0, { name: label })
|
|
908
|
+
}
|
|
909
|
+
),
|
|
910
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-1", children: [
|
|
911
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm font-medium", children: label }),
|
|
912
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-3 text-xs text-muted-foreground", children: [
|
|
913
|
+
/* @__PURE__ */ jsx("span", { children: line.sku ?? t("warranty_claims.common.noValue") }),
|
|
914
|
+
/* @__PURE__ */ jsx("span", { children: t("warranty_claims.form.addFromOrder.quantity", void 0, { quantity: formatQuantity(line.quantity, t("warranty_claims.common.noValue")) }) })
|
|
915
|
+
] })
|
|
916
|
+
] })
|
|
917
|
+
] }, line.id);
|
|
918
|
+
}) })
|
|
919
|
+
] }),
|
|
920
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [
|
|
921
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: () => setOrderDialogOpen(false), children: t("common.cancel", "Cancel") }),
|
|
922
|
+
/* @__PURE__ */ jsx(Button, { type: "button", onClick: insertSelectedOrderLines, disabled: !selectedOrderLineIds.size, children: t("warranty_claims.form.addFromOrder.confirm", "Add selected lines") })
|
|
923
|
+
] })
|
|
924
|
+
]
|
|
925
|
+
}
|
|
926
|
+
) })
|
|
927
|
+
] });
|
|
928
|
+
}
|
|
929
|
+
function CreateWarrantyClaimPage() {
|
|
930
|
+
const t = useT();
|
|
931
|
+
const router = useRouter();
|
|
932
|
+
const searchParams = useSearchParams();
|
|
933
|
+
const [selectedCustomerId, setSelectedCustomerId] = React.useState(null);
|
|
934
|
+
const [selectedClaimType, setSelectedClaimType] = React.useState(() => normalizeClaimType(searchParams.get("claimType")));
|
|
935
|
+
const [selectedReasonCode, setSelectedReasonCode] = React.useState(null);
|
|
936
|
+
const [orderAccessDenied, setOrderAccessDenied] = React.useState(false);
|
|
937
|
+
const [faultCodeOptions, setFaultCodeOptions] = React.useState([]);
|
|
938
|
+
const [defaultWarrantyMonths, setDefaultWarrantyMonths] = React.useState(null);
|
|
939
|
+
const loadDictionaryOptions = React.useCallback(async (dictionaryKey, kind) => {
|
|
940
|
+
const dictionaries = await readApiResultOrThrow(
|
|
941
|
+
"/api/dictionaries",
|
|
942
|
+
void 0,
|
|
943
|
+
{
|
|
944
|
+
fallback: { items: [] },
|
|
945
|
+
errorMessage: t("warranty_claims.form.error.dictionaryLoad")
|
|
946
|
+
}
|
|
947
|
+
);
|
|
948
|
+
const dictionary = (dictionaries.items ?? []).find((item) => item.key === dictionaryKey);
|
|
949
|
+
if (!dictionary?.id) return [];
|
|
950
|
+
const entries = await readApiResultOrThrow(
|
|
951
|
+
`/api/dictionaries/${encodeURIComponent(dictionary.id)}/entries`,
|
|
952
|
+
void 0,
|
|
953
|
+
{
|
|
954
|
+
fallback: { items: [] },
|
|
955
|
+
errorMessage: t("warranty_claims.form.error.dictionaryLoad")
|
|
956
|
+
}
|
|
957
|
+
);
|
|
958
|
+
return (entries.items ?? []).map(normalizeDictionaryOption).filter((option) => option !== null).map((option) => ({
|
|
959
|
+
value: option.value,
|
|
960
|
+
label: localizeDictionaryLabel(t, kind, option.value, option.label)
|
|
961
|
+
}));
|
|
962
|
+
}, [t]);
|
|
963
|
+
const loadCustomerOptions = React.useCallback(async (query) => {
|
|
964
|
+
const params = new URLSearchParams({ page: "1", pageSize: "20" });
|
|
965
|
+
const trimmed = query?.trim();
|
|
966
|
+
if (trimmed) params.set("search", trimmed);
|
|
967
|
+
const [people, companies] = await Promise.all([
|
|
968
|
+
apiCall(`/api/customers/people?${params.toString()}`, void 0, { fallback: { items: [] } }),
|
|
969
|
+
apiCall(`/api/customers/companies?${params.toString()}`, void 0, { fallback: { items: [] } })
|
|
970
|
+
]);
|
|
971
|
+
const items = [
|
|
972
|
+
...Array.isArray(people.result?.items) ? people.result.items : [],
|
|
973
|
+
...Array.isArray(companies.result?.items) ? companies.result.items : []
|
|
974
|
+
];
|
|
975
|
+
return items.map((item) => normalizeOption(item, t)).filter((option) => option !== null);
|
|
976
|
+
}, [t]);
|
|
977
|
+
const loadOrderOptions = React.useCallback(async (query) => {
|
|
978
|
+
return loadOrderOptionsShared(query, {
|
|
979
|
+
customerId: selectedCustomerId,
|
|
980
|
+
onAccessChange: setOrderAccessDenied,
|
|
981
|
+
fallbackLabel: t("warranty_claims.form.orderUnavailable", "Order unavailable")
|
|
982
|
+
});
|
|
983
|
+
}, [selectedCustomerId, t]);
|
|
984
|
+
React.useEffect(() => {
|
|
985
|
+
let cancelled = false;
|
|
986
|
+
void loadDictionaryOptions(DICTIONARY_KEYS.faultCodes, "fault").then((options) => {
|
|
987
|
+
if (!cancelled) setFaultCodeOptions(options);
|
|
988
|
+
}).catch(() => {
|
|
989
|
+
if (!cancelled) setFaultCodeOptions([]);
|
|
990
|
+
});
|
|
991
|
+
return () => {
|
|
992
|
+
cancelled = true;
|
|
993
|
+
};
|
|
994
|
+
}, [loadDictionaryOptions]);
|
|
995
|
+
React.useEffect(() => {
|
|
996
|
+
let cancelled = false;
|
|
997
|
+
void apiCall("/api/warranty_claims/settings-general", { headers: { "x-om-forbidden-redirect": "0" } }).then((response) => {
|
|
998
|
+
if (cancelled || !response.ok) return;
|
|
999
|
+
setDefaultWarrantyMonths(readDefaultWarrantyMonths(response.result));
|
|
1000
|
+
}).catch(() => {
|
|
1001
|
+
if (!cancelled) setDefaultWarrantyMonths(null);
|
|
1002
|
+
});
|
|
1003
|
+
return () => {
|
|
1004
|
+
cancelled = true;
|
|
1005
|
+
};
|
|
1006
|
+
}, []);
|
|
1007
|
+
const lineTranslations = React.useMemo(() => ({
|
|
1008
|
+
addLine: t("warranty_claims.form.lines.add", "Add line"),
|
|
1009
|
+
removeLine: t("warranty_claims.form.lines.remove", "Remove line"),
|
|
1010
|
+
productName: t("warranty_claims.form.productName"),
|
|
1011
|
+
sku: t("warranty_claims.form.sku"),
|
|
1012
|
+
serialNumber: t("warranty_claims.form.serialNumber"),
|
|
1013
|
+
faultCode: t("warranty_claims.form.faultCode"),
|
|
1014
|
+
faultDescription: t("warranty_claims.form.faultDescription"),
|
|
1015
|
+
qtyClaimed: t("warranty_claims.form.qtyClaimed"),
|
|
1016
|
+
faultCodePlaceholder: t("warranty_claims.form.faultCode.placeholder", "Select fault code")
|
|
1017
|
+
}), [t]);
|
|
1018
|
+
const fields = React.useMemo(() => [
|
|
1019
|
+
{
|
|
1020
|
+
id: "claimType",
|
|
1021
|
+
label: t("warranty_claims.form.claimType"),
|
|
1022
|
+
type: "custom",
|
|
1023
|
+
required: true,
|
|
1024
|
+
layout: "half",
|
|
1025
|
+
component: ({ values, setFormValue }) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-1 rounded-lg bg-muted p-1 sm:grid-cols-4", children: CLAIM_TYPES.map((claimType) => /* @__PURE__ */ jsx(
|
|
1026
|
+
Button,
|
|
1027
|
+
{
|
|
1028
|
+
type: "button",
|
|
1029
|
+
size: "sm",
|
|
1030
|
+
variant: values?.claimType === claimType ? "default" : "ghost",
|
|
1031
|
+
onClick: () => setFormValue?.("claimType", claimType),
|
|
1032
|
+
children: t(`warranty_claims.claimType.${claimType}`)
|
|
1033
|
+
},
|
|
1034
|
+
claimType
|
|
1035
|
+
)) })
|
|
1036
|
+
},
|
|
1037
|
+
{
|
|
1038
|
+
id: "priority",
|
|
1039
|
+
label: t("warranty_claims.form.priority"),
|
|
1040
|
+
type: "select",
|
|
1041
|
+
required: true,
|
|
1042
|
+
layout: "half",
|
|
1043
|
+
options: CLAIM_PRIORITIES.map((priority) => ({
|
|
1044
|
+
value: priority,
|
|
1045
|
+
label: t(`warranty_claims.priority.${priority}`)
|
|
1046
|
+
}))
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
id: "reasonCode",
|
|
1050
|
+
label: t("warranty_claims.form.reasonCode"),
|
|
1051
|
+
type: "select",
|
|
1052
|
+
layout: "half",
|
|
1053
|
+
loadOptions: () => loadDictionaryOptions(DICTIONARY_KEYS.claimReasons, "reason")
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
id: "customerId",
|
|
1057
|
+
label: t("warranty_claims.form.customerId"),
|
|
1058
|
+
type: "combobox",
|
|
1059
|
+
layout: "half",
|
|
1060
|
+
loadOptions: loadCustomerOptions,
|
|
1061
|
+
allowCustomValues: false,
|
|
1062
|
+
placeholder: t("warranty_claims.form.customerId.placeholder"),
|
|
1063
|
+
seedOptions: []
|
|
1064
|
+
},
|
|
1065
|
+
{
|
|
1066
|
+
id: "orderId",
|
|
1067
|
+
label: t("warranty_claims.form.orderId"),
|
|
1068
|
+
type: "combobox",
|
|
1069
|
+
layout: "half",
|
|
1070
|
+
loadOptions: loadOrderOptions,
|
|
1071
|
+
allowCustomValues: false,
|
|
1072
|
+
placeholder: t("warranty_claims.form.orderId.placeholder"),
|
|
1073
|
+
description: orderAccessDenied ? t("warranty_claims.form.orderId.noAccess") : void 0,
|
|
1074
|
+
seedOptions: [],
|
|
1075
|
+
resolveLabel: (value) => resolveOrderLabel(value, t("warranty_claims.form.orderUnavailable", "Order unavailable"))
|
|
1076
|
+
},
|
|
1077
|
+
{
|
|
1078
|
+
id: "notes",
|
|
1079
|
+
label: t("warranty_claims.form.notes"),
|
|
1080
|
+
type: "textarea",
|
|
1081
|
+
rows: 4,
|
|
1082
|
+
layout: "half"
|
|
1083
|
+
},
|
|
1084
|
+
{
|
|
1085
|
+
id: "resolutionSummary",
|
|
1086
|
+
label: t("warranty_claims.form.resolutionSummary", "Resolution summary"),
|
|
1087
|
+
type: "textarea",
|
|
1088
|
+
rows: 3,
|
|
1089
|
+
layout: "full"
|
|
1090
|
+
}
|
|
1091
|
+
], [loadCustomerOptions, loadDictionaryOptions, loadOrderOptions, orderAccessDenied, resolveOrderLabel, t]);
|
|
1092
|
+
const groups = React.useMemo(() => [
|
|
1093
|
+
{
|
|
1094
|
+
id: "header",
|
|
1095
|
+
title: t("warranty_claims.create.basics", "Claim basics"),
|
|
1096
|
+
column: 1,
|
|
1097
|
+
// Render order lives here, not in the field definitions. Keep the three
|
|
1098
|
+
// thirds adjacent and the two halves adjacent so each grid row fills.
|
|
1099
|
+
fields: ["claimType", "priority", "customerId", "orderId", "reasonCode", "notes", "resolutionSummary"],
|
|
1100
|
+
component: ({ values }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1101
|
+
/* @__PURE__ */ jsx(CustomerSelectionObserver, { value: values.customerId, onChange: setSelectedCustomerId }),
|
|
1102
|
+
/* @__PURE__ */ jsx(ClaimTypeSelectionObserver, { value: values.claimType, onChange: setSelectedClaimType }),
|
|
1103
|
+
/* @__PURE__ */ jsx(ReasonCodeSelectionObserver, { value: values.reasonCode, onChange: setSelectedReasonCode })
|
|
1104
|
+
] })
|
|
1105
|
+
},
|
|
1106
|
+
{
|
|
1107
|
+
id: "troubleshooting",
|
|
1108
|
+
title: t("warranty_claims.form.troubleshooting.title", "Guided troubleshooting"),
|
|
1109
|
+
column: 1,
|
|
1110
|
+
bare: true,
|
|
1111
|
+
component: ({ setValue }) => /* @__PURE__ */ jsx(
|
|
1112
|
+
GuidedTroubleshootingSection,
|
|
1113
|
+
{
|
|
1114
|
+
claimType: selectedClaimType,
|
|
1115
|
+
reasonCode: selectedReasonCode,
|
|
1116
|
+
t,
|
|
1117
|
+
onResolve: (result) => {
|
|
1118
|
+
if (result.reasonCode) setValue("reasonCode", result.reasonCode);
|
|
1119
|
+
if (result.resolution) setValue("resolutionSummary", result.resolution);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
)
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
id: "line",
|
|
1126
|
+
title: t(resolveClaimTypeUiConfig(selectedClaimType).lineHeaderKey),
|
|
1127
|
+
column: 1,
|
|
1128
|
+
component: ({ values, setValue, errors }) => /* @__PURE__ */ jsx(
|
|
1129
|
+
LineItemsEditor,
|
|
1130
|
+
{
|
|
1131
|
+
value: values.lines,
|
|
1132
|
+
setLines: (lines) => setValue("lines", lines),
|
|
1133
|
+
orderId: nullableText(values.orderId),
|
|
1134
|
+
defaultWarrantyMonths,
|
|
1135
|
+
error: errors.lines,
|
|
1136
|
+
faultCodeOptions,
|
|
1137
|
+
translations: lineTranslations,
|
|
1138
|
+
t
|
|
1139
|
+
}
|
|
1140
|
+
)
|
|
1141
|
+
},
|
|
1142
|
+
{
|
|
1143
|
+
id: "summary",
|
|
1144
|
+
column: 2,
|
|
1145
|
+
bare: true,
|
|
1146
|
+
component: ({ values }) => {
|
|
1147
|
+
const claimType = nullableText(values.claimType) ?? "warranty";
|
|
1148
|
+
const lineCount = readSubmittedLineValues(values.lines).filter(lineHasContent).length;
|
|
1149
|
+
return /* @__PURE__ */ jsxs("div", { className: "sticky top-4 space-y-4", children: [
|
|
1150
|
+
/* @__PURE__ */ jsxs("aside", { className: "overflow-hidden rounded-xl bg-foreground text-background shadow-sm", children: [
|
|
1151
|
+
/* @__PURE__ */ jsxs("div", { className: "border-b border-background/20 p-5", children: [
|
|
1152
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1153
|
+
/* @__PURE__ */ jsx(ShieldCheck, { className: "size-5", "aria-hidden": true }),
|
|
1154
|
+
/* @__PURE__ */ jsx("h2", { className: "text-base font-semibold", children: t("warranty_claims.create.summary.title", "Claim summary") })
|
|
1155
|
+
] }),
|
|
1156
|
+
/* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-background/70", children: t("warranty_claims.create.summary.description", "Review the intake context before creating the claim.") })
|
|
1157
|
+
] }),
|
|
1158
|
+
/* @__PURE__ */ jsxs("dl", { className: "space-y-4 p-5 text-sm", children: [
|
|
1159
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
|
|
1160
|
+
/* @__PURE__ */ jsx("dt", { className: "text-background/70", children: t("warranty_claims.form.claimType") }),
|
|
1161
|
+
/* @__PURE__ */ jsx("dd", { className: "font-medium", children: t(`warranty_claims.claimType.${claimType}`) })
|
|
1162
|
+
] }),
|
|
1163
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
|
|
1164
|
+
/* @__PURE__ */ jsx("dt", { className: "text-background/70", children: t("warranty_claims.form.priority") }),
|
|
1165
|
+
/* @__PURE__ */ jsx("dd", { className: "font-medium", children: t(`warranty_claims.priority.${nullableText(values.priority) ?? "normal"}`) })
|
|
1166
|
+
] }),
|
|
1167
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
|
|
1168
|
+
/* @__PURE__ */ jsx("dt", { className: "text-background/70", children: t("warranty_claims.create.summary.lines", "Claim lines") }),
|
|
1169
|
+
/* @__PURE__ */ jsx("dd", { className: "font-medium tabular-nums", children: lineCount })
|
|
1170
|
+
] }),
|
|
1171
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
|
|
1172
|
+
/* @__PURE__ */ jsx("dt", { className: "text-background/70", children: t("warranty_claims.create.summary.customer", "Customer") }),
|
|
1173
|
+
/* @__PURE__ */ jsx("dd", { className: "font-medium", children: nullableText(values.customerId) ? t("warranty_claims.create.summary.selected", "Selected") : t("warranty_claims.create.summary.notSelected", "Not selected") })
|
|
1174
|
+
] }),
|
|
1175
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3", children: [
|
|
1176
|
+
/* @__PURE__ */ jsx("dt", { className: "text-background/70", children: t("warranty_claims.list.column.order") }),
|
|
1177
|
+
/* @__PURE__ */ jsx("dd", { className: "font-medium", children: nullableText(values.orderId) ? t("warranty_claims.create.summary.linked", "Linked") : t("warranty_claims.create.summary.notLinked", "Not linked") })
|
|
1178
|
+
] })
|
|
1179
|
+
] })
|
|
1180
|
+
] }),
|
|
1181
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-border bg-card p-5", children: [
|
|
1182
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: t("warranty_claims.create.summary.automation", "Automation") }),
|
|
1183
|
+
/* @__PURE__ */ jsxs("ul", { className: "mt-3 space-y-3 text-sm text-foreground", children: [
|
|
1184
|
+
/* @__PURE__ */ jsxs("li", { className: "flex gap-2", children: [
|
|
1185
|
+
/* @__PURE__ */ jsx(CheckCircle2, { className: "mt-0.5 size-4 shrink-0", "aria-hidden": true }),
|
|
1186
|
+
t("warranty_claims.create.summary.entitlement", "Warranty entitlement is checked from the selected product and serial.")
|
|
1187
|
+
] }),
|
|
1188
|
+
/* @__PURE__ */ jsxs("li", { className: "flex gap-2", children: [
|
|
1189
|
+
/* @__PURE__ */ jsx(CheckCircle2, { className: "mt-0.5 size-4 shrink-0", "aria-hidden": true }),
|
|
1190
|
+
t("warranty_claims.create.summary.sla", "The SLA clock starts when the claim is submitted.")
|
|
1191
|
+
] })
|
|
1192
|
+
] })
|
|
1193
|
+
] })
|
|
1194
|
+
] });
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
], [defaultWarrantyMonths, faultCodeOptions, lineTranslations, selectedClaimType, selectedReasonCode, t]);
|
|
1198
|
+
const initialValues = React.useMemo(() => ({
|
|
1199
|
+
claimType: normalizeClaimType(searchParams.get("claimType")),
|
|
1200
|
+
orderId: searchParams.get("orderId") ?? "",
|
|
1201
|
+
priority: "normal",
|
|
1202
|
+
lines: [createDefaultLine()]
|
|
1203
|
+
}), [searchParams]);
|
|
1204
|
+
return /* @__PURE__ */ jsx(Page, { children: /* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsx("div", { className: "rounded-xl border border-border bg-card p-5", children: /* @__PURE__ */ jsx(
|
|
1205
|
+
CrudForm,
|
|
1206
|
+
{
|
|
1207
|
+
title: t("warranty_claims.create.title"),
|
|
1208
|
+
backHref: "/backend/warranty_claims",
|
|
1209
|
+
fields,
|
|
1210
|
+
groups,
|
|
1211
|
+
initialValues,
|
|
1212
|
+
submitLabel: t("warranty_claims.create.submit", "Create claim"),
|
|
1213
|
+
cancelHref: "/backend/warranty_claims",
|
|
1214
|
+
onSubmit: async (values) => {
|
|
1215
|
+
const lines = readSubmittedLineValues(values.lines).filter(lineHasContent);
|
|
1216
|
+
if (!lines.length) {
|
|
1217
|
+
const message = t("warranty_claims.form.lines.error.required", "Add at least one claim line.");
|
|
1218
|
+
throw createCrudFormError(message, { lines: message });
|
|
1219
|
+
}
|
|
1220
|
+
if (lines.some((line) => parsePositiveNumber(line.qtyClaimed) === null)) {
|
|
1221
|
+
const message = t("warranty_claims.form.lines.error.qtyPositive", "Claimed quantity must be greater than zero.");
|
|
1222
|
+
throw createCrudFormError(message, { lines: message });
|
|
1223
|
+
}
|
|
1224
|
+
const payload = {
|
|
1225
|
+
claimType: values.claimType,
|
|
1226
|
+
channel: "staff",
|
|
1227
|
+
priority: values.priority || "normal",
|
|
1228
|
+
customerId: nullableText(values.customerId),
|
|
1229
|
+
orderId: nullableText(values.orderId),
|
|
1230
|
+
reasonCode: nullableText(values.reasonCode),
|
|
1231
|
+
resolutionSummary: nullableText(values.resolutionSummary),
|
|
1232
|
+
notes: nullableText(values.notes),
|
|
1233
|
+
lines: lines.map(normalizeLinePayload)
|
|
1234
|
+
};
|
|
1235
|
+
const { result } = await createCrud("warranty_claims", payload, {
|
|
1236
|
+
errorMessage: t("warranty_claims.create.error")
|
|
1237
|
+
});
|
|
1238
|
+
const id = result?.id ?? null;
|
|
1239
|
+
flash(t("warranty_claims.create.success"), "success");
|
|
1240
|
+
router.push(id ? `/backend/warranty_claims/${id}` : "/backend/warranty_claims");
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
) }) }) });
|
|
1244
|
+
}
|
|
1245
|
+
export {
|
|
1246
|
+
LineItemsEditor,
|
|
1247
|
+
CreateWarrantyClaimPage as default
|
|
1248
|
+
};
|
|
1249
|
+
//# sourceMappingURL=page.js.map
|