@redacto.io/consent-sdk-react 3.4.0 → 3.6.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 (155) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE +176 -0
  3. package/dist/index.d.mts +51 -4
  4. package/dist/index.d.ts +51 -4
  5. package/dist/index.js +1912 -345
  6. package/dist/index.mjs +1911 -345
  7. package/dist/privacy-center.d.mts +566 -0
  8. package/dist/privacy-center.d.ts +566 -0
  9. package/dist/privacy-center.js +17174 -0
  10. package/dist/privacy-center.mjs +17136 -0
  11. package/package.json +47 -3
  12. package/src/RedactoNoticeConsent/RedactoNoticeConsent.test.tsx +201 -118
  13. package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +1194 -93
  14. package/src/RedactoNoticeConsent/api/index.ts +337 -246
  15. package/src/RedactoNoticeConsent/api/types.ts +140 -41
  16. package/src/RedactoNoticeConsent/components/DigiLockerCallback.tsx +602 -0
  17. package/src/RedactoNoticeConsent/components/index.ts +7 -0
  18. package/src/RedactoNoticeConsent/injectStyles.ts +11 -0
  19. package/src/RedactoNoticeConsent/language-codes.ts +61 -0
  20. package/src/RedactoNoticeConsent/services/storage.ts +122 -0
  21. package/src/RedactoNoticeConsent/types.ts +2 -0
  22. package/src/RedactoNoticeConsentInline/api/index.ts +26 -64
  23. package/src/RedactoNoticeConsentInline/api/types.ts +0 -25
  24. package/src/RedactoPrivacyCenter/PrivacyCenterActivityPage.tsx +19 -0
  25. package/src/RedactoPrivacyCenter/PrivacyCenterConsentManagerPage.tsx +17 -0
  26. package/src/RedactoPrivacyCenter/PrivacyCenterFormPage.tsx +79 -0
  27. package/src/RedactoPrivacyCenter/PrivacyCenterHomePage.tsx +27 -0
  28. package/src/RedactoPrivacyCenter/PrivacyCenterLayout.tsx +142 -0
  29. package/src/RedactoPrivacyCenter/RedactoPrivacyCenter.tsx +51 -0
  30. package/src/RedactoPrivacyCenter/api/actions.ts +444 -0
  31. package/src/RedactoPrivacyCenter/api/client.ts +413 -0
  32. package/src/RedactoPrivacyCenter/api/config.ts +33 -0
  33. package/src/RedactoPrivacyCenter/api/fetcher.ts +181 -0
  34. package/src/RedactoPrivacyCenter/api/upload.ts +93 -0
  35. package/src/RedactoPrivacyCenter/assets/character.svg +31 -0
  36. package/src/RedactoPrivacyCenter/assets/fileAttach.svg +9 -0
  37. package/src/RedactoPrivacyCenter/assets/greenTick.svg +4 -0
  38. package/src/RedactoPrivacyCenter/assets/mail.svg +3 -0
  39. package/src/RedactoPrivacyCenter/assets/poweredByRedacto.svg +9 -0
  40. package/src/RedactoPrivacyCenter/assets/sentImg.svg +9 -0
  41. package/src/RedactoPrivacyCenter/assets/uploadFileIcon.svg +9 -0
  42. package/src/RedactoPrivacyCenter/components/ActivitiesList.tsx +272 -0
  43. package/src/RedactoPrivacyCenter/components/CaseDetailsModal.tsx +468 -0
  44. package/src/RedactoPrivacyCenter/components/CaseHistory.tsx +433 -0
  45. package/src/RedactoPrivacyCenter/components/ConsentManager.tsx +726 -0
  46. package/src/RedactoPrivacyCenter/components/ConsentManagerColumns.tsx +239 -0
  47. package/src/RedactoPrivacyCenter/components/ConsentManagerConstants.ts +7 -0
  48. package/src/RedactoPrivacyCenter/components/ConsentManagerTableSkeleton.tsx +155 -0
  49. package/src/RedactoPrivacyCenter/components/DataRequest/CorrectionDataSection.tsx +189 -0
  50. package/src/RedactoPrivacyCenter/components/DataRequest/GrievanceDataSection.tsx +118 -0
  51. package/src/RedactoPrivacyCenter/components/DataRequest/NominationDataSection.tsx +66 -0
  52. package/src/RedactoPrivacyCenter/components/DataRequest/PurposeSelectionSection.tsx +305 -0
  53. package/src/RedactoPrivacyCenter/components/Form.tsx +1455 -0
  54. package/src/RedactoPrivacyCenter/components/GrievanceTable.tsx +176 -0
  55. package/src/RedactoPrivacyCenter/components/GrievanceTablePagination.tsx +330 -0
  56. package/src/RedactoPrivacyCenter/components/ModifyConsentModal.tsx +329 -0
  57. package/src/RedactoPrivacyCenter/components/Pagination.tsx +140 -0
  58. package/src/RedactoPrivacyCenter/components/PrivacyCenterLayout.tsx +302 -0
  59. package/src/RedactoPrivacyCenter/components/RequestSubmit.tsx +218 -0
  60. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/SideBarPC.tsx +475 -0
  61. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/SideMenuPC.tsx +412 -0
  62. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/constants.tsx +42 -0
  63. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/menuItemsPC.tsx +1 -0
  64. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/types.ts +40 -0
  65. package/src/RedactoPrivacyCenter/components/SideMenuBarPC/utils.ts +38 -0
  66. package/src/RedactoPrivacyCenter/components/ThemeTransitionOverlay.tsx +85 -0
  67. package/src/RedactoPrivacyCenter/components/activitiesColumns.tsx +141 -0
  68. package/src/RedactoPrivacyCenter/components/caseHistoryColumns.tsx +179 -0
  69. package/src/RedactoPrivacyCenter/components/constant.ts +20 -0
  70. package/src/RedactoPrivacyCenter/components/types.ts +68 -0
  71. package/src/RedactoPrivacyCenter/components/utils.tsx +10 -0
  72. package/src/RedactoPrivacyCenter/config/routes.ts +9 -0
  73. package/src/RedactoPrivacyCenter/config/table.ts +25 -0
  74. package/src/RedactoPrivacyCenter/context/AuthContext.tsx +123 -0
  75. package/src/RedactoPrivacyCenter/context/BaseUrlContext.tsx +44 -0
  76. package/src/RedactoPrivacyCenter/context/LocaleContext.tsx +11 -0
  77. package/src/RedactoPrivacyCenter/context/NavigationContext.tsx +64 -0
  78. package/src/RedactoPrivacyCenter/context/OrganizationContext.tsx +30 -0
  79. package/src/RedactoPrivacyCenter/context/PageChromeContext.tsx +60 -0
  80. package/src/RedactoPrivacyCenter/context/theme.tsx +127 -0
  81. package/src/RedactoPrivacyCenter/lib/api.ts +468 -0
  82. package/src/RedactoPrivacyCenter/lib/consent-manager/utils.tsx +63 -0
  83. package/src/RedactoPrivacyCenter/lib/constants.ts +116 -0
  84. package/src/RedactoPrivacyCenter/lib/i18n.ts +81 -0
  85. package/src/RedactoPrivacyCenter/lib/locales.ts +105 -0
  86. package/src/RedactoPrivacyCenter/lib/queries.ts +30 -0
  87. package/src/RedactoPrivacyCenter/lib/types.ts +346 -0
  88. package/src/RedactoPrivacyCenter/lib/useCurrentLanguage.ts +37 -0
  89. package/src/RedactoPrivacyCenter/lib/utils.ts +625 -0
  90. package/src/RedactoPrivacyCenter/locales/as/translation.json +188 -0
  91. package/src/RedactoPrivacyCenter/locales/bho/translation.json +188 -0
  92. package/src/RedactoPrivacyCenter/locales/bn/translation.json +188 -0
  93. package/src/RedactoPrivacyCenter/locales/brx/translation.json +188 -0
  94. package/src/RedactoPrivacyCenter/locales/doi/translation.json +188 -0
  95. package/src/RedactoPrivacyCenter/locales/en/translation.json +188 -0
  96. package/src/RedactoPrivacyCenter/locales/gom/translation.json +188 -0
  97. package/src/RedactoPrivacyCenter/locales/gu/translation.json +188 -0
  98. package/src/RedactoPrivacyCenter/locales/hi/translation.json +188 -0
  99. package/src/RedactoPrivacyCenter/locales/kn/translation.json +188 -0
  100. package/src/RedactoPrivacyCenter/locales/ks/translation.json +188 -0
  101. package/src/RedactoPrivacyCenter/locales/mai/translation.json +188 -0
  102. package/src/RedactoPrivacyCenter/locales/ml/translation.json +188 -0
  103. package/src/RedactoPrivacyCenter/locales/mni-Mtei/translation.json +188 -0
  104. package/src/RedactoPrivacyCenter/locales/mr/translation.json +188 -0
  105. package/src/RedactoPrivacyCenter/locales/ne/translation.json +188 -0
  106. package/src/RedactoPrivacyCenter/locales/or/translation.json +188 -0
  107. package/src/RedactoPrivacyCenter/locales/pa/translation.json +188 -0
  108. package/src/RedactoPrivacyCenter/locales/sa/translation.json +188 -0
  109. package/src/RedactoPrivacyCenter/locales/sat/translation.json +188 -0
  110. package/src/RedactoPrivacyCenter/locales/sd/translation.json +188 -0
  111. package/src/RedactoPrivacyCenter/locales/ta/translation.json +188 -0
  112. package/src/RedactoPrivacyCenter/locales/te/translation.json +188 -0
  113. package/src/RedactoPrivacyCenter/locales/ur/translation.json +188 -0
  114. package/src/RedactoPrivacyCenter/styles/base.css +117 -0
  115. package/src/RedactoPrivacyCenter/styles/injectStyles.ts +1000 -0
  116. package/src/RedactoPrivacyCenter/styles/pcStyles.ts +819 -0
  117. package/src/RedactoPrivacyCenter/styles/responsive.ts +138 -0
  118. package/src/RedactoPrivacyCenter/styles/variables.css +133 -0
  119. package/src/RedactoPrivacyCenter/table/AdvancedTable.tsx +365 -0
  120. package/src/RedactoPrivacyCenter/table/AdvancedTablePagination.tsx +479 -0
  121. package/src/RedactoPrivacyCenter/table/index.ts +2 -0
  122. package/src/RedactoPrivacyCenter/types/images.d.ts +29 -0
  123. package/src/RedactoPrivacyCenter/ui/Footer.tsx +73 -0
  124. package/src/RedactoPrivacyCenter/ui/FormBlockWrapper.tsx +54 -0
  125. package/src/RedactoPrivacyCenter/ui/PCAccordion.tsx +87 -0
  126. package/src/RedactoPrivacyCenter/ui/PCActionIcon.tsx +47 -0
  127. package/src/RedactoPrivacyCenter/ui/PCAvatar.tsx +69 -0
  128. package/src/RedactoPrivacyCenter/ui/PCBadge.tsx +48 -0
  129. package/src/RedactoPrivacyCenter/ui/PCButton.tsx +77 -0
  130. package/src/RedactoPrivacyCenter/ui/PCCheckbox.tsx +55 -0
  131. package/src/RedactoPrivacyCenter/ui/PCCollapse.tsx +97 -0
  132. package/src/RedactoPrivacyCenter/ui/PCEmpty.tsx +35 -0
  133. package/src/RedactoPrivacyCenter/ui/PCInput.tsx +128 -0
  134. package/src/RedactoPrivacyCenter/ui/PCLoader.tsx +30 -0
  135. package/src/RedactoPrivacyCenter/ui/PCModal.tsx +104 -0
  136. package/src/RedactoPrivacyCenter/ui/PCPopover.tsx +175 -0
  137. package/src/RedactoPrivacyCenter/ui/PCSelect.tsx +381 -0
  138. package/src/RedactoPrivacyCenter/ui/PCTable.tsx +137 -0
  139. package/src/RedactoPrivacyCenter/ui/PCText.tsx +39 -0
  140. package/src/RedactoPrivacyCenter/ui/PCTextarea.tsx +43 -0
  141. package/src/RedactoPrivacyCenter/ui/PCTitle.tsx +37 -0
  142. package/src/RedactoPrivacyCenter/ui/PCTooltip.tsx +119 -0
  143. package/src/RedactoPrivacyCenter/ui/SimpleBar.tsx +25 -0
  144. package/src/RedactoPrivacyCenter/ui/StatusBadge.tsx +55 -0
  145. package/src/RedactoPrivacyCenter/ui/ThemeToggle.tsx +70 -0
  146. package/src/RedactoPrivacyCenter/ui/index.ts +18 -0
  147. package/src/RedactoPrivacyCenter/utils/cn.ts +28 -0
  148. package/src/RedactoPrivacyCenter/utils/date.ts +48 -0
  149. package/src/RedactoPrivacyCenter/utils/status.ts +111 -0
  150. package/src/RedactoPrivacyCenter/utils/toast.ts +130 -0
  151. package/src/index.ts +10 -0
  152. package/src/privacy-center.ts +107 -0
  153. package/tsconfig.json +2 -0
  154. package/tsup.config.ts +16 -1
  155. package/src/utils/isLegacyApi.ts +0 -12
