@striae-org/striae 3.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 (223) hide show
  1. package/.env.example +100 -0
  2. package/LICENSE +190 -0
  3. package/NOTICE +18 -0
  4. package/README.md +133 -0
  5. package/app/components/actions/case-export/core-export.ts +328 -0
  6. package/app/components/actions/case-export/data-processing.ts +167 -0
  7. package/app/components/actions/case-export/download-handlers.ts +900 -0
  8. package/app/components/actions/case-export/index.ts +41 -0
  9. package/app/components/actions/case-export/metadata-helpers.ts +107 -0
  10. package/app/components/actions/case-export/types-constants.ts +56 -0
  11. package/app/components/actions/case-export/validation-utils.ts +25 -0
  12. package/app/components/actions/case-export.ts +4 -0
  13. package/app/components/actions/case-import/annotation-import.ts +35 -0
  14. package/app/components/actions/case-import/confirmation-import.ts +363 -0
  15. package/app/components/actions/case-import/image-operations.ts +61 -0
  16. package/app/components/actions/case-import/index.ts +39 -0
  17. package/app/components/actions/case-import/orchestrator.ts +420 -0
  18. package/app/components/actions/case-import/storage-operations.ts +270 -0
  19. package/app/components/actions/case-import/validation.ts +189 -0
  20. package/app/components/actions/case-import/zip-processing.ts +413 -0
  21. package/app/components/actions/case-manage.ts +524 -0
  22. package/app/components/actions/case-review.ts +4 -0
  23. package/app/components/actions/confirm-export.ts +351 -0
  24. package/app/components/actions/generate-pdf.ts +210 -0
  25. package/app/components/actions/image-manage.ts +385 -0
  26. package/app/components/actions/notes-manage.ts +33 -0
  27. package/app/components/actions/signout.module.css +15 -0
  28. package/app/components/actions/signout.tsx +50 -0
  29. package/app/components/audit/user-audit-viewer.tsx +975 -0
  30. package/app/components/audit/user-audit.module.css +568 -0
  31. package/app/components/auth/auth-provider.tsx +78 -0
  32. package/app/components/auth/mfa-enrollment.module.css +268 -0
  33. package/app/components/auth/mfa-enrollment.tsx +398 -0
  34. package/app/components/auth/mfa-verification.module.css +251 -0
  35. package/app/components/auth/mfa-verification.tsx +295 -0
  36. package/app/components/button/button.module.css +63 -0
  37. package/app/components/button/button.tsx +46 -0
  38. package/app/components/canvas/box-annotations/box-annotations.module.css +170 -0
  39. package/app/components/canvas/box-annotations/box-annotations.tsx +634 -0
  40. package/app/components/canvas/canvas.module.css +314 -0
  41. package/app/components/canvas/canvas.tsx +449 -0
  42. package/app/components/canvas/confirmation/confirmation.module.css +187 -0
  43. package/app/components/canvas/confirmation/confirmation.tsx +214 -0
  44. package/app/components/colors/colors.module.css +59 -0
  45. package/app/components/colors/colors.tsx +68 -0
  46. package/app/components/form/base-form.tsx +21 -0
  47. package/app/components/form/form-button.tsx +28 -0
  48. package/app/components/form/form-field.tsx +53 -0
  49. package/app/components/form/form-message.tsx +17 -0
  50. package/app/components/form/form-toggle.tsx +23 -0
  51. package/app/components/form/form.module.css +427 -0
  52. package/app/components/form/index.ts +6 -0
  53. package/app/components/icon/icon.module.css +3 -0
  54. package/app/components/icon/icon.tsx +27 -0
  55. package/app/components/icon/icons.svg +102 -0
  56. package/app/components/icon/manifest.json +110 -0
  57. package/app/components/sidebar/case-export/case-export.module.css +386 -0
  58. package/app/components/sidebar/case-export/case-export.tsx +317 -0
  59. package/app/components/sidebar/case-import/case-import.module.css +626 -0
  60. package/app/components/sidebar/case-import/case-import.tsx +404 -0
  61. package/app/components/sidebar/case-import/components/CasePreviewSection.tsx +72 -0
  62. package/app/components/sidebar/case-import/components/ConfirmationDialog.tsx +72 -0
  63. package/app/components/sidebar/case-import/components/ConfirmationPreviewSection.tsx +71 -0
  64. package/app/components/sidebar/case-import/components/ExistingCaseSection.tsx +40 -0
  65. package/app/components/sidebar/case-import/components/FileSelector.tsx +161 -0
  66. package/app/components/sidebar/case-import/components/ProgressSection.tsx +46 -0
  67. package/app/components/sidebar/case-import/hooks/useFilePreview.ts +101 -0
  68. package/app/components/sidebar/case-import/hooks/useImportExecution.ts +152 -0
  69. package/app/components/sidebar/case-import/hooks/useImportState.ts +88 -0
  70. package/app/components/sidebar/case-import/index.ts +18 -0
  71. package/app/components/sidebar/case-import/utils/file-validation.ts +43 -0
  72. package/app/components/sidebar/cases/case-sidebar.tsx +827 -0
  73. package/app/components/sidebar/cases/cases-modal.module.css +166 -0
  74. package/app/components/sidebar/cases/cases-modal.tsx +201 -0
  75. package/app/components/sidebar/cases/cases.module.css +713 -0
  76. package/app/components/sidebar/files/files-modal.module.css +209 -0
  77. package/app/components/sidebar/files/files-modal.tsx +239 -0
  78. package/app/components/sidebar/hash/hash-utility.module.css +366 -0
  79. package/app/components/sidebar/hash/hash-utility.tsx +982 -0
  80. package/app/components/sidebar/notes/notes-modal.tsx +51 -0
  81. package/app/components/sidebar/notes/notes-sidebar.tsx +491 -0
  82. package/app/components/sidebar/notes/notes.module.css +360 -0
  83. package/app/components/sidebar/sidebar-container.tsx +149 -0
  84. package/app/components/sidebar/sidebar.module.css +321 -0
  85. package/app/components/sidebar/sidebar.tsx +215 -0
  86. package/app/components/sidebar/upload/image-upload-zone.module.css +123 -0
  87. package/app/components/sidebar/upload/image-upload-zone.tsx +330 -0
  88. package/app/components/theme-provider/theme-provider.tsx +131 -0
  89. package/app/components/theme-provider/theme.ts +155 -0
  90. package/app/components/toast/toast.module.css +137 -0
  91. package/app/components/toast/toast.tsx +56 -0
  92. package/app/components/toolbar/toolbar-color-selector.module.css +171 -0
  93. package/app/components/toolbar/toolbar-color-selector.tsx +129 -0
  94. package/app/components/toolbar/toolbar.module.css +42 -0
  95. package/app/components/toolbar/toolbar.tsx +167 -0
  96. package/app/components/user/delete-account.module.css +274 -0
  97. package/app/components/user/delete-account.tsx +471 -0
  98. package/app/components/user/inactivity-warning.module.css +145 -0
  99. package/app/components/user/inactivity-warning.tsx +84 -0
  100. package/app/components/user/manage-profile.module.css +190 -0
  101. package/app/components/user/manage-profile.tsx +253 -0
  102. package/app/components/user/mfa-phone-update.tsx +739 -0
  103. package/app/config-example/admin-service.json +13 -0
  104. package/app/config-example/config.json +17 -0
  105. package/app/config-example/firebase.ts +21 -0
  106. package/app/config-example/inactivity.ts +13 -0
  107. package/app/config-example/meta-config.json +6 -0
  108. package/app/contexts/auth.context.ts +12 -0
  109. package/app/entry.client.tsx +12 -0
  110. package/app/entry.server.tsx +44 -0
  111. package/app/hooks/useInactivityTimeout.ts +110 -0
  112. package/app/root.tsx +170 -0
  113. package/app/routes/_index.tsx +16 -0
  114. package/app/routes/auth/emailActionHandler.module.css +232 -0
  115. package/app/routes/auth/emailActionHandler.tsx +405 -0
  116. package/app/routes/auth/emailVerification.tsx +120 -0
  117. package/app/routes/auth/login.module.css +523 -0
  118. package/app/routes/auth/login.tsx +654 -0
  119. package/app/routes/auth/passwordReset.module.css +274 -0
  120. package/app/routes/auth/passwordReset.tsx +154 -0
  121. package/app/routes/auth/route.ts +16 -0
  122. package/app/routes/mobile-prevented/mobilePrevented.module.css +47 -0
  123. package/app/routes/mobile-prevented/mobilePrevented.tsx +26 -0
  124. package/app/routes/mobile-prevented/route.ts +14 -0
  125. package/app/routes/striae/striae.module.css +30 -0
  126. package/app/routes/striae/striae.tsx +417 -0
  127. package/app/services/audit-export.service.ts +755 -0
  128. package/app/services/audit.service.ts +1454 -0
  129. package/app/services/firebase-errors.ts +106 -0
  130. package/app/services/firebase.ts +15 -0
  131. package/app/styles/legal-pages.module.css +113 -0
  132. package/app/styles/root.module.css +146 -0
  133. package/app/tailwind.css +225 -0
  134. package/app/types/annotations.ts +45 -0
  135. package/app/types/audit.ts +301 -0
  136. package/app/types/case.ts +90 -0
  137. package/app/types/export.ts +8 -0
  138. package/app/types/file.ts +30 -0
  139. package/app/types/import.ts +107 -0
  140. package/app/types/index.ts +24 -0
  141. package/app/types/user.ts +38 -0
  142. package/app/utils/SHA256.ts +461 -0
  143. package/app/utils/annotation-timestamp.ts +25 -0
  144. package/app/utils/audit-export-signature.ts +117 -0
  145. package/app/utils/auth-action-settings.ts +48 -0
  146. package/app/utils/auth.ts +34 -0
  147. package/app/utils/batch-operations.ts +135 -0
  148. package/app/utils/confirmation-signature.ts +193 -0
  149. package/app/utils/data-operations.ts +871 -0
  150. package/app/utils/device-detection.ts +5 -0
  151. package/app/utils/html-sanitizer.ts +80 -0
  152. package/app/utils/id-generator.ts +36 -0
  153. package/app/utils/meta.ts +48 -0
  154. package/app/utils/mfa-phone.ts +97 -0
  155. package/app/utils/mfa.ts +79 -0
  156. package/app/utils/password-policy.ts +28 -0
  157. package/app/utils/permissions.ts +562 -0
  158. package/app/utils/signature-utils.ts +160 -0
  159. package/app/utils/style.ts +83 -0
  160. package/app/utils/version.ts +5 -0
  161. package/firebase.json +11 -0
  162. package/functions/[[path]].ts +10 -0
  163. package/package.json +138 -0
  164. package/postcss.config.js +6 -0
  165. package/public/.well-known/publickey.info@striae.org.asc +17 -0
  166. package/public/.well-known/security.txt +7 -0
  167. package/public/_headers +28 -0
  168. package/public/_routes.json +13 -0
  169. package/public/assets/striae.jpg +0 -0
  170. package/public/clear.jpg +0 -0
  171. package/public/favicon.ico +0 -0
  172. package/public/favicon.svg +9 -0
  173. package/public/icon-256.png +0 -0
  174. package/public/icon-512.png +0 -0
  175. package/public/logo-dark.png +0 -0
  176. package/public/manifest.json +25 -0
  177. package/public/oin-badge.png +0 -0
  178. package/public/shortcut.png +0 -0
  179. package/public/social-image.png +0 -0
  180. package/public/striae-ascii.txt +10 -0
  181. package/scripts/deploy-all.sh +100 -0
  182. package/scripts/deploy-config.sh +940 -0
  183. package/scripts/deploy-pages.sh +34 -0
  184. package/scripts/deploy-worker-secrets.sh +215 -0
  185. package/scripts/dev.cjs +23 -0
  186. package/scripts/install-workers.sh +88 -0
  187. package/scripts/run-eslint.cjs +35 -0
  188. package/scripts/update-compatibility-dates.cjs +124 -0
  189. package/scripts/update-markdown-versions.cjs +43 -0
  190. package/tailwind.config.ts +22 -0
  191. package/tsconfig.json +33 -0
  192. package/vite.config.ts +35 -0
  193. package/worker-configuration.d.ts +7490 -0
  194. package/workers/audit-worker/package.json +17 -0
  195. package/workers/audit-worker/src/audit-worker.example.ts +195 -0
  196. package/workers/audit-worker/worker-configuration.d.ts +7448 -0
  197. package/workers/audit-worker/wrangler.jsonc.example +29 -0
  198. package/workers/data-worker/package.json +17 -0
  199. package/workers/data-worker/src/data-worker.example.ts +267 -0
  200. package/workers/data-worker/src/signature-utils.ts +79 -0
  201. package/workers/data-worker/src/signing-payload-utils.ts +290 -0
  202. package/workers/data-worker/worker-configuration.d.ts +7448 -0
  203. package/workers/data-worker/wrangler.jsonc.example +30 -0
  204. package/workers/image-worker/package.json +17 -0
  205. package/workers/image-worker/src/image-worker.example.ts +180 -0
  206. package/workers/image-worker/worker-configuration.d.ts +7447 -0
  207. package/workers/image-worker/wrangler.jsonc.example +22 -0
  208. package/workers/keys-worker/package.json +17 -0
  209. package/workers/keys-worker/src/keys.example.ts +66 -0
  210. package/workers/keys-worker/src/keys.ts +66 -0
  211. package/workers/keys-worker/worker-configuration.d.ts +7447 -0
  212. package/workers/keys-worker/wrangler.jsonc.example +22 -0
  213. package/workers/pdf-worker/package.json +17 -0
  214. package/workers/pdf-worker/src/format-striae.ts +534 -0
  215. package/workers/pdf-worker/src/pdf-worker.example.ts +119 -0
  216. package/workers/pdf-worker/src/report-types.ts +69 -0
  217. package/workers/pdf-worker/worker-configuration.d.ts +7448 -0
  218. package/workers/pdf-worker/wrangler.jsonc.example +26 -0
  219. package/workers/user-worker/package.json +17 -0
  220. package/workers/user-worker/src/user-worker.example.ts +636 -0
  221. package/workers/user-worker/worker-configuration.d.ts +7448 -0
  222. package/workers/user-worker/wrangler.jsonc.example +29 -0
  223. package/wrangler.toml.example +8 -0
