@tantainnovative/ndpr-toolkit 1.0.5 → 1.0.6

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 (159) hide show
  1. package/README.md +447 -84
  2. package/dist/index.esm.js +2 -0
  3. package/dist/index.esm.js.map +1 -0
  4. package/dist/index.js +2 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/types/index.d.ts +35 -0
  7. package/package.json +52 -70
  8. package/CHANGELOG.md +0 -16
  9. package/CNAME +0 -1
  10. package/CONTRIBUTING.md +0 -87
  11. package/RELEASE-NOTES-v1.0.0.md +0 -140
  12. package/RELEASE-NOTES-v1.0.1.md +0 -69
  13. package/SECURITY.md +0 -21
  14. package/components.json +0 -21
  15. package/eslint.config.mjs +0 -16
  16. package/next-env.d.ts +0 -5
  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/dist/index.esm.js +0 -2
  21. package/packages/ndpr-toolkit/dist/index.esm.js.map +0 -1
  22. package/packages/ndpr-toolkit/dist/index.js +0 -2
  23. package/packages/ndpr-toolkit/dist/index.js.map +0 -1
  24. package/packages/ndpr-toolkit/package-lock.json +0 -8197
  25. package/packages/ndpr-toolkit/package.json +0 -71
  26. package/packages/ndpr-toolkit/rollup.config.js +0 -34
  27. package/packages/ndpr-toolkit/src/components/breach/BreachNotificationManager.tsx +0 -701
  28. package/packages/ndpr-toolkit/src/components/breach/BreachReportForm.tsx +0 -631
  29. package/packages/ndpr-toolkit/src/components/breach/BreachRiskAssessment.tsx +0 -569
  30. package/packages/ndpr-toolkit/src/components/breach/RegulatoryReportGenerator.tsx +0 -496
  31. package/packages/ndpr-toolkit/src/components/consent/ConsentBanner.tsx +0 -270
  32. package/packages/ndpr-toolkit/src/components/consent/ConsentManager.tsx +0 -217
  33. package/packages/ndpr-toolkit/src/components/consent/ConsentStorage.tsx +0 -206
  34. package/packages/ndpr-toolkit/src/components/dpia/DPIAQuestionnaire.tsx +0 -342
  35. package/packages/ndpr-toolkit/src/components/dpia/DPIAReport.tsx +0 -373
  36. package/packages/ndpr-toolkit/src/components/dpia/StepIndicator.tsx +0 -174
  37. package/packages/ndpr-toolkit/src/components/dsr/DSRDashboard.tsx +0 -717
  38. package/packages/ndpr-toolkit/src/components/dsr/DSRRequestForm.tsx +0 -476
  39. package/packages/ndpr-toolkit/src/components/dsr/DSRTracker.tsx +0 -620
  40. package/packages/ndpr-toolkit/src/components/policy/PolicyExporter.tsx +0 -541
  41. package/packages/ndpr-toolkit/src/components/policy/PolicyGenerator.tsx +0 -454
  42. package/packages/ndpr-toolkit/src/components/policy/PolicyPreview.tsx +0 -333
  43. package/packages/ndpr-toolkit/src/hooks/useBreach.ts +0 -409
  44. package/packages/ndpr-toolkit/src/hooks/useConsent.ts +0 -263
  45. package/packages/ndpr-toolkit/src/hooks/useDPIA.ts +0 -457
  46. package/packages/ndpr-toolkit/src/hooks/useDSR.ts +0 -236
  47. package/packages/ndpr-toolkit/src/hooks/usePrivacyPolicy.ts +0 -428
  48. package/packages/ndpr-toolkit/src/index.ts +0 -44
  49. package/packages/ndpr-toolkit/src/setupTests.ts +0 -5
  50. package/packages/ndpr-toolkit/src/types/breach.ts +0 -283
  51. package/packages/ndpr-toolkit/src/types/consent.ts +0 -111
  52. package/packages/ndpr-toolkit/src/types/dpia.ts +0 -236
  53. package/packages/ndpr-toolkit/src/types/dsr.ts +0 -192
  54. package/packages/ndpr-toolkit/src/types/index.ts +0 -42
  55. package/packages/ndpr-toolkit/src/types/privacy.ts +0 -246
  56. package/packages/ndpr-toolkit/src/utils/breach.ts +0 -122
  57. package/packages/ndpr-toolkit/src/utils/consent.ts +0 -51
  58. package/packages/ndpr-toolkit/src/utils/dpia.ts +0 -104
  59. package/packages/ndpr-toolkit/src/utils/dsr.ts +0 -77
  60. package/packages/ndpr-toolkit/src/utils/privacy.ts +0 -100
  61. package/packages/ndpr-toolkit/tsconfig.json +0 -23
  62. package/postcss.config.mjs +0 -5
  63. package/public/NDPR TOOLKIT.svg +0 -1
  64. package/public/favicon/android-chrome-192x192.png +0 -0
  65. package/public/favicon/android-chrome-512x512.png +0 -0
  66. package/public/favicon/apple-touch-icon.png +0 -0
  67. package/public/favicon/favicon-16x16.png +0 -0
  68. package/public/favicon/favicon-32x32.png +0 -0
  69. package/public/favicon/site.webmanifest +0 -1
  70. package/public/file.svg +0 -1
  71. package/public/globe.svg +0 -1
  72. package/public/ndpr-toolkit-logo.svg +0 -108
  73. package/public/next.svg +0 -1
  74. package/public/vercel.svg +0 -1
  75. package/public/window.svg +0 -1
  76. package/src/app/accessibility.css +0 -70
  77. package/src/app/favicon.ico +0 -0
  78. package/src/app/globals.css +0 -123
  79. package/src/app/layout.tsx +0 -37
  80. package/src/app/ndpr-demos/breach/page.tsx +0 -354
  81. package/src/app/ndpr-demos/consent/page.tsx +0 -366
  82. package/src/app/ndpr-demos/dpia/page.tsx +0 -495
  83. package/src/app/ndpr-demos/dsr/page.tsx +0 -280
  84. package/src/app/ndpr-demos/page.tsx +0 -73
  85. package/src/app/ndpr-demos/policy/page.tsx +0 -771
  86. package/src/app/page.tsx +0 -452
  87. package/src/components/ErrorBoundary.tsx +0 -90
  88. package/src/components/breach-notification/BreachNotificationForm.tsx +0 -479
  89. package/src/components/consent/ConsentBanner.tsx +0 -193
  90. package/src/components/data-subject-rights/DataSubjectRequestForm.tsx +0 -530
  91. package/src/components/dpia/DPIAQuestionnaire.tsx +0 -523
  92. package/src/components/privacy-policy/PolicyGenerator.tsx +0 -1062
  93. package/src/components/privacy-policy/data.ts +0 -98
  94. package/src/components/privacy-policy/shared/CheckboxField.tsx +0 -38
  95. package/src/components/privacy-policy/shared/CheckboxGroup.tsx +0 -85
  96. package/src/components/privacy-policy/shared/FormField.tsx +0 -79
  97. package/src/components/privacy-policy/shared/StepIndicator.tsx +0 -86
  98. package/src/components/privacy-policy/steps/CustomSectionsStep.tsx +0 -361
  99. package/src/components/privacy-policy/steps/DataCollectionStep.tsx +0 -231
  100. package/src/components/privacy-policy/steps/DataSharingStep.tsx +0 -418
  101. package/src/components/privacy-policy/steps/OrganizationInfoStep.tsx +0 -202
  102. package/src/components/privacy-policy/steps/PolicyPreviewStep.tsx +0 -226
  103. package/src/components/ui/Badge.tsx +0 -46
  104. package/src/components/ui/Button.tsx +0 -59
  105. package/src/components/ui/Card.tsx +0 -92
  106. package/src/components/ui/Checkbox.tsx +0 -57
  107. package/src/components/ui/FormField.tsx +0 -50
  108. package/src/components/ui/Input.tsx +0 -38
  109. package/src/components/ui/Loading.tsx +0 -201
  110. package/src/components/ui/Select.tsx +0 -42
  111. package/src/components/ui/TextArea.tsx +0 -38
  112. package/src/components/ui/label.tsx +0 -24
  113. package/src/components/ui/switch.tsx +0 -31
  114. package/src/components/ui/tabs.tsx +0 -66
  115. package/src/hooks/useConsent.ts +0 -70
  116. package/src/hooks/useLoadingState.ts +0 -85
  117. package/src/lib/consentService.ts +0 -144
  118. package/src/lib/dpiaQuestions.ts +0 -188
  119. package/src/lib/requestService.ts +0 -79
  120. package/src/lib/sanitize.ts +0 -108
  121. package/src/lib/storage.ts +0 -222
  122. package/src/lib/utils.ts +0 -6
  123. package/src/types/html-to-docx.d.ts +0 -30
  124. package/src/types/index.ts +0 -77
  125. package/tailwind.config.ts +0 -65
  126. package/tsconfig.json +0 -41
  127. /package/{packages/ndpr-toolkit/dist → dist}/components/breach/BreachNotificationManager.d.ts +0 -0
  128. /package/{packages/ndpr-toolkit/dist → dist}/components/breach/BreachReportForm.d.ts +0 -0
  129. /package/{packages/ndpr-toolkit/dist → dist}/components/breach/BreachRiskAssessment.d.ts +0 -0
  130. /package/{packages/ndpr-toolkit/dist → dist}/components/breach/RegulatoryReportGenerator.d.ts +0 -0
  131. /package/{packages/ndpr-toolkit/dist → dist}/components/consent/ConsentBanner.d.ts +0 -0
  132. /package/{packages/ndpr-toolkit/dist → dist}/components/consent/ConsentManager.d.ts +0 -0
  133. /package/{packages/ndpr-toolkit/dist → dist}/components/consent/ConsentStorage.d.ts +0 -0
  134. /package/{packages/ndpr-toolkit/dist → dist}/components/dpia/DPIAQuestionnaire.d.ts +0 -0
  135. /package/{packages/ndpr-toolkit/dist → dist}/components/dpia/DPIAReport.d.ts +0 -0
  136. /package/{packages/ndpr-toolkit/dist → dist}/components/dpia/StepIndicator.d.ts +0 -0
  137. /package/{packages/ndpr-toolkit/dist → dist}/components/dsr/DSRDashboard.d.ts +0 -0
  138. /package/{packages/ndpr-toolkit/dist → dist}/components/dsr/DSRRequestForm.d.ts +0 -0
  139. /package/{packages/ndpr-toolkit/dist → dist}/components/dsr/DSRTracker.d.ts +0 -0
  140. /package/{packages/ndpr-toolkit/dist → dist}/components/policy/PolicyExporter.d.ts +0 -0
  141. /package/{packages/ndpr-toolkit/dist → dist}/components/policy/PolicyGenerator.d.ts +0 -0
  142. /package/{packages/ndpr-toolkit/dist → dist}/components/policy/PolicyPreview.d.ts +0 -0
  143. /package/{packages/ndpr-toolkit/dist → dist}/hooks/useBreach.d.ts +0 -0
  144. /package/{packages/ndpr-toolkit/dist → dist}/hooks/useConsent.d.ts +0 -0
  145. /package/{packages/ndpr-toolkit/dist → dist}/hooks/useDPIA.d.ts +0 -0
  146. /package/{packages/ndpr-toolkit/dist → dist}/hooks/useDSR.d.ts +0 -0
  147. /package/{packages/ndpr-toolkit/dist → dist}/hooks/usePrivacyPolicy.d.ts +0 -0
  148. /package/{packages/ndpr-toolkit/dist → dist}/index.d.ts +0 -0
  149. /package/{packages/ndpr-toolkit/dist → dist}/setupTests.d.ts +0 -0
  150. /package/{packages/ndpr-toolkit/dist → dist}/types/breach.d.ts +0 -0
  151. /package/{packages/ndpr-toolkit/dist → dist}/types/consent.d.ts +0 -0
  152. /package/{packages/ndpr-toolkit/dist → dist}/types/dpia.d.ts +0 -0
  153. /package/{packages/ndpr-toolkit/dist → dist}/types/dsr.d.ts +0 -0
  154. /package/{packages/ndpr-toolkit/dist → dist}/types/privacy.d.ts +0 -0
  155. /package/{packages/ndpr-toolkit/dist → dist}/utils/breach.d.ts +0 -0
  156. /package/{packages/ndpr-toolkit/dist → dist}/utils/consent.d.ts +0 -0
  157. /package/{packages/ndpr-toolkit/dist → dist}/utils/dpia.d.ts +0 -0
  158. /package/{packages/ndpr-toolkit/dist → dist}/utils/dsr.d.ts +0 -0
  159. /package/{packages/ndpr-toolkit/dist → dist}/utils/privacy.d.ts +0 -0
