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

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 (262) hide show
  1. package/NOTICE.md +17 -0
  2. package/README.md +141 -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 +41 -4
  10. package/dist/index.d.ts +41 -4
  11. package/dist/index.js +881 -416
  12. package/dist/index.mjs +502 -253
  13. package/dist/montserrat.generated-NBTECYRW.mjs +22 -0
  14. package/dist/privacy-center.d.mts +51 -11
  15. package/dist/privacy-center.d.ts +51 -11
  16. package/dist/privacy-center.js +252 -136
  17. package/dist/privacy-center.mjs +251 -137
  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 -343
  25. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.test.tsx +0 -934
  26. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.tsx +0 -2160
  27. package/src/RedactoNoticeAssisted/api/index.ts +0 -275
  28. package/src/RedactoNoticeAssisted/api/types.ts +0 -182
  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 -1408
  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 -26
  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 -512
  40. package/src/RedactoNoticeConsent/api/types.ts +0 -469
  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 -95
  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 -687
  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 -695
  72. package/src/RedactoPrivacyCenter/api/client.ts +0 -911
  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 -268
  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 -245
  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 -1206
  112. package/src/RedactoPrivacyCenter/components/ConsentManagerCells.tsx +0 -218
  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 -95
  146. package/src/RedactoPrivacyCenter/components/SelectUserGate.tsx +0 -187
  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 -759
  169. package/src/RedactoPrivacyCenter/lib/consent-manager/utils.tsx +0 -67
  170. package/src/RedactoPrivacyCenter/lib/constants.ts +0 -276
  171. package/src/RedactoPrivacyCenter/lib/i18n.ts +0 -81
  172. package/src/RedactoPrivacyCenter/lib/locales.ts +0 -102
  173. package/src/RedactoPrivacyCenter/lib/queries.ts +0 -141
  174. package/src/RedactoPrivacyCenter/lib/types.ts +0 -876
  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 -342
  181. package/src/RedactoPrivacyCenter/locales/bn/translation.json +0 -342
  182. package/src/RedactoPrivacyCenter/locales/brx/translation.json +0 -342
  183. package/src/RedactoPrivacyCenter/locales/doi/translation.json +0 -342
  184. package/src/RedactoPrivacyCenter/locales/en/translation.json +0 -357
  185. package/src/RedactoPrivacyCenter/locales/gom/translation.json +0 -342
  186. package/src/RedactoPrivacyCenter/locales/gu/translation.json +0 -342
  187. package/src/RedactoPrivacyCenter/locales/hi/translation.json +0 -345
  188. package/src/RedactoPrivacyCenter/locales/kn/translation.json +0 -342
  189. package/src/RedactoPrivacyCenter/locales/ks/translation.json +0 -342
  190. package/src/RedactoPrivacyCenter/locales/mai/translation.json +0 -342
  191. package/src/RedactoPrivacyCenter/locales/ml/translation.json +0 -342
  192. package/src/RedactoPrivacyCenter/locales/mni-Mtei/translation.json +0 -342
  193. package/src/RedactoPrivacyCenter/locales/mr/translation.json +0 -342
  194. package/src/RedactoPrivacyCenter/locales/ne/translation.json +0 -342
  195. package/src/RedactoPrivacyCenter/locales/or/translation.json +0 -342
  196. package/src/RedactoPrivacyCenter/locales/pa/translation.json +0 -342
  197. package/src/RedactoPrivacyCenter/locales/sa/translation.json +0 -342
  198. package/src/RedactoPrivacyCenter/locales/sat/translation.json +0 -342
  199. package/src/RedactoPrivacyCenter/locales/sd/translation.json +0 -342
  200. package/src/RedactoPrivacyCenter/locales/ta/translation.json +0 -342
  201. package/src/RedactoPrivacyCenter/locales/te/translation.json +0 -342
  202. package/src/RedactoPrivacyCenter/locales/ur/translation.json +0 -342
  203. package/src/RedactoPrivacyCenter/styles/applyBrandingTheme.ts +0 -66
  204. package/src/RedactoPrivacyCenter/styles/base.css +0 -117
  205. package/src/RedactoPrivacyCenter/styles/injectStyles.ts +0 -3108
  206. package/src/RedactoPrivacyCenter/styles/pcStyles.ts +0 -831
  207. package/src/RedactoPrivacyCenter/styles/responsive.ts +0 -138
  208. package/src/RedactoPrivacyCenter/styles/variables.css +0 -96
  209. package/src/RedactoPrivacyCenter/table/AdvancedTable.tsx +0 -387
  210. package/src/RedactoPrivacyCenter/table/AdvancedTablePagination.tsx +0 -468
  211. package/src/RedactoPrivacyCenter/table/index.ts +0 -2
  212. package/src/RedactoPrivacyCenter/types/images.d.ts +0 -29
  213. package/src/RedactoPrivacyCenter/ui/Footer.tsx +0 -69
  214. package/src/RedactoPrivacyCenter/ui/FormBlockWrapper.tsx +0 -54
  215. package/src/RedactoPrivacyCenter/ui/PCAccordion.tsx +0 -93
  216. package/src/RedactoPrivacyCenter/ui/PCActionIcon.tsx +0 -47
  217. package/src/RedactoPrivacyCenter/ui/PCAvatar.test.tsx +0 -83
  218. package/src/RedactoPrivacyCenter/ui/PCAvatar.tsx +0 -93
  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/shared/notice-consent-status.ts +0 -190
  245. package/src/types/css.d.ts +0 -4
  246. package/src/types/images.d.ts +0 -19
  247. package/src/types/react-jsx.d.ts +0 -26
  248. package/tests/DataAvailabilityContext.test.tsx +0 -123
  249. package/tests/Form.test.tsx +0 -1287
  250. package/tests/ManageConsentErrorMapping.test.tsx +0 -85
  251. package/tests/ProductSelectionSection.test.tsx +0 -328
  252. package/tests/RequestSubmit.test.tsx +0 -135
  253. package/tests/RevocablePurpose.test.tsx +0 -146
  254. package/tests/RevokeWarningMessage.test.tsx +0 -151
  255. package/tests/consentClient.test.ts +0 -217
  256. package/tests/manageConsentServer.test.ts +0 -38
  257. package/tests/mocks.ts +0 -257
  258. package/tests/resolveContactFromJwt.test.ts +0 -44
  259. package/tests/setup.ts +0 -16
  260. package/tsconfig.json +0 -16
  261. package/tsup.config.ts +0 -31
  262. package/vitest.config.ts +0 -16
