@tantainnovative/ndpr-toolkit 1.0.1 → 1.0.3
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/.claude/settings.local.json +20 -0
- package/.eslintrc.json +10 -0
- package/.github/workflows/ci.yml +36 -0
- package/.github/workflows/nextjs.yml +104 -0
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/.lintstagedrc.js +4 -0
- package/.nvmrc +1 -0
- package/.versionrc +17 -0
- package/CHANGELOG.md +16 -0
- package/CLAUDE.md +90 -0
- package/CNAME +1 -0
- package/CONTRIBUTING.md +87 -0
- package/README.md +84 -431
- package/RELEASE-NOTES-v1.0.0.md +140 -0
- package/RELEASE-NOTES-v1.0.1.md +69 -0
- package/SECURITY.md +21 -0
- package/commitlint.config.js +36 -0
- package/components.json +21 -0
- package/eslint.config.mjs +16 -0
- package/jest.config.js +31 -0
- package/jest.setup.js +15 -0
- package/next.config.js +15 -0
- package/next.config.ts +62 -0
- package/package.json +70 -52
- package/packages/ndpr-toolkit/README.md +467 -0
- package/packages/ndpr-toolkit/jest.config.js +23 -0
- package/packages/ndpr-toolkit/package-lock.json +8197 -0
- package/packages/ndpr-toolkit/package.json +71 -0
- package/packages/ndpr-toolkit/rollup.config.js +34 -0
- package/packages/ndpr-toolkit/src/__tests__/components/consent/ConsentBanner.test.tsx +119 -0
- package/packages/ndpr-toolkit/src/__tests__/components/consent/ConsentManager.test.tsx +122 -0
- package/packages/ndpr-toolkit/src/__tests__/components/consent/ConsentStorage.test.tsx +270 -0
- package/packages/ndpr-toolkit/src/__tests__/components/dsr/DSRDashboard.test.tsx +199 -0
- package/packages/ndpr-toolkit/src/__tests__/components/dsr/DSRRequestForm.test.tsx +224 -0
- package/packages/ndpr-toolkit/src/__tests__/components/dsr/DSRTracker.test.tsx +104 -0
- package/packages/ndpr-toolkit/src/__tests__/hooks/useConsent.test.tsx +161 -0
- package/packages/ndpr-toolkit/src/__tests__/hooks/useDSR.test.tsx +330 -0
- package/packages/ndpr-toolkit/src/__tests__/utils/breach.test.ts +149 -0
- package/packages/ndpr-toolkit/src/__tests__/utils/consent.test.ts +88 -0
- package/packages/ndpr-toolkit/src/__tests__/utils/dpia.test.ts +160 -0
- package/packages/ndpr-toolkit/src/__tests__/utils/dsr.test.ts +110 -0
- package/packages/ndpr-toolkit/src/__tests__/utils/privacy.test.ts +97 -0
- package/packages/ndpr-toolkit/src/components/breach/BreachNotificationManager.tsx +701 -0
- package/packages/ndpr-toolkit/src/components/breach/BreachReportForm.tsx +631 -0
- package/packages/ndpr-toolkit/src/components/breach/BreachRiskAssessment.tsx +569 -0
- package/packages/ndpr-toolkit/src/components/breach/RegulatoryReportGenerator.tsx +496 -0
- package/packages/ndpr-toolkit/src/components/consent/ConsentBanner.tsx +270 -0
- package/packages/ndpr-toolkit/src/components/consent/ConsentManager.tsx +217 -0
- package/packages/ndpr-toolkit/src/components/consent/ConsentStorage.tsx +206 -0
- package/packages/ndpr-toolkit/src/components/dpia/DPIAQuestionnaire.tsx +342 -0
- package/packages/ndpr-toolkit/src/components/dpia/DPIAReport.tsx +373 -0
- package/packages/ndpr-toolkit/src/components/dpia/StepIndicator.tsx +174 -0
- package/packages/ndpr-toolkit/src/components/dsr/DSRDashboard.tsx +717 -0
- package/packages/ndpr-toolkit/src/components/dsr/DSRRequestForm.tsx +476 -0
- package/packages/ndpr-toolkit/src/components/dsr/DSRTracker.tsx +620 -0
- package/packages/ndpr-toolkit/src/components/policy/PolicyExporter.tsx +541 -0
- package/packages/ndpr-toolkit/src/components/policy/PolicyGenerator.tsx +454 -0
- package/packages/ndpr-toolkit/src/components/policy/PolicyPreview.tsx +333 -0
- package/packages/ndpr-toolkit/src/hooks/useBreach.ts +409 -0
- package/packages/ndpr-toolkit/src/hooks/useConsent.ts +263 -0
- package/packages/ndpr-toolkit/src/hooks/useDPIA.ts +457 -0
- package/packages/ndpr-toolkit/src/hooks/useDSR.ts +236 -0
- package/packages/ndpr-toolkit/src/hooks/usePrivacyPolicy.ts +428 -0
- package/{dist/index.d.ts → packages/ndpr-toolkit/src/index.ts} +14 -1
- package/packages/ndpr-toolkit/src/setupTests.ts +5 -0
- package/packages/ndpr-toolkit/src/types/breach.ts +283 -0
- package/packages/ndpr-toolkit/src/types/consent.ts +111 -0
- package/packages/ndpr-toolkit/src/types/dpia.ts +236 -0
- package/packages/ndpr-toolkit/src/types/dsr.ts +192 -0
- package/packages/ndpr-toolkit/src/types/index.ts +42 -0
- package/packages/ndpr-toolkit/src/types/privacy.ts +246 -0
- package/packages/ndpr-toolkit/src/utils/breach.ts +122 -0
- package/packages/ndpr-toolkit/src/utils/consent.ts +51 -0
- package/packages/ndpr-toolkit/src/utils/dpia.ts +104 -0
- package/packages/ndpr-toolkit/src/utils/dsr.ts +77 -0
- package/packages/ndpr-toolkit/src/utils/privacy.ts +100 -0
- package/packages/ndpr-toolkit/tsconfig.json +23 -0
- package/postcss.config.mjs +5 -0
- package/public/NDPR TOOLKIT.svg +1 -0
- package/public/favicon/android-chrome-192x192.png +0 -0
- package/public/favicon/android-chrome-512x512.png +0 -0
- package/public/favicon/apple-touch-icon.png +0 -0
- package/public/favicon/favicon-16x16.png +0 -0
- package/public/favicon/favicon-32x32.png +0 -0
- package/public/favicon/site.webmanifest +1 -0
- package/public/file.svg +1 -0
- package/public/globe.svg +1 -0
- package/public/ndpr-toolkit-logo.svg +108 -0
- package/public/next.svg +1 -0
- package/public/vercel.svg +1 -0
- package/public/window.svg +1 -0
- package/src/__tests__/example.test.ts +13 -0
- package/src/__tests__/requestService.test.ts +57 -0
- package/src/app/accessibility.css +70 -0
- package/src/app/docs/components/DocLayout.tsx +267 -0
- package/src/app/docs/components/breach-notification/page.tsx +797 -0
- package/src/app/docs/components/consent-management/page.tsx +576 -0
- package/src/app/docs/components/data-subject-rights/page.tsx +511 -0
- package/src/app/docs/components/dpia-questionnaire/layout.tsx +15 -0
- package/src/app/docs/components/dpia-questionnaire/metadata.ts +31 -0
- package/src/app/docs/components/dpia-questionnaire/page.tsx +666 -0
- package/src/app/docs/components/hooks/page.tsx +305 -0
- package/src/app/docs/components/page.tsx +84 -0
- package/src/app/docs/components/privacy-policy-generator/page.tsx +634 -0
- package/src/app/docs/guides/breach-notification-process/components/BestPractices.tsx +123 -0
- package/src/app/docs/guides/breach-notification-process/components/ImplementationSteps.tsx +328 -0
- package/src/app/docs/guides/breach-notification-process/components/Introduction.tsx +28 -0
- package/src/app/docs/guides/breach-notification-process/components/NotificationTimeline.tsx +91 -0
- package/src/app/docs/guides/breach-notification-process/components/Resources.tsx +118 -0
- package/src/app/docs/guides/breach-notification-process/page.tsx +39 -0
- package/src/app/docs/guides/conducting-dpia/page.tsx +593 -0
- package/src/app/docs/guides/data-subject-requests/page.tsx +666 -0
- package/src/app/docs/guides/managing-consent/page.tsx +738 -0
- package/src/app/docs/guides/ndpr-compliance-checklist/components/ComplianceChecklist.tsx +296 -0
- package/src/app/docs/guides/ndpr-compliance-checklist/components/ImplementationTools.tsx +145 -0
- package/src/app/docs/guides/ndpr-compliance-checklist/components/Introduction.tsx +33 -0
- package/src/app/docs/guides/ndpr-compliance-checklist/components/KeyRequirements.tsx +99 -0
- package/src/app/docs/guides/ndpr-compliance-checklist/components/Resources.tsx +159 -0
- package/src/app/docs/guides/ndpr-compliance-checklist/page.tsx +38 -0
- package/src/app/docs/guides/page.tsx +67 -0
- package/src/app/docs/layout.tsx +15 -0
- package/src/app/docs/metadata.ts +31 -0
- package/src/app/docs/page.tsx +572 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +123 -0
- package/src/app/layout.tsx +37 -0
- package/src/app/ndpr-demos/breach/page.tsx +354 -0
- package/src/app/ndpr-demos/consent/page.tsx +366 -0
- package/src/app/ndpr-demos/dpia/page.tsx +495 -0
- package/src/app/ndpr-demos/dsr/page.tsx +280 -0
- package/src/app/ndpr-demos/page.tsx +73 -0
- package/src/app/ndpr-demos/policy/page.tsx +771 -0
- package/src/app/page.tsx +452 -0
- package/src/components/ErrorBoundary.tsx +90 -0
- package/src/components/breach-notification/BreachNotificationForm.tsx +479 -0
- package/src/components/consent/ConsentBanner.tsx +159 -0
- package/src/components/data-subject-rights/DataSubjectRequestForm.tsx +419 -0
- package/src/components/docs/DocLayout.tsx +289 -0
- package/src/components/docs/index.ts +2 -0
- package/src/components/dpia/DPIAQuestionnaire.tsx +483 -0
- package/src/components/privacy-policy/PolicyGenerator.tsx +1062 -0
- package/src/components/privacy-policy/data.ts +98 -0
- package/src/components/privacy-policy/shared/CheckboxField.tsx +38 -0
- package/src/components/privacy-policy/shared/CheckboxGroup.tsx +85 -0
- package/src/components/privacy-policy/shared/FormField.tsx +79 -0
- package/src/components/privacy-policy/shared/StepIndicator.tsx +86 -0
- package/src/components/privacy-policy/steps/CustomSectionsStep.tsx +335 -0
- package/src/components/privacy-policy/steps/DataCollectionStep.tsx +231 -0
- package/src/components/privacy-policy/steps/DataSharingStep.tsx +418 -0
- package/src/components/privacy-policy/steps/OrganizationInfoStep.tsx +202 -0
- package/src/components/privacy-policy/steps/PolicyPreviewStep.tsx +172 -0
- package/src/components/ui/Badge.tsx +46 -0
- package/src/components/ui/Button.tsx +59 -0
- package/src/components/ui/Card.tsx +92 -0
- package/src/components/ui/Checkbox.tsx +57 -0
- package/src/components/ui/FormField.tsx +50 -0
- package/src/components/ui/Input.tsx +38 -0
- package/src/components/ui/Loading.tsx +201 -0
- package/src/components/ui/Select.tsx +42 -0
- package/src/components/ui/TextArea.tsx +38 -0
- package/src/components/ui/label.tsx +24 -0
- package/src/components/ui/switch.tsx +31 -0
- package/src/components/ui/tabs.tsx +66 -0
- package/src/hooks/useConsent.ts +64 -0
- package/src/hooks/useLoadingState.ts +85 -0
- package/src/lib/consentService.ts +137 -0
- package/src/lib/dpiaQuestions.ts +148 -0
- package/src/lib/requestService.ts +75 -0
- package/src/lib/sanitize.ts +108 -0
- package/src/lib/storage.ts +222 -0
- package/src/lib/utils.ts +6 -0
- package/src/types/html-to-docx.d.ts +30 -0
- package/src/types/index.ts +72 -0
- package/tailwind.config.ts +65 -0
- package/tsconfig.json +41 -0
- package/dist/components/breach/BreachNotificationManager.d.ts +0 -62
- package/dist/components/breach/BreachReportForm.d.ts +0 -66
- package/dist/components/breach/BreachRiskAssessment.d.ts +0 -50
- package/dist/components/breach/RegulatoryReportGenerator.d.ts +0 -94
- package/dist/components/consent/ConsentBanner.d.ts +0 -79
- package/dist/components/consent/ConsentManager.d.ts +0 -73
- package/dist/components/consent/ConsentStorage.d.ts +0 -41
- package/dist/components/dpia/DPIAQuestionnaire.d.ts +0 -70
- package/dist/components/dpia/DPIAReport.d.ts +0 -40
- package/dist/components/dpia/StepIndicator.d.ts +0 -64
- package/dist/components/dsr/DSRDashboard.d.ts +0 -58
- package/dist/components/dsr/DSRRequestForm.d.ts +0 -74
- package/dist/components/dsr/DSRTracker.d.ts +0 -56
- package/dist/components/policy/PolicyExporter.d.ts +0 -65
- package/dist/components/policy/PolicyGenerator.d.ts +0 -54
- package/dist/components/policy/PolicyPreview.d.ts +0 -71
- package/dist/hooks/useBreach.d.ts +0 -97
- package/dist/hooks/useConsent.d.ts +0 -63
- package/dist/hooks/useDPIA.d.ts +0 -92
- package/dist/hooks/useDSR.d.ts +0 -72
- package/dist/hooks/usePrivacyPolicy.d.ts +0 -87
- package/dist/index.esm.js +0 -2
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/setupTests.d.ts +0 -2
- package/dist/types/breach.d.ts +0 -239
- package/dist/types/consent.d.ts +0 -95
- package/dist/types/dpia.d.ts +0 -196
- package/dist/types/dsr.d.ts +0 -162
- package/dist/types/privacy.d.ts +0 -204
- package/dist/utils/breach.d.ts +0 -14
- package/dist/utils/consent.d.ts +0 -10
- package/dist/utils/dpia.d.ts +0 -12
- package/dist/utils/dsr.d.ts +0 -11
- package/dist/utils/privacy.d.ts +0 -12
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { PolicySection, PolicyTemplate, OrganizationInfo, PrivacyPolicy } from '../types/privacy';
|
|
3
|
+
import { generatePolicyText } from '../utils/privacy';
|
|
4
|
+
|
|
5
|
+
interface UsePrivacyPolicyOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Available policy templates
|
|
8
|
+
*/
|
|
9
|
+
templates: PolicyTemplate[];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Initial policy data (if editing an existing policy)
|
|
13
|
+
*/
|
|
14
|
+
initialPolicy?: PrivacyPolicy;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Storage key for policy data
|
|
18
|
+
* @default "ndpr_privacy_policy"
|
|
19
|
+
*/
|
|
20
|
+
storageKey?: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Whether to use local storage to persist policy data
|
|
24
|
+
* @default true
|
|
25
|
+
*/
|
|
26
|
+
useLocalStorage?: boolean;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Callback function called when a policy is generated
|
|
30
|
+
*/
|
|
31
|
+
onGenerate?: (policy: PrivacyPolicy) => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface UsePrivacyPolicyReturn {
|
|
35
|
+
/**
|
|
36
|
+
* Current policy data
|
|
37
|
+
*/
|
|
38
|
+
policy: PrivacyPolicy | null;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Selected template
|
|
42
|
+
*/
|
|
43
|
+
selectedTemplate: PolicyTemplate | null;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Organization information
|
|
47
|
+
*/
|
|
48
|
+
organizationInfo: OrganizationInfo;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Select a template
|
|
52
|
+
*/
|
|
53
|
+
selectTemplate: (templateId: string) => boolean;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Update organization information
|
|
57
|
+
*/
|
|
58
|
+
updateOrganizationInfo: (updates: Partial<OrganizationInfo>) => void;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Toggle whether a section is included in the policy
|
|
62
|
+
*/
|
|
63
|
+
toggleSection: (sectionId: string, included: boolean) => void;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Update section content
|
|
67
|
+
*/
|
|
68
|
+
updateSectionContent: (sectionId: string, content: string) => void;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Update variable values
|
|
72
|
+
*/
|
|
73
|
+
updateVariableValue: (variable: string, value: string) => void;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Generate the policy
|
|
77
|
+
*/
|
|
78
|
+
generatePolicy: () => PrivacyPolicy;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Get the generated policy text
|
|
82
|
+
*/
|
|
83
|
+
getPolicyText: () => {
|
|
84
|
+
fullText: string;
|
|
85
|
+
sectionTexts: Record<string, string>;
|
|
86
|
+
missingVariables: string[];
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Reset the policy
|
|
91
|
+
*/
|
|
92
|
+
resetPolicy: () => void;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Check if the policy is valid
|
|
96
|
+
*/
|
|
97
|
+
isValid: () => {
|
|
98
|
+
valid: boolean;
|
|
99
|
+
errors: string[];
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Hook for generating NDPR-compliant privacy policies
|
|
105
|
+
*/
|
|
106
|
+
export function usePrivacyPolicy({
|
|
107
|
+
templates,
|
|
108
|
+
initialPolicy,
|
|
109
|
+
storageKey = "ndpr_privacy_policy",
|
|
110
|
+
useLocalStorage = true,
|
|
111
|
+
onGenerate
|
|
112
|
+
}: UsePrivacyPolicyOptions): UsePrivacyPolicyReturn {
|
|
113
|
+
const [policy, setPolicy] = useState<PrivacyPolicy | null>(initialPolicy || null);
|
|
114
|
+
const [selectedTemplate, setSelectedTemplate] = useState<PolicyTemplate | null>(null);
|
|
115
|
+
const [organizationInfo, setOrganizationInfo] = useState<OrganizationInfo>({
|
|
116
|
+
name: '',
|
|
117
|
+
website: '',
|
|
118
|
+
privacyEmail: '',
|
|
119
|
+
address: '',
|
|
120
|
+
privacyPhone: '',
|
|
121
|
+
dpoName: '',
|
|
122
|
+
dpoEmail: '',
|
|
123
|
+
industry: ''
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Load policy data from storage on mount
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
if (useLocalStorage && typeof window !== 'undefined' && !initialPolicy) {
|
|
129
|
+
try {
|
|
130
|
+
const savedData = localStorage.getItem(storageKey);
|
|
131
|
+
if (savedData) {
|
|
132
|
+
const { policy, template, organizationInfo } = JSON.parse(savedData);
|
|
133
|
+
|
|
134
|
+
if (policy) {
|
|
135
|
+
setPolicy(policy);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (template) {
|
|
139
|
+
const foundTemplate = templates.find(t => t.id === template.id);
|
|
140
|
+
if (foundTemplate) {
|
|
141
|
+
setSelectedTemplate(foundTemplate);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (organizationInfo) {
|
|
146
|
+
setOrganizationInfo(organizationInfo);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
} catch (error) {
|
|
150
|
+
console.error('Error loading privacy policy data:', error);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}, [storageKey, useLocalStorage, initialPolicy, templates]);
|
|
154
|
+
|
|
155
|
+
// Save policy data to storage when it changes
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
if (useLocalStorage && typeof window !== 'undefined') {
|
|
158
|
+
try {
|
|
159
|
+
localStorage.setItem(storageKey, JSON.stringify({
|
|
160
|
+
policy,
|
|
161
|
+
template: selectedTemplate,
|
|
162
|
+
organizationInfo
|
|
163
|
+
}));
|
|
164
|
+
} catch (error) {
|
|
165
|
+
console.error('Error saving privacy policy data:', error);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}, [policy, selectedTemplate, organizationInfo, storageKey, useLocalStorage]);
|
|
169
|
+
|
|
170
|
+
// Select a template
|
|
171
|
+
const selectTemplate = (templateId: string): boolean => {
|
|
172
|
+
const template = templates.find(t => t.id === templateId);
|
|
173
|
+
|
|
174
|
+
if (!template) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
setSelectedTemplate(template);
|
|
179
|
+
|
|
180
|
+
// Initialize sections from the template
|
|
181
|
+
const sections = template.sections.map(section => ({
|
|
182
|
+
...section,
|
|
183
|
+
customContent: undefined
|
|
184
|
+
}));
|
|
185
|
+
|
|
186
|
+
// Initialize variable values
|
|
187
|
+
const variableValues: Record<string, string> = {};
|
|
188
|
+
Object.keys(template.variables).forEach(variable => {
|
|
189
|
+
variableValues[variable] = template.variables[variable].defaultValue || '';
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
return true;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// Update organization information
|
|
196
|
+
const updateOrganizationInfo = (updates: Partial<OrganizationInfo>) => {
|
|
197
|
+
setOrganizationInfo(prev => ({
|
|
198
|
+
...prev,
|
|
199
|
+
...updates
|
|
200
|
+
}));
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
// Toggle whether a section is included in the policy
|
|
204
|
+
const toggleSection = (sectionId: string, included: boolean) => {
|
|
205
|
+
if (!selectedTemplate) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (policy) {
|
|
210
|
+
setPolicy(prev => {
|
|
211
|
+
if (!prev) return prev;
|
|
212
|
+
|
|
213
|
+
return {
|
|
214
|
+
...prev,
|
|
215
|
+
sections: prev.sections.map(section =>
|
|
216
|
+
section.id === sectionId ? { ...section, included } : section
|
|
217
|
+
)
|
|
218
|
+
};
|
|
219
|
+
});
|
|
220
|
+
} else {
|
|
221
|
+
// If no policy exists yet, update the template sections
|
|
222
|
+
setSelectedTemplate(prev => {
|
|
223
|
+
if (!prev) return prev;
|
|
224
|
+
|
|
225
|
+
return {
|
|
226
|
+
...prev,
|
|
227
|
+
sections: prev.sections.map(section =>
|
|
228
|
+
section.id === sectionId ? { ...section, included } : section
|
|
229
|
+
)
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// Update section content
|
|
236
|
+
const updateSectionContent = (sectionId: string, content: string) => {
|
|
237
|
+
if (!selectedTemplate) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (policy) {
|
|
242
|
+
setPolicy(prev => {
|
|
243
|
+
if (!prev) return prev;
|
|
244
|
+
|
|
245
|
+
return {
|
|
246
|
+
...prev,
|
|
247
|
+
sections: prev.sections.map(section =>
|
|
248
|
+
section.id === sectionId ? { ...section, customContent: content } : section
|
|
249
|
+
)
|
|
250
|
+
};
|
|
251
|
+
});
|
|
252
|
+
} else {
|
|
253
|
+
// If no policy exists yet, update the template sections
|
|
254
|
+
setSelectedTemplate(prev => {
|
|
255
|
+
if (!prev) return prev;
|
|
256
|
+
|
|
257
|
+
return {
|
|
258
|
+
...prev,
|
|
259
|
+
sections: prev.sections.map(section =>
|
|
260
|
+
section.id === sectionId ? { ...section, customContent: content } : section
|
|
261
|
+
)
|
|
262
|
+
};
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// Update variable values
|
|
268
|
+
const updateVariableValue = (variable: string, value: string) => {
|
|
269
|
+
if (!policy) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
setPolicy(prev => {
|
|
274
|
+
if (!prev) return prev;
|
|
275
|
+
|
|
276
|
+
return {
|
|
277
|
+
...prev,
|
|
278
|
+
variableValues: {
|
|
279
|
+
...prev.variableValues,
|
|
280
|
+
[variable]: value
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
});
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
// Generate a unique ID
|
|
287
|
+
const generateId = (): string => {
|
|
288
|
+
return 'policy_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
// Generate the policy
|
|
292
|
+
const generatePolicy = (): PrivacyPolicy => {
|
|
293
|
+
if (!selectedTemplate) {
|
|
294
|
+
throw new Error('No template selected');
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const now = Date.now();
|
|
298
|
+
|
|
299
|
+
const newPolicy: PrivacyPolicy = {
|
|
300
|
+
id: policy?.id || generateId(),
|
|
301
|
+
title: `Privacy Policy for ${organizationInfo.name}`,
|
|
302
|
+
templateId: selectedTemplate.id,
|
|
303
|
+
organizationInfo,
|
|
304
|
+
sections: selectedTemplate.sections.map(section => ({
|
|
305
|
+
...section,
|
|
306
|
+
customContent: policy?.sections.find(s => s.id === section.id)?.customContent
|
|
307
|
+
})),
|
|
308
|
+
variableValues: policy?.variableValues || {},
|
|
309
|
+
effectiveDate: now,
|
|
310
|
+
lastUpdated: now,
|
|
311
|
+
version: '1.0'
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
setPolicy(newPolicy);
|
|
315
|
+
|
|
316
|
+
if (onGenerate) {
|
|
317
|
+
onGenerate(newPolicy);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
return newPolicy;
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
// Get the generated policy text
|
|
324
|
+
const getPolicyText = () => {
|
|
325
|
+
if (!policy) {
|
|
326
|
+
return {
|
|
327
|
+
fullText: '',
|
|
328
|
+
sectionTexts: {},
|
|
329
|
+
missingVariables: []
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
const result = generatePolicyText(policy.sections, policy.organizationInfo);
|
|
334
|
+
|
|
335
|
+
// Handle both string and object return types from generatePolicyText
|
|
336
|
+
if (typeof result === 'string') {
|
|
337
|
+
return {
|
|
338
|
+
fullText: result,
|
|
339
|
+
sectionTexts: { 'full': result },
|
|
340
|
+
missingVariables: []
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
return result;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
// Reset the policy
|
|
348
|
+
const resetPolicy = () => {
|
|
349
|
+
setPolicy(null);
|
|
350
|
+
setSelectedTemplate(null);
|
|
351
|
+
setOrganizationInfo({
|
|
352
|
+
name: '',
|
|
353
|
+
website: '',
|
|
354
|
+
privacyEmail: '',
|
|
355
|
+
address: '',
|
|
356
|
+
privacyPhone: '',
|
|
357
|
+
dpoName: '',
|
|
358
|
+
dpoEmail: '',
|
|
359
|
+
industry: ''
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
if (useLocalStorage && typeof window !== 'undefined') {
|
|
363
|
+
localStorage.removeItem(storageKey);
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
// Check if the policy is valid
|
|
368
|
+
const isValid = () => {
|
|
369
|
+
const errors: string[] = [];
|
|
370
|
+
|
|
371
|
+
if (!selectedTemplate) {
|
|
372
|
+
errors.push('No template selected');
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (!organizationInfo.name) {
|
|
376
|
+
errors.push('Organization name is required');
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if (!organizationInfo.website) {
|
|
380
|
+
errors.push('Organization website is required');
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (!organizationInfo.privacyEmail) {
|
|
384
|
+
errors.push('Privacy contact email is required');
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// Check if all required sections are included
|
|
388
|
+
if (selectedTemplate) {
|
|
389
|
+
const requiredSections = selectedTemplate.sections.filter(section => section.required);
|
|
390
|
+
const includedSections = policy?.sections.filter(section => section.included) || [];
|
|
391
|
+
|
|
392
|
+
requiredSections.forEach(section => {
|
|
393
|
+
if (!includedSections.some(s => s.id === section.id)) {
|
|
394
|
+
errors.push(`Required section "${section.title}" must be included`);
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// Check if all required variables have values
|
|
400
|
+
if (selectedTemplate && policy) {
|
|
401
|
+
Object.entries(selectedTemplate.variables).forEach(([variable, info]) => {
|
|
402
|
+
if (info.required && !policy.variableValues[variable]) {
|
|
403
|
+
errors.push(`Required variable "${info.name}" must have a value`);
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
return {
|
|
409
|
+
valid: errors.length === 0,
|
|
410
|
+
errors
|
|
411
|
+
};
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
return {
|
|
415
|
+
policy,
|
|
416
|
+
selectedTemplate,
|
|
417
|
+
organizationInfo,
|
|
418
|
+
selectTemplate,
|
|
419
|
+
updateOrganizationInfo,
|
|
420
|
+
toggleSection,
|
|
421
|
+
updateSectionContent,
|
|
422
|
+
updateVariableValue,
|
|
423
|
+
generatePolicy,
|
|
424
|
+
getPolicyText,
|
|
425
|
+
resetPolicy,
|
|
426
|
+
isValid
|
|
427
|
+
};
|
|
428
|
+
}
|
|
@@ -1,29 +1,42 @@
|
|
|
1
|
+
// Consent Management Components
|
|
1
2
|
export { ConsentBanner } from './components/consent/ConsentBanner';
|
|
2
3
|
export { ConsentManager } from './components/consent/ConsentManager';
|
|
3
4
|
export { ConsentStorage } from './components/consent/ConsentStorage';
|
|
4
5
|
export type { ConsentOption, ConsentSettings, ConsentStorageOptions } from './types/consent';
|
|
6
|
+
|
|
7
|
+
// Data Subject Rights Components
|
|
5
8
|
export { DSRRequestForm } from './components/dsr/DSRRequestForm';
|
|
6
9
|
export { DSRDashboard } from './components/dsr/DSRDashboard';
|
|
7
10
|
export { DSRTracker } from './components/dsr/DSRTracker';
|
|
8
11
|
export type { DSRRequest, RequestType, DSRStatus, DSRType, RequestStatus } from './types/dsr';
|
|
12
|
+
|
|
13
|
+
// DPIA Components
|
|
9
14
|
export { DPIAQuestionnaire } from './components/dpia/DPIAQuestionnaire';
|
|
10
15
|
export { DPIAReport } from './components/dpia/DPIAReport';
|
|
11
16
|
export { StepIndicator } from './components/dpia/StepIndicator';
|
|
12
17
|
export type { DPIAQuestion, DPIASection, DPIAResult } from './types/dpia';
|
|
18
|
+
|
|
19
|
+
// Breach Notification Components
|
|
13
20
|
export { BreachReportForm } from './components/breach/BreachReportForm';
|
|
14
21
|
export { BreachRiskAssessment } from './components/breach/BreachRiskAssessment';
|
|
15
22
|
export { BreachNotificationManager } from './components/breach/BreachNotificationManager';
|
|
16
23
|
export { RegulatoryReportGenerator } from './components/breach/RegulatoryReportGenerator';
|
|
17
|
-
export type { BreachReport, RiskAssessment, NotificationRequirement } from './types/breach';
|
|
24
|
+
export type { BreachReport, RiskAssessment, NotificationRequirement, RegulatoryNotification } from './types/breach';
|
|
25
|
+
|
|
26
|
+
// Privacy Policy Generator Components
|
|
18
27
|
export { PolicyGenerator } from './components/policy/PolicyGenerator';
|
|
19
28
|
export { PolicyPreview } from './components/policy/PolicyPreview';
|
|
20
29
|
export { PolicyExporter } from './components/policy/PolicyExporter';
|
|
21
30
|
export type { PolicySection, PolicyTemplate, PolicyVariable, OrganizationInfo, PrivacyPolicy } from './types/privacy';
|
|
31
|
+
|
|
32
|
+
// Utility Functions
|
|
22
33
|
export { validateConsent } from './utils/consent';
|
|
23
34
|
export { formatDSRRequest } from './utils/dsr';
|
|
24
35
|
export { assessDPIARisk } from './utils/dpia';
|
|
25
36
|
export { calculateBreachSeverity } from './utils/breach';
|
|
26
37
|
export { generatePolicyText } from './utils/privacy';
|
|
38
|
+
|
|
39
|
+
// Hooks
|
|
27
40
|
export { useConsent } from './hooks/useConsent';
|
|
28
41
|
export { useDSR } from './hooks/useDSR';
|
|
29
42
|
export { useDPIA } from './hooks/useDPIA';
|