hazo_auth 10.26.1 → 10.27.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_types.ts +6 -0
- package/cli-src/lib/auth/hazo_get_auth.server.ts +1 -0
- package/cli-src/lib/services/registration_service.ts +29 -4
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts +0 -8
- 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 +0 -37
- package/dist/components/layouts/my_settings/index.d.ts +1 -6
- 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 +1 -15
- package/dist/components/layouts/register/hooks/use_register_form.d.ts.map +1 -1
- package/dist/components/layouts/register/hooks/use_register_form.js +4 -69
- package/dist/components/layouts/register/index.d.ts +1 -7
- package/dist/components/layouts/register/index.d.ts.map +1 -1
- package/dist/components/layouts/register/index.js +3 -24
- package/dist/components/layouts/shared/hooks/use_auth_status.d.ts +0 -3
- package/dist/components/layouts/shared/hooks/use_auth_status.d.ts.map +1 -1
- package/dist/components/layouts/shared/hooks/use_auth_status.js +2 -5
- 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 +3 -4
- 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 +1 -2
- 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 +1 -27
- package/dist/components/ui/input-otp.d.ts.map +1 -1
- package/dist/components/ui/label.d.ts +1 -2
- 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 +1 -2
- 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 +1 -2
- 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 +1 -2
- 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_types.d.ts +0 -3
- 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 +0 -3
- package/dist/lib/my_settings_config.server.d.ts +0 -4
- package/dist/lib/my_settings_config.server.d.ts.map +1 -1
- package/dist/lib/my_settings_config.server.js +0 -3
- package/dist/lib/register_config.server.d.ts +0 -10
- package/dist/lib/register_config.server.d.ts.map +1 -1
- package/dist/lib/register_config.server.js +0 -7
- package/dist/lib/services/registration_service.d.ts +11 -0
- package/dist/lib/services/registration_service.d.ts.map +1 -1
- package/dist/lib/services/registration_service.js +0 -11
- package/dist/lib/services/user_update_service.d.ts +0 -5
- package/dist/lib/services/user_update_service.d.ts.map +1 -1
- package/dist/lib/services/user_update_service.js +0 -2
- package/dist/locales/en.json +0 -9
- package/dist/page_components/my_settings.d.ts +1 -9
- package/dist/page_components/my_settings.d.ts.map +1 -1
- package/dist/page_components/my_settings.js +2 -8
- package/dist/server/routes/me.d.ts.map +1 -1
- package/dist/server/routes/me.js +1 -5
- package/dist/server/routes/register.d.ts.map +1 -1
- package/dist/server/routes/register.js +0 -46
- package/dist/server/routes/update_user.d.ts.map +1 -1
- package/dist/server/routes/update_user.js +1 -24
- package/dist/server/routes/user_management_users.d.ts +1 -1
- 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.map +1 -1
- package/dist/server_pages/register.js +1 -1
- package/dist/server_pages/register_client_wrapper.d.ts +2 -4
- package/dist/server_pages/register_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/register_client_wrapper.js +2 -2
- package/package.json +14 -14
|
@@ -25,6 +25,12 @@ export type HazoAuthUser = {
|
|
|
25
25
|
country: string | null;
|
|
26
26
|
state_province: string | null;
|
|
27
27
|
suburb: string | null;
|
|
28
|
+
// The type key from [hazo_auth__user_types] (e.g. "parent", "teacher"), or
|
|
29
|
+
// null when the feature is disabled, unset for this user, or the user
|
|
30
|
+
// predates activation. See user_types_config.server.ts for the config
|
|
31
|
+
// shape and get_user_type_by_key() for resolving this to a display
|
|
32
|
+
// label/badge color.
|
|
33
|
+
user_type: string | null;
|
|
28
34
|
};
|
|
29
35
|
|
|
30
36
|
/**
|
|
@@ -210,6 +210,7 @@ async function fetch_user_data_from_db(user_id: string): Promise<{
|
|
|
210
210
|
country: (user_db.country as string | null | undefined) || null,
|
|
211
211
|
state_province: (user_db.state_province as string | null | undefined) || null,
|
|
212
212
|
suburb: (user_db.suburb as string | null | undefined) || null,
|
|
213
|
+
user_type: (user_db.user_type as string | null | undefined) || null,
|
|
213
214
|
};
|
|
214
215
|
|
|
215
216
|
// v5.x: Fetch user's roles from hazo_user_scopes (scope-based role assignments)
|
|
@@ -15,6 +15,7 @@ import { get_filename, get_line_number } from "../utils/api_route_helpers.js";
|
|
|
15
15
|
import {
|
|
16
16
|
is_user_types_enabled,
|
|
17
17
|
get_default_user_type,
|
|
18
|
+
get_user_type_by_key,
|
|
18
19
|
} from "../user_types_config.server.js";
|
|
19
20
|
import { write_legal_acceptance } from "../legal/legal_docs_service.js";
|
|
20
21
|
import { fire_auth_hook } from "../auth_hooks.js";
|
|
@@ -38,6 +39,17 @@ export type RegistrationData = {
|
|
|
38
39
|
* existing `app_user_data` JSONB column via `update_app_user_data()` — no new
|
|
39
40
|
* column or config parser for these; see register_config.server.ts. */
|
|
40
41
|
custom_fields?: Record<string, unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* Explicit user type for this registration (e.g. a consumer with separate
|
|
44
|
+
* `/register/parent` and `/register/teacher` entry points, each setting a
|
|
45
|
+
* different type). Only takes effect when `[hazo_auth__user_types]`'s
|
|
46
|
+
* `enable_user_types` is on, and must match a configured `user_type_N` key
|
|
47
|
+
* — an unknown key fails the registration with `error: "Invalid user
|
|
48
|
+
* type"` rather than silently falling back to the config default.
|
|
49
|
+
* Omitted = fall back to `[hazo_auth__user_types].default_user_type`, same
|
|
50
|
+
* as before this field existed.
|
|
51
|
+
*/
|
|
52
|
+
user_type?: string;
|
|
41
53
|
};
|
|
42
54
|
|
|
43
55
|
export type RegistrationResult = {
|
|
@@ -123,11 +135,24 @@ export async function register_user(
|
|
|
123
135
|
}
|
|
124
136
|
}
|
|
125
137
|
|
|
126
|
-
// Set
|
|
138
|
+
// Set the user's type if the feature is enabled: an explicit `data.user_type`
|
|
139
|
+
// takes precedence over the configured default (validated against the
|
|
140
|
+
// configured type list either way — an unknown key is a registration
|
|
141
|
+
// error, not a silent fallback to the default).
|
|
127
142
|
if (is_user_types_enabled()) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
143
|
+
if (data.user_type !== undefined) {
|
|
144
|
+
if (!get_user_type_by_key(data.user_type)) {
|
|
145
|
+
return {
|
|
146
|
+
success: false,
|
|
147
|
+
error: "Invalid user type",
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
insert_data.user_type = data.user_type;
|
|
151
|
+
} else {
|
|
152
|
+
const default_type = get_default_user_type();
|
|
153
|
+
if (default_type) {
|
|
154
|
+
insert_data.user_type = default_type;
|
|
155
|
+
}
|
|
131
156
|
}
|
|
132
157
|
}
|
|
133
158
|
|
|
@@ -19,9 +19,6 @@ export type UseMySettingsResult = {
|
|
|
19
19
|
profilePictureUrl?: string;
|
|
20
20
|
profileSource?: "upload" | "library" | "gravatar" | "custom";
|
|
21
21
|
preferredLocale?: string | null;
|
|
22
|
-
country?: string | null;
|
|
23
|
-
stateProvince?: string | null;
|
|
24
|
-
suburb?: string | null;
|
|
25
22
|
lastLogon?: string;
|
|
26
23
|
loading: boolean;
|
|
27
24
|
authProviders?: string;
|
|
@@ -40,11 +37,6 @@ export type UseMySettingsResult = {
|
|
|
40
37
|
handleNameSave: (value: string) => Promise<void>;
|
|
41
38
|
handleEmailSave: (value: string) => Promise<void>;
|
|
42
39
|
handlePreferredLocaleSave: (localeCode: string) => Promise<void>;
|
|
43
|
-
handleLocationSave: (location: {
|
|
44
|
-
country?: string;
|
|
45
|
-
state_province?: string;
|
|
46
|
-
suburb?: string;
|
|
47
|
-
}) => Promise<void>;
|
|
48
40
|
refreshUserData: () => Promise<void>;
|
|
49
41
|
};
|
|
50
42
|
export type UseMySettingsParams = {
|
|
@@ -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,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,
|
|
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,iB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O,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,CA0X3C"}
|
|
@@ -56,9 +56,6 @@ 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;
|
|
62
59
|
const lastLogon = authStatus.last_logon;
|
|
63
60
|
const loading = authStatus.loading;
|
|
64
61
|
// OAuth-related data
|
|
@@ -172,36 +169,6 @@ export function use_my_settings({ passwordRequirements, t, }) {
|
|
|
172
169
|
throw error;
|
|
173
170
|
}
|
|
174
171
|
}, [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]);
|
|
205
172
|
/**
|
|
206
173
|
* Handles password field change
|
|
207
174
|
*/
|
|
@@ -385,9 +352,6 @@ export function use_my_settings({ passwordRequirements, t, }) {
|
|
|
385
352
|
profilePictureUrl,
|
|
386
353
|
profileSource,
|
|
387
354
|
preferredLocale,
|
|
388
|
-
country,
|
|
389
|
-
stateProvince,
|
|
390
|
-
suburb,
|
|
391
355
|
lastLogon,
|
|
392
356
|
loading,
|
|
393
357
|
// OAuth-related data
|
|
@@ -408,7 +372,6 @@ export function use_my_settings({ passwordRequirements, t, }) {
|
|
|
408
372
|
handleNameSave,
|
|
409
373
|
handleEmailSave,
|
|
410
374
|
handlePreferredLocaleSave,
|
|
411
|
-
handleLocationSave,
|
|
412
375
|
refreshUserData,
|
|
413
376
|
};
|
|
414
377
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
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";
|
|
5
4
|
export type MySettingsLayoutProps = {
|
|
6
5
|
className?: string;
|
|
7
6
|
labels?: MySettingsLabelOverrides;
|
|
@@ -21,10 +20,6 @@ export type MySettingsLayoutProps = {
|
|
|
21
20
|
show_email_field: boolean;
|
|
22
21
|
show_password_field: boolean;
|
|
23
22
|
};
|
|
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;
|
|
28
23
|
unauthorizedMessage?: string;
|
|
29
24
|
loginButtonLabel?: string;
|
|
30
25
|
loginPath?: string;
|
|
@@ -79,5 +74,5 @@ export type MySettingsLayoutProps = {
|
|
|
79
74
|
* @param props - Component props including labels, button colors, password requirements, etc.
|
|
80
75
|
* @returns My settings layout component
|
|
81
76
|
*/
|
|
82
|
-
export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields,
|
|
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;
|
|
83
78
|
//# 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,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,uCAAuC,CAAC;
|
|
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,mCAAmC,CA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E,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,EAAE;QACR,6BAA6B,EAAE,MAAM,CAAC;QACtC,sBAAsB,EAAE,MAAM,CAAC;QAC/B,2BAA2B,EAAE,MAAM,CAAC;QACpC,uBAAuB,EAAE,MAAM,CAAC;KACjC,CAAC;IACF,OAAO,EAAE;QACP,aAAa,EAAE,MAAM,CAAC;QACtB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,yBAAyB,EAAE,MAAM,CAAC;QAClC,uBAAuB,EAAE,MAAM,CAAC;QAChC,0BAA0B,EAAE,MAAM,CAAC;QACnC,0BAA0B,EAAE,MAAM,CAAC;QACnC,+BAA+B,EAAE,MAAM,CAAC;QACxC,4BAA4B,EAAE,MAAM,CAAC;KACtC,CAAC;IACF,SAAS,EAAE;QACT,wBAAwB,EAAE,MAAM,EAAE,CAAC;QACnC,wBAAwB,EAAE,MAAM,EAAE,CAAC;KACpC,CAAC;CACH,CAAC;AAGF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,SAAS,EACT,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,UAAU,EACV,mBAAmB,EACnB,gBAAgB,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,+BAkRvB"}
|
|
@@ -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,
|
|
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, 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;
|
|
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 })] })] }),
|
|
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: ((_a = settings.passwordFields) === null || _a === void 0 ? void 0 : _a.currentPassword) || "", placeholder: t("my_settings.current_password_placeholder_default"), autoComplete: "current-password", isVisible: ((_b = settings.passwordFields) === null || _b === void 0 ? void 0 : _b.currentPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("currentPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("currentPassword"), errorMessage: (_d = (_c = settings.passwordFields) === null || _c === void 0 ? void 0 : _c.errors) === null || _d === void 0 ? void 0 : _d.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: ((_e = settings.passwordFields) === null || _e === void 0 ? void 0 : _e.newPassword) || "", placeholder: t("my_settings.set_password.new_password_placeholder"), autoComplete: "new-password", isVisible: ((_f = settings.passwordFields) === null || _f === void 0 ? void 0 : _f.newPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("newPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("newPassword"), errorMessage: (_h = (_g = settings.passwordFields) === null || _g === void 0 ? void 0 : _g.errors) === null || _h === void 0 ? void 0 : _h.newPassword }) }), _jsx(FormFieldWrapper, { fieldId: "confirm-password", label: resolvedConfirmPasswordLabel, input: _jsx(PasswordField, { inputId: "confirm-password", ariaLabel: resolvedConfirmPasswordLabel, value: ((_j = settings.passwordFields) === null || _j === void 0 ? void 0 : _j.confirmPassword) || "", placeholder: t("my_settings.set_password.confirm_password_placeholder"), autoComplete: "new-password", isVisible: ((_k = settings.passwordFields) === null || _k === void 0 ? void 0 : _k.confirmPasswordVisible) || false, onChange: (value) => settings.handlePasswordFieldChange("confirmPassword", value), onToggleVisibility: () => settings.togglePasswordVisibility("confirmPassword"), errorMessage: (_m = (_l = settings.passwordFields) === null || _l === void 0 ? void 0 : _l.errors) === null || _m === void 0 ? void 0 : _m.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,8 +2,6 @@ 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";
|
|
7
5
|
export type RegisterFormValues = Record<RegisterFieldId, string>;
|
|
8
6
|
export type RegisterFormErrors = Partial<Record<RegisterFieldId, string | string[]>> & {
|
|
9
7
|
submit?: string;
|
|
@@ -16,15 +14,7 @@ export type UseRegisterFormParams<TClient = unknown> = {
|
|
|
16
14
|
dataClient: LayoutDataClient<TClient>;
|
|
17
15
|
urlOnLogon?: string;
|
|
18
16
|
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
17
|
};
|
|
27
|
-
export type LocationFieldKey = "country" | "state_province" | "suburb";
|
|
28
18
|
export type UseRegisterFormResult = {
|
|
29
19
|
values: RegisterFormValues;
|
|
30
20
|
errors: RegisterFormErrors;
|
|
@@ -39,10 +29,6 @@ export type UseRegisterFormResult = {
|
|
|
39
29
|
handleCancel: () => void;
|
|
40
30
|
legal_accepted: Record<string, boolean>;
|
|
41
31
|
handleLegalAcceptedChange: (key: string, value: boolean) => void;
|
|
42
|
-
locationValues: Record<LocationFieldKey, string>;
|
|
43
|
-
handleLocationFieldChange: (field: LocationFieldKey, value: string) => void;
|
|
44
|
-
customFieldValues: Record<string, string>;
|
|
45
|
-
handleCustomFieldChange: (key: string, value: string) => void;
|
|
46
32
|
};
|
|
47
|
-
export declare const use_register_form: <TClient>({ showNameField, passwordRequirements, dataClient, urlOnLogon, legalDocs,
|
|
33
|
+
export declare const use_register_form: <TClient>({ showNameField, passwordRequirements, dataClient, urlOnLogon, legalDocs, }: UseRegisterFormParams<TClient>) => UseRegisterFormResult;
|
|
48
34
|
//# 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,0CAA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,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,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;CAClE,CAAC;AAYF,eAAO,MAAM,iBAAiB,GAAI,OAAO,EAAG,6EAMzC,qBAAqB,CAAC,OAAO,CAAC,KAAG,qBAgRnC,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, }) => {
|
|
22
22
|
const { apiBasePath } = useHazoAuthConfig();
|
|
23
23
|
const t = useAuthT();
|
|
24
24
|
const initialValues = useMemo(() => buildInitialValues(), []);
|
|
@@ -31,18 +31,6 @@ 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
|
-
}, []);
|
|
46
34
|
// Check if form has been edited (changed from initial state)
|
|
47
35
|
const isFormEdited = useMemo(() => {
|
|
48
36
|
return Object.entries(values).some(([fieldId, fieldValue]) => {
|
|
@@ -170,48 +158,14 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
170
158
|
.filter(doc => legal_accepted[doc.key])
|
|
171
159
|
.map(doc => [doc.key, { hash: doc.hash }]))
|
|
172
160
|
: 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
|
-
}
|
|
207
161
|
const response = await fetch(`${apiBasePath}/register`, {
|
|
208
162
|
method: "POST",
|
|
209
163
|
headers: {
|
|
210
164
|
"Content-Type": "application/json",
|
|
211
165
|
},
|
|
212
|
-
body: JSON.stringify(Object.assign(
|
|
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
|
|
213
167
|
? { legal_accepted: legal_accepted_payload }
|
|
214
|
-
: {}))
|
|
168
|
+
: {}))),
|
|
215
169
|
});
|
|
216
170
|
const data = await response.json();
|
|
217
171
|
if (!response.ok) {
|
|
@@ -231,8 +185,6 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
231
185
|
});
|
|
232
186
|
setEmailTouched(false);
|
|
233
187
|
set_legal_accepted({});
|
|
234
|
-
setLocationValues({ country: "", state_province: "", suburb: "" });
|
|
235
|
-
setCustomFieldValues({});
|
|
236
188
|
}
|
|
237
189
|
catch (error) {
|
|
238
190
|
const errorMessage = error instanceof Error ? error.message : t("register.error.failed_retry_message");
|
|
@@ -248,18 +200,7 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
248
200
|
finally {
|
|
249
201
|
setIsSubmitting(false);
|
|
250
202
|
}
|
|
251
|
-
}, [
|
|
252
|
-
values,
|
|
253
|
-
passwordRequirements,
|
|
254
|
-
dataClient,
|
|
255
|
-
urlOnLogon,
|
|
256
|
-
legalDocs,
|
|
257
|
-
legal_accepted,
|
|
258
|
-
locationFields,
|
|
259
|
-
locationValues,
|
|
260
|
-
customFieldsSchema,
|
|
261
|
-
customFieldValues,
|
|
262
|
-
]);
|
|
203
|
+
}, [values, passwordRequirements, dataClient, urlOnLogon, legalDocs, legal_accepted]);
|
|
263
204
|
const handleCancel = useCallback(() => {
|
|
264
205
|
const resetValues = buildInitialValues();
|
|
265
206
|
setValues(resetValues);
|
|
@@ -270,8 +211,6 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
270
211
|
});
|
|
271
212
|
setEmailTouched(false);
|
|
272
213
|
set_legal_accepted({});
|
|
273
|
-
setLocationValues({ country: "", state_province: "", suburb: "" });
|
|
274
|
-
setCustomFieldValues({});
|
|
275
214
|
}, []);
|
|
276
215
|
return {
|
|
277
216
|
values,
|
|
@@ -287,9 +226,5 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
287
226
|
handleCancel,
|
|
288
227
|
legal_accepted,
|
|
289
228
|
handleLegalAcceptedChange,
|
|
290
|
-
locationValues,
|
|
291
|
-
handleLocationFieldChange,
|
|
292
|
-
customFieldValues,
|
|
293
|
-
handleCustomFieldChange,
|
|
294
229
|
};
|
|
295
230
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
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";
|
|
6
4
|
export type OAuthLayoutConfig = {
|
|
7
5
|
/** Enable Google OAuth login */
|
|
8
6
|
enable_google: boolean;
|
|
@@ -41,10 +39,6 @@ export type RegisterLayoutProps<TClient = unknown> = {
|
|
|
41
39
|
oauth?: OAuthLayoutConfig;
|
|
42
40
|
/** Layout mode (default: `"two_column"`). See `LoginLayoutProps.layout` for the full description. */
|
|
43
41
|
layout?: "two_column" | "form_only";
|
|
44
|
-
/** Which indexed location fields to render — see [hazo_auth__custom_fields]. */
|
|
45
|
-
locationFields?: LocationFieldsConfig;
|
|
46
|
-
/** Arbitrary custom fields, reusing the existing app_user_data JSON Schema config. */
|
|
47
|
-
customFieldsSchema?: AppUserDataSchema | null;
|
|
48
42
|
};
|
|
49
|
-
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,
|
|
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;
|
|
50
44
|
//# 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,KA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;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,qGAAqG;IACrG,MAAM,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC;CACrC,CAAC;AAYF,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,UAA+B,EAC/B,WAAW,EACX,UAAU,EACV,KAAK,EACL,MAAqB,GACtB,EAAE,mBAAmB,CAAC,OAAO,CAAC,+BAuS9B"}
|
|
@@ -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, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
5
5
|
// section: imports
|
|
6
6
|
import { useState, useEffect } from "react";
|
|
7
7
|
import Link from "next/link";
|
|
@@ -22,11 +22,6 @@ 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
|
-
};
|
|
30
25
|
const ORDERED_FIELDS = [
|
|
31
26
|
REGISTER_FIELD_IDS.NAME,
|
|
32
27
|
REGISTER_FIELD_IDS.EMAIL,
|
|
@@ -34,7 +29,7 @@ const ORDERED_FIELDS = [
|
|
|
34
29
|
REGISTER_FIELD_IDS.CONFIRM_PASSWORD,
|
|
35
30
|
];
|
|
36
31
|
// section: component
|
|
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 = "/", signInPath = "/hazo_auth/login", signInLabel, urlOnLogon, oauth, layout = "two_column",
|
|
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", }) {
|
|
38
33
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
39
34
|
const t = useAuthT();
|
|
40
35
|
const resolvedAlreadyLoggedInMessage = alreadyLoggedInMessage !== null && alreadyLoggedInMessage !== void 0 ? alreadyLoggedInMessage : t("shared.guard.already_logged_in_prop_default");
|
|
@@ -102,23 +97,7 @@ export default function register_layout({ image_src, image_alt, image_background
|
|
|
102
97
|
dataClient: data_client,
|
|
103
98
|
urlOnLogon: effectiveUrlOnLogon,
|
|
104
99
|
legalDocs: legal_docs,
|
|
105
|
-
locationFields,
|
|
106
|
-
customFieldsSchema,
|
|
107
100
|
});
|
|
108
|
-
// Additive, below the fixed name/email/password fields — never merged into
|
|
109
|
-
// REGISTER_FIELD_IDS's closed union (see use_register_form.ts's doc comment).
|
|
110
|
-
const renderLocationAndCustomFields = () => {
|
|
111
|
-
const enabledLocationKeys = ["country", "state_province", "suburb"].filter((key) => locationFields === null || locationFields === void 0 ? void 0 : locationFields[key]);
|
|
112
|
-
const customEntries = customFieldsSchema
|
|
113
|
-
? Object.entries(customFieldsSchema.properties).filter(([, def]) => def.type !== "object")
|
|
114
|
-
: [];
|
|
115
|
-
if (enabledLocationKeys.length === 0 && customEntries.length === 0)
|
|
116
|
-
return null;
|
|
117
|
-
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]) => {
|
|
118
|
-
var _a;
|
|
119
|
-
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));
|
|
120
|
-
})] }));
|
|
121
|
-
};
|
|
122
101
|
const renderFields = (formState) => {
|
|
123
102
|
const renderOrder = ORDERED_FIELDS.filter((fieldId) => show_name_field || fieldId !== REGISTER_FIELD_IDS.NAME);
|
|
124
103
|
return renderOrder.map((fieldId) => {
|
|
@@ -145,7 +124,7 @@ export default function register_layout({ image_src, image_alt, image_background
|
|
|
145
124
|
// Form content — used in both layout modes. See `login_layout` for the
|
|
146
125
|
// rationale: keeps the form independent of TwoColumnAuthLayout / AuthPageShell
|
|
147
126
|
// so consumers can compose it into their own brand chrome.
|
|
148
|
-
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),
|
|
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
128
|
// form_only mode: emit just the form content. See login_layout for the
|
|
150
129
|
// rationale; AlreadyLoggedInGuard is intentionally skipped here.
|
|
151
130
|
// The wrapper below mirrors TwoColumnAuthLayout's own form container
|
|
@@ -11,9 +11,6 @@ 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;
|
|
17
14
|
permissions?: string[];
|
|
18
15
|
permission_ok?: boolean;
|
|
19
16
|
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,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;IACjC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,cAAc,GAAG;IACxC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,CAAC;AAMF;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAIlD;AAGD,wBAAgB,eAAe,IAAI,UAAU,CA4E5C"}
|
|
@@ -23,7 +23,7 @@ export function use_auth_status() {
|
|
|
23
23
|
loading: true,
|
|
24
24
|
});
|
|
25
25
|
const checkAuth = useCallback(async () => {
|
|
26
|
-
var _a, _b
|
|
26
|
+
var _a, _b;
|
|
27
27
|
setAuthStatus((prev) => (Object.assign(Object.assign({}, prev), { loading: true })));
|
|
28
28
|
try {
|
|
29
29
|
const response = await fetch(`${apiBasePath}/me`, {
|
|
@@ -46,11 +46,8 @@ export function use_auth_status() {
|
|
|
46
46
|
image: data.image,
|
|
47
47
|
profile_source: data.profile_source,
|
|
48
48
|
preferred_locale: (_a = data.preferred_locale) !== null && _a !== void 0 ? _a : null,
|
|
49
|
-
country: (_b = data.country) !== null && _b !== void 0 ? _b : null,
|
|
50
|
-
state_province: (_c = data.state_province) !== null && _c !== void 0 ? _c : null,
|
|
51
|
-
suburb: (_d = data.suburb) !== null && _d !== void 0 ? _d : null,
|
|
52
49
|
permissions: data.permissions || [],
|
|
53
|
-
permission_ok: (
|
|
50
|
+
permission_ok: (_b = data.permission_ok) !== null && _b !== void 0 ? _b : true,
|
|
54
51
|
missing_permissions: data.missing_permissions,
|
|
55
52
|
// OAuth-related fields
|
|
56
53
|
auth_providers: data.auth_providers,
|