@@ -1,334 +0,0 @@
1
- import { useState, useMemo, useEffect } from 'react';
2
- import { useTranslation } from 'react-i18next';
3
- import { PCButton, PCText, PCModal, PCAccordion, PCBadge, PCCheckbox } from '../ui';
4
- import { pcStyles } from '../styles/pcStyles';
5
- import { ChevronDownIcon } from 'lucide-react';
6
- import { PiWarningCircleBold } from 'react-icons/pi';
7
- import type { ModifyConsentModalProps } from './types';
8
- import { ConsentStatusEnum } from '../lib/types';
9
- import type { ConsentAction } from '../lib/types';
10
-
11
- export const ModifyConsentModal = ({
12
- isOpen,
13
- onClose,
14
- selectedRecord,
15
- isLoading,
16
- onManageConsent,
17
- }: ModifyConsentModalProps) => {
18
- const { t } = useTranslation();
19
- const [isAccordionOpen, setIsAccordionOpen] = useState(false);
20
- const [selectedDataElementUuids, setSelectedDataElementUuids] = useState<string[]>([]);
21
-
22
- const nominatorInfo = selectedRecord?.nominator;
23
- const nominatorLabel = nominatorInfo?.name || nominatorInfo?.email || nominatorInfo?.org_user_id || null;
24
-
25
- const actionConfig = useMemo(() => {
26
- if (!selectedRecord) return null;
27
-
28
- const status = selectedRecord.status;
29
-
30
- if (status === ConsentStatusEnum.ACTIVE) {
31
- return {
32
- action: 'revoke' as ConsentAction,
33
- buttonLabel: t('revokeConsent'),
34
- buttonVariant: 'danger' as const,
35
- warningMessage: selectedRecord.revoke_warning_message || t('revokeConsentWarning'),
36
- description: nominatorLabel
37
- ? t('aboutToModifyConsentOnBehalf', { nominator: nominatorLabel })
38
- : t('aboutToModifyConsent'),
39
- };
40
- }
41
-
42
- if (
43
- status === ConsentStatusEnum.WITHDRAWN ||
44
- status === ConsentStatusEnum.REVOKED
45
- ) {
46
- return {
47
- action: 'regrant' as ConsentAction,
48
- buttonLabel: t('regrantConsent'),
49
- buttonVariant: 'primary' as const,
50
- warningMessage: t('regrantConsentWarning'),
51
- description: nominatorLabel
52
- ? t('aboutToRegrantConsentOnBehalf', { nominator: nominatorLabel })
53
- : t('aboutToRegrantConsent'),
54
- };
55
- }
56
-
57
- if (status === ConsentStatusEnum.EXPIRED) {
58
- return {
59
- action: 'renew' as ConsentAction,
60
- buttonLabel: t('renewConsent'),
61
- buttonVariant: 'primary' as const,
62
- warningMessage: t('renewConsentWarning'),
63
- description: nominatorLabel
64
- ? t('aboutToRenewConsentOnBehalf', { nominator: nominatorLabel })
65
- : t('aboutToRenewConsent'),
66
- };
67
- }
68
-
69
- // DECLINED or unknown statuses — no action available
70
- return null;
71
- }, [selectedRecord, t, nominatorLabel]);
72
-
73
- const isRegrantAction = actionConfig?.action === 'regrant';
74
-
75
- useEffect(() => {
76
- setIsAccordionOpen(isRegrantAction);
77
- }, [selectedRecord, isRegrantAction]);
78
-
79
- const regrantEligibleDataElements = useMemo(
80
- () =>
81
- (selectedRecord?.data_elements || []).filter(
82
- (element) => Boolean(element?.uuid) && element.enabled
83
- ),
84
- [selectedRecord]
85
- );
86
-
87
- const requiredDataElementUuids = useMemo(
88
- () =>
89
- regrantEligibleDataElements
90
- .filter((element) => element.required)
91
- .map((element) => element.uuid),
92
- [regrantEligibleDataElements]
93
- );
94
-
95
- const requiredDataElementUuidSet = useMemo(
96
- () => new Set(requiredDataElementUuids),
97
- [requiredDataElementUuids]
98
- );
99
-
100
- useEffect(() => {
101
- if (isRegrantAction) {
102
- setSelectedDataElementUuids(regrantEligibleDataElements.map((element) => element.uuid));
103
- return;
104
- }
105
- setSelectedDataElementUuids([]);
106
- }, [isRegrantAction, regrantEligibleDataElements]);
107
-
108
- const toggleDataElementSelection = (uuid: string, checked: boolean) => {
109
- if (requiredDataElementUuidSet.has(uuid)) {
110
- return;
111
- }
112
- setSelectedDataElementUuids((prev) => {
113
- if (checked) {
114
- return prev.includes(uuid) ? prev : [...prev, uuid];
115
- }
116
- return prev.filter((item) => item !== uuid);
117
- });
118
- };
119
-
120
- return (
121
- <PCModal
122
- isOpen={isOpen}
123
- onClose={onClose}
124
- closeAriaLabel={t('closeModal')}
125
- title={
126
- <PCText size="base" weight="semibold">
127
- {t('modifyConsent')}
128
- </PCText>
129
- }
130
- >
131
- <div style={{ padding: pcStyles.pMd.padding }}>
132
- {selectedRecord && !actionConfig && (
133
- <PCText size="sm" weight="medium" color="tertiary" style={{ textAlign: 'center', padding: pcStyles.pMd.padding }}>
134
- {t('noActionsAvailable', 'No actions available for this record.')}
135
- </PCText>
136
- )}
137
- {selectedRecord && actionConfig && (
138
- <>
139
- <PCText size="sm" weight="medium" color="secondary" style={{ marginBottom: pcStyles.mbMd.marginBottom }}>
140
- {actionConfig.description}
141
- </PCText>
142
- <div style={{
143
- marginTop: pcStyles.mtMd.marginTop,
144
- borderRadius: pcStyles.borderRadiusMd,
145
- ...pcStyles.bgSecondary,
146
- border: `1px solid ${pcStyles.borderColor}`,
147
- padding: pcStyles.pMd.padding,
148
- ...pcStyles.overflowHidden,
149
- }}>
150
- <PCAccordion style={{ border: 'none', borderRadius: 0 }}>
151
- <PCAccordion.Header
152
- open={isAccordionOpen}
153
- onToggle={() => setIsAccordionOpen(!isAccordionOpen)}
154
- >
155
- {({ open }) => (
156
- <>
157
- <div style={{ flex: 1 }}>
158
- <p style={{
159
- marginBottom: pcStyles.mbXs.marginBottom,
160
- fontSize: pcStyles.textBase.fontSize,
161
- fontWeight: pcStyles.fontWeightSemibold.fontWeight,
162
- color: pcStyles.textPrimary.color,
163
- }}>
164
- {selectedRecord.name}
165
- </p>
166
- <p style={{
167
- textAlign: 'left',
168
- fontSize: pcStyles.textSm.fontSize,
169
- fontWeight: pcStyles.fontWeightMedium.fontWeight,
170
- color: pcStyles.textSecondary.color,
171
- margin: 0,
172
- }}>
173
- {selectedRecord.description}
174
- </p>
175
- </div>
176
- <ChevronDownIcon
177
- size={20}
178
- style={{
179
- transform: open ? 'rotate(0deg)' : 'rotate(-90deg)',
180
- transition: 'transform 0.3s',
181
- color: pcStyles.textSecondary.color,
182
- flexShrink: 0,
183
- marginLeft: pcStyles.mlSm.marginLeft,
184
- }}
185
- />
186
- </>
187
- )}
188
- </PCAccordion.Header>
189
-
190
- <PCAccordion.Body open={isAccordionOpen}>
191
- <div style={{
192
- marginTop: pcStyles.mtSm.marginTop,
193
- paddingTop: pcStyles.ptSm.paddingTop,
194
- ...(!isRegrantAction && { borderTop: `1px solid ${pcStyles.borderColor}` }),
195
- }}>
196
- {isRegrantAction && regrantEligibleDataElements.length > 0 ? (
197
- <div>
198
- <PCText
199
- size="sm"
200
- color="secondary"
201
- style={{ marginTop: 0, marginBottom: pcStyles.mbSm.marginBottom }}
202
- >
203
- {t(
204
- 'selectDataElementsForRegrant',
205
- 'Select the data elements you want to regrant consent for.'
206
- )}
207
- </PCText>
208
- <div style={{ display: 'grid', gap: pcStyles.gapSm.gap }}>
209
- {regrantEligibleDataElements.map((element) => {
210
- const isRequired = requiredDataElementUuidSet.has(element.uuid);
211
- const isChecked = isRequired || selectedDataElementUuids.includes(element.uuid);
212
-
213
- return (
214
- <PCCheckbox
215
- key={element.uuid}
216
- size="md"
217
- checked={isChecked}
218
- disabled={isRequired}
219
- onChange={(event) =>
220
- toggleDataElementSelection(element.uuid, event.target.checked)
221
- }
222
- label={
223
- isRequired
224
- ? `${element.name} (${t('mandatory', 'Mandatory')})`
225
- : element.name
226
- }
227
- labelClassName="text-sm"
228
- style={{ accentColor: pcStyles.primary }}
229
- />
230
- );
231
- })}
232
- </div>
233
- </div>
234
- ) : Array.isArray(selectedRecord.data_elements) &&
235
- selectedRecord.data_elements.filter((el) => el.selected).length > 0 ? (
236
- selectedRecord.data_elements
237
- .filter((el) => el.selected)
238
- .map((i, index, filteredArray) => (
239
- <div
240
- key={index}
241
- style={{
242
- ...pcStyles.flex,
243
- ...pcStyles.itemsCenter,
244
- paddingBottom: index < filteredArray.length - 1 ? pcStyles.pbXs.paddingBottom : 0,
245
- marginBottom: index < filteredArray.length - 1 ? pcStyles.mbXs.marginBottom : 0,
246
- }}
247
- >
248
- <PCBadge renderAsDot size="sm">{''}</PCBadge>
249
- <span style={{
250
- marginLeft: pcStyles.mlSm.marginLeft,
251
- fontSize: pcStyles.textSm.fontSize,
252
- color: pcStyles.textPrimary.color,
253
- fontWeight: pcStyles.fontWeightMedium.fontWeight,
254
- }}>
255
- {i.name}
256
- </span>
257
- </div>
258
- ))
259
- ) : (
260
- <PCText size="sm" color="tertiary">
261
- {t('noDataElementsAvailable')}
262
- </PCText>
263
- )}
264
- </div>
265
- </PCAccordion.Body>
266
- </PCAccordion>
267
- </div>
268
- <div style={{
269
- marginTop: pcStyles.mtLg.marginTop,
270
- ...pcStyles.flex,
271
- ...pcStyles.itemsStart,
272
- ...pcStyles.gapSm,
273
- borderRadius: pcStyles.borderRadiusMd,
274
- border: `1px solid ${pcStyles.warningBorder}`,
275
- backgroundColor: pcStyles.warningBg,
276
- padding: pcStyles.pMd.padding,
277
- lineHeight: 1.5,
278
- }}>
279
- <PiWarningCircleBold
280
- size={20}
281
- style={{
282
- flexShrink: 0,
283
- color: pcStyles.warningText,
284
- marginTop: '2px',
285
- }}
286
- />
287
- <span style={{
288
- fontWeight: pcStyles.fontWeightMedium.fontWeight,
289
- fontSize: pcStyles.textSm.fontSize,
290
- color: pcStyles.warningText,
291
- }}>
292
- {actionConfig.warningMessage}
293
- </span>
294
- </div>
295
-
296
- <div style={{
297
- marginTop: pcStyles.mtLg.marginTop,
298
- ...pcStyles.flex,
299
- ...pcStyles.flexRow,
300
- ...pcStyles.gapSm,
301
- ...pcStyles.justifyEnd,
302
- }}>
303
- <PCButton variant="secondary" onClick={onClose}>
304
- {t('cancel')}
305
- </PCButton>
306
- <PCButton
307
- isLoading={isLoading}
308
- disabled={
309
- !selectedRecord.purpose_uuid ||
310
- (isRegrantAction && selectedDataElementUuids.length === 0)
311
- }
312
- variant={actionConfig.buttonVariant}
313
- onClick={() => {
314
- if (selectedRecord.purpose_uuid) {
315
- const nomContact = selectedRecord.nominator?.email || selectedRecord.nominator?.org_user_id || undefined;
316
- onManageConsent(
317
- selectedRecord.purpose_uuid,
318
- actionConfig.action,
319
- nomContact,
320
- isRegrantAction ? selectedDataElementUuids : undefined,
321
- selectedRecord.product_uuid
322
- );
323
- }
324
- }}
325
- >
326
- {actionConfig.buttonLabel}
327
- </PCButton>
328
- </div>
329
- </>
330
- )}
331
- </div>
332
- </PCModal>
333
- );
334
- };
@@ -1,173 +0,0 @@
1
- import { useState, useCallback, useEffect, useRef } from 'react';
2
- import { useTranslation } from 'react-i18next';
3
- import { IoNotificationsOutline } from 'react-icons/io5';
4
- import { PCPopover } from '../../ui';
5
- import { PCTooltip } from '../../ui/PCTooltip';
6
- import { fetchUnreadCount, fetchNotifications } from '../../lib/api';
7
- import { POLL_INTERVAL, NOTIFICATION_DROPDOWN_LIMIT } from '../../lib/constants';
8
- import { isRefreshBlocked } from '../../lib/utils';
9
- import { useCurrentLanguage } from '../../lib/useCurrentLanguage';
10
- import type { Notification, NotificationCTA } from '../../lib/types';
11
- import { NotificationDropdown } from './NotificationDropdown';
12
- import { useNotificationActions } from './useNotificationActions';
13
-
14
- export const NotificationBell = () => {
15
- const { t } = useTranslation();
16
- const { langParam } = useCurrentLanguage();
17
- const [notifications, setNotifications] = useState<Notification[]>([]);
18
- const [unreadCount, setUnreadCount] = useState(0);
19
- const [isRefreshing, setIsRefreshing] = useState(false);
20
- const pollRef = useRef<ReturnType<typeof setInterval> | null>(null);
21
- const tenantRequestRef = useRef(0);
22
-
23
- const {
24
- organizationId, workspaceId, authContext, consentClient, navigateTo,
25
- handleMarkRead, handleMarkAllRead, handleCTAClick,
26
- } = useNotificationActions();
27
-
28
- const pollUnreadCount = useCallback(async () => {
29
- if (!organizationId || !workspaceId) {
30
- return;
31
- }
32
- // Skip doomed work while auth is terminally failed / backing off (incident 2026-06-22).
33
- if (isRefreshBlocked(authContext)) {
34
- return;
35
- }
36
- const requestId = tenantRequestRef.current;
37
- const result = await fetchUnreadCount(organizationId, workspaceId, authContext, consentClient);
38
- if (requestId !== tenantRequestRef.current) {
39
- return;
40
- }
41
- if (result) {
42
- setUnreadCount(result.count);
43
- }
44
- }, [organizationId, workspaceId, authContext, consentClient]);
45
-
46
- const loadDropdownNotifications = useCallback(async () => {
47
- if (!organizationId || !workspaceId) {
48
- return;
49
- }
50
- const requestId = tenantRequestRef.current;
51
- const result = await fetchNotifications(organizationId, workspaceId, { limit: NOTIFICATION_DROPDOWN_LIMIT, include_summary: true }, authContext, consentClient, langParam);
52
- if (requestId !== tenantRequestRef.current) {
53
- return;
54
- }
55
- if (result) {
56
- setNotifications(result.data);
57
- if (result.summary) {
58
- setUnreadCount(result.summary.unread);
59
- }
60
- }
61
- }, [organizationId, workspaceId, authContext, consentClient, langParam]);
62
-
63
- useEffect(() => {
64
- tenantRequestRef.current += 1;
65
- setNotifications([]);
66
- setUnreadCount(0);
67
- return () => {
68
- tenantRequestRef.current += 1;
69
- };
70
- }, [organizationId, workspaceId]);
71
-
72
- // Keep the interval pointed at the latest poll fn without resetting it (and
73
- // re-firing an immediate poll) each time authContext identity churns — that
74
- // churn was an amplifier in the 2026-06-22 refresh storm.
75
- const pollUnreadCountRef = useRef(pollUnreadCount);
76
- useEffect(() => {
77
- pollUnreadCountRef.current = pollUnreadCount;
78
- }, [pollUnreadCount]);
79
-
80
- useEffect(() => {
81
- if (!organizationId || !workspaceId) {
82
- if (pollRef.current) {
83
- clearInterval(pollRef.current);
84
- pollRef.current = null;
85
- }
86
- return;
87
- }
88
- pollUnreadCountRef.current();
89
- pollRef.current = setInterval(() => pollUnreadCountRef.current(), POLL_INTERVAL);
90
- return () => {
91
- if (pollRef.current) {
92
- clearInterval(pollRef.current);
93
- }
94
- };
95
- }, [organizationId, workspaceId]);
96
-
97
- const onRefresh = useCallback(async () => {
98
- setIsRefreshing(true);
99
- try {
100
- await loadDropdownNotifications();
101
- } finally {
102
- setIsRefreshing(false);
103
- }
104
- }, [loadDropdownNotifications]);
105
-
106
- const onMarkAllRead = useCallback(async () => {
107
- const ok = await handleMarkAllRead();
108
- if (!ok) {
109
- return;
110
- }
111
- setNotifications((prev) => prev.map((n) => ({ ...n, is_read: true })));
112
- setUnreadCount(0);
113
- }, [handleMarkAllRead]);
114
-
115
- const onNotificationClick = useCallback(async (notification: Notification) => {
116
- if (!notification.is_read) {
117
- const ok = await handleMarkRead(notification.uuid);
118
- if (!ok) {
119
- return;
120
- }
121
- setNotifications((prev) => prev.map((n) => n.uuid === notification.uuid ? { ...n, is_read: true } : n));
122
- setUnreadCount((prev) => Math.max(0, prev - 1));
123
- }
124
- }, [handleMarkRead]);
125
-
126
- const onCTAClick = useCallback(async (notification: Notification, cta: NotificationCTA) => {
127
- const result = await handleCTAClick(notification, cta);
128
- if (result === 'acknowledged') {
129
- setNotifications((prev) => prev.map((n) =>
130
- n.uuid === notification.uuid ? { ...n, is_read: true, is_acknowledged: true } : n
131
- ));
132
- setUnreadCount((prev) => Math.max(0, prev - (notification.is_read ? 0 : 1)));
133
- } else if (result === 'opened' || result === 'navigated' || result === 'not_found') {
134
- if (!notification.is_read) {
135
- setNotifications((prev) => prev.map((n) =>
136
- n.uuid === notification.uuid ? { ...n, is_read: true } : n
137
- ));
138
- setUnreadCount((prev) => Math.max(0, prev - 1));
139
- }
140
- }
141
- }, [handleCTAClick]);
142
-
143
- return (
144
- <PCPopover
145
- placement="bottom-end"
146
- shadow="lg"
147
- className="pc-notification-popover-offset"
148
- onOpen={loadDropdownNotifications}
149
- content={
150
- <NotificationDropdown
151
- notifications={notifications}
152
- onMarkAllRead={onMarkAllRead}
153
- onRefresh={onRefresh}
154
- isRefreshing={isRefreshing}
155
- onViewAll={() => navigateTo('notifications')}
156
- onNotificationClick={onNotificationClick}
157
- onCTAClick={onCTAClick}
158
- />
159
- }
160
- >
161
- <PCTooltip content={t('notifications')} placement="bottom" color="invert">
162
- <div className="pc-notification-bell-wrapper">
163
- <button type="button" aria-label={t('notifications')} className="pc-notification-bell-btn">
164
- <IoNotificationsOutline size={18} />
165
- </button>
166
- {unreadCount > 0 && (
167
- <span className="pc-notification-badge">{unreadCount}</span>
168
- )}
169
- </div>
170
- </PCTooltip>
171
- </PCPopover>
172
- );
173
- }
@@ -1,18 +0,0 @@
1
- import type { NotificationCTAButtonProps } from '../../lib/types';
2
- import { CTA_VARIANT_CLASS } from '../../lib/constants';
3
- import { cn } from '../../utils/cn';
4
-
5
- export const NotificationCTAButton = ({ cta, onClick, size = 'lg' }: NotificationCTAButtonProps) => {
6
- const sizeClass = size === 'sm' ? 'pc-notification-cta-sm' : 'pc-notification-cta-lg';
7
- const variantClass = CTA_VARIANT_CLASS[cta.style] ?? CTA_VARIANT_CLASS.secondary;
8
-
9
- return (
10
- <button
11
- type='button'
12
- onClick={onClick}
13
- className={cn('pc-notification-cta', sizeClass, variantClass)}
14
- >
15
- {cta.label}
16
- </button>
17
- );
18
- }
@@ -1,54 +0,0 @@
1
- import { useTranslation } from 'react-i18next';
2
- import type { NotificationDropdownProps } from '../../lib/types';
3
- import { NOTIFICATION_DROPDOWN_LIMIT } from '../../lib/constants';
4
- import { NotificationDropdownItem } from './NotificationDropdownItem';
5
- import { NotificationRefreshButton } from './NotificationRefreshButton';
6
-
7
- export const NotificationDropdown = ({
8
- notifications, onMarkAllRead, onRefresh, isRefreshing, onViewAll, onNotificationClick, onCTAClick,
9
- }: NotificationDropdownProps) => {
10
- const { t } = useTranslation();
11
- const recentNotifications = notifications.slice(0, NOTIFICATION_DROPDOWN_LIMIT);
12
-
13
- return (
14
- <div className="pc-notification-dropdown">
15
- {/* Header */}
16
- <div className="pc-notification-panel-header">
17
- <span className="pc-notification-dropdown-title">{t('notifications')}</span>
18
- <div className="pc-notification-header-actions">
19
- <NotificationRefreshButton isRefreshing={isRefreshing} onRefresh={onRefresh} iconSize={16} />
20
- <button type="button" onClick={onMarkAllRead} className="pc-notification-link-btn">
21
- {t('markAllAsRead')}
22
- </button>
23
- </div>
24
- </div>
25
-
26
- {/* Notification List */}
27
- <div className="pc-notification-dropdown-list">
28
- {recentNotifications.length === 0 ? (
29
- <div className="pc-notification-dropdown-empty-state">{t('noNotificationsYet')}</div>
30
- ) : (
31
- recentNotifications.map((notification) => (
32
- <NotificationDropdownItem
33
- key={notification.uuid}
34
- notification={notification}
35
- onNotificationClick={onNotificationClick}
36
- onCTAClick={onCTAClick}
37
- />
38
- ))
39
- )}
40
- </div>
41
-
42
- {/* Footer */}
43
- <div className="pc-notification-dropdown-footer">
44
- <button
45
- type="button"
46
- onClick={onViewAll}
47
- className="pc-notification-link-btn pc-notification-link-btn-arrow"
48
- >
49
- {t('viewAllNotifications')} →
50
- </button>
51
- </div>
52
- </div>
53
- );
54
- }
@@ -1,57 +0,0 @@
1
- import { useTranslation } from 'react-i18next';
2
- import type { NotificationDropdownItemProps } from '../../lib/types';
3
- import { NotificationIcon } from './NotificationIcon';
4
- import { NotificationCTAButton } from './NotificationCTAButton';
5
- import { formatTimeAgo } from './utils';
6
-
7
- export const NotificationDropdownItem = ({
8
- notification, onNotificationClick, onCTAClick,
9
- }: NotificationDropdownItemProps) => {
10
- const { t } = useTranslation();
11
- const statusLabel = notification.status_label_display || notification.status_label;
12
-
13
- return (
14
- <div
15
- className="pc-notification-dropdown-row"
16
- data-read={notification.is_read ? 'true' : 'false'}
17
- role="button"
18
- tabIndex={0}
19
- onClick={() => onNotificationClick(notification)}
20
- onKeyDown={(e) => {
21
- if (e.currentTarget !== e.target) {
22
- return;
23
- }
24
- if (e.key === 'Enter' || e.key === ' ') {
25
- e.preventDefault();
26
- onNotificationClick(notification);
27
- }
28
- }}
29
- >
30
- <NotificationIcon notificationType={notification.notification_type} size="sm" />
31
-
32
- <div className="pc-notification-dropdown-content">
33
- <p className="pc-notification-dropdown-title-text">{notification.title}</p>
34
- {statusLabel && (
35
- <span className="pc-notification-status-badge">{statusLabel}</span>
36
- )}
37
- <p className="pc-notification-dropdown-description">{notification.description}</p>
38
- <p className="pc-notification-dropdown-time">{formatTimeAgo(notification.created_at, t)}</p>
39
-
40
- {notification.ctas && notification.ctas.length > 0 && (
41
- <div className="pc-notification-dropdown-ctas">
42
- {notification.ctas.map((cta) => (
43
- <NotificationCTAButton
44
- key={cta.label}
45
- cta={cta}
46
- size="sm"
47
- onClick={(e) => { e.stopPropagation(); onCTAClick(notification, cta); }}
48
- />
49
- ))}
50
- </div>
51
- )}
52
- </div>
53
-
54
- {!notification.is_read && <div className="pc-notification-unread-dot-sm" />}
55
- </div>
56
- );
57
- }
@@ -1,19 +0,0 @@
1
- import type { CSSProperties } from 'react';
2
- import type { NotificationIconProps } from '../../lib/types';
3
- import { TYPE_TO_ICON_CATEGORY, ICON_MAP, ICON_COLORS } from '../../lib/constants';
4
- import { cn } from '../../utils/cn';
5
-
6
- export const NotificationIcon = ({ notificationType, size = 'lg' }: NotificationIconProps) => {
7
- const category = TYPE_TO_ICON_CATEGORY[notificationType] ?? 'system';
8
- const Icon = ICON_MAP[category];
9
- const color = ICON_COLORS[category];
10
- const sizeClass = size === 'sm' ? 'pc-notification-icon-sm' : 'pc-notification-icon-lg';
11
- const iconPx = size === 'sm' ? 18 : 20;
12
- const iconBgStyle = { '--pc-notification-icon-bg': `${color}14` } as CSSProperties;
13
-
14
- return (
15
- <div className={cn('pc-notification-icon', sizeClass)} style={iconBgStyle}>
16
- <Icon size={iconPx} color={color} />
17
- </div>
18
- );
19
- }