@@ -0,0 +1,386 @@
1
+ .overlay {
2
+ position: fixed;
3
+ inset: 0;
4
+ background-color: color-mix(in lab, var(--background) 50%, transparent);
5
+ display: flex;
6
+ justify-content: center;
7
+ align-items: center;
8
+ z-index: var(--zIndex5);
9
+ transition: background-color var(--durationM) var(--bezierFastoutSlowin);
10
+ }
11
+
12
+ .modal {
13
+ background: var(--backgroundLight);
14
+ border-radius: var(--spaceXS);
15
+ width: 90%;
16
+ max-width: 480px;
17
+ max-height: 90vh;
18
+ box-shadow: 0 var(--spaceXS) var(--spaceL) color-mix(in lab, var(--black) 10%, transparent);
19
+ transition: background-color var(--durationM) var(--bezierFastoutSlowin);
20
+ }
21
+
22
+ .header {
23
+ display: flex;
24
+ font-size: var(--fontSizeBodyL);
25
+ justify-content: space-between;
26
+ align-items: center;
27
+ padding: var(--spaceL);
28
+ border-bottom: 1px solid color-mix(in lab, var(--text) 10%, transparent);
29
+ color: var(--textTitle);
30
+ }
31
+
32
+ .title {
33
+ margin: 0;
34
+ font-size: var(--fontSizeBodyL);
35
+ font-weight: 600;
36
+ color: var(--textTitle);
37
+ }
38
+
39
+ .closeButton {
40
+ background: none;
41
+ border: none;
42
+ font-size: var(--fontSizeH5);
43
+ cursor: pointer;
44
+ padding: var(--spaceS);
45
+ color: var(--textLight);
46
+ transition: color var(--durationS) var(--bezierFastoutSlowin);
47
+ }
48
+
49
+ .closeButton:hover {
50
+ color: var(--text);
51
+ }
52
+
53
+ .content {
54
+ padding: var(--spaceL);
55
+ overflow-y: auto;
56
+ max-height: calc(90vh - var(--space3XL));
57
+ }
58
+
59
+ .formatSelector {
60
+ display: flex;
61
+ align-items: center;
62
+ justify-content: space-between;
63
+ padding: var(--spaceM);
64
+ background: var(--backgroundLight);
65
+ border-radius: var(--spaceXS);
66
+ border: 1px solid color-mix(in lab, var(--text) 10%, transparent);
67
+ margin-top: var(--spaceM);
68
+ }
69
+
70
+ .formatLabel {
71
+ font-size: var(--fontSizeBodyS);
72
+ font-weight: var(--fontWeightMedium);
73
+ color: var(--textTitle);
74
+ margin: 0;
75
+ }
76
+
77
+ .formatToggle {
78
+ display: flex;
79
+ background: color-mix(in lab, var(--primary) 10%, transparent);
80
+ border: 1px solid color-mix(in lab, var(--primary) 20%, transparent);
81
+ border-radius: var(--spaceXS);
82
+ overflow: hidden;
83
+ box-shadow: 0 1px 3px color-mix(in lab, var(--primary) 15%, transparent);
84
+ }
85
+
86
+ .formatOption {
87
+ background: transparent;
88
+ border: none;
89
+ padding: var(--spaceS) var(--spaceM);
90
+ font-size: var(--fontSizeBodyS);
91
+ font-weight: var(--fontWeightMedium);
92
+ color: var(--primary);
93
+ cursor: pointer;
94
+ transition: all var(--durationS) var(--bezierFastoutSlowin);
95
+ position: relative;
96
+ min-width: 60px;
97
+ }
98
+
99
+ .formatOption:hover:not(:disabled) {
100
+ background: color-mix(in lab, var(--primary) 15%, transparent);
101
+ color: var(--primary);
102
+ }
103
+
104
+ .formatOption:disabled {
105
+ opacity: 0.5;
106
+ cursor: not-allowed;
107
+ }
108
+
109
+ .formatOptionActive {
110
+ background: var(--primary) !important;
111
+ color: white !important;
112
+ box-shadow: 0 1px 3px color-mix(in lab, var(--primary) 30%, transparent);
113
+ }
114
+
115
+ .formatOptionActive:hover:not(:disabled) {
116
+ background: color-mix(in lab, var(--primary) 85%, var(--black)) !important;
117
+ }
118
+
119
+ .imageOption {
120
+ display: flex;
121
+ align-items: center;
122
+ justify-content: space-between;
123
+ padding: var(--spaceM);
124
+ background: var(--backgroundLight);
125
+ border-radius: var(--spaceXS);
126
+ border: 1px solid color-mix(in lab, var(--text) 10%, transparent);
127
+ margin-top: var(--spaceM);
128
+ }
129
+
130
+ .checkboxLabel {
131
+ display: flex;
132
+ align-items: center;
133
+ gap: var(--spaceS);
134
+ cursor: pointer;
135
+ user-select: none;
136
+ }
137
+
138
+ .checkbox {
139
+ appearance: none;
140
+ width: 18px;
141
+ height: 18px;
142
+ border: 2px solid color-mix(in lab, var(--primary) 40%, transparent);
143
+ border-radius: 4px;
144
+ background: transparent;
145
+ cursor: pointer;
146
+ transition: all var(--durationS) var(--bezierFastoutSlowin);
147
+ position: relative;
148
+ flex-shrink: 0;
149
+ }
150
+
151
+ .checkbox:checked {
152
+ background: var(--primary);
153
+ border-color: var(--primary);
154
+ }
155
+
156
+ .checkbox:checked::after {
157
+ content: '';
158
+ position: absolute;
159
+ left: 3px;
160
+ top: 0px;
161
+ width: 6px;
162
+ height: 10px;
163
+ border: solid white;
164
+ border-width: 0 2px 2px 0;
165
+ transform: rotate(45deg);
166
+ }
167
+
168
+ .checkbox:hover:not(:disabled) {
169
+ border-color: var(--primary);
170
+ box-shadow: 0 0 0 2px color-mix(in lab, var(--primary) 20%, transparent);
171
+ }
172
+
173
+ .checkbox:disabled {
174
+ opacity: 0.5;
175
+ cursor: not-allowed;
176
+ }
177
+
178
+ .imageOption:has(.checkbox:disabled) {
179
+ opacity: 0.6;
180
+ }
181
+
182
+ .imageOption:has(.checkbox:disabled) .checkboxLabel {
183
+ cursor: not-allowed;
184
+ }
185
+
186
+ .checkboxText {
187
+ font-size: var(--fontSizeBodyS);
188
+ font-weight: var(--fontWeightMedium);
189
+ color: var(--textTitle);
190
+ margin: 0;
191
+ }
192
+
193
+ .checkboxTooltip {
194
+ font-size: var(--fontSizeBodyXS);
195
+ color: var(--textBody);
196
+ margin: 0;
197
+ opacity: 0.8;
198
+ }
199
+
200
+ .fieldGroup {
201
+ display: flex;
202
+ flex-direction: column;
203
+ gap: var(--spaceM);
204
+ }
205
+
206
+ .inputGroup {
207
+ display: flex;
208
+ gap: var(--spaceM);
209
+ align-items: center;
210
+ }
211
+
212
+ .input {
213
+ flex: 1;
214
+ padding: var(--spaceM);
215
+ border: 1px solid color-mix(in lab, var(--text) 10%, transparent);
216
+ border-radius: var(--spaceXS);
217
+ font-size: var(--fontSizeBodyS);
218
+ background: var(--backgroundLight);
219
+ color: var(--textBody);
220
+ transition: all var(--durationS) var(--bezierFastoutSlowin);
221
+ }
222
+
223
+ .input:focus {
224
+ outline: none;
225
+ border-color: color-mix(in lab, var(--text) 30%, transparent);
226
+ box-shadow: 0 0 0 2px color-mix(in lab, var(--text) 10%, transparent);
227
+ }
228
+
229
+ .input:disabled {
230
+ background: color-mix(in lab, var(--background) 95%, transparent);
231
+ color: var(--textLight);
232
+ cursor: not-allowed;
233
+ }
234
+
235
+ .exportButton {
236
+ background: var(--success);
237
+ color: white;
238
+ border: none;
239
+ border-radius: var(--spaceXS);
240
+ padding: var(--spaceM) var(--spaceL);
241
+ font-size: var(--fontSizeBodyS);
242
+ font-weight: var(--fontWeightMedium);
243
+ cursor: pointer;
244
+ transition: all var(--durationS) var(--bezierFastoutSlowin);
245
+ white-space: nowrap;
246
+ min-width: 140px;
247
+ box-shadow: 0 1px 3px color-mix(in lab, var(--success) 30%, transparent);
248
+ }
249
+
250
+ .exportButton:hover:not(:disabled) {
251
+ background: color-mix(in lab, var(--success) 85%, var(--black));
252
+ box-shadow: 0 2px 6px color-mix(in lab, var(--success) 40%, transparent);
253
+ }
254
+
255
+ .exportButton:disabled {
256
+ background: color-mix(in lab, var(--background) 95%, transparent);
257
+ color: var(--textLight);
258
+ cursor: not-allowed;
259
+ box-shadow: none;
260
+ }
261
+
262
+ .confirmationExportButton {
263
+ background: var(--accent);
264
+ color: white;
265
+ border: none;
266
+ border-radius: var(--spaceXS);
267
+ padding: var(--spaceM) var(--spaceL);
268
+ font-size: var(--fontSizeBodyS);
269
+ font-weight: var(--fontWeightMedium);
270
+ cursor: pointer;
271
+ transition: all var(--durationS) var(--bezierFastoutSlowin);
272
+ white-space: nowrap;
273
+ min-width: 140px;
274
+ box-shadow: 0 1px 3px color-mix(in lab, var(--accent) 30%, transparent);
275
+ }
276
+
277
+ .confirmationExportButton:hover:not(:disabled) {
278
+ background: color-mix(in lab, var(--accent) 85%, var(--black));
279
+ box-shadow: 0 2px 6px color-mix(in lab, var(--accent) 40%, transparent);
280
+ }
281
+
282
+ .confirmationExportButton:disabled {
283
+ background: color-mix(in lab, var(--background) 95%, transparent);
284
+ color: var(--textLight);
285
+ cursor: not-allowed;
286
+ box-shadow: none;
287
+ }
288
+
289
+ .divider {
290
+ margin: var(--spaceL) 0;
291
+ text-align: center;
292
+ position: relative;
293
+ color: var(--textLight);
294
+ font-size: var(--fontSizeBodyS);
295
+ font-weight: var(--fontWeightMedium);
296
+ }
297
+
298
+ .divider::before {
299
+ content: '';
300
+ position: absolute;
301
+ top: 50%;
302
+ left: 0;
303
+ right: 0;
304
+ height: 1px;
305
+ background: color-mix(in lab, var(--text) 10%, transparent);
306
+ z-index: 1;
307
+ }
308
+
309
+ .divider span {
310
+ background: var(--backgroundLight);
311
+ padding: 0 var(--spaceM);
312
+ position: relative;
313
+ z-index: 2;
314
+ }
315
+
316
+ .exportAllSection {
317
+ text-align: center;
318
+ margin-bottom: var(--spaceM);
319
+ }
320
+
321
+ .exportAllButton {
322
+ background: var(--primary);
323
+ color: white;
324
+ border: none;
325
+ border-radius: var(--spaceXS);
326
+ padding: var(--spaceM) var(--spaceL);
327
+ font-size: var(--fontSizeBodyS);
328
+ font-weight: var(--fontWeightMedium);
329
+ cursor: pointer;
330
+ transition: all var(--durationS) var(--bezierFastoutSlowin);
331
+ width: 100%;
332
+ box-shadow: 0 1px 3px color-mix(in lab, var(--primary) 30%, transparent);
333
+ }
334
+
335
+ .exportAllButton:hover:not(:disabled) {
336
+ background: color-mix(in lab, var(--primary) 85%, var(--black));
337
+ box-shadow: 0 2px 6px color-mix(in lab, var(--primary) 40%, transparent);
338
+ }
339
+
340
+ .exportAllButton:disabled {
341
+ background: color-mix(in lab, var(--background) 95%, transparent);
342
+ color: var(--textLight);
343
+ cursor: not-allowed;
344
+ box-shadow: none;
345
+ }
346
+
347
+ .progressSection {
348
+ margin: var(--spaceM) 0;
349
+ padding: var(--spaceM);
350
+ background: var(--backgroundLight);
351
+ border-radius: var(--spaceXS);
352
+ border: 1px solid color-mix(in lab, var(--text) 10%, transparent);
353
+ }
354
+
355
+ .progressText {
356
+ font-size: var(--fontSizeBodyS);
357
+ color: var(--textBody);
358
+ margin-bottom: var(--spaceS);
359
+ font-weight: var(--fontWeightMedium);
360
+ }
361
+
362
+ .progressBar {
363
+ width: 100%;
364
+ height: 8px;
365
+ background: color-mix(in lab, var(--text) 10%, transparent);
366
+ border-radius: var(--spaceXS);
367
+ overflow: hidden;
368
+ }
369
+
370
+ .progressFill {
371
+ height: 100%;
372
+ background: color-mix(in lab, var(--text) 60%, transparent);
373
+ border-radius: var(--spaceXS);
374
+ transition: width var(--durationS) var(--bezierFastoutSlowin);
375
+ }
376
+
377
+ .error {
378
+ margin-top: var(--spaceM);
379
+ padding: var(--spaceM);
380
+ background: color-mix(in lab, var(--error) 10%, transparent);
381
+ border: 1px solid color-mix(in lab, var(--error) 20%, transparent);
382
+ border-radius: var(--spaceXS);
383
+ color: var(--error);
384
+ font-size: var(--fontSizeBodyS);
385
+ font-weight: var(--fontWeightMedium);
386
+ }
@@ -0,0 +1,317 @@
1
+ import { useState, useEffect, useContext } from 'react';
2
+ import styles from './case-export.module.css';
3
+ import { AuthContext } from '~/contexts/auth.context';
4
+ import { getCaseConfirmations, exportConfirmationData } from '../../actions/confirm-export';
5
+
6
+ export type ExportFormat = 'json' | 'csv';
7
+
8
+ interface CaseExportProps {
9
+ isOpen: boolean;
10
+ onClose: () => void;
11
+ onExport: (caseNumber: string, format: ExportFormat, includeImages?: boolean) => void;
12
+ onExportAll: (onProgress: (current: number, total: number, caseName: string) => void, format: ExportFormat) => void;
13
+ currentCaseNumber?: string;
14
+ isReadOnly?: boolean;
15
+ }
16
+
17
+ export const CaseExport = ({
18
+ isOpen,
19
+ onClose,
20
+ onExport,
21
+ onExportAll,
22
+ currentCaseNumber = '',
23
+ isReadOnly = false
24
+ }: CaseExportProps) => {
25
+ const { user } = useContext(AuthContext);
26
+ const [caseNumber, setCaseNumber] = useState(currentCaseNumber);
27
+ const [isExporting, setIsExporting] = useState(false);
28
+ const [isExportingAll, setIsExportingAll] = useState(false);
29
+ const [isExportingConfirmations, setIsExportingConfirmations] = useState(false);
30
+ const [error, setError] = useState<string>('');
31
+ const [exportProgress, setExportProgress] = useState<{ current: number; total: number; caseName: string } | null>(null);
32
+ const [selectedFormat, setSelectedFormat] = useState<ExportFormat>('json');
33
+ const [includeImages, setIncludeImages] = useState(false);
34
+ const [hasConfirmationData, setHasConfirmationData] = useState(false);
35
+
36
+ // Update caseNumber when currentCaseNumber prop changes
37
+ useEffect(() => {
38
+ setCaseNumber(currentCaseNumber);
39
+ }, [currentCaseNumber]);
40
+
41
+ // Disable images option when exporting all cases or when no case number is entered
42
+ useEffect(() => {
43
+ if ((isExportingAll || !caseNumber.trim()) && includeImages) {
44
+ setIncludeImages(false);
45
+ }
46
+ }, [isExportingAll, caseNumber, includeImages]);
47
+
48
+ // Check for confirmation data when case changes (for read-only cases)
49
+ useEffect(() => {
50
+ const checkConfirmationData = async () => {
51
+ if (isReadOnly && user && caseNumber.trim()) {
52
+ try {
53
+ const confirmations = await getCaseConfirmations(user, caseNumber.trim());
54
+ const hasData = !!confirmations && Object.keys(confirmations).length > 0;
55
+ setHasConfirmationData(hasData);
56
+ } catch (error) {
57
+ console.error('Failed to check confirmation data:', error);
58
+ setHasConfirmationData(false);
59
+ }
60
+ } else {
61
+ setHasConfirmationData(false);
62
+ }
63
+ };
64
+
65
+ checkConfirmationData();
66
+ }, [isReadOnly, user?.uid, caseNumber]);
67
+
68
+ // Additional useEffect to check when modal opens
69
+ useEffect(() => {
70
+ if (isOpen && isReadOnly && user && caseNumber.trim()) {
71
+ const checkOnOpen = async () => {
72
+ try {
73
+ const confirmations = await getCaseConfirmations(user, caseNumber.trim());
74
+ const hasData = !!confirmations && Object.keys(confirmations).length > 0;
75
+ setHasConfirmationData(hasData);
76
+ } catch (error) {
77
+ console.error('Modal open confirmation check failed:', error);
78
+ setHasConfirmationData(false);
79
+ }
80
+ };
81
+ checkOnOpen();
82
+ }
83
+ }, [isOpen, isReadOnly, user?.uid, caseNumber]);
84
+
85
+ // Force JSON format and disable images for read-only cases
86
+ useEffect(() => {
87
+ if (isReadOnly) {
88
+ setSelectedFormat('json');
89
+ setIncludeImages(false);
90
+ }
91
+ }, [isReadOnly]);
92
+
93
+ // Handle Escape key to close modal
94
+ useEffect(() => {
95
+ const handleEscapeKey = (event: KeyboardEvent) => {
96
+ if (event.key === 'Escape' && isOpen) {
97
+ onClose();
98
+ }
99
+ };
100
+
101
+ if (isOpen) {
102
+ document.addEventListener('keydown', handleEscapeKey);
103
+ }
104
+
105
+ return () => {
106
+ document.removeEventListener('keydown', handleEscapeKey);
107
+ };
108
+ }, [isOpen, onClose]);
109
+
110
+ if (!isOpen) return null;
111
+
112
+ const handleExport = async () => {
113
+ if (!caseNumber.trim()) {
114
+ setError('Please enter a case number');
115
+ return;
116
+ }
117
+
118
+ setIsExporting(true);
119
+ setError('');
120
+ setExportProgress(null);
121
+
122
+ try {
123
+ await onExport(caseNumber.trim(), selectedFormat, includeImages);
124
+ onClose();
125
+ } catch (error) {
126
+ console.error('Export failed:', error);
127
+ setError(error instanceof Error ? error.message : 'Export failed. Please try again.');
128
+ } finally {
129
+ setIsExporting(false);
130
+ }
131
+ };
132
+
133
+ const handleExportAll = async () => {
134
+ setIsExportingAll(true);
135
+ setError('');
136
+ setExportProgress(null); // Don't show progress until we have real data
137
+
138
+ try {
139
+ await onExportAll((current: number, total: number, caseName: string) => {
140
+ setExportProgress({ current, total, caseName });
141
+ }, selectedFormat);
142
+ onClose();
143
+ } catch (error) {
144
+ console.error('Export all failed:', error);
145
+ setError(error instanceof Error ? error.message : 'Export all cases failed. Please try again.');
146
+ } finally {
147
+ setIsExportingAll(false);
148
+ setExportProgress(null);
149
+ }
150
+ };
151
+
152
+ const handleExportConfirmations = async () => {
153
+ if (!caseNumber.trim() || !user) {
154
+ setError('Unable to export confirmation data');
155
+ return;
156
+ }
157
+
158
+ setIsExportingConfirmations(true);
159
+ setError('');
160
+
161
+ try {
162
+ await exportConfirmationData(user, caseNumber.trim());
163
+ onClose();
164
+ } catch (error) {
165
+ console.error('Confirmation export failed:', error);
166
+ setError(error instanceof Error ? error.message : 'Confirmation export failed. Please try again.');
167
+ } finally {
168
+ setIsExportingConfirmations(false);
169
+ }
170
+ };
171
+
172
+ const handleOverlayClick = (e: React.MouseEvent) => {
173
+ if (e.target === e.currentTarget) {
174
+ onClose();
175
+ }
176
+ };
177
+
178
+ return (
179
+ <div className={styles.overlay} onClick={handleOverlayClick}>
180
+ <div className={styles.modal}>
181
+ <div className={styles.header}>
182
+ <h2 className={styles.title}>Export Case Data</h2>
183
+ <button
184
+ className={styles.closeButton}
185
+ onClick={onClose}
186
+ aria-label="Close modal"
187
+ >
188
+ ×
189
+ </button>
190
+ </div>
191
+
192
+ <div className={styles.content}>
193
+ <div className={styles.fieldGroup}>
194
+ {/* 1. Case number input */}
195
+ <div className={styles.inputGroup}>
196
+ <input
197
+ id="caseNumber"
198
+ type="text"
199
+ className={styles.input}
200
+ value={caseNumber}
201
+ onChange={(e) => {
202
+ setCaseNumber(e.target.value);
203
+ if (error) setError('');
204
+ }}
205
+ placeholder="Enter case number"
206
+ disabled={isExporting || isExportingAll || isReadOnly}
207
+ />
208
+ </div>
209
+
210
+ {/* 2. Format choice - disabled for read-only cases */}
211
+ <div className={styles.formatSelector}>
212
+ <span className={styles.formatLabel}>Data Format:</span>
213
+ <div className={styles.formatToggle}>
214
+ <button
215
+ type="button"
216
+ className={`${styles.formatOption} ${selectedFormat === 'json' ? styles.formatOptionActive : ''}`}
217
+ onClick={() => setSelectedFormat('json')}
218
+ disabled={isExporting || isExportingAll || isReadOnly}
219
+ title="JSON for case imports"
220
+ >
221
+ JSON
222
+ </button>
223
+ <button
224
+ type="button"
225
+ className={`${styles.formatOption} ${selectedFormat === 'csv' ? styles.formatOptionActive : ''}`}
226
+ onClick={() => setSelectedFormat('csv')}
227
+ disabled={isExporting || isExportingAll || isReadOnly}
228
+ title="CSV for single case, Excel (.xlsx) with multiple worksheets for all cases"
229
+ >
230
+ CSV/Excel
231
+ </button>
232
+ </div>
233
+ </div>
234
+
235
+ {/* 3. Image inclusion option - disabled for read-only cases */}
236
+ <div className={styles.imageOption}>
237
+ <label className={styles.checkboxLabel}>
238
+ <input
239
+ type="checkbox"
240
+ className={styles.checkbox}
241
+ checked={includeImages}
242
+ onChange={(e) => setIncludeImages(e.target.checked)}
243
+ disabled={!caseNumber.trim() || isExporting || isExportingAll || isReadOnly}
244
+ />
245
+ <div className={styles.checkboxText}>
246
+ <span>Include Images (ZIP)</span>
247
+ <p className={styles.checkboxTooltip}>
248
+ Available for single case exports only. Downloads a ZIP file containing data and all associated image files. Case imports support only JSON data format.
249
+ </p>
250
+ </div>
251
+ </label>
252
+ </div>
253
+
254
+ {/* 4. Export buttons (case OR all cases) */}
255
+ <div className={styles.inputGroup}>
256
+ <button
257
+ className={isReadOnly ? styles.confirmationExportButton : styles.exportButton}
258
+ onClick={isReadOnly ? handleExportConfirmations : handleExport}
259
+ disabled={!caseNumber.trim() || isExporting || isExportingAll || isExportingConfirmations || (isReadOnly && !hasConfirmationData)}
260
+ >
261
+ {isExporting || isExportingConfirmations ? 'Exporting...' :
262
+ isReadOnly ? 'Export Confirmation Data' : 'Export Case Data'}
263
+ </button>
264
+ </div>
265
+
266
+ {/* Hide "Export All Cases" for read-only cases */}
267
+ {!isReadOnly && (
268
+ <>
269
+ <div className={styles.divider}>
270
+ <span>OR</span>
271
+ </div>
272
+
273
+ <div className={styles.exportAllSection}>
274
+ <button
275
+ className={styles.exportAllButton}
276
+ onClick={handleExportAll}
277
+ disabled={isExporting || isExportingAll}
278
+ >
279
+ {isExportingAll ? 'Exporting All Cases...' : 'Export All Cases'}
280
+ </button>
281
+ </div>
282
+ </>
283
+ )}
284
+
285
+ {exportProgress && exportProgress.total > 0 && (
286
+ <div className={styles.progressSection}>
287
+ <div className={styles.progressText}>
288
+ Exporting case {exportProgress.current} of {exportProgress.total}: {exportProgress.caseName}
289
+ </div>
290
+ <div className={styles.progressBar}>
291
+ <div
292
+ className={styles.progressFill}
293
+ style={{ width: `${(exportProgress.current / exportProgress.total) * 100}%` }}
294
+ />
295
+ </div>
296
+ </div>
297
+ )}
298
+
299
+ {isExportingAll && !exportProgress && (
300
+ <div className={styles.progressSection}>
301
+ <div className={styles.progressText}>
302
+ Preparing export...
303
+ </div>
304
+ </div>
305
+ )}
306
+
307
+ {error && (
308
+ <div className={styles.error}>
309
+ {error}
310
+ </div>
311
+ )}
312
+ </div>
313
+ </div>
314
+ </div>
315
+ </div>
316
+ );
317
+ };