@redacto.io/consent-sdk-react 10.0.0-beta.11 → 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 (259) hide show
  1. package/NOTICE.md +17 -0
  2. package/README.md +67 -3
  3. package/dist/chunk-FEGTW73Q.mjs +182 -0
  4. package/dist/fonts.d.mts +35 -0
  5. package/dist/fonts.d.ts +35 -0
  6. package/dist/fonts.js +183 -0
  7. package/dist/fonts.mjs +10 -0
  8. package/dist/index.d.mts +12 -1
  9. package/dist/index.d.ts +12 -1
  10. package/dist/index.js +613 -249
  11. package/dist/index.mjs +235 -85
  12. package/dist/montserrat.generated-NBTECYRW.mjs +22 -0
  13. package/dist/types-6Aj7faxL.d.mts +57 -0
  14. package/dist/types-6Aj7faxL.d.ts +57 -0
  15. package/package.json +10 -1
  16. package/.turbo/turbo-build.log +0 -22
  17. package/.turbo/turbo-test.log +0 -203
  18. package/.turbo/turbo-verify-pack.log +0 -6
  19. package/CHANGELOG.md +0 -383
  20. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.test.tsx +0 -934
  21. package/src/RedactoNoticeAssisted/RedactoNoticeAssisted.tsx +0 -2160
  22. package/src/RedactoNoticeAssisted/api/index.ts +0 -275
  23. package/src/RedactoNoticeAssisted/api/types.ts +0 -182
  24. package/src/RedactoNoticeAssisted/assets/redacto-logo.png +0 -0
  25. package/src/RedactoNoticeAssisted/constants.ts +0 -51
  26. package/src/RedactoNoticeAssisted/i18n.ts +0 -1408
  27. package/src/RedactoNoticeAssisted/index.ts +0 -1
  28. package/src/RedactoNoticeAssisted/injectStyles.ts +0 -251
  29. package/src/RedactoNoticeAssisted/styles.ts +0 -730
  30. package/src/RedactoNoticeAssisted/types.ts +0 -26
  31. package/src/RedactoNoticeAssisted/useMediaQuery.ts +0 -36
  32. package/src/RedactoNoticeConsent/RedactoNoticeConsent.test.tsx +0 -1186
  33. package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +0 -4299
  34. package/src/RedactoNoticeConsent/api/index.ts +0 -486
  35. package/src/RedactoNoticeConsent/api/sandbox.ts +0 -150
  36. package/src/RedactoNoticeConsent/api/types.ts +0 -505
  37. package/src/RedactoNoticeConsent/assets/redacto-logo.png +0 -0
  38. package/src/RedactoNoticeConsent/components/DigiLockerCallback.tsx +0 -602
  39. package/src/RedactoNoticeConsent/components/index.ts +0 -7
  40. package/src/RedactoNoticeConsent/constants.ts +0 -20
  41. package/src/RedactoNoticeConsent/index.ts +0 -1
  42. package/src/RedactoNoticeConsent/injectStyles.ts +0 -151
  43. package/src/RedactoNoticeConsent/language-codes.ts +0 -95
  44. package/src/RedactoNoticeConsent/services/storage.ts +0 -122
  45. package/src/RedactoNoticeConsent/styles.ts +0 -409
  46. package/src/RedactoNoticeConsent/types.ts +0 -80
  47. package/src/RedactoNoticeConsent/useMediaQuery.ts +0 -36
  48. package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.test.tsx +0 -369
  49. package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx +0 -709
  50. package/src/RedactoNoticeConsentInline/api/index.ts +0 -115
  51. package/src/RedactoNoticeConsentInline/api/notice-read-routing.test.ts +0 -72
  52. package/src/RedactoNoticeConsentInline/api/types.ts +0 -185
  53. package/src/RedactoNoticeConsentInline/assets/redacto-logo.png +0 -0
  54. package/src/RedactoNoticeConsentInline/index.ts +0 -1
  55. package/src/RedactoNoticeConsentInline/injectStyles.ts +0 -40
  56. package/src/RedactoNoticeConsentInline/styles.ts +0 -397
  57. package/src/RedactoNoticeConsentInline/types.ts +0 -51
  58. package/src/RedactoNoticeConsentInline/useMediaQuery.ts +0 -36
  59. package/src/RedactoPrivacyCenter/NotificationsPage.tsx +0 -182
  60. package/src/RedactoPrivacyCenter/PrivacyCenterActivityPage.tsx +0 -19
  61. package/src/RedactoPrivacyCenter/PrivacyCenterCaseDetailsPage.tsx +0 -156
  62. package/src/RedactoPrivacyCenter/PrivacyCenterConsentManagerPage.tsx +0 -17
  63. package/src/RedactoPrivacyCenter/PrivacyCenterFormPage.tsx +0 -79
  64. package/src/RedactoPrivacyCenter/PrivacyCenterHomePage.tsx +0 -36
  65. package/src/RedactoPrivacyCenter/PrivacyCenterLayout.tsx +0 -177
  66. package/src/RedactoPrivacyCenter/PrivacyCenterMyReceiptPage.tsx +0 -26
  67. package/src/RedactoPrivacyCenter/RedactoPrivacyCenter.tsx +0 -93
  68. package/src/RedactoPrivacyCenter/api/actions.ts +0 -682
  69. package/src/RedactoPrivacyCenter/api/client.ts +0 -1003
  70. package/src/RedactoPrivacyCenter/api/config.ts +0 -33
  71. package/src/RedactoPrivacyCenter/api/fetcher.ts +0 -275
  72. package/src/RedactoPrivacyCenter/api/orgBranding.ts +0 -16
  73. package/src/RedactoPrivacyCenter/api/upload.ts +0 -93
  74. package/src/RedactoPrivacyCenter/assets/character.svg +0 -31
  75. package/src/RedactoPrivacyCenter/assets/fileAttach.svg +0 -9
  76. package/src/RedactoPrivacyCenter/assets/greenTick.svg +0 -4
  77. package/src/RedactoPrivacyCenter/assets/mail.svg +0 -3
  78. package/src/RedactoPrivacyCenter/assets/poweredByRedacto.svg +0 -9
  79. package/src/RedactoPrivacyCenter/assets/sentImg.svg +0 -9
  80. package/src/RedactoPrivacyCenter/assets/uploadFileIcon.svg +0 -9
  81. package/src/RedactoPrivacyCenter/components/ActivitiesList.tsx +0 -252
  82. package/src/RedactoPrivacyCenter/components/ActivityTimeline.tsx +0 -239
  83. package/src/RedactoPrivacyCenter/components/AppShell/AppShell.tsx +0 -268
  84. package/src/RedactoPrivacyCenter/components/AppShell/MobileNavDrawer.tsx +0 -218
  85. package/src/RedactoPrivacyCenter/components/AppShell/NavItem.tsx +0 -205
  86. package/src/RedactoPrivacyCenter/components/AppShell/PageHeader.tsx +0 -107
  87. package/src/RedactoPrivacyCenter/components/AppShell/SidebarNav.tsx +0 -100
  88. package/src/RedactoPrivacyCenter/components/AppShell/TopAppBar.tsx +0 -339
  89. package/src/RedactoPrivacyCenter/components/AppShell/UserMenu.tsx +0 -245
  90. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useIsTruncated.ts +0 -28
  91. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useKeyboardShortcut.ts +0 -40
  92. package/src/RedactoPrivacyCenter/components/AppShell/hooks/useSidebarState.ts +0 -62
  93. package/src/RedactoPrivacyCenter/components/AppShell/usePrivacyCenterExitAction.ts +0 -36
  94. package/src/RedactoPrivacyCenter/components/CaseDetails/AttachmentCard.tsx +0 -38
  95. package/src/RedactoPrivacyCenter/components/CaseDetails/ChatBubble.tsx +0 -31
  96. package/src/RedactoPrivacyCenter/components/CaseDetails/DocumentRequestCard.tsx +0 -79
  97. package/src/RedactoPrivacyCenter/components/CaseDetails/FinalizedTooltipWrapper.tsx +0 -25
  98. package/src/RedactoPrivacyCenter/components/CaseDetails/MessageComposer.tsx +0 -96
  99. package/src/RedactoPrivacyCenter/components/CaseDetails/MessageItem.tsx +0 -97
  100. package/src/RedactoPrivacyCenter/components/CaseDetails/MessagesTab.tsx +0 -156
  101. package/src/RedactoPrivacyCenter/components/CaseDetails/RequestDetailsTab.tsx +0 -171
  102. package/src/RedactoPrivacyCenter/components/CaseDetails/StatusEvent.tsx +0 -23
  103. package/src/RedactoPrivacyCenter/components/CaseDetails/useFileUpload.ts +0 -116
  104. package/src/RedactoPrivacyCenter/components/CaseDetails/useMessagePolling.ts +0 -43
  105. package/src/RedactoPrivacyCenter/components/CaseDetails/utils.ts +0 -71
  106. package/src/RedactoPrivacyCenter/components/CaseDetailsModal.tsx +0 -469
  107. package/src/RedactoPrivacyCenter/components/CaseHistory.tsx +0 -426
  108. package/src/RedactoPrivacyCenter/components/ConsentManager.tsx +0 -1199
  109. package/src/RedactoPrivacyCenter/components/ConsentManagerCells.tsx +0 -201
  110. package/src/RedactoPrivacyCenter/components/ConsentManagerColumns.tsx +0 -138
  111. package/src/RedactoPrivacyCenter/components/ConsentManagerConstants.ts +0 -7
  112. package/src/RedactoPrivacyCenter/components/ConsentManagerExpandedRow.tsx +0 -179
  113. package/src/RedactoPrivacyCenter/components/ConsentManagerGroupedColumns.tsx +0 -318
  114. package/src/RedactoPrivacyCenter/components/ConsentManagerProductCards.tsx +0 -333
  115. package/src/RedactoPrivacyCenter/components/ConsentManagerPurposeCards.tsx +0 -102
  116. package/src/RedactoPrivacyCenter/components/ConsentManagerTableSkeleton.tsx +0 -159
  117. package/src/RedactoPrivacyCenter/components/DataRequest/CorrectionDataSection.tsx +0 -189
  118. package/src/RedactoPrivacyCenter/components/DataRequest/GrievanceDataSection.tsx +0 -118
  119. package/src/RedactoPrivacyCenter/components/DataRequest/NominationDataSection.tsx +0 -66
  120. package/src/RedactoPrivacyCenter/components/DataRequest/ProductSelectionSection.tsx +0 -222
  121. package/src/RedactoPrivacyCenter/components/DataRequest/PurposeSelectionSection.tsx +0 -331
  122. package/src/RedactoPrivacyCenter/components/Form.tsx +0 -1821
  123. package/src/RedactoPrivacyCenter/components/GrievanceTable.tsx +0 -174
  124. package/src/RedactoPrivacyCenter/components/GrievanceTablePagination.tsx +0 -337
  125. package/src/RedactoPrivacyCenter/components/ModifyConsentModal.tsx +0 -334
  126. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationBell.tsx +0 -173
  127. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationCTAButton.tsx +0 -18
  128. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdown.tsx +0 -54
  129. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdownItem.tsx +0 -57
  130. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationIcon.tsx +0 -19
  131. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationListPanel.tsx +0 -92
  132. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRefreshButton.tsx +0 -20
  133. package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRow.tsx +0 -58
  134. package/src/RedactoPrivacyCenter/components/NotificationHub/StatCard.tsx +0 -10
  135. package/src/RedactoPrivacyCenter/components/NotificationHub/useNotificationActions.ts +0 -112
  136. package/src/RedactoPrivacyCenter/components/NotificationHub/utils.ts +0 -27
  137. package/src/RedactoPrivacyCenter/components/Pagination.tsx +0 -140
  138. package/src/RedactoPrivacyCenter/components/PrivacyCenterEmptyState.tsx +0 -76
  139. package/src/RedactoPrivacyCenter/components/PrivacyCenterSessionExpired.tsx +0 -97
  140. package/src/RedactoPrivacyCenter/components/ReceiptsList.tsx +0 -454
  141. package/src/RedactoPrivacyCenter/components/RequestSubmit.tsx +0 -270
  142. package/src/RedactoPrivacyCenter/components/SelectUser.tsx +0 -95
  143. package/src/RedactoPrivacyCenter/components/SelectUserGate.tsx +0 -195
  144. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/constants.tsx +0 -25
  145. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/types.ts +0 -21
  146. package/src/RedactoPrivacyCenter/components/caseHistoryColumns.tsx +0 -159
  147. package/src/RedactoPrivacyCenter/components/constant.ts +0 -52
  148. package/src/RedactoPrivacyCenter/components/groupHelpers.ts +0 -155
  149. package/src/RedactoPrivacyCenter/components/receiptColumns.tsx +0 -203
  150. package/src/RedactoPrivacyCenter/components/types.ts +0 -123
  151. package/src/RedactoPrivacyCenter/components/utils.tsx +0 -10
  152. package/src/RedactoPrivacyCenter/config/routes.ts +0 -9
  153. package/src/RedactoPrivacyCenter/config/table.ts +0 -25
  154. package/src/RedactoPrivacyCenter/context/AuthContext.tsx +0 -252
  155. package/src/RedactoPrivacyCenter/context/BaseUrlContext.tsx +0 -47
  156. package/src/RedactoPrivacyCenter/context/BrandingContext.tsx +0 -52
  157. package/src/RedactoPrivacyCenter/context/DataAvailabilityContext.session-expired.test.tsx +0 -92
  158. package/src/RedactoPrivacyCenter/context/DataAvailabilityContext.tsx +0 -181
  159. package/src/RedactoPrivacyCenter/context/LocaleContext.tsx +0 -11
  160. package/src/RedactoPrivacyCenter/context/NavigationContext.tsx +0 -96
  161. package/src/RedactoPrivacyCenter/context/OrganizationContext.tsx +0 -30
  162. package/src/RedactoPrivacyCenter/context/PageChromeContext.tsx +0 -80
  163. package/src/RedactoPrivacyCenter/context/ProfileSwitchContext.tsx +0 -15
  164. package/src/RedactoPrivacyCenter/context/types.ts +0 -57
  165. package/src/RedactoPrivacyCenter/lib/api.ts +0 -759
  166. package/src/RedactoPrivacyCenter/lib/consent-manager/utils.tsx +0 -67
  167. package/src/RedactoPrivacyCenter/lib/constants.ts +0 -283
  168. package/src/RedactoPrivacyCenter/lib/i18n.ts +0 -81
  169. package/src/RedactoPrivacyCenter/lib/locales.ts +0 -102
  170. package/src/RedactoPrivacyCenter/lib/queries.ts +0 -141
  171. package/src/RedactoPrivacyCenter/lib/sandbox.ts +0 -104
  172. package/src/RedactoPrivacyCenter/lib/types.ts +0 -892
  173. package/src/RedactoPrivacyCenter/lib/useCurrentLanguage.ts +0 -37
  174. package/src/RedactoPrivacyCenter/lib/utils.refresh-circuit.test.ts +0 -127
  175. package/src/RedactoPrivacyCenter/lib/utils.refresh-storage.test.ts +0 -85
  176. package/src/RedactoPrivacyCenter/lib/utils.session-expired.test.ts +0 -109
  177. package/src/RedactoPrivacyCenter/lib/utils.ts +0 -798
  178. package/src/RedactoPrivacyCenter/locales/as/translation.json +0 -340
  179. package/src/RedactoPrivacyCenter/locales/bn/translation.json +0 -340
  180. package/src/RedactoPrivacyCenter/locales/brx/translation.json +0 -340
  181. package/src/RedactoPrivacyCenter/locales/doi/translation.json +0 -340
  182. package/src/RedactoPrivacyCenter/locales/en/translation.json +0 -355
  183. package/src/RedactoPrivacyCenter/locales/gom/translation.json +0 -340
  184. package/src/RedactoPrivacyCenter/locales/gu/translation.json +0 -340
  185. package/src/RedactoPrivacyCenter/locales/hi/translation.json +0 -343
  186. package/src/RedactoPrivacyCenter/locales/kn/translation.json +0 -340
  187. package/src/RedactoPrivacyCenter/locales/ks/translation.json +0 -340
  188. package/src/RedactoPrivacyCenter/locales/mai/translation.json +0 -340
  189. package/src/RedactoPrivacyCenter/locales/ml/translation.json +0 -340
  190. package/src/RedactoPrivacyCenter/locales/mni-Mtei/translation.json +0 -340
  191. package/src/RedactoPrivacyCenter/locales/mr/translation.json +0 -340
  192. package/src/RedactoPrivacyCenter/locales/ne/translation.json +0 -340
  193. package/src/RedactoPrivacyCenter/locales/or/translation.json +0 -340
  194. package/src/RedactoPrivacyCenter/locales/pa/translation.json +0 -340
  195. package/src/RedactoPrivacyCenter/locales/sa/translation.json +0 -340
  196. package/src/RedactoPrivacyCenter/locales/sat/translation.json +0 -340
  197. package/src/RedactoPrivacyCenter/locales/sd/translation.json +0 -340
  198. package/src/RedactoPrivacyCenter/locales/ta/translation.json +0 -340
  199. package/src/RedactoPrivacyCenter/locales/te/translation.json +0 -340
  200. package/src/RedactoPrivacyCenter/locales/ur/translation.json +0 -340
  201. package/src/RedactoPrivacyCenter/styles/applyBrandingTheme.ts +0 -66
  202. package/src/RedactoPrivacyCenter/styles/base.css +0 -117
  203. package/src/RedactoPrivacyCenter/styles/injectStyles.ts +0 -3108
  204. package/src/RedactoPrivacyCenter/styles/pcStyles.ts +0 -831
  205. package/src/RedactoPrivacyCenter/styles/responsive.ts +0 -138
  206. package/src/RedactoPrivacyCenter/styles/variables.css +0 -96
  207. package/src/RedactoPrivacyCenter/table/AdvancedTable.tsx +0 -387
  208. package/src/RedactoPrivacyCenter/table/AdvancedTablePagination.tsx +0 -468
  209. package/src/RedactoPrivacyCenter/table/index.ts +0 -2
  210. package/src/RedactoPrivacyCenter/types/images.d.ts +0 -29
  211. package/src/RedactoPrivacyCenter/ui/Footer.tsx +0 -69
  212. package/src/RedactoPrivacyCenter/ui/FormBlockWrapper.tsx +0 -54
  213. package/src/RedactoPrivacyCenter/ui/PCAccordion.tsx +0 -93
  214. package/src/RedactoPrivacyCenter/ui/PCActionIcon.tsx +0 -47
  215. package/src/RedactoPrivacyCenter/ui/PCAvatar.test.tsx +0 -83
  216. package/src/RedactoPrivacyCenter/ui/PCAvatar.tsx +0 -93
  217. package/src/RedactoPrivacyCenter/ui/PCBadge.tsx +0 -48
  218. package/src/RedactoPrivacyCenter/ui/PCButton.tsx +0 -77
  219. package/src/RedactoPrivacyCenter/ui/PCCheckbox.tsx +0 -55
  220. package/src/RedactoPrivacyCenter/ui/PCCollapse.tsx +0 -107
  221. package/src/RedactoPrivacyCenter/ui/PCEmpty.tsx +0 -35
  222. package/src/RedactoPrivacyCenter/ui/PCInput.tsx +0 -132
  223. package/src/RedactoPrivacyCenter/ui/PCLoader.tsx +0 -31
  224. package/src/RedactoPrivacyCenter/ui/PCModal.tsx +0 -106
  225. package/src/RedactoPrivacyCenter/ui/PCPopover.tsx +0 -206
  226. package/src/RedactoPrivacyCenter/ui/PCSelect.tsx +0 -433
  227. package/src/RedactoPrivacyCenter/ui/PCTable.tsx +0 -149
  228. package/src/RedactoPrivacyCenter/ui/PCText.tsx +0 -41
  229. package/src/RedactoPrivacyCenter/ui/PCTextarea.tsx +0 -43
  230. package/src/RedactoPrivacyCenter/ui/PCTitle.tsx +0 -37
  231. package/src/RedactoPrivacyCenter/ui/PCTooltip.tsx +0 -121
  232. package/src/RedactoPrivacyCenter/ui/SimpleBar.tsx +0 -25
  233. package/src/RedactoPrivacyCenter/ui/StatusBadge.tsx +0 -53
  234. package/src/RedactoPrivacyCenter/ui/index.ts +0 -18
  235. package/src/RedactoPrivacyCenter/utils/cn.ts +0 -28
  236. package/src/RedactoPrivacyCenter/utils/date.ts +0 -48
  237. package/src/RedactoPrivacyCenter/utils/status.ts +0 -111
  238. package/src/RedactoPrivacyCenter/utils/toast.ts +0 -130
  239. package/src/index.ts +0 -19
  240. package/src/privacy-center.ts +0 -113
  241. package/src/shared/api-errors.ts +0 -180
  242. package/src/shared/notice-consent-status.ts +0 -190
  243. package/src/shared/sandbox.ts +0 -6
  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 -1424
  249. package/tests/ProductSelectionSection.test.tsx +0 -328
  250. package/tests/RequestSubmit.test.tsx +0 -135
  251. package/tests/RevokeWarningMessage.test.tsx +0 -151
  252. package/tests/consentClient.test.ts +0 -217
  253. package/tests/manageConsentServer.test.ts +0 -38
  254. package/tests/mocks.ts +0 -257
  255. package/tests/resolveContactFromJwt.test.ts +0 -44
  256. package/tests/setup.ts +0 -16
  257. package/tsconfig.json +0 -16
  258. package/tsup.config.ts +0 -31
  259. package/vitest.config.ts +0 -16
