@terreno/admin-frontend 0.31.0 → 57.0.0-beta.1
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/dist/AdminShell.d.ts +5 -0
- package/dist/AdminShell.js +100 -31
- package/dist/AdminShell.js.map +1 -1
- package/dist/ConsentHistory.d.ts +9 -0
- package/dist/ConsentHistory.js +61 -0
- package/dist/ConsentHistory.js.map +1 -0
- package/dist/generateConsentHistoryPdf.d.ts +2 -0
- package/dist/generateConsentHistoryPdf.js +225 -0
- package/dist/generateConsentHistoryPdf.js.map +1 -0
- package/dist/generateConsentPdf.js +75 -28
- package/dist/generateConsentPdf.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/pdfUtils.d.ts +9 -0
- package/dist/pdfUtils.js +25 -0
- package/dist/pdfUtils.js.map +1 -0
- package/dist/useAdminBackgroundTask.js.map +1 -1
- package/dist/useConsentHistory.d.ts +63 -0
- package/dist/useConsentHistory.js +40 -0
- package/dist/useConsentHistory.js.map +1 -0
- package/package.json +11 -9
- package/src/AdminModelForm.test.tsx +1 -1
- package/src/AdminModelList.test.tsx +1 -1
- package/src/AdminModelTable.test.tsx +1 -1
- package/src/AdminPrimitiveArrayField.test.tsx +1 -1
- package/src/AdminScriptList.test.tsx +1 -1
- package/src/AdminShell.test.tsx +191 -0
- package/src/AdminShell.tsx +331 -144
- package/src/AdminVersionConfig.test.tsx +1 -1
- package/src/CheckboxListEditor.test.tsx +1 -1
- package/src/ConfigurationScreen.test.tsx +1 -1
- package/src/ConsentFormEditor.test.tsx +1 -1
- package/src/ConsentFormList.test.tsx +1 -1
- package/src/ConsentHistory.test.tsx +161 -0
- package/src/ConsentHistory.tsx +251 -0
- package/src/ConsentResponseViewer.test.tsx +1 -1
- package/src/DocumentStorageBrowser.test.tsx +1 -1
- package/src/LocaleContentEditor.test.tsx +1 -1
- package/src/generateConsentHistoryPdf.ts +259 -0
- package/src/generateConsentPdf.ts +96 -31
- package/src/index.tsx +3 -0
- package/src/isolated/AdminFieldRenderer.isolated.tsx +1 -1
- package/src/isolated/AdminNestedArrayField.isolated.tsx +1 -1
- package/src/isolated/AdminObjectPicker.isolated.tsx +1 -1
- package/src/isolated/AdminScriptRunModal.isolated.tsx +1 -1
- package/src/isolated/DocumentStorageBrowser.isolated.tsx +1 -1
- package/src/isolated/generateConsentPdf.isolated.ts +5 -0
- package/src/pdfUtils.ts +28 -0
- package/src/useAdminBackgroundTask.ts +1 -0
- package/src/useConsentHistory.test.ts +106 -0
- package/src/useConsentHistory.ts +94 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export interface ConsentHistoryEntry {
|
|
2
|
+
_id: string;
|
|
3
|
+
agreed: boolean;
|
|
4
|
+
agreedAt: string;
|
|
5
|
+
checkboxValues?: Record<string, boolean>;
|
|
6
|
+
contentSnapshot?: string;
|
|
7
|
+
form: {
|
|
8
|
+
captureSignature: boolean;
|
|
9
|
+
checkboxes: Array<{label: string; required: boolean; confirmationPrompt?: string}>;
|
|
10
|
+
slug: string;
|
|
11
|
+
title: string;
|
|
12
|
+
type: string;
|
|
13
|
+
version: number;
|
|
14
|
+
} | null;
|
|
15
|
+
formVersionSnapshot?: number;
|
|
16
|
+
ipAddress?: string;
|
|
17
|
+
locale?: string;
|
|
18
|
+
signature?: string;
|
|
19
|
+
signedAt?: string;
|
|
20
|
+
userAgent?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface ConsentHistoryResponse {
|
|
24
|
+
data?: ConsentHistoryEntry[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface ConsentHistoryQueryBuilder {
|
|
28
|
+
query: (options: {providesTags: string[]; query: () => string}) => unknown;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface ConsentHistoryHookState {
|
|
32
|
+
data?: ConsentHistoryEntry[] | ConsentHistoryResponse;
|
|
33
|
+
error: unknown;
|
|
34
|
+
isLoading: boolean;
|
|
35
|
+
refetch: () => void | Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface ConsentHistoryEnhancedApi {
|
|
39
|
+
useGetMyConsentsQuery: () => ConsentHistoryHookState;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface ConsentHistoryApiWithTags {
|
|
43
|
+
injectEndpoints: (options: {
|
|
44
|
+
endpoints: (build: ConsentHistoryQueryBuilder) => {getMyConsents: unknown};
|
|
45
|
+
overrideExisting: boolean;
|
|
46
|
+
}) => ConsentHistoryEnhancedApi;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface ConsentHistoryApi {
|
|
50
|
+
enhanceEndpoints: (options: {addTagTypes: string[]}) => ConsentHistoryApiWithTags;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Cache the enhanced api per (api, baseUrl). `injectEndpoints` logs a console
|
|
55
|
+
* error in development whenever an endpoint with the same name is re-injected
|
|
56
|
+
* (with `overrideExisting: false`), so calling it on every render of every
|
|
57
|
+
* consumer would flood the console. WeakMap-by-api lets the GC reclaim entries
|
|
58
|
+
* when the api object is unreachable.
|
|
59
|
+
*/
|
|
60
|
+
const enhancedApiCache = new WeakMap<ConsentHistoryApi, Map<string, ConsentHistoryEnhancedApi>>();
|
|
61
|
+
|
|
62
|
+
const getEnhancedApi = (api: ConsentHistoryApi, base: string): ConsentHistoryEnhancedApi => {
|
|
63
|
+
let byBase = enhancedApiCache.get(api);
|
|
64
|
+
if (!byBase) {
|
|
65
|
+
byBase = new Map();
|
|
66
|
+
enhancedApiCache.set(api, byBase);
|
|
67
|
+
}
|
|
68
|
+
const cached = byBase.get(base);
|
|
69
|
+
if (cached) {
|
|
70
|
+
return cached;
|
|
71
|
+
}
|
|
72
|
+
const apiWithConsentTags = api.enhanceEndpoints({addTagTypes: ["MyConsents"]});
|
|
73
|
+
const enhanced = apiWithConsentTags.injectEndpoints({
|
|
74
|
+
endpoints: (build) => ({
|
|
75
|
+
getMyConsents: build.query({
|
|
76
|
+
providesTags: ["MyConsents"],
|
|
77
|
+
query: () => `${base}/consents/my`,
|
|
78
|
+
}),
|
|
79
|
+
}),
|
|
80
|
+
overrideExisting: false,
|
|
81
|
+
});
|
|
82
|
+
byBase.set(base, enhanced);
|
|
83
|
+
return enhanced;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const useConsentHistory = (api: ConsentHistoryApi, baseUrl?: string) => {
|
|
87
|
+
const base = baseUrl || "";
|
|
88
|
+
const enhancedApi = getEnhancedApi(api, base);
|
|
89
|
+
|
|
90
|
+
const {data, isLoading, error, refetch} = enhancedApi.useGetMyConsentsQuery();
|
|
91
|
+
const entries: ConsentHistoryEntry[] = Array.isArray(data) ? data : (data?.data ?? []);
|
|
92
|
+
|
|
93
|
+
return {entries, error, isLoading, refetch};
|
|
94
|
+
};
|