hazo_auth 10.27.0 → 10.32.0
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/cli-src/lib/auth/auth_cache.ts +11 -1
- package/cli-src/lib/auth/hazo_get_auth.server.ts +65 -8
- package/cli-src/lib/auth/hazo_get_tenant_auth.server.ts +9 -45
- package/cli-src/lib/auth/scope_header.ts +58 -0
- package/cli-src/lib/auth_hooks.ts +19 -5
- package/cli-src/lib/email_verification_config.server.ts +3 -0
- package/cli-src/lib/forgot_password_config.server.ts +3 -0
- package/cli-src/lib/register_config.server.ts +3 -0
- package/cli-src/lib/reset_password_config.server.ts +3 -0
- package/cli-src/lib/schema/sqlite_schema.ts +150 -38
- package/cli-src/lib/services/index.ts +1 -0
- package/cli-src/lib/services/scope_membership_service.ts +68 -0
- package/cli-src/lib/services/scope_service.ts +21 -0
- package/cli-src/lib/services/user_scope_service.ts +4 -32
- package/dist/admin-issues/plugin.server.js +1 -1
- package/dist/components/layouts/email_verification/index.d.ts +3 -1
- package/dist/components/layouts/email_verification/index.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/index.js +4 -4
- package/dist/components/layouts/forgot_password/index.d.ts +3 -1
- package/dist/components/layouts/forgot_password/index.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/index.js +2 -2
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts +8 -0
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/hooks/use_my_settings.js +37 -0
- package/dist/components/layouts/my_settings/index.d.ts +6 -1
- package/dist/components/layouts/my_settings/index.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/index.js +3 -3
- package/dist/components/layouts/register/hooks/use_register_form.d.ts +20 -1
- package/dist/components/layouts/register/hooks/use_register_form.d.ts.map +1 -1
- package/dist/components/layouts/register/hooks/use_register_form.js +70 -4
- package/dist/components/layouts/register/index.d.ts +13 -1
- package/dist/components/layouts/register/index.d.ts.map +1 -1
- package/dist/components/layouts/register/index.js +26 -4
- package/dist/components/layouts/reset_password/index.d.ts +3 -1
- package/dist/components/layouts/reset_password/index.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/index.js +5 -5
- package/dist/components/layouts/shared/hooks/use_auth_status.d.ts +3 -0
- package/dist/components/layouts/shared/hooks/use_auth_status.d.ts.map +1 -1
- package/dist/components/layouts/shared/hooks/use_auth_status.js +5 -2
- package/dist/components/layouts/user_management/components/user_signup_stats_cards.d.ts +1 -8
- package/dist/components/layouts/user_management/components/user_signup_stats_cards.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/user_signup_stats_cards.js +8 -90
- package/dist/components/ui/alert-dialog.d.ts +9 -9
- package/dist/components/ui/alert-dialog.d.ts.map +1 -1
- package/dist/components/ui/avatar.d.ts +4 -3
- package/dist/components/ui/avatar.d.ts.map +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/checkbox.d.ts +2 -1
- package/dist/components/ui/checkbox.d.ts.map +1 -1
- package/dist/components/ui/dialog.d.ts +8 -8
- package/dist/components/ui/dialog.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.d.ts +17 -17
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/hover-card.d.ts +3 -3
- package/dist/components/ui/hover-card.d.ts.map +1 -1
- package/dist/components/ui/input-otp.d.ts +27 -1
- package/dist/components/ui/input-otp.d.ts.map +1 -1
- package/dist/components/ui/label.d.ts +2 -1
- package/dist/components/ui/label.d.ts.map +1 -1
- package/dist/components/ui/select.d.ts +10 -10
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/separator.d.ts +2 -1
- package/dist/components/ui/separator.d.ts.map +1 -1
- package/dist/components/ui/sheet.d.ts +9 -9
- package/dist/components/ui/sheet.d.ts.map +1 -1
- package/dist/components/ui/sidebar.d.ts +1 -1
- package/dist/components/ui/sidebar.d.ts.map +1 -1
- package/dist/components/ui/switch.d.ts +2 -1
- package/dist/components/ui/switch.d.ts.map +1 -1
- package/dist/components/ui/tabs.d.ts +4 -4
- package/dist/components/ui/tabs.d.ts.map +1 -1
- package/dist/components/ui/tooltip.d.ts +4 -4
- package/dist/components/ui/tooltip.d.ts.map +1 -1
- package/dist/components/ui/tree-view.d.ts +2 -1
- package/dist/components/ui/tree-view.d.ts.map +1 -1
- package/dist/components/ui/vertical-tabs.d.ts +4 -4
- package/dist/components/ui/vertical-tabs.d.ts.map +1 -1
- package/dist/lib/auth/auth_cache.d.ts +6 -2
- package/dist/lib/auth/auth_cache.d.ts.map +1 -1
- package/dist/lib/auth/auth_cache.js +6 -2
- package/dist/lib/auth/auth_types.d.ts +4 -0
- package/dist/lib/auth/auth_types.d.ts.map +1 -1
- package/dist/lib/auth/hazo_get_auth.server.d.ts.map +1 -1
- package/dist/lib/auth/hazo_get_auth.server.js +64 -8
- package/dist/lib/auth/hazo_get_tenant_auth.server.d.ts +2 -18
- package/dist/lib/auth/hazo_get_tenant_auth.server.d.ts.map +1 -1
- package/dist/lib/auth/hazo_get_tenant_auth.server.js +5 -38
- package/dist/lib/auth/scope_header.d.ts +28 -0
- package/dist/lib/auth/scope_header.d.ts.map +1 -0
- package/dist/lib/auth/scope_header.js +34 -0
- package/dist/lib/auth_hooks.d.ts.map +1 -1
- package/dist/lib/auth_hooks.js +19 -5
- package/dist/lib/email_verification_config.server.d.ts +2 -0
- package/dist/lib/email_verification_config.server.d.ts.map +1 -1
- package/dist/lib/email_verification_config.server.js +1 -0
- package/dist/lib/forgot_password_config.server.d.ts +2 -0
- package/dist/lib/forgot_password_config.server.d.ts.map +1 -1
- package/dist/lib/forgot_password_config.server.js +1 -0
- package/dist/lib/my_settings_config.server.d.ts +4 -0
- package/dist/lib/my_settings_config.server.d.ts.map +1 -1
- package/dist/lib/my_settings_config.server.js +3 -0
- package/dist/lib/register_config.server.d.ts +12 -0
- package/dist/lib/register_config.server.d.ts.map +1 -1
- package/dist/lib/register_config.server.js +8 -0
- package/dist/lib/reset_password_config.server.d.ts +2 -0
- package/dist/lib/reset_password_config.server.d.ts.map +1 -1
- package/dist/lib/reset_password_config.server.js +1 -0
- package/dist/lib/schema/sqlite_schema.d.ts +1 -1
- package/dist/lib/schema/sqlite_schema.d.ts.map +1 -1
- package/dist/lib/schema/sqlite_schema.js +150 -38
- package/dist/lib/services/index.d.ts +1 -0
- package/dist/lib/services/index.d.ts.map +1 -1
- package/dist/lib/services/index.js +1 -0
- package/dist/lib/services/registration_service.js +30 -5
- package/dist/lib/services/scope_membership_service.d.ts +20 -0
- package/dist/lib/services/scope_membership_service.d.ts.map +1 -0
- package/dist/lib/services/scope_membership_service.js +49 -0
- package/dist/lib/services/scope_service.d.ts +6 -0
- package/dist/lib/services/scope_service.d.ts.map +1 -1
- package/dist/lib/services/scope_service.js +12 -0
- package/dist/lib/services/user_scope_service.d.ts.map +1 -1
- package/dist/lib/services/user_scope_service.js +4 -30
- package/dist/lib/services/user_update_service.d.ts +5 -0
- package/dist/lib/services/user_update_service.d.ts.map +1 -1
- package/dist/lib/services/user_update_service.js +2 -0
- package/dist/locales/en.json +10 -0
- package/dist/page_components/my_settings.d.ts +9 -1
- package/dist/page_components/my_settings.d.ts.map +1 -1
- package/dist/page_components/my_settings.js +8 -2
- package/dist/server/routes/detect_proxy_origin.d.ts +6 -0
- package/dist/server/routes/detect_proxy_origin.d.ts.map +1 -0
- package/dist/server/routes/detect_proxy_origin.js +49 -0
- package/dist/server/routes/me.d.ts.map +1 -1
- package/dist/server/routes/me.js +5 -1
- package/dist/server/routes/nextauth.d.ts.map +1 -1
- package/dist/server/routes/nextauth.js +1 -44
- package/dist/server/routes/register.js +53 -2
- package/dist/server/routes/update_user.d.ts.map +1 -1
- package/dist/server/routes/update_user.js +24 -1
- package/dist/server/routes/user_management_users.d.ts +1 -1
- package/dist/server_pages/forgot_password.d.ts.map +1 -1
- package/dist/server_pages/forgot_password.js +1 -1
- package/dist/server_pages/forgot_password_client_wrapper.d.ts +1 -1
- package/dist/server_pages/forgot_password_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/forgot_password_client_wrapper.js +2 -2
- package/dist/server_pages/my_settings.d.ts.map +1 -1
- package/dist/server_pages/my_settings.js +1 -1
- package/dist/server_pages/register.d.ts +19 -1
- package/dist/server_pages/register.d.ts.map +1 -1
- package/dist/server_pages/register.js +4 -4
- package/dist/server_pages/register_client_wrapper.d.ts +6 -2
- package/dist/server_pages/register_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/register_client_wrapper.js +2 -2
- package/dist/server_pages/reset_password.d.ts.map +1 -1
- package/dist/server_pages/reset_password.js +1 -1
- package/dist/server_pages/reset_password_client_wrapper.d.ts +1 -1
- package/dist/server_pages/reset_password_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/reset_password_client_wrapper.js +2 -2
- package/dist/server_pages/verify_email.d.ts.map +1 -1
- package/dist/server_pages/verify_email.js +1 -1
- package/dist/server_pages/verify_email_client_wrapper.d.ts +1 -1
- package/dist/server_pages/verify_email_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/verify_email_client_wrapper.js +2 -2
- package/dist/settings/index.d.ts +5 -0
- package/dist/settings/index.d.ts.map +1 -0
- package/dist/settings/index.js +161 -0
- package/package.json +15 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_my_settings.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/hooks/use_my_settings.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAE3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAI3E,MAAM,MAAM,cAAc,GAAG;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,sBAAsB,EAAE,OAAO,CAAC;IAChC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,sBAAsB,EAAE,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CAAC,CAAC;IAGhD,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,yBAAyB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"use_my_settings.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/hooks/use_my_settings.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAE3F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAI3E,MAAM,MAAM,cAAc,GAAG;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,sBAAsB,EAAE,OAAO,CAAC;IAChC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,sBAAsB,EAAE,OAAO,CAAC;IAChC,MAAM,EAAE;QACN,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAChC,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAEhC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC7D,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,MAAM,CAA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E,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAGhH,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,oBAAoB,EAAE,0BAA0B,CAAC;IACjD,CAAC,EAAE,aAAa,CAAC;CAClB,CAAC;AA4BF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,EAC9B,oBAAoB,EACpB,CAAC,GACF,EAAE,mBAAmB,GAAG,mBAAmB,CAka3C"}
|
|
@@ -56,6 +56,9 @@ export function use_my_settings({ passwordRequirements, t, }) {
|
|
|
56
56
|
const profilePictureUrl = authStatus.profile_picture_url;
|
|
57
57
|
const profileSource = authStatus.profile_source;
|
|
58
58
|
const preferredLocale = authStatus.preferred_locale;
|
|
59
|
+
const country = authStatus.country;
|
|
60
|
+
const stateProvince = authStatus.state_province;
|
|
61
|
+
const suburb = authStatus.suburb;
|
|
59
62
|
const lastLogon = authStatus.last_logon;
|
|
60
63
|
const loading = authStatus.loading;
|
|
61
64
|
// OAuth-related data
|
|
@@ -169,6 +172,36 @@ export function use_my_settings({ passwordRequirements, t, }) {
|
|
|
169
172
|
throw error;
|
|
170
173
|
}
|
|
171
174
|
}, [apiBasePath, refreshUserData, t]);
|
|
175
|
+
/**
|
|
176
|
+
* Updates the user's location fields (country / state_province / suburb).
|
|
177
|
+
* Only sends the fields present in `location` — the server re-validates against
|
|
178
|
+
* [hazo_auth__custom_fields] regardless (see update_user.ts).
|
|
179
|
+
*/
|
|
180
|
+
const handleLocationSave = useCallback(async (location) => {
|
|
181
|
+
try {
|
|
182
|
+
const response = await fetch(`${apiBasePath}/update_user`, {
|
|
183
|
+
method: "PATCH",
|
|
184
|
+
headers: {
|
|
185
|
+
"Content-Type": "application/json",
|
|
186
|
+
},
|
|
187
|
+
credentials: "include",
|
|
188
|
+
body: JSON.stringify({ location }),
|
|
189
|
+
});
|
|
190
|
+
const data = await response.json();
|
|
191
|
+
if (!response.ok || !data.success) {
|
|
192
|
+
const errorMessage = data.error || t("my_settings.toast.location_error");
|
|
193
|
+
toast.error(errorMessage);
|
|
194
|
+
throw new Error(errorMessage);
|
|
195
|
+
}
|
|
196
|
+
toast.success(t("my_settings.toast.location_success"));
|
|
197
|
+
await refreshUserData();
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
const errorMessage = error instanceof Error ? error.message : t("my_settings.toast.location_error");
|
|
201
|
+
toast.error(errorMessage);
|
|
202
|
+
throw error;
|
|
203
|
+
}
|
|
204
|
+
}, [apiBasePath, refreshUserData, t]);
|
|
172
205
|
/**
|
|
173
206
|
* Handles password field change
|
|
174
207
|
*/
|
|
@@ -352,6 +385,9 @@ export function use_my_settings({ passwordRequirements, t, }) {
|
|
|
352
385
|
profilePictureUrl,
|
|
353
386
|
profileSource,
|
|
354
387
|
preferredLocale,
|
|
388
|
+
country,
|
|
389
|
+
stateProvince,
|
|
390
|
+
suburb,
|
|
355
391
|
lastLogon,
|
|
356
392
|
loading,
|
|
357
393
|
// OAuth-related data
|
|
@@ -372,6 +408,7 @@ export function use_my_settings({ passwordRequirements, t, }) {
|
|
|
372
408
|
handleNameSave,
|
|
373
409
|
handleEmailSave,
|
|
374
410
|
handlePreferredLocaleSave,
|
|
411
|
+
handleLocationSave,
|
|
375
412
|
refreshUserData,
|
|
376
413
|
};
|
|
377
414
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type AvailableLocale } from "./components/language_picker_section.js";
|
|
2
2
|
import { type MySettingsLabelOverrides } from "./config/my_settings_field_config.js";
|
|
3
3
|
import type { PasswordRequirementOptions, ButtonPaletteOverrides } from "../shared/config/layout_customization";
|
|
4
|
+
import type { LocationFieldsConfig } from "../../../lib/location_fields_config.server";
|
|
4
5
|
export type MySettingsLayoutProps = {
|
|
5
6
|
className?: string;
|
|
6
7
|
labels?: MySettingsLabelOverrides;
|
|
@@ -20,6 +21,10 @@ export type MySettingsLayoutProps = {
|
|
|
20
21
|
show_email_field: boolean;
|
|
21
22
|
show_password_field: boolean;
|
|
22
23
|
};
|
|
24
|
+
/** Which indexed location fields to show as an editable "Location" card.
|
|
25
|
+
* Optional — defaults to all-off, so existing callers that don't pass it
|
|
26
|
+
* (and existing tests) are unaffected. */
|
|
27
|
+
locationFields?: LocationFieldsConfig;
|
|
23
28
|
unauthorizedMessage?: string;
|
|
24
29
|
loginButtonLabel?: string;
|
|
25
30
|
loginPath?: string;
|
|
@@ -74,5 +79,5 @@ export type MySettingsLayoutProps = {
|
|
|
74
79
|
* @param props - Component props including labels, button colors, password requirements, etc.
|
|
75
80
|
* @returns My settings layout component
|
|
76
81
|
*/
|
|
77
|
-
export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage, loginButtonLabel, loginPath, availableLocales, enableAccountDeletion, heading, subHeading, profilePhotoLabel, profilePhotoRecommendation, uploadPhotoButtonLabel, removePhotoButtonLabel, profileInformationLabel, passwordLabel, currentPasswordLabel, newPasswordLabel, confirmPasswordLabel, messages, uiSizes, fileTypes, }: MySettingsLayoutProps): import("react").JSX.Element;
|
|
82
|
+
export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields, locationFields, unauthorizedMessage, loginButtonLabel, loginPath, availableLocales, enableAccountDeletion, heading, subHeading, profilePhotoLabel, profilePhotoRecommendation, uploadPhotoButtonLabel, removePhotoButtonLabel, profileInformationLabel, passwordLabel, currentPasswordLabel, newPasswordLabel, confirmPasswordLabel, messages, uiSizes, fileTypes, }: MySettingsLayoutProps): import("react").JSX.Element;
|
|
78
83
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/my_settings/index.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAGnG,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,mCAA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AgB,EAChB,SAA8B,EAC9B,gBAAgB,EAChB,qBAA6B,EAC7B,OAAO,EACP,UAAU,EACV,iBAAiB,EACjB,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,EACvB,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE,qBAAqB,+BA2TvB"}
|
|
@@ -27,8 +27,8 @@ import { useAuthT } from "../../../contexts/hazo_auth_provider.js";
|
|
|
27
27
|
* @param props - Component props including labels, button colors, password requirements, etc.
|
|
28
28
|
* @returns My settings layout component
|
|
29
29
|
*/
|
|
30
|
-
export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage, loginButtonLabel, loginPath = "/hazo_auth/login", availableLocales, enableAccountDeletion = false, heading, subHeading, profilePhotoLabel, profilePhotoRecommendation, uploadPhotoButtonLabel, removePhotoButtonLabel, profileInformationLabel, passwordLabel, currentPasswordLabel, newPasswordLabel, confirmPasswordLabel, messages, uiSizes, fileTypes, }) {
|
|
31
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
30
|
+
export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields, locationFields = { country: false, state_province: false, suburb: false }, unauthorizedMessage, loginButtonLabel, loginPath = "/hazo_auth/login", availableLocales, enableAccountDeletion = false, heading, subHeading, profilePhotoLabel, profilePhotoRecommendation, uploadPhotoButtonLabel, removePhotoButtonLabel, profileInformationLabel, passwordLabel, currentPasswordLabel, newPasswordLabel, confirmPasswordLabel, messages, uiSizes, fileTypes, }) {
|
|
31
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
32
32
|
const t = useAuthT();
|
|
33
33
|
const resolvedLabels = resolveMySettingsLabels(t, labels);
|
|
34
34
|
const resolvedButtonPalette = resolveMySettingsButtonPalette(button_colors);
|
|
@@ -65,7 +65,7 @@ export default function my_settings_layout({ className, labels, button_colors, p
|
|
|
65
65
|
passwordRequirements: password_requirements,
|
|
66
66
|
t,
|
|
67
67
|
});
|
|
68
|
-
return (_jsx(UnauthorizedGuard, { message: resolvedUnauthorizedMessage, loginButtonLabel: resolvedLoginButtonLabel, loginPath: loginPath, children: _jsxs("div", { className: cn("cls_my_settings_layout flex flex-col gap-6 p-6 w-full", className), children: [_jsxs("div", { className: "cls_my_settings_layout_header flex flex-col gap-2", children: [_jsx("h1", { className: "cls_my_settings_layout_heading text-3xl font-bold text-[var(--hazo-text-primary)]", children: resolvedHeading }), _jsx("p", { className: "cls_my_settings_layout_subheading text-[var(--hazo-text-muted)]", children: resolvedSubHeading })] }), _jsxs("div", { className: "cls_my_settings_layout_profile_photo_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: resolvedProfilePhotoLabel }), _jsx("div", { className: "cls_my_settings_layout_profile_photo_content flex flex-col items-center", children: _jsxs("div", { className: "cls_my_settings_layout_profile_photo_display relative", children: [_jsx(ProfilePictureDisplay, { profilePictureUrl: settings.profilePictureUrl, name: settings.name, email: settings.email, onEdit: settings.handleProfilePictureEdit }), _jsxs("div", { className: "cls_my_settings_layout_profile_photo_actions absolute left-0 right-0 flex items-center justify-between px-2", style: { bottom: '-20px' }, children: [_jsx(Button, { type: "button", onClick: settings.handleProfilePictureEdit, disabled: settings.loading, variant: "ghost", size: "icon", className: "cls_my_settings_layout_upload_photo_button", "aria-label": resolvedUploadPhotoButtonLabel, children: _jsx(Pencil, { className: "h-4 w-4", "aria-hidden": "true" }) }), _jsx(Button, { type: "button", onClick: settings.handleProfilePictureRemove, disabled: settings.loading || !settings.profilePictureUrl, variant: "ghost", size: "icon", className: "cls_my_settings_layout_remove_photo_button text-red-600 hover:text-red-700 hover:bg-red-50", "aria-label": resolvedRemovePhotoButtonLabel, children: _jsx(Trash2, { className: "h-4 w-4", "aria-hidden": "true" }) })] })] }) })] }), _jsxs("div", { className: "cls_my_settings_layout_profile_information_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: resolvedProfileInformationLabel }), _jsxs("div", { className: "cls_my_settings_layout_profile_information_fields grid grid-cols-1 md:grid-cols-2 gap-6", children: [userFields.show_name_field && (_jsx(EditableField, { label: t("my_settings.name_field.label_default"), value: settings.name, type: "text", placeholder: t("my_settings.name_field.placeholder_default"), onSave: settings.handleNameSave, validation: validateName, disabled: settings.loading, ariaLabel: t("my_settings.name_field.aria_label_default") })), userFields.show_email_field && (_jsx(EditableField, { label: t("shared.field.email.label"), value: settings.email, type: "email", placeholder: t("shared.field.email.placeholder"), onSave: settings.handleEmailSave, validation: validateEmail, disabled: settings.loading, ariaLabel: t("shared.field.email.aria_label") })), _jsx(LanguagePickerSection, { availableLocales: availableLocales, currentLocale: settings.preferredLocale, onLocaleChange: settings.handlePreferredLocaleSave, disabled: settings.loading })] })] }), userFields.show_password_field && settings.hasPassword && (_jsxs("div", { className: "cls_my_settings_layout_password_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: resolvedPasswordLabel }), _jsxs("div", { className: "cls_my_settings_layout_password_fields flex flex-col gap-6", children: [_jsx(FormFieldWrapper, { fieldId: "current-password", label: resolvedCurrentPasswordLabel, input: _jsx(PasswordField, { inputId: "current-password", ariaLabel: resolvedCurrentPasswordLabel, value: ((
|
|
68
|
+
return (_jsx(UnauthorizedGuard, { message: resolvedUnauthorizedMessage, loginButtonLabel: resolvedLoginButtonLabel, loginPath: loginPath, children: _jsxs("div", { className: cn("cls_my_settings_layout flex flex-col gap-6 p-6 w-full", className), children: [_jsxs("div", { className: "cls_my_settings_layout_header flex flex-col gap-2", children: [_jsx("h1", { className: "cls_my_settings_layout_heading text-3xl font-bold text-[var(--hazo-text-primary)]", children: resolvedHeading }), _jsx("p", { className: "cls_my_settings_layout_subheading text-[var(--hazo-text-muted)]", children: resolvedSubHeading })] }), _jsxs("div", { className: "cls_my_settings_layout_profile_photo_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: resolvedProfilePhotoLabel }), _jsx("div", { className: "cls_my_settings_layout_profile_photo_content flex flex-col items-center", children: _jsxs("div", { className: "cls_my_settings_layout_profile_photo_display relative", children: [_jsx(ProfilePictureDisplay, { profilePictureUrl: settings.profilePictureUrl, name: settings.name, email: settings.email, onEdit: settings.handleProfilePictureEdit }), _jsxs("div", { className: "cls_my_settings_layout_profile_photo_actions absolute left-0 right-0 flex items-center justify-between px-2", style: { bottom: '-20px' }, children: [_jsx(Button, { type: "button", onClick: settings.handleProfilePictureEdit, disabled: settings.loading, variant: "ghost", size: "icon", className: "cls_my_settings_layout_upload_photo_button", "aria-label": resolvedUploadPhotoButtonLabel, children: _jsx(Pencil, { className: "h-4 w-4", "aria-hidden": "true" }) }), _jsx(Button, { type: "button", onClick: settings.handleProfilePictureRemove, disabled: settings.loading || !settings.profilePictureUrl, variant: "ghost", size: "icon", className: "cls_my_settings_layout_remove_photo_button text-red-600 hover:text-red-700 hover:bg-red-50", "aria-label": resolvedRemovePhotoButtonLabel, children: _jsx(Trash2, { className: "h-4 w-4", "aria-hidden": "true" }) })] })] }) })] }), _jsxs("div", { className: "cls_my_settings_layout_profile_information_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: resolvedProfileInformationLabel }), _jsxs("div", { className: "cls_my_settings_layout_profile_information_fields grid grid-cols-1 md:grid-cols-2 gap-6", children: [userFields.show_name_field && (_jsx(EditableField, { label: t("my_settings.name_field.label_default"), value: settings.name, type: "text", placeholder: t("my_settings.name_field.placeholder_default"), onSave: settings.handleNameSave, validation: validateName, disabled: settings.loading, ariaLabel: t("my_settings.name_field.aria_label_default") })), userFields.show_email_field && (_jsx(EditableField, { label: t("shared.field.email.label"), value: settings.email, type: "email", placeholder: t("shared.field.email.placeholder"), onSave: settings.handleEmailSave, validation: validateEmail, disabled: settings.loading, ariaLabel: t("shared.field.email.aria_label") })), _jsx(LanguagePickerSection, { availableLocales: availableLocales, currentLocale: settings.preferredLocale, onLocaleChange: settings.handlePreferredLocaleSave, disabled: settings.loading })] })] }), (locationFields.country || locationFields.state_province || locationFields.suburb) && (_jsxs("div", { className: "cls_my_settings_layout_location_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: t("my_settings.location_label_default") }), _jsxs("div", { className: "cls_my_settings_layout_location_fields grid grid-cols-1 md:grid-cols-2 gap-6", children: [locationFields.country && (_jsx(EditableField, { label: t("my_settings.location.country_label"), value: (_a = settings.country) !== null && _a !== void 0 ? _a : "", type: "text", onSave: (value) => settings.handleLocationSave({ country: value }), disabled: settings.loading, ariaLabel: t("my_settings.location.country_label") })), locationFields.state_province && (_jsx(EditableField, { label: t("my_settings.location.state_province_label"), value: (_b = settings.stateProvince) !== null && _b !== void 0 ? _b : "", type: "text", onSave: (value) => settings.handleLocationSave({ state_province: value }), disabled: settings.loading, ariaLabel: t("my_settings.location.state_province_label") })), locationFields.suburb && (_jsx(EditableField, { label: t("my_settings.location.suburb_label"), value: (_c = settings.suburb) !== null && _c !== void 0 ? _c : "", type: "text", onSave: (value) => settings.handleLocationSave({ suburb: value }), disabled: settings.loading, ariaLabel: t("my_settings.location.suburb_label") }))] })] })), userFields.show_password_field && settings.hasPassword && (_jsxs("div", { className: "cls_my_settings_layout_password_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_layout_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: resolvedPasswordLabel }), _jsxs("div", { className: "cls_my_settings_layout_password_fields flex flex-col gap-6", children: [_jsx(FormFieldWrapper, { fieldId: "current-password", label: resolvedCurrentPasswordLabel, input: _jsx(PasswordField, { inputId: "current-password", ariaLabel: resolvedCurrentPasswordLabel, value: ((_d = settings.passwordFields) === null || _d === void 0 ? void 0 : _d.currentPassword) || "", placeholder: t("my_settings.current_password_placeholder_default"), autoComplete: "current-password", isVisible: ((_e = settings.passwordFields) === null || _e === void 0 ? void 0 : _e.currentPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("currentPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("currentPassword"), errorMessage: (_g = (_f = settings.passwordFields) === null || _f === void 0 ? void 0 : _f.errors) === null || _g === void 0 ? void 0 : _g.currentPassword }) }), _jsxs("div", { className: "cls_my_settings_layout_password_fields_row grid grid-cols-1 md:grid-cols-2 gap-6", children: [_jsx(FormFieldWrapper, { fieldId: "new-password", label: resolvedNewPasswordLabel, input: _jsx(PasswordField, { inputId: "new-password", ariaLabel: resolvedNewPasswordLabel, value: ((_h = settings.passwordFields) === null || _h === void 0 ? void 0 : _h.newPassword) || "", placeholder: t("my_settings.set_password.new_password_placeholder"), autoComplete: "new-password", isVisible: ((_j = settings.passwordFields) === null || _j === void 0 ? void 0 : _j.newPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("newPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("newPassword"), errorMessage: (_l = (_k = settings.passwordFields) === null || _k === void 0 ? void 0 : _k.errors) === null || _l === void 0 ? void 0 : _l.newPassword }) }), _jsx(FormFieldWrapper, { fieldId: "confirm-password", label: resolvedConfirmPasswordLabel, input: _jsx(PasswordField, { inputId: "confirm-password", ariaLabel: resolvedConfirmPasswordLabel, value: ((_m = settings.passwordFields) === null || _m === void 0 ? void 0 : _m.confirmPassword) || "", placeholder: t("my_settings.set_password.confirm_password_placeholder"), autoComplete: "new-password", isVisible: ((_o = settings.passwordFields) === null || _o === void 0 ? void 0 : _o.confirmPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("confirmPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("confirmPassword"), errorMessage: (_q = (_p = settings.passwordFields) === null || _p === void 0 ? void 0 : _p.errors) === null || _q === void 0 ? void 0 : _q.confirmPassword }) })] })] }), _jsx("div", { className: "cls_my_settings_layout_password_actions flex justify-end mt-4", children: _jsx(Button, { type: "button", onClick: settings.handlePasswordSave, disabled: settings.loading || settings.isPasswordSaveDisabled, className: "cls_my_settings_layout_save_password_button", style: {
|
|
69
69
|
backgroundColor: resolvedButtonPalette.submitBackground,
|
|
70
70
|
color: resolvedButtonPalette.submitText,
|
|
71
71
|
}, "aria-label": t("my_settings.save_password_aria_default"), children: t("my_settings.save_password_button_default") }) })] })), !settings.hasPassword && settings.googleConnected && (_jsx(SetPasswordSection, { passwordRequirements: password_requirements, onPasswordSet: settings.refreshUserData, parentLoading: settings.loading })), _jsx(ConnectedAccountsSection, { googleConnected: settings.googleConnected || false, email: settings.email, loading: settings.loading }), _jsx(DangerZoneSection, { enabled: enableAccountDeletion, email: settings.email }), _jsx(ProfilePictureDialog, { open: settings.profilePictureDialogOpen, onOpenChange: (open) => {
|
|
@@ -2,6 +2,8 @@ import type { LayoutDataClient } from "../../shared/data/layout_data_client";
|
|
|
2
2
|
import type { PasswordRequirementOptions, PasswordRequirementOverrides } from "../../shared/config/layout_customization";
|
|
3
3
|
import { type RegisterFieldId } from "../config/register_field_config.js";
|
|
4
4
|
import type { LegalDoc } from "../../../../lib/legal/legal_docs_types";
|
|
5
|
+
import type { LocationFieldsConfig } from "../../../../lib/location_fields_config.server";
|
|
6
|
+
import type { AppUserDataSchema } from "../../../../lib/app_user_data_config.server";
|
|
5
7
|
export type RegisterFormValues = Record<RegisterFieldId, string>;
|
|
6
8
|
export type RegisterFormErrors = Partial<Record<RegisterFieldId, string | string[]>> & {
|
|
7
9
|
submit?: string;
|
|
@@ -14,7 +16,20 @@ export type UseRegisterFormParams<TClient = unknown> = {
|
|
|
14
16
|
dataClient: LayoutDataClient<TClient>;
|
|
15
17
|
urlOnLogon?: string;
|
|
16
18
|
legalDocs?: LegalDoc[];
|
|
19
|
+
/** Which indexed location fields to collect — see [hazo_auth__custom_fields]. */
|
|
20
|
+
locationFields?: LocationFieldsConfig;
|
|
21
|
+
/** Arbitrary custom fields, reusing the existing app_user_data JSON Schema config.
|
|
22
|
+
* Only flat `string` | `number` | `boolean` top-level properties are rendered at
|
|
23
|
+
* registration time — nested `object` properties are edited later via User
|
|
24
|
+
* Management's schema editor, not at signup. */
|
|
25
|
+
customFieldsSchema?: AppUserDataSchema | null;
|
|
26
|
+
/** A `user_type` to send with every submission from this form instance, fixed by
|
|
27
|
+
* the consumer (e.g. a `/register/parent` vs `/register/teacher` entry point) —
|
|
28
|
+
* never rendered as a field, never user-editable. Omitted = unchanged existing
|
|
29
|
+
* behavior (no `user_type` sent, same as before this option existed). */
|
|
30
|
+
fixedUserType?: string;
|
|
17
31
|
};
|
|
32
|
+
export type LocationFieldKey = "country" | "state_province" | "suburb";
|
|
18
33
|
export type UseRegisterFormResult = {
|
|
19
34
|
values: RegisterFormValues;
|
|
20
35
|
errors: RegisterFormErrors;
|
|
@@ -29,6 +44,10 @@ export type UseRegisterFormResult = {
|
|
|
29
44
|
handleCancel: () => void;
|
|
30
45
|
legal_accepted: Record<string, boolean>;
|
|
31
46
|
handleLegalAcceptedChange: (key: string, value: boolean) => void;
|
|
47
|
+
locationValues: Record<LocationFieldKey, string>;
|
|
48
|
+
handleLocationFieldChange: (field: LocationFieldKey, value: string) => void;
|
|
49
|
+
customFieldValues: Record<string, string>;
|
|
50
|
+
handleCustomFieldChange: (key: string, value: string) => void;
|
|
32
51
|
};
|
|
33
|
-
export declare const use_register_form: <TClient>({ showNameField, passwordRequirements, dataClient, urlOnLogon, legalDocs, }: UseRegisterFormParams<TClient>) => UseRegisterFormResult;
|
|
52
|
+
export declare const use_register_form: <TClient>({ showNameField, passwordRequirements, dataClient, urlOnLogon, legalDocs, locationFields, customFieldsSchema, fixedUserType, }: UseRegisterFormParams<TClient>) => UseRegisterFormResult;
|
|
34
53
|
//# sourceMappingURL=use_register_form.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_register_form.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/register/hooks/use_register_form.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACzH,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAG3F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"use_register_form.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/register/hooks/use_register_form.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACzH,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAG3F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AAGvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AAC1F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AASrF,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AACjE,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,GAAG;IACrF,M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CAAC;IAChE,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,yBAAyB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACjE,cAAc,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;IACjD,yBAAyB,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5E,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,uBAAuB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/D,CAAC;AAYF,eAAO,MAAM,iBAAiB,GAAI,OAAO,EAAG,gIASzC,qBAAqB,CAAC,OAAO,CAAC,KAAG,qBAqVnC,CAAC"}
|
|
@@ -18,7 +18,7 @@ const buildInitialValues = () => ({
|
|
|
18
18
|
[REGISTER_FIELD_IDS.CONFIRM_PASSWORD]: "",
|
|
19
19
|
});
|
|
20
20
|
// section: hook
|
|
21
|
-
export const use_register_form = ({ showNameField, passwordRequirements, dataClient, urlOnLogon, legalDocs, }) => {
|
|
21
|
+
export const use_register_form = ({ showNameField, passwordRequirements, dataClient, urlOnLogon, legalDocs, locationFields, customFieldsSchema, fixedUserType, }) => {
|
|
22
22
|
const { apiBasePath } = useHazoAuthConfig();
|
|
23
23
|
const t = useAuthT();
|
|
24
24
|
const initialValues = useMemo(() => buildInitialValues(), []);
|
|
@@ -31,6 +31,18 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
31
31
|
const [emailTouched, setEmailTouched] = useState(false);
|
|
32
32
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
33
33
|
const [legal_accepted, set_legal_accepted] = useState({});
|
|
34
|
+
const [locationValues, setLocationValues] = useState({
|
|
35
|
+
country: "",
|
|
36
|
+
state_province: "",
|
|
37
|
+
suburb: "",
|
|
38
|
+
});
|
|
39
|
+
const [customFieldValues, setCustomFieldValues] = useState({});
|
|
40
|
+
const handleLocationFieldChange = useCallback((field, value) => {
|
|
41
|
+
setLocationValues((prev) => (Object.assign(Object.assign({}, prev), { [field]: value })));
|
|
42
|
+
}, []);
|
|
43
|
+
const handleCustomFieldChange = useCallback((key, value) => {
|
|
44
|
+
setCustomFieldValues((prev) => (Object.assign(Object.assign({}, prev), { [key]: value })));
|
|
45
|
+
}, []);
|
|
34
46
|
// Check if form has been edited (changed from initial state)
|
|
35
47
|
const isFormEdited = useMemo(() => {
|
|
36
48
|
return Object.entries(values).some(([fieldId, fieldValue]) => {
|
|
@@ -158,14 +170,48 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
158
170
|
.filter(doc => legal_accepted[doc.key])
|
|
159
171
|
.map(doc => [doc.key, { hash: doc.hash }]))
|
|
160
172
|
: undefined;
|
|
173
|
+
// Only send fields the app actually enabled, and only non-blank ones —
|
|
174
|
+
// mirrors the server-side re-validation in register.ts (never trust the
|
|
175
|
+
// client alone, but no point sending what the server would strip anyway).
|
|
176
|
+
const location_payload = {};
|
|
177
|
+
if ((locationFields === null || locationFields === void 0 ? void 0 : locationFields.country) && locationValues.country.trim()) {
|
|
178
|
+
location_payload.country = locationValues.country.trim();
|
|
179
|
+
}
|
|
180
|
+
if ((locationFields === null || locationFields === void 0 ? void 0 : locationFields.state_province) && locationValues.state_province.trim()) {
|
|
181
|
+
location_payload.state_province = locationValues.state_province.trim();
|
|
182
|
+
}
|
|
183
|
+
if ((locationFields === null || locationFields === void 0 ? void 0 : locationFields.suburb) && locationValues.suburb.trim()) {
|
|
184
|
+
location_payload.suburb = locationValues.suburb.trim();
|
|
185
|
+
}
|
|
186
|
+
const custom_fields_payload = {};
|
|
187
|
+
if (customFieldsSchema) {
|
|
188
|
+
for (const [key, propertySchema] of Object.entries(customFieldsSchema.properties)) {
|
|
189
|
+
const raw = customFieldValues[key];
|
|
190
|
+
if (raw === undefined || raw === "")
|
|
191
|
+
continue;
|
|
192
|
+
if (propertySchema.type === "number") {
|
|
193
|
+
const parsed = Number(raw);
|
|
194
|
+
if (!Number.isNaN(parsed))
|
|
195
|
+
custom_fields_payload[key] = parsed;
|
|
196
|
+
}
|
|
197
|
+
else if (propertySchema.type === "boolean") {
|
|
198
|
+
custom_fields_payload[key] = raw === "true";
|
|
199
|
+
}
|
|
200
|
+
else if (propertySchema.type === "string") {
|
|
201
|
+
custom_fields_payload[key] = raw;
|
|
202
|
+
}
|
|
203
|
+
// "object"-typed top-level properties aren't rendered at registration
|
|
204
|
+
// time (see UseRegisterFormParams.customFieldsSchema doc) — skipped.
|
|
205
|
+
}
|
|
206
|
+
}
|
|
161
207
|
const response = await fetch(`${apiBasePath}/register`, {
|
|
162
208
|
method: "POST",
|
|
163
209
|
headers: {
|
|
164
210
|
"Content-Type": "application/json",
|
|
165
211
|
},
|
|
166
|
-
body: JSON.stringify(Object.assign({ name: values[REGISTER_FIELD_IDS.NAME] || undefined, email: values[REGISTER_FIELD_IDS.EMAIL], password: values[REGISTER_FIELD_IDS.PASSWORD], url_on_logon: urlOnLogon }, (legal_accepted_payload && Object.keys(legal_accepted_payload).length > 0
|
|
212
|
+
body: JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({ name: values[REGISTER_FIELD_IDS.NAME] || undefined, email: values[REGISTER_FIELD_IDS.EMAIL], password: values[REGISTER_FIELD_IDS.PASSWORD], url_on_logon: urlOnLogon }, (legal_accepted_payload && Object.keys(legal_accepted_payload).length > 0
|
|
167
213
|
? { legal_accepted: legal_accepted_payload }
|
|
168
|
-
: {}))),
|
|
214
|
+
: {})), (Object.keys(location_payload).length > 0 ? { location: location_payload } : {})), (Object.keys(custom_fields_payload).length > 0 ? { custom_fields: custom_fields_payload } : {})), (fixedUserType ? { user_type: fixedUserType } : {}))),
|
|
169
215
|
});
|
|
170
216
|
const data = await response.json();
|
|
171
217
|
if (!response.ok) {
|
|
@@ -185,6 +231,8 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
185
231
|
});
|
|
186
232
|
setEmailTouched(false);
|
|
187
233
|
set_legal_accepted({});
|
|
234
|
+
setLocationValues({ country: "", state_province: "", suburb: "" });
|
|
235
|
+
setCustomFieldValues({});
|
|
188
236
|
}
|
|
189
237
|
catch (error) {
|
|
190
238
|
const errorMessage = error instanceof Error ? error.message : t("register.error.failed_retry_message");
|
|
@@ -200,7 +248,19 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
200
248
|
finally {
|
|
201
249
|
setIsSubmitting(false);
|
|
202
250
|
}
|
|
203
|
-
}, [
|
|
251
|
+
}, [
|
|
252
|
+
values,
|
|
253
|
+
passwordRequirements,
|
|
254
|
+
dataClient,
|
|
255
|
+
urlOnLogon,
|
|
256
|
+
legalDocs,
|
|
257
|
+
legal_accepted,
|
|
258
|
+
locationFields,
|
|
259
|
+
locationValues,
|
|
260
|
+
customFieldsSchema,
|
|
261
|
+
customFieldValues,
|
|
262
|
+
fixedUserType,
|
|
263
|
+
]);
|
|
204
264
|
const handleCancel = useCallback(() => {
|
|
205
265
|
const resetValues = buildInitialValues();
|
|
206
266
|
setValues(resetValues);
|
|
@@ -211,6 +271,8 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
211
271
|
});
|
|
212
272
|
setEmailTouched(false);
|
|
213
273
|
set_legal_accepted({});
|
|
274
|
+
setLocationValues({ country: "", state_province: "", suburb: "" });
|
|
275
|
+
setCustomFieldValues({});
|
|
214
276
|
}, []);
|
|
215
277
|
return {
|
|
216
278
|
values,
|
|
@@ -226,5 +288,9 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
226
288
|
handleCancel,
|
|
227
289
|
legal_accepted,
|
|
228
290
|
handleLegalAcceptedChange,
|
|
291
|
+
locationValues,
|
|
292
|
+
handleLocationFieldChange,
|
|
293
|
+
customFieldValues,
|
|
294
|
+
handleCustomFieldChange,
|
|
229
295
|
};
|
|
230
296
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type ButtonPaletteOverrides, type LayoutFieldMapOverrides, type LayoutLabelOverrides, type PasswordRequirementOverrides } from "../shared/config/layout_customization.js";
|
|
2
2
|
import { type LayoutDataClient } from "../shared/data/layout_data_client.js";
|
|
3
3
|
import type { StaticImageData } from "next/image";
|
|
4
|
+
import type { LocationFieldsConfig } from "../../../lib/location_fields_config.server";
|
|
5
|
+
import type { AppUserDataSchema } from "../../../lib/app_user_data_config.server";
|
|
4
6
|
export type OAuthLayoutConfig = {
|
|
5
7
|
/** Enable Google OAuth login */
|
|
6
8
|
enable_google: boolean;
|
|
@@ -32,6 +34,8 @@ export type RegisterLayoutProps<TClient = unknown> = {
|
|
|
32
34
|
showReturnHomeButton?: boolean;
|
|
33
35
|
returnHomeButtonLabel?: string;
|
|
34
36
|
returnHomePath?: string;
|
|
37
|
+
/** `AlreadyLoggedInGuard`'s `redirectPath` prop. Ignored in `form_only` mode. */
|
|
38
|
+
alreadyLoggedInRedirectPath?: string;
|
|
35
39
|
signInPath?: string;
|
|
36
40
|
signInLabel?: string;
|
|
37
41
|
urlOnLogon?: string;
|
|
@@ -39,6 +43,14 @@ export type RegisterLayoutProps<TClient = unknown> = {
|
|
|
39
43
|
oauth?: OAuthLayoutConfig;
|
|
40
44
|
/** Layout mode (default: `"two_column"`). See `LoginLayoutProps.layout` for the full description. */
|
|
41
45
|
layout?: "two_column" | "form_only";
|
|
46
|
+
/** Which indexed location fields to render — see [hazo_auth__custom_fields]. */
|
|
47
|
+
locationFields?: LocationFieldsConfig;
|
|
48
|
+
/** Arbitrary custom fields, reusing the existing app_user_data JSON Schema config. */
|
|
49
|
+
customFieldsSchema?: AppUserDataSchema | null;
|
|
50
|
+
/** A `user_type` fixed by the consuming page (e.g. `/register/parent` vs
|
|
51
|
+
* `/register/teacher`), sent with every submission from this form instance.
|
|
52
|
+
* Never rendered as a field — see `UseRegisterFormParams.fixedUserType`. */
|
|
53
|
+
fixedUserType?: string;
|
|
42
54
|
};
|
|
43
|
-
export default function register_layout<TClient>({ image_src, image_alt, image_background_color, field_overrides, labels, button_colors, password_requirements, show_name_field, data_client, alreadyLoggedInMessage, showLogoutButton, showReturnHomeButton, returnHomeButtonLabel, returnHomePath, signInPath, signInLabel, urlOnLogon, oauth, layout, }: RegisterLayoutProps<TClient>): import("react").JSX.Element;
|
|
55
|
+
export default function register_layout<TClient>({ image_src, image_alt, image_background_color, field_overrides, labels, button_colors, password_requirements, show_name_field, data_client, alreadyLoggedInMessage, showLogoutButton, showReturnHomeButton, returnHomeButtonLabel, returnHomePath, alreadyLoggedInRedirectPath, signInPath, signInLabel, urlOnLogon, oauth, layout, locationFields, customFieldsSchema, fixedUserType, }: RegisterLayoutProps<TClient>): import("react").JSX.Element;
|
|
44
56
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/register/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EAClC,MAAM,uCAAuC,CAAC;AAY/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/register/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EAClC,MAAM,uCAAuC,CAAC;AAY/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,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,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,qGAAqG;IACrG,MAAM,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC;IACpC,gFAAgF;IAChF,cAAc,CAAC,EAAE,oBAAoB,CAAC;IACtC,sFAAsF;IACtF,kBAAkB,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC9C;;iFAE6E;IAC7E,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAkBF,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,OAAO,EAAE,EAC/C,SAAS,EACT,SAAS,EACT,sBAAkC,EAClC,eAAe,EACf,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,eAAsB,EACtB,WAAW,EACX,sBAAsB,EACtB,gBAAuB,EACvB,oBAA4B,EAC5B,qBAAqB,EACrB,cAAoB,EACpB,2BAA2B,EAC3B,UAA+B,EAC/B,WAAW,EACX,UAAU,EACV,KAAK,EACL,MAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,aAAa,GACd,EAAE,mBAAmB,CAAC,OAAO,CAAC,+BA0W9B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// file_description: register layout component built atop shared layout utilities
|
|
2
2
|
// section: client_directive
|
|
3
3
|
"use client";
|
|
4
|
-
import { jsx as _jsx,
|
|
4
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
5
|
// section: imports
|
|
6
6
|
import { useState, useEffect } from "react";
|
|
7
7
|
import Link from "next/link";
|
|
@@ -22,6 +22,11 @@ import { use_register_form, } from "./hooks/use_register_form.js";
|
|
|
22
22
|
import { LegalDocCheckboxList } from "../legal/legal_doc_checkbox_list.js";
|
|
23
23
|
import { LegalDocCombinedView } from "../legal/legal_doc_combined_view.js";
|
|
24
24
|
import { useHazoAuthConfig, useAuthT } from "../../../contexts/hazo_auth_provider.js";
|
|
25
|
+
const LOCATION_FIELD_LABELS = {
|
|
26
|
+
country: "register.field.location_country.label",
|
|
27
|
+
state_province: "register.field.location_state_province.label",
|
|
28
|
+
suburb: "register.field.location_suburb.label",
|
|
29
|
+
};
|
|
25
30
|
const ORDERED_FIELDS = [
|
|
26
31
|
REGISTER_FIELD_IDS.NAME,
|
|
27
32
|
REGISTER_FIELD_IDS.EMAIL,
|
|
@@ -29,7 +34,7 @@ const ORDERED_FIELDS = [
|
|
|
29
34
|
REGISTER_FIELD_IDS.CONFIRM_PASSWORD,
|
|
30
35
|
];
|
|
31
36
|
// section: component
|
|
32
|
-
export default function register_layout({ image_src, image_alt, image_background_color = "#f1f5f9", field_overrides, labels, button_colors, password_requirements, show_name_field = true, data_client, alreadyLoggedInMessage, showLogoutButton = true, showReturnHomeButton = false, returnHomeButtonLabel, returnHomePath = "/", signInPath = "/hazo_auth/login", signInLabel, urlOnLogon, oauth, layout = "two_column", }) {
|
|
37
|
+
export default function register_layout({ image_src, image_alt, image_background_color = "#f1f5f9", field_overrides, labels, button_colors, password_requirements, show_name_field = true, data_client, alreadyLoggedInMessage, showLogoutButton = true, showReturnHomeButton = false, returnHomeButtonLabel, returnHomePath = "/", alreadyLoggedInRedirectPath, signInPath = "/hazo_auth/login", signInLabel, urlOnLogon, oauth, layout = "two_column", locationFields, customFieldsSchema, fixedUserType, }) {
|
|
33
38
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
34
39
|
const t = useAuthT();
|
|
35
40
|
const resolvedAlreadyLoggedInMessage = alreadyLoggedInMessage !== null && alreadyLoggedInMessage !== void 0 ? alreadyLoggedInMessage : t("shared.guard.already_logged_in_prop_default");
|
|
@@ -97,7 +102,24 @@ export default function register_layout({ image_src, image_alt, image_background
|
|
|
97
102
|
dataClient: data_client,
|
|
98
103
|
urlOnLogon: effectiveUrlOnLogon,
|
|
99
104
|
legalDocs: legal_docs,
|
|
105
|
+
locationFields,
|
|
106
|
+
customFieldsSchema,
|
|
107
|
+
fixedUserType,
|
|
100
108
|
});
|
|
109
|
+
// Additive, below the fixed name/email/password fields — never merged into
|
|
110
|
+
// REGISTER_FIELD_IDS's closed union (see use_register_form.ts's doc comment).
|
|
111
|
+
const renderLocationAndCustomFields = () => {
|
|
112
|
+
const enabledLocationKeys = ["country", "state_province", "suburb"].filter((key) => locationFields === null || locationFields === void 0 ? void 0 : locationFields[key]);
|
|
113
|
+
const customEntries = customFieldsSchema
|
|
114
|
+
? Object.entries(customFieldsSchema.properties).filter(([, def]) => def.type !== "object")
|
|
115
|
+
: [];
|
|
116
|
+
if (enabledLocationKeys.length === 0 && customEntries.length === 0)
|
|
117
|
+
return null;
|
|
118
|
+
return (_jsxs(_Fragment, { children: [enabledLocationKeys.map((key) => (_jsx(FormFieldWrapper, { fieldId: `register_location_${key}`, label: t(LOCATION_FIELD_LABELS[key]), input: _jsx(Input, { id: `register_location_${key}`, type: "text", value: form.locationValues[key], onChange: (event) => form.handleLocationFieldChange(key, event.target.value), className: "cls_register_layout_field_input" }) }, key))), customEntries.map(([key, def]) => {
|
|
119
|
+
var _a;
|
|
120
|
+
return (_jsx(FormFieldWrapper, { fieldId: `register_custom_${key}`, label: key, input: def.type === "boolean" ? (_jsx("input", { id: `register_custom_${key}`, type: "checkbox", checked: form.customFieldValues[key] === "true", onChange: (event) => form.handleCustomFieldChange(key, event.target.checked ? "true" : "false"), className: "cls_register_layout_custom_field_checkbox" })) : (_jsx(Input, { id: `register_custom_${key}`, type: def.type === "number" ? "number" : "text", value: (_a = form.customFieldValues[key]) !== null && _a !== void 0 ? _a : "", onChange: (event) => form.handleCustomFieldChange(key, event.target.value), className: "cls_register_layout_field_input" })) }, key));
|
|
121
|
+
})] }));
|
|
122
|
+
};
|
|
101
123
|
const renderFields = (formState) => {
|
|
102
124
|
const renderOrder = ORDERED_FIELDS.filter((fieldId) => show_name_field || fieldId !== REGISTER_FIELD_IDS.NAME);
|
|
103
125
|
return renderOrder.map((fieldId) => {
|
|
@@ -124,7 +146,7 @@ export default function register_layout({ image_src, image_alt, image_background
|
|
|
124
146
|
// Form content — used in both layout modes. See `login_layout` for the
|
|
125
147
|
// rationale: keeps the form independent of TwoColumnAuthLayout / AuthPageShell
|
|
126
148
|
// so consumers can compose it into their own brand chrome.
|
|
127
|
-
const mainContent = (_jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), oauthError && (_jsxs("div", { className: "cls_register_layout_oauth_error flex items-center gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700", children: [_jsx(AlertCircle, { className: "h-4 w-4 shrink-0", "aria-hidden": "true" }), _jsx("span", { children: getOAuthErrorMessage(oauthError) })] })), oauthConfig.enable_google && (_jsx("div", { className: "cls_register_layout_oauth_section", children: _jsx(GoogleSignInButton, { label: oauthConfig.google_button_text, callbackUrl: oauthCallbackUrl }) })), oauthConfig.enable_facebook_oauth && (_jsx("div", { className: "cls_register_layout_facebook_section", children: _jsx(FacebookSignInButton, { label: oauthConfig.facebook_button_text || t("shared.oauth.facebook_button_default"), callbackUrl: "/api/hazo_auth/oauth/facebook/callback" }) })), (oauthConfig.enable_google || oauthConfig.enable_facebook_oauth) && oauthConfig.enable_email_password && (_jsx(OAuthDivider, { text: oauthConfig.oauth_divider_text })), oauthConfig.enable_email_password && (_jsxs("form", { className: "cls_register_layout_form_fields flex flex-col gap-5", onSubmit: form.handleSubmit, "aria-label": t("register.aria.form"), children: [renderFields(form), legal_docs.length > 0 && (_jsx("div", { className: "space-y-2", children: legal_display_mode === 'combined' ? (_jsx(LegalDocCombinedView, { docs: legal_docs, accepted: legal_docs.every(doc => form.legal_accepted[doc.key]), onAcceptedChange: (value) => legal_docs.forEach(doc => form.handleLegalAcceptedChange(doc.key, value)) })) : (_jsx(LegalDocCheckboxList, { docs: legal_docs, accepted: form.legal_accepted, onAcceptedChange: form.handleLegalAcceptedChange })) })), _jsx(FormActionButtons, { submitLabel: resolvedLabels.submitButton, cancelLabel: resolvedLabels.cancelButton, buttonPalette: resolvedButtonPalette, isSubmitDisabled: form.isSubmitDisabled, onCancel: form.handleCancel, submitAriaLabel: t("register.aria.submit"), cancelAriaLabel: t("register.aria.cancel") }), _jsxs("div", { className: "cls_register_layout_sign_in_link flex items-center justify-center gap-1 text-sm text-muted-foreground", children: [_jsx("span", { children: t("register.sign_in_prompt") }), _jsx(Link, { href: signInPath, className: "cls_register_layout_sign_in_link_text text-primary underline-offset-4 hover:underline", "aria-label": t("register.aria.sign_in_link"), children: resolvedSignInLabel })] }), form.isSubmitting && (_jsx("div", { className: "cls_register_submitting_indicator text-sm text-slate-600 text-center", children: t("register.submitting_indicator") }))] })), !oauthConfig.enable_email_password && (oauthConfig.enable_google || oauthConfig.enable_facebook_oauth) && (_jsxs("div", { className: "cls_register_layout_sign_in_link mt-4 flex items-center justify-center gap-1 text-sm text-muted-foreground", children: [_jsx("span", { children: t("register.sign_in_prompt") }), _jsx(Link, { href: signInPath, className: "cls_register_layout_sign_in_link_text text-primary underline-offset-4 hover:underline", "aria-label": t("register.aria.sign_in_link"), children: resolvedSignInLabel })] }))] }));
|
|
149
|
+
const mainContent = (_jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), oauthError && (_jsxs("div", { className: "cls_register_layout_oauth_error flex items-center gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700", children: [_jsx(AlertCircle, { className: "h-4 w-4 shrink-0", "aria-hidden": "true" }), _jsx("span", { children: getOAuthErrorMessage(oauthError) })] })), oauthConfig.enable_google && (_jsx("div", { className: "cls_register_layout_oauth_section", children: _jsx(GoogleSignInButton, { label: oauthConfig.google_button_text, callbackUrl: oauthCallbackUrl }) })), oauthConfig.enable_facebook_oauth && (_jsx("div", { className: "cls_register_layout_facebook_section", children: _jsx(FacebookSignInButton, { label: oauthConfig.facebook_button_text || t("shared.oauth.facebook_button_default"), callbackUrl: "/api/hazo_auth/oauth/facebook/callback" }) })), (oauthConfig.enable_google || oauthConfig.enable_facebook_oauth) && oauthConfig.enable_email_password && (_jsx(OAuthDivider, { text: oauthConfig.oauth_divider_text })), oauthConfig.enable_email_password && (_jsxs("form", { className: "cls_register_layout_form_fields flex flex-col gap-5", onSubmit: form.handleSubmit, "aria-label": t("register.aria.form"), children: [renderFields(form), renderLocationAndCustomFields(), legal_docs.length > 0 && (_jsx("div", { className: "space-y-2", children: legal_display_mode === 'combined' ? (_jsx(LegalDocCombinedView, { docs: legal_docs, accepted: legal_docs.every(doc => form.legal_accepted[doc.key]), onAcceptedChange: (value) => legal_docs.forEach(doc => form.handleLegalAcceptedChange(doc.key, value)) })) : (_jsx(LegalDocCheckboxList, { docs: legal_docs, accepted: form.legal_accepted, onAcceptedChange: form.handleLegalAcceptedChange })) })), _jsx(FormActionButtons, { submitLabel: resolvedLabels.submitButton, cancelLabel: resolvedLabels.cancelButton, buttonPalette: resolvedButtonPalette, isSubmitDisabled: form.isSubmitDisabled, onCancel: form.handleCancel, submitAriaLabel: t("register.aria.submit"), cancelAriaLabel: t("register.aria.cancel") }), _jsxs("div", { className: "cls_register_layout_sign_in_link flex items-center justify-center gap-1 text-sm text-muted-foreground", children: [_jsx("span", { children: t("register.sign_in_prompt") }), _jsx(Link, { href: signInPath, className: "cls_register_layout_sign_in_link_text text-primary underline-offset-4 hover:underline", "aria-label": t("register.aria.sign_in_link"), children: resolvedSignInLabel })] }), form.isSubmitting && (_jsx("div", { className: "cls_register_submitting_indicator text-sm text-slate-600 text-center", children: t("register.submitting_indicator") }))] })), !oauthConfig.enable_email_password && (oauthConfig.enable_google || oauthConfig.enable_facebook_oauth) && (_jsxs("div", { className: "cls_register_layout_sign_in_link mt-4 flex items-center justify-center gap-1 text-sm text-muted-foreground", children: [_jsx("span", { children: t("register.sign_in_prompt") }), _jsx(Link, { href: signInPath, className: "cls_register_layout_sign_in_link_text text-primary underline-offset-4 hover:underline", "aria-label": t("register.aria.sign_in_link"), children: resolvedSignInLabel })] }))] }));
|
|
128
150
|
// form_only mode: emit just the form content. See login_layout for the
|
|
129
151
|
// rationale; AlreadyLoggedInGuard is intentionally skipped here.
|
|
130
152
|
// The wrapper below mirrors TwoColumnAuthLayout's own form container
|
|
@@ -135,7 +157,7 @@ export default function register_layout({ image_src, image_alt, image_background
|
|
|
135
157
|
if (layout === "form_only") {
|
|
136
158
|
return (_jsx("div", { className: "cls_register_layout_form_only_container mx-auto flex w-full max-w-sm flex-col gap-6", children: mainContent }));
|
|
137
159
|
}
|
|
138
|
-
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: resolvedAlreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: mainContent }) }));
|
|
160
|
+
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: resolvedAlreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, redirectPath: alreadyLoggedInRedirectPath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: mainContent }) }));
|
|
139
161
|
}
|
|
140
162
|
// Same-origin path validator. See login/index.tsx for the rationale.
|
|
141
163
|
function isSafeRedirectPath(value) {
|
|
@@ -15,10 +15,12 @@ export type ResetPasswordLayoutProps<TClient = unknown> = {
|
|
|
15
15
|
showReturnHomeButton?: boolean;
|
|
16
16
|
returnHomeButtonLabel?: string;
|
|
17
17
|
returnHomePath?: string;
|
|
18
|
+
/** `AlreadyLoggedInGuard`'s `redirectPath` prop. */
|
|
19
|
+
alreadyLoggedInRedirectPath?: string;
|
|
18
20
|
errorMessage?: string;
|
|
19
21
|
successMessage?: string;
|
|
20
22
|
loginPath?: string;
|
|
21
23
|
forgotPasswordPath?: string;
|
|
22
24
|
};
|
|
23
|
-
export default function reset_password_layout<TClient>({ image_src, image_alt, image_background_color, field_overrides, labels, button_colors, password_requirements, data_client, alreadyLoggedInMessage, showLogoutButton, showReturnHomeButton, returnHomeButtonLabel, returnHomePath, errorMessage, successMessage, loginPath, forgotPasswordPath, }: ResetPasswordLayoutProps<TClient>): import("react").JSX.Element;
|
|
25
|
+
export default function reset_password_layout<TClient>({ image_src, image_alt, image_background_color, field_overrides, labels, button_colors, password_requirements, data_client, alreadyLoggedInMessage, showLogoutButton, showReturnHomeButton, returnHomeButtonLabel, returnHomePath, alreadyLoggedInRedirectPath, errorMessage, successMessage, loginPath, forgotPasswordPath, }: ResetPasswordLayoutProps<TClient>): import("react").JSX.Element;
|
|
24
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/reset_password/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAOlD,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EAClC,MAAM,uCAAuC,CAAC;AAY/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAK1E,MAAM,MAAM,wBAAwB,CAAC,OAAO,GAAG,OAAO,IAAI;IACxD,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,qBAAqB,CAAC,EAAE,4BAA4B,CAAC;IACrD,WAAW,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACvC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAUF,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,OAAO,EAAE,EACrD,SAAS,EACT,SAAS,EACT,sBAAkC,EAClC,eAAe,EACf,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,WAAW,EACX,sBAAsB,EACtB,gBAAuB,EACvB,oBAA4B,EAC5B,qBAAqB,EACrB,cAAoB,EACpB,YAAY,EACZ,cAAc,EACd,SAA8B,EAC9B,kBAAiD,GAClD,EAAE,wBAAwB,CAAC,OAAO,CAAC,+
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/reset_password/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAOlD,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EAClC,MAAM,uCAAuC,CAAC;AAY/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAK1E,MAAM,MAAM,wBAAwB,CAAC,OAAO,GAAG,OAAO,IAAI;IACxD,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,qBAAqB,CAAC,EAAE,4BAA4B,CAAC;IACrD,WAAW,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACvC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oDAAoD;IACpD,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAUF,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,OAAO,EAAE,EACrD,SAAS,EACT,SAAS,EACT,sBAAkC,EAClC,eAAe,EACf,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,WAAW,EACX,sBAAsB,EACtB,gBAAuB,EACvB,oBAA4B,EAC5B,qBAAqB,EACrB,cAAoB,EACpB,2BAA2B,EAC3B,YAAY,EACZ,cAAc,EACd,SAA8B,EAC9B,kBAAiD,GAClD,EAAE,wBAAwB,CAAC,OAAO,CAAC,+BA8NnC"}
|
|
@@ -19,7 +19,7 @@ const ORDERED_FIELDS = [
|
|
|
19
19
|
RESET_PASSWORD_FIELD_IDS.CONFIRM_PASSWORD,
|
|
20
20
|
];
|
|
21
21
|
// section: component
|
|
22
|
-
export default function reset_password_layout({ image_src, image_alt, image_background_color = "#f1f5f9", field_overrides, labels, button_colors, password_requirements, data_client, alreadyLoggedInMessage, showLogoutButton = true, showReturnHomeButton = false, returnHomeButtonLabel, returnHomePath = "/", errorMessage, successMessage, loginPath = "/hazo_auth/login", forgotPasswordPath = "/hazo_auth/forgot_password", }) {
|
|
22
|
+
export default function reset_password_layout({ image_src, image_alt, image_background_color = "#f1f5f9", field_overrides, labels, button_colors, password_requirements, data_client, alreadyLoggedInMessage, showLogoutButton = true, showReturnHomeButton = false, returnHomeButtonLabel, returnHomePath = "/", alreadyLoggedInRedirectPath, errorMessage, successMessage, loginPath = "/hazo_auth/login", forgotPasswordPath = "/hazo_auth/forgot_password", }) {
|
|
23
23
|
const t = useAuthT();
|
|
24
24
|
const resolvedReturnHomeButtonLabel = returnHomeButtonLabel !== null && returnHomeButtonLabel !== void 0 ? returnHomeButtonLabel : t("shared.guard.return_home_default");
|
|
25
25
|
const resolvedErrorMessage = errorMessage !== null && errorMessage !== void 0 ? errorMessage : t("reset_password.link_invalid_message");
|
|
@@ -44,15 +44,15 @@ export default function reset_password_layout({ image_src, image_alt, image_back
|
|
|
44
44
|
};
|
|
45
45
|
// Show success message if password reset was successful
|
|
46
46
|
if (form.isSuccess) {
|
|
47
|
-
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: alreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), _jsxs("div", { className: "cls_reset_password_layout_success flex flex-col items-center justify-center gap-4 p-8 text-center", children: [_jsx(CheckCircle, { className: "cls_reset_password_layout_success_icon h-16 w-16 text-green-600", "aria-hidden": "true" }), _jsx("p", { className: "cls_reset_password_layout_success_message text-lg font-medium text-slate-900", children: resolvedSuccessMessage })] })] }) }) }));
|
|
47
|
+
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: alreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, redirectPath: alreadyLoggedInRedirectPath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), _jsxs("div", { className: "cls_reset_password_layout_success flex flex-col items-center justify-center gap-4 p-8 text-center", children: [_jsx(CheckCircle, { className: "cls_reset_password_layout_success_icon h-16 w-16 text-green-600", "aria-hidden": "true" }), _jsx("p", { className: "cls_reset_password_layout_success_message text-lg font-medium text-slate-900", children: resolvedSuccessMessage })] })] }) }) }));
|
|
48
48
|
}
|
|
49
49
|
// Show loading state while validating token
|
|
50
50
|
if (form.isValidatingToken) {
|
|
51
|
-
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: alreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs("div", { className: "cls_reset_password_layout_validating flex flex-col items-center justify-center gap-4 py-8", children: [_jsx(Loader2, { className: "h-12 w-12 animate-spin text-slate-600", "aria-hidden": "true" }), _jsxs("div", { className: "cls_reset_password_layout_validating_text text-center", children: [_jsx("h1", { className: "cls_reset_password_layout_validating_heading text-2xl font-semibold text-slate-900", children: resolvedLabels.heading }), _jsx("p", { className: "cls_reset_password_layout_validating_subheading mt-2 text-sm text-slate-600", children: t("reset_password.validating_message") })] })] }) }) }));
|
|
51
|
+
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: alreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, redirectPath: alreadyLoggedInRedirectPath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs("div", { className: "cls_reset_password_layout_validating flex flex-col items-center justify-center gap-4 py-8", children: [_jsx(Loader2, { className: "h-12 w-12 animate-spin text-slate-600", "aria-hidden": "true" }), _jsxs("div", { className: "cls_reset_password_layout_validating_text text-center", children: [_jsx("h1", { className: "cls_reset_password_layout_validating_heading text-2xl font-semibold text-slate-900", children: resolvedLabels.heading }), _jsx("p", { className: "cls_reset_password_layout_validating_subheading mt-2 text-sm text-slate-600", children: t("reset_password.validating_message") })] })] }) }) }));
|
|
52
52
|
}
|
|
53
53
|
// Show error message if token is invalid or missing
|
|
54
54
|
if (form.tokenError || !form.token) {
|
|
55
|
-
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: alreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs("div", { className: "cls_reset_password_layout_error flex flex-col items-center justify-center gap-4 p-8 text-center", children: [_jsx(XCircle, { className: "cls_reset_password_layout_error_icon h-16 w-16 text-red-600", "aria-hidden": "true" }), _jsxs("div", { className: "cls_reset_password_layout_error_text", children: [_jsx("h1", { className: "cls_reset_password_layout_error_heading text-2xl font-semibold text-slate-900", children: t("reset_password.invalid_link_heading") }), _jsx("p", { className: "cls_reset_password_layout_error_message mt-2 text-sm text-slate-600", children: form.tokenError || resolvedErrorMessage })] }), _jsx(Link, { href: forgotPasswordPath, className: "cls_reset_password_layout_forgot_password_link mt-4 text-sm text-blue-600 hover:text-blue-800 underline", children: t("reset_password.invalid_link_page_link") })] }) }) }));
|
|
55
|
+
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: alreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, redirectPath: alreadyLoggedInRedirectPath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs("div", { className: "cls_reset_password_layout_error flex flex-col items-center justify-center gap-4 p-8 text-center", children: [_jsx(XCircle, { className: "cls_reset_password_layout_error_icon h-16 w-16 text-red-600", "aria-hidden": "true" }), _jsxs("div", { className: "cls_reset_password_layout_error_text", children: [_jsx("h1", { className: "cls_reset_password_layout_error_heading text-2xl font-semibold text-slate-900", children: t("reset_password.invalid_link_heading") }), _jsx("p", { className: "cls_reset_password_layout_error_message mt-2 text-sm text-slate-600", children: form.tokenError || resolvedErrorMessage })] }), _jsx(Link, { href: forgotPasswordPath, className: "cls_reset_password_layout_forgot_password_link mt-4 text-sm text-blue-600 hover:text-blue-800 underline", children: t("reset_password.invalid_link_page_link") })] }) }) }));
|
|
56
56
|
}
|
|
57
|
-
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: alreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), _jsxs("form", { className: "cls_reset_password_layout_form_fields flex flex-col gap-5", onSubmit: form.handleSubmit, "aria-label": t("reset_password.aria.form"), children: [renderFields(form), _jsx(FormActionButtons, { submitLabel: resolvedLabels.submitButton, cancelLabel: resolvedLabels.cancelButton, buttonPalette: resolvedButtonPalette, isSubmitDisabled: form.isSubmitDisabled, onCancel: form.handleCancel, submitAriaLabel: t("reset_password.aria.submit"), cancelAriaLabel: t("reset_password.aria.cancel") }), form.isSubmitting && (_jsx("div", { className: "cls_reset_password_layout_submitting_indicator text-sm text-slate-600 text-center", children: t("reset_password.submitting_indicator") }))] })] }) }) }));
|
|
57
|
+
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: alreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, redirectPath: alreadyLoggedInRedirectPath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: _jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), _jsxs("form", { className: "cls_reset_password_layout_form_fields flex flex-col gap-5", onSubmit: form.handleSubmit, "aria-label": t("reset_password.aria.form"), children: [renderFields(form), _jsx(FormActionButtons, { submitLabel: resolvedLabels.submitButton, cancelLabel: resolvedLabels.cancelButton, buttonPalette: resolvedButtonPalette, isSubmitDisabled: form.isSubmitDisabled, onCancel: form.handleCancel, submitAriaLabel: t("reset_password.aria.submit"), cancelAriaLabel: t("reset_password.aria.cancel") }), form.isSubmitting && (_jsx("div", { className: "cls_reset_password_layout_submitting_indicator text-sm text-slate-600 text-center", children: t("reset_password.submitting_indicator") }))] })] }) }) }));
|
|
58
58
|
}
|
|
@@ -11,6 +11,9 @@ export type AuthStatusData = {
|
|
|
11
11
|
image?: string;
|
|
12
12
|
profile_source?: "upload" | "library" | "gravatar" | "custom";
|
|
13
13
|
preferred_locale?: string | null;
|
|
14
|
+
country?: string | null;
|
|
15
|
+
state_province?: string | null;
|
|
16
|
+
suburb?: string | null;
|
|
14
17
|
permissions?: string[];
|
|
15
18
|
permission_ok?: boolean;
|
|
16
19
|
missing_permissions?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_auth_status.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/shared/hooks/use_auth_status.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,cAAc,GAAG;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IAE9D,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"use_auth_status.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/shared/hooks/use_auth_status.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,cAAc,GAAG;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,aAAa,CAAC,EAAE,MAAM,CAA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