@@ -1,709 +0,0 @@
1
- import { useEffect, useMemo, useState, useRef, useCallback, memo } from "react";
2
- import { fetchConsentContent, submitConsentEvent } from "./api";
3
- import {
4
- fetchNoticeConsentStatus,
5
- isNoticeFullyConsented,
6
- } from "../shared/notice-consent-status";
7
- import type { ConsentContent } from "./api/types";
8
- import type { Props, TranslationObject } from "./types";
9
- import { styles } from "./styles";
10
- import { useMediaQuery } from "./useMediaQuery";
11
- import { injectSpinnerAnimation } from "./injectStyles";
12
-
13
- const RedactoConsentInlineComponent = ({
14
- org_uuid,
15
- workspace_uuid,
16
- notice_uuid,
17
- accessToken,
18
- baseUrl,
19
- ledgerBaseUrl,
20
- language = "en",
21
- onAccept,
22
- onError,
23
- onValidationChange,
24
- settings,
25
- applicationId,
26
- }: Props) => {
27
- const [content, setContent] = useState<
28
- ConsentContent["detail"]["active_config"] | null
29
- >(null);
30
- const [isLoading, setIsLoading] = useState(true);
31
- const [isSubmitting, setIsSubmitting] = useState(false);
32
- const [selectedLanguage, setSelectedLanguage] = useState<string>(language);
33
- const [collapsedPurposes, setCollapsedPurposes] = useState<
34
- Record<string, boolean>
35
- >({});
36
- const [selectedPurposes, setSelectedPurposes] = useState<
37
- Record<string, boolean>
38
- >({});
39
- const [selectedDataElements, setSelectedDataElements] = useState<
40
- Record<string, boolean>
41
- >({});
42
- const [hasAlreadyConsented, setHasAlreadyConsented] = useState(false);
43
- // When a ledger is configured, block the auto-submit effect until the ledger
44
- // check-consent read settles, so an already-consented principal is not
45
- // re-submitted. Starts true only when a ledger check will actually run
46
- // (skipped for the magic-link specific_uuid flow); stays false otherwise so
47
- // the legacy Python-409 path is unaffected.
48
- const [isCheckingConsent, setIsCheckingConsent] = useState<boolean>(
49
- Boolean(ledgerBaseUrl) && !applicationId
50
- );
51
- const [fetchError, setFetchError] = useState<Error | null>(null);
52
- const [errorMessage, setErrorMessage] = useState<string | null>(null);
53
-
54
- // Ref to track if we've already submitted consent to prevent duplicate submissions
55
- const hasSubmittedRef = useRef(false);
56
-
57
- // Inject spinner animation for loading indicator
58
- useEffect(() => {
59
- injectSpinnerAnimation();
60
- }, []);
61
-
62
- // Add media query hooks
63
- const isMobile = useMediaQuery("(max-width: 768px)");
64
-
65
- // Responsive styles
66
- const responsiveStyles = useMemo(
67
- () => ({
68
- optionTitle: {
69
- fontSize: isMobile ? "14px" : "16px",
70
- },
71
- optionDescription: {
72
- fontSize: isMobile ? "11px" : "12px",
73
- },
74
- dataElementText: {
75
- fontSize: isMobile ? "12px" : "14px",
76
- },
77
- button: {
78
- fontSize: isMobile ? "14px" : "16px",
79
- padding: isMobile ? "10px 20px" : "9px 45px",
80
- },
81
- }),
82
- [isMobile]
83
- );
84
-
85
- const areAllRequiredElementsChecked = useMemo(() => {
86
- if (!content) return false;
87
-
88
- return content.purposes.every((purpose) => {
89
- const requiredElements = purpose.data_elements.filter(
90
- (element) => element.required
91
- );
92
- return requiredElements.every(
93
- (element) => selectedDataElements[`${purpose.uuid}-${element.uuid}`]
94
- );
95
- });
96
- }, [content, selectedDataElements]);
97
-
98
- // Notify parent component when validation state changes
99
- useEffect(() => {
100
- onValidationChange?.(areAllRequiredElementsChecked);
101
- }, [areAllRequiredElementsChecked, onValidationChange]);
102
-
103
- useEffect(() => {
104
- if (hasAlreadyConsented) {
105
- onAccept?.();
106
- }
107
- }, [hasAlreadyConsented, onAccept]);
108
-
109
- const getTranslatedText = (
110
- key: string,
111
- defaultText: string,
112
- itemId?: string
113
- ): string => {
114
- if (!content) return defaultText;
115
-
116
- if (selectedLanguage === "English" || selectedLanguage === "en" || selectedLanguage === "EN") {
117
- if (
118
- key === "privacy_policy_anchor_text" &&
119
- content.privacy_policy_anchor_text
120
- ) {
121
- return content.privacy_policy_anchor_text;
122
- }
123
- return defaultText;
124
- }
125
-
126
- if (!content.supported_languages_and_translations) {
127
- return defaultText;
128
- }
129
-
130
- const translationMap = content.supported_languages_and_translations[
131
- selectedLanguage
132
- ] as TranslationObject | undefined;
133
-
134
- if (!translationMap) {
135
- return defaultText;
136
- }
137
-
138
- if (itemId) {
139
- if (key === "purposes.name" || key === "purposes.description") {
140
- const purposeData = translationMap.purposes?.[itemId];
141
- if (purposeData) {
142
- if (typeof purposeData === "string") {
143
- return key === "purposes.name" ? purposeData : defaultText;
144
- }
145
- return key === "purposes.name"
146
- ? purposeData.name || defaultText
147
- : purposeData.description || defaultText;
148
- }
149
- return defaultText;
150
- }
151
- if (key.startsWith("data_elements.")) {
152
- return translationMap.data_elements?.[itemId] || defaultText;
153
- }
154
- }
155
-
156
- const value = translationMap[key];
157
- if (typeof value === "string" && value) {
158
- return value;
159
- }
160
-
161
- return defaultText;
162
- };
163
-
164
- const fetchNotice = async (signal?: AbortSignal) => {
165
- setIsLoading(true);
166
- setFetchError(null);
167
- setHasAlreadyConsented(false);
168
- try {
169
- const consentContentData = await fetchConsentContent({
170
- org_uuid,
171
- workspace_uuid,
172
- notice_uuid,
173
- accessToken,
174
- baseUrl,
175
- language,
176
- specific_uuid: applicationId,
177
- signal,
178
- });
179
-
180
- if (signal?.aborted) {
181
- return;
182
- }
183
-
184
- const activeConfig = consentContentData.detail.active_config;
185
- setContent(activeConfig);
186
- if (activeConfig.default_language) {
187
- setSelectedLanguage(activeConfig.default_language);
188
- }
189
- const initialCollapsedState = activeConfig.purposes.reduce(
190
- (acc, purpose) => ({
191
- ...acc,
192
- [purpose.uuid]: true,
193
- }),
194
- {}
195
- );
196
- setCollapsedPurposes(initialCollapsedState);
197
-
198
- // Initialize selected states
199
- // All elements start unchecked, but required elements cannot be unchecked once checked
200
- const initialDataElementState: Record<string, boolean> =
201
- activeConfig.purposes.reduce(
202
- (acc: Record<string, boolean>, purpose) => {
203
- purpose.data_elements.forEach((element) => {
204
- const combinedId = `${purpose.uuid}-${element.uuid}`;
205
- acc[combinedId] = false;
206
- });
207
- return acc;
208
- },
209
- {}
210
- );
211
- setSelectedDataElements(initialDataElementState);
212
-
213
- // Initialize purpose states - all start unchecked
214
- const initialPurposeState: Record<string, boolean> =
215
- activeConfig.purposes.reduce(
216
- (acc: Record<string, boolean>, purpose) => {
217
- return {
218
- ...acc,
219
- [purpose.uuid]: false,
220
- };
221
- },
222
- {}
223
- );
224
- setSelectedPurposes(initialPurposeState);
225
- } catch (err: unknown) {
226
- if (
227
- signal?.aborted ||
228
- (err instanceof Error && err.name === "AbortError")
229
- ) {
230
- return;
231
- }
232
-
233
- const error = err as Error & { status?: number };
234
- setFetchError(error);
235
- if (error.status === 409) {
236
- setHasAlreadyConsented(true);
237
- } else {
238
- onError?.(error);
239
- }
240
- } finally {
241
- if (!signal?.aborted) {
242
- setIsLoading(false);
243
- }
244
- }
245
- };
246
-
247
- useEffect(() => {
248
- const controller = new AbortController();
249
- void fetchNotice(controller.signal);
250
-
251
- return () => {
252
- controller.abort();
253
- };
254
- // eslint-disable-next-line react-hooks/exhaustive-deps
255
- }, [org_uuid, workspace_uuid, notice_uuid, language, applicationId, accessToken]);
256
-
257
- // Post-cutover, consent records live in the Go ledger, so Python's
258
- // get-notice no longer returns 409 CONSENT_ALREADY_PROVIDED. When a ledger
259
- // is configured, ask it directly whether this principal has already fully
260
- // consented — the same check-consent read the banner uses. Skipped for the
261
- // magic-link specific_uuid flow (which always re-submits against a specific
262
- // application) and when no ledger is set (the legacy 409 path governs).
263
- useEffect(() => {
264
- if (!ledgerBaseUrl || applicationId) {
265
- return;
266
- }
267
- if (!accessToken || !content) {
268
- return;
269
- }
270
- let active = true;
271
- const controller = new AbortController();
272
- const checkLedgerConsent = async () => {
273
- try {
274
- const ledgerStatus = await fetchNoticeConsentStatus({
275
- accessToken,
276
- ledgerBaseUrl,
277
- noticeUuid: notice_uuid,
278
- signal: controller.signal,
279
- });
280
- if (active && ledgerStatus && isNoticeFullyConsented(ledgerStatus)) {
281
- setHasAlreadyConsented(true);
282
- }
283
- } finally {
284
- if (active) {
285
- setIsCheckingConsent(false);
286
- }
287
- }
288
- };
289
- checkLedgerConsent();
290
- return () => {
291
- active = false;
292
- controller.abort();
293
- };
294
- }, [ledgerBaseUrl, applicationId, accessToken, content, notice_uuid]);
295
-
296
- const togglePurposeCollapse = (purposeUuid: string) => {
297
- setCollapsedPurposes((prev) => ({
298
- ...prev,
299
- [purposeUuid]: !prev[purposeUuid],
300
- }));
301
- };
302
-
303
- const handlePurposeCheckboxChange = (purposeUuid: string) => {
304
- if (content) {
305
- const purpose = content.purposes.find((p) => p.uuid === purposeUuid);
306
- if (purpose) {
307
- const newPurposeState = !selectedPurposes[purposeUuid];
308
-
309
- // Update purpose state
310
- setSelectedPurposes((prev) => ({
311
- ...prev,
312
- [purposeUuid]: newPurposeState,
313
- }));
314
-
315
- // Update ALL data elements (including required) when purpose checkbox is toggled
316
- setSelectedDataElements((prev) => {
317
- const updated = { ...prev };
318
- purpose.data_elements.forEach((el) => {
319
- const combinedId = `${purposeUuid}-${el.uuid}`;
320
- updated[combinedId] = newPurposeState;
321
- });
322
- return updated;
323
- });
324
- }
325
- }
326
- };
327
-
328
- const handleDataElementCheckboxChange = (
329
- elementUuid: string,
330
- purposeUuid: string
331
- ) => {
332
- if (!content) return;
333
-
334
- const purpose = content.purposes.find((p) => p.uuid === purposeUuid);
335
- if (!purpose) return;
336
-
337
- const dataElement = purpose.data_elements.find(
338
- (el) => el.uuid === elementUuid
339
- );
340
- if (!dataElement) return;
341
-
342
- const combinedId = `${purposeUuid}-${elementUuid}`;
343
- const currentState = selectedDataElements[combinedId] || false;
344
- const newElementState = !currentState;
345
-
346
- // Update data element state
347
- setSelectedDataElements((prev) => {
348
- const newState = {
349
- ...prev,
350
- [combinedId]: newElementState,
351
- };
352
-
353
- // Check if all required elements are checked
354
- const requiredElements = purpose.data_elements.filter(
355
- (el) => el.required
356
- );
357
-
358
- let shouldCheckPurpose: boolean;
359
-
360
- if (requiredElements.length > 0) {
361
- // Has required elements: check purpose when all required are selected
362
- shouldCheckPurpose = requiredElements.every(
363
- (el) => newState[`${purposeUuid}-${el.uuid}`]
364
- );
365
- } else {
366
- // No required elements: check purpose when ANY element is selected
367
- shouldCheckPurpose = purpose.data_elements.some(
368
- (el) => newState[`${purposeUuid}-${el.uuid}`]
369
- );
370
- }
371
-
372
- setSelectedPurposes((prevPurposes) => ({
373
- ...prevPurposes,
374
- [purposeUuid]: shouldCheckPurpose,
375
- }));
376
-
377
- return newState;
378
- });
379
- };
380
-
381
- const handleAcceptWithToken = useCallback(
382
- async (tokenToUse: string) => {
383
- if (!tokenToUse || !content) {
384
- setErrorMessage("Unable to submit consent. Please try again.");
385
- throw new Error("Access token or content not available");
386
- }
387
-
388
- try {
389
- setIsSubmitting(true);
390
- setErrorMessage(null);
391
-
392
- await submitConsentEvent({
393
- org_uuid,
394
- workspace_uuid,
395
- accessToken: tokenToUse,
396
- baseUrl,
397
- ledgerBaseUrl,
398
- noticeUuid: content.notice_uuid,
399
- purposes: content.purposes.map((purpose) => {
400
- // Check if any required data element is selected
401
- const hasSelectedRequiredElement = purpose.data_elements.some(
402
- (element) =>
403
- element.required &&
404
- (selectedDataElements[`${purpose.uuid}-${element.uuid}`] ||
405
- false)
406
- );
407
-
408
- // Check if any data element is selected
409
- const hasSelectedDataElement = purpose.data_elements.some(
410
- (element) =>
411
- selectedDataElements[`${purpose.uuid}-${element.uuid}`] || false
412
- );
413
-
414
- // Purpose is selected if: purpose checkbox is checked OR any required element is selected OR any data element is selected
415
- const purposeSelected =
416
- selectedPurposes[purpose.uuid] ||
417
- hasSelectedRequiredElement ||
418
- hasSelectedDataElement;
419
-
420
- return {
421
- ...purpose,
422
- selected: purposeSelected,
423
- data_elements: purpose.data_elements.map((element) => ({
424
- ...element,
425
- selected:
426
- selectedDataElements[`${purpose.uuid}-${element.uuid}`] ||
427
- false,
428
- })),
429
- };
430
- }),
431
- declined: false,
432
- meta_data: applicationId
433
- ? { specific_uuid: applicationId }
434
- : undefined,
435
- });
436
-
437
- onAccept?.();
438
- // Reset ref on success to allow re-submission if needed
439
- hasSubmittedRef.current = false;
440
- } catch (error) {
441
- const err = error as Error;
442
- // The SDK is a passthrough: server-owned message wins. Only the
443
- // bare-Error fallback is used when no message is present (e.g. a
444
- // network failure that never produced a Response).
445
- const message =
446
- err.message || "Failed to submit consent. Please try again.";
447
- setErrorMessage(message);
448
- // Reset ref on error to allow retry
449
- hasSubmittedRef.current = false;
450
- throw error;
451
- } finally {
452
- setIsSubmitting(false);
453
- }
454
- },
455
- [
456
- content,
457
- org_uuid,
458
- workspace_uuid,
459
- baseUrl,
460
- ledgerBaseUrl,
461
- selectedDataElements,
462
- selectedPurposes,
463
- applicationId,
464
- onAccept,
465
- ]
466
- );
467
-
468
- // Auto-submit consent when all conditions are met. Waits for the ledger
469
- // check-consent read to settle (isCheckingConsent) and never fires for an
470
- // already-consented principal, so the cutover cannot trigger a duplicate
471
- // submission.
472
- useEffect(() => {
473
- if (
474
- accessToken &&
475
- content &&
476
- areAllRequiredElementsChecked &&
477
- !isSubmitting &&
478
- !isCheckingConsent &&
479
- !hasAlreadyConsented &&
480
- !hasSubmittedRef.current
481
- ) {
482
- hasSubmittedRef.current = true;
483
- const autoSubmit = async () => {
484
- try {
485
- await handleAcceptWithToken(accessToken);
486
- } catch (err) {
487
- hasSubmittedRef.current = false;
488
- onError?.(err as Error);
489
- }
490
- };
491
- autoSubmit();
492
- }
493
- }, [
494
- accessToken,
495
- content,
496
- areAllRequiredElementsChecked,
497
- isSubmitting,
498
- isCheckingConsent,
499
- hasAlreadyConsented,
500
- handleAcceptWithToken,
501
- ]);
502
-
503
- // Reset submission ref when accessToken changes (allows re-submission with new token)
504
- useEffect(() => {
505
- if (!accessToken) {
506
- hasSubmittedRef.current = false;
507
- }
508
- }, [accessToken]);
509
-
510
- const headingStyle = {
511
- color: settings?.headingColor || "#101828",
512
- };
513
-
514
- const textStyle = {
515
- color: settings?.textColor || "#344054",
516
- };
517
-
518
- if (hasAlreadyConsented || fetchError) {
519
- return null;
520
- }
521
-
522
- if (isLoading) {
523
- return (
524
- <div style={styles.loadingContainer}>
525
- <div style={styles.loadingSpinner}></div>
526
- <p style={{ ...styles.privacyText, ...textStyle }}>Loading...</p>
527
- </div>
528
- );
529
- }
530
-
531
- if (!content) {
532
- return null;
533
- }
534
-
535
- return (
536
- <div style={{ display: "flex", flexDirection: "column", gap: "16px" }}>
537
- {errorMessage && (
538
- <div
539
- role="alert"
540
- style={{
541
- backgroundColor: "#FEE2E2",
542
- color: "#DC2626",
543
- padding: "12px",
544
- borderRadius: "6px",
545
- fontSize: "14px",
546
- border: "1px solid #FCA5A5",
547
- }}
548
- >
549
- {errorMessage}
550
- </div>
551
- )}
552
-
553
- {content?.purposes?.map((purpose) => (
554
- <div key={purpose.uuid}>
555
- <div style={styles.optionItem}>
556
- <div
557
- style={styles.optionLeft}
558
- onClick={() => togglePurposeCollapse(purpose.uuid)}
559
- role="button"
560
- tabIndex={0}
561
- aria-expanded={!collapsedPurposes[purpose.uuid]}
562
- aria-controls={`purpose-${purpose.uuid}`}
563
- aria-label={`${collapsedPurposes[purpose.uuid] ? "Expand" : "Collapse"} ${getTranslatedText(
564
- `purposes.name`,
565
- purpose.name,
566
- purpose.uuid
567
- )} details`}
568
- onKeyDown={(e) => {
569
- if (e.key === "Enter" || e.key === " ") {
570
- e.preventDefault();
571
- togglePurposeCollapse(purpose.uuid);
572
- }
573
- }}
574
- >
575
- <div
576
- style={{
577
- display: "flex",
578
- alignItems: "center",
579
- justifyContent: "center",
580
- marginLeft: "5px",
581
- }}
582
- >
583
- <svg
584
- width="7"
585
- height="12"
586
- viewBox="0 0 7 12"
587
- fill="none"
588
- xmlns="http://www.w3.org/2000/svg"
589
- stroke={settings?.headingColor || "#323B4B"}
590
- strokeWidth="2"
591
- strokeLinecap="round"
592
- strokeLinejoin="round"
593
- style={{
594
- transform: !collapsedPurposes[purpose.uuid]
595
- ? "rotate(90deg)"
596
- : "rotate(0deg)",
597
- transition: "transform 0.3s ease",
598
- }}
599
- aria-hidden="true"
600
- >
601
- <path d="M1 1L6 6L1 11" />
602
- </svg>
603
- </div>
604
- <div style={styles.optionTextContainer}>
605
- <h2
606
- style={{
607
- ...styles.optionTitle,
608
- ...responsiveStyles.optionTitle,
609
- ...headingStyle,
610
- }}
611
- >
612
- {getTranslatedText(
613
- `purposes.name`,
614
- purpose.name,
615
- purpose.uuid
616
- )}
617
- </h2>
618
- <h3
619
- style={{
620
- ...styles.optionDescription,
621
- ...responsiveStyles.optionDescription,
622
- ...textStyle,
623
- }}
624
- >
625
- {getTranslatedText(
626
- `purposes.description`,
627
- purpose.description,
628
- purpose.uuid
629
- )}
630
- </h3>
631
- </div>
632
- </div>
633
- <input
634
- type="checkbox"
635
- checked={selectedPurposes[purpose.uuid] || false}
636
- onChange={() => handlePurposeCheckboxChange(purpose.uuid)}
637
- aria-label={`Select all data elements for ${getTranslatedText(
638
- `purposes.name`,
639
- purpose.name,
640
- purpose.uuid
641
- )}`}
642
- />
643
- </div>
644
- {!collapsedPurposes[purpose.uuid] &&
645
- purpose.data_elements &&
646
- purpose.data_elements.length > 0 && (
647
- <div
648
- id={`purpose-${purpose.uuid}`}
649
- style={styles.dataElementsContainer}
650
- >
651
- {purpose.data_elements.map((dataElement) => (
652
- <div key={dataElement.uuid} style={styles.dataElementItem}>
653
- <span
654
- style={{
655
- ...styles.dataElementText,
656
- ...responsiveStyles.dataElementText,
657
- ...textStyle,
658
- }}
659
- >
660
- {getTranslatedText(
661
- `data_elements.name`,
662
- dataElement.name,
663
- dataElement.uuid
664
- )}
665
- {dataElement.required && (
666
- <span
667
- style={{
668
- color: "red",
669
- marginLeft: "4px",
670
- }}
671
- aria-label="required"
672
- >
673
- *
674
- </span>
675
- )}
676
- </span>
677
- <input
678
- type="checkbox"
679
- checked={
680
- selectedDataElements[
681
- `${purpose.uuid}-${dataElement.uuid}`
682
- ] || false
683
- }
684
- onChange={() =>
685
- handleDataElementCheckboxChange(
686
- dataElement.uuid,
687
- purpose.uuid
688
- )
689
- }
690
- aria-label={`Select ${getTranslatedText(
691
- `data_elements.name`,
692
- dataElement.name,
693
- dataElement.uuid
694
- )}${dataElement.required ? " (required)" : ""}`}
695
- />
696
- </div>
697
- ))}
698
- </div>
699
- )}
700
- </div>
701
- ))}
702
- </div>
703
- );
704
- };
705
-
706
- RedactoConsentInlineComponent.displayName = "RedactoConsentInline";
707
-
708
- // Memoize the component to prevent unnecessary re-renders when props haven't changed
709
- export const RedactoConsentInline = memo(RedactoConsentInlineComponent);