@@ -1,523 +0,0 @@
1
- "use client";
2
-
3
- import { useState, useEffect } from "react";
4
- import { RiskAssessmentQuestion } from "@/types";
5
- import { Button } from "@/components/ui/Button";
6
- import { Input } from "@/components/ui/Input";
7
- import { TextArea } from "@/components/ui/TextArea";
8
- import { FormField } from "@/components/ui/FormField";
9
- import { Card, CardHeader, CardTitle, CardContent } from "@/components/ui/Card";
10
- import { Badge } from "@/components/ui/Badge";
11
-
12
- interface DPIAQuestionnaireProps {
13
- questions: RiskAssessmentQuestion[];
14
- onSubmit: (answers: Record<string, number>, projectName: string) => void;
15
- className?: string;
16
- }
17
-
18
- export default function DPIAQuestionnaire({
19
- questions,
20
- onSubmit,
21
- className = "",
22
- }: DPIAQuestionnaireProps) {
23
- const [projectName, setProjectName] = useState("");
24
- const [projectDescription, setProjectDescription] = useState("");
25
- const [dataController, setDataController] = useState("");
26
- const [assessmentDate, setAssessmentDate] = useState(
27
- new Date().toISOString().split("T")[0],
28
- );
29
- const [answers, setAnswers] = useState<Record<string, number>>({});
30
- const [currentStep, setCurrentStep] = useState(0);
31
- const [errors, setErrors] = useState<Record<string, string>>({});
32
- const [progress, setProgress] = useState(0);
33
-
34
- // Since DPIAQuestion doesn't have a category, we'll create a single category
35
- const categories: Record<string, RiskAssessmentQuestion[]> = {
36
- "Assessment Questions": questions,
37
- };
38
-
39
- const categoryNames = Object.keys(categories);
40
-
41
- const handleAnswerChange = (questionId: string, value: number | string) => {
42
- setAnswers((prev) => ({
43
- ...prev,
44
- [questionId]: typeof value === "string" ? parseInt(value, 10) : value,
45
- }));
46
-
47
- // Clear error when question is answered
48
- if (errors[questionId]) {
49
- setErrors((prev) => {
50
- const newErrors = { ...prev };
51
- delete newErrors[questionId];
52
- return newErrors;
53
- });
54
- }
55
- };
56
-
57
- // Render different input types based on question type
58
- const renderQuestionInput = (question: RiskAssessmentQuestion) => {
59
- switch (question.type) {
60
- case "text":
61
- return (
62
- <Input
63
- id={question.id}
64
- value={answers[question.id] || ""}
65
- onChange={(e) => handleAnswerChange(question.id, e.target.value)}
66
- placeholder={question.guidance}
67
- className="w-full"
68
- />
69
- );
70
-
71
- case "textarea":
72
- return (
73
- <TextArea
74
- id={question.id}
75
- value={answers[question.id] || ""}
76
- onChange={(e) => handleAnswerChange(question.id, e.target.value)}
77
- placeholder={question.guidance}
78
- rows={4}
79
- className="w-full"
80
- />
81
- );
82
-
83
- case "select":
84
- return (
85
- <select
86
- id={question.id}
87
- value={answers[question.id] || ""}
88
- onChange={(e) => handleAnswerChange(question.id, e.target.value)}
89
- className="w-full p-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
90
- >
91
- <option value="">Select an option</option>
92
- {question.options?.map((option) => (
93
- <option key={option.value} value={option.value}>
94
- {option.label}
95
- </option>
96
- ))}
97
- </select>
98
- );
99
-
100
- case "radio":
101
- return question.options?.map((option) => (
102
- <div
103
- key={option.value}
104
- className={`p-3 border rounded-md cursor-pointer transition-colors ${
105
- answers[question.id] === parseInt(option.value)
106
- ? "border-blue-500 bg-blue-50 dark:bg-blue-900/30 dark:border-blue-400"
107
- : "border-gray-200 dark:border-gray-700 hover:bg-gray-50 dark:hover:bg-gray-800"
108
- }`}
109
- onClick={() => handleAnswerChange(question.id, option.value)}
110
- >
111
- <div className="flex items-center justify-between">
112
- <div className="flex items-center">
113
- <input
114
- id={`${question.id}-${option.value}`}
115
- name={question.id}
116
- type="radio"
117
- value={option.value}
118
- checked={answers[question.id] === parseInt(option.value)}
119
- onChange={() => handleAnswerChange(question.id, option.value)}
120
- className="h-4 w-4 border-gray-300 text-blue-600 focus:ring-blue-500"
121
- />
122
- <label
123
- htmlFor={`${question.id}-${option.value}`}
124
- className="ml-3 block text-sm text-gray-700 dark:text-gray-300 cursor-pointer"
125
- >
126
- {option.label}
127
- </label>
128
- </div>
129
- {option.riskLevel &&
130
- getRiskLevelIndicator(parseInt(option.value))}
131
- </div>
132
- </div>
133
- ));
134
-
135
- case "checkbox":
136
- return question.options?.map((option) => (
137
- <div key={option.value} className="flex items-center">
138
- <input
139
- id={`${question.id}-${option.value}`}
140
- type="checkbox"
141
- value={option.value}
142
- checked={answers[question.id]?.toString().includes(option.value)}
143
- onChange={(e) => {
144
- const currentValues =
145
- answers[question.id]?.toString().split(",").filter(Boolean) ||
146
- [];
147
- if (e.target.checked) {
148
- currentValues.push(option.value);
149
- } else {
150
- const index = currentValues.indexOf(option.value);
151
- if (index > -1) currentValues.splice(index, 1);
152
- }
153
- handleAnswerChange(question.id, currentValues.join(","));
154
- }}
155
- className="h-4 w-4 border-gray-300 text-blue-600 focus:ring-blue-500 rounded"
156
- />
157
- <label
158
- htmlFor={`${question.id}-${option.value}`}
159
- className="ml-3 block text-sm text-gray-700 dark:text-gray-300"
160
- >
161
- {option.label}
162
- </label>
163
- </div>
164
- ));
165
-
166
- case "scale":
167
- return (
168
- <div className="space-y-2">
169
- <input
170
- type="range"
171
- id={question.id}
172
- min={question.minValue || 1}
173
- max={question.maxValue || 5}
174
- value={answers[question.id] || question.minValue || 1}
175
- onChange={(e) => handleAnswerChange(question.id, e.target.value)}
176
- className="w-full"
177
- />
178
- <div className="flex justify-between text-sm text-gray-600">
179
- {question.scaleLabels ? (
180
- Object.entries(question.scaleLabels).map(([value, label]) => (
181
- <span key={value}>{label}</span>
182
- ))
183
- ) : (
184
- <>
185
- <span>{question.minValue || 1}</span>
186
- <span>{question.maxValue || 5}</span>
187
- </>
188
- )}
189
- </div>
190
- </div>
191
- );
192
-
193
- default:
194
- return (
195
- <p className="text-gray-500">
196
- Unsupported question type: {question.type}
197
- </p>
198
- );
199
- }
200
- };
201
-
202
- // Calculate overall progress
203
- useEffect(() => {
204
- const totalQuestions = questions.length;
205
- const answeredQuestions = Object.keys(answers).length;
206
- const projectInfoComplete = projectName.trim() !== "" ? 1 : 0;
207
-
208
- // Calculate progress percentage (project info counts as one question)
209
- const calculatedProgress = Math.round(
210
- ((answeredQuestions + projectInfoComplete) / (totalQuestions + 1)) * 100,
211
- );
212
- setProgress(calculatedProgress);
213
- }, [answers, projectName, questions.length]);
214
-
215
- const validateStep = (step: number) => {
216
- const newErrors: Record<string, string> = {};
217
-
218
- if (step === 0) {
219
- if (!projectName.trim()) {
220
- newErrors.projectName = "Project name is required";
221
- }
222
- // Description and data controller are optional, so no validation needed
223
- } else {
224
- const category = categoryNames[step - 1];
225
- const categoryQuestions = categories[category];
226
-
227
- categoryQuestions.forEach((question) => {
228
- if (answers[question.id] === undefined) {
229
- newErrors[question.id] = "Please select an answer for this question";
230
- }
231
- });
232
- }
233
-
234
- setErrors(newErrors);
235
- return Object.keys(newErrors).length === 0;
236
- };
237
-
238
- const handleNext = () => {
239
- if (validateStep(currentStep)) {
240
- setCurrentStep((prev) => prev + 1);
241
- }
242
- };
243
-
244
- const handleBack = () => {
245
- setCurrentStep((prev) => prev - 1);
246
- };
247
-
248
- const handleSubmit = () => {
249
- if (validateStep(currentStep)) {
250
- // Submit with just the answers and project name as per interface definition
251
- onSubmit(answers, projectName);
252
- }
253
- };
254
-
255
- const renderStepContent = () => {
256
- if (currentStep === 0) {
257
- return (
258
- <div className="space-y-6">
259
- <h3 className="text-lg font-medium text-gray-900 dark:text-white">
260
- Project Information
261
- </h3>
262
-
263
- <div className="bg-blue-50 dark:bg-blue-900/20 p-4 rounded-md mb-6">
264
- <p className="text-sm text-blue-800 dark:text-blue-200">
265
- This Data Protection Impact Assessment (DPIA) will help you
266
- identify and minimize data protection risks in your project.
267
- Please provide accurate information to receive the most relevant
268
- recommendations.
269
- </p>
270
- </div>
271
-
272
- <FormField
273
- id="projectName"
274
- label="Project Name"
275
- required
276
- error={errors.projectName}
277
- >
278
- <Input
279
- id="projectName"
280
- value={projectName}
281
- onChange={(e) => setProjectName(e.target.value)}
282
- placeholder="Enter the name of your project or data processing activity"
283
- />
284
- </FormField>
285
-
286
- <FormField
287
- id="projectDescription"
288
- label="Project Description"
289
- description="Briefly describe the purpose and scope of your project"
290
- >
291
- <TextArea
292
- id="projectDescription"
293
- value={projectDescription}
294
- onChange={(e) => setProjectDescription(e.target.value)}
295
- rows={3}
296
- placeholder="Briefly describe the purpose and scope of your project"
297
- />
298
- </FormField>
299
-
300
- <FormField
301
- id="dataController"
302
- label="Data Controller"
303
- description="Organization responsible for the data"
304
- >
305
- <Input
306
- id="dataController"
307
- value={dataController}
308
- onChange={(e) => setDataController(e.target.value)}
309
- placeholder="Name of the organization responsible for the data"
310
- />
311
- </FormField>
312
-
313
- <FormField id="assessmentDate" label="Assessment Date">
314
- <Input
315
- type="date"
316
- id="assessmentDate"
317
- value={assessmentDate}
318
- onChange={(e) => setAssessmentDate(e.target.value)}
319
- />
320
- </FormField>
321
- </div>
322
- );
323
- }
324
-
325
- const category = categoryNames[currentStep - 1];
326
- const categoryQuestions = categories[category];
327
-
328
- return (
329
- <div className="space-y-6">
330
- <div className="flex items-center space-x-2">
331
- <div className="w-8 h-8 rounded-full bg-blue-100 dark:bg-blue-900 flex items-center justify-center">
332
- <span className="text-blue-600 dark:text-blue-300 font-medium">
333
- {currentStep}
334
- </span>
335
- </div>
336
- <h3 className="text-lg font-medium text-gray-900 dark:text-white">
337
- {category}
338
- </h3>
339
- </div>
340
-
341
- <div className="bg-gray-50 dark:bg-gray-800 p-4 rounded-md mb-4">
342
- <p className="text-sm text-gray-600 dark:text-gray-400">
343
- {getCategoryDescription(category)}
344
- </p>
345
- </div>
346
-
347
- {categoryQuestions.map((question, index) => (
348
- <div
349
- key={question.id}
350
- className="p-4 border border-gray-200 dark:border-gray-700 rounded-lg space-y-4"
351
- >
352
- <div className="flex items-start">
353
- <div className="flex-shrink-0 w-6 h-6 rounded-full bg-blue-100 dark:bg-blue-900 flex items-center justify-center mr-3 mt-0.5">
354
- <span className="text-blue-600 dark:text-blue-300 text-xs font-medium">
355
- {index + 1}
356
- </span>
357
- </div>
358
- <label className="block text-sm font-medium text-gray-800 dark:text-gray-200">
359
- {question.text}
360
- </label>
361
- </div>
362
-
363
- <div className="ml-9 space-y-2">
364
- {renderQuestionInput(question)}
365
- </div>
366
-
367
- {errors[question.id] && (
368
- <p className="ml-9 text-sm text-red-600 dark:text-red-400">
369
- {errors[question.id]}
370
- </p>
371
- )}
372
- </div>
373
- ))}
374
- </div>
375
- );
376
- };
377
-
378
- // Helper function to get category descriptions
379
- const getCategoryDescription = (category: string): string => {
380
- switch (category) {
381
- case "Data Collection":
382
- return "These questions help assess the risks associated with the types of personal data you collect and the sources of that data.";
383
- case "Data Processing":
384
- return "These questions evaluate how you use, analyze, and transform the personal data within your project.";
385
- case "Data Sharing":
386
- return "These questions examine the risks of sharing personal data with third parties or transferring it across borders.";
387
- case "Security Measures":
388
- return "These questions assess the safeguards you have in place to protect personal data from unauthorized access or breaches.";
389
- case "Data Subject Rights":
390
- return "These questions evaluate how well your project supports individuals in exercising their rights over their personal data.";
391
- default:
392
- return "Please answer the following questions about your project.";
393
- }
394
- };
395
-
396
- // Helper function to display risk level indicators
397
- const getRiskLevelIndicator = (value: number) => {
398
- const variants: Record<
399
- number,
400
- "success" | "warning" | "danger" | "primary"
401
- > = {
402
- 1: "success",
403
- 2: "warning",
404
- 3: "danger",
405
- 4: "danger",
406
- };
407
-
408
- const labels = {
409
- 1: "Low Risk",
410
- 2: "Medium Risk",
411
- 3: "High Risk",
412
- 4: "Very High Risk",
413
- };
414
-
415
- return (
416
- <div className="flex items-center ml-auto pl-2">
417
- <Badge variant={variants[value as keyof typeof variants]}>
418
- {labels[value as keyof typeof labels]}
419
- </Badge>
420
- </div>
421
- );
422
- };
423
-
424
- const totalSteps = categoryNames.length + 1; // +1 for the project info step
425
-
426
- return (
427
- <Card className={className}>
428
- <CardHeader>
429
- <CardTitle>Data Protection Impact Assessment</CardTitle>
430
- <p className="text-sm text-gray-500 dark:text-gray-400">
431
- Assess the data protection risks of your project with our DPIA tool.
432
- </p>
433
- </CardHeader>
434
-
435
- <CardContent>
436
- <div className="mb-6">
437
- <div className="flex items-center justify-between mb-2">
438
- <div className="text-sm text-gray-500 dark:text-gray-400">
439
- Step {currentStep + 1} of {totalSteps}
440
- </div>
441
- <div className="text-sm font-medium text-gray-900 dark:text-white">
442
- {currentStep === 0
443
- ? "Project Information"
444
- : categoryNames[currentStep - 1]}
445
- </div>
446
- </div>
447
- <div className="h-2 w-full bg-gray-200 dark:bg-gray-700 rounded-full overflow-hidden">
448
- <div
449
- className="h-2 bg-blue-600 rounded-full transition-all duration-300 ease-in-out"
450
- style={{ width: `${((currentStep + 1) / totalSteps) * 100}%` }}
451
- />
452
- </div>
453
- <div className="flex justify-between mt-2">
454
- <div className="text-xs text-gray-500 dark:text-gray-400">
455
- Overall completion: {progress}%
456
- </div>
457
- {currentStep > 0 && currentStep < totalSteps && (
458
- <div className="text-xs text-gray-500 dark:text-gray-400">
459
- {
460
- categories[categoryNames[currentStep - 1]].filter(
461
- (q) => answers[q.id] !== undefined,
462
- ).length
463
- }{" "}
464
- of {categories[categoryNames[currentStep - 1]].length} questions
465
- answered
466
- </div>
467
- )}
468
- </div>
469
- </div>
470
-
471
- <div className="mb-6">{renderStepContent()}</div>
472
-
473
- <div className="flex justify-between pt-4 border-t border-gray-200 dark:border-gray-700">
474
- {currentStep > 0 ? (
475
- <Button type="button" onClick={handleBack} variant="outline">
476
- <svg
477
- className="w-5 h-5 mr-1"
478
- fill="none"
479
- stroke="currentColor"
480
- viewBox="0 0 24 24"
481
- xmlns="http://www.w3.org/2000/svg"
482
- >
483
- <path
484
- strokeLinecap="round"
485
- strokeLinejoin="round"
486
- strokeWidth={2}
487
- d="M15 19l-7-7 7-7"
488
- />
489
- </svg>
490
- Back
491
- </Button>
492
- ) : (
493
- <div>{/* Empty div to maintain layout */}</div>
494
- )}
495
-
496
- {currentStep < totalSteps - 1 ? (
497
- <Button type="button" onClick={handleNext} variant="default">
498
- Next
499
- <svg
500
- className="w-5 h-5 ml-1"
501
- fill="none"
502
- stroke="currentColor"
503
- viewBox="0 0 24 24"
504
- xmlns="http://www.w3.org/2000/svg"
505
- >
506
- <path
507
- strokeLinecap="round"
508
- strokeLinejoin="round"
509
- strokeWidth={2}
510
- d="M9 5l7 7-7 7"
511
- />
512
- </svg>
513
- </Button>
514
- ) : (
515
- <Button type="button" onClick={handleSubmit} variant="default">
516
- Submit Assessment
517
- </Button>
518
- )}
519
- </div>
520
- </CardContent>
521
- </Card>
522
- );
523
- }