@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,2101 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { useRouter } from "next/navigation";
|
|
6
|
+
import { Copy, Hash, Info, MessageSquare, Pencil, RefreshCw, Trash2, UserRound } from "lucide-react";
|
|
7
|
+
import { hasFeature } from "@open-mercato/shared/security/features";
|
|
8
|
+
import { parseBooleanFromUnknown } from "@open-mercato/shared/lib/boolean";
|
|
9
|
+
import { useLocale, useT } from "@open-mercato/shared/lib/i18n/context";
|
|
10
|
+
import { formatDateTime, formatRelativeTime } from "@open-mercato/shared/lib/time";
|
|
11
|
+
import { Page, PageBody } from "@open-mercato/ui/backend/Page";
|
|
12
|
+
import { DataTable } from "@open-mercato/ui/backend/DataTable";
|
|
13
|
+
import { RowActions } from "@open-mercato/ui/backend/RowActions";
|
|
14
|
+
import { ActionsDropdown } from "@open-mercato/ui/backend/forms/ActionsDropdown";
|
|
15
|
+
import { LoadingMessage, ErrorMessage, RecordNotFoundState } from "@open-mercato/ui/backend/detail";
|
|
16
|
+
import { CrudForm } from "@open-mercato/ui/backend/CrudForm";
|
|
17
|
+
import { Button } from "@open-mercato/ui/primitives/button";
|
|
18
|
+
import { IconButton } from "@open-mercato/ui/primitives/icon-button";
|
|
19
|
+
import { EmptyState } from "@open-mercato/ui/primitives/empty-state";
|
|
20
|
+
import { Input } from "@open-mercato/ui/primitives/input";
|
|
21
|
+
import { Label } from "@open-mercato/ui/primitives/label";
|
|
22
|
+
import { StatusBadge } from "@open-mercato/ui/primitives/status-badge";
|
|
23
|
+
import { Textarea } from "@open-mercato/ui/primitives/textarea";
|
|
24
|
+
import { SegmentedControl, SegmentedControlItem } from "@open-mercato/ui/primitives/segmented-control";
|
|
25
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@open-mercato/ui/primitives/select";
|
|
26
|
+
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@open-mercato/ui/primitives/dialog";
|
|
27
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@open-mercato/ui/primitives/tabs";
|
|
28
|
+
const LazyAiChat = React.lazy(async () => {
|
|
29
|
+
const mod = await import("@open-mercato/ui/ai/AiChat");
|
|
30
|
+
return { default: mod.AiChat };
|
|
31
|
+
});
|
|
32
|
+
import { AiIcon } from "@open-mercato/ui/ai/AiIcon";
|
|
33
|
+
import { flash } from "@open-mercato/ui/backend/FlashMessages";
|
|
34
|
+
import { useConfirmDialog } from "@open-mercato/ui/backend/confirm-dialog";
|
|
35
|
+
import { useAppEvent } from "@open-mercato/ui/backend/injection/useAppEvent";
|
|
36
|
+
import { useGuardedMutation } from "@open-mercato/ui/backend/injection/useGuardedMutation";
|
|
37
|
+
import { apiCall, readApiResultOrThrow, withScopedApiRequestHeaders } from "@open-mercato/ui/backend/utils/apiCall";
|
|
38
|
+
import { createCrud, deleteCrud, updateCrud } from "@open-mercato/ui/backend/utils/crud";
|
|
39
|
+
import { buildOptimisticLockHeader } from "@open-mercato/ui/backend/utils/optimisticLock";
|
|
40
|
+
import { surfaceRecordConflict } from "@open-mercato/ui/backend/conflicts";
|
|
41
|
+
import { mapCrudServerErrorToFormErrors } from "@open-mercato/ui/backend/utils/serverErrors";
|
|
42
|
+
import { useCurrentUserId } from "@open-mercato/ui/backend/utils/useCurrentUserId";
|
|
43
|
+
import { useOrganizationScopeVersion } from "@open-mercato/shared/lib/frontend/useOrganizationScope";
|
|
44
|
+
import { AttachmentInput } from "@open-mercato/core/modules/attachments/fields/attachment";
|
|
45
|
+
import {
|
|
46
|
+
fetchAssignableStaffMembersPage
|
|
47
|
+
} from "@open-mercato/core/modules/customers/lib/assignableStaff";
|
|
48
|
+
import { CLAIM_STATUS_TRANSITIONS } from "../../../data/constants.js";
|
|
49
|
+
import {
|
|
50
|
+
ClaimStatusBadge
|
|
51
|
+
} from "../../components/ClaimStatusBadge.js";
|
|
52
|
+
import { ClaimSlaIndicator } from "../../components/claimSla.js";
|
|
53
|
+
import {
|
|
54
|
+
ClaimLineProductPicker,
|
|
55
|
+
EntitlementChip,
|
|
56
|
+
computeEntitlementPreview
|
|
57
|
+
} from "../../components/productLookup.js";
|
|
58
|
+
import { AiAssessButtons } from "../../components/AiAssessButtons.js";
|
|
59
|
+
import { useUserDisplayNames } from "../../components/useUserDisplayNames.js";
|
|
60
|
+
import { ReceivingPanel } from "../../components/ReceivingPanel.js";
|
|
61
|
+
import { ReturnLabelPanel } from "../../components/ReturnLabelPanel.js";
|
|
62
|
+
import { VendorRecoverySuggestionsPanel } from "../../components/VendorRecoverySuggestionsPanel.js";
|
|
63
|
+
import { ClaimStageProgress } from "../../components/ClaimStageProgress.js";
|
|
64
|
+
import { claimTypeAllowsLineFinancialAdjustments, resolveClaimTypeUiConfig } from "../../../lib/claimTypeConfig.js";
|
|
65
|
+
import { isTerminal } from "../../../lib/stateMachine.js";
|
|
66
|
+
import { isCustomerVisibleAttachment } from "../../../lib/attachmentVisibility.js";
|
|
67
|
+
import { formatQuantity, parseQuantity, quantityInputValue } from "../../../lib/quantity.js";
|
|
68
|
+
import { localizeDictionaryLabel } from "../../../lib/dictionaryLabels.js";
|
|
69
|
+
import {
|
|
70
|
+
TIMELINE_FILTERS,
|
|
71
|
+
filterTimelineEvents,
|
|
72
|
+
isTimelineFilterId
|
|
73
|
+
} from "../../../lib/timelineFilters.js";
|
|
74
|
+
function eligibilityBadgeVariant(status) {
|
|
75
|
+
if (status === "in_warranty") return "success";
|
|
76
|
+
if (status === "out_of_warranty") return "error";
|
|
77
|
+
return "neutral";
|
|
78
|
+
}
|
|
79
|
+
const CLAIM_LINE_STATUSES = ["pending", "approved", "rejected", "received", "inspected", "resolved"];
|
|
80
|
+
const CLAIM_DISPOSITIONS = [
|
|
81
|
+
"restock",
|
|
82
|
+
"repair",
|
|
83
|
+
"replace",
|
|
84
|
+
"credit",
|
|
85
|
+
"refund",
|
|
86
|
+
"field_destroy",
|
|
87
|
+
"scrap",
|
|
88
|
+
"return_to_vendor",
|
|
89
|
+
"deny"
|
|
90
|
+
];
|
|
91
|
+
const DICTIONARY_KEYS = {
|
|
92
|
+
faultCodes: "warranty_claims.warranty_claim_fault_code",
|
|
93
|
+
rejectionReasons: "warranty_claims.warranty_claim_rejection_reason"
|
|
94
|
+
};
|
|
95
|
+
const LINE_EDITABLE_CLAIM_STATUSES = /* @__PURE__ */ new Set([
|
|
96
|
+
"draft",
|
|
97
|
+
"submitted",
|
|
98
|
+
"in_review",
|
|
99
|
+
"info_requested",
|
|
100
|
+
"approved",
|
|
101
|
+
"received",
|
|
102
|
+
"inspecting"
|
|
103
|
+
]);
|
|
104
|
+
const RECEIVING_CAPABLE_CLAIM_STATUSES = /* @__PURE__ */ new Set([
|
|
105
|
+
"received",
|
|
106
|
+
"inspecting"
|
|
107
|
+
]);
|
|
108
|
+
const DELETABLE_CLAIM_STATUSES = /* @__PURE__ */ new Set(["draft", "cancelled"]);
|
|
109
|
+
const LINE_STATUS_TRANSITIONS = {
|
|
110
|
+
pending: ["approved", "rejected"],
|
|
111
|
+
approved: ["received", "resolved"],
|
|
112
|
+
rejected: [],
|
|
113
|
+
received: ["inspected"],
|
|
114
|
+
inspected: ["resolved"],
|
|
115
|
+
resolved: []
|
|
116
|
+
};
|
|
117
|
+
const EMPTY_RISK_ASSESSMENT = { level: "none", signals: [] };
|
|
118
|
+
const UNASSIGNED_SELECT_VALUE = "__unassigned__";
|
|
119
|
+
const CLEAR_SELECT_VALUE = "__clear__";
|
|
120
|
+
const AGENT_ID = "warranty_claims.claims_assistant";
|
|
121
|
+
function isRecord(value) {
|
|
122
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
123
|
+
}
|
|
124
|
+
function toStringOrNull(value) {
|
|
125
|
+
return typeof value === "string" && value.trim().length ? value.trim() : null;
|
|
126
|
+
}
|
|
127
|
+
function toNumberOrNull(value) {
|
|
128
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
129
|
+
if (typeof value === "string" && value.trim().length) {
|
|
130
|
+
const parsed = Number(value);
|
|
131
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
132
|
+
}
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
function toTranslateParams(value) {
|
|
136
|
+
if (!isRecord(value)) return void 0;
|
|
137
|
+
const params = {};
|
|
138
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
139
|
+
if (typeof entry === "string" || typeof entry === "number") {
|
|
140
|
+
params[key] = entry;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return Object.keys(params).length ? params : void 0;
|
|
144
|
+
}
|
|
145
|
+
function normalizeRiskSignal(value) {
|
|
146
|
+
if (!isRecord(value)) return null;
|
|
147
|
+
const id = toStringOrNull(value.id);
|
|
148
|
+
const level = toStringOrNull(value.level);
|
|
149
|
+
const messageKey = toStringOrNull(value.messageKey);
|
|
150
|
+
if (!id || !messageKey || level !== "low" && level !== "medium" && level !== "high") return null;
|
|
151
|
+
const relatedClaimNumbers = Array.isArray(value.relatedClaimNumbers) ? value.relatedClaimNumbers.filter((claimNumber) => typeof claimNumber === "string" && claimNumber.length > 0) : void 0;
|
|
152
|
+
return {
|
|
153
|
+
id,
|
|
154
|
+
level,
|
|
155
|
+
messageKey,
|
|
156
|
+
params: toTranslateParams(value.params),
|
|
157
|
+
relatedClaimNumbers: relatedClaimNumbers?.length ? relatedClaimNumbers : void 0
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
function normalizeRiskAssessment(value) {
|
|
161
|
+
if (!isRecord(value)) return EMPTY_RISK_ASSESSMENT;
|
|
162
|
+
const level = toStringOrNull(value.level);
|
|
163
|
+
const normalizedLevel = level === "low" || level === "medium" || level === "high" || level === "none" ? level : "none";
|
|
164
|
+
const signals = Array.isArray(value.signals) ? value.signals.map(normalizeRiskSignal).filter((signal) => signal !== null) : [];
|
|
165
|
+
return { level: normalizedLevel, signals };
|
|
166
|
+
}
|
|
167
|
+
function normalizeRiskResponse(value) {
|
|
168
|
+
if (!isRecord(value)) return EMPTY_RISK_ASSESSMENT;
|
|
169
|
+
if ("result" in value) return normalizeRiskAssessment(value.result);
|
|
170
|
+
return normalizeRiskAssessment(value);
|
|
171
|
+
}
|
|
172
|
+
function isClaimLineStatusValue(value) {
|
|
173
|
+
return typeof value === "string" && CLAIM_LINE_STATUSES.includes(value);
|
|
174
|
+
}
|
|
175
|
+
function buildLineStatusOptions(status, t) {
|
|
176
|
+
const current = isClaimLineStatusValue(status) ? status : "pending";
|
|
177
|
+
const values = Array.from(/* @__PURE__ */ new Set([current, ...LINE_STATUS_TRANSITIONS[current]]));
|
|
178
|
+
return values.map((value) => ({ value, label: t(`warranty_claims.lineStatus.${value}`) }));
|
|
179
|
+
}
|
|
180
|
+
function buildDispositionOptions(allowedDispositions, currentDisposition, t) {
|
|
181
|
+
const values = new Set(
|
|
182
|
+
CLAIM_DISPOSITIONS.filter((disposition) => allowedDispositions.includes(disposition))
|
|
183
|
+
);
|
|
184
|
+
if (currentDisposition) values.add(currentDisposition);
|
|
185
|
+
return Array.from(values).map((disposition) => ({
|
|
186
|
+
value: disposition,
|
|
187
|
+
label: t(`warranty_claims.disposition.${disposition}`, disposition)
|
|
188
|
+
}));
|
|
189
|
+
}
|
|
190
|
+
function formatTriageMessage(value, t) {
|
|
191
|
+
if (typeof value === "string") return t(value);
|
|
192
|
+
return t(value.messageKey, value.params);
|
|
193
|
+
}
|
|
194
|
+
function triageLineHeading(suggestedLine, lines, t) {
|
|
195
|
+
const name = suggestedLine.productName ?? suggestedLine.sku ?? suggestedLine.serialNumber ?? null;
|
|
196
|
+
const lineNo = toNumberOrNull(suggestedLine.lineNo) ?? lines.find((line) => line.id === suggestedLine.lineId)?.lineNo ?? null;
|
|
197
|
+
const label = name ?? t("warranty_claims.detail.lines.unnamed", "Unnamed line");
|
|
198
|
+
return lineNo !== null ? `#${lineNo} ${label}` : label;
|
|
199
|
+
}
|
|
200
|
+
function formatTimelineBody(event, t, userNames) {
|
|
201
|
+
if (event.body) return event.body;
|
|
202
|
+
const payload = event.payload;
|
|
203
|
+
const action = payload ? toStringOrNull(payload.action) : null;
|
|
204
|
+
if (event.kind === "system" && action === "sla_paused") return t("warranty_claims.timeline.slaPaused");
|
|
205
|
+
if (event.kind === "system" && action === "sla_resumed") return t("warranty_claims.timeline.slaResumed");
|
|
206
|
+
if (event.kind === "system" && action === "auto_approved") return t("warranty_claims.timeline.autoApproved");
|
|
207
|
+
if (event.kind === "system" && action === "ai_assessment_recorded") return t("warranty_claims.timeline.aiAssessmentRecorded");
|
|
208
|
+
if (event.kind === "system" && action === "sales_return_created") return t("warranty_claims.timeline.salesReturnCreated");
|
|
209
|
+
if (event.kind === "system" && action === "sales_return_orphaned") return t("warranty_claims.timeline.salesReturnOrphaned");
|
|
210
|
+
if (event.kind === "system" && action === "undo_sales_return_created") return t("warranty_claims.timeline.undoSalesReturnCreated");
|
|
211
|
+
if (event.kind === "system" && action === "replacement_order_created") return t("warranty_claims.timeline.replacementOrderCreated");
|
|
212
|
+
if (event.kind === "system" && action === "replacement_order_orphaned") return t("warranty_claims.timeline.replacementOrderOrphaned");
|
|
213
|
+
if (event.kind === "system" && action === "undo_replacement_order_created") return t("warranty_claims.timeline.undoReplacementOrderCreated");
|
|
214
|
+
if (event.kind === "system" && action === "credit_memo_created") return t("warranty_claims.timeline.creditMemoCreated");
|
|
215
|
+
if (event.kind === "system" && action === "credit_memo_orphaned") return t("warranty_claims.timeline.creditMemoOrphaned");
|
|
216
|
+
if (event.kind === "system" && action === "undo_credit_memo_created") return t("warranty_claims.timeline.undoCreditMemoCreated");
|
|
217
|
+
if (event.kind === "assignment") {
|
|
218
|
+
const assigneeUserId = payload ? toStringOrNull(payload.assigneeUserId) : null;
|
|
219
|
+
if (!assigneeUserId) return t("warranty_claims.timeline.unassigned");
|
|
220
|
+
return t("warranty_claims.timeline.assignedTo", { name: userNames[assigneeUserId] ?? t("warranty_claims.detail.unknownUser") });
|
|
221
|
+
}
|
|
222
|
+
const from = payload ? toStringOrNull(payload.from) ?? toStringOrNull(payload.fromStatus) : null;
|
|
223
|
+
const to = payload ? toStringOrNull(payload.to) ?? toStringOrNull(payload.toStatus) : null;
|
|
224
|
+
if (event.kind === "status_changed" && from && to) {
|
|
225
|
+
const statusLine = `${t(`warranty_claims.status.${from}`)} \u2192 ${t(`warranty_claims.status.${to}`)}`;
|
|
226
|
+
const systemNote = payload ? toStringOrNull(payload.systemNote) : null;
|
|
227
|
+
if (systemNote && systemNote.startsWith("warranty_claims.")) {
|
|
228
|
+
return `${statusLine} \u2014 ${t(systemNote)}`;
|
|
229
|
+
}
|
|
230
|
+
return statusLine;
|
|
231
|
+
}
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
function resolveTimelineActor(event, claim, userNames, t) {
|
|
235
|
+
if (event.actorUserId) return userNames[event.actorUserId] ?? t("warranty_claims.detail.unknownUser");
|
|
236
|
+
if (event.actorCustomerId) return claim.customerName ?? t("warranty_claims.detail.customerActor");
|
|
237
|
+
return t("warranty_claims.detail.systemActor");
|
|
238
|
+
}
|
|
239
|
+
function translateErrorMessage(err, t, fallbackKey) {
|
|
240
|
+
const mappedMessage = mapCrudServerErrorToFormErrors(err).message;
|
|
241
|
+
if (typeof mappedMessage === "string" && mappedMessage.trim().length) return t(mappedMessage, mappedMessage);
|
|
242
|
+
if (err instanceof Error && err.message) return t(err.message, err.message);
|
|
243
|
+
return t(fallbackKey);
|
|
244
|
+
}
|
|
245
|
+
function buildRiskSignalTitle(signal) {
|
|
246
|
+
return signal.relatedClaimNumbers?.length ? signal.relatedClaimNumbers.join(", ") : void 0;
|
|
247
|
+
}
|
|
248
|
+
function riskSignalVariant(signal) {
|
|
249
|
+
return signal.level === "high" ? "error" : "warning";
|
|
250
|
+
}
|
|
251
|
+
function normalizeClaim(value) {
|
|
252
|
+
if (!isRecord(value)) return null;
|
|
253
|
+
const id = toStringOrNull(value.id);
|
|
254
|
+
if (!id) return null;
|
|
255
|
+
return {
|
|
256
|
+
id,
|
|
257
|
+
claimNumber: toStringOrNull(value.claimNumber),
|
|
258
|
+
claimType: toStringOrNull(value.claimType),
|
|
259
|
+
channel: toStringOrNull(value.channel),
|
|
260
|
+
status: toStringOrNull(value.status),
|
|
261
|
+
priority: toStringOrNull(value.priority),
|
|
262
|
+
customerId: toStringOrNull(value.customerId),
|
|
263
|
+
customerName: toStringOrNull(value.customerName),
|
|
264
|
+
orderId: toStringOrNull(value.orderId),
|
|
265
|
+
orderNumber: toStringOrNull(value.orderNumber),
|
|
266
|
+
salesReturnId: toStringOrNull(value.salesReturnId),
|
|
267
|
+
replacementOrderId: toStringOrNull(value.replacementOrderId),
|
|
268
|
+
creditMemoId: toStringOrNull(value.creditMemoId),
|
|
269
|
+
awaitingStaffReply: parseBooleanFromUnknown(value.awaitingStaffReply) ?? false,
|
|
270
|
+
vendorName: toStringOrNull(value.vendorName),
|
|
271
|
+
vendorRef: toStringOrNull(value.vendorRef),
|
|
272
|
+
totalClaimedAmount: toStringOrNull(value.totalClaimedAmount),
|
|
273
|
+
totalApprovedAmount: toStringOrNull(value.totalApprovedAmount),
|
|
274
|
+
totalRecoveredAmount: toStringOrNull(value.totalRecoveredAmount),
|
|
275
|
+
slaDueAt: toStringOrNull(value.slaDueAt),
|
|
276
|
+
slaPausedAt: toStringOrNull(value.slaPausedAt),
|
|
277
|
+
submittedAt: toStringOrNull(value.submittedAt),
|
|
278
|
+
assigneeUserId: toStringOrNull(value.assigneeUserId),
|
|
279
|
+
assigneeName: toStringOrNull(value.assigneeName),
|
|
280
|
+
createdAt: toStringOrNull(value.createdAt),
|
|
281
|
+
updatedAt: toStringOrNull(value.updatedAt),
|
|
282
|
+
currencyCode: toStringOrNull(value.currencyCode),
|
|
283
|
+
notes: toStringOrNull(value.notes),
|
|
284
|
+
reasonCode: toStringOrNull(value.reasonCode),
|
|
285
|
+
rejectionReasonCode: toStringOrNull(value.rejectionReasonCode),
|
|
286
|
+
resolutionSummary: toStringOrNull(value.resolutionSummary),
|
|
287
|
+
returnLabelUrl: toStringOrNull(value.returnLabelUrl),
|
|
288
|
+
returnTrackingNumber: toStringOrNull(value.returnTrackingNumber),
|
|
289
|
+
returnCarrier: toStringOrNull(value.returnCarrier)
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
function normalizeLine(value) {
|
|
293
|
+
if (!isRecord(value)) return null;
|
|
294
|
+
const id = toStringOrNull(value.id);
|
|
295
|
+
if (!id) return null;
|
|
296
|
+
return {
|
|
297
|
+
id,
|
|
298
|
+
claimId: toStringOrNull(value.claimId),
|
|
299
|
+
lineNo: toNumberOrNull(value.lineNo),
|
|
300
|
+
productId: toStringOrNull(value.productId),
|
|
301
|
+
variantId: toStringOrNull(value.variantId),
|
|
302
|
+
productName: toStringOrNull(value.productName),
|
|
303
|
+
orderLineId: toStringOrNull(value.orderLineId),
|
|
304
|
+
sku: toStringOrNull(value.sku),
|
|
305
|
+
serialNumber: toStringOrNull(value.serialNumber),
|
|
306
|
+
purchaseDate: toStringOrNull(value.purchaseDate),
|
|
307
|
+
warrantyMonths: toNumberOrNull(value.warrantyMonths),
|
|
308
|
+
faultCode: toStringOrNull(value.faultCode),
|
|
309
|
+
faultDescription: toStringOrNull(value.faultDescription),
|
|
310
|
+
qtyClaimed: toStringOrNull(value.qtyClaimed),
|
|
311
|
+
qtyApproved: toStringOrNull(value.qtyApproved),
|
|
312
|
+
qtyReceived: toStringOrNull(value.qtyReceived),
|
|
313
|
+
disposition: toStringOrNull(value.disposition),
|
|
314
|
+
lineStatus: toStringOrNull(value.lineStatus),
|
|
315
|
+
creditAmount: toStringOrNull(value.creditAmount),
|
|
316
|
+
restockingFee: toStringOrNull(value.restockingFee),
|
|
317
|
+
coreChargeAmount: toStringOrNull(value.coreChargeAmount),
|
|
318
|
+
coreCreditAmount: toStringOrNull(value.coreCreditAmount),
|
|
319
|
+
vendorClaimLineId: toStringOrNull(value.vendorClaimLineId),
|
|
320
|
+
conditionOnReceipt: toStringOrNull(value.conditionOnReceipt),
|
|
321
|
+
conditionGrade: toStringOrNull(value.conditionGrade),
|
|
322
|
+
quarantineStatus: toStringOrNull(value.quarantineStatus),
|
|
323
|
+
inspectionNotes: toStringOrNull(value.inspectionNotes),
|
|
324
|
+
assessmentPayload: isRecord(value.assessmentPayload) ? value.assessmentPayload : null,
|
|
325
|
+
updatedAt: toStringOrNull(value.updatedAt)
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function normalizeEvent(value) {
|
|
329
|
+
if (!isRecord(value)) return null;
|
|
330
|
+
const id = toStringOrNull(value.id);
|
|
331
|
+
if (!id) return null;
|
|
332
|
+
return {
|
|
333
|
+
id,
|
|
334
|
+
kind: toStringOrNull(value.kind) ?? "system",
|
|
335
|
+
visibility: toStringOrNull(value.visibility) ?? "internal",
|
|
336
|
+
body: toStringOrNull(value.body),
|
|
337
|
+
payload: isRecord(value.payload) ? value.payload : null,
|
|
338
|
+
actorUserId: toStringOrNull(value.actorUserId),
|
|
339
|
+
actorCustomerId: toStringOrNull(value.actorCustomerId),
|
|
340
|
+
createdAt: toStringOrNull(value.createdAt)
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function normalizeDictionaryOption(item) {
|
|
344
|
+
if (!isRecord(item)) return null;
|
|
345
|
+
const value = toStringOrNull(item.value);
|
|
346
|
+
if (!value) return null;
|
|
347
|
+
return { value, label: toStringOrNull(item.label) ?? value };
|
|
348
|
+
}
|
|
349
|
+
function nullableText(value) {
|
|
350
|
+
return toStringOrNull(value);
|
|
351
|
+
}
|
|
352
|
+
function buildConflictError(call, fallbackMessage, t) {
|
|
353
|
+
const payload = isRecord(call.result) ? call.result : {};
|
|
354
|
+
const rawMessage = typeof payload.error === "string" ? payload.error : fallbackMessage;
|
|
355
|
+
const message = t ? t(rawMessage) : rawMessage;
|
|
356
|
+
return Object.assign(new Error(message), { status: call.status }, payload);
|
|
357
|
+
}
|
|
358
|
+
function readDraftReplyPayload(value) {
|
|
359
|
+
if (!isRecord(value)) return {};
|
|
360
|
+
return isRecord(value.result) ? value.result : value;
|
|
361
|
+
}
|
|
362
|
+
function isDraftReplyNotConfigured(value) {
|
|
363
|
+
const payload = readDraftReplyPayload(value);
|
|
364
|
+
return payload.notConfigured === true;
|
|
365
|
+
}
|
|
366
|
+
function readDraftReply(value) {
|
|
367
|
+
return toStringOrNull(readDraftReplyPayload(value).draft);
|
|
368
|
+
}
|
|
369
|
+
function readErrorKey(value) {
|
|
370
|
+
return isRecord(value) ? toStringOrNull(value.error) : null;
|
|
371
|
+
}
|
|
372
|
+
function formatAmount(value, currencyCode, fallback) {
|
|
373
|
+
const amount = toNumberOrNull(value);
|
|
374
|
+
if (amount === null) return fallback;
|
|
375
|
+
if (!currencyCode) return amount.toLocaleString();
|
|
376
|
+
return new Intl.NumberFormat(void 0, { style: "currency", currency: currencyCode }).format(amount);
|
|
377
|
+
}
|
|
378
|
+
function eventIcon(kind) {
|
|
379
|
+
if (kind === "comment") return MessageSquare;
|
|
380
|
+
if (kind === "assignment") return UserRound;
|
|
381
|
+
if (kind === "status_changed") return RefreshCw;
|
|
382
|
+
return Info;
|
|
383
|
+
}
|
|
384
|
+
const TIMELINE_FILTER_LABELS = {
|
|
385
|
+
all: { key: "warranty_claims.detail.timeline.filter.all", fallback: "All" },
|
|
386
|
+
comments: { key: "warranty_claims.detail.timeline.filter.comments", fallback: "Comments" },
|
|
387
|
+
status_changes: { key: "warranty_claims.detail.timeline.filter.statusChanges", fallback: "Status changes" },
|
|
388
|
+
customer_visible: { key: "warranty_claims.detail.timeline.filter.customerVisible", fallback: "Customer-visible" }
|
|
389
|
+
};
|
|
390
|
+
function RiskSignalChips({ signals, t }) {
|
|
391
|
+
if (!signals.length) return null;
|
|
392
|
+
return /* @__PURE__ */ jsx(Fragment, { children: signals.map((signal) => /* @__PURE__ */ jsx("span", { className: "min-w-0 max-w-full", title: buildRiskSignalTitle(signal), children: /* @__PURE__ */ jsx(
|
|
393
|
+
StatusBadge,
|
|
394
|
+
{
|
|
395
|
+
variant: riskSignalVariant(signal),
|
|
396
|
+
className: "h-auto max-w-full rounded-md py-1 whitespace-normal break-words text-left leading-snug",
|
|
397
|
+
children: t(signal.messageKey, signal.params)
|
|
398
|
+
}
|
|
399
|
+
) }, signal.id)) });
|
|
400
|
+
}
|
|
401
|
+
function InlineQtyApprovedCell({
|
|
402
|
+
line,
|
|
403
|
+
disabled,
|
|
404
|
+
label,
|
|
405
|
+
onSave
|
|
406
|
+
}) {
|
|
407
|
+
const currentValue = quantityInputValue(line.qtyApproved);
|
|
408
|
+
const [draft, setDraft] = React.useState(currentValue);
|
|
409
|
+
const blurSaveSuppressedRef = React.useRef(false);
|
|
410
|
+
React.useEffect(() => {
|
|
411
|
+
setDraft(currentValue);
|
|
412
|
+
}, [currentValue]);
|
|
413
|
+
const commit = React.useCallback((value) => {
|
|
414
|
+
const nextValue = value.trim().length ? value.trim() : null;
|
|
415
|
+
if (parseQuantity(nextValue) === parseQuantity(line.qtyApproved)) return;
|
|
416
|
+
void onSave(line, "qtyApproved", nextValue);
|
|
417
|
+
}, [line, onSave]);
|
|
418
|
+
return /* @__PURE__ */ jsx(
|
|
419
|
+
Input,
|
|
420
|
+
{
|
|
421
|
+
type: "number",
|
|
422
|
+
inputMode: "decimal",
|
|
423
|
+
value: draft,
|
|
424
|
+
disabled,
|
|
425
|
+
"aria-label": label,
|
|
426
|
+
className: "w-24",
|
|
427
|
+
onClick: (event) => event.stopPropagation(),
|
|
428
|
+
onChange: (event) => setDraft(event.target.value),
|
|
429
|
+
onFocus: () => {
|
|
430
|
+
blurSaveSuppressedRef.current = false;
|
|
431
|
+
},
|
|
432
|
+
onBlur: () => {
|
|
433
|
+
if (blurSaveSuppressedRef.current) {
|
|
434
|
+
blurSaveSuppressedRef.current = false;
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
commit(draft);
|
|
438
|
+
},
|
|
439
|
+
onKeyDown: (event) => {
|
|
440
|
+
if (event.key === "Escape") {
|
|
441
|
+
event.preventDefault();
|
|
442
|
+
blurSaveSuppressedRef.current = true;
|
|
443
|
+
setDraft(currentValue);
|
|
444
|
+
event.currentTarget.blur();
|
|
445
|
+
return;
|
|
446
|
+
}
|
|
447
|
+
if (event.key === "Enter") {
|
|
448
|
+
event.preventDefault();
|
|
449
|
+
blurSaveSuppressedRef.current = true;
|
|
450
|
+
commit(draft);
|
|
451
|
+
event.currentTarget.blur();
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
);
|
|
456
|
+
}
|
|
457
|
+
function InlineLineSelectCell({
|
|
458
|
+
line,
|
|
459
|
+
field,
|
|
460
|
+
value,
|
|
461
|
+
options,
|
|
462
|
+
label,
|
|
463
|
+
emptyLabel,
|
|
464
|
+
disabled,
|
|
465
|
+
onSave
|
|
466
|
+
}) {
|
|
467
|
+
const selectedValue = value ?? CLEAR_SELECT_VALUE;
|
|
468
|
+
return /* @__PURE__ */ jsx("div", { onClick: (event) => event.stopPropagation(), children: /* @__PURE__ */ jsxs(
|
|
469
|
+
Select,
|
|
470
|
+
{
|
|
471
|
+
value: selectedValue,
|
|
472
|
+
disabled,
|
|
473
|
+
onValueChange: (nextValue) => {
|
|
474
|
+
const normalizedValue = nextValue === CLEAR_SELECT_VALUE ? null : nextValue;
|
|
475
|
+
if (normalizedValue === value) return;
|
|
476
|
+
void onSave(line, field, normalizedValue);
|
|
477
|
+
},
|
|
478
|
+
children: [
|
|
479
|
+
/* @__PURE__ */ jsx(SelectTrigger, { "aria-label": label, className: "w-36", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
480
|
+
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
481
|
+
emptyLabel ? /* @__PURE__ */ jsx(SelectItem, { value: CLEAR_SELECT_VALUE, children: emptyLabel }) : null,
|
|
482
|
+
options.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: option.label }, option.value))
|
|
483
|
+
] })
|
|
484
|
+
]
|
|
485
|
+
}
|
|
486
|
+
) });
|
|
487
|
+
}
|
|
488
|
+
function WarrantyClaimDetailPage({ params }) {
|
|
489
|
+
const t = useT();
|
|
490
|
+
const locale = useLocale();
|
|
491
|
+
const router = useRouter();
|
|
492
|
+
const id = typeof params?.id === "string" ? params.id : "";
|
|
493
|
+
const { confirm, ConfirmDialogElement } = useConfirmDialog();
|
|
494
|
+
const currentUserId = useCurrentUserId();
|
|
495
|
+
const scopeVersion = useOrganizationScopeVersion();
|
|
496
|
+
const [claim, setClaim] = React.useState(null);
|
|
497
|
+
const [lines, setLines] = React.useState([]);
|
|
498
|
+
const [events, setEvents] = React.useState([]);
|
|
499
|
+
const [attachmentCount, setAttachmentCount] = React.useState(0);
|
|
500
|
+
const [loading, setLoading] = React.useState(true);
|
|
501
|
+
const [error, setError] = React.useState(null);
|
|
502
|
+
const [notFound, setNotFound] = React.useState(false);
|
|
503
|
+
const [activeTab, setActiveTab] = React.useState("lines");
|
|
504
|
+
const [timelineFilter, setTimelineFilter] = React.useState("all");
|
|
505
|
+
const [customerLink, setCustomerLink] = React.useState(null);
|
|
506
|
+
const [lineDialog, setLineDialog] = React.useState(null);
|
|
507
|
+
const [defaultWarrantyMonths, setDefaultWarrantyMonths] = React.useState(null);
|
|
508
|
+
const [featureAccess, setFeatureAccess] = React.useState({
|
|
509
|
+
claimManage: false,
|
|
510
|
+
claimDelete: false,
|
|
511
|
+
receivingManage: false,
|
|
512
|
+
salesReturnsCreate: false,
|
|
513
|
+
salesOrdersManage: false,
|
|
514
|
+
salesCreditMemosManage: false
|
|
515
|
+
});
|
|
516
|
+
React.useEffect(() => {
|
|
517
|
+
let cancelled = false;
|
|
518
|
+
void apiCall("/api/warranty_claims/settings-general", { headers: { "x-om-forbidden-redirect": "0" } }, { fallback: {} }).then((call) => {
|
|
519
|
+
if (cancelled || !call.ok) return;
|
|
520
|
+
const months = call.result?.result?.defaultWarrantyMonths;
|
|
521
|
+
setDefaultWarrantyMonths(typeof months === "number" && Number.isFinite(months) ? months : null);
|
|
522
|
+
}).catch(() => void 0);
|
|
523
|
+
return () => {
|
|
524
|
+
cancelled = true;
|
|
525
|
+
};
|
|
526
|
+
}, [scopeVersion]);
|
|
527
|
+
React.useEffect(() => {
|
|
528
|
+
let cancelled = false;
|
|
529
|
+
void apiCall(
|
|
530
|
+
"/api/auth/feature-check",
|
|
531
|
+
{
|
|
532
|
+
method: "POST",
|
|
533
|
+
headers: { "content-type": "application/json" },
|
|
534
|
+
body: JSON.stringify({
|
|
535
|
+
features: [
|
|
536
|
+
"warranty_claims.claim.manage",
|
|
537
|
+
"warranty_claims.claim.delete",
|
|
538
|
+
"warranty_claims.receiving.manage",
|
|
539
|
+
"sales.returns.create",
|
|
540
|
+
"sales.orders.manage",
|
|
541
|
+
"sales.credit_memos.manage"
|
|
542
|
+
]
|
|
543
|
+
})
|
|
544
|
+
},
|
|
545
|
+
{ fallback: { ok: false, granted: [] } }
|
|
546
|
+
).then((call) => {
|
|
547
|
+
if (cancelled || !call.ok) return;
|
|
548
|
+
const granted = Array.isArray(call.result?.granted) ? call.result.granted : [];
|
|
549
|
+
const allGranted = call.result?.ok === true;
|
|
550
|
+
setFeatureAccess({
|
|
551
|
+
claimManage: allGranted || hasFeature(granted, "warranty_claims.claim.manage"),
|
|
552
|
+
claimDelete: allGranted || hasFeature(granted, "warranty_claims.claim.delete"),
|
|
553
|
+
receivingManage: allGranted || hasFeature(granted, "warranty_claims.receiving.manage"),
|
|
554
|
+
salesReturnsCreate: allGranted || hasFeature(granted, "sales.returns.create"),
|
|
555
|
+
salesOrdersManage: allGranted || hasFeature(granted, "sales.orders.manage"),
|
|
556
|
+
salesCreditMemosManage: allGranted || hasFeature(granted, "sales.credit_memos.manage")
|
|
557
|
+
});
|
|
558
|
+
}).catch(() => {
|
|
559
|
+
if (!cancelled) {
|
|
560
|
+
setFeatureAccess({
|
|
561
|
+
claimManage: false,
|
|
562
|
+
claimDelete: false,
|
|
563
|
+
receivingManage: false,
|
|
564
|
+
salesReturnsCreate: false,
|
|
565
|
+
salesOrdersManage: false,
|
|
566
|
+
salesCreditMemosManage: false
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
return () => {
|
|
571
|
+
cancelled = true;
|
|
572
|
+
};
|
|
573
|
+
}, [scopeVersion]);
|
|
574
|
+
const [transitionDialog, setTransitionDialog] = React.useState(null);
|
|
575
|
+
const [vendorDialogOpen, setVendorDialogOpen] = React.useState(false);
|
|
576
|
+
const [commentBody, setCommentBody] = React.useState("");
|
|
577
|
+
const [commentVisibility, setCommentVisibility] = React.useState("internal");
|
|
578
|
+
const [aiSuggestion, setAiSuggestion] = React.useState(null);
|
|
579
|
+
const [aiLoading, setAiLoading] = React.useState(false);
|
|
580
|
+
const [appliedTriageLineIds, setAppliedTriageLineIds] = React.useState(/* @__PURE__ */ new Set());
|
|
581
|
+
const [draftReplyLoading, setDraftReplyLoading] = React.useState(false);
|
|
582
|
+
const [draftReplyHidden, setDraftReplyHidden] = React.useState(false);
|
|
583
|
+
const [riskAssessment, setRiskAssessment] = React.useState(EMPTY_RISK_ASSESSMENT);
|
|
584
|
+
const [slaAtRiskThresholdPct, setSlaAtRiskThresholdPct] = React.useState(void 0);
|
|
585
|
+
const [assignDialogOpen, setAssignDialogOpen] = React.useState(false);
|
|
586
|
+
const [assignSearch, setAssignSearch] = React.useState("");
|
|
587
|
+
const [assignOptions, setAssignOptions] = React.useState([]);
|
|
588
|
+
const [assignLoading, setAssignLoading] = React.useState(false);
|
|
589
|
+
const [selectedAssigneeUserId, setSelectedAssigneeUserId] = React.useState(UNASSIGNED_SELECT_VALUE);
|
|
590
|
+
const mutationContextId = React.useMemo(() => `warranty-claim:${id || "pending"}`, [id]);
|
|
591
|
+
const { runMutation, retryLastMutation } = useGuardedMutation({
|
|
592
|
+
contextId: mutationContextId,
|
|
593
|
+
blockedMessage: t("warranty_claims.common.saveBlocked")
|
|
594
|
+
});
|
|
595
|
+
const mutationContext = React.useMemo(() => ({
|
|
596
|
+
formId: mutationContextId,
|
|
597
|
+
resourceKind: "warranty_claims.claim",
|
|
598
|
+
resourceId: claim?.id ?? id,
|
|
599
|
+
retryLastMutation
|
|
600
|
+
}), [claim?.id, id, mutationContextId, retryLastMutation]);
|
|
601
|
+
const loadDictionaryOptions = React.useCallback(async (dictionaryKey, kind) => {
|
|
602
|
+
const dictionaries = await readApiResultOrThrow(
|
|
603
|
+
"/api/dictionaries",
|
|
604
|
+
void 0,
|
|
605
|
+
{
|
|
606
|
+
fallback: { items: [] },
|
|
607
|
+
errorMessage: t("warranty_claims.form.error.dictionaryLoad")
|
|
608
|
+
}
|
|
609
|
+
);
|
|
610
|
+
const dictionary = (dictionaries.items ?? []).find((item) => item.key === dictionaryKey);
|
|
611
|
+
if (!dictionary?.id) return [];
|
|
612
|
+
const entries = await readApiResultOrThrow(
|
|
613
|
+
`/api/dictionaries/${encodeURIComponent(dictionary.id)}/entries`,
|
|
614
|
+
void 0,
|
|
615
|
+
{
|
|
616
|
+
fallback: { items: [] },
|
|
617
|
+
errorMessage: t("warranty_claims.form.error.dictionaryLoad")
|
|
618
|
+
}
|
|
619
|
+
);
|
|
620
|
+
return (entries.items ?? []).map(normalizeDictionaryOption).filter((option) => option !== null).map((option) => ({
|
|
621
|
+
...option,
|
|
622
|
+
label: localizeDictionaryLabel(t, kind, option.value, option.label)
|
|
623
|
+
}));
|
|
624
|
+
}, [t]);
|
|
625
|
+
const loadData = React.useCallback(async () => {
|
|
626
|
+
if (!id) return;
|
|
627
|
+
setLoading(true);
|
|
628
|
+
setError(null);
|
|
629
|
+
setNotFound(false);
|
|
630
|
+
try {
|
|
631
|
+
const [claimPayload, linesPayload, eventsPayload, riskPayload, statsPayload, attachmentsPayload] = await Promise.all([
|
|
632
|
+
readApiResultOrThrow(
|
|
633
|
+
`/api/warranty_claims?ids=${encodeURIComponent(id)}&page=1&pageSize=1`,
|
|
634
|
+
void 0,
|
|
635
|
+
{ fallback: { items: [] }, errorMessage: t("warranty_claims.detail.error.load") }
|
|
636
|
+
),
|
|
637
|
+
readApiResultOrThrow(
|
|
638
|
+
`/api/warranty_claims/lines?claimId=${encodeURIComponent(id)}&page=1&pageSize=100`,
|
|
639
|
+
void 0,
|
|
640
|
+
{ fallback: { items: [] }, errorMessage: t("warranty_claims.detail.error.loadLines") }
|
|
641
|
+
),
|
|
642
|
+
readApiResultOrThrow(
|
|
643
|
+
`/api/warranty_claims/events?claimId=${encodeURIComponent(id)}`,
|
|
644
|
+
void 0,
|
|
645
|
+
{ fallback: { items: [] }, errorMessage: t("warranty_claims.detail.error.loadEvents") }
|
|
646
|
+
),
|
|
647
|
+
readApiResultOrThrow(
|
|
648
|
+
`/api/warranty_claims/risk?claimId=${encodeURIComponent(id)}`,
|
|
649
|
+
void 0,
|
|
650
|
+
{
|
|
651
|
+
fallback: { ok: true, result: EMPTY_RISK_ASSESSMENT },
|
|
652
|
+
errorMessage: t("warranty_claims.detail.error.loadRisk")
|
|
653
|
+
}
|
|
654
|
+
),
|
|
655
|
+
readApiResultOrThrow(
|
|
656
|
+
"/api/warranty_claims/stats",
|
|
657
|
+
void 0,
|
|
658
|
+
{ fallback: { ok: true, result: {} } }
|
|
659
|
+
),
|
|
660
|
+
readApiResultOrThrow(
|
|
661
|
+
`/api/attachments?entityId=${encodeURIComponent("warranty_claims:warranty_claim")}&recordId=${encodeURIComponent(id)}`,
|
|
662
|
+
void 0,
|
|
663
|
+
{ fallback: { items: [] } }
|
|
664
|
+
)
|
|
665
|
+
]);
|
|
666
|
+
const nextClaim = (claimPayload.items ?? []).map(normalizeClaim).find((item) => item !== null) ?? null;
|
|
667
|
+
if (!nextClaim) {
|
|
668
|
+
setClaim(null);
|
|
669
|
+
setLines([]);
|
|
670
|
+
setEvents([]);
|
|
671
|
+
setAttachmentCount(0);
|
|
672
|
+
setRiskAssessment(EMPTY_RISK_ASSESSMENT);
|
|
673
|
+
setNotFound(true);
|
|
674
|
+
return;
|
|
675
|
+
}
|
|
676
|
+
setClaim(nextClaim);
|
|
677
|
+
setLines((linesPayload.items ?? []).map(normalizeLine).filter((item) => item !== null));
|
|
678
|
+
setEvents((eventsPayload.items ?? []).map(normalizeEvent).filter((item) => item !== null));
|
|
679
|
+
setAttachmentCount(Array.isArray(attachmentsPayload.items) ? attachmentsPayload.items.length : 0);
|
|
680
|
+
setRiskAssessment(normalizeRiskResponse(riskPayload));
|
|
681
|
+
const nextThreshold = statsPayload?.result?.slaAtRiskThresholdPct;
|
|
682
|
+
setSlaAtRiskThresholdPct(typeof nextThreshold === "number" ? nextThreshold : void 0);
|
|
683
|
+
} catch (err) {
|
|
684
|
+
setError(err instanceof Error ? err.message : t("warranty_claims.detail.error.load"));
|
|
685
|
+
} finally {
|
|
686
|
+
setLoading(false);
|
|
687
|
+
}
|
|
688
|
+
}, [id, scopeVersion, t]);
|
|
689
|
+
React.useEffect(() => {
|
|
690
|
+
void loadData();
|
|
691
|
+
}, [loadData]);
|
|
692
|
+
useAppEvent("warranty_claims.claim.*", (event) => {
|
|
693
|
+
const eventClaimId = toStringOrNull(event.payload.claimId);
|
|
694
|
+
if (eventClaimId === id) void loadData();
|
|
695
|
+
}, [id, loadData]);
|
|
696
|
+
const referencedUserIds = React.useMemo(() => {
|
|
697
|
+
const collected = /* @__PURE__ */ new Set();
|
|
698
|
+
if (claim?.assigneeUserId) collected.add(claim.assigneeUserId);
|
|
699
|
+
for (const event of events) {
|
|
700
|
+
if (event.actorUserId) collected.add(event.actorUserId);
|
|
701
|
+
if (event.kind === "assignment") {
|
|
702
|
+
const assigneeUserId = toStringOrNull(event.payload?.assigneeUserId);
|
|
703
|
+
if (assigneeUserId) collected.add(assigneeUserId);
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return [...collected];
|
|
707
|
+
}, [claim?.assigneeUserId, events]);
|
|
708
|
+
const userNames = useUserDisplayNames(referencedUserIds);
|
|
709
|
+
React.useEffect(() => {
|
|
710
|
+
if (!assignDialogOpen) return;
|
|
711
|
+
const controller = new AbortController();
|
|
712
|
+
setAssignLoading(true);
|
|
713
|
+
fetchAssignableStaffMembersPage(assignSearch, { page: 1, pageSize: 24, signal: controller.signal }).then((page) => setAssignOptions(page.items)).catch(() => setAssignOptions([])).finally(() => {
|
|
714
|
+
if (!controller.signal.aborted) setAssignLoading(false);
|
|
715
|
+
});
|
|
716
|
+
return () => controller.abort();
|
|
717
|
+
}, [assignDialogOpen, assignSearch]);
|
|
718
|
+
const claimCustomerId = claim?.customerId ?? null;
|
|
719
|
+
React.useEffect(() => {
|
|
720
|
+
if (!claimCustomerId || customerLink?.customerId === claimCustomerId) return;
|
|
721
|
+
const controller = new AbortController();
|
|
722
|
+
const idsParam = encodeURIComponent(claimCustomerId);
|
|
723
|
+
const hasMatch = (payload) => (payload?.items ?? []).some((item) => isRecord(item) && toStringOrNull(item.id) === claimCustomerId);
|
|
724
|
+
const resolveCustomerHref = async () => {
|
|
725
|
+
const people = await apiCall(
|
|
726
|
+
`/api/customers/people?ids=${idsParam}&pageSize=1`,
|
|
727
|
+
{ signal: controller.signal },
|
|
728
|
+
{ fallback: { items: [] } }
|
|
729
|
+
);
|
|
730
|
+
if (people.ok && hasMatch(people.result)) return `/backend/customers/people/${claimCustomerId}`;
|
|
731
|
+
const companies = await apiCall(
|
|
732
|
+
`/api/customers/companies?ids=${idsParam}&pageSize=1`,
|
|
733
|
+
{ signal: controller.signal },
|
|
734
|
+
{ fallback: { items: [] } }
|
|
735
|
+
);
|
|
736
|
+
if (companies.ok && hasMatch(companies.result)) return `/backend/customers/companies/${claimCustomerId}`;
|
|
737
|
+
return null;
|
|
738
|
+
};
|
|
739
|
+
resolveCustomerHref().then((href) => {
|
|
740
|
+
if (controller.signal.aborted || !href) return;
|
|
741
|
+
setCustomerLink({ customerId: claimCustomerId, href });
|
|
742
|
+
}).catch(() => {
|
|
743
|
+
});
|
|
744
|
+
return () => controller.abort();
|
|
745
|
+
}, [claimCustomerId, customerLink]);
|
|
746
|
+
const filteredTimelineEvents = React.useMemo(
|
|
747
|
+
() => filterTimelineEvents(events, timelineFilter),
|
|
748
|
+
[events, timelineFilter]
|
|
749
|
+
);
|
|
750
|
+
const currentStatus = typeof claim?.status === "string" ? claim.status : "draft";
|
|
751
|
+
const nextStatuses = React.useMemo(() => {
|
|
752
|
+
if (!claim || !(currentStatus in CLAIM_STATUS_TRANSITIONS)) return [];
|
|
753
|
+
return CLAIM_STATUS_TRANSITIONS[currentStatus] ?? [];
|
|
754
|
+
}, [claim, currentStatus]);
|
|
755
|
+
const primaryNextStatus = React.useMemo(
|
|
756
|
+
() => nextStatuses.find((status) => status !== "cancelled" && status !== "rejected" && status !== "info_requested") ?? nextStatuses[0] ?? null,
|
|
757
|
+
[nextStatuses]
|
|
758
|
+
);
|
|
759
|
+
const resolutionStatuses = React.useMemo(
|
|
760
|
+
() => nextStatuses.filter((status) => status !== primaryNextStatus),
|
|
761
|
+
[nextStatuses, primaryNextStatus]
|
|
762
|
+
);
|
|
763
|
+
const noValue = t("warranty_claims.common.noValue");
|
|
764
|
+
const linesEditable = LINE_EDITABLE_CLAIM_STATUSES.has(currentStatus);
|
|
765
|
+
const linesInlineEditable = linesEditable && featureAccess.claimManage;
|
|
766
|
+
const claimActive = !isTerminal(currentStatus);
|
|
767
|
+
const claimMutable = claimActive && currentStatus !== "resolved" && currentStatus !== "rejected";
|
|
768
|
+
const allowedDispositions = React.useMemo(
|
|
769
|
+
() => resolveClaimTypeUiConfig(claim?.claimType).allowedDispositions,
|
|
770
|
+
[claim?.claimType]
|
|
771
|
+
);
|
|
772
|
+
const currentLineDisposition = lineDialog?.mode === "edit" ? lineDialog.line.disposition : null;
|
|
773
|
+
const riskSignals = riskAssessment.signals;
|
|
774
|
+
const assigneeDisplayName = claim?.assigneeUserId ? claim.assigneeName ?? userNames[claim.assigneeUserId] ?? t("warranty_claims.detail.unknownUser") : t("warranty_claims.detail.unassigned");
|
|
775
|
+
const eligibleVendorLines = React.useMemo(
|
|
776
|
+
() => lines.filter((line) => line.lineStatus === "resolved" && !line.vendorClaimLineId),
|
|
777
|
+
[lines]
|
|
778
|
+
);
|
|
779
|
+
const assignableOptions = React.useMemo(() => {
|
|
780
|
+
const byUserId = /* @__PURE__ */ new Map();
|
|
781
|
+
for (const option of assignOptions) byUserId.set(option.userId, option);
|
|
782
|
+
if (claim?.assigneeUserId && !byUserId.has(claim.assigneeUserId)) {
|
|
783
|
+
byUserId.set(claim.assigneeUserId, {
|
|
784
|
+
teamMemberId: claim.assigneeUserId,
|
|
785
|
+
userId: claim.assigneeUserId,
|
|
786
|
+
displayName: userNames[claim.assigneeUserId] ?? t("warranty_claims.detail.unknownUser"),
|
|
787
|
+
email: null,
|
|
788
|
+
teamName: null
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
return Array.from(byUserId.values());
|
|
792
|
+
}, [assignOptions, claim?.assigneeUserId, userNames, t]);
|
|
793
|
+
const openAssignDialog = React.useCallback(() => {
|
|
794
|
+
setSelectedAssigneeUserId(claim?.assigneeUserId ?? UNASSIGNED_SELECT_VALUE);
|
|
795
|
+
setAssignSearch("");
|
|
796
|
+
setAssignDialogOpen(true);
|
|
797
|
+
}, [claim?.assigneeUserId]);
|
|
798
|
+
const runClaimPost = React.useCallback(async (endpoint, body, successKey) => {
|
|
799
|
+
if (!claim) return;
|
|
800
|
+
try {
|
|
801
|
+
await runMutation({
|
|
802
|
+
operation: async () => {
|
|
803
|
+
const call = await withScopedApiRequestHeaders(
|
|
804
|
+
buildOptimisticLockHeader(claim.updatedAt),
|
|
805
|
+
() => apiCall(endpoint, {
|
|
806
|
+
method: "POST",
|
|
807
|
+
headers: { "content-type": "application/json" },
|
|
808
|
+
body: JSON.stringify(body)
|
|
809
|
+
})
|
|
810
|
+
);
|
|
811
|
+
if (!call.ok) throw buildConflictError(call, t("warranty_claims.detail.error.action"), t);
|
|
812
|
+
return call;
|
|
813
|
+
},
|
|
814
|
+
context: mutationContext,
|
|
815
|
+
mutationPayload: body
|
|
816
|
+
});
|
|
817
|
+
flash(t(successKey), "success");
|
|
818
|
+
await loadData();
|
|
819
|
+
} catch (err) {
|
|
820
|
+
if (surfaceRecordConflict(err, t, { onRefresh: loadData })) return;
|
|
821
|
+
const message = translateErrorMessage(err, t, "warranty_claims.detail.error.action");
|
|
822
|
+
flash(message, "error");
|
|
823
|
+
}
|
|
824
|
+
}, [claim, loadData, mutationContext, runMutation, t]);
|
|
825
|
+
const createSalesReturn = React.useCallback(async () => {
|
|
826
|
+
if (!claim) return;
|
|
827
|
+
const payload = { claimId: claim.id };
|
|
828
|
+
try {
|
|
829
|
+
const call = await runMutation({
|
|
830
|
+
operation: async () => {
|
|
831
|
+
const response = await withScopedApiRequestHeaders(
|
|
832
|
+
buildOptimisticLockHeader(claim.updatedAt),
|
|
833
|
+
() => apiCall("/api/warranty_claims/sales-return", {
|
|
834
|
+
method: "POST",
|
|
835
|
+
headers: { "content-type": "application/json" },
|
|
836
|
+
body: JSON.stringify(payload)
|
|
837
|
+
})
|
|
838
|
+
);
|
|
839
|
+
if (!response.ok) throw buildConflictError(response, t("warranty_claims.detail.error.action"), t);
|
|
840
|
+
return response;
|
|
841
|
+
},
|
|
842
|
+
context: mutationContext,
|
|
843
|
+
mutationPayload: payload
|
|
844
|
+
});
|
|
845
|
+
flash(t("warranty_claims.detail.createSalesReturnSuccess"), "success");
|
|
846
|
+
const skippedCount = call?.result?.skippedLineIds?.length ?? 0;
|
|
847
|
+
if (skippedCount > 0) {
|
|
848
|
+
flash(t("warranty_claims.detail.createSalesReturnSkipped", void 0, { count: skippedCount }), "info");
|
|
849
|
+
}
|
|
850
|
+
await loadData();
|
|
851
|
+
} catch (err) {
|
|
852
|
+
if (surfaceRecordConflict(err, t, { onRefresh: loadData })) return;
|
|
853
|
+
const message = translateErrorMessage(err, t, "warranty_claims.detail.error.action");
|
|
854
|
+
flash(message, "error");
|
|
855
|
+
}
|
|
856
|
+
}, [claim, loadData, mutationContext, runMutation, t]);
|
|
857
|
+
const createReplacementOrder = React.useCallback(async () => {
|
|
858
|
+
if (!claim) return;
|
|
859
|
+
const payload = { claimId: claim.id };
|
|
860
|
+
try {
|
|
861
|
+
const call = await runMutation({
|
|
862
|
+
operation: async () => {
|
|
863
|
+
const response = await withScopedApiRequestHeaders(
|
|
864
|
+
buildOptimisticLockHeader(claim.updatedAt),
|
|
865
|
+
() => apiCall("/api/warranty_claims/replacement-order", {
|
|
866
|
+
method: "POST",
|
|
867
|
+
headers: { "content-type": "application/json" },
|
|
868
|
+
body: JSON.stringify(payload)
|
|
869
|
+
})
|
|
870
|
+
);
|
|
871
|
+
if (!response.ok) throw buildConflictError(response, t("warranty_claims.detail.error.action"), t);
|
|
872
|
+
return response;
|
|
873
|
+
},
|
|
874
|
+
context: mutationContext,
|
|
875
|
+
mutationPayload: payload
|
|
876
|
+
});
|
|
877
|
+
flash(t("warranty_claims.detail.createReplacementOrderSuccess"), "success");
|
|
878
|
+
const skippedCount = call?.result?.skippedLineIds?.length ?? 0;
|
|
879
|
+
if (skippedCount > 0) {
|
|
880
|
+
flash(t("warranty_claims.detail.createReplacementOrderSkipped", void 0, { count: skippedCount }), "info");
|
|
881
|
+
}
|
|
882
|
+
await loadData();
|
|
883
|
+
} catch (err) {
|
|
884
|
+
if (surfaceRecordConflict(err, t, { onRefresh: loadData })) return;
|
|
885
|
+
const message = translateErrorMessage(err, t, "warranty_claims.detail.error.action");
|
|
886
|
+
flash(message, "error");
|
|
887
|
+
}
|
|
888
|
+
}, [claim, loadData, mutationContext, runMutation, t]);
|
|
889
|
+
const createCreditMemo = React.useCallback(async () => {
|
|
890
|
+
if (!claim) return;
|
|
891
|
+
const payload = { claimId: claim.id };
|
|
892
|
+
try {
|
|
893
|
+
const call = await runMutation({
|
|
894
|
+
operation: async () => {
|
|
895
|
+
const response = await withScopedApiRequestHeaders(
|
|
896
|
+
buildOptimisticLockHeader(claim.updatedAt),
|
|
897
|
+
() => apiCall("/api/warranty_claims/credit-memo", {
|
|
898
|
+
method: "POST",
|
|
899
|
+
headers: { "content-type": "application/json" },
|
|
900
|
+
body: JSON.stringify(payload)
|
|
901
|
+
})
|
|
902
|
+
);
|
|
903
|
+
if (!response.ok) throw buildConflictError(response, t("warranty_claims.detail.error.action"), t);
|
|
904
|
+
return response;
|
|
905
|
+
},
|
|
906
|
+
context: mutationContext,
|
|
907
|
+
mutationPayload: payload
|
|
908
|
+
});
|
|
909
|
+
flash(
|
|
910
|
+
t("warranty_claims.detail.createCreditMemoSuccess", void 0, {
|
|
911
|
+
amount: call?.result?.grandTotalGrossAmount ?? "",
|
|
912
|
+
currency: call?.result?.currencyCode ?? ""
|
|
913
|
+
}),
|
|
914
|
+
"success"
|
|
915
|
+
);
|
|
916
|
+
const skippedCount = call?.result?.skippedLineIds?.length ?? 0;
|
|
917
|
+
if (skippedCount > 0) {
|
|
918
|
+
flash(t("warranty_claims.detail.createCreditMemoSkipped", void 0, { count: skippedCount }), "info");
|
|
919
|
+
}
|
|
920
|
+
await loadData();
|
|
921
|
+
} catch (err) {
|
|
922
|
+
if (surfaceRecordConflict(err, t, { onRefresh: loadData })) return;
|
|
923
|
+
const message = translateErrorMessage(err, t, "warranty_claims.detail.error.action");
|
|
924
|
+
flash(message, "error");
|
|
925
|
+
}
|
|
926
|
+
}, [claim, loadData, mutationContext, runMutation, t]);
|
|
927
|
+
const performAssignment = React.useCallback(async (assigneeUserId) => {
|
|
928
|
+
if (!claim) return false;
|
|
929
|
+
const payload = { id: claim.id, assigneeUserId };
|
|
930
|
+
try {
|
|
931
|
+
await runMutation({
|
|
932
|
+
operation: async () => {
|
|
933
|
+
const call = await withScopedApiRequestHeaders(
|
|
934
|
+
buildOptimisticLockHeader(claim.updatedAt),
|
|
935
|
+
() => apiCall("/api/warranty_claims/assign", {
|
|
936
|
+
method: "POST",
|
|
937
|
+
headers: { "content-type": "application/json" },
|
|
938
|
+
body: JSON.stringify(payload)
|
|
939
|
+
})
|
|
940
|
+
);
|
|
941
|
+
if (!call.ok) throw buildConflictError(call, t("warranty_claims.detail.error.action"), t);
|
|
942
|
+
return call;
|
|
943
|
+
},
|
|
944
|
+
context: mutationContext,
|
|
945
|
+
mutationPayload: payload
|
|
946
|
+
});
|
|
947
|
+
flash(t("warranty_claims.list.flash.assigned"), "success");
|
|
948
|
+
await loadData();
|
|
949
|
+
return true;
|
|
950
|
+
} catch (err) {
|
|
951
|
+
if (surfaceRecordConflict(err, t, { onRefresh: loadData })) return false;
|
|
952
|
+
flash(translateErrorMessage(err, t, "warranty_claims.detail.error.action"), "error");
|
|
953
|
+
return false;
|
|
954
|
+
}
|
|
955
|
+
}, [claim, loadData, mutationContext, runMutation, t]);
|
|
956
|
+
const assignClaim = React.useCallback(async () => {
|
|
957
|
+
const assigneeUserId = selectedAssigneeUserId === UNASSIGNED_SELECT_VALUE ? null : selectedAssigneeUserId;
|
|
958
|
+
const success = await performAssignment(assigneeUserId);
|
|
959
|
+
if (success) setAssignDialogOpen(false);
|
|
960
|
+
}, [performAssignment, selectedAssigneeUserId]);
|
|
961
|
+
const assignToMe = React.useCallback(async () => {
|
|
962
|
+
if (!currentUserId) return;
|
|
963
|
+
await performAssignment(currentUserId);
|
|
964
|
+
}, [currentUserId, performAssignment]);
|
|
965
|
+
const loadAiSuggestion = React.useCallback(async () => {
|
|
966
|
+
if (!id) return;
|
|
967
|
+
setAiLoading(true);
|
|
968
|
+
try {
|
|
969
|
+
const suggestion = await readApiResultOrThrow(
|
|
970
|
+
`/api/warranty_claims/ai/suggest?claimId=${encodeURIComponent(id)}`,
|
|
971
|
+
void 0,
|
|
972
|
+
{ errorMessage: t("warranty_claims.detail.error.action") }
|
|
973
|
+
);
|
|
974
|
+
setAiSuggestion(suggestion);
|
|
975
|
+
setAppliedTriageLineIds(/* @__PURE__ */ new Set());
|
|
976
|
+
} catch (err) {
|
|
977
|
+
const message = translateErrorMessage(err, t, "warranty_claims.detail.error.action");
|
|
978
|
+
flash(message, "error");
|
|
979
|
+
} finally {
|
|
980
|
+
setAiLoading(false);
|
|
981
|
+
}
|
|
982
|
+
}, [id, t]);
|
|
983
|
+
const applyAiDisposition = React.useCallback(async (lineId, disposition) => {
|
|
984
|
+
if (!claim) return;
|
|
985
|
+
const line = lines.find((candidate) => candidate.id === lineId);
|
|
986
|
+
if (!line) return;
|
|
987
|
+
try {
|
|
988
|
+
await runMutation({
|
|
989
|
+
operation: () => withScopedApiRequestHeaders(
|
|
990
|
+
buildOptimisticLockHeader(line.updatedAt),
|
|
991
|
+
() => updateCrud("warranty_claims/lines", { id: lineId, claimId: claim.id, disposition }, {
|
|
992
|
+
errorMessage: t("warranty_claims.detail.lines.error.save")
|
|
993
|
+
})
|
|
994
|
+
),
|
|
995
|
+
context: mutationContext,
|
|
996
|
+
mutationPayload: { id: lineId, claimId: claim.id, disposition }
|
|
997
|
+
});
|
|
998
|
+
flash(t("warranty_claims.detail.lines.flash.saved"), "success");
|
|
999
|
+
setAppliedTriageLineIds((prev) => new Set(prev).add(lineId));
|
|
1000
|
+
await loadData();
|
|
1001
|
+
} catch (err) {
|
|
1002
|
+
if (surfaceRecordConflict(err, t, { onRefresh: loadData })) return;
|
|
1003
|
+
const message = translateErrorMessage(err, t, "warranty_claims.detail.error.action");
|
|
1004
|
+
flash(message, "error");
|
|
1005
|
+
}
|
|
1006
|
+
}, [claim, lines, loadData, mutationContext, runMutation, t]);
|
|
1007
|
+
const handleTransition = React.useCallback(async (toStatus, values) => {
|
|
1008
|
+
if (!claim) return;
|
|
1009
|
+
await runClaimPost(
|
|
1010
|
+
toStatus === "submitted" && currentStatus === "draft" ? "/api/warranty_claims/submit" : "/api/warranty_claims/transition",
|
|
1011
|
+
toStatus === "submitted" && currentStatus === "draft" ? { id: claim.id } : {
|
|
1012
|
+
id: claim.id,
|
|
1013
|
+
toStatus,
|
|
1014
|
+
rejectionReasonCode: nullableText(values?.rejectionReasonCode),
|
|
1015
|
+
resolutionSummary: nullableText(values?.resolutionSummary)
|
|
1016
|
+
},
|
|
1017
|
+
"warranty_claims.detail.flash.transitioned"
|
|
1018
|
+
);
|
|
1019
|
+
}, [claim, currentStatus, runClaimPost]);
|
|
1020
|
+
const generateSupplierRecovery = React.useCallback(async ({
|
|
1021
|
+
lineIds,
|
|
1022
|
+
vendorName
|
|
1023
|
+
}) => {
|
|
1024
|
+
if (!claim) return;
|
|
1025
|
+
if (!lineIds.length || !vendorName.trim()) {
|
|
1026
|
+
flash(t("warranty_claims.errors.vendorRecoveryNeedsResolvedLines"), "error");
|
|
1027
|
+
return;
|
|
1028
|
+
}
|
|
1029
|
+
await runClaimPost(
|
|
1030
|
+
"/api/warranty_claims/vendor-recovery",
|
|
1031
|
+
{
|
|
1032
|
+
claimId: claim.id,
|
|
1033
|
+
lineIds,
|
|
1034
|
+
vendorName: vendorName.trim(),
|
|
1035
|
+
vendorRef: null
|
|
1036
|
+
},
|
|
1037
|
+
"warranty_claims.detail.vendorRecovery.created"
|
|
1038
|
+
);
|
|
1039
|
+
}, [claim, runClaimPost, t]);
|
|
1040
|
+
const confirmAndTransition = React.useCallback(async (toStatus) => {
|
|
1041
|
+
if (!claim) return;
|
|
1042
|
+
if (toStatus === "rejected") {
|
|
1043
|
+
setTransitionDialog({ toStatus });
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
if (toStatus === "cancelled") {
|
|
1047
|
+
const confirmed = await confirm({
|
|
1048
|
+
title: t("warranty_claims.detail.confirm.cancelTitle"),
|
|
1049
|
+
variant: "destructive"
|
|
1050
|
+
});
|
|
1051
|
+
if (!confirmed) return;
|
|
1052
|
+
} else {
|
|
1053
|
+
const confirmed = await confirm({
|
|
1054
|
+
title: t("warranty_claims.detail.confirm.transitionTitle")
|
|
1055
|
+
});
|
|
1056
|
+
if (!confirmed) return;
|
|
1057
|
+
}
|
|
1058
|
+
await handleTransition(toStatus);
|
|
1059
|
+
}, [claim, confirm, handleTransition, t]);
|
|
1060
|
+
const deleteClaim = React.useCallback(async () => {
|
|
1061
|
+
if (!claim || !featureAccess.claimDelete || !DELETABLE_CLAIM_STATUSES.has(currentStatus)) return;
|
|
1062
|
+
const confirmed = await confirm({
|
|
1063
|
+
title: t("warranty_claims.audit.claim.delete"),
|
|
1064
|
+
variant: "destructive"
|
|
1065
|
+
});
|
|
1066
|
+
if (!confirmed) return;
|
|
1067
|
+
try {
|
|
1068
|
+
await runMutation({
|
|
1069
|
+
operation: () => withScopedApiRequestHeaders(
|
|
1070
|
+
buildOptimisticLockHeader(claim.updatedAt),
|
|
1071
|
+
() => deleteCrud("warranty_claims", claim.id, {
|
|
1072
|
+
errorMessage: t("warranty_claims.edit.error.delete")
|
|
1073
|
+
})
|
|
1074
|
+
),
|
|
1075
|
+
context: mutationContext,
|
|
1076
|
+
mutationPayload: { id: claim.id }
|
|
1077
|
+
});
|
|
1078
|
+
flash(t("warranty_claims.edit.deleted"), "success");
|
|
1079
|
+
router.push("/backend/warranty_claims");
|
|
1080
|
+
} catch (err) {
|
|
1081
|
+
if (surfaceRecordConflict(err, t, { onRefresh: loadData })) return;
|
|
1082
|
+
flash(translateErrorMessage(err, t, "warranty_claims.edit.error.delete"), "error");
|
|
1083
|
+
}
|
|
1084
|
+
}, [claim, confirm, currentStatus, featureAccess.claimDelete, loadData, mutationContext, router, runMutation, t]);
|
|
1085
|
+
const headerMoreActions = React.useMemo(() => {
|
|
1086
|
+
if (!claim) return [];
|
|
1087
|
+
const items = [
|
|
1088
|
+
...claimMutable ? [{
|
|
1089
|
+
id: "edit",
|
|
1090
|
+
label: t("warranty_claims.detail.actions.edit"),
|
|
1091
|
+
icon: Pencil,
|
|
1092
|
+
onSelect: () => router.push(`/backend/warranty_claims/${claim.id}/edit`)
|
|
1093
|
+
}] : [],
|
|
1094
|
+
{
|
|
1095
|
+
id: "copy-link",
|
|
1096
|
+
label: t("warranty_claims.detail.copyLink"),
|
|
1097
|
+
icon: Copy,
|
|
1098
|
+
onSelect: async () => {
|
|
1099
|
+
try {
|
|
1100
|
+
await navigator.clipboard.writeText(window.location.href);
|
|
1101
|
+
flash(t("warranty_claims.detail.linkCopied"), "success");
|
|
1102
|
+
} catch {
|
|
1103
|
+
flash(t("warranty_claims.detail.copyFailed", "Could not copy to the clipboard."), "error");
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
];
|
|
1108
|
+
if (claim.claimNumber) {
|
|
1109
|
+
items.push({
|
|
1110
|
+
id: "copy-number",
|
|
1111
|
+
label: t("warranty_claims.detail.copyClaimNumber", "Copy claim number"),
|
|
1112
|
+
icon: Hash,
|
|
1113
|
+
onSelect: async () => {
|
|
1114
|
+
try {
|
|
1115
|
+
await navigator.clipboard.writeText(claim.claimNumber ?? "");
|
|
1116
|
+
flash(t("warranty_claims.detail.claimNumberCopied", "Claim number copied."), "success");
|
|
1117
|
+
} catch {
|
|
1118
|
+
flash(t("warranty_claims.detail.copyFailed", "Could not copy to the clipboard."), "error");
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
if (claim.orderId) {
|
|
1124
|
+
items.push({
|
|
1125
|
+
id: "view-order",
|
|
1126
|
+
label: claim.orderNumber ?? t("warranty_claims.detail.viewOrder"),
|
|
1127
|
+
icon: Copy,
|
|
1128
|
+
onSelect: () => router.push(`/backend/sales/documents/${claim.orderId}`)
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
if (featureAccess.claimManage && claimActive) {
|
|
1132
|
+
items.push({
|
|
1133
|
+
id: "assign",
|
|
1134
|
+
label: t("warranty_claims.detail.reassign"),
|
|
1135
|
+
icon: UserRound,
|
|
1136
|
+
onSelect: openAssignDialog
|
|
1137
|
+
});
|
|
1138
|
+
if (currentUserId && claim.assigneeUserId !== currentUserId) {
|
|
1139
|
+
items.push({
|
|
1140
|
+
id: "assign-to-me",
|
|
1141
|
+
label: t("warranty_claims.detail.assignToMe"),
|
|
1142
|
+
icon: UserRound,
|
|
1143
|
+
onSelect: () => {
|
|
1144
|
+
void assignToMe();
|
|
1145
|
+
}
|
|
1146
|
+
});
|
|
1147
|
+
}
|
|
1148
|
+
if (claim.claimType !== "vendor_recovery" && eligibleVendorLines.length > 0) {
|
|
1149
|
+
items.push({
|
|
1150
|
+
id: "vendor-recovery",
|
|
1151
|
+
label: t("warranty_claims.detail.actions.vendorRecovery"),
|
|
1152
|
+
icon: RefreshCw,
|
|
1153
|
+
onSelect: () => setVendorDialogOpen(true)
|
|
1154
|
+
});
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
return items;
|
|
1158
|
+
}, [assignToMe, claim, claimActive, claimMutable, currentUserId, eligibleVendorLines.length, featureAccess.claimManage, openAssignDialog, router, t]);
|
|
1159
|
+
const submitComment = React.useCallback(async () => {
|
|
1160
|
+
if (!claim || !commentBody.trim()) return;
|
|
1161
|
+
try {
|
|
1162
|
+
await runMutation({
|
|
1163
|
+
operation: async () => {
|
|
1164
|
+
const call = await withScopedApiRequestHeaders(
|
|
1165
|
+
buildOptimisticLockHeader(claim.updatedAt),
|
|
1166
|
+
() => apiCall("/api/warranty_claims/events", {
|
|
1167
|
+
method: "POST",
|
|
1168
|
+
headers: { "content-type": "application/json" },
|
|
1169
|
+
body: JSON.stringify({
|
|
1170
|
+
claimId: claim.id,
|
|
1171
|
+
body: commentBody.trim(),
|
|
1172
|
+
visibility: commentVisibility
|
|
1173
|
+
})
|
|
1174
|
+
})
|
|
1175
|
+
);
|
|
1176
|
+
if (!call.ok) throw buildConflictError(call, t("warranty_claims.detail.error.action"), t);
|
|
1177
|
+
return call;
|
|
1178
|
+
},
|
|
1179
|
+
context: mutationContext,
|
|
1180
|
+
mutationPayload: {
|
|
1181
|
+
claimId: claim.id,
|
|
1182
|
+
body: commentBody.trim(),
|
|
1183
|
+
visibility: commentVisibility
|
|
1184
|
+
}
|
|
1185
|
+
});
|
|
1186
|
+
setCommentBody("");
|
|
1187
|
+
flash(t("warranty_claims.detail.flash.commentAdded"), "success");
|
|
1188
|
+
await loadData();
|
|
1189
|
+
} catch (err) {
|
|
1190
|
+
if (surfaceRecordConflict(err, t, { onRefresh: loadData })) return;
|
|
1191
|
+
const message = translateErrorMessage(err, t, "warranty_claims.detail.error.comment");
|
|
1192
|
+
flash(message, "error");
|
|
1193
|
+
}
|
|
1194
|
+
}, [claim, commentBody, commentVisibility, loadData, mutationContext, runMutation, t]);
|
|
1195
|
+
const draftReplyWithAi = React.useCallback(async () => {
|
|
1196
|
+
if (!claim) return;
|
|
1197
|
+
setDraftReplyLoading(true);
|
|
1198
|
+
try {
|
|
1199
|
+
const call = await runMutation({
|
|
1200
|
+
operation: async () => {
|
|
1201
|
+
const draftCall = await apiCall("/api/warranty_claims/ai/draft-reply", {
|
|
1202
|
+
method: "POST",
|
|
1203
|
+
headers: { "Content-Type": "application/json" },
|
|
1204
|
+
body: JSON.stringify({ claimId: claim.id })
|
|
1205
|
+
});
|
|
1206
|
+
if (isDraftReplyNotConfigured(draftCall.result)) return draftCall;
|
|
1207
|
+
if (!draftCall.ok) throw new Error(readErrorKey(draftCall.result) ?? "warranty_claims.ai.draftError");
|
|
1208
|
+
return draftCall;
|
|
1209
|
+
},
|
|
1210
|
+
context: mutationContext,
|
|
1211
|
+
mutationPayload: { claimId: claim.id }
|
|
1212
|
+
});
|
|
1213
|
+
if (isDraftReplyNotConfigured(call.result)) {
|
|
1214
|
+
setDraftReplyHidden(true);
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
const draft = readDraftReply(call.result);
|
|
1218
|
+
if (!draft) {
|
|
1219
|
+
flash(t("warranty_claims.ai.draftError"), "error");
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
setCommentBody(draft);
|
|
1223
|
+
setCommentVisibility("customer");
|
|
1224
|
+
} catch (err) {
|
|
1225
|
+
flash(translateErrorMessage(err, t, "warranty_claims.ai.draftError"), "error");
|
|
1226
|
+
} finally {
|
|
1227
|
+
setDraftReplyLoading(false);
|
|
1228
|
+
}
|
|
1229
|
+
}, [claim, mutationContext, runMutation, t]);
|
|
1230
|
+
const saveLineInlineField = React.useCallback(async (line, field, value) => {
|
|
1231
|
+
if (!claim) return;
|
|
1232
|
+
const payload = { id: line.id, claimId: claim.id, [field]: value };
|
|
1233
|
+
try {
|
|
1234
|
+
await runMutation({
|
|
1235
|
+
operation: () => withScopedApiRequestHeaders(
|
|
1236
|
+
buildOptimisticLockHeader(line.updatedAt),
|
|
1237
|
+
() => updateCrud("warranty_claims/lines", payload, {
|
|
1238
|
+
errorMessage: t("warranty_claims.detail.lines.error.save")
|
|
1239
|
+
})
|
|
1240
|
+
),
|
|
1241
|
+
context: mutationContext,
|
|
1242
|
+
mutationPayload: payload
|
|
1243
|
+
});
|
|
1244
|
+
flash(t("warranty_claims.detail.lines.flash.saved"), "success");
|
|
1245
|
+
await loadData();
|
|
1246
|
+
} catch (err) {
|
|
1247
|
+
if (surfaceRecordConflict(err, t, { onRefresh: loadData })) return;
|
|
1248
|
+
flash(translateErrorMessage(err, t, "warranty_claims.detail.lines.error.save"), "error");
|
|
1249
|
+
}
|
|
1250
|
+
}, [claim, loadData, mutationContext, runMutation, t]);
|
|
1251
|
+
const lineFields = React.useMemo(() => [
|
|
1252
|
+
{
|
|
1253
|
+
id: "productLookup",
|
|
1254
|
+
label: t("warranty_claims.form.productLookup"),
|
|
1255
|
+
type: "custom",
|
|
1256
|
+
layout: "full",
|
|
1257
|
+
component: ({ values, setFormValue }) => /* @__PURE__ */ jsx(
|
|
1258
|
+
ClaimLineProductPicker,
|
|
1259
|
+
{
|
|
1260
|
+
value: {
|
|
1261
|
+
productId: nullableText(values?.productId),
|
|
1262
|
+
variantId: nullableText(values?.variantId),
|
|
1263
|
+
productName: nullableText(values?.productName),
|
|
1264
|
+
sku: nullableText(values?.sku)
|
|
1265
|
+
},
|
|
1266
|
+
onPick: (pick) => {
|
|
1267
|
+
setFormValue?.("productId", pick.productId);
|
|
1268
|
+
setFormValue?.("variantId", pick.variantId);
|
|
1269
|
+
setFormValue?.("sku", pick.sku);
|
|
1270
|
+
setFormValue?.("productName", pick.productName);
|
|
1271
|
+
},
|
|
1272
|
+
onClear: () => {
|
|
1273
|
+
setFormValue?.("productId", null);
|
|
1274
|
+
setFormValue?.("variantId", null);
|
|
1275
|
+
},
|
|
1276
|
+
hideLabel: true
|
|
1277
|
+
}
|
|
1278
|
+
)
|
|
1279
|
+
},
|
|
1280
|
+
{ id: "productName", label: t("warranty_claims.form.productName"), type: "text", layout: "half" },
|
|
1281
|
+
{ id: "sku", label: t("warranty_claims.form.sku"), type: "text", layout: "half" },
|
|
1282
|
+
{ id: "serialNumber", label: t("warranty_claims.form.serialNumber"), type: "text", layout: "half" },
|
|
1283
|
+
{ id: "purchaseDate", label: t("warranty_claims.form.purchaseDate"), type: "date", layout: "half" },
|
|
1284
|
+
{ id: "warrantyMonths", label: t("warranty_claims.form.warrantyMonths"), type: "number", layout: "half" },
|
|
1285
|
+
{
|
|
1286
|
+
id: "entitlementPreview",
|
|
1287
|
+
label: t("warranty_claims.form.entitlement"),
|
|
1288
|
+
type: "custom",
|
|
1289
|
+
layout: "half",
|
|
1290
|
+
component: ({ values }) => {
|
|
1291
|
+
const purchaseDateText = nullableText(values?.purchaseDate);
|
|
1292
|
+
const purchaseDate = purchaseDateText ? new Date(purchaseDateText) : null;
|
|
1293
|
+
const monthsValue = Number(values?.warrantyMonths);
|
|
1294
|
+
const months = Number.isFinite(monthsValue) && String(values?.warrantyMonths ?? "").trim() !== "" ? monthsValue : null;
|
|
1295
|
+
return /* @__PURE__ */ jsx(EntitlementChip, { status: computeEntitlementPreview(purchaseDate, months), t });
|
|
1296
|
+
}
|
|
1297
|
+
},
|
|
1298
|
+
{
|
|
1299
|
+
id: "faultCode",
|
|
1300
|
+
label: t("warranty_claims.form.faultCode"),
|
|
1301
|
+
type: "select",
|
|
1302
|
+
loadOptions: () => loadDictionaryOptions(DICTIONARY_KEYS.faultCodes, "fault"),
|
|
1303
|
+
layout: "half"
|
|
1304
|
+
},
|
|
1305
|
+
{ id: "faultDescription", label: t("warranty_claims.form.faultDescription"), type: "textarea", rows: 3, layout: "full" },
|
|
1306
|
+
{ id: "qtyClaimed", label: t("warranty_claims.form.qtyClaimed"), type: "number", layout: "third" },
|
|
1307
|
+
{ id: "qtyApproved", label: t("warranty_claims.form.qtyApproved"), type: "number", layout: "third" },
|
|
1308
|
+
{ id: "qtyReceived", label: t("warranty_claims.form.qtyReceived"), type: "number", layout: "third" },
|
|
1309
|
+
{
|
|
1310
|
+
id: "lineStatus",
|
|
1311
|
+
label: t("warranty_claims.form.lineStatus"),
|
|
1312
|
+
type: "select",
|
|
1313
|
+
options: CLAIM_LINE_STATUSES.map((status) => ({ value: status, label: t(`warranty_claims.lineStatus.${status}`) })),
|
|
1314
|
+
layout: "half"
|
|
1315
|
+
},
|
|
1316
|
+
{
|
|
1317
|
+
id: "disposition",
|
|
1318
|
+
label: t("warranty_claims.form.disposition"),
|
|
1319
|
+
type: "select",
|
|
1320
|
+
options: buildDispositionOptions(allowedDispositions, currentLineDisposition, t),
|
|
1321
|
+
layout: "half"
|
|
1322
|
+
},
|
|
1323
|
+
{ id: "creditAmount", label: t("warranty_claims.form.creditAmount"), type: "number", layout: "third" },
|
|
1324
|
+
{ id: "restockingFee", label: t("warranty_claims.form.restockingFee"), type: "number", layout: "third" },
|
|
1325
|
+
{ id: "coreChargeAmount", label: t("warranty_claims.form.coreChargeAmount"), type: "number", layout: "third" },
|
|
1326
|
+
{ id: "coreCreditAmount", label: t("warranty_claims.form.coreCreditAmount"), type: "number", layout: "third" },
|
|
1327
|
+
{ id: "conditionOnReceipt", label: t("warranty_claims.form.conditionOnReceipt"), type: "textarea", rows: 3, layout: "full" },
|
|
1328
|
+
{ id: "inspectionNotes", label: t("warranty_claims.form.inspectionNotes"), type: "textarea", rows: 3, layout: "full" }
|
|
1329
|
+
], [allowedDispositions, currentLineDisposition, loadDictionaryOptions, t]);
|
|
1330
|
+
const lineGroups = React.useMemo(() => [
|
|
1331
|
+
{
|
|
1332
|
+
id: "line-main",
|
|
1333
|
+
title: t(resolveClaimTypeUiConfig(claim?.claimType).lineHeaderKey),
|
|
1334
|
+
fields: [
|
|
1335
|
+
"productLookup",
|
|
1336
|
+
"productName",
|
|
1337
|
+
"sku",
|
|
1338
|
+
"serialNumber",
|
|
1339
|
+
"purchaseDate",
|
|
1340
|
+
"warrantyMonths",
|
|
1341
|
+
"entitlementPreview",
|
|
1342
|
+
"faultCode",
|
|
1343
|
+
"faultDescription",
|
|
1344
|
+
"qtyClaimed",
|
|
1345
|
+
"qtyApproved",
|
|
1346
|
+
"qtyReceived",
|
|
1347
|
+
"lineStatus",
|
|
1348
|
+
"disposition"
|
|
1349
|
+
]
|
|
1350
|
+
},
|
|
1351
|
+
{
|
|
1352
|
+
id: "line-money",
|
|
1353
|
+
title: t("warranty_claims.detail.lines.amounts"),
|
|
1354
|
+
// Restock / core fields belong only to return-family claims; warranty & vendor-recovery
|
|
1355
|
+
// settle on the credit amount alone (LINE-05).
|
|
1356
|
+
fields: claimTypeAllowsLineFinancialAdjustments(claim?.claimType) ? ["creditAmount", "restockingFee", "coreChargeAmount", "coreCreditAmount"] : ["creditAmount"]
|
|
1357
|
+
},
|
|
1358
|
+
{
|
|
1359
|
+
id: "line-inspection",
|
|
1360
|
+
title: t("warranty_claims.detail.lines.inspection"),
|
|
1361
|
+
fields: ["conditionOnReceipt", "inspectionNotes"]
|
|
1362
|
+
}
|
|
1363
|
+
], [claim?.claimType, t]);
|
|
1364
|
+
const lineColumns = React.useMemo(() => [
|
|
1365
|
+
{
|
|
1366
|
+
accessorKey: "lineNo",
|
|
1367
|
+
header: t("warranty_claims.detail.lines.column.number"),
|
|
1368
|
+
cell: ({ row }) => /* @__PURE__ */ jsx("span", { className: "font-mono text-xs", children: row.original.lineNo ?? noValue })
|
|
1369
|
+
},
|
|
1370
|
+
{
|
|
1371
|
+
accessorKey: "lineStatus",
|
|
1372
|
+
header: t("warranty_claims.detail.lines.column.status"),
|
|
1373
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(
|
|
1374
|
+
InlineLineSelectCell,
|
|
1375
|
+
{
|
|
1376
|
+
line: row.original,
|
|
1377
|
+
field: "lineStatus",
|
|
1378
|
+
value: row.original.lineStatus,
|
|
1379
|
+
label: t("warranty_claims.form.lineStatus"),
|
|
1380
|
+
options: buildLineStatusOptions(row.original.lineStatus, t),
|
|
1381
|
+
disabled: !linesInlineEditable,
|
|
1382
|
+
onSave: saveLineInlineField
|
|
1383
|
+
}
|
|
1384
|
+
)
|
|
1385
|
+
},
|
|
1386
|
+
{
|
|
1387
|
+
accessorKey: "productName",
|
|
1388
|
+
header: t("warranty_claims.detail.lines.column.product"),
|
|
1389
|
+
cell: ({ row }) => /* @__PURE__ */ jsxs("div", { className: "max-w-80 space-y-0.5", children: [
|
|
1390
|
+
/* @__PURE__ */ jsx("div", { className: "truncate font-medium", title: row.original.productName ?? void 0, children: row.original.productName ?? noValue }),
|
|
1391
|
+
/* @__PURE__ */ jsx("div", { className: "truncate text-xs text-muted-foreground", children: [row.original.sku, row.original.serialNumber].filter(Boolean).join(" / ") || noValue })
|
|
1392
|
+
] })
|
|
1393
|
+
},
|
|
1394
|
+
{
|
|
1395
|
+
id: "entitlement",
|
|
1396
|
+
header: t("warranty_claims.detail.lines.column.entitlement"),
|
|
1397
|
+
cell: ({ row }) => {
|
|
1398
|
+
const purchaseDate = row.original.purchaseDate ? new Date(row.original.purchaseDate) : null;
|
|
1399
|
+
return /* @__PURE__ */ jsx(
|
|
1400
|
+
EntitlementChip,
|
|
1401
|
+
{
|
|
1402
|
+
status: computeEntitlementPreview(purchaseDate, row.original.warrantyMonths),
|
|
1403
|
+
t
|
|
1404
|
+
}
|
|
1405
|
+
);
|
|
1406
|
+
}
|
|
1407
|
+
},
|
|
1408
|
+
{
|
|
1409
|
+
accessorKey: "qtyClaimed",
|
|
1410
|
+
header: t("warranty_claims.lines.header.qtyClaimed"),
|
|
1411
|
+
cell: ({ row }) => formatQuantity(row.original.qtyClaimed, noValue)
|
|
1412
|
+
},
|
|
1413
|
+
{
|
|
1414
|
+
accessorKey: "qtyApproved",
|
|
1415
|
+
header: t("warranty_claims.lines.header.qtyApproved"),
|
|
1416
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(
|
|
1417
|
+
InlineQtyApprovedCell,
|
|
1418
|
+
{
|
|
1419
|
+
line: row.original,
|
|
1420
|
+
disabled: !linesInlineEditable,
|
|
1421
|
+
label: t("warranty_claims.form.qtyApproved"),
|
|
1422
|
+
onSave: saveLineInlineField
|
|
1423
|
+
}
|
|
1424
|
+
)
|
|
1425
|
+
},
|
|
1426
|
+
{
|
|
1427
|
+
accessorKey: "disposition",
|
|
1428
|
+
header: t("warranty_claims.form.disposition"),
|
|
1429
|
+
cell: ({ row }) => /* @__PURE__ */ jsx(
|
|
1430
|
+
InlineLineSelectCell,
|
|
1431
|
+
{
|
|
1432
|
+
line: row.original,
|
|
1433
|
+
field: "disposition",
|
|
1434
|
+
value: row.original.disposition,
|
|
1435
|
+
label: t("warranty_claims.form.disposition"),
|
|
1436
|
+
emptyLabel: noValue,
|
|
1437
|
+
options: buildDispositionOptions(allowedDispositions, row.original.disposition, t),
|
|
1438
|
+
disabled: !linesInlineEditable,
|
|
1439
|
+
onSave: saveLineInlineField
|
|
1440
|
+
}
|
|
1441
|
+
)
|
|
1442
|
+
},
|
|
1443
|
+
{
|
|
1444
|
+
accessorKey: "creditAmount",
|
|
1445
|
+
header: t("warranty_claims.detail.lines.column.credit"),
|
|
1446
|
+
cell: ({ row }) => formatAmount(row.original.creditAmount, claim?.currencyCode ?? null, noValue)
|
|
1447
|
+
}
|
|
1448
|
+
], [allowedDispositions, claim?.currencyCode, linesInlineEditable, noValue, saveLineInlineField, t]);
|
|
1449
|
+
const transitionFields = React.useMemo(() => [
|
|
1450
|
+
{
|
|
1451
|
+
id: "rejectionReasonCode",
|
|
1452
|
+
label: t("warranty_claims.form.rejectionReasonCode"),
|
|
1453
|
+
type: "select",
|
|
1454
|
+
required: true,
|
|
1455
|
+
loadOptions: () => loadDictionaryOptions(DICTIONARY_KEYS.rejectionReasons, "rejection")
|
|
1456
|
+
},
|
|
1457
|
+
{
|
|
1458
|
+
id: "resolutionSummary",
|
|
1459
|
+
label: t("warranty_claims.form.resolutionSummary"),
|
|
1460
|
+
type: "textarea",
|
|
1461
|
+
rows: 3,
|
|
1462
|
+
layout: "full"
|
|
1463
|
+
}
|
|
1464
|
+
], [loadDictionaryOptions, t]);
|
|
1465
|
+
const vendorFields = React.useMemo(() => [
|
|
1466
|
+
{
|
|
1467
|
+
id: "lineIds",
|
|
1468
|
+
label: t("warranty_claims.detail.vendorRecovery.lines"),
|
|
1469
|
+
type: "select",
|
|
1470
|
+
multiple: true,
|
|
1471
|
+
required: true,
|
|
1472
|
+
options: eligibleVendorLines.map((line) => ({
|
|
1473
|
+
value: line.id,
|
|
1474
|
+
label: [
|
|
1475
|
+
t("warranty_claims.form.lines.lineLabel", "Line {number}", { number: line.lineNo ?? "?" }),
|
|
1476
|
+
line.productName ?? line.sku
|
|
1477
|
+
].filter(Boolean).join(" \u2014 ")
|
|
1478
|
+
}))
|
|
1479
|
+
},
|
|
1480
|
+
{ id: "vendorName", label: t("warranty_claims.form.vendorName"), type: "text", required: true },
|
|
1481
|
+
{ id: "vendorRef", label: t("warranty_claims.form.vendorRef"), type: "text" }
|
|
1482
|
+
], [eligibleVendorLines, t]);
|
|
1483
|
+
if (loading) {
|
|
1484
|
+
return /* @__PURE__ */ jsx(Page, { children: /* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsx(LoadingMessage, { label: t("warranty_claims.detail.loading") }) }) });
|
|
1485
|
+
}
|
|
1486
|
+
if (notFound) {
|
|
1487
|
+
return /* @__PURE__ */ jsx(Page, { children: /* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsx(
|
|
1488
|
+
RecordNotFoundState,
|
|
1489
|
+
{
|
|
1490
|
+
label: t("warranty_claims.errors.notFound"),
|
|
1491
|
+
backHref: "/backend/warranty_claims",
|
|
1492
|
+
backLabel: t("warranty_claims.detail.actions.backToList")
|
|
1493
|
+
}
|
|
1494
|
+
) }) });
|
|
1495
|
+
}
|
|
1496
|
+
if (error || !claim) {
|
|
1497
|
+
return /* @__PURE__ */ jsx(Page, { children: /* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsx(
|
|
1498
|
+
ErrorMessage,
|
|
1499
|
+
{
|
|
1500
|
+
label: error ?? t("warranty_claims.errors.notFound"),
|
|
1501
|
+
action: /* @__PURE__ */ jsx(Button, { asChild: true, variant: "outline", size: "sm", children: /* @__PURE__ */ jsx(Link, { href: "/backend/warranty_claims", children: t("warranty_claims.detail.actions.backToList") }) })
|
|
1502
|
+
}
|
|
1503
|
+
) }) });
|
|
1504
|
+
}
|
|
1505
|
+
const tabs = [
|
|
1506
|
+
{ id: "lines", label: t("warranty_claims.detail.tabs.lines"), count: lines.length },
|
|
1507
|
+
{ id: "timeline", label: t("warranty_claims.detail.tabs.timeline"), count: events.length },
|
|
1508
|
+
{ id: "attachments", label: t("warranty_claims.detail.tabs.attachments"), count: attachmentCount },
|
|
1509
|
+
{ id: "ai", label: t("warranty_claims.detail.tabs.ai") }
|
|
1510
|
+
];
|
|
1511
|
+
const approvedLineCount = lines.filter((line) => line.lineStatus === "approved").length;
|
|
1512
|
+
return /* @__PURE__ */ jsxs(Page, { children: [
|
|
1513
|
+
/* @__PURE__ */ jsx(PageBody, { children: /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
1514
|
+
/* @__PURE__ */ jsxs("div", { className: "overflow-hidden rounded-xl border border-border bg-card", children: [
|
|
1515
|
+
/* @__PURE__ */ jsxs("div", { className: "px-8 pb-5 pt-5", children: [
|
|
1516
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [
|
|
1517
|
+
/* @__PURE__ */ jsxs("div", { className: "inline-flex items-center rounded-md border border-border bg-background px-2.5 py-1 text-xs text-muted-foreground", children: [
|
|
1518
|
+
t(`warranty_claims.claimType.${claim.claimType ?? "warranty"}`),
|
|
1519
|
+
/* @__PURE__ */ jsx("span", { className: "ml-1 font-semibold text-foreground", children: claim.claimNumber ?? t("warranty_claims.detail.unnumbered", "Unnumbered claim") })
|
|
1520
|
+
] }),
|
|
1521
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1522
|
+
featureAccess.claimDelete ? /* @__PURE__ */ jsx(
|
|
1523
|
+
IconButton,
|
|
1524
|
+
{
|
|
1525
|
+
type: "button",
|
|
1526
|
+
variant: "outline",
|
|
1527
|
+
size: "default",
|
|
1528
|
+
className: "border-destructive/30 text-destructive hover:bg-destructive/10 hover:text-destructive",
|
|
1529
|
+
disabled: !DELETABLE_CLAIM_STATUSES.has(currentStatus),
|
|
1530
|
+
"aria-label": t("warranty_claims.audit.claim.delete"),
|
|
1531
|
+
title: DELETABLE_CLAIM_STATUSES.has(currentStatus) ? t("warranty_claims.audit.claim.delete") : t("warranty_claims.errors.deleteNotAllowed"),
|
|
1532
|
+
onClick: () => {
|
|
1533
|
+
void deleteClaim();
|
|
1534
|
+
},
|
|
1535
|
+
children: /* @__PURE__ */ jsx(Trash2, { className: "size-4", "aria-hidden": true })
|
|
1536
|
+
}
|
|
1537
|
+
) : null,
|
|
1538
|
+
/* @__PURE__ */ jsx(
|
|
1539
|
+
ActionsDropdown,
|
|
1540
|
+
{
|
|
1541
|
+
items: headerMoreActions,
|
|
1542
|
+
triggerMode: "icon",
|
|
1543
|
+
ariaLabel: t("ui.actions.actions", "Actions")
|
|
1544
|
+
}
|
|
1545
|
+
),
|
|
1546
|
+
/* @__PURE__ */ jsxs(
|
|
1547
|
+
Select,
|
|
1548
|
+
{
|
|
1549
|
+
value: "",
|
|
1550
|
+
disabled: !featureAccess.claimManage || resolutionStatuses.length === 0,
|
|
1551
|
+
onValueChange: (status) => {
|
|
1552
|
+
void confirmAndTransition(status);
|
|
1553
|
+
},
|
|
1554
|
+
children: [
|
|
1555
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-8 w-28", "aria-label": t("warranty_claims.edit.fulfillment.resolution"), children: /* @__PURE__ */ jsx(SelectValue, { placeholder: t("warranty_claims.edit.fulfillment.resolution") }) }),
|
|
1556
|
+
/* @__PURE__ */ jsx(SelectContent, { children: resolutionStatuses.map((status) => /* @__PURE__ */ jsx(SelectItem, { value: status, children: t(`warranty_claims.status.${status}`) }, status)) })
|
|
1557
|
+
]
|
|
1558
|
+
}
|
|
1559
|
+
),
|
|
1560
|
+
featureAccess.claimManage && primaryNextStatus ? /* @__PURE__ */ jsx(
|
|
1561
|
+
Button,
|
|
1562
|
+
{
|
|
1563
|
+
type: "button",
|
|
1564
|
+
size: "sm",
|
|
1565
|
+
onClick: () => {
|
|
1566
|
+
void confirmAndTransition(primaryNextStatus);
|
|
1567
|
+
},
|
|
1568
|
+
children: primaryNextStatus === "submitted" && currentStatus === "draft" ? t("warranty_claims.detail.actions.submit") : primaryNextStatus === "in_review" && currentStatus === "submitted" ? t("warranty_claims.list.actions.startReview") : t(`warranty_claims.status.${primaryNextStatus}`)
|
|
1569
|
+
}
|
|
1570
|
+
) : null
|
|
1571
|
+
] })
|
|
1572
|
+
] }),
|
|
1573
|
+
/* @__PURE__ */ jsx("h1", { className: "mt-3 max-w-3xl text-2xl font-bold tracking-tight text-foreground", children: claim.notes || claim.reasonCode || claim.claimNumber || t("warranty_claims.detail.unnumbered", "Unnumbered claim") }),
|
|
1574
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-3 grid gap-4 sm:grid-cols-2 xl:max-w-4xl xl:grid-cols-6", children: [
|
|
1575
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1576
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("warranty_claims.detail.customer") }),
|
|
1577
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1 text-sm font-medium text-foreground", children: /* @__PURE__ */ jsx("span", { children: claim.customerName ? customerLink && customerLink.customerId === claim.customerId ? /* @__PURE__ */ jsx(
|
|
1578
|
+
Link,
|
|
1579
|
+
{
|
|
1580
|
+
href: customerLink.href,
|
|
1581
|
+
className: "text-foreground underline-offset-4 hover:underline",
|
|
1582
|
+
children: claim.customerName
|
|
1583
|
+
}
|
|
1584
|
+
) : claim.customerName : noValue }) })
|
|
1585
|
+
] }),
|
|
1586
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1587
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("warranty_claims.detail.priority", "Priority") }),
|
|
1588
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 text-sm font-medium text-foreground", children: t(`warranty_claims.priority.${claim.priority ?? "normal"}`) })
|
|
1589
|
+
] }),
|
|
1590
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1591
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("warranty_claims.detail.opened") }),
|
|
1592
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 text-sm font-medium text-foreground", title: formatDateTime(claim.createdAt) ?? void 0, children: formatRelativeTime(claim.createdAt, { locale }) ?? noValue })
|
|
1593
|
+
] }),
|
|
1594
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1595
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("warranty_claims.list.column.slaDueAt") }),
|
|
1596
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1 flex flex-wrap items-center gap-2 text-sm", children: /* @__PURE__ */ jsx(
|
|
1597
|
+
ClaimSlaIndicator,
|
|
1598
|
+
{
|
|
1599
|
+
slaDueAt: claim.slaDueAt,
|
|
1600
|
+
slaPausedAt: claim.slaPausedAt,
|
|
1601
|
+
submittedAt: claim.submittedAt,
|
|
1602
|
+
status: claim.status,
|
|
1603
|
+
atRiskThresholdPct: slaAtRiskThresholdPct
|
|
1604
|
+
}
|
|
1605
|
+
) })
|
|
1606
|
+
] }),
|
|
1607
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1608
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("warranty_claims.detail.owner") }),
|
|
1609
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 truncate text-sm font-medium text-foreground", title: assigneeDisplayName, children: assigneeDisplayName })
|
|
1610
|
+
] }),
|
|
1611
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1612
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("warranty_claims.detail.state") }),
|
|
1613
|
+
/* @__PURE__ */ jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsx(ClaimStatusBadge, { status: claim.status }) })
|
|
1614
|
+
] })
|
|
1615
|
+
] }),
|
|
1616
|
+
riskSignals.length > 0 ? /* @__PURE__ */ jsx("div", { className: "mt-3 flex flex-wrap items-center gap-2 xl:max-w-4xl", "data-testid": "warranty-claim-risk-signals", children: /* @__PURE__ */ jsx(RiskSignalChips, { signals: riskSignals, t }) }) : null
|
|
1617
|
+
] }),
|
|
1618
|
+
/* @__PURE__ */ jsx(ClaimStageProgress, { status: claim.status }),
|
|
1619
|
+
/* @__PURE__ */ jsxs(
|
|
1620
|
+
Tabs,
|
|
1621
|
+
{
|
|
1622
|
+
value: activeTab,
|
|
1623
|
+
onValueChange: (value) => setActiveTab(value),
|
|
1624
|
+
variant: "underline",
|
|
1625
|
+
children: [
|
|
1626
|
+
/* @__PURE__ */ jsx(TabsList, { className: "h-auto w-full flex-wrap gap-1 px-7", "aria-label": t("warranty_claims.detail.tabs.label", "Claim sections"), children: tabs.map((tab) => /* @__PURE__ */ jsx(
|
|
1627
|
+
TabsTrigger,
|
|
1628
|
+
{
|
|
1629
|
+
value: tab.id,
|
|
1630
|
+
count: tab.count,
|
|
1631
|
+
"data-tab-id": tab.id,
|
|
1632
|
+
className: "px-4 pb-2 pt-3",
|
|
1633
|
+
children: tab.label
|
|
1634
|
+
},
|
|
1635
|
+
tab.id
|
|
1636
|
+
)) }),
|
|
1637
|
+
/* @__PURE__ */ jsx(TabsContent, { value: "lines", className: "mt-0", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
1638
|
+
/* @__PURE__ */ jsxs("div", { className: "grid items-center gap-4 border-b border-border px-8 py-5 sm:grid-cols-2 xl:grid-cols-[repeat(3,minmax(0,1fr))_auto]", children: [
|
|
1639
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
1640
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("warranty_claims.detail.totalClaimed") }),
|
|
1641
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 text-base font-semibold text-foreground", children: formatAmount(claim.totalClaimedAmount, claim.currencyCode, noValue) }),
|
|
1642
|
+
/* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-muted-foreground", children: t("warranty_claims.detail.lines.count", { count: lines.length }) })
|
|
1643
|
+
] }),
|
|
1644
|
+
/* @__PURE__ */ jsxs("div", { className: "xl:border-l xl:border-border xl:pl-5", children: [
|
|
1645
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("warranty_claims.detail.totalApproved") }),
|
|
1646
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 text-base font-semibold text-foreground", children: formatAmount(claim.totalApprovedAmount, claim.currencyCode, noValue) }),
|
|
1647
|
+
/* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-muted-foreground", children: t("warranty_claims.detail.lines.approvedCount", { count: approvedLineCount }) })
|
|
1648
|
+
] }),
|
|
1649
|
+
/* @__PURE__ */ jsxs("div", { className: "xl:border-l xl:border-border xl:pl-5", children: [
|
|
1650
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("warranty_claims.detail.totalRecovered") }),
|
|
1651
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 text-base font-semibold text-foreground", children: formatAmount(claim.totalRecoveredAmount, claim.currencyCode, noValue) }),
|
|
1652
|
+
/* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-muted-foreground", children: claim.vendorName ?? t("warranty_claims.detail.lines.noVendorClaims") })
|
|
1653
|
+
] }),
|
|
1654
|
+
linesInlineEditable ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", size: "sm", className: "justify-self-start xl:justify-self-end", onClick: () => setLineDialog({ mode: "create" }), children: t("warranty_claims.detail.lines.add") }) : null
|
|
1655
|
+
] }),
|
|
1656
|
+
/* @__PURE__ */ jsx("div", { className: "pb-3", children: /* @__PURE__ */ jsx(
|
|
1657
|
+
DataTable,
|
|
1658
|
+
{
|
|
1659
|
+
embedded: true,
|
|
1660
|
+
columns: lineColumns,
|
|
1661
|
+
data: lines,
|
|
1662
|
+
stickyActionsColumn: true,
|
|
1663
|
+
emptyState: /* @__PURE__ */ jsx(
|
|
1664
|
+
EmptyState,
|
|
1665
|
+
{
|
|
1666
|
+
title: t("warranty_claims.detail.lines.empty.title"),
|
|
1667
|
+
description: t("warranty_claims.detail.lines.empty.description"),
|
|
1668
|
+
variant: "subtle"
|
|
1669
|
+
}
|
|
1670
|
+
),
|
|
1671
|
+
rowActions: linesInlineEditable ? (line) => /* @__PURE__ */ jsx(
|
|
1672
|
+
RowActions,
|
|
1673
|
+
{
|
|
1674
|
+
items: [
|
|
1675
|
+
{
|
|
1676
|
+
id: "edit",
|
|
1677
|
+
label: t("warranty_claims.detail.lines.edit"),
|
|
1678
|
+
onSelect: () => setLineDialog({ mode: "edit", line })
|
|
1679
|
+
}
|
|
1680
|
+
]
|
|
1681
|
+
}
|
|
1682
|
+
) : void 0
|
|
1683
|
+
}
|
|
1684
|
+
) }),
|
|
1685
|
+
/* @__PURE__ */ jsx("div", { className: "px-8 pb-8", children: /* @__PURE__ */ jsx(
|
|
1686
|
+
ReceivingPanel,
|
|
1687
|
+
{
|
|
1688
|
+
claimId: claim.id,
|
|
1689
|
+
lines,
|
|
1690
|
+
canManage: featureAccess.receivingManage,
|
|
1691
|
+
receivingCapable: RECEIVING_CAPABLE_CLAIM_STATUSES.has(currentStatus),
|
|
1692
|
+
onRefresh: loadData
|
|
1693
|
+
}
|
|
1694
|
+
) })
|
|
1695
|
+
] }) }),
|
|
1696
|
+
/* @__PURE__ */ jsx(TabsContent, { value: "timeline", className: "mt-0", children: /* @__PURE__ */ jsxs("div", { className: "mx-8 max-w-3xl space-y-5 pb-8 pt-6", children: [
|
|
1697
|
+
featureAccess.claimManage ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
1698
|
+
/* @__PURE__ */ jsx(
|
|
1699
|
+
Textarea,
|
|
1700
|
+
{
|
|
1701
|
+
value: commentBody,
|
|
1702
|
+
onChange: (event) => setCommentBody(event.target.value),
|
|
1703
|
+
onKeyDown: (event) => {
|
|
1704
|
+
if ((event.metaKey || event.ctrlKey) && event.key === "Enter") {
|
|
1705
|
+
event.preventDefault();
|
|
1706
|
+
void submitComment();
|
|
1707
|
+
}
|
|
1708
|
+
},
|
|
1709
|
+
placeholder: t("warranty_claims.detail.timeline.commentPlaceholder"),
|
|
1710
|
+
rows: 6
|
|
1711
|
+
}
|
|
1712
|
+
),
|
|
1713
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [
|
|
1714
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1715
|
+
/* @__PURE__ */ jsxs(Select, { value: commentVisibility, onValueChange: (next) => setCommentVisibility(next === "customer" ? "customer" : "internal"), children: [
|
|
1716
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "w-40", "aria-label": t("warranty_claims.detail.visibility.label"), children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
1717
|
+
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
1718
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "internal", children: t("warranty_claims.detail.visibility.internal") }),
|
|
1719
|
+
/* @__PURE__ */ jsx(SelectItem, { value: "customer", children: t("warranty_claims.detail.visibility.customer") })
|
|
1720
|
+
] })
|
|
1721
|
+
] }),
|
|
1722
|
+
!draftReplyHidden && featureAccess.claimManage && claimMutable ? /* @__PURE__ */ jsxs(
|
|
1723
|
+
Button,
|
|
1724
|
+
{
|
|
1725
|
+
type: "button",
|
|
1726
|
+
variant: "outline",
|
|
1727
|
+
onClick: () => {
|
|
1728
|
+
void draftReplyWithAi();
|
|
1729
|
+
},
|
|
1730
|
+
disabled: draftReplyLoading,
|
|
1731
|
+
children: [
|
|
1732
|
+
/* @__PURE__ */ jsx(AiIcon, { className: "size-4", "aria-hidden": "true" }),
|
|
1733
|
+
draftReplyLoading ? t("warranty_claims.ai.draftingReply") : t("warranty_claims.ai.draftReply")
|
|
1734
|
+
]
|
|
1735
|
+
}
|
|
1736
|
+
) : null
|
|
1737
|
+
] }),
|
|
1738
|
+
/* @__PURE__ */ jsx(Button, { type: "button", onClick: () => {
|
|
1739
|
+
void submitComment();
|
|
1740
|
+
}, disabled: !commentBody.trim(), children: t("warranty_claims.detail.timeline.addComment") })
|
|
1741
|
+
] })
|
|
1742
|
+
] }) }) : null,
|
|
1743
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
1744
|
+
events.length ? /* @__PURE__ */ jsx(
|
|
1745
|
+
SegmentedControl,
|
|
1746
|
+
{
|
|
1747
|
+
size: "sm",
|
|
1748
|
+
value: timelineFilter,
|
|
1749
|
+
onValueChange: (next) => setTimelineFilter(isTimelineFilterId(next) ? next : "all"),
|
|
1750
|
+
"aria-label": t("warranty_claims.detail.timeline.filter.label", "Filter timeline"),
|
|
1751
|
+
children: TIMELINE_FILTERS.map((filter) => /* @__PURE__ */ jsx(SegmentedControlItem, { value: filter, children: t(TIMELINE_FILTER_LABELS[filter].key, TIMELINE_FILTER_LABELS[filter].fallback) }, filter))
|
|
1752
|
+
}
|
|
1753
|
+
) : null,
|
|
1754
|
+
filteredTimelineEvents.length ? filteredTimelineEvents.map((event) => {
|
|
1755
|
+
const Icon = eventIcon(event.kind);
|
|
1756
|
+
const body = formatTimelineBody(event, t, userNames);
|
|
1757
|
+
const actor = resolveTimelineActor(event, claim, userNames, t);
|
|
1758
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex gap-3 py-2", children: [
|
|
1759
|
+
/* @__PURE__ */ jsx("div", { className: "flex size-7 shrink-0 items-center justify-center rounded-full bg-muted text-muted-foreground", children: /* @__PURE__ */ jsx(Icon, { className: "h-4 w-4", "aria-hidden": true }) }),
|
|
1760
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-1", children: [
|
|
1761
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1762
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: t(`warranty_claims.eventKind.${event.kind}`) }),
|
|
1763
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: actor }),
|
|
1764
|
+
/* @__PURE__ */ jsx(StatusBadge, { variant: event.visibility === "customer" ? "info" : "neutral", children: event.visibility === "customer" ? t("warranty_claims.detail.visibility.customer") : t("warranty_claims.detail.visibility.internal") }),
|
|
1765
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: formatDateTime(event.createdAt) ?? noValue })
|
|
1766
|
+
] }),
|
|
1767
|
+
body ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: body }) : null
|
|
1768
|
+
] })
|
|
1769
|
+
] }, event.id);
|
|
1770
|
+
}) : events.length ? /* @__PURE__ */ jsx(
|
|
1771
|
+
EmptyState,
|
|
1772
|
+
{
|
|
1773
|
+
title: t("warranty_claims.detail.timeline.filterEmpty.title", "No matching events"),
|
|
1774
|
+
description: t("warranty_claims.detail.timeline.filterEmpty.description", "No timeline events match the selected filter."),
|
|
1775
|
+
variant: "subtle"
|
|
1776
|
+
}
|
|
1777
|
+
) : /* @__PURE__ */ jsx(
|
|
1778
|
+
EmptyState,
|
|
1779
|
+
{
|
|
1780
|
+
title: t("warranty_claims.detail.timeline.empty.title"),
|
|
1781
|
+
description: t("warranty_claims.detail.timeline.empty.description"),
|
|
1782
|
+
variant: "subtle"
|
|
1783
|
+
}
|
|
1784
|
+
)
|
|
1785
|
+
] })
|
|
1786
|
+
] }) }),
|
|
1787
|
+
/* @__PURE__ */ jsx(TabsContent, { value: "attachments", className: "mt-0", children: /* @__PURE__ */ jsx("div", { className: "px-8 pb-8 pt-6", children: /* @__PURE__ */ jsx(
|
|
1788
|
+
AttachmentInput,
|
|
1789
|
+
{
|
|
1790
|
+
entityId: "warranty_claims:warranty_claim",
|
|
1791
|
+
recordId: claim.id,
|
|
1792
|
+
allowDelete: featureAccess.claimManage,
|
|
1793
|
+
allowReplace: featureAccess.claimManage,
|
|
1794
|
+
disabled: !featureAccess.claimManage,
|
|
1795
|
+
onCountChange: setAttachmentCount,
|
|
1796
|
+
renderItemMeta: (item) => isCustomerVisibleAttachment(item.tags) ? /* @__PURE__ */ jsx(StatusBadge, { variant: "info", children: t("warranty_claims.detail.attachments.customerVisible", "Visible to customer") }) : null
|
|
1797
|
+
}
|
|
1798
|
+
) }) }),
|
|
1799
|
+
/* @__PURE__ */ jsx(TabsContent, { value: "ai", className: "mt-0", children: /* @__PURE__ */ jsxs("div", { className: "grid gap-4 px-8 pb-8 pt-6 xl:grid-cols-2", children: [
|
|
1800
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-border bg-card p-4", children: [
|
|
1801
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-3", children: [
|
|
1802
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
1803
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium", children: t("warranty_claims.triage.panelTitle") }),
|
|
1804
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: t("warranty_claims.triage.panelSubtitle") })
|
|
1805
|
+
] }),
|
|
1806
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: loadAiSuggestion, disabled: aiLoading, children: t("warranty_claims.triage.suggestButton") })
|
|
1807
|
+
] }),
|
|
1808
|
+
aiSuggestion ? /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-4", children: [
|
|
1809
|
+
/* @__PURE__ */ jsxs("div", { className: "rounded-md border border-border p-3", children: [
|
|
1810
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1811
|
+
/* @__PURE__ */ jsxs(StatusBadge, { variant: aiSuggestion.priority.overdue ? "error" : "info", children: [
|
|
1812
|
+
t(`warranty_claims.priority.${aiSuggestion.priority.currentPriority}`),
|
|
1813
|
+
" \u2192 ",
|
|
1814
|
+
t(`warranty_claims.priority.${aiSuggestion.priority.suggestedPriority}`)
|
|
1815
|
+
] }),
|
|
1816
|
+
/* @__PURE__ */ jsx(RiskSignalChips, { signals: aiSuggestion.risk?.signals ?? [], t })
|
|
1817
|
+
] }),
|
|
1818
|
+
/* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-muted-foreground", children: formatTriageMessage(aiSuggestion.priority.reason, t) })
|
|
1819
|
+
] }),
|
|
1820
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: aiSuggestion.lines.map((suggestedLine) => {
|
|
1821
|
+
const applied = appliedTriageLineIds.has(suggestedLine.lineId);
|
|
1822
|
+
return /* @__PURE__ */ jsxs(
|
|
1823
|
+
"div",
|
|
1824
|
+
{
|
|
1825
|
+
className: "flex flex-wrap items-start justify-between gap-3 rounded-md border border-border p-3",
|
|
1826
|
+
children: [
|
|
1827
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
1828
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm font-medium", children: triageLineHeading(suggestedLine, lines, t) }),
|
|
1829
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-1 flex flex-wrap items-center gap-2", children: [
|
|
1830
|
+
/* @__PURE__ */ jsx(StatusBadge, { variant: eligibilityBadgeVariant(suggestedLine.eligibility.status), children: t(`warranty_claims.eligibility.${suggestedLine.eligibility.status}`) }),
|
|
1831
|
+
/* @__PURE__ */ jsx(StatusBadge, { variant: "info", children: t(`warranty_claims.disposition.${suggestedLine.suggestedDisposition}`) })
|
|
1832
|
+
] }),
|
|
1833
|
+
/* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-muted-foreground", children: formatTriageMessage(suggestedLine.reason, t) }),
|
|
1834
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: formatTriageMessage(suggestedLine.eligibility.reason, t) })
|
|
1835
|
+
] }),
|
|
1836
|
+
applied ? /* @__PURE__ */ jsxs(StatusBadge, { variant: "success", children: [
|
|
1837
|
+
t("warranty_claims.triage.applied", "Applied"),
|
|
1838
|
+
": ",
|
|
1839
|
+
t(`warranty_claims.disposition.${suggestedLine.suggestedDisposition}`)
|
|
1840
|
+
] }) : /* @__PURE__ */ jsx(
|
|
1841
|
+
Button,
|
|
1842
|
+
{
|
|
1843
|
+
type: "button",
|
|
1844
|
+
variant: "outline",
|
|
1845
|
+
size: "sm",
|
|
1846
|
+
onClick: () => applyAiDisposition(suggestedLine.lineId, suggestedLine.suggestedDisposition),
|
|
1847
|
+
children: t("warranty_claims.triage.apply")
|
|
1848
|
+
}
|
|
1849
|
+
)
|
|
1850
|
+
]
|
|
1851
|
+
},
|
|
1852
|
+
suggestedLine.lineId
|
|
1853
|
+
);
|
|
1854
|
+
}) })
|
|
1855
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "mt-4", children: /* @__PURE__ */ jsx(
|
|
1856
|
+
EmptyState,
|
|
1857
|
+
{
|
|
1858
|
+
title: t("warranty_claims.triage.panelTitle"),
|
|
1859
|
+
description: t("warranty_claims.triage.empty.description"),
|
|
1860
|
+
variant: "subtle"
|
|
1861
|
+
}
|
|
1862
|
+
) })
|
|
1863
|
+
] }),
|
|
1864
|
+
/* @__PURE__ */ jsx("div", { className: "h-96 overflow-hidden rounded-lg border border-border bg-card", children: /* @__PURE__ */ jsx(React.Suspense, { fallback: /* @__PURE__ */ jsx(LoadingMessage, { label: t("warranty_claims.detail.loading") }), children: /* @__PURE__ */ jsx(
|
|
1865
|
+
LazyAiChat,
|
|
1866
|
+
{
|
|
1867
|
+
agent: AGENT_ID,
|
|
1868
|
+
pageContext: { entityType: "warranty_claims.claim", recordId: claim.id },
|
|
1869
|
+
className: "h-full",
|
|
1870
|
+
placeholder: t("warranty_claims.ai.chatPlaceholder"),
|
|
1871
|
+
welcomeTitle: t("warranty_claims.ai.chatWelcomeTitle")
|
|
1872
|
+
},
|
|
1873
|
+
`${AGENT_ID}:${claim.id}`
|
|
1874
|
+
) }) }),
|
|
1875
|
+
lines.length ? /* @__PURE__ */ jsx("div", { className: "space-y-3 xl:col-span-2", children: lines.map((line) => /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3 rounded-lg border border-border p-4", children: [
|
|
1876
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
1877
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-sm font-medium text-foreground", children: line.productName ?? line.sku ?? t("warranty_claims.detail.lines.unnamed", "Unnamed line") }),
|
|
1878
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: [line.sku, line.serialNumber].filter(Boolean).join(" / ") || noValue })
|
|
1879
|
+
] }),
|
|
1880
|
+
/* @__PURE__ */ jsx(
|
|
1881
|
+
AiAssessButtons,
|
|
1882
|
+
{
|
|
1883
|
+
claimId: claim.id,
|
|
1884
|
+
line,
|
|
1885
|
+
canManage: featureAccess.claimManage && claimMutable,
|
|
1886
|
+
onRefresh: loadData
|
|
1887
|
+
}
|
|
1888
|
+
)
|
|
1889
|
+
] }, line.id)) }) : null
|
|
1890
|
+
] }) })
|
|
1891
|
+
]
|
|
1892
|
+
}
|
|
1893
|
+
)
|
|
1894
|
+
] }),
|
|
1895
|
+
/* @__PURE__ */ jsx(ReturnLabelPanel, { claim, canManage: featureAccess.claimManage, onRefresh: loadData }),
|
|
1896
|
+
(() => {
|
|
1897
|
+
const showSalesReturn = featureAccess.claimManage && featureAccess.salesReturnsCreate && claim.orderId && !claim.salesReturnId && ["approved", "awaiting_return", "received", "inspecting"].includes(currentStatus ?? "");
|
|
1898
|
+
const showReplacementOrder = featureAccess.claimManage && featureAccess.salesOrdersManage && claim.orderId && !claim.replacementOrderId && ["approved", "awaiting_return", "received", "inspecting", "resolved"].includes(currentStatus ?? "");
|
|
1899
|
+
const showCreditMemo = featureAccess.claimManage && featureAccess.salesCreditMemosManage && claim.orderId && !claim.creditMemoId && ["received", "inspecting", "resolved"].includes(currentStatus ?? "");
|
|
1900
|
+
if (!showSalesReturn && !showReplacementOrder && !showCreditMemo) return null;
|
|
1901
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1902
|
+
showSalesReturn ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: () => {
|
|
1903
|
+
void createSalesReturn();
|
|
1904
|
+
}, children: t("warranty_claims.detail.createSalesReturn") }) : null,
|
|
1905
|
+
showReplacementOrder ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: () => {
|
|
1906
|
+
void createReplacementOrder();
|
|
1907
|
+
}, children: t("warranty_claims.detail.createReplacementOrder") }) : null,
|
|
1908
|
+
showCreditMemo ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: () => {
|
|
1909
|
+
void createCreditMemo();
|
|
1910
|
+
}, children: t("warranty_claims.detail.createCreditMemo") }) : null
|
|
1911
|
+
] });
|
|
1912
|
+
})(),
|
|
1913
|
+
/* @__PURE__ */ jsx(
|
|
1914
|
+
VendorRecoverySuggestionsPanel,
|
|
1915
|
+
{
|
|
1916
|
+
claim,
|
|
1917
|
+
canManage: featureAccess.claimManage,
|
|
1918
|
+
onGenerateSupplierRecovery: generateSupplierRecovery
|
|
1919
|
+
}
|
|
1920
|
+
)
|
|
1921
|
+
] }) }),
|
|
1922
|
+
/* @__PURE__ */ jsx(Dialog, { open: assignDialogOpen, onOpenChange: setAssignDialogOpen, children: /* @__PURE__ */ jsxs(
|
|
1923
|
+
DialogContent,
|
|
1924
|
+
{
|
|
1925
|
+
className: "max-w-lg",
|
|
1926
|
+
onKeyDown: (event) => {
|
|
1927
|
+
if ((event.metaKey || event.ctrlKey) && event.key === "Enter") {
|
|
1928
|
+
event.preventDefault();
|
|
1929
|
+
void assignClaim();
|
|
1930
|
+
}
|
|
1931
|
+
if (event.key === "Escape") {
|
|
1932
|
+
setAssignDialogOpen(false);
|
|
1933
|
+
}
|
|
1934
|
+
},
|
|
1935
|
+
children: [
|
|
1936
|
+
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: t("warranty_claims.detail.assignDialog.title") }) }),
|
|
1937
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
1938
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
1939
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "warranty-claim-assignee-search", children: t("warranty_claims.detail.assignDialog.search") }),
|
|
1940
|
+
/* @__PURE__ */ jsx(
|
|
1941
|
+
Input,
|
|
1942
|
+
{
|
|
1943
|
+
id: "warranty-claim-assignee-search",
|
|
1944
|
+
value: assignSearch,
|
|
1945
|
+
onChange: (event) => setAssignSearch(event.target.value),
|
|
1946
|
+
placeholder: t("warranty_claims.detail.assignDialog.searchPlaceholder")
|
|
1947
|
+
}
|
|
1948
|
+
)
|
|
1949
|
+
] }),
|
|
1950
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
1951
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: "warranty-claim-assignee-select", children: t("warranty_claims.detail.assignDialog.staff") }),
|
|
1952
|
+
/* @__PURE__ */ jsxs(Select, { value: selectedAssigneeUserId, onValueChange: setSelectedAssigneeUserId, children: [
|
|
1953
|
+
/* @__PURE__ */ jsx(SelectTrigger, { id: "warranty-claim-assignee-select", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
|
|
1954
|
+
/* @__PURE__ */ jsxs(SelectContent, { children: [
|
|
1955
|
+
/* @__PURE__ */ jsx(SelectItem, { value: UNASSIGNED_SELECT_VALUE, children: t("warranty_claims.detail.unassigned") }),
|
|
1956
|
+
assignableOptions.map((staffMember) => /* @__PURE__ */ jsx(SelectItem, { value: staffMember.userId, children: staffMember.email && staffMember.email !== staffMember.displayName ? `${staffMember.displayName} (${staffMember.email})` : staffMember.displayName }, staffMember.userId))
|
|
1957
|
+
] })
|
|
1958
|
+
] }),
|
|
1959
|
+
assignLoading ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("warranty_claims.detail.assignDialog.loading") }) : null,
|
|
1960
|
+
!assignLoading && assignableOptions.length === 0 ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: t("warranty_claims.detail.assignDialog.empty") }) : null
|
|
1961
|
+
] })
|
|
1962
|
+
] }),
|
|
1963
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [
|
|
1964
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "outline", onClick: () => setAssignDialogOpen(false), children: t("common.cancel", "Cancel") }),
|
|
1965
|
+
/* @__PURE__ */ jsx(Button, { type: "button", onClick: () => {
|
|
1966
|
+
void assignClaim();
|
|
1967
|
+
}, children: t("warranty_claims.form.submit") })
|
|
1968
|
+
] })
|
|
1969
|
+
]
|
|
1970
|
+
}
|
|
1971
|
+
) }),
|
|
1972
|
+
/* @__PURE__ */ jsx(Dialog, { open: lineDialog !== null, onOpenChange: (open) => {
|
|
1973
|
+
if (!open) setLineDialog(null);
|
|
1974
|
+
}, children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-3xl", children: [
|
|
1975
|
+
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: lineDialog?.mode === "edit" ? t("warranty_claims.detail.lines.edit") : t("warranty_claims.detail.lines.add") }) }),
|
|
1976
|
+
/* @__PURE__ */ jsx(
|
|
1977
|
+
CrudForm,
|
|
1978
|
+
{
|
|
1979
|
+
embedded: true,
|
|
1980
|
+
title: lineDialog?.mode === "edit" ? t("warranty_claims.detail.lines.edit") : t("warranty_claims.detail.lines.add"),
|
|
1981
|
+
fields: lineDialog?.mode === "edit" ? lineFields : lineFields.filter((field) => field.id !== "lineStatus"),
|
|
1982
|
+
groups: lineDialog?.mode === "edit" ? lineGroups : lineGroups.map((group) => ({ ...group, fields: (group.fields ?? []).filter((fieldId) => fieldId !== "lineStatus") })),
|
|
1983
|
+
initialValues: lineDialog?.mode === "edit" ? {
|
|
1984
|
+
...lineDialog.line,
|
|
1985
|
+
qtyClaimed: quantityInputValue(lineDialog.line.qtyClaimed),
|
|
1986
|
+
qtyApproved: quantityInputValue(lineDialog.line.qtyApproved),
|
|
1987
|
+
qtyReceived: quantityInputValue(lineDialog.line.qtyReceived)
|
|
1988
|
+
} : { claimId: claim.id, qtyClaimed: "1", lineStatus: "pending", warrantyMonths: defaultWarrantyMonths ?? void 0 },
|
|
1989
|
+
submitLabel: t("warranty_claims.form.submit"),
|
|
1990
|
+
onSubmit: async (values) => {
|
|
1991
|
+
const payload = {
|
|
1992
|
+
claimId: claim.id,
|
|
1993
|
+
productId: nullableText(values.productId),
|
|
1994
|
+
variantId: nullableText(values.variantId),
|
|
1995
|
+
productName: nullableText(values.productName),
|
|
1996
|
+
sku: nullableText(values.sku),
|
|
1997
|
+
serialNumber: nullableText(values.serialNumber),
|
|
1998
|
+
purchaseDate: nullableText(values.purchaseDate),
|
|
1999
|
+
warrantyMonths: values.warrantyMonths === null || values.warrantyMonths === void 0 || String(values.warrantyMonths).trim() === "" ? null : Number(values.warrantyMonths),
|
|
2000
|
+
faultCode: nullableText(values.faultCode),
|
|
2001
|
+
faultDescription: nullableText(values.faultDescription),
|
|
2002
|
+
qtyClaimed: values.qtyClaimed ?? 1,
|
|
2003
|
+
qtyApproved: values.qtyApproved ?? null,
|
|
2004
|
+
qtyReceived: values.qtyReceived ?? null,
|
|
2005
|
+
disposition: nullableText(values.disposition),
|
|
2006
|
+
creditAmount: values.creditAmount ?? null,
|
|
2007
|
+
restockingFee: values.restockingFee ?? null,
|
|
2008
|
+
coreChargeAmount: values.coreChargeAmount ?? null,
|
|
2009
|
+
coreCreditAmount: values.coreCreditAmount ?? null,
|
|
2010
|
+
conditionOnReceipt: nullableText(values.conditionOnReceipt),
|
|
2011
|
+
inspectionNotes: nullableText(values.inspectionNotes)
|
|
2012
|
+
};
|
|
2013
|
+
if (lineDialog?.mode === "edit") {
|
|
2014
|
+
payload.lineStatus = nullableText(values.lineStatus) ?? "pending";
|
|
2015
|
+
}
|
|
2016
|
+
if (lineDialog?.mode === "edit") {
|
|
2017
|
+
await updateCrud("warranty_claims/lines", { id: lineDialog.line.id, ...payload }, {
|
|
2018
|
+
errorMessage: t("warranty_claims.detail.lines.error.save")
|
|
2019
|
+
});
|
|
2020
|
+
flash(t("warranty_claims.detail.lines.flash.saved"), "success");
|
|
2021
|
+
} else {
|
|
2022
|
+
await createCrud("warranty_claims/lines", payload, {
|
|
2023
|
+
errorMessage: t("warranty_claims.detail.lines.error.save")
|
|
2024
|
+
});
|
|
2025
|
+
flash(t("warranty_claims.detail.lines.flash.created"), "success");
|
|
2026
|
+
}
|
|
2027
|
+
setLineDialog(null);
|
|
2028
|
+
await loadData();
|
|
2029
|
+
},
|
|
2030
|
+
onDelete: lineDialog?.mode === "edit" ? async () => {
|
|
2031
|
+
await deleteCrud("warranty_claims/lines", {
|
|
2032
|
+
body: { id: lineDialog.line.id, claimId: claim.id },
|
|
2033
|
+
errorMessage: t("warranty_claims.detail.lines.error.delete")
|
|
2034
|
+
});
|
|
2035
|
+
flash(t("warranty_claims.detail.lines.flash.deleted"), "success");
|
|
2036
|
+
setLineDialog(null);
|
|
2037
|
+
await loadData();
|
|
2038
|
+
} : void 0
|
|
2039
|
+
}
|
|
2040
|
+
)
|
|
2041
|
+
] }) }),
|
|
2042
|
+
/* @__PURE__ */ jsx(Dialog, { open: transitionDialog !== null, onOpenChange: (open) => {
|
|
2043
|
+
if (!open) setTransitionDialog(null);
|
|
2044
|
+
}, children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-lg", children: [
|
|
2045
|
+
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: t("warranty_claims.detail.confirm.rejectTitle") }) }),
|
|
2046
|
+
/* @__PURE__ */ jsx(
|
|
2047
|
+
CrudForm,
|
|
2048
|
+
{
|
|
2049
|
+
embedded: true,
|
|
2050
|
+
title: t("warranty_claims.detail.confirm.rejectTitle"),
|
|
2051
|
+
fields: transitionFields,
|
|
2052
|
+
initialValues: { rejectionReasonCode: claim.rejectionReasonCode ?? "", resolutionSummary: claim.resolutionSummary ?? "" },
|
|
2053
|
+
submitLabel: t("warranty_claims.detail.actions.transition"),
|
|
2054
|
+
onSubmit: async (values) => {
|
|
2055
|
+
if (!transitionDialog) return;
|
|
2056
|
+
await handleTransition(transitionDialog.toStatus, values);
|
|
2057
|
+
setTransitionDialog(null);
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
)
|
|
2061
|
+
] }) }),
|
|
2062
|
+
/* @__PURE__ */ jsx(Dialog, { open: vendorDialogOpen, onOpenChange: setVendorDialogOpen, children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-lg", children: [
|
|
2063
|
+
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: t("warranty_claims.detail.actions.vendorRecovery") }) }),
|
|
2064
|
+
/* @__PURE__ */ jsx(
|
|
2065
|
+
CrudForm,
|
|
2066
|
+
{
|
|
2067
|
+
embedded: true,
|
|
2068
|
+
title: t("warranty_claims.detail.actions.vendorRecovery"),
|
|
2069
|
+
fields: vendorFields,
|
|
2070
|
+
initialValues: { lineIds: eligibleVendorLines.map((line) => line.id), vendorName: "", vendorRef: "" },
|
|
2071
|
+
submitLabel: t("warranty_claims.detail.actions.vendorRecovery"),
|
|
2072
|
+
onSubmit: async (values) => {
|
|
2073
|
+
const lineIds = Array.isArray(values.lineIds) ? values.lineIds.filter((lineId) => typeof lineId === "string") : [];
|
|
2074
|
+
if (!lineIds.length) {
|
|
2075
|
+
flash(t("warranty_claims.errors.vendorRecoveryNeedsResolvedLines"), "error");
|
|
2076
|
+
return;
|
|
2077
|
+
}
|
|
2078
|
+
await runClaimPost(
|
|
2079
|
+
"/api/warranty_claims/vendor-recovery",
|
|
2080
|
+
{
|
|
2081
|
+
claimId: claim.id,
|
|
2082
|
+
lineIds,
|
|
2083
|
+
vendorName: nullableText(values.vendorName),
|
|
2084
|
+
vendorRef: nullableText(values.vendorRef)
|
|
2085
|
+
},
|
|
2086
|
+
"warranty_claims.detail.vendorRecovery.created"
|
|
2087
|
+
);
|
|
2088
|
+
setVendorDialogOpen(false);
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
)
|
|
2092
|
+
] }) }),
|
|
2093
|
+
ConfirmDialogElement
|
|
2094
|
+
] });
|
|
2095
|
+
}
|
|
2096
|
+
export {
|
|
2097
|
+
InlineLineSelectCell,
|
|
2098
|
+
InlineQtyApprovedCell,
|
|
2099
|
+
WarrantyClaimDetailPage as default
|
|
2100
|
+
};
|
|
2101
|
+
//# sourceMappingURL=page.js.map
|