@redacto.io/consent-sdk-react 10.0.0-beta.1 → 10.0.0-beta.12

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.
Files changed (258) hide show
  1. package/NOTICE.md +17 -0
  2. package/README.md +145 -3
  3. package/dist/chunk-FEGTW73Q.mjs +182 -0
  4. package/dist/{chunk-6A665OPR.mjs → chunk-OGL6OC3A.mjs} +4 -0
  5. package/dist/fonts.d.mts +35 -0
  6. package/dist/fonts.d.ts +35 -0
  7. package/dist/fonts.js +183 -0
  8. package/dist/fonts.mjs +10 -0
  9. package/dist/index.d.mts +44 -5
  10. package/dist/index.d.ts +44 -5
  11. package/dist/index.js +950 -476
  12. package/dist/index.mjs +572 -314
  13. package/dist/montserrat.generated-NBTECYRW.mjs +22 -0
  14. package/dist/privacy-center.d.mts +55 -12
  15. package/dist/privacy-center.d.ts +55 -12
  16. package/dist/privacy-center.js +848 -950
  17. package/dist/privacy-center.mjs +698 -802
  18. package/dist/types-6Aj7faxL.d.mts +57 -0
  19. package/dist/types-6Aj7faxL.d.ts +57 -0
  20. package/package.json +10 -1
  21. package/.turbo/turbo-build.log +0 -22
  22. package/.turbo/turbo-test.log +0 -203
  23. package/.turbo/turbo-verify-pack.log +0 -6
  24. package/CHANGELOG.md +0 -274
  25. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.test.tsx +0 -847
  26. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.tsx +0 -2133
  27. package/src/RedactoNoticeAssisted/api/index.ts +0 -269
  28. package/src/RedactoNoticeAssisted/api/types.ts +0 -180
  29. package/src/RedactoNoticeAssisted/assets/redacto-logo.png +0 -0
  30. package/src/RedactoNoticeAssisted/constants.ts +0 -51
  31. package/src/RedactoNoticeAssisted/i18n.ts +0 -1463
  32. package/src/RedactoNoticeAssisted/index.ts +0 -1
  33. package/src/RedactoNoticeAssisted/injectStyles.ts +0 -251
  34. package/src/RedactoNoticeAssisted/styles.ts +0 -730
  35. package/src/RedactoNoticeAssisted/types.ts +0 -24
  36. package/src/RedactoNoticeAssisted/useMediaQuery.ts +0 -36
  37. package/src/RedactoNoticeConsent/RedactoNoticeConsent.test.tsx +0 -1152
  38. package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +0 -4258
  39. package/src/RedactoNoticeConsent/api/index.ts +0 -573
  40. package/src/RedactoNoticeConsent/api/types.ts +0 -490
  41. package/src/RedactoNoticeConsent/assets/redacto-logo.png +0 -0
  42. package/src/RedactoNoticeConsent/components/DigiLockerCallback.tsx +0 -602
  43. package/src/RedactoNoticeConsent/components/index.ts +0 -7
  44. package/src/RedactoNoticeConsent/constants.ts +0 -20
  45. package/src/RedactoNoticeConsent/index.ts +0 -1
  46. package/src/RedactoNoticeConsent/injectStyles.ts +0 -151
  47. package/src/RedactoNoticeConsent/language-codes.ts +0 -97
  48. package/src/RedactoNoticeConsent/services/storage.ts +0 -122
  49. package/src/RedactoNoticeConsent/styles.ts +0 -409
  50. package/src/RedactoNoticeConsent/types.ts +0 -54
  51. package/src/RedactoNoticeConsent/useMediaQuery.ts +0 -36
  52. package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.test.tsx +0 -369
  53. package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx +0 -629
  54. package/src/RedactoNoticeConsentInline/api/index.ts +0 -106
  55. package/src/RedactoNoticeConsentInline/api/types.ts +0 -183
  56. package/src/RedactoNoticeConsentInline/assets/redacto-logo.png +0 -0
  57. package/src/RedactoNoticeConsentInline/index.ts +0 -1
  58. package/src/RedactoNoticeConsentInline/injectStyles.ts +0 -40
  59. package/src/RedactoNoticeConsentInline/styles.ts +0 -397
  60. package/src/RedactoNoticeConsentInline/types.ts +0 -51
  61. package/src/RedactoNoticeConsentInline/useMediaQuery.ts +0 -36
  62. package/src/RedactoPrivacyCenter/NotificationsPage.tsx +0 -182
  63. package/src/RedactoPrivacyCenter/PrivacyCenterActivityPage.tsx +0 -19
  64. package/src/RedactoPrivacyCenter/PrivacyCenterCaseDetailsPage.tsx +0 -156
  65. package/src/RedactoPrivacyCenter/PrivacyCenterConsentManagerPage.tsx +0 -17
  66. package/src/RedactoPrivacyCenter/PrivacyCenterFormPage.tsx +0 -79
  67. package/src/RedactoPrivacyCenter/PrivacyCenterHomePage.tsx +0 -36
  68. package/src/RedactoPrivacyCenter/PrivacyCenterLayout.tsx +0 -177
  69. package/src/RedactoPrivacyCenter/PrivacyCenterMyReceiptPage.tsx +0 -26
  70. package/src/RedactoPrivacyCenter/RedactoPrivacyCenter.tsx +0 -58
  71. package/src/RedactoPrivacyCenter/api/actions.ts +0 -680
  72. package/src/RedactoPrivacyCenter/api/client.ts +0 -906
  73. package/src/RedactoPrivacyCenter/api/config.ts +0 -33
  74. package/src/RedactoPrivacyCenter/api/fetcher.ts +0 -260
  75. package/src/RedactoPrivacyCenter/api/orgBranding.ts +0 -16
  76. package/src/RedactoPrivacyCenter/api/upload.ts +0 -93
  77. package/src/RedactoPrivacyCenter/assets/character.svg +0 -31
  78. package/src/RedactoPrivacyCenter/assets/fileAttach.svg +0 -9
  79. package/src/RedactoPrivacyCenter/assets/greenTick.svg +0 -4
  80. package/src/RedactoPrivacyCenter/assets/mail.svg +0 -3
  81. package/src/RedactoPrivacyCenter/assets/poweredByRedacto.svg +0 -9
  82. package/src/RedactoPrivacyCenter/assets/sentImg.svg +0 -9
  83. package/src/RedactoPrivacyCenter/assets/uploadFileIcon.svg +0 -9
  84. package/src/RedactoPrivacyCenter/components/ActivitiesList.tsx +0 -252
  85. package/src/RedactoPrivacyCenter/components/ActivityTimeline.tsx +0 -239
  86. package/src/RedactoPrivacyCenter/components/AppShell/AppShell.tsx +0 -240
  87. package/src/RedactoPrivacyCenter/components/AppShell/MobileNavDrawer.tsx +0 -218
  88. package/src/RedactoPrivacyCenter/components/AppShell/NavItem.tsx +0 -205
  89. package/src/RedactoPrivacyCenter/components/AppShell/PageHeader.tsx +0 -107
  90. package/src/RedactoPrivacyCenter/components/AppShell/SidebarNav.tsx +0 -100
  91. package/src/RedactoPrivacyCenter/components/AppShell/TopAppBar.tsx +0 -339
  92. package/src/RedactoPrivacyCenter/components/AppShell/UserMenu.tsx +0 -243
  93. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useIsTruncated.ts +0 -28
  94. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useKeyboardShortcut.ts +0 -40
  95. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useSidebarState.ts +0 -62
  96. package/src/RedactoPrivacyCenter/components/AppShell/usePrivacyCenterExitAction.ts +0 -36
  97. package/src/RedactoPrivacyCenter/components/CaseDetails/AttachmentCard.tsx +0 -38
  98. package/src/RedactoPrivacyCenter/components/CaseDetails/ChatBubble.tsx +0 -31
  99. package/src/RedactoPrivacyCenter/components/CaseDetails/DocumentRequestCard.tsx +0 -79
  100. package/src/RedactoPrivacyCenter/components/CaseDetails/FinalizedTooltipWrapper.tsx +0 -25
  101. package/src/RedactoPrivacyCenter/components/CaseDetails/MessageComposer.tsx +0 -96
  102. package/src/RedactoPrivacyCenter/components/CaseDetails/MessageItem.tsx +0 -97
  103. package/src/RedactoPrivacyCenter/components/CaseDetails/MessagesTab.tsx +0 -156
  104. package/src/RedactoPrivacyCenter/components/CaseDetails/RequestDetailsTab.tsx +0 -171
  105. package/src/RedactoPrivacyCenter/components/CaseDetails/StatusEvent.tsx +0 -23
  106. package/src/RedactoPrivacyCenter/components/CaseDetails/useFileUpload.ts +0 -116
  107. package/src/RedactoPrivacyCenter/components/CaseDetails/useMessagePolling.ts +0 -43
  108. package/src/RedactoPrivacyCenter/components/CaseDetails/utils.ts +0 -71
  109. package/src/RedactoPrivacyCenter/components/CaseDetailsModal.tsx +0 -469
  110. package/src/RedactoPrivacyCenter/components/CaseHistory.tsx +0 -426
  111. package/src/RedactoPrivacyCenter/components/ConsentManager.tsx +0 -1198
  112. package/src/RedactoPrivacyCenter/components/ConsentManagerCells.tsx +0 -201
  113. package/src/RedactoPrivacyCenter/components/ConsentManagerColumns.tsx +0 -138
  114. package/src/RedactoPrivacyCenter/components/ConsentManagerConstants.ts +0 -7
  115. package/src/RedactoPrivacyCenter/components/ConsentManagerExpandedRow.tsx +0 -179
  116. package/src/RedactoPrivacyCenter/components/ConsentManagerGroupedColumns.tsx +0 -318
  117. package/src/RedactoPrivacyCenter/components/ConsentManagerProductCards.tsx +0 -333
  118. package/src/RedactoPrivacyCenter/components/ConsentManagerPurposeCards.tsx +0 -102
  119. package/src/RedactoPrivacyCenter/components/ConsentManagerTableSkeleton.tsx +0 -159
  120. package/src/RedactoPrivacyCenter/components/DataRequest/CorrectionDataSection.tsx +0 -189
  121. package/src/RedactoPrivacyCenter/components/DataRequest/GrievanceDataSection.tsx +0 -118
  122. package/src/RedactoPrivacyCenter/components/DataRequest/NominationDataSection.tsx +0 -66
  123. package/src/RedactoPrivacyCenter/components/DataRequest/ProductSelectionSection.tsx +0 -222
  124. package/src/RedactoPrivacyCenter/components/DataRequest/PurposeSelectionSection.tsx +0 -331
  125. package/src/RedactoPrivacyCenter/components/Form.tsx +0 -1796
  126. package/src/RedactoPrivacyCenter/components/GrievanceTable.tsx +0 -174
  127. package/src/RedactoPrivacyCenter/components/GrievanceTablePagination.tsx +0 -337
  128. package/src/RedactoPrivacyCenter/components/ModifyConsentModal.tsx +0 -334
  129. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationBell.tsx +0 -173
  130. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationCTAButton.tsx +0 -18
  131. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdown.tsx +0 -54
  132. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdownItem.tsx +0 -57
  133. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationIcon.tsx +0 -19
  134. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationListPanel.tsx +0 -92
  135. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRefreshButton.tsx +0 -20
  136. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRow.tsx +0 -58
  137. package/src/RedactoPrivacyCenter/components/NotificationHub/StatCard.tsx +0 -10
  138. package/src/RedactoPrivacyCenter/components/NotificationHub/useNotificationActions.ts +0 -112
  139. package/src/RedactoPrivacyCenter/components/NotificationHub/utils.ts +0 -27
  140. package/src/RedactoPrivacyCenter/components/Pagination.tsx +0 -140
  141. package/src/RedactoPrivacyCenter/components/PrivacyCenterEmptyState.tsx +0 -76
  142. package/src/RedactoPrivacyCenter/components/PrivacyCenterSessionExpired.tsx +0 -97
  143. package/src/RedactoPrivacyCenter/components/ReceiptsList.tsx +0 -454
  144. package/src/RedactoPrivacyCenter/components/RequestSubmit.tsx +0 -270
  145. package/src/RedactoPrivacyCenter/components/SelectUser.tsx +0 -83
  146. package/src/RedactoPrivacyCenter/components/SelectUserGate.tsx +0 -193
  147. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/constants.tsx +0 -25
  148. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/types.ts +0 -21
  149. package/src/RedactoPrivacyCenter/components/caseHistoryColumns.tsx +0 -159
  150. package/src/RedactoPrivacyCenter/components/constant.ts +0 -52
  151. package/src/RedactoPrivacyCenter/components/groupHelpers.ts +0 -119
  152. package/src/RedactoPrivacyCenter/components/receiptColumns.tsx +0 -203
  153. package/src/RedactoPrivacyCenter/components/types.ts +0 -123
  154. package/src/RedactoPrivacyCenter/components/utils.tsx +0 -10
  155. package/src/RedactoPrivacyCenter/config/routes.ts +0 -9
  156. package/src/RedactoPrivacyCenter/config/table.ts +0 -25
  157. package/src/RedactoPrivacyCenter/context/AuthContext.tsx +0 -160
  158. package/src/RedactoPrivacyCenter/context/BaseUrlContext.tsx +0 -47
  159. package/src/RedactoPrivacyCenter/context/BrandingContext.tsx +0 -52
  160. package/src/RedactoPrivacyCenter/context/DataAvailabilityContext.session-expired.test.tsx +0 -92
  161. package/src/RedactoPrivacyCenter/context/DataAvailabilityContext.tsx +0 -181
  162. package/src/RedactoPrivacyCenter/context/LocaleContext.tsx +0 -11
  163. package/src/RedactoPrivacyCenter/context/NavigationContext.tsx +0 -96
  164. package/src/RedactoPrivacyCenter/context/OrganizationContext.tsx +0 -30
  165. package/src/RedactoPrivacyCenter/context/PageChromeContext.tsx +0 -80
  166. package/src/RedactoPrivacyCenter/context/ProfileSwitchContext.tsx +0 -15
  167. package/src/RedactoPrivacyCenter/context/types.ts +0 -19
  168. package/src/RedactoPrivacyCenter/lib/api.ts +0 -756
  169. package/src/RedactoPrivacyCenter/lib/consent-manager/utils.tsx +0 -67
  170. package/src/RedactoPrivacyCenter/lib/constants.ts +0 -277
  171. package/src/RedactoPrivacyCenter/lib/i18n.ts +0 -81
  172. package/src/RedactoPrivacyCenter/lib/locales.ts +0 -105
  173. package/src/RedactoPrivacyCenter/lib/queries.ts +0 -141
  174. package/src/RedactoPrivacyCenter/lib/types.ts +0 -868
  175. package/src/RedactoPrivacyCenter/lib/useCurrentLanguage.ts +0 -37
  176. package/src/RedactoPrivacyCenter/lib/utils.refresh-circuit.test.ts +0 -127
  177. package/src/RedactoPrivacyCenter/lib/utils.refresh-storage.test.ts +0 -85
  178. package/src/RedactoPrivacyCenter/lib/utils.session-expired.test.ts +0 -109
  179. package/src/RedactoPrivacyCenter/lib/utils.ts +0 -783
  180. package/src/RedactoPrivacyCenter/locales/as/translation.json +0 -340
  181. package/src/RedactoPrivacyCenter/locales/bho/translation.json +0 -340
  182. package/src/RedactoPrivacyCenter/locales/bn/translation.json +0 -340
  183. package/src/RedactoPrivacyCenter/locales/brx/translation.json +0 -340
  184. package/src/RedactoPrivacyCenter/locales/doi/translation.json +0 -340
  185. package/src/RedactoPrivacyCenter/locales/en/translation.json +0 -354
  186. package/src/RedactoPrivacyCenter/locales/gom/translation.json +0 -340
  187. package/src/RedactoPrivacyCenter/locales/gu/translation.json +0 -340
  188. package/src/RedactoPrivacyCenter/locales/hi/translation.json +0 -343
  189. package/src/RedactoPrivacyCenter/locales/kn/translation.json +0 -340
  190. package/src/RedactoPrivacyCenter/locales/ks/translation.json +0 -340
  191. package/src/RedactoPrivacyCenter/locales/mai/translation.json +0 -340
  192. package/src/RedactoPrivacyCenter/locales/ml/translation.json +0 -340
  193. package/src/RedactoPrivacyCenter/locales/mni-Mtei/translation.json +0 -340
  194. package/src/RedactoPrivacyCenter/locales/mr/translation.json +0 -340
  195. package/src/RedactoPrivacyCenter/locales/ne/translation.json +0 -340
  196. package/src/RedactoPrivacyCenter/locales/or/translation.json +0 -340
  197. package/src/RedactoPrivacyCenter/locales/pa/translation.json +0 -340
  198. package/src/RedactoPrivacyCenter/locales/sa/translation.json +0 -340
  199. package/src/RedactoPrivacyCenter/locales/sat/translation.json +0 -340
  200. package/src/RedactoPrivacyCenter/locales/sd/translation.json +0 -340
  201. package/src/RedactoPrivacyCenter/locales/ta/translation.json +0 -340
  202. package/src/RedactoPrivacyCenter/locales/te/translation.json +0 -340
  203. package/src/RedactoPrivacyCenter/locales/ur/translation.json +0 -340
  204. package/src/RedactoPrivacyCenter/styles/applyBrandingTheme.ts +0 -66
  205. package/src/RedactoPrivacyCenter/styles/base.css +0 -117
  206. package/src/RedactoPrivacyCenter/styles/injectStyles.ts +0 -3103
  207. package/src/RedactoPrivacyCenter/styles/pcStyles.ts +0 -814
  208. package/src/RedactoPrivacyCenter/styles/responsive.ts +0 -138
  209. package/src/RedactoPrivacyCenter/styles/variables.css +0 -96
  210. package/src/RedactoPrivacyCenter/table/AdvancedTable.tsx +0 -387
  211. package/src/RedactoPrivacyCenter/table/AdvancedTablePagination.tsx +0 -468
  212. package/src/RedactoPrivacyCenter/table/index.ts +0 -2
  213. package/src/RedactoPrivacyCenter/types/images.d.ts +0 -29
  214. package/src/RedactoPrivacyCenter/ui/Footer.tsx +0 -69
  215. package/src/RedactoPrivacyCenter/ui/FormBlockWrapper.tsx +0 -54
  216. package/src/RedactoPrivacyCenter/ui/PCAccordion.tsx +0 -93
  217. package/src/RedactoPrivacyCenter/ui/PCActionIcon.tsx +0 -47
  218. package/src/RedactoPrivacyCenter/ui/PCAvatar.tsx +0 -69
  219. package/src/RedactoPrivacyCenter/ui/PCBadge.tsx +0 -48
  220. package/src/RedactoPrivacyCenter/ui/PCButton.tsx +0 -77
  221. package/src/RedactoPrivacyCenter/ui/PCCheckbox.tsx +0 -55
  222. package/src/RedactoPrivacyCenter/ui/PCCollapse.tsx +0 -107
  223. package/src/RedactoPrivacyCenter/ui/PCEmpty.tsx +0 -35
  224. package/src/RedactoPrivacyCenter/ui/PCInput.tsx +0 -132
  225. package/src/RedactoPrivacyCenter/ui/PCLoader.tsx +0 -31
  226. package/src/RedactoPrivacyCenter/ui/PCModal.tsx +0 -106
  227. package/src/RedactoPrivacyCenter/ui/PCPopover.tsx +0 -206
  228. package/src/RedactoPrivacyCenter/ui/PCSelect.tsx +0 -433
  229. package/src/RedactoPrivacyCenter/ui/PCTable.tsx +0 -149
  230. package/src/RedactoPrivacyCenter/ui/PCText.tsx +0 -41
  231. package/src/RedactoPrivacyCenter/ui/PCTextarea.tsx +0 -43
  232. package/src/RedactoPrivacyCenter/ui/PCTitle.tsx +0 -37
  233. package/src/RedactoPrivacyCenter/ui/PCTooltip.tsx +0 -121
  234. package/src/RedactoPrivacyCenter/ui/SimpleBar.tsx +0 -25
  235. package/src/RedactoPrivacyCenter/ui/StatusBadge.tsx +0 -53
  236. package/src/RedactoPrivacyCenter/ui/index.ts +0 -18
  237. package/src/RedactoPrivacyCenter/utils/cn.ts +0 -28
  238. package/src/RedactoPrivacyCenter/utils/date.ts +0 -48
  239. package/src/RedactoPrivacyCenter/utils/status.ts +0 -111
  240. package/src/RedactoPrivacyCenter/utils/toast.ts +0 -130
  241. package/src/index.ts +0 -19
  242. package/src/privacy-center.ts +0 -113
  243. package/src/shared/api-errors.ts +0 -180
  244. package/src/types/css.d.ts +0 -4
  245. package/src/types/images.d.ts +0 -19
  246. package/src/types/react-jsx.d.ts +0 -26
  247. package/tests/DataAvailabilityContext.test.tsx +0 -123
  248. package/tests/Form.test.tsx +0 -1287
  249. package/tests/ProductSelectionSection.test.tsx +0 -328
  250. package/tests/RequestSubmit.test.tsx +0 -135
  251. package/tests/consentClient.test.ts +0 -171
  252. package/tests/manageConsentServer.test.ts +0 -38
  253. package/tests/mocks.ts +0 -257
  254. package/tests/resolveContactFromJwt.test.ts +0 -44
  255. package/tests/setup.ts +0 -16
  256. package/tsconfig.json +0 -16
  257. package/tsup.config.ts +0 -31
  258. package/vitest.config.ts +0 -16