@@ -0,0 +1,81 @@
1
+ import dayjs from 'dayjs';
2
+ import 'dayjs/locale/hi';
3
+ import 'dayjs/locale/te';
4
+ import 'dayjs/locale/mr';
5
+ import 'dayjs/locale/ta';
6
+ import 'dayjs/locale/ur';
7
+ import 'dayjs/locale/gu';
8
+ import 'dayjs/locale/kn';
9
+ import 'dayjs/locale/ml';
10
+ import 'dayjs/locale/pa-in';
11
+ import 'dayjs/locale/ne';
12
+ import 'dayjs/locale/sd';
13
+ import 'dayjs/locale/bn';
14
+ import 'dayjs/locale/gom-latn';
15
+ import i18n from 'i18next';
16
+ import LanguageDetector from 'i18next-browser-languagedetector';
17
+ import { initReactI18next } from 'react-i18next';
18
+ import translations from './locales';
19
+
20
+ // Map app language codes to dayjs locale IDs.
21
+ // Languages not listed here fall back to 'en'.
22
+ const dayjsLocaleMap: Record<string, string> = {
23
+ hi: 'hi',
24
+ te: 'te',
25
+ mr: 'mr',
26
+ ta: 'ta',
27
+ ur: 'ur',
28
+ gu: 'gu',
29
+ kn: 'kn',
30
+ ml: 'ml',
31
+ pa: 'pa-in',
32
+ ne: 'ne',
33
+ sd: 'sd',
34
+ bn: 'bn',
35
+ gom: 'gom-latn',
36
+ };
37
+
38
+ function syncDayjsLocale(lng: string) {
39
+ dayjs.locale(dayjsLocaleMap[lng] || 'en');
40
+ }
41
+
42
+ // Convert translations to i18next resources format
43
+ // i18next expects: { [language]: { [namespace]: { [key]: value } } }
44
+ const resources: Record<string, Record<string, any>> = {};
45
+ Object.keys(translations).forEach((lang) => {
46
+ resources[lang] = translations[lang];
47
+ });
48
+
49
+ i18n
50
+ .use(LanguageDetector)
51
+ .use(initReactI18next)
52
+ .init({
53
+ resources,
54
+ fallbackLng: 'en',
55
+ defaultNS: 'translation',
56
+ ns: ['translation'],
57
+ debug: false,
58
+ interpolation: {
59
+ escapeValue: false,
60
+ },
61
+ detection: {
62
+ order: ['sessionStorage', 'navigator', 'htmlTag'],
63
+ caches: ['sessionStorage'],
64
+ lookupSessionStorage: 'i18nextLng',
65
+ convertDetectedLanguage: (lng) => {
66
+ // Extract base language code (e.g. 'en-US' -> 'en') so it matches
67
+ // our supported language keys, but preserve script subtags like 'mni-Mtei'.
68
+ const base = lng.split('-')[0];
69
+ if (base && resources[base]) return base;
70
+ return lng;
71
+ },
72
+ },
73
+ react: {
74
+ useSuspense: false,
75
+ },
76
+ });
77
+
78
+ i18n.on('languageChanged', syncDayjsLocale);
79
+ syncDayjsLocale(i18n.language);
80
+
81
+ export default i18n;
@@ -0,0 +1,105 @@
1
+ // Static imports of all locale files for bundling
2
+ import enTranslation from '../locales/en/translation.json';
3
+ import asTranslation from '../locales/as/translation.json';
4
+ import bnTranslation from '../locales/bn/translation.json';
5
+ import bhoTranslation from '../locales/bho/translation.json';
6
+ import brxTranslation from '../locales/brx/translation.json';
7
+ import doiTranslation from '../locales/doi/translation.json';
8
+ import gomTranslation from '../locales/gom/translation.json';
9
+ import guTranslation from '../locales/gu/translation.json';
10
+ import hiTranslation from '../locales/hi/translation.json';
11
+ import knTranslation from '../locales/kn/translation.json';
12
+ import ksTranslation from '../locales/ks/translation.json';
13
+ import maiTranslation from '../locales/mai/translation.json';
14
+ import mlTranslation from '../locales/ml/translation.json';
15
+ import mniMteiTranslation from '../locales/mni-Mtei/translation.json';
16
+ import mrTranslation from '../locales/mr/translation.json';
17
+ import neTranslation from '../locales/ne/translation.json';
18
+ import orTranslation from '../locales/or/translation.json';
19
+ import paTranslation from '../locales/pa/translation.json';
20
+ import saTranslation from '../locales/sa/translation.json';
21
+ import satTranslation from '../locales/sat/translation.json';
22
+ import sdTranslation from '../locales/sd/translation.json';
23
+ import taTranslation from '../locales/ta/translation.json';
24
+ import teTranslation from '../locales/te/translation.json';
25
+ import urTranslation from '../locales/ur/translation.json';
26
+
27
+ const activityFetchErrorTranslations: Record<string, string> = {
28
+ en: 'Failed to fetch activity data',
29
+ as: 'কাৰ্যকলাপৰ তথ্য আনিবলৈ ব্যৰ্থ',
30
+ bn: 'কার্যকলাপের ডেটা আনতে ব্যর্থ',
31
+ bho: 'गतिविधि डेटा लावे में विफल',
32
+ brx: 'खामानि डाटा लाङो दिहुनायाव असफल',
33
+ doi: 'गतिविधि डेटा लावै मे असफल',
34
+ gom: 'क्रियाकलाप डेटा आणपांत अयशस्वी',
35
+ gu: 'પ્રવૃત્તિ ડેટા મેળવવામાં નિષ્ફળ',
36
+ hi: 'गतिविधि डेटा लाने में विफल',
37
+ kn: 'ಚಟುವಟಿಕೆ ಡೇಟಾವನ್ನು ತರಲು ವಿಫಲ',
38
+ ks: 'سرگرمی ڈیٹا حاصل کرنے میں ناکام',
39
+ mai: 'गतिविधि डेटा लावै मे असफल',
40
+ ml: 'പ്രവർത്തന ഡാറ്റ ലഭ്യമാക്കുന്നതിൽ പരാജയപ്പെട്ടു',
41
+ 'mni-Mtei': 'ꯈꯨꯗꯝꯕꯤꯠ ꯗꯦꯇꯥ ꯐꯪꯉꯕꯗ ꯌꯥꯝꯅꯥ ꯋꯥꯏ꯫',
42
+ mr: 'क्रियाकलाप डेटा आणण्यात अयशस्वी',
43
+ ne: 'गतिविधि डेटा ल्याउन असफल',
44
+ or: 'କାର୍ଯ୍ୟକଳାପ ତଥ୍ୟ ଆଣିବାରେ ବିଫଳ',
45
+ pa: 'ਗਤੀਵਿਧੀ ਡਾਟਾ ਲਿਆਉਣ ਵਿੱਚ ਅਸਫਲ',
46
+ sa: 'क्रियाकलाप-दत्तांशम् आने विफलम्',
47
+ sat: 'ᱠᱟᱹᱢᱤ ᱰᱟᱴᱟ ᱟᱹᱜᱩ ᱨᱮ ᱵᱤᱯᱚᱠ',
48
+ sd: 'سرگرمي جي ڊيٽا حاصل ڪرڻ ۾ ناڪام',
49
+ ta: 'செயல்பாட்டு தரவை பெற முடியவில்லை',
50
+ te: 'కార్యకలాప డేటాను తెచ్చుకోవడం విఫలమైంది',
51
+ ur: 'سرگرمی کا ڈیٹا حاصل کرنے میں ناکام',
52
+ };
53
+
54
+ function withSharedActivityErrors(
55
+ language: string,
56
+ translation: Record<string, any>
57
+ ) {
58
+ return {
59
+ ...translation,
60
+ failedToFetchActivityData:
61
+ activityFetchErrorTranslations[language] ??
62
+ activityFetchErrorTranslations.en,
63
+ };
64
+ }
65
+
66
+ // Map of language codes to translation objects
67
+ const translations: Record<string, Record<string, any>> = {
68
+ en: { translation: withSharedActivityErrors('en', enTranslation) },
69
+ as: { translation: withSharedActivityErrors('as', asTranslation) },
70
+ bn: { translation: withSharedActivityErrors('bn', bnTranslation) },
71
+ bho: { translation: withSharedActivityErrors('bho', bhoTranslation) },
72
+ brx: { translation: withSharedActivityErrors('brx', brxTranslation) },
73
+ doi: { translation: withSharedActivityErrors('doi', doiTranslation) },
74
+ gom: { translation: withSharedActivityErrors('gom', gomTranslation) },
75
+ gu: { translation: withSharedActivityErrors('gu', guTranslation) },
76
+ hi: { translation: withSharedActivityErrors('hi', hiTranslation) },
77
+ kn: { translation: withSharedActivityErrors('kn', knTranslation) },
78
+ ks: { translation: withSharedActivityErrors('ks', ksTranslation) },
79
+ mai: { translation: withSharedActivityErrors('mai', maiTranslation) },
80
+ ml: { translation: withSharedActivityErrors('ml', mlTranslation) },
81
+ 'mni-Mtei': { translation: withSharedActivityErrors('mni-Mtei', mniMteiTranslation) },
82
+ mr: { translation: withSharedActivityErrors('mr', mrTranslation) },
83
+ ne: { translation: withSharedActivityErrors('ne', neTranslation) },
84
+ or: { translation: withSharedActivityErrors('or', orTranslation) },
85
+ pa: { translation: withSharedActivityErrors('pa', paTranslation) },
86
+ sa: { translation: withSharedActivityErrors('sa', saTranslation) },
87
+ sat: { translation: withSharedActivityErrors('sat', satTranslation) },
88
+ sd: { translation: withSharedActivityErrors('sd', sdTranslation) },
89
+ ta: { translation: withSharedActivityErrors('ta', taTranslation) },
90
+ te: { translation: withSharedActivityErrors('te', teTranslation) },
91
+ ur: { translation: withSharedActivityErrors('ur', urTranslation) },
92
+ };
93
+
94
+ export function getTranslation(language: string, namespace: string) {
95
+ const langTranslations = translations[language];
96
+ if (!langTranslations) {
97
+ // Fallback to English if language not found
98
+ const fallback = translations.en?.[namespace];
99
+ return fallback || {};
100
+ }
101
+ const translation = langTranslations[namespace];
102
+ return translation || {};
103
+ }
104
+
105
+ export default translations;
@@ -0,0 +1,30 @@
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import { fetchCaseHistory, type AuthContext } from './api';
3
+ import { useBaseUrl } from '../context/BaseUrlContext';
4
+ import { useCurrentLanguage } from './useCurrentLanguage';
5
+
6
+ export const useCaseHistory = (
7
+ organizationId: string | undefined,
8
+ workspaceId: string | undefined,
9
+ contact: string | undefined,
10
+ authContext?: AuthContext
11
+ ) => {
12
+ const { consentClient } = useBaseUrl();
13
+ // Include accessToken in queryKey so queries refetch when tokens change
14
+ // This ensures data is refetched with new tokens after refresh
15
+ const accessToken = authContext?.accessToken;
16
+ const { currentLanguage, langParam } = useCurrentLanguage();
17
+
18
+ return useQuery({
19
+ queryKey: ['caseHistory', organizationId, workspaceId, contact, accessToken, currentLanguage],
20
+ queryFn: async () => {
21
+ if (!organizationId || !workspaceId || !contact) {
22
+ return [];
23
+ }
24
+ const response = await fetchCaseHistory(organizationId, workspaceId, contact, undefined, undefined, authContext, consentClient, langParam);
25
+ return response?.data || [];
26
+ },
27
+ enabled: !!organizationId && !!workspaceId && !!contact && !!consentClient,
28
+ retry: 1,
29
+ });
30
+ };
@@ -0,0 +1,346 @@
1
+ export type Workspace = {
2
+ uuid: string;
3
+ suid: string;
4
+ name: string;
5
+ description: string;
6
+ workspace_type: string;
7
+ status: string;
8
+ };
9
+
10
+ export type OrganizationDetail = {
11
+ uuid: string;
12
+ suid: string;
13
+ name: string;
14
+ slug: string;
15
+ description: string;
16
+ domain: string;
17
+ workspaces: Workspace[];
18
+ ai_summary: Record<string, unknown>;
19
+ icon_url: string | null;
20
+ activated: boolean;
21
+ allowed_domains: string[];
22
+ };
23
+
24
+ export type OrganizationResponse = {
25
+ code: number;
26
+ status: string;
27
+ detail: OrganizationDetail;
28
+ };
29
+
30
+ export type DataElement = {
31
+ uuid: string;
32
+ name: string;
33
+ description: string;
34
+ enabled: boolean;
35
+ required: boolean;
36
+ given_consent: boolean;
37
+ selected: boolean;
38
+ };
39
+
40
+ export type Purpose = {
41
+ uuid: string;
42
+ name: string;
43
+ description: string;
44
+ industries: string;
45
+ selected: boolean;
46
+ given_consent: boolean;
47
+ data_elements: DataElement[];
48
+ status?: string;
49
+ validity?: number | null;
50
+ purpose_uuid?: string;
51
+ enabled?: boolean;
52
+ };
53
+
54
+ export type RawPurposeWrapper = {
55
+ purpose: Purpose;
56
+ };
57
+
58
+ export type GrievanceValue =
59
+ | 'consent_violation'
60
+ | 'unlawful_processing'
61
+ | 'data_breach';
62
+
63
+ export type GrievanceOptions = {
64
+ value: GrievanceValue;
65
+ label: string;
66
+ };
67
+
68
+ export type FormData = {
69
+ uuid: string;
70
+ name: string;
71
+ contact: string;
72
+ grievance_options: GrievanceOptions[];
73
+ purposes: RawPurposeWrapper[];
74
+ };
75
+
76
+ export type FormDataResponse = {
77
+ code: number;
78
+ detail: FormData;
79
+ };
80
+
81
+ export enum RequestTypeEnum {
82
+ ACCESS = 'ACCESS',
83
+ CORRECTION = 'CORRECTION',
84
+ ERASURE = 'erasure',
85
+ GRIEVANCE = 'grievance',
86
+ NOMINATION = 'nomination',
87
+ }
88
+
89
+ export type NominationData = {
90
+ nominee_email: string;
91
+ nominee_mobile?: string;
92
+ };
93
+
94
+ export type UpdatePurpose = {
95
+ purpose_uuid: string;
96
+ data_element_uuids: string[];
97
+ };
98
+
99
+ export type UpdateCorrectionDataItem = {
100
+ name: string;
101
+ curr_value: string;
102
+ new_value: string;
103
+ };
104
+
105
+ export enum GrievanceTypeEnum {
106
+ CONSENT_VIOLATION = 'consent_violation',
107
+ UNLAWFUL_PROCESSING = 'unlawful_processing',
108
+ DATA_BREACH = 'data_breach',
109
+ }
110
+
111
+ export type GrievanceTypeElement = {
112
+ grievance: GrievanceValue;
113
+ };
114
+
115
+ export type UpdateRequestDetails = {
116
+ purposes: UpdatePurpose[];
117
+ correction_data: UpdateCorrectionDataItem[];
118
+ grievance_types?: GrievanceTypeElement[];
119
+ nomination_data?: NominationData;
120
+ };
121
+
122
+ export type UserDataRequest = {
123
+ uuid: string;
124
+ name: string;
125
+ contact: string;
126
+ request_type: RequestTypeEnum;
127
+ supporting_docs_uuids: string[];
128
+ request_details: {
129
+ purposes: UpdatePurpose[];
130
+ correction_data: UpdateCorrectionDataItem[];
131
+ grievance_types: GrievanceTypeElement[];
132
+ nomination_data?: NominationData;
133
+ };
134
+ time_period: number | null;
135
+ requestor_note: string;
136
+ };
137
+
138
+ export type CreateCaseResponse = {
139
+ code: number;
140
+ status: string;
141
+ detail: {
142
+ uuid: string;
143
+ case_id: string;
144
+ };
145
+ };
146
+
147
+ export type OtpResponse = {
148
+ uuid: string;
149
+ to: string;
150
+ channel: string;
151
+ expire_at: string;
152
+ success: boolean;
153
+ message: string;
154
+ };
155
+
156
+ export type OtpVerificationResponse = {
157
+ token: string;
158
+ success: boolean;
159
+ message: string;
160
+ };
161
+
162
+ export type TokenExchangeResponse = {
163
+ token: string;
164
+ refresh_token: string;
165
+ expires_at: string;
166
+ notice_uuid: string;
167
+ };
168
+
169
+ export type FetchOrgParams = {
170
+ slug?: string;
171
+ name?: string;
172
+ };
173
+
174
+ export type ConsentDataElement = {
175
+ uuid: string;
176
+ name: string;
177
+ enabled: boolean;
178
+ required: boolean;
179
+ selected: boolean;
180
+ };
181
+
182
+ export type UserConsent = {
183
+ purpose_uuid?: string;
184
+ purpose: string;
185
+ purpose_description: string;
186
+ status: ConsentStatusEnum;
187
+ given_date: string;
188
+ valid_till: string;
189
+ method: string;
190
+ data_elements: ConsentDataElement[];
191
+ product_uuid?: string;
192
+ product_name?: string;
193
+ product_description?: string | null;
194
+ nominator_info?: NominatorInfo;
195
+ };
196
+
197
+ export type NominatorInfo = {
198
+ org_user_id: string;
199
+ name: string | null;
200
+ uuid: string;
201
+ email: string | null;
202
+ };
203
+
204
+ export type ConsentHistoryStatusSummary = {
205
+ total_purposes: number;
206
+ direct_purposes: number;
207
+ nominated_purposes: number;
208
+ nominee_purposes?: number;
209
+ active_purposes: number;
210
+ inactive_purposes: number;
211
+ };
212
+
213
+ export type ProductConsentHistoryGroup = {
214
+ product_uuid: string;
215
+ product_name: string;
216
+ product_description: string | null;
217
+ purposes: UserConsent[];
218
+ total_purposes: number;
219
+ active_purposes: number;
220
+ };
221
+
222
+ export type NominatedPurposesGroup = {
223
+ nominator_info: NominatorInfo;
224
+ product_groups: ProductConsentHistoryGroup[];
225
+ };
226
+
227
+ export type Pagination = {
228
+ total_count: number;
229
+ offset: number;
230
+ limit: number;
231
+ };
232
+
233
+ export type UserConsentDetail = {
234
+ data?: UserConsent[];
235
+ product_purpose_groups?: ProductConsentHistoryGroup[];
236
+ pagination: Pagination;
237
+ direct_product_groups?: ProductConsentHistoryGroup[];
238
+ user_status?: 'ACTIVE' | 'TRANSFERRED' | null;
239
+ nominated_purposes?: NominatedPurposesGroup[];
240
+ nominators?: NominatorInfo[];
241
+ status_summary?: ConsentHistoryStatusSummary | null;
242
+ };
243
+
244
+ export type UserConsentResponse = {
245
+ code: number;
246
+ status: string;
247
+ detail: UserConsentDetail;
248
+ };
249
+
250
+ export enum ConsentStatusEnum {
251
+ ACTIVE = 'ACTIVE',
252
+ WITHDRAWN = 'WITHDRAW',
253
+ EXPIRED = 'EXPIRED',
254
+ DECLINED = 'DECLINED',
255
+ }
256
+
257
+ export type ConsentAction = 'revoke' | 'regrant' | 'renew';
258
+
259
+ export type ManageConsentResponse = {
260
+ code: number;
261
+ status: string;
262
+ detail: {
263
+ success: boolean;
264
+ };
265
+ };
266
+
267
+ export type ManageConsentParams = {
268
+ organizationId: string;
269
+ workspaceId: string;
270
+ purposeId: string;
271
+ contact: string;
272
+ action: ConsentAction;
273
+ nominatorContact?: string;
274
+ dataElementUuids?: string[];
275
+ };
276
+
277
+ export type GrievanceDataSectionProps = {
278
+ grievanceOptions: GrievanceOptions[];
279
+ selectedGrievances: Record<string, boolean>;
280
+ setSelectedGrievances: React.Dispatch<
281
+ React.SetStateAction<Record<string, boolean>>
282
+ >;
283
+ };
284
+
285
+ export type NominationDataSectionProps = {
286
+ nominationData: NominationData;
287
+ setNominationData: React.Dispatch<React.SetStateAction<NominationData>>;
288
+ isTranslating?: boolean;
289
+ };
290
+
291
+ export type Activity = {
292
+ activity_type: string;
293
+ activity_type_display?: string;
294
+ timestamp: string;
295
+ title: string;
296
+ title_display?: string;
297
+ description: string;
298
+ description_display?: string;
299
+ case_id?: string;
300
+ status?: 'Processing' | 'Completed' | 'Rejected';
301
+ status_display?: string;
302
+ };
303
+
304
+ export type ActivityDetail = {
305
+ data: Activity[];
306
+ pagination: Pagination;
307
+ };
308
+
309
+ export type ActivityResponse = {
310
+ code: number;
311
+ status: string;
312
+ detail: ActivityDetail;
313
+ };
314
+
315
+ export type ActivityBadgeStatus =
316
+ | 'success'
317
+ | 'warning'
318
+ | 'error'
319
+ | 'info'
320
+ | 'pending';
321
+
322
+ export type CaseRequest = {
323
+ uuid: string;
324
+ case_id: string;
325
+ status: string;
326
+ status_display?: string;
327
+ request_type: string;
328
+ request_type_display?: string;
329
+ description: string;
330
+ description_display?: string;
331
+ created_at: string;
332
+ completed_at?: string;
333
+ due_date?: string;
334
+ request_details?: any;
335
+ };
336
+
337
+ export type CaseHistoryDetail = {
338
+ data: CaseRequest[];
339
+ pagination: Pagination;
340
+ };
341
+
342
+ export type CaseHistoryResponse = {
343
+ code: number;
344
+ status: string;
345
+ detail: CaseRequest[];
346
+ };
@@ -0,0 +1,37 @@
1
+ import { useSyncExternalStore, useCallback } from 'react';
2
+ import i18n from './i18n';
3
+
4
+ const DEFAULT_LANGUAGE = 'en';
5
+
6
+ /**
7
+ * Returns the language query param to send to the API.
8
+ * Returns `undefined` for the default language (English) so that
9
+ * existing un-localised behaviour is preserved.
10
+ */
11
+ export function getLangParam(language: string): string | undefined {
12
+ return language !== DEFAULT_LANGUAGE ? language : undefined;
13
+ }
14
+
15
+ /**
16
+ * React hook that subscribes to i18next language changes.
17
+ * Returns `{ currentLanguage, langParam }` where `langParam`
18
+ * is `undefined` for the default language.
19
+ *
20
+ * Unlike reading `i18n.language` directly, this hook triggers a
21
+ * component re-render whenever the language changes.
22
+ */
23
+ export function useCurrentLanguage() {
24
+ const subscribe = useCallback((onStoreChange: () => void) => {
25
+ i18n.on('languageChanged', onStoreChange);
26
+ return () => {
27
+ i18n.off('languageChanged', onStoreChange);
28
+ };
29
+ }, []);
30
+
31
+ const getSnapshot = useCallback(() => i18n.language, []);
32
+
33
+ const currentLanguage = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
34
+ const langParam = getLangParam(currentLanguage);
35
+
36
+ return { currentLanguage, langParam };
37
+ }