@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.
- package/.env.example +100 -0
- package/LICENSE +190 -0
- package/NOTICE +18 -0
- package/README.md +133 -0
- package/app/components/actions/case-export/core-export.ts +328 -0
- package/app/components/actions/case-export/data-processing.ts +167 -0
- package/app/components/actions/case-export/download-handlers.ts +900 -0
- package/app/components/actions/case-export/index.ts +41 -0
- package/app/components/actions/case-export/metadata-helpers.ts +107 -0
- package/app/components/actions/case-export/types-constants.ts +56 -0
- package/app/components/actions/case-export/validation-utils.ts +25 -0
- package/app/components/actions/case-export.ts +4 -0
- package/app/components/actions/case-import/annotation-import.ts +35 -0
- package/app/components/actions/case-import/confirmation-import.ts +363 -0
- package/app/components/actions/case-import/image-operations.ts +61 -0
- package/app/components/actions/case-import/index.ts +39 -0
- package/app/components/actions/case-import/orchestrator.ts +420 -0
- package/app/components/actions/case-import/storage-operations.ts +270 -0
- package/app/components/actions/case-import/validation.ts +189 -0
- package/app/components/actions/case-import/zip-processing.ts +413 -0
- package/app/components/actions/case-manage.ts +524 -0
- package/app/components/actions/case-review.ts +4 -0
- package/app/components/actions/confirm-export.ts +351 -0
- package/app/components/actions/generate-pdf.ts +210 -0
- package/app/components/actions/image-manage.ts +385 -0
- package/app/components/actions/notes-manage.ts +33 -0
- package/app/components/actions/signout.module.css +15 -0
- package/app/components/actions/signout.tsx +50 -0
- package/app/components/audit/user-audit-viewer.tsx +975 -0
- package/app/components/audit/user-audit.module.css +568 -0
- package/app/components/auth/auth-provider.tsx +78 -0
- package/app/components/auth/mfa-enrollment.module.css +268 -0
- package/app/components/auth/mfa-enrollment.tsx +398 -0
- package/app/components/auth/mfa-verification.module.css +251 -0
- package/app/components/auth/mfa-verification.tsx +295 -0
- package/app/components/button/button.module.css +63 -0
- package/app/components/button/button.tsx +46 -0
- package/app/components/canvas/box-annotations/box-annotations.module.css +170 -0
- package/app/components/canvas/box-annotations/box-annotations.tsx +634 -0
- package/app/components/canvas/canvas.module.css +314 -0
- package/app/components/canvas/canvas.tsx +449 -0
- package/app/components/canvas/confirmation/confirmation.module.css +187 -0
- package/app/components/canvas/confirmation/confirmation.tsx +214 -0
- package/app/components/colors/colors.module.css +59 -0
- package/app/components/colors/colors.tsx +68 -0
- package/app/components/form/base-form.tsx +21 -0
- package/app/components/form/form-button.tsx +28 -0
- package/app/components/form/form-field.tsx +53 -0
- package/app/components/form/form-message.tsx +17 -0
- package/app/components/form/form-toggle.tsx +23 -0
- package/app/components/form/form.module.css +427 -0
- package/app/components/form/index.ts +6 -0
- package/app/components/icon/icon.module.css +3 -0
- package/app/components/icon/icon.tsx +27 -0
- package/app/components/icon/icons.svg +102 -0
- package/app/components/icon/manifest.json +110 -0
- package/app/components/sidebar/case-export/case-export.module.css +386 -0
- package/app/components/sidebar/case-export/case-export.tsx +317 -0
- package/app/components/sidebar/case-import/case-import.module.css +626 -0
- package/app/components/sidebar/case-import/case-import.tsx +404 -0
- package/app/components/sidebar/case-import/components/CasePreviewSection.tsx +72 -0
- package/app/components/sidebar/case-import/components/ConfirmationDialog.tsx +72 -0
- package/app/components/sidebar/case-import/components/ConfirmationPreviewSection.tsx +71 -0
- package/app/components/sidebar/case-import/components/ExistingCaseSection.tsx +40 -0
- package/app/components/sidebar/case-import/components/FileSelector.tsx +161 -0
- package/app/components/sidebar/case-import/components/ProgressSection.tsx +46 -0
- package/app/components/sidebar/case-import/hooks/useFilePreview.ts +101 -0
- package/app/components/sidebar/case-import/hooks/useImportExecution.ts +152 -0
- package/app/components/sidebar/case-import/hooks/useImportState.ts +88 -0
- package/app/components/sidebar/case-import/index.ts +18 -0
- package/app/components/sidebar/case-import/utils/file-validation.ts +43 -0
- package/app/components/sidebar/cases/case-sidebar.tsx +827 -0
- package/app/components/sidebar/cases/cases-modal.module.css +166 -0
- package/app/components/sidebar/cases/cases-modal.tsx +201 -0
- package/app/components/sidebar/cases/cases.module.css +713 -0
- package/app/components/sidebar/files/files-modal.module.css +209 -0
- package/app/components/sidebar/files/files-modal.tsx +239 -0
- package/app/components/sidebar/hash/hash-utility.module.css +366 -0
- package/app/components/sidebar/hash/hash-utility.tsx +982 -0
- package/app/components/sidebar/notes/notes-modal.tsx +51 -0
- package/app/components/sidebar/notes/notes-sidebar.tsx +491 -0
- package/app/components/sidebar/notes/notes.module.css +360 -0
- package/app/components/sidebar/sidebar-container.tsx +149 -0
- package/app/components/sidebar/sidebar.module.css +321 -0
- package/app/components/sidebar/sidebar.tsx +215 -0
- package/app/components/sidebar/upload/image-upload-zone.module.css +123 -0
- package/app/components/sidebar/upload/image-upload-zone.tsx +330 -0
- package/app/components/theme-provider/theme-provider.tsx +131 -0
- package/app/components/theme-provider/theme.ts +155 -0
- package/app/components/toast/toast.module.css +137 -0
- package/app/components/toast/toast.tsx +56 -0
- package/app/components/toolbar/toolbar-color-selector.module.css +171 -0
- package/app/components/toolbar/toolbar-color-selector.tsx +129 -0
- package/app/components/toolbar/toolbar.module.css +42 -0
- package/app/components/toolbar/toolbar.tsx +167 -0
- package/app/components/user/delete-account.module.css +274 -0
- package/app/components/user/delete-account.tsx +471 -0
- package/app/components/user/inactivity-warning.module.css +145 -0
- package/app/components/user/inactivity-warning.tsx +84 -0
- package/app/components/user/manage-profile.module.css +190 -0
- package/app/components/user/manage-profile.tsx +253 -0
- package/app/components/user/mfa-phone-update.tsx +739 -0
- package/app/config-example/admin-service.json +13 -0
- package/app/config-example/config.json +17 -0
- package/app/config-example/firebase.ts +21 -0
- package/app/config-example/inactivity.ts +13 -0
- package/app/config-example/meta-config.json +6 -0
- package/app/contexts/auth.context.ts +12 -0
- package/app/entry.client.tsx +12 -0
- package/app/entry.server.tsx +44 -0
- package/app/hooks/useInactivityTimeout.ts +110 -0
- package/app/root.tsx +170 -0
- package/app/routes/_index.tsx +16 -0
- package/app/routes/auth/emailActionHandler.module.css +232 -0
- package/app/routes/auth/emailActionHandler.tsx +405 -0
- package/app/routes/auth/emailVerification.tsx +120 -0
- package/app/routes/auth/login.module.css +523 -0
- package/app/routes/auth/login.tsx +654 -0
- package/app/routes/auth/passwordReset.module.css +274 -0
- package/app/routes/auth/passwordReset.tsx +154 -0
- package/app/routes/auth/route.ts +16 -0
- package/app/routes/mobile-prevented/mobilePrevented.module.css +47 -0
- package/app/routes/mobile-prevented/mobilePrevented.tsx +26 -0
- package/app/routes/mobile-prevented/route.ts +14 -0
- package/app/routes/striae/striae.module.css +30 -0
- package/app/routes/striae/striae.tsx +417 -0
- package/app/services/audit-export.service.ts +755 -0
- package/app/services/audit.service.ts +1454 -0
- package/app/services/firebase-errors.ts +106 -0
- package/app/services/firebase.ts +15 -0
- package/app/styles/legal-pages.module.css +113 -0
- package/app/styles/root.module.css +146 -0
- package/app/tailwind.css +225 -0
- package/app/types/annotations.ts +45 -0
- package/app/types/audit.ts +301 -0
- package/app/types/case.ts +90 -0
- package/app/types/export.ts +8 -0
- package/app/types/file.ts +30 -0
- package/app/types/import.ts +107 -0
- package/app/types/index.ts +24 -0
- package/app/types/user.ts +38 -0
- package/app/utils/SHA256.ts +461 -0
- package/app/utils/annotation-timestamp.ts +25 -0
- package/app/utils/audit-export-signature.ts +117 -0
- package/app/utils/auth-action-settings.ts +48 -0
- package/app/utils/auth.ts +34 -0
- package/app/utils/batch-operations.ts +135 -0
- package/app/utils/confirmation-signature.ts +193 -0
- package/app/utils/data-operations.ts +871 -0
- package/app/utils/device-detection.ts +5 -0
- package/app/utils/html-sanitizer.ts +80 -0
- package/app/utils/id-generator.ts +36 -0
- package/app/utils/meta.ts +48 -0
- package/app/utils/mfa-phone.ts +97 -0
- package/app/utils/mfa.ts +79 -0
- package/app/utils/password-policy.ts +28 -0
- package/app/utils/permissions.ts +562 -0
- package/app/utils/signature-utils.ts +160 -0
- package/app/utils/style.ts +83 -0
- package/app/utils/version.ts +5 -0
- package/firebase.json +11 -0
- package/functions/[[path]].ts +10 -0
- package/package.json +138 -0
- package/postcss.config.js +6 -0
- package/public/.well-known/publickey.info@striae.org.asc +17 -0
- package/public/.well-known/security.txt +7 -0
- package/public/_headers +28 -0
- package/public/_routes.json +13 -0
- package/public/assets/striae.jpg +0 -0
- package/public/clear.jpg +0 -0
- package/public/favicon.ico +0 -0
- package/public/favicon.svg +9 -0
- package/public/icon-256.png +0 -0
- package/public/icon-512.png +0 -0
- package/public/logo-dark.png +0 -0
- package/public/manifest.json +25 -0
- package/public/oin-badge.png +0 -0
- package/public/shortcut.png +0 -0
- package/public/social-image.png +0 -0
- package/public/striae-ascii.txt +10 -0
- package/scripts/deploy-all.sh +100 -0
- package/scripts/deploy-config.sh +940 -0
- package/scripts/deploy-pages.sh +34 -0
- package/scripts/deploy-worker-secrets.sh +215 -0
- package/scripts/dev.cjs +23 -0
- package/scripts/install-workers.sh +88 -0
- package/scripts/run-eslint.cjs +35 -0
- package/scripts/update-compatibility-dates.cjs +124 -0
- package/scripts/update-markdown-versions.cjs +43 -0
- package/tailwind.config.ts +22 -0
- package/tsconfig.json +33 -0
- package/vite.config.ts +35 -0
- package/worker-configuration.d.ts +7490 -0
- package/workers/audit-worker/package.json +17 -0
- package/workers/audit-worker/src/audit-worker.example.ts +195 -0
- package/workers/audit-worker/worker-configuration.d.ts +7448 -0
- package/workers/audit-worker/wrangler.jsonc.example +29 -0
- package/workers/data-worker/package.json +17 -0
- package/workers/data-worker/src/data-worker.example.ts +267 -0
- package/workers/data-worker/src/signature-utils.ts +79 -0
- package/workers/data-worker/src/signing-payload-utils.ts +290 -0
- package/workers/data-worker/worker-configuration.d.ts +7448 -0
- package/workers/data-worker/wrangler.jsonc.example +30 -0
- package/workers/image-worker/package.json +17 -0
- package/workers/image-worker/src/image-worker.example.ts +180 -0
- package/workers/image-worker/worker-configuration.d.ts +7447 -0
- package/workers/image-worker/wrangler.jsonc.example +22 -0
- package/workers/keys-worker/package.json +17 -0
- package/workers/keys-worker/src/keys.example.ts +66 -0
- package/workers/keys-worker/src/keys.ts +66 -0
- package/workers/keys-worker/worker-configuration.d.ts +7447 -0
- package/workers/keys-worker/wrangler.jsonc.example +22 -0
- package/workers/pdf-worker/package.json +17 -0
- package/workers/pdf-worker/src/format-striae.ts +534 -0
- package/workers/pdf-worker/src/pdf-worker.example.ts +119 -0
- package/workers/pdf-worker/src/report-types.ts +69 -0
- package/workers/pdf-worker/worker-configuration.d.ts +7448 -0
- package/workers/pdf-worker/wrangler.jsonc.example +26 -0
- package/workers/user-worker/package.json +17 -0
- package/workers/user-worker/src/user-worker.example.ts +636 -0
- package/workers/user-worker/worker-configuration.d.ts +7448 -0
- package/workers/user-worker/wrangler.jsonc.example +29 -0
- package/wrangler.toml.example +8 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/* Modal Overlay & Container */
|
|
2
|
+
.modalOverlay {
|
|
3
|
+
position: fixed;
|
|
4
|
+
inset: 0;
|
|
5
|
+
background-color: color-mix(in lab, var(--background) 50%, transparent);
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
align-items: center;
|
|
9
|
+
z-index: var(--zIndex5);
|
|
10
|
+
transition: background-color var(--durationM) var(--bezierFastoutSlowin);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.modal {
|
|
14
|
+
background: var(--backgroundLight);
|
|
15
|
+
border-radius: var(--spaceXS);
|
|
16
|
+
width: 90%;
|
|
17
|
+
max-width: 500px;
|
|
18
|
+
max-height: min(90vh, 90vw);
|
|
19
|
+
box-shadow: 0 var(--spaceXS) var(--spaceL)
|
|
20
|
+
color-mix(in lab, var(--black) 10%, transparent);
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
transition: background-color var(--durationM) var(--bezierFastoutSlowin);
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* Modal Header */
|
|
28
|
+
.modalHeader {
|
|
29
|
+
display: flex;
|
|
30
|
+
justify-content: space-between;
|
|
31
|
+
align-items: center;
|
|
32
|
+
padding: var(--spaceL);
|
|
33
|
+
font-size: var(--fontSizeBodyL);
|
|
34
|
+
border-bottom: 1px solid color-mix(in lab, var(--text) 10%, transparent);
|
|
35
|
+
color: var(--textTitle);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.modalHeader h1 {
|
|
39
|
+
font-size: var(--fontSizeBodyM);
|
|
40
|
+
margin: 0;
|
|
41
|
+
font-weight: var(--fontWeightMedium);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* Close Button */
|
|
45
|
+
.closeButton {
|
|
46
|
+
background: none;
|
|
47
|
+
border: none;
|
|
48
|
+
font-size: var(--fontSizeH5);
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
padding: var(--spaceS);
|
|
51
|
+
color: var(--textLight);
|
|
52
|
+
transition: color var(--durationS) var(--bezierFastoutSlowin);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.closeButton:hover {
|
|
56
|
+
color: var(--text);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Form & Form Groups */
|
|
60
|
+
.form {
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-direction: column;
|
|
63
|
+
flex: 1 1 auto;
|
|
64
|
+
min-height: 0;
|
|
65
|
+
gap: var(--spaceL);
|
|
66
|
+
width: 100%;
|
|
67
|
+
max-width: 100%;
|
|
68
|
+
padding: var(--spaceL);
|
|
69
|
+
margin: 0 auto;
|
|
70
|
+
box-sizing: border-box;
|
|
71
|
+
overflow-y: auto;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.formGroup {
|
|
75
|
+
margin-bottom: var(--spaceXS);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.formGroup label {
|
|
79
|
+
display: block;
|
|
80
|
+
margin-bottom: var(--spaceS);
|
|
81
|
+
color: var(--textBody);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* Readonly Input Styling (for company/email fields) */
|
|
85
|
+
.input {
|
|
86
|
+
width: 100%;
|
|
87
|
+
padding: var(--spaceM);
|
|
88
|
+
border: 1.5px solid color-mix(in lab, var(--text) 20%, transparent);
|
|
89
|
+
border-radius: var(--spaceXS);
|
|
90
|
+
font-size: var(--fontSizeBodyS);
|
|
91
|
+
background: var(--backgroundLight);
|
|
92
|
+
color: var(--textBody);
|
|
93
|
+
box-sizing: border-box;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.input:disabled {
|
|
97
|
+
background-color: color-mix(in lab, var(--background) 95%, transparent);
|
|
98
|
+
cursor: not-allowed;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* Helper Text */
|
|
102
|
+
.helpText {
|
|
103
|
+
font-size: var(--fontSizeBodyXS);
|
|
104
|
+
color: var(--textLight);
|
|
105
|
+
margin-top: var(--spaceXS);
|
|
106
|
+
line-height: 1.4;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* Button Group */
|
|
110
|
+
.buttonGroup {
|
|
111
|
+
display: flex;
|
|
112
|
+
gap: var(--spaceS);
|
|
113
|
+
margin-top: var(--spaceL);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.mfaVerificationSection {
|
|
117
|
+
margin-top: var(--spaceM);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.mfaReauthSection {
|
|
121
|
+
margin-top: var(--spaceM);
|
|
122
|
+
display: flex;
|
|
123
|
+
flex-direction: column;
|
|
124
|
+
gap: var(--spaceS);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.mfaReauthSection label {
|
|
128
|
+
color: var(--textBody);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.mfaButtonGroup {
|
|
132
|
+
display: flex;
|
|
133
|
+
gap: var(--spaceS);
|
|
134
|
+
flex-wrap: wrap;
|
|
135
|
+
margin-top: var(--spaceS);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.resendTimer {
|
|
139
|
+
margin: 0;
|
|
140
|
+
font-size: var(--fontSizeBodyXS);
|
|
141
|
+
color: var(--textLight);
|
|
142
|
+
display: inline-flex;
|
|
143
|
+
align-items: center;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.recaptchaContainer {
|
|
147
|
+
height: 0;
|
|
148
|
+
overflow: hidden;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* Delete Button (error variant) */
|
|
152
|
+
.deleteButton {
|
|
153
|
+
background-color: var(--error);
|
|
154
|
+
color: var(--white);
|
|
155
|
+
border: none;
|
|
156
|
+
padding: var(--spaceM) var(--spaceL);
|
|
157
|
+
border-radius: var(--spaceXS);
|
|
158
|
+
font-weight: var(--fontWeightMedium);
|
|
159
|
+
cursor: pointer;
|
|
160
|
+
transition: all var(--durationS) var(--bezierFastoutSlowin);
|
|
161
|
+
margin-top: var(--spaceXL);
|
|
162
|
+
width: 100%;
|
|
163
|
+
font-size: var(--fontSizeBodyS);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.deleteButton:hover:not(:disabled) {
|
|
167
|
+
background-color: color-mix(in lab, var(--error) 85%, var(--black));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.deleteButton:focus {
|
|
171
|
+
outline: 2px solid var(--error);
|
|
172
|
+
outline-offset: 2px;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.deleteNotice {
|
|
176
|
+
margin-top: var(--spaceXL);
|
|
177
|
+
font-size: var(--fontSizeBodyXS);
|
|
178
|
+
text-align: center;
|
|
179
|
+
color: var(--textLight);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.deleteLink {
|
|
183
|
+
color: var(--error);
|
|
184
|
+
text-decoration: underline;
|
|
185
|
+
transition: color var(--durationS) var(--bezierFastoutSlowin);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.deleteLink:hover {
|
|
189
|
+
color: color-mix(in lab, var(--error) 85%, var(--black));
|
|
190
|
+
}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { useState, useContext, useEffect, useCallback } from 'react';
|
|
2
|
+
import { updateProfile } from 'firebase/auth';
|
|
3
|
+
import { PasswordReset } from '~/routes/auth/passwordReset';
|
|
4
|
+
import { DeleteAccount } from './delete-account';
|
|
5
|
+
import { UserAuditViewer } from '../audit/user-audit-viewer';
|
|
6
|
+
import { AuthContext } from '~/contexts/auth.context';
|
|
7
|
+
import { getUserData, updateUserData } from '~/utils/permissions';
|
|
8
|
+
import { auditService } from '~/services/audit.service';
|
|
9
|
+
import { handleAuthError, ERROR_MESSAGES } from '~/services/firebase-errors';
|
|
10
|
+
import { FormField, FormButton, FormMessage } from '../form';
|
|
11
|
+
import { MfaPhoneUpdateSection } from './mfa-phone-update';
|
|
12
|
+
import styles from './manage-profile.module.css';
|
|
13
|
+
|
|
14
|
+
interface ManageProfileProps {
|
|
15
|
+
isOpen: boolean;
|
|
16
|
+
onClose: () => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const ManageProfile = ({ isOpen, onClose }: ManageProfileProps) => {
|
|
20
|
+
const { user } = useContext(AuthContext);
|
|
21
|
+
const [displayName, setDisplayName] = useState(user?.displayName || '');
|
|
22
|
+
const [company, setCompany] = useState('');
|
|
23
|
+
const [email, setEmail] = useState('');
|
|
24
|
+
const [permitted, setPermitted] = useState(false); // Default to false for safety - updated after data loads.
|
|
25
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
26
|
+
const [isMfaBusy, setIsMfaBusy] = useState(false);
|
|
27
|
+
const [error, setError] = useState('');
|
|
28
|
+
const [success, setSuccess] = useState('');
|
|
29
|
+
const [showResetForm, setShowResetForm] = useState(false);
|
|
30
|
+
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
|
31
|
+
const [showAuditViewer, setShowAuditViewer] = useState(false);
|
|
32
|
+
const isCloseBlocked = isMfaBusy || isLoading;
|
|
33
|
+
|
|
34
|
+
const handleMfaBusyChange = useCallback((isBusy: boolean) => {
|
|
35
|
+
setIsMfaBusy(isBusy);
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
const handleCloseRequest = () => {
|
|
39
|
+
if (isCloseBlocked) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
onClose();
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (isOpen && user) {
|
|
48
|
+
const loadUserData = async () => {
|
|
49
|
+
try {
|
|
50
|
+
const userData = await getUserData(user);
|
|
51
|
+
|
|
52
|
+
if (userData) {
|
|
53
|
+
setCompany(userData.company || '');
|
|
54
|
+
setEmail(userData.email || '');
|
|
55
|
+
setPermitted(userData.permitted === true);
|
|
56
|
+
}
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.error('Failed to load user data:', err);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
void loadUserData();
|
|
63
|
+
}
|
|
64
|
+
}, [isOpen, user]);
|
|
65
|
+
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
const handleEscape = (e: KeyboardEvent) => {
|
|
68
|
+
if (e.key === 'Escape' && isOpen && !isCloseBlocked) {
|
|
69
|
+
onClose();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
if (isOpen) {
|
|
74
|
+
document.addEventListener('keydown', handleEscape);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return () => {
|
|
78
|
+
document.removeEventListener('keydown', handleEscape);
|
|
79
|
+
};
|
|
80
|
+
}, [isOpen, isCloseBlocked, onClose]);
|
|
81
|
+
|
|
82
|
+
const handleUpdateProfile = async (e: React.FormEvent) => {
|
|
83
|
+
e.preventDefault();
|
|
84
|
+
setIsLoading(true);
|
|
85
|
+
setError('');
|
|
86
|
+
setSuccess('');
|
|
87
|
+
|
|
88
|
+
const oldDisplayName = user?.displayName || '';
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
if (!user) throw new Error(ERROR_MESSAGES.NO_USER);
|
|
92
|
+
|
|
93
|
+
await updateProfile(user, {
|
|
94
|
+
displayName,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const [firstName, lastName] = displayName.split(' ');
|
|
98
|
+
|
|
99
|
+
await updateUserData(user, {
|
|
100
|
+
email: user.email,
|
|
101
|
+
firstName: firstName || '',
|
|
102
|
+
lastName: lastName || '',
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
await auditService.logUserProfileUpdate(
|
|
106
|
+
user,
|
|
107
|
+
'displayName',
|
|
108
|
+
oldDisplayName,
|
|
109
|
+
displayName,
|
|
110
|
+
'success'
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
setSuccess(ERROR_MESSAGES.PROFILE_UPDATED);
|
|
114
|
+
} catch (err) {
|
|
115
|
+
const { message } = handleAuthError(err);
|
|
116
|
+
|
|
117
|
+
await auditService.logUserProfileUpdate(
|
|
118
|
+
user!,
|
|
119
|
+
'displayName',
|
|
120
|
+
oldDisplayName,
|
|
121
|
+
displayName,
|
|
122
|
+
'failure',
|
|
123
|
+
undefined,
|
|
124
|
+
[message]
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
setError(message);
|
|
128
|
+
} finally {
|
|
129
|
+
setIsLoading(false);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const handleDeleteAccountClick = () => {
|
|
134
|
+
setShowDeleteModal(true);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
if (!isOpen) return null;
|
|
138
|
+
|
|
139
|
+
if (showAuditViewer) {
|
|
140
|
+
return <UserAuditViewer isOpen={showAuditViewer} onClose={() => setShowAuditViewer(false)} />;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (showResetForm) {
|
|
144
|
+
return <PasswordReset isModal={true} onBack={() => setShowResetForm(false)} />;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (showDeleteModal && user) {
|
|
148
|
+
return (
|
|
149
|
+
<DeleteAccount
|
|
150
|
+
isOpen={showDeleteModal}
|
|
151
|
+
onClose={() => setShowDeleteModal(false)}
|
|
152
|
+
user={{
|
|
153
|
+
uid: user.uid,
|
|
154
|
+
displayName: user.displayName,
|
|
155
|
+
email: user.email,
|
|
156
|
+
}}
|
|
157
|
+
company={company}
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<div className={styles.modalOverlay} onClick={handleCloseRequest} role="presentation">
|
|
164
|
+
{/* eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */}
|
|
165
|
+
<div
|
|
166
|
+
className={styles.modal}
|
|
167
|
+
role="dialog"
|
|
168
|
+
aria-modal="true"
|
|
169
|
+
aria-labelledby="modal-title"
|
|
170
|
+
onClick={(e) => e.stopPropagation()}
|
|
171
|
+
>
|
|
172
|
+
<header className={styles.modalHeader}>
|
|
173
|
+
<h1 id="modal-title">Manage Profile</h1>
|
|
174
|
+
<button
|
|
175
|
+
onClick={handleCloseRequest}
|
|
176
|
+
className={styles.closeButton}
|
|
177
|
+
aria-label="Close modal"
|
|
178
|
+
disabled={isCloseBlocked}
|
|
179
|
+
>
|
|
180
|
+
×
|
|
181
|
+
</button>
|
|
182
|
+
</header>
|
|
183
|
+
|
|
184
|
+
<form onSubmit={handleUpdateProfile} className={styles.form}>
|
|
185
|
+
<FormField
|
|
186
|
+
label="Display Name"
|
|
187
|
+
component="input"
|
|
188
|
+
type="text"
|
|
189
|
+
name="displayName"
|
|
190
|
+
id="displayName"
|
|
191
|
+
value={displayName}
|
|
192
|
+
onChange={(e) => setDisplayName(e.target.value)}
|
|
193
|
+
autoComplete="name"
|
|
194
|
+
required
|
|
195
|
+
/>
|
|
196
|
+
|
|
197
|
+
<div className={styles.formGroup}>
|
|
198
|
+
<label htmlFor="company">Lab/Company Name</label>
|
|
199
|
+
<input
|
|
200
|
+
id="company"
|
|
201
|
+
type="text"
|
|
202
|
+
value={company}
|
|
203
|
+
disabled
|
|
204
|
+
readOnly
|
|
205
|
+
className={styles.input}
|
|
206
|
+
style={{ backgroundColor: '#f8f9fa', cursor: 'not-allowed' }}
|
|
207
|
+
/>
|
|
208
|
+
<p className={styles.helpText}>
|
|
209
|
+
Company name can only be changed by an administrator. Contact support if changes are needed.
|
|
210
|
+
</p>
|
|
211
|
+
</div>
|
|
212
|
+
|
|
213
|
+
<div className={styles.formGroup}>
|
|
214
|
+
<label htmlFor="email">Email</label>
|
|
215
|
+
<input
|
|
216
|
+
id="email"
|
|
217
|
+
type="email"
|
|
218
|
+
value={email}
|
|
219
|
+
disabled
|
|
220
|
+
readOnly
|
|
221
|
+
className={styles.input}
|
|
222
|
+
autoComplete="email"
|
|
223
|
+
style={{ backgroundColor: '#f8f9fa', cursor: 'not-allowed' }}
|
|
224
|
+
/>
|
|
225
|
+
<p className={styles.helpText}>
|
|
226
|
+
Email address cannot be changed for security reasons. Contact support if changes are needed.
|
|
227
|
+
</p>
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
<MfaPhoneUpdateSection user={user} isOpen={isOpen} onBusyChange={handleMfaBusyChange} />
|
|
231
|
+
|
|
232
|
+
{error && <FormMessage type="error" message={error} />}
|
|
233
|
+
{success && <FormMessage type="success" message={success} />}
|
|
234
|
+
|
|
235
|
+
<div className={styles.buttonGroup}>
|
|
236
|
+
<FormButton variant="primary" type="submit" isLoading={isLoading} loadingText="Updating...">
|
|
237
|
+
Update Profile
|
|
238
|
+
</FormButton>
|
|
239
|
+
<FormButton variant="secondary" type="button" onClick={() => setShowAuditViewer(true)}>
|
|
240
|
+
View My Audit Trail
|
|
241
|
+
</FormButton>
|
|
242
|
+
<FormButton variant="secondary" type="button" onClick={() => setShowResetForm(true)}>
|
|
243
|
+
Reset Password
|
|
244
|
+
</FormButton>
|
|
245
|
+
</div>
|
|
246
|
+
<button type="button" onClick={handleDeleteAccountClick} className={styles.deleteButton}>
|
|
247
|
+
Delete Striae Account
|
|
248
|
+
</button>
|
|
249
|
+
</form>
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
);
|
|
253
|
+
};
|