@@ -1,97 +0,0 @@
1
- import { useTranslation } from 'react-i18next';
2
- import {
3
- IoCheckmarkCircle, IoCloseCircle, IoAlertCircle,
4
- } from 'react-icons/io5';
5
- import type { MessageItemProps } from '../../lib/types';
6
- import { STATUS_COLORS } from '../../lib/constants';
7
- import { formatMessageTime } from './utils';
8
- import { DocumentRequestCard } from './DocumentRequestCard';
9
- import { StatusEvent } from './StatusEvent';
10
- import { ChatBubble } from './ChatBubble';
11
-
12
- export const MessageItem = ({
13
- message,
14
- onUploadForRequest,
15
- isSubmittingForRequest,
16
- isCaseFinalized,
17
- }: MessageItemProps) => {
18
- const { t } = useTranslation();
19
- const isPrincipal = message.sender_role === 'data_principal';
20
- const timestamp = formatMessageTime(message.created_at);
21
- const senderLabel = isPrincipal ? t('senderYou') : message.triggered_by_email || t('senderPrivacyTeam');
22
-
23
- switch (message.message_type) {
24
- case 'document_requested':
25
- return (
26
- <>
27
- {message.body && (
28
- <div className="pc-chat-bubble-wrap pc-chat-bubble-wrap--received">
29
- <span className="pc-chat-sender">
30
- {senderLabel} · {timestamp}
31
- </span>
32
- <div className="pc-chat-bubble pc-chat-bubble--received">
33
- {message.body}
34
- </div>
35
- </div>
36
- )}
37
- <DocumentRequestCard
38
- message={message}
39
- onUpload={onUploadForRequest}
40
- isSubmitting={isSubmittingForRequest}
41
- isCaseFinalized={isCaseFinalized}
42
- />
43
- </>
44
- );
45
-
46
- case 'document_approved':
47
- return (
48
- <StatusEvent
49
- icon={<IoCheckmarkCircle size={18} />}
50
- color={STATUS_COLORS.success.color}
51
- bgColor={STATUS_COLORS.success.bg}
52
- borderColor={STATUS_COLORS.success.border}
53
- text={t('documentAccepted')}
54
- timestamp={timestamp}
55
- />
56
- );
57
-
58
- case 'document_rejected':
59
- return (
60
- <StatusEvent
61
- icon={<IoCloseCircle size={18} />}
62
- color={STATUS_COLORS.error.color}
63
- bgColor={STATUS_COLORS.error.bg}
64
- borderColor={STATUS_COLORS.error.border}
65
- text={t('documentRejected')}
66
- subText={message.document_request_metadata?.rejection_reason}
67
- timestamp={timestamp}
68
- />
69
- );
70
-
71
- case 'document_replacement_requested':
72
- return (
73
- <StatusEvent
74
- icon={<IoAlertCircle size={18} />}
75
- color={STATUS_COLORS.warning.color}
76
- bgColor={STATUS_COLORS.warning.bg}
77
- borderColor={STATUS_COLORS.warning.border}
78
- text={t('replacementRequested')}
79
- subText={message.body}
80
- timestamp={timestamp}
81
- />
82
- );
83
-
84
- case 'document_submitted':
85
- case 'document_replaced':
86
- case 'message_sent':
87
- default:
88
- return (
89
- <ChatBubble
90
- message={message}
91
- isPrincipal={isPrincipal}
92
- senderLabel={senderLabel}
93
- timestamp={timestamp}
94
- />
95
- );
96
- }
97
- };
@@ -1,156 +0,0 @@
1
- import { useState, useMemo, useCallback } from 'react';
2
- import { useTranslation } from 'react-i18next';
3
- import { IoDocumentText, IoRefresh } from 'react-icons/io5';
4
- import { PCText, PCLoader } from '../../ui';
5
- import { useOrganization } from '../../context/OrganizationContext';
6
- import { useAuth } from '../../context/AuthContext';
7
- import {
8
- useCaseMessages,
9
- useSendCaseMessage,
10
- useUploadCaseDocument,
11
- useSubmitDocumentForRequest,
12
- } from '../../lib/queries';
13
- import { STATUS_COLORS, useCaseFinalizedTooltip } from '../../lib/constants';
14
- import { isRefreshBlocked } from '../../lib/utils';
15
- import type { MessagesTabProps } from '../../lib/types';
16
- import { MessageItem } from './MessageItem';
17
- import { MessageComposer } from './MessageComposer';
18
- import { useMessagePolling } from './useMessagePolling';
19
- import { useFileUpload } from './useFileUpload';
20
- import { isTerminalCaseStatus } from './utils';
21
-
22
- export const MessagesTab = ({ caseUuid, caseStatus }: MessagesTabProps) => {
23
- const isCaseFinalized = isTerminalCaseStatus(caseStatus);
24
- const { t } = useTranslation();
25
- const caseFinalizedTooltip = useCaseFinalizedTooltip();
26
- const { organization } = useOrganization();
27
- const { accessToken, refreshToken, onError, updateTokens } = useAuth();
28
- const authContext = useMemo(
29
- () => ({ accessToken, refreshToken, onError, updateTokens }),
30
- [accessToken, refreshToken, onError, updateTokens]
31
- );
32
-
33
- const organizationId = organization?.uuid;
34
- const workspaceId = organization?.workspaces[0]?.uuid;
35
-
36
- const { data: messages = [], isLoading, isError, isFetching, refetch } = useCaseMessages(
37
- organizationId, workspaceId, caseUuid, authContext
38
- );
39
-
40
- const sendMutation = useSendCaseMessage(organizationId, workspaceId, caseUuid, authContext);
41
- const uploadMutation = useUploadCaseDocument(organizationId, workspaceId, caseUuid, authContext);
42
- const submitMutation = useSubmitDocumentForRequest(organizationId, workspaceId, caseUuid, authContext);
43
-
44
- const isPollingPaused = useCallback(() => isRefreshBlocked(authContext), [authContext]);
45
- const { scrollContainerRef, handleScroll, scrollToBottom } = useMessagePolling(refetch, messages, isPollingPaused);
46
-
47
- const {
48
- pendingUpload, setPendingUpload, submittingForRequest,
49
- attachInputRef, submitInputRef,
50
- handleAttachFile, handleSubmitInputChange, triggerUploadForRequest,
51
- } = useFileUpload(uploadMutation, submitMutation, refetch, scrollToBottom);
52
-
53
- const [messageText, setMessageText] = useState('');
54
-
55
- const handleSend = useCallback(() => {
56
- if (sendMutation.isPending || uploadMutation.isPending) return;
57
- const trimmedBody = messageText.trim();
58
- if (!trimmedBody && !pendingUpload) return;
59
- sendMutation.mutate(
60
- { body: trimmedBody, documentUuids: pendingUpload ? [pendingUpload.uuid] : [] },
61
- {
62
- onSuccess: () => {
63
- setMessageText('');
64
- setPendingUpload(null);
65
- scrollToBottom();
66
- refetch();
67
- },
68
- }
69
- );
70
- }, [messageText, pendingUpload, sendMutation, uploadMutation, refetch, setPendingUpload, scrollToBottom]);
71
-
72
- const isSending = sendMutation.isPending;
73
- const isUploading = uploadMutation.isPending;
74
-
75
- return (
76
- <div className="pc-messages-container">
77
- {/* Hidden file inputs */}
78
- <input ref={attachInputRef} type="file" className="pc-hidden" onChange={handleAttachFile} />
79
- <input ref={submitInputRef} type="file" className="pc-hidden" onChange={handleSubmitInputChange} />
80
-
81
- {/* Secure notice */}
82
- <div
83
- className="pc-messages-notice"
84
- style={{
85
- backgroundColor: STATUS_COLORS.infoBanner.bg,
86
- borderBottom: `1px solid ${STATUS_COLORS.infoBanner.border}`,
87
- color: STATUS_COLORS.infoBanner.color,
88
- }}
89
- >
90
- <span>🔒</span>
91
- <span className="pc-messages-notice-text">
92
- {isCaseFinalized ? caseFinalizedTooltip : t('secureMessagesNotice')}
93
- </span>
94
- <button
95
- type="button"
96
- onClick={() => refetch()}
97
- disabled={isFetching}
98
- aria-label={t('refreshMessages', 'Refresh messages')}
99
- title={t('refreshMessages', 'Refresh messages')}
100
- className="pc-messages-refresh-btn"
101
- style={{ color: STATUS_COLORS.infoBanner.color }}
102
- >
103
- <IoRefresh
104
- size={16}
105
- style={{ animation: isFetching ? 'pc-spin 1s linear infinite' : 'none' }}
106
- />
107
- </button>
108
- </div>
109
-
110
- {/* Messages list */}
111
- <div
112
- ref={scrollContainerRef}
113
- onScroll={handleScroll}
114
- className="pc-messages-list"
115
- >
116
- {isLoading && (
117
- <div className="pc-messages-center">
118
- <PCLoader variant="spinner" size="md" />
119
- </div>
120
- )}
121
- {isError && (
122
- <div className="pc-messages-center-text">
123
- <PCText size="sm" color="secondary">{t('errorLoadingMessages')}</PCText>
124
- </div>
125
- )}
126
- {!isLoading && !isError && messages.length === 0 && (
127
- <div className="pc-messages-empty">
128
- <IoDocumentText size={40} className="pc-messages-empty-icon" />
129
- <PCText size="sm" color="secondary">{t('noMessagesYet')}</PCText>
130
- </div>
131
- )}
132
- {messages.map((msg) => (
133
- <MessageItem
134
- key={msg.uuid}
135
- message={msg}
136
- onUploadForRequest={triggerUploadForRequest}
137
- isSubmittingForRequest={submittingForRequest === msg.uuid}
138
- isCaseFinalized={isCaseFinalized}
139
- />
140
- ))}
141
- </div>
142
-
143
- <MessageComposer
144
- messageText={messageText}
145
- onMessageTextChange={setMessageText}
146
- pendingUpload={pendingUpload}
147
- onRemovePendingUpload={() => setPendingUpload(null)}
148
- onAttachClick={() => attachInputRef.current?.click()}
149
- onSend={handleSend}
150
- isSending={isSending}
151
- isUploading={isUploading}
152
- isCaseFinalized={isCaseFinalized}
153
- />
154
- </div>
155
- );
156
- };
@@ -1,171 +0,0 @@
1
- import { useTranslation } from 'react-i18next';
2
- import { PCText, PCBadge, PCTable } from '../../ui';
3
- import { formatDate } from '../utils';
4
- import type { RequestDetailsTabProps, RawPurposeWrapper, DataElement, UpdateCorrectionDataItem, GrievanceTypeElement } from '../../lib/types';
5
- import { getCaseStatusVariant, formatCaseStatus } from './utils';
6
-
7
- export const RequestDetailsTab = ({
8
- selectedCase,
9
- request_details,
10
- requestTypeLabel,
11
- }: RequestDetailsTabProps) => {
12
- const { t } = useTranslation();
13
- return (
14
- <div className="pc-request-details">
15
- {/* Summary card */}
16
- <div className="pc-request-summary-card">
17
- <div className="pc-case-details-grid pc-request-summary-grid">
18
- <div>
19
- <PCText size="xs" weight="medium" color="secondary" className="pc-request-field-label">
20
- {t('requestType')}
21
- </PCText>
22
- <PCText size="sm" weight="semibold" className="pc-request-field-value--capitalize">
23
- {requestTypeLabel}
24
- </PCText>
25
- </div>
26
- <div>
27
- <PCText size="xs" weight="medium" color="secondary" className="pc-request-field-label">
28
- {t('status')}
29
- </PCText>
30
- <PCBadge variant={getCaseStatusVariant(selectedCase.status)} size="sm" className="pc-status-badge">
31
- {selectedCase.status_display || formatCaseStatus(selectedCase.status)}
32
- </PCBadge>
33
- </div>
34
- <div>
35
- <PCText size="xs" weight="medium" color="secondary" className="pc-request-field-label">
36
- {t('createdAt')}
37
- </PCText>
38
- <PCText size="sm" weight="medium" className="pc-request-field-value">
39
- {formatDate(selectedCase.created_at)}
40
- </PCText>
41
- </div>
42
- {selectedCase.completed_at && (
43
- <div>
44
- <PCText size="xs" weight="medium" color="secondary" className="pc-request-field-label">
45
- {t('completedAt')}
46
- </PCText>
47
- <PCText size="sm" weight="medium" className="pc-request-field-value">
48
- {formatDate(selectedCase.completed_at)}
49
- </PCText>
50
- </div>
51
- )}
52
- </div>
53
- </div>
54
-
55
- {/* Description */}
56
- {(selectedCase.description_display || selectedCase.description) && (
57
- <div className="pc-request-description">
58
- <PCText size="sm" weight="semibold" className="pc-request-description-title">
59
- {t('descriptionLabel')}
60
- </PCText>
61
- <PCText size="sm" color="secondary" className="pc-request-description-text">
62
- {selectedCase.description_display || selectedCase.description}
63
- </PCText>
64
- </div>
65
- )}
66
-
67
- {/* Request specifics */}
68
- {request_details && (
69
- <div className="pc-request-specifics">
70
- <div className="pc-request-section-divider">
71
- <span className="pc-request-section-title">{t('requestSpecifics')}</span>
72
- </div>
73
-
74
- {request_details.purposes && request_details.purposes.length > 0 && (
75
- <div>
76
- <PCText size="sm" weight="semibold" className="pc-request-section-heading">
77
- {t('purposesInvolved')}
78
- </PCText>
79
- <ul className="pc-request-purpose-list">
80
- {request_details.purposes.map((p: RawPurposeWrapper) => (
81
- <li key={p.purpose?.uuid} className="pc-request-purpose-item">
82
- <div className="pc-request-purpose-name">
83
- {p.purpose?.name}
84
- </div>
85
- {p.purpose?.description && (
86
- <div className="pc-request-purpose-desc">
87
- {p.purpose.description}
88
- </div>
89
- )}
90
- {p.purpose?.data_elements && p.purpose.data_elements.some((de: DataElement) => de.selected) && (
91
- <div className="pc-request-data-elements">
92
- {p.purpose.data_elements.filter((de: DataElement) => de.selected).map((de: DataElement) => (
93
- <PCBadge key={de.uuid} variant="secondary" size="sm" className="pc-status-badge">{de.name}</PCBadge>
94
- ))}
95
- </div>
96
- )}
97
- </li>
98
- ))}
99
- </ul>
100
- </div>
101
- )}
102
-
103
- {request_details.correction_data && request_details.correction_data.length > 0 && (
104
- <div>
105
- <PCText size="sm" weight="semibold" className="pc-request-section-heading">
106
- {t('dataToCorrect')}
107
- </PCText>
108
- <div className="pcOverflowXAuto">
109
- <div className="pc-request-table-wrap">
110
- <PCTable className="pc-request-table">
111
- <PCTable.Header className="pc-request-table-header">
112
- <PCTable.Row>
113
- {[t('field'), t('currentValue'), t('newValue')].map((h) => (
114
- <PCTable.Head key={h} className="pc-request-table-head">
115
- {h}
116
- </PCTable.Head>
117
- ))}
118
- </PCTable.Row>
119
- </PCTable.Header>
120
- <PCTable.Body>
121
- {request_details.correction_data.map((item: UpdateCorrectionDataItem) => (
122
- <PCTable.Row key={item.name} className="pc-request-table-row">
123
- <PCTable.Cell className="pc-request-table-cell pc-request-table-cell--name">{item.name}</PCTable.Cell>
124
- <PCTable.Cell className="pc-request-table-cell pc-request-table-cell--value">{item.curr_value || '-'}</PCTable.Cell>
125
- <PCTable.Cell className="pc-request-table-cell pc-request-table-cell--value">{item.new_value || '-'}</PCTable.Cell>
126
- </PCTable.Row>
127
- ))}
128
- </PCTable.Body>
129
- </PCTable>
130
- </div>
131
- </div>
132
- </div>
133
- )}
134
-
135
- {request_details.nomination_data && (
136
- <div>
137
- <PCText size="sm" weight="semibold" className="pc-request-section-heading">
138
- {t('nomination')}
139
- </PCText>
140
- <div className="pc-request-nomination-card">
141
- <div className="pc-request-nomination-field">
142
- <PCText size="xs" weight="medium" color="secondary">{t('nomineeEmail')}</PCText>
143
- <PCText size="sm" weight="medium" className="pc-request-field-value">{request_details.nomination_data.nominee_email || '-'}</PCText>
144
- </div>
145
- <div className="pc-request-nomination-field">
146
- <PCText size="xs" weight="medium" color="secondary">{t('nomineeMobile')}</PCText>
147
- <PCText size="sm" weight="medium" className="pc-request-field-value">{request_details.nomination_data.nominee_mobile || '-'}</PCText>
148
- </div>
149
- </div>
150
- </div>
151
- )}
152
-
153
- {request_details.grievance_types && request_details.grievance_types.length > 0 && (
154
- <div>
155
- <PCText size="sm" weight="semibold" className="pc-request-section-heading">
156
- {t('grievanceTypes')}
157
- </PCText>
158
- <div className="pc-request-grievance-wrap">
159
- {request_details.grievance_types.map((g: GrievanceTypeElement) => (
160
- <PCBadge key={g.grievance} variant="secondary" size="sm" className="pc-status-badge">
161
- {g.grievance?.replace('_', ' ')}
162
- </PCBadge>
163
- ))}
164
- </div>
165
- </div>
166
- )}
167
- </div>
168
- )}
169
- </div>
170
- );
171
- };
@@ -1,23 +0,0 @@
1
- import type { StatusEventProps } from '../../lib/types';
2
-
3
- export const StatusEvent = ({
4
- icon, color, bgColor, borderColor, text, subText, timestamp,
5
- }: StatusEventProps) => {
6
- return (
7
- <div className="pc-status-event">
8
- <div
9
- className="pc-status-event-pill"
10
- style={{ backgroundColor: bgColor, border: `1px solid ${borderColor}`, color }}
11
- >
12
- {icon}
13
- <span>{text}</span>
14
- </div>
15
- {subText && (
16
- <div className="pc-status-event-sub" style={{ color }}>{subText}</div>
17
- )}
18
- <span className="pc-status-event-time">
19
- {timestamp}
20
- </span>
21
- </div>
22
- );
23
- };
@@ -1,116 +0,0 @@
1
- import { useState, useRef, useCallback } from 'react';
2
- import type { PendingUpload } from '../../lib/types';
3
- import { toast } from '../../utils/toast';
4
- import { validateUploadFile, getUploadErrorMessage } from './utils';
5
-
6
- type UploadMutation = {
7
- mutate: (file: File, opts: {
8
- onSuccess: (result: { uuid: string; file_name: string; file_size: number } | null) => void;
9
- onError: (error: unknown) => void;
10
- }) => void;
11
- isPending: boolean;
12
- };
13
-
14
- type SubmitMutation = {
15
- mutate: (params: { requestEventUuid: string; documentUuid: string; body: string }, opts: {
16
- onSuccess: () => void;
17
- onError: () => void;
18
- }) => void;
19
- };
20
-
21
- export function useFileUpload(
22
- uploadMutation: UploadMutation,
23
- submitMutation: SubmitMutation,
24
- refetch: () => void,
25
- scrollToBottom: () => void,
26
- ) {
27
- const [pendingUpload, setPendingUpload] = useState<PendingUpload | null>(null);
28
- const [submittingForRequest, setSubmittingForRequest] = useState<string | null>(null);
29
-
30
- const attachInputRef = useRef<HTMLInputElement>(null);
31
- const submitInputRef = useRef<HTMLInputElement>(null);
32
- const pendingRequestRef = useRef<string | null>(null);
33
-
34
- const handleAttachFile = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
35
- const file = e.target.files?.[0];
36
- if (!file) return;
37
- e.target.value = '';
38
- const validationError = validateUploadFile(file);
39
- if (validationError) {
40
- toast.error(validationError);
41
- return;
42
- }
43
- uploadMutation.mutate(file, {
44
- onSuccess: (result) => {
45
- if (result) {
46
- setPendingUpload({ uuid: result.uuid, file_name: result.file_name, file_size: result.file_size });
47
- toast.success(`"${result.file_name}" uploaded successfully`);
48
- } else {
49
- toast.error('Document upload failed. Please try again.');
50
- }
51
- },
52
- onError: (error) => {
53
- toast.error(getUploadErrorMessage(error));
54
- },
55
- });
56
- }, [uploadMutation]);
57
-
58
- const handleSubmitForRequest = useCallback((requestEventUuid: string, file: File) => {
59
- const validationError = validateUploadFile(file);
60
- if (validationError) {
61
- toast.error(validationError);
62
- return;
63
- }
64
- setSubmittingForRequest(requestEventUuid);
65
- uploadMutation.mutate(file, {
66
- onSuccess: (uploaded) => {
67
- if (!uploaded) {
68
- setSubmittingForRequest(null);
69
- toast.error('Document upload failed. Please try again.');
70
- return;
71
- }
72
- toast.success(`"${uploaded.file_name}" uploaded successfully`);
73
- submitMutation.mutate(
74
- { requestEventUuid, documentUuid: uploaded.uuid, body: '' },
75
- {
76
- onSuccess: () => { setSubmittingForRequest(null); scrollToBottom(); refetch(); },
77
- onError: () => {
78
- setSubmittingForRequest(null);
79
- toast.error('Failed to submit document. Please try again.');
80
- },
81
- }
82
- );
83
- },
84
- onError: (error) => {
85
- setSubmittingForRequest(null);
86
- toast.error(getUploadErrorMessage(error));
87
- },
88
- });
89
- }, [uploadMutation, submitMutation, refetch, scrollToBottom]);
90
-
91
- const handleSubmitInputChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
92
- const file = e.target.files?.[0];
93
- e.target.value = '';
94
- const requestUuid = pendingRequestRef.current;
95
- pendingRequestRef.current = null;
96
- if (file && requestUuid) {
97
- handleSubmitForRequest(requestUuid, file);
98
- }
99
- }, [handleSubmitForRequest]);
100
-
101
- const triggerUploadForRequest = useCallback((requestEventUuid: string) => {
102
- pendingRequestRef.current = requestEventUuid;
103
- submitInputRef.current?.click();
104
- }, []);
105
-
106
- return {
107
- pendingUpload,
108
- setPendingUpload,
109
- submittingForRequest,
110
- attachInputRef,
111
- submitInputRef,
112
- handleAttachFile,
113
- handleSubmitInputChange,
114
- triggerUploadForRequest,
115
- };
116
- }
@@ -1,43 +0,0 @@
1
- import { useEffect, useLayoutEffect, useRef, useCallback } from 'react';
2
- import type { CaseMessage } from '../../lib/types';
3
-
4
- export function useMessagePolling(
5
- refetch: () => void,
6
- messages: CaseMessage[],
7
- isPaused?: () => boolean,
8
- ) {
9
- const scrollContainerRef = useRef<HTMLDivElement>(null);
10
- const isNearBottomRef = useRef(true);
11
- const shouldAutoScrollRef = useRef(true);
12
- // Latest pause predicate, read inside the interval without resetting it.
13
- const isPausedRef = useRef(isPaused);
14
- isPausedRef.current = isPaused;
15
-
16
- useEffect(() => {
17
- const interval = setInterval(() => {
18
- // Don't poll while auth is terminally failed / backing off (incident 2026-06-22).
19
- if (!isPausedRef.current?.()) refetch();
20
- }, 30_000);
21
- return () => clearInterval(interval);
22
- }, [refetch]);
23
-
24
- const handleScroll = useCallback(() => {
25
- const el = scrollContainerRef.current;
26
- if (!el) return;
27
- isNearBottomRef.current = el.scrollHeight - el.scrollTop - el.clientHeight < 100;
28
- }, []);
29
-
30
- useLayoutEffect(() => {
31
- const el = scrollContainerRef.current;
32
- if (el && (isNearBottomRef.current || shouldAutoScrollRef.current)) {
33
- el.scrollTop = el.scrollHeight;
34
- shouldAutoScrollRef.current = false;
35
- }
36
- }, [messages]);
37
-
38
- const scrollToBottom = useCallback(() => {
39
- shouldAutoScrollRef.current = true;
40
- }, []);
41
-
42
- return { scrollContainerRef, handleScroll, scrollToBottom };
43
- }
@@ -1,71 +0,0 @@
1
- import { MAX_FILE_SIZE, ALLOWED_MIME_TYPES, TERMINAL_CASE_STATUSES } from '../../lib/constants';
2
- import type { CaseStatusVariant } from '../../lib/types';
3
-
4
- export const isTerminalCaseStatus = (status: string | undefined | null): boolean => {
5
- if (!status) {
6
- return false;
7
- }
8
- return (TERMINAL_CASE_STATUSES as readonly string[]).includes(status.toLowerCase());
9
- };
10
-
11
- export const getVar = (v: string) => `var(${v})`;
12
-
13
- export const getCaseStatusVariant = (status: string): CaseStatusVariant => {
14
- const normalized = status.toLowerCase().replace(/_/g, '');
15
- if (normalized === 'completed') {
16
- return 'success';
17
- }
18
- if (normalized === 'rejected' || normalized === 'declined') {
19
- return 'error';
20
- }
21
- if (normalized === 'processing' || normalized === 'inprogress' || normalized === 'expired') {
22
- return 'warning';
23
- }
24
- if (normalized === 'initiated') {
25
- return 'info';
26
- }
27
- return 'secondary';
28
- };
29
-
30
- export const formatCaseStatus = (s: string) =>
31
- s.split('_').map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
32
-
33
- export const getDownloadUrl = (fileUrl: { url?: string; download_url?: string } | null | undefined): string | null =>
34
- fileUrl ? (fileUrl.url || fileUrl.download_url || null) : null;
35
-
36
- /** Formats a UTC ISO string to local timezone display, e.g. "Mar 24, 2:14 PM" */
37
- export function formatMessageTime(isoString: string): string {
38
- const d = new Date(isoString);
39
- return d.toLocaleDateString('en-US', { month: 'short', day: 'numeric' })
40
- + ', '
41
- + d.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', hour12: true });
42
- }
43
-
44
- export function formatFileSize(bytes: number): string {
45
- if (bytes < 1024) return `${bytes} B`;
46
- if (bytes < 1024 * 1024) return `${Math.round(bytes / 1024)} KB`;
47
- return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
48
- }
49
-
50
- export function validateUploadFile(file: File): string | null {
51
- if (file.size === 0) return 'File is empty. Please select a valid file.';
52
- if (file.size > MAX_FILE_SIZE) return 'File size must not exceed 10 MB.';
53
- if (!file.type || file.type.trim() === '') return 'Could not determine file type. Please try a different file.';
54
- if (!ALLOWED_MIME_TYPES.includes(file.type))
55
- return 'File type not supported. Allowed: PDF, JPG, PNG, WEBP, DOC, DOCX, XLS, XLSX, TXT, CSV.';
56
- return null;
57
- }
58
-
59
- export function getUploadErrorMessage(error: unknown): string {
60
- if (!(error instanceof Error)) return 'Something went wrong. Please try again.';
61
- const msg = error.message;
62
- if (msg.includes('[409]') || msg.includes('document_already_exists'))
63
- return 'This document has already been uploaded.';
64
- if (msg.includes('[422]'))
65
- return 'File format not accepted. Please upload a PDF, image, or Office document.';
66
- if (msg.includes('[400]') || msg.includes('empty_file'))
67
- return 'File is empty or the request is invalid.';
68
- if (msg.includes('[500]'))
69
- return 'Something went wrong on the server. Please try again.';
70
- return 'Document upload failed. Please try again.';
71
- }