@tantainnovative/ndpr-toolkit 1.0.3 → 1.0.4

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 (156) hide show
  1. package/next-env.d.ts +5 -0
  2. package/package.json +1 -1
  3. package/.claude/settings.local.json +0 -20
  4. package/.eslintrc.json +0 -10
  5. package/.github/workflows/ci.yml +0 -36
  6. package/.github/workflows/nextjs.yml +0 -104
  7. package/.husky/commit-msg +0 -4
  8. package/.husky/pre-commit +0 -4
  9. package/.lintstagedrc.js +0 -4
  10. package/.nvmrc +0 -1
  11. package/.versionrc +0 -17
  12. package/CLAUDE.md +0 -90
  13. package/commitlint.config.js +0 -36
  14. package/eslint.config.mjs +0 -16
  15. package/jest.config.js +0 -31
  16. package/jest.setup.js +0 -15
  17. package/next.config.js +0 -15
  18. package/next.config.ts +0 -62
  19. package/packages/ndpr-toolkit/README.md +0 -467
  20. package/packages/ndpr-toolkit/jest.config.js +0 -23
  21. package/packages/ndpr-toolkit/package-lock.json +0 -8197
  22. package/packages/ndpr-toolkit/package.json +0 -71
  23. package/packages/ndpr-toolkit/rollup.config.js +0 -34
  24. package/packages/ndpr-toolkit/src/__tests__/components/consent/ConsentBanner.test.tsx +0 -119
  25. package/packages/ndpr-toolkit/src/__tests__/components/consent/ConsentManager.test.tsx +0 -122
  26. package/packages/ndpr-toolkit/src/__tests__/components/consent/ConsentStorage.test.tsx +0 -270
  27. package/packages/ndpr-toolkit/src/__tests__/components/dsr/DSRDashboard.test.tsx +0 -199
  28. package/packages/ndpr-toolkit/src/__tests__/components/dsr/DSRRequestForm.test.tsx +0 -224
  29. package/packages/ndpr-toolkit/src/__tests__/components/dsr/DSRTracker.test.tsx +0 -104
  30. package/packages/ndpr-toolkit/src/__tests__/hooks/useConsent.test.tsx +0 -161
  31. package/packages/ndpr-toolkit/src/__tests__/hooks/useDSR.test.tsx +0 -330
  32. package/packages/ndpr-toolkit/src/__tests__/utils/breach.test.ts +0 -149
  33. package/packages/ndpr-toolkit/src/__tests__/utils/consent.test.ts +0 -88
  34. package/packages/ndpr-toolkit/src/__tests__/utils/dpia.test.ts +0 -160
  35. package/packages/ndpr-toolkit/src/__tests__/utils/dsr.test.ts +0 -110
  36. package/packages/ndpr-toolkit/src/__tests__/utils/privacy.test.ts +0 -97
  37. package/packages/ndpr-toolkit/src/components/breach/BreachNotificationManager.tsx +0 -701
  38. package/packages/ndpr-toolkit/src/components/breach/BreachReportForm.tsx +0 -631
  39. package/packages/ndpr-toolkit/src/components/breach/BreachRiskAssessment.tsx +0 -569
  40. package/packages/ndpr-toolkit/src/components/breach/RegulatoryReportGenerator.tsx +0 -496
  41. package/packages/ndpr-toolkit/src/components/consent/ConsentBanner.tsx +0 -270
  42. package/packages/ndpr-toolkit/src/components/consent/ConsentManager.tsx +0 -217
  43. package/packages/ndpr-toolkit/src/components/consent/ConsentStorage.tsx +0 -206
  44. package/packages/ndpr-toolkit/src/components/dpia/DPIAQuestionnaire.tsx +0 -342
  45. package/packages/ndpr-toolkit/src/components/dpia/DPIAReport.tsx +0 -373
  46. package/packages/ndpr-toolkit/src/components/dpia/StepIndicator.tsx +0 -174
  47. package/packages/ndpr-toolkit/src/components/dsr/DSRDashboard.tsx +0 -717
  48. package/packages/ndpr-toolkit/src/components/dsr/DSRRequestForm.tsx +0 -476
  49. package/packages/ndpr-toolkit/src/components/dsr/DSRTracker.tsx +0 -620
  50. package/packages/ndpr-toolkit/src/components/policy/PolicyExporter.tsx +0 -541
  51. package/packages/ndpr-toolkit/src/components/policy/PolicyGenerator.tsx +0 -454
  52. package/packages/ndpr-toolkit/src/components/policy/PolicyPreview.tsx +0 -333
  53. package/packages/ndpr-toolkit/src/hooks/useBreach.ts +0 -409
  54. package/packages/ndpr-toolkit/src/hooks/useConsent.ts +0 -263
  55. package/packages/ndpr-toolkit/src/hooks/useDPIA.ts +0 -457
  56. package/packages/ndpr-toolkit/src/hooks/useDSR.ts +0 -236
  57. package/packages/ndpr-toolkit/src/hooks/usePrivacyPolicy.ts +0 -428
  58. package/packages/ndpr-toolkit/src/index.ts +0 -44
  59. package/packages/ndpr-toolkit/src/setupTests.ts +0 -5
  60. package/packages/ndpr-toolkit/src/types/breach.ts +0 -283
  61. package/packages/ndpr-toolkit/src/types/consent.ts +0 -111
  62. package/packages/ndpr-toolkit/src/types/dpia.ts +0 -236
  63. package/packages/ndpr-toolkit/src/types/dsr.ts +0 -192
  64. package/packages/ndpr-toolkit/src/types/index.ts +0 -42
  65. package/packages/ndpr-toolkit/src/types/privacy.ts +0 -246
  66. package/packages/ndpr-toolkit/src/utils/breach.ts +0 -122
  67. package/packages/ndpr-toolkit/src/utils/consent.ts +0 -51
  68. package/packages/ndpr-toolkit/src/utils/dpia.ts +0 -104
  69. package/packages/ndpr-toolkit/src/utils/dsr.ts +0 -77
  70. package/packages/ndpr-toolkit/src/utils/privacy.ts +0 -100
  71. package/packages/ndpr-toolkit/tsconfig.json +0 -23
  72. package/postcss.config.mjs +0 -5
  73. package/src/__tests__/example.test.ts +0 -13
  74. package/src/__tests__/requestService.test.ts +0 -57
  75. package/src/app/accessibility.css +0 -70
  76. package/src/app/docs/components/DocLayout.tsx +0 -267
  77. package/src/app/docs/components/breach-notification/page.tsx +0 -797
  78. package/src/app/docs/components/consent-management/page.tsx +0 -576
  79. package/src/app/docs/components/data-subject-rights/page.tsx +0 -511
  80. package/src/app/docs/components/dpia-questionnaire/layout.tsx +0 -15
  81. package/src/app/docs/components/dpia-questionnaire/metadata.ts +0 -31
  82. package/src/app/docs/components/dpia-questionnaire/page.tsx +0 -666
  83. package/src/app/docs/components/hooks/page.tsx +0 -305
  84. package/src/app/docs/components/page.tsx +0 -84
  85. package/src/app/docs/components/privacy-policy-generator/page.tsx +0 -634
  86. package/src/app/docs/guides/breach-notification-process/components/BestPractices.tsx +0 -123
  87. package/src/app/docs/guides/breach-notification-process/components/ImplementationSteps.tsx +0 -328
  88. package/src/app/docs/guides/breach-notification-process/components/Introduction.tsx +0 -28
  89. package/src/app/docs/guides/breach-notification-process/components/NotificationTimeline.tsx +0 -91
  90. package/src/app/docs/guides/breach-notification-process/components/Resources.tsx +0 -118
  91. package/src/app/docs/guides/breach-notification-process/page.tsx +0 -39
  92. package/src/app/docs/guides/conducting-dpia/page.tsx +0 -593
  93. package/src/app/docs/guides/data-subject-requests/page.tsx +0 -666
  94. package/src/app/docs/guides/managing-consent/page.tsx +0 -738
  95. package/src/app/docs/guides/ndpr-compliance-checklist/components/ComplianceChecklist.tsx +0 -296
  96. package/src/app/docs/guides/ndpr-compliance-checklist/components/ImplementationTools.tsx +0 -145
  97. package/src/app/docs/guides/ndpr-compliance-checklist/components/Introduction.tsx +0 -33
  98. package/src/app/docs/guides/ndpr-compliance-checklist/components/KeyRequirements.tsx +0 -99
  99. package/src/app/docs/guides/ndpr-compliance-checklist/components/Resources.tsx +0 -159
  100. package/src/app/docs/guides/ndpr-compliance-checklist/page.tsx +0 -38
  101. package/src/app/docs/guides/page.tsx +0 -67
  102. package/src/app/docs/layout.tsx +0 -15
  103. package/src/app/docs/metadata.ts +0 -31
  104. package/src/app/docs/page.tsx +0 -572
  105. package/src/app/favicon.ico +0 -0
  106. package/src/app/globals.css +0 -123
  107. package/src/app/layout.tsx +0 -37
  108. package/src/app/ndpr-demos/breach/page.tsx +0 -354
  109. package/src/app/ndpr-demos/consent/page.tsx +0 -366
  110. package/src/app/ndpr-demos/dpia/page.tsx +0 -495
  111. package/src/app/ndpr-demos/dsr/page.tsx +0 -280
  112. package/src/app/ndpr-demos/page.tsx +0 -73
  113. package/src/app/ndpr-demos/policy/page.tsx +0 -771
  114. package/src/app/page.tsx +0 -452
  115. package/src/components/ErrorBoundary.tsx +0 -90
  116. package/src/components/breach-notification/BreachNotificationForm.tsx +0 -479
  117. package/src/components/consent/ConsentBanner.tsx +0 -159
  118. package/src/components/data-subject-rights/DataSubjectRequestForm.tsx +0 -419
  119. package/src/components/docs/DocLayout.tsx +0 -289
  120. package/src/components/docs/index.ts +0 -2
  121. package/src/components/dpia/DPIAQuestionnaire.tsx +0 -483
  122. package/src/components/privacy-policy/PolicyGenerator.tsx +0 -1062
  123. package/src/components/privacy-policy/data.ts +0 -98
  124. package/src/components/privacy-policy/shared/CheckboxField.tsx +0 -38
  125. package/src/components/privacy-policy/shared/CheckboxGroup.tsx +0 -85
  126. package/src/components/privacy-policy/shared/FormField.tsx +0 -79
  127. package/src/components/privacy-policy/shared/StepIndicator.tsx +0 -86
  128. package/src/components/privacy-policy/steps/CustomSectionsStep.tsx +0 -335
  129. package/src/components/privacy-policy/steps/DataCollectionStep.tsx +0 -231
  130. package/src/components/privacy-policy/steps/DataSharingStep.tsx +0 -418
  131. package/src/components/privacy-policy/steps/OrganizationInfoStep.tsx +0 -202
  132. package/src/components/privacy-policy/steps/PolicyPreviewStep.tsx +0 -172
  133. package/src/components/ui/Badge.tsx +0 -46
  134. package/src/components/ui/Button.tsx +0 -59
  135. package/src/components/ui/Card.tsx +0 -92
  136. package/src/components/ui/Checkbox.tsx +0 -57
  137. package/src/components/ui/FormField.tsx +0 -50
  138. package/src/components/ui/Input.tsx +0 -38
  139. package/src/components/ui/Loading.tsx +0 -201
  140. package/src/components/ui/Select.tsx +0 -42
  141. package/src/components/ui/TextArea.tsx +0 -38
  142. package/src/components/ui/label.tsx +0 -24
  143. package/src/components/ui/switch.tsx +0 -31
  144. package/src/components/ui/tabs.tsx +0 -66
  145. package/src/hooks/useConsent.ts +0 -64
  146. package/src/hooks/useLoadingState.ts +0 -85
  147. package/src/lib/consentService.ts +0 -137
  148. package/src/lib/dpiaQuestions.ts +0 -148
  149. package/src/lib/requestService.ts +0 -75
  150. package/src/lib/sanitize.ts +0 -108
  151. package/src/lib/storage.ts +0 -222
  152. package/src/lib/utils.ts +0 -6
  153. package/src/types/html-to-docx.d.ts +0 -30
  154. package/src/types/index.ts +0 -72
  155. package/tailwind.config.ts +0 -65
  156. package/tsconfig.json +0 -41
@@ -1,634 +0,0 @@
1
- 'use client';
2
-
3
- import Link from 'next/link';
4
- import { DocLayout } from '../DocLayout';
5
- import { Button } from '@/components/ui/Button';
6
- import { Card, CardContent } from '@/components/ui/Card';
7
-
8
- export default function PrivacyPolicyGeneratorDocs() {
9
- return (
10
- <DocLayout
11
- title="Privacy Policy Generator"
12
- description="NDPR-compliant privacy policy generator for websites and applications"
13
- >
14
- <div className="flex mb-6 space-x-2">
15
- <Button asChild variant="outline" size="sm">
16
- <Link href="/ndpr-demos/policy">
17
- View Demo
18
- </Link>
19
- </Button>
20
- <Button asChild variant="outline" size="sm">
21
- <a href="https://github.com/tantainnovative/ndpr-toolkit/tree/main/packages/ndpr-toolkit/src/components/policy" target="_blank" rel="noopener noreferrer">
22
- View Source
23
- </a>
24
- </Button>
25
- </div>
26
-
27
- <section id="overview" className="mb-8">
28
- <h2 className="text-2xl font-bold mb-4">Overview</h2>
29
- <p className="mb-4">
30
- The Privacy Policy Management components provide a comprehensive solution for creating, previewing, and exporting
31
- customized, NDPR-compliant privacy policies for your website or application. The system includes three main components:
32
- PolicyGenerator, PolicyPreview, and PolicyExporter, which work together to create professional, enterprise-ready
33
- privacy policies with variable support.
34
- </p>
35
- <div className="bg-blue-50 dark:bg-blue-900/20 p-4 rounded-md">
36
- <h4 className="text-blue-800 dark:text-blue-200 font-medium mb-2">NDPR Privacy Policy Requirements</h4>
37
- <p className="text-blue-700 dark:text-blue-300 text-sm mb-0">
38
- Under the NDPR, organizations must maintain a clear and accessible privacy policy that informs data subjects
39
- about how their personal data is collected, processed, stored, and protected. The policy must be written in
40
- clear, plain language and cover specific elements required by the regulation.
41
- </p>
42
- </div>
43
- </section>
44
-
45
- <section id="installation" className="mb-8">
46
- <h2 className="text-2xl font-bold mb-4">Installation</h2>
47
- <p className="mb-4">
48
- Install the NDPR Toolkit package which includes the Privacy Policy Generator components:
49
- </p>
50
- <div className="bg-gray-800 text-gray-200 p-4 rounded-md overflow-x-auto mb-4">
51
- <pre><code>npm install @tantainnovative/ndpr-toolkit</code></pre>
52
- <pre><code># Or with legacy peer deps if using React 19
53
- npm install @tantainnovative/ndpr-toolkit --legacy-peer-deps</code></pre>
54
- </div>
55
- <p>
56
- Or if you&apos;re using yarn:
57
- </p>
58
- <div className="bg-gray-800 text-gray-200 p-4 rounded-md overflow-x-auto">
59
- <pre><code>yarn add @tantainnovative/ndpr-toolkit</code></pre>
60
- <pre><code># Or with legacy peer deps if using React 19
61
- yarn add @tantainnovative/ndpr-toolkit --legacy-peer-deps</code></pre>
62
- </div>
63
- </section>
64
-
65
- <section id="components" className="mb-8">
66
- <h2 className="text-2xl font-bold mb-4">Components</h2>
67
- <p className="mb-4">
68
- The Privacy Policy Management system includes three main components that work together to create, preview, and export NDPR-compliant privacy policies:
69
- </p>
70
-
71
- <div className="space-y-6">
72
- <div className="bg-white dark:bg-gray-800 p-6 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700">
73
- <h3 className="text-xl font-bold mb-2">PolicyGenerator</h3>
74
- <p className="text-gray-600 dark:text-gray-300 mb-4">
75
- The main component that allows users to create a policy by configuring sections and variables with an intuitive interface.
76
- </p>
77
- <div className="bg-gray-800 text-gray-200 p-4 rounded-md overflow-x-auto">
78
- <pre><code>{`import { PolicyGenerator } from '@tantainnovative/ndpr-toolkit';
79
-
80
- <PolicyGenerator
81
- sections={policySections}
82
- variables={policyVariables}
83
- onGenerate={(policy) => {
84
- // policy.sections - Updated sections
85
- // policy.variables - Updated variables with values
86
- // policy.content - Generated policy content in markdown format
87
- setPolicyContent(policy.content);
88
- }}
89
- title="Privacy Policy Generator"
90
- description="Create your NDPR-compliant privacy policy"
91
- showPreview={true}
92
- allowEditing={true}
93
- />`}</code></pre>
94
- </div>
95
- </div>
96
-
97
- <div className="bg-white dark:bg-gray-800 p-6 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700">
98
- <h3 className="text-xl font-bold mb-2">PolicyPreview</h3>
99
- <p className="text-gray-600 dark:text-gray-300 mb-4">
100
- A component for displaying the generated privacy policy with professional formatting and navigation features.
101
- </p>
102
- <div className="bg-gray-800 text-gray-200 p-4 rounded-md overflow-x-auto">
103
- <pre><code>{`import { PolicyPreview } from '@tantainnovative/ndpr-toolkit';
104
-
105
- <PolicyPreview
106
- content={policyContent} // Markdown content of the policy
107
- title="Privacy Policy"
108
- showTableOfContents={true}
109
- className="policy-preview"
110
- onContentChange={(updatedContent) => {
111
- setPolicyContent(updatedContent);
112
- }}
113
- />`}</code></pre>
114
- </div>
115
- </div>
116
-
117
- <div className="bg-white dark:bg-gray-800 p-6 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700">
118
- <h3 className="text-xl font-bold mb-2">PolicyExporter</h3>
119
- <p className="text-gray-600 dark:text-gray-300 mb-4">
120
- A utility component for exporting the generated policy in various formats (PDF, HTML, Markdown) with professional formatting.
121
- </p>
122
- <div className="bg-gray-800 text-gray-200 p-4 rounded-md overflow-x-auto">
123
- <pre><code>{`import { PolicyExporter } from '@tantainnovative/ndpr-toolkit';
124
-
125
- <PolicyExporter
126
- content={policyContent} // Markdown content of the policy
127
- title="Privacy Policy"
128
- filename="privacy-policy"
129
- formats={{
130
- pdf: true,
131
- markdown: true,
132
- html: true
133
- }}
134
- companyInfo={{
135
- name: "Your Company Name",
136
- logo: "/path/to/logo.png", // Optional
137
- website: "https://example.com",
138
- email: "privacy@example.com"
139
- }}
140
- />`}</code></pre>
141
- </div>
142
- </div>
143
- </div>
144
- </section>
145
-
146
- <section id="variable-support" className="mb-8">
147
- <h2 className="text-2xl font-bold mb-4">Variable Support</h2>
148
- <p className="mb-4">
149
- The Privacy Policy Management system supports variables in templates, allowing for dynamic and enterprise-ready policies.
150
- Variables are defined with specific types and can be edited through the PolicyGenerator interface, making it easy to customize
151
- the policy for different organizations and use cases.
152
- </p>
153
-
154
- <h3 className="text-xl font-bold mt-6 mb-4">Defining Variables</h3>
155
- <p className="mb-4">
156
- Variables are defined as an array of PolicyVariable objects, each with properties like id, name, description, defaultValue,
157
- inputType, and required status. These variables can then be referenced in your policy sections using the <code>{'{{'}</code> and <code>{'}}'}</code> syntax.
158
- </p>
159
-
160
- <div className="bg-gray-800 text-gray-200 p-4 rounded-md overflow-x-auto mb-6">
161
- <pre><code>{`// Example of defining policy variables
162
- const policyVariables = [
163
- {
164
- id: 'companyName',
165
- name: 'Company Name',
166
- description: 'The legal name of your organization',
167
- defaultValue: 'Your Company',
168
- value: '',
169
- inputType: 'text',
170
- required: true
171
- },
172
- {
173
- id: 'contactEmail',
174
- name: 'Contact Email',
175
- description: 'Email address for privacy inquiries',
176
- defaultValue: 'privacy@example.com',
177
- value: '',
178
- inputType: 'email',
179
- required: true
180
- },
181
- {
182
- id: 'effectiveDate',
183
- name: 'Effective Date',
184
- description: 'When this privacy policy takes effect',
185
- defaultValue: new Date().toISOString().split('T')[0],
186
- value: '',
187
- inputType: 'date',
188
- required: true
189
- },
190
- {
191
- id: 'dataRetentionPeriod',
192
- name: 'Data Retention Period',
193
- description: 'How long you retain user data',
194
- defaultValue: '12 months',
195
- value: '',
196
- inputType: 'text',
197
- required: true
198
- }
199
- ];
200
-
201
- // Example of a policy section that uses variables
202
- const policySections = [
203
- {
204
- id: 'introduction',
205
- title: 'Introduction',
206
- content: '# Privacy Policy for {{companyName}}\n\nLast Updated: {{effectiveDate}}\n\n## Introduction\n{{companyName}} ("we", "us", or "our") is committed to protecting your privacy. This Privacy Policy explains how we collect, use, and safeguard your information when you use our services.',
207
- enabled: true,
208
- order: 1
209
- },
210
- This page informs you of our policies regarding the collection, use, and disclosure
211
- of personal data when you use our Service and the choices you have associated with that data.
212
-
213
- ## Contact Us
214
- If you have any questions about this Privacy Policy, please contact us:
215
- - By email: {{contactEmail}}
216
- - By visiting this page on our website: {{websiteUrl}}/contact
217
- \`;
218
-
219
- // Using the template with the generatePolicyText utility
220
- import { generatePolicyText } from '@tantainnovative/ndpr-toolkit';
221
-
222
- const variables = {
223
- organizationName: 'Acme Corporation',
224
- lastUpdated: new Date().toLocaleDateString(),
225
- websiteUrl: 'https://acme.com',
226
- contactEmail: 'privacy@acme.com'
227
- };
228
-
229
- const generatedPolicy = generatePolicyText(policyTemplate, variables);
230
-
231
- // The result will have all variables replaced with their values
232
- console.log(generatedPolicy);`}</code></pre>
233
- </div>
234
-
235
- <h3 className="text-xl font-bold mt-6 mb-4">Variable Validation</h3>
236
- <p className="mb-4">
237
- The <code>generatePolicyText</code> utility also provides validation to help you identify missing variables:
238
- </p>
239
-
240
- <div className="bg-gray-800 text-gray-200 p-4 rounded-md overflow-x-auto mb-6">
241
- <pre><code>{`// The function returns an object with additional information
242
- const result = generatePolicyText(policyTemplate, variables);
243
-
244
- // The full generated text
245
- console.log(result.fullText);
246
-
247
- // Any missing variables that weren't provided
248
- console.log(result.missingVariables); // e.g., ['phoneNumber']
249
-
250
- // Individual section texts if using PolicySection[] input
251
- console.log(result.sectionTexts);`}</code></pre>
252
- </div>
253
-
254
- <h3 className="text-xl font-bold mt-6 mb-4">Using with PolicySection Array</h3>
255
- <p className="mb-4">
256
- Variables also work with the array-based policy section format:
257
- </p>
258
-
259
- <div className="bg-gray-800 text-gray-200 p-4 rounded-md overflow-x-auto">
260
- <pre><code>{`import { generatePolicyText, PolicySection } from '@tantainnovative/ndpr-toolkit';
261
-
262
- const policySections: PolicySection[] = [
263
- {
264
- id: 'introduction',
265
- title: 'Introduction',
266
- content: '{{organizationName}} ("we", "us", or "our") operates the {{websiteUrl}} website.'
267
- },
268
- {
269
- id: 'data-collection',
270
- title: 'Data Collection',
271
- content: 'We collect several different types of information for various purposes to provide and improve our Service to you.'
272
- },
273
- {
274
- id: 'contact',
275
- title: 'Contact Us',
276
- content: 'If you have any questions, please contact us at {{contactEmail}}.'
277
- }
278
- ];
279
-
280
- const variables = {
281
- organizationName: 'Acme Corporation',
282
- websiteUrl: 'https://acme.com',
283
- contactEmail: 'privacy@acme.com'
284
- };
285
-
286
- const result = generatePolicyText(policySections, variables);
287
-
288
- // Access the full text
289
- console.log(result.fullText);
290
-
291
- // Access individual section texts
292
- console.log(result.sectionTexts.introduction);
293
- console.log(result.sectionTexts.contact);`}</code></pre>
294
- </div>
295
- </section>
296
-
297
- <section id="usage" className="mb-8">
298
- <h2 className="text-2xl font-bold mb-4">Usage</h2>
299
- <p className="mb-4">
300
- Here&apos;s a complete example of how to implement the Privacy Policy Generator in your application:
301
- </p>
302
- <div className="bg-gray-800 text-gray-200 p-4 rounded-md overflow-x-auto">
303
- <pre><code>{`import { useState } from 'react';
304
- import {
305
- PolicyGenerator,
306
- PolicyPreview,
307
- PolicyExport,
308
- generatePolicyText,
309
- PolicySection
310
- } from '@tantainnovative/ndpr-toolkit';
311
-
312
- // Define your policy templates
313
- const policyTemplates = [
314
- {
315
- id: 'standard',
316
- name: 'Standard Privacy Policy',
317
- description: 'A comprehensive privacy policy suitable for most websites and applications.',
318
- sections: [
319
- {
320
- id: 'introduction',
321
- title: 'Introduction',
322
- content: '{{organizationName}} ("we", "us", or "our") operates the {{websiteUrl}} website ("the Service"). This page informs you of our policies regarding the collection, use, and disclosure of personal data when you use our Service and the choices you have associated with that data.'
323
- },
324
- {
325
- id: 'data-collection',
326
- title: 'Information Collection and Use',
327
- content: 'We collect several different types of information for various purposes to provide and improve our Service to you.'
328
- },
329
- // More sections...
330
- ]
331
- },
332
- {
333
- id: 'minimal',
334
- name: 'Minimal Privacy Policy',
335
- description: 'A simplified privacy policy for small websites with minimal data collection.',
336
- sections: [
337
- // Sections...
338
- ]
339
- }
340
- ];
341
-
342
- function PrivacyPolicyPage() {
343
- const [generatedPolicy, setGeneratedPolicy] = useState(null);
344
- const [selectedTemplate, setSelectedTemplate] = useState('standard');
345
- const [policyData, setPolicyData] = useState({
346
- organizationName: '',
347
- organizationWebsite: '',
348
- organizationContact: '',
349
- // Other fields...
350
- });
351
- const [variables, setVariables] = useState({
352
- organizationName: '',
353
- websiteUrl: '',
354
- contactEmail: '',
355
- lastUpdated: new Date().toLocaleDateString()
356
- });
357
-
358
- const handlePolicyGenerated = (data) => {
359
- setPolicyData(data);
360
-
361
- // Update variables based on policy data
362
- setVariables({
363
- ...variables,
364
- organizationName: data.organizationName,
365
- websiteUrl: data.organizationWebsite,
366
- contactEmail: data.organizationContact
367
- });
368
-
369
- // Find the selected template
370
- const template = policyTemplates.find(t => t.id === selectedTemplate);
371
-
372
- // Generate the policy text with variables
373
- const result = generatePolicyText(template.sections, variables);
374
-
375
- setGeneratedPolicy({
376
- title: \`Privacy Policy for \${data.organizationName}\`,
377
- content: result.fullText,
378
- sections: template.sections.map(section => ({
379
- ...section,
380
- content: result.sectionTexts[section.id] || section.content
381
- })),
382
- lastUpdated: new Date()
383
- });
384
- };
385
-
386
- const handleExportPolicy = (format) => {
387
- // Export logic...
388
- };
389
-
390
- return (
391
- <div>
392
- {!generatedPolicy ? (
393
- <PolicyGenerator
394
- onComplete={handlePolicyGenerated}
395
- templates={policyTemplates}
396
- initialValues={policyData}
397
- onTemplateSelect={(templateId) => setSelectedTemplate(templateId)}
398
- variables={variables}
399
- />
400
- ) : (
401
- <div>
402
- <PolicyPreview
403
- policy={generatedPolicy}
404
- onEdit={() => setGeneratedPolicy(null)}
405
- variables={variables}
406
- onVariableChange={(newVariables) => {
407
- setVariables(newVariables);
408
-
409
- // Regenerate policy with new variables
410
- const template = policyTemplates.find(t => t.id === selectedTemplate);
411
- const result = generatePolicyText(template.sections, newVariables);
412
-
413
- setGeneratedPolicy({
414
- ...generatedPolicy,
415
- content: result.fullText,
416
- sections: template.sections.map(section => ({
417
- ...section,
418
- content: result.sectionTexts[section.id] || section.content
419
- }))
420
- });
421
- }}
422
- />
423
-
424
- <div className="mt-6">
425
- <h3 className="text-lg font-bold mb-2">Export Options</h3>
426
- <PolicyExport
427
- policy={generatedPolicy}
428
- formats={['html', 'pdf', 'markdown']}
429
- filename={\`privacy-policy-\${policyData.organizationName.toLowerCase().replace(/\\s+/g, '-')}\`}
430
- onExport={handleExportPolicy}
431
- />
432
- </div>
433
- </div>
434
- )}
435
- </div>
436
- );
437
- }`}</code></pre>
438
- </div>
439
- </section>
440
-
441
- <section id="api" className="mb-8">
442
- <h2 className="text-2xl font-bold mb-4">API Reference</h2>
443
-
444
- <h3 className="text-xl font-bold mt-8 mb-4">PolicyGenerator Props</h3>
445
- <div className="overflow-x-auto">
446
- <table className="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
447
- <thead className="bg-gray-50 dark:bg-gray-800">
448
- <tr>
449
- <th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Prop</th>
450
- <th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Type</th>
451
- <th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Default</th>
452
- <th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Description</th>
453
- </tr>
454
- </thead>
455
- <tbody className="bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700">
456
- <tr>
457
- <td className="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 dark:text-white">onComplete</td>
458
- <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">{`(data: PolicyData) => void`}</td>
459
- <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">Required</td>
460
- <td className="px-6 py-4 text-sm text-gray-500 dark:text-gray-400">Callback when policy generation is complete</td>
461
- </tr>
462
- <tr>
463
- <td className="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 dark:text-white">templates</td>
464
- <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">PolicyTemplate[]</td>
465
- <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">Required</td>
466
- <td className="px-6 py-4 text-sm text-gray-500 dark:text-gray-400">Array of policy templates</td>
467
- </tr>
468
- <tr>
469
- <td className="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 dark:text-white">initialValues</td>
470
- <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">{`Partial<PolicyData>`}</td>
471
- <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">{}</td>
472
- <td className="px-6 py-4 text-sm text-gray-500 dark:text-gray-400">Initial values for the policy form</td>
473
- </tr>
474
- <tr>
475
- <td className="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 dark:text-white">onTemplateSelect</td>
476
- <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">{`(templateId: string) => void`}</td>
477
- <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">undefined</td>
478
- <td className="px-6 py-4 text-sm text-gray-500 dark:text-gray-400">Callback when a template is selected</td>
479
- </tr>
480
- <tr>
481
- <td className="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 dark:text-white">variables</td>
482
- <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">{`Record<string, string>`}</td>
483
- <td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400">{}</td>
484
- <td className="px-6 py-4 text-sm text-gray-500 dark:text-gray-400">Variables to replace in policy templates</td>
485
- </tr>
486
- </tbody>
487
- </table>
488
- </div>
489
-
490
- <h3 className="text-xl font-bold mt-8 mb-4">generatePolicyText Function</h3>
491
- <div className="bg-gray-800 text-gray-200 p-4 rounded-md overflow-x-auto">
492
- <pre><code>{`/**
493
- * Generates policy text by replacing variables in a template
494
- *
495
- * @param sectionsOrTemplate - Either an array of PolicySection objects or a template string
496
- * @param organizationInfoOrVariables - Either an OrganizationInfo object or a variables object
497
- * @returns Either a string (if no variables used) or an object with fullText, sectionTexts, and missingVariables
498
- */
499
- function generatePolicyText(
500
- sectionsOrTemplate: PolicySection[] | string,
501
- organizationInfoOrVariables: OrganizationInfo | Record<string, string>
502
- ): string | {
503
- fullText: string;
504
- sectionTexts: Record<string, string>;
505
- missingVariables: string[];
506
- }`}</code></pre>
507
- </div>
508
-
509
- <h3 className="text-xl font-bold mt-8 mb-4">PolicyTemplate Type</h3>
510
- <div className="bg-gray-800 text-gray-200 p-4 rounded-md overflow-x-auto">
511
- <pre><code>{`type PolicyTemplate = {
512
- id: string;
513
- name: string;
514
- description: string;
515
- sections: PolicySection[];
516
- };`}</code></pre>
517
- </div>
518
-
519
- <h3 className="text-xl font-bold mt-8 mb-4">PolicySection Type</h3>
520
- <div className="bg-gray-800 text-gray-200 p-4 rounded-md overflow-x-auto">
521
- <pre><code>{`type PolicySection = {
522
- id: string;
523
- title: string;
524
- content: string;
525
- required?: boolean;
526
- };`}</code></pre>
527
- </div>
528
-
529
- <h3 className="text-xl font-bold mt-8 mb-4">PolicyData Type</h3>
530
- <div className="bg-gray-800 text-gray-200 p-4 rounded-md overflow-x-auto">
531
- <pre><code>{`type PolicyData = {
532
- // Organization Information
533
- organizationName: string;
534
- organizationWebsite: string;
535
- organizationContact: string;
536
- dpoName?: string;
537
- dpoEmail?: string;
538
-
539
- // Data Collection
540
- dataCollectionMethods: string[];
541
- personalDataTypes: string[];
542
- sensitiveDataTypes?: string[];
543
- legalBasisForProcessing: string[];
544
-
545
- // Data Usage
546
- dataUsagePurposes: string[];
547
- automaticDecisionMaking: boolean;
548
-
549
- // Data Sharing
550
- thirdPartySharing: boolean;
551
- thirdPartyCategories?: string[];
552
- internationalTransfers: boolean;
553
- transferSafeguards?: string;
554
-
555
- // Data Subject Rights
556
- dataSubjectRightsProcess: string;
557
-
558
- // Security and Retention
559
- securityMeasures: string[];
560
- retentionPeriod: string;
561
-
562
- // Cookies and Tracking
563
- usesCookies: boolean;
564
- cookieTypes?: string[];
565
-
566
- // Additional Information
567
- lastUpdated: Date;
568
- effectiveDate: Date;
569
- additionalInformation?: string;
570
- };`}</code></pre>
571
- </div>
572
- </section>
573
-
574
- <section id="best-practices" className="mb-8">
575
- <h2 className="text-2xl font-bold mb-4">Best Practices</h2>
576
- <ul className="list-disc pl-6 space-y-2">
577
- <li>
578
- <strong>Clear Language:</strong> Ensure your privacy policy is written in clear, plain language that is easy for data subjects to understand.
579
- </li>
580
- <li>
581
- <strong>Regular Updates:</strong> Review and update your privacy policy regularly, especially when there are changes to your data processing activities.
582
- </li>
583
- <li>
584
- <strong>Accessibility:</strong> Make your privacy policy easily accessible on your website or application, typically through a link in the footer.
585
- </li>
586
- <li>
587
- <strong>Customization:</strong> While the generator provides a solid template, customize the policy to accurately reflect your specific data practices.
588
- </li>
589
- <li>
590
- <strong>Legal Review:</strong> Have your generated privacy policy reviewed by a legal professional familiar with the NDPR to ensure compliance.
591
- </li>
592
- <li>
593
- <strong>Use Variables:</strong> Leverage the variable system to create reusable templates that can be easily updated when your organization information changes.
594
- </li>
595
- </ul>
596
- </section>
597
-
598
- <section id="help-resources" className="mb-8">
599
- <h2 className="text-2xl font-bold mb-4">Need Help?</h2>
600
- <p className="mb-4">
601
- If you have questions about implementing the Privacy Policy Generator or need assistance with NDPR compliance, check out these resources:
602
- </p>
603
- <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
604
- <Card>
605
- <CardContent className="p-4">
606
- <h3 className="font-medium text-gray-900 dark:text-white mb-2">GitHub Issues</h3>
607
- <p className="text-gray-600 dark:text-gray-300 text-sm mb-3">
608
- Report bugs or request features on our GitHub repository.
609
- </p>
610
- <Button asChild variant="outline" size="sm">
611
- <a href="https://github.com/tantainnovative/ndpr-toolkit/issues" target="_blank" rel="noopener noreferrer">
612
- View Issues
613
- </a>
614
- </Button>
615
- </CardContent>
616
- </Card>
617
- <Card>
618
- <CardContent className="p-4">
619
- <h3 className="font-medium text-gray-900 dark:text-white mb-2">NDPR Resources</h3>
620
- <p className="text-gray-600 dark:text-gray-300 text-sm mb-3">
621
- Learn more about NDPR compliance requirements.
622
- </p>
623
- <Button asChild variant="outline" size="sm">
624
- <a href="https://nitda.gov.ng/wp-content/uploads/2020/01/NDPR-Implementation-Framework.pdf" target="_blank" rel="noopener noreferrer">
625
- NDPR Framework
626
- </a>
627
- </Button>
628
- </CardContent>
629
- </Card>
630
- </div>
631
- </section>
632
- </DocLayout>
633
- );
634
- }