@redacto.io/consent-sdk-react 5.2.0 → 6.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.
- package/.turbo/turbo-build.log +24 -0
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +24 -1
- package/dist/index.d.ts +24 -1
- package/dist/index.js +149 -206
- package/dist/index.mjs +148 -206
- package/dist/privacy-center.d.mts +178 -39
- package/dist/privacy-center.d.ts +178 -39
- package/dist/privacy-center.js +10534 -6795
- package/dist/privacy-center.mjs +7922 -4181
- package/package.json +1 -1
- package/src/RedactoNoticeConsent/RedactoNoticeConsent.tsx +16 -20
- package/src/RedactoNoticeConsent/api/index.ts +21 -103
- package/src/RedactoNoticeConsentInline/RedactoNoticeConsentInline.tsx +5 -4
- package/src/RedactoNoticeConsentInline/api/index.ts +64 -117
- package/src/RedactoPrivacyCenter/NotificationsPage.tsx +174 -0
- package/src/RedactoPrivacyCenter/PrivacyCenterHomePage.tsx +3 -0
- package/src/RedactoPrivacyCenter/api/actions.ts +136 -8
- package/src/RedactoPrivacyCenter/api/client.ts +176 -15
- package/src/RedactoPrivacyCenter/components/ConsentManager.tsx +722 -273
- package/src/RedactoPrivacyCenter/components/ConsentManagerCells.tsx +187 -0
- package/src/RedactoPrivacyCenter/components/ConsentManagerColumns.tsx +65 -165
- package/src/RedactoPrivacyCenter/components/ConsentManagerExpandedRow.tsx +179 -0
- package/src/RedactoPrivacyCenter/components/ConsentManagerGroupedColumns.tsx +318 -0
- package/src/RedactoPrivacyCenter/components/ConsentManagerProductCards.tsx +333 -0
- package/src/RedactoPrivacyCenter/components/ConsentManagerPurposeCards.tsx +102 -0
- package/src/RedactoPrivacyCenter/components/ConsentManagerTableSkeleton.tsx +6 -2
- package/src/RedactoPrivacyCenter/components/DataRequest/PurposeSelectionSection.tsx +15 -0
- package/src/RedactoPrivacyCenter/components/ModifyConsentModal.tsx +8 -5
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationBell.tsx +160 -0
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationCTAButton.tsx +18 -0
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdown.tsx +54 -0
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationDropdownItem.tsx +57 -0
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationIcon.tsx +19 -0
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationListPanel.tsx +92 -0
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRefreshButton.tsx +20 -0
- package/src/RedactoPrivacyCenter/components/NotificationHub/NotificationRow.tsx +58 -0
- package/src/RedactoPrivacyCenter/components/NotificationHub/StatCard.tsx +10 -0
- package/src/RedactoPrivacyCenter/components/NotificationHub/useNotificationActions.ts +112 -0
- package/src/RedactoPrivacyCenter/components/NotificationHub/utils.ts +27 -0
- package/src/RedactoPrivacyCenter/components/PrivacyCenterLayout.tsx +105 -55
- package/src/RedactoPrivacyCenter/components/types.ts +2 -5
- package/src/RedactoPrivacyCenter/context/NavigationContext.tsx +2 -2
- package/src/RedactoPrivacyCenter/context/PageChromeContext.tsx +21 -1
- package/src/RedactoPrivacyCenter/lib/api.ts +147 -28
- package/src/RedactoPrivacyCenter/lib/consent-manager/utils.tsx +4 -2
- package/src/RedactoPrivacyCenter/lib/constants.ts +78 -1
- package/src/RedactoPrivacyCenter/lib/types.ts +205 -36
- package/src/RedactoPrivacyCenter/lib/utils.ts +3 -0
- package/src/RedactoPrivacyCenter/locales/as/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/bho/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/bn/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/brx/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/doi/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/en/translation.json +42 -1
- package/src/RedactoPrivacyCenter/locales/gom/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/gu/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/hi/translation.json +15 -1
- package/src/RedactoPrivacyCenter/locales/kn/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/ks/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/mai/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/ml/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/mni-Mtei/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/mr/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/ne/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/or/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/pa/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/sa/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/sat/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/sd/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/ta/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/te/translation.json +12 -1
- package/src/RedactoPrivacyCenter/locales/ur/translation.json +12 -1
- package/src/RedactoPrivacyCenter/styles/injectStyles.ts +1027 -0
- package/src/RedactoPrivacyCenter/styles/variables.css +5 -0
- package/src/RedactoPrivacyCenter/table/AdvancedTable.tsx +36 -16
- package/src/RedactoPrivacyCenter/table/AdvancedTablePagination.tsx +4 -12
- package/src/RedactoPrivacyCenter/ui/PCInput.tsx +1 -1
- package/src/RedactoPrivacyCenter/ui/PCPopover.tsx +23 -1
- package/src/RedactoPrivacyCenter/ui/PCSelect.tsx +51 -5
- package/src/RedactoPrivacyCenter/ui/ThemeToggle.tsx +2 -4
- package/src/index.ts +5 -0
- package/src/privacy-center.ts +8 -3
- package/src/shared/api-errors.ts +171 -0
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,64 @@ import { useCallback, useEffect as useEffect2, useMemo, useRef, useState as useS
|
|
|
3
3
|
|
|
4
4
|
// src/RedactoNoticeConsent/api/index.ts
|
|
5
5
|
import { jwtDecode } from "jwt-decode";
|
|
6
|
+
|
|
7
|
+
// src/shared/api-errors.ts
|
|
8
|
+
var ApiError = class extends Error {
|
|
9
|
+
constructor(opts) {
|
|
10
|
+
super(opts.message);
|
|
11
|
+
this.name = "ApiError";
|
|
12
|
+
this.status = opts.status;
|
|
13
|
+
this.code = opts.code;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
function statusFallback(status) {
|
|
17
|
+
if (status === 401) {
|
|
18
|
+
return "Your session has expired. Please request a new access link.";
|
|
19
|
+
}
|
|
20
|
+
if (status === 403) {
|
|
21
|
+
return "You do not have access to this resource.";
|
|
22
|
+
}
|
|
23
|
+
if (status >= 500) {
|
|
24
|
+
return "Something went wrong on our end. Please try again later.";
|
|
25
|
+
}
|
|
26
|
+
return void 0;
|
|
27
|
+
}
|
|
28
|
+
function extractFromDetail(detail) {
|
|
29
|
+
var _a;
|
|
30
|
+
if (typeof detail === "string") {
|
|
31
|
+
return { message: detail };
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(detail)) {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
if (detail && typeof detail === "object") {
|
|
37
|
+
const obj = detail;
|
|
38
|
+
return { message: (_a = obj.message) != null ? _a : obj.detail, code: obj.error_code };
|
|
39
|
+
}
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
async function parseApiError(response, fallbackMessage) {
|
|
43
|
+
var _a, _b, _c, _d;
|
|
44
|
+
let body;
|
|
45
|
+
let parsedBody = false;
|
|
46
|
+
try {
|
|
47
|
+
body = await response.json();
|
|
48
|
+
parsedBody = true;
|
|
49
|
+
} catch {
|
|
50
|
+
body = void 0;
|
|
51
|
+
}
|
|
52
|
+
const fromDetail = extractFromDetail(body == null ? void 0 : body.detail);
|
|
53
|
+
const serverMessage = (_a = body == null ? void 0 : body.message) != null ? _a : fromDetail.message;
|
|
54
|
+
const message = (_b = serverMessage != null ? serverMessage : parsedBody ? statusFallback(response.status) : void 0) != null ? _b : fallbackMessage;
|
|
55
|
+
const code = (_d = (_c = body == null ? void 0 : body.error_code) != null ? _c : fromDetail.code) != null ? _d : void 0;
|
|
56
|
+
return new ApiError({
|
|
57
|
+
status: response.status,
|
|
58
|
+
code,
|
|
59
|
+
message
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// src/RedactoNoticeConsent/api/index.ts
|
|
6
64
|
var BASE_URL = "https://api.redacto.io/consent";
|
|
7
65
|
var apiCache = /* @__PURE__ */ new Map();
|
|
8
66
|
var CACHE_TTL = 5 * 60 * 1e3;
|
|
@@ -78,21 +136,10 @@ var fetchConsentContent = async ({
|
|
|
78
136
|
signal
|
|
79
137
|
});
|
|
80
138
|
if (!response.ok) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
errorMessage = "Forbidden: Access denied";
|
|
86
|
-
} else if (response.status === 404) {
|
|
87
|
-
errorMessage = "Notice not found";
|
|
88
|
-
} else if (response.status === 409) {
|
|
89
|
-
errorMessage = "User has already provided consent";
|
|
90
|
-
} else if (response.status >= 500) {
|
|
91
|
-
errorMessage = "Server error: Please try again later";
|
|
92
|
-
}
|
|
93
|
-
const error = new Error(errorMessage);
|
|
94
|
-
error.status = response.status;
|
|
95
|
-
throw error;
|
|
139
|
+
throw await parseApiError(
|
|
140
|
+
response,
|
|
141
|
+
"Could not load the consent notice. Please try again."
|
|
142
|
+
);
|
|
96
143
|
}
|
|
97
144
|
const data = await response.json();
|
|
98
145
|
if (validate_against === "all" && !specific_uuid) {
|
|
@@ -162,26 +209,10 @@ var submitConsentEvent = async ({
|
|
|
162
209
|
}
|
|
163
210
|
);
|
|
164
211
|
if (!response.ok) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
try
|
|
168
|
-
|
|
169
|
-
errorMessage = errorData.message || "Invalid request data";
|
|
170
|
-
} catch {
|
|
171
|
-
errorMessage = "Invalid request data";
|
|
172
|
-
}
|
|
173
|
-
} else if (response.status === 401) {
|
|
174
|
-
errorMessage = "Unauthorized: Invalid or expired token";
|
|
175
|
-
} else if (response.status === 403) {
|
|
176
|
-
errorMessage = "Forbidden: Access denied";
|
|
177
|
-
} else if (response.status === 404) {
|
|
178
|
-
errorMessage = "Notice not found";
|
|
179
|
-
} else if (response.status >= 500) {
|
|
180
|
-
errorMessage = "Server error: Please try again later";
|
|
181
|
-
}
|
|
182
|
-
const error = new Error(errorMessage);
|
|
183
|
-
error.status = response.status;
|
|
184
|
-
throw error;
|
|
212
|
+
throw await parseApiError(
|
|
213
|
+
response,
|
|
214
|
+
"Could not submit your consent. Please try again."
|
|
215
|
+
);
|
|
185
216
|
}
|
|
186
217
|
apiCache.clear();
|
|
187
218
|
};
|
|
@@ -214,19 +245,10 @@ var fetchTTSAudioUrls = async ({
|
|
|
214
245
|
signal
|
|
215
246
|
});
|
|
216
247
|
if (!response.ok) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
errorMessage = "Forbidden: Access denied";
|
|
222
|
-
} else if (response.status === 404) {
|
|
223
|
-
errorMessage = "Notice or audio not found";
|
|
224
|
-
} else if (response.status >= 500) {
|
|
225
|
-
errorMessage = "Server error: Please try again later";
|
|
226
|
-
}
|
|
227
|
-
const error = new Error(errorMessage);
|
|
228
|
-
error.status = response.status;
|
|
229
|
-
throw error;
|
|
248
|
+
throw await parseApiError(
|
|
249
|
+
response,
|
|
250
|
+
"Could not load audio narration. Please try again."
|
|
251
|
+
);
|
|
230
252
|
}
|
|
231
253
|
const data = await response.json();
|
|
232
254
|
return data;
|
|
@@ -288,31 +310,10 @@ var initiateGuardianVerification = async ({
|
|
|
288
310
|
}
|
|
289
311
|
);
|
|
290
312
|
if (!response.ok) {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
try
|
|
294
|
-
|
|
295
|
-
errorMessage = errorData.message || "Invalid request data";
|
|
296
|
-
} catch {
|
|
297
|
-
errorMessage = "Invalid request data";
|
|
298
|
-
}
|
|
299
|
-
} else if (response.status === 401) {
|
|
300
|
-
errorMessage = "Unauthorized: Invalid or expired token";
|
|
301
|
-
} else if (response.status === 404) {
|
|
302
|
-
errorMessage = "Organization or workspace not found";
|
|
303
|
-
} else if (response.status === 422) {
|
|
304
|
-
try {
|
|
305
|
-
const errorData = await response.json();
|
|
306
|
-
errorMessage = errorData.message || "Validation error: Please check your input";
|
|
307
|
-
} catch {
|
|
308
|
-
errorMessage = "Validation error: Please check your input";
|
|
309
|
-
}
|
|
310
|
-
} else if (response.status >= 500) {
|
|
311
|
-
errorMessage = "Server error: Please try again later";
|
|
312
|
-
}
|
|
313
|
-
const error = new Error(errorMessage);
|
|
314
|
-
error.status = response.status;
|
|
315
|
-
throw error;
|
|
313
|
+
throw await parseApiError(
|
|
314
|
+
response,
|
|
315
|
+
"Could not start guardian verification. Please try again."
|
|
316
|
+
);
|
|
316
317
|
}
|
|
317
318
|
const responseData = await response.json();
|
|
318
319
|
const detail = responseData.detail || responseData;
|
|
@@ -346,7 +347,7 @@ var verifyGuardianStatus = async ({
|
|
|
346
347
|
sessionToken,
|
|
347
348
|
signal
|
|
348
349
|
}) => {
|
|
349
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
350
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
350
351
|
if (!accessToken || !sessionToken) {
|
|
351
352
|
throw new Error("accessToken and sessionToken are required");
|
|
352
353
|
}
|
|
@@ -374,37 +375,21 @@ var verifyGuardianStatus = async ({
|
|
|
374
375
|
}
|
|
375
376
|
);
|
|
376
377
|
if (!response.ok) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
try
|
|
380
|
-
|
|
381
|
-
errorMessage = errorData.message || ((_a = errorData.detail) == null ? void 0 : _a.message) || "Invalid session token";
|
|
382
|
-
} catch {
|
|
383
|
-
errorMessage = "Invalid session token";
|
|
384
|
-
}
|
|
385
|
-
} else if (response.status === 401) {
|
|
386
|
-
errorMessage = "Unauthorized: Invalid or expired token";
|
|
387
|
-
} else if (response.status === 404) {
|
|
388
|
-
errorMessage = "Verification session not found or expired. Please restart the verification process.";
|
|
389
|
-
} else if (response.status === 410) {
|
|
390
|
-
errorMessage = "Verification session has expired. Please restart the verification process.";
|
|
391
|
-
} else if (response.status >= 500) {
|
|
392
|
-
errorMessage = "Server error: Please try again later";
|
|
393
|
-
}
|
|
394
|
-
const error = new Error(errorMessage);
|
|
395
|
-
error.status = response.status;
|
|
396
|
-
throw error;
|
|
378
|
+
throw await parseApiError(
|
|
379
|
+
response,
|
|
380
|
+
"Could not check verification status. Please try again."
|
|
381
|
+
);
|
|
397
382
|
}
|
|
398
383
|
const responseData = await response.json();
|
|
399
384
|
const detail = responseData.detail || responseData;
|
|
400
385
|
return {
|
|
401
|
-
status: (
|
|
402
|
-
guardian_info_uuid: (
|
|
403
|
-
verification_reference: (
|
|
404
|
-
guardian_details: (
|
|
405
|
-
error: (
|
|
406
|
-
error_code: (
|
|
407
|
-
can_retry: (
|
|
386
|
+
status: (_a = detail.status) != null ? _a : "in_progress",
|
|
387
|
+
guardian_info_uuid: (_b = detail.guardian_info_uuid) != null ? _b : null,
|
|
388
|
+
verification_reference: (_c = detail.verification_reference) != null ? _c : null,
|
|
389
|
+
guardian_details: (_d = detail.guardian_details) != null ? _d : null,
|
|
390
|
+
error: (_e = detail.error) != null ? _e : null,
|
|
391
|
+
error_code: (_f = detail.error_code) != null ? _f : null,
|
|
392
|
+
can_retry: (_g = detail.can_retry) != null ? _g : true
|
|
408
393
|
};
|
|
409
394
|
};
|
|
410
395
|
|
|
@@ -2901,7 +2886,7 @@ var RedactoNoticeConsent = ({
|
|
|
2901
2886
|
return;
|
|
2902
2887
|
}
|
|
2903
2888
|
const err = error;
|
|
2904
|
-
const message = err.
|
|
2889
|
+
const message = err.message || "Failed to submit consent. Please try again.";
|
|
2905
2890
|
setErrorMessage(message);
|
|
2906
2891
|
onError == null ? void 0 : onError(error);
|
|
2907
2892
|
} finally {
|
|
@@ -3323,20 +3308,12 @@ var RedactoNoticeConsent = ({
|
|
|
3323
3308
|
}, []);
|
|
3324
3309
|
const availableLanguages = useMemo(() => {
|
|
3325
3310
|
if (!content) return [language];
|
|
3326
|
-
const
|
|
3311
|
+
const pinned = ["English"];
|
|
3327
3312
|
if (content.default_language && content.default_language !== "English" && content.default_language !== "en") {
|
|
3328
|
-
|
|
3313
|
+
pinned.push(content.default_language);
|
|
3329
3314
|
}
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
(lang) => {
|
|
3333
|
-
if (!languages.includes(lang)) {
|
|
3334
|
-
languages.push(lang);
|
|
3335
|
-
}
|
|
3336
|
-
}
|
|
3337
|
-
);
|
|
3338
|
-
}
|
|
3339
|
-
return languages;
|
|
3315
|
+
const rest = content.supported_languages_and_translations ? Object.keys(content.supported_languages_and_translations).filter((lang) => !pinned.includes(lang)).sort((a, b) => a.localeCompare(b, "en")) : [];
|
|
3316
|
+
return [...pinned, ...rest];
|
|
3340
3317
|
}, [content, language]);
|
|
3341
3318
|
const getLanguageCode = useCallback(
|
|
3342
3319
|
(displayLanguage) => {
|
|
@@ -4581,40 +4558,27 @@ var fetchConsentContent2 = async ({
|
|
|
4581
4558
|
baseUrl,
|
|
4582
4559
|
specific_uuid
|
|
4583
4560
|
}) => {
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
"Content-Type": "application/json"
|
|
4596
|
-
}
|
|
4597
|
-
});
|
|
4598
|
-
if (response.status === 401) {
|
|
4599
|
-
const error = new Error("Unauthorized");
|
|
4600
|
-
error.status = 401;
|
|
4601
|
-
throw error;
|
|
4602
|
-
}
|
|
4603
|
-
if (response.status === 409) {
|
|
4604
|
-
const error = new Error("User has already provided consent");
|
|
4605
|
-
error.status = 409;
|
|
4606
|
-
throw error;
|
|
4607
|
-
}
|
|
4608
|
-
if (!response.ok) {
|
|
4609
|
-
throw new Error(
|
|
4610
|
-
`Failed to fetch consent content: ${response.statusText}`
|
|
4611
|
-
);
|
|
4561
|
+
const apiBaseUrl = baseUrl || BASE_URL2;
|
|
4562
|
+
const url = new URL(
|
|
4563
|
+
`${apiBaseUrl}/public/organisations/${org_uuid}/workspaces/${workspace_uuid}/notices/get-notice/${notice_uuid}`
|
|
4564
|
+
);
|
|
4565
|
+
if (specific_uuid) {
|
|
4566
|
+
url.searchParams.append("specific_uuid", specific_uuid);
|
|
4567
|
+
}
|
|
4568
|
+
const response = await fetch(url.toString(), {
|
|
4569
|
+
method: "GET",
|
|
4570
|
+
headers: {
|
|
4571
|
+
"Content-Type": "application/json"
|
|
4612
4572
|
}
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4573
|
+
});
|
|
4574
|
+
if (!response.ok) {
|
|
4575
|
+
throw await parseApiError(
|
|
4576
|
+
response,
|
|
4577
|
+
"Could not load the consent notice. Please try again."
|
|
4578
|
+
);
|
|
4617
4579
|
}
|
|
4580
|
+
const data = await response.json();
|
|
4581
|
+
return data;
|
|
4618
4582
|
};
|
|
4619
4583
|
var submitConsentEvent2 = async ({
|
|
4620
4584
|
org_uuid,
|
|
@@ -4626,67 +4590,44 @@ var submitConsentEvent2 = async ({
|
|
|
4626
4590
|
declined,
|
|
4627
4591
|
meta_data
|
|
4628
4592
|
}) => {
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
if (!purpose.uuid) {
|
|
4636
|
-
throw new Error(`Invalid purpose data: missing uuid`);
|
|
4637
|
-
}
|
|
4638
|
-
const dataElements = purpose.data_elements.filter((element) => element.enabled).map((element) => ({
|
|
4639
|
-
uuid: element.uuid,
|
|
4640
|
-
selected: element.required ? true : Boolean(element.selected)
|
|
4641
|
-
}));
|
|
4642
|
-
return {
|
|
4643
|
-
purpose_uuid: purpose.uuid,
|
|
4644
|
-
selected: Boolean(purpose.selected),
|
|
4645
|
-
data_elements: dataElements.length > 0 ? dataElements : void 0
|
|
4646
|
-
};
|
|
4647
|
-
}),
|
|
4648
|
-
select_all_mandatory: false,
|
|
4649
|
-
source: "WEB",
|
|
4650
|
-
declined,
|
|
4651
|
-
meta_data
|
|
4652
|
-
};
|
|
4653
|
-
const response = await fetch(
|
|
4654
|
-
`${apiBaseUrl}/public/organisations/${org_uuid}/workspaces/${workspace_uuid}/submit-consent`,
|
|
4655
|
-
{
|
|
4656
|
-
method: "POST",
|
|
4657
|
-
headers: {
|
|
4658
|
-
Authorization: `Bearer ${accessToken}`,
|
|
4659
|
-
"Content-Type": "application/json"
|
|
4660
|
-
},
|
|
4661
|
-
body: JSON.stringify(payload)
|
|
4662
|
-
}
|
|
4663
|
-
);
|
|
4664
|
-
if (!response.ok) {
|
|
4665
|
-
let errorData;
|
|
4666
|
-
try {
|
|
4667
|
-
errorData = await response.json();
|
|
4668
|
-
} catch {
|
|
4669
|
-
errorData = { message: response.statusText };
|
|
4670
|
-
}
|
|
4671
|
-
if (response.status === 409) {
|
|
4672
|
-
const error2 = new Error(
|
|
4673
|
-
((_a = errorData.detail) == null ? void 0 : _a.message) || errorData.message || "User has already provided consent"
|
|
4674
|
-
);
|
|
4675
|
-
error2.status = 409;
|
|
4676
|
-
error2.code = errorData.code || 409;
|
|
4677
|
-
error2.detail = errorData.detail;
|
|
4678
|
-
throw error2;
|
|
4593
|
+
const apiBaseUrl = baseUrl || BASE_URL2;
|
|
4594
|
+
const payload = {
|
|
4595
|
+
notice_uuid: noticeUuid,
|
|
4596
|
+
purposes: purposes.map((purpose) => {
|
|
4597
|
+
if (!purpose.uuid) {
|
|
4598
|
+
throw new Error(`Invalid purpose data: missing uuid`);
|
|
4679
4599
|
}
|
|
4680
|
-
const
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4600
|
+
const dataElements = purpose.data_elements.filter((element) => element.enabled).map((element) => ({
|
|
4601
|
+
uuid: element.uuid,
|
|
4602
|
+
selected: element.required ? true : Boolean(element.selected)
|
|
4603
|
+
}));
|
|
4604
|
+
return {
|
|
4605
|
+
purpose_uuid: purpose.uuid,
|
|
4606
|
+
selected: Boolean(purpose.selected),
|
|
4607
|
+
data_elements: dataElements.length > 0 ? dataElements : void 0
|
|
4608
|
+
};
|
|
4609
|
+
}),
|
|
4610
|
+
select_all_mandatory: false,
|
|
4611
|
+
source: "WEB",
|
|
4612
|
+
declined,
|
|
4613
|
+
meta_data
|
|
4614
|
+
};
|
|
4615
|
+
const response = await fetch(
|
|
4616
|
+
`${apiBaseUrl}/public/organisations/${org_uuid}/workspaces/${workspace_uuid}/submit-consent`,
|
|
4617
|
+
{
|
|
4618
|
+
method: "POST",
|
|
4619
|
+
headers: {
|
|
4620
|
+
Authorization: `Bearer ${accessToken}`,
|
|
4621
|
+
"Content-Type": "application/json"
|
|
4622
|
+
},
|
|
4623
|
+
body: JSON.stringify(payload)
|
|
4687
4624
|
}
|
|
4688
|
-
|
|
4689
|
-
|
|
4625
|
+
);
|
|
4626
|
+
if (!response.ok) {
|
|
4627
|
+
throw await parseApiError(
|
|
4628
|
+
response,
|
|
4629
|
+
"Could not submit your consent. Please try again."
|
|
4630
|
+
);
|
|
4690
4631
|
}
|
|
4691
4632
|
};
|
|
4692
4633
|
|
|
@@ -5359,7 +5300,7 @@ var RedactoConsentInlineComponent = ({
|
|
|
5359
5300
|
hasSubmittedRef.current = false;
|
|
5360
5301
|
} catch (error) {
|
|
5361
5302
|
const err = error;
|
|
5362
|
-
const message = err.
|
|
5303
|
+
const message = err.message || "Failed to submit consent. Please try again.";
|
|
5363
5304
|
setErrorMessage(message);
|
|
5364
5305
|
hasSubmittedRef.current = false;
|
|
5365
5306
|
throw error;
|
|
@@ -6072,6 +6013,7 @@ var DigiLockerCallback = ({
|
|
|
6072
6013
|
] });
|
|
6073
6014
|
};
|
|
6074
6015
|
export {
|
|
6016
|
+
ApiError,
|
|
6075
6017
|
DigiLockerCallback,
|
|
6076
6018
|
RedactoNoticeConsent,
|
|
6077
6019
|
RedactoConsentInline as RedactoNoticeConsentInline
|