hazo_auth 10.24.0 → 10.25.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 +3 -0
- package/cli-src/lib/location_fields_config.server.ts +42 -0
- package/cli-src/lib/my_settings_config.server.ts +6 -0
- package/cli-src/lib/register_config.server.ts +16 -0
- package/cli-src/lib/services/location_fields_helper.ts +30 -0
- package/cli-src/lib/services/registration_service.ts +21 -0
- package/cli-src/lib/services/user_update_service.ts +7 -0
- 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 +15 -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 +69 -4
- package/dist/components/layouts/register/index.d.ts +7 -1
- package/dist/components/layouts/register/index.d.ts.map +1 -1
- package/dist/components/layouts/register/index.js +24 -3
- 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/ui/button.d.ts +1 -1
- package/dist/lib/auth/auth_types.d.ts +3 -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 +3 -0
- package/dist/lib/location_fields_config.server.d.ts +22 -0
- package/dist/lib/location_fields_config.server.d.ts.map +1 -0
- package/dist/lib/location_fields_config.server.js +31 -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 +10 -0
- package/dist/lib/register_config.server.d.ts.map +1 -1
- package/dist/lib/register_config.server.js +7 -0
- package/dist/lib/services/location_fields_helper.d.ts +13 -0
- package/dist/lib/services/location_fields_helper.d.ts.map +1 -0
- package/dist/lib/services/location_fields_helper.js +24 -0
- package/dist/lib/services/registration_service.d.ts +9 -0
- package/dist/lib/services/registration_service.d.ts.map +1 -1
- package/dist/lib/services/registration_service.js +11 -0
- 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 +9 -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/me.d.ts.map +1 -1
- package/dist/server/routes/me.js +5 -1
- package/dist/server/routes/register.d.ts.map +1 -1
- package/dist/server/routes/register.js +46 -0
- package/dist/server/routes/update_user.d.ts.map +1 -1
- package/dist/server/routes/update_user.js +24 -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 +4 -2
- 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 +4 -4
|
@@ -19,6 +19,12 @@ export type HazoAuthUser = {
|
|
|
19
19
|
// User's explicit locale preference (BCP 47 tag, e.g. "en", "pt-BR"). NULL means
|
|
20
20
|
// no preference set — callers fall back to detection (Accept-Language, app default).
|
|
21
21
|
preferred_locale: string | null;
|
|
22
|
+
// Indexed location columns (migration 025) — null unless the consuming app has
|
|
23
|
+
// enabled the corresponding [hazo_auth__custom_fields] toggle AND the user has
|
|
24
|
+
// set a value. See location_fields_config.server.ts.
|
|
25
|
+
country: string | null;
|
|
26
|
+
state_province: string | null;
|
|
27
|
+
suburb: string | null;
|
|
22
28
|
};
|
|
23
29
|
|
|
24
30
|
/**
|
|
@@ -207,6 +207,9 @@ async function fetch_user_data_from_db(user_id: string): Promise<{
|
|
|
207
207
|
app_user_data: parse_app_user_data(user_db.app_user_data),
|
|
208
208
|
legal_acceptance: parse_legal_acceptance(user_db.legal_acceptance),
|
|
209
209
|
preferred_locale: (user_db.preferred_locale as string | null | undefined) || null,
|
|
210
|
+
country: (user_db.country as string | null | undefined) || null,
|
|
211
|
+
state_province: (user_db.state_province as string | null | undefined) || null,
|
|
212
|
+
suburb: (user_db.suburb as string | null | undefined) || null,
|
|
210
213
|
};
|
|
211
214
|
|
|
212
215
|
// v5.x: Fetch user's roles from hazo_user_scopes (scope-based role assignments)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// file_description: server-only helper to read location field toggles from hazo_auth_config.ini
|
|
2
|
+
// section: server-only-guard
|
|
3
|
+
import "server-only";
|
|
4
|
+
|
|
5
|
+
// section: imports
|
|
6
|
+
import { get_config_boolean } from "./config/config_loader.server.js";
|
|
7
|
+
|
|
8
|
+
// section: constants
|
|
9
|
+
const SECTION_NAME = "hazo_auth__custom_fields";
|
|
10
|
+
|
|
11
|
+
// section: types
|
|
12
|
+
export type LocationFieldsConfig = {
|
|
13
|
+
country: boolean;
|
|
14
|
+
state_province: boolean;
|
|
15
|
+
suburb: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// section: helpers
|
|
19
|
+
/**
|
|
20
|
+
* Reads the indexed location field toggles (country / state_province / suburb)
|
|
21
|
+
* from `[hazo_auth__custom_fields]` in hazo_auth_config.ini. All default to
|
|
22
|
+
* `false` — registration is unchanged for apps that don't opt in. These three
|
|
23
|
+
* columns are indexed (migration 025) for cohort benchmarking (GROUP BY
|
|
24
|
+
* country, state_province); arbitrary free-form fields go through the
|
|
25
|
+
* existing app_user_data schema (`get_app_user_data_schema()`) instead.
|
|
26
|
+
* @returns Which location fields are enabled
|
|
27
|
+
*/
|
|
28
|
+
export function get_location_fields_config(): LocationFieldsConfig {
|
|
29
|
+
return {
|
|
30
|
+
country: get_config_boolean(SECTION_NAME, "location_country", false),
|
|
31
|
+
state_province: get_config_boolean(SECTION_NAME, "location_state_province", false),
|
|
32
|
+
suburb: get_config_boolean(SECTION_NAME, "location_suburb", false),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* True if at least one location field is enabled — lets a consumer skip
|
|
38
|
+
* rendering an empty "Location" section entirely.
|
|
39
|
+
*/
|
|
40
|
+
export function is_any_location_field_enabled(config: LocationFieldsConfig): boolean {
|
|
41
|
+
return config.country || config.state_province || config.suburb;
|
|
42
|
+
}
|
|
@@ -10,6 +10,7 @@ import { get_profile_picture_config } from "./profile_picture_config.server.js";
|
|
|
10
10
|
import { get_messages_config } from "./messages_config.server.js";
|
|
11
11
|
import { get_ui_sizes_config } from "./ui_sizes_config.server.js";
|
|
12
12
|
import { get_file_types_config } from "./file_types_config.server.js";
|
|
13
|
+
import { get_location_fields_config, type LocationFieldsConfig } from "./location_fields_config.server.js";
|
|
13
14
|
|
|
14
15
|
// section: types
|
|
15
16
|
export type MySettingsConfig = {
|
|
@@ -18,6 +19,9 @@ export type MySettingsConfig = {
|
|
|
18
19
|
show_email_field: boolean;
|
|
19
20
|
show_password_field: boolean;
|
|
20
21
|
};
|
|
22
|
+
/** Which indexed location fields to show as an editable "Location" card —
|
|
23
|
+
* see [hazo_auth__custom_fields] in hazo_auth_config.ini. */
|
|
24
|
+
locationFields: LocationFieldsConfig;
|
|
21
25
|
passwordRequirements: {
|
|
22
26
|
minimum_length: number;
|
|
23
27
|
require_uppercase: boolean;
|
|
@@ -120,9 +124,11 @@ export function get_my_settings_config(): MySettingsConfig {
|
|
|
120
124
|
const loginButtonLabel = get_config_value_optional(section, "login_button_label");
|
|
121
125
|
const loginPath = get_config_value(section, "login_path", "/hazo_auth/login");
|
|
122
126
|
const enableAccountDeletion = get_config_boolean(section, "enable_account_deletion", false);
|
|
127
|
+
const locationFields = get_location_fields_config();
|
|
123
128
|
|
|
124
129
|
return {
|
|
125
130
|
userFields,
|
|
131
|
+
locationFields,
|
|
126
132
|
passwordRequirements,
|
|
127
133
|
profilePicture,
|
|
128
134
|
heading,
|
|
@@ -13,6 +13,8 @@ import { get_password_requirements_config } from "./password_requirements_config
|
|
|
13
13
|
import { get_already_logged_in_config } from "./already_logged_in_config.server.js";
|
|
14
14
|
import { get_user_fields_config } from "./user_fields_config.server.js";
|
|
15
15
|
import { get_oauth_config } from "./oauth_config.server.js";
|
|
16
|
+
import { get_location_fields_config, type LocationFieldsConfig } from "./location_fields_config.server.js";
|
|
17
|
+
import { get_app_user_data_schema, type AppUserDataSchema } from "./app_user_data_config.server.js";
|
|
16
18
|
|
|
17
19
|
// Default image path - consuming apps should either:
|
|
18
20
|
// 1. Configure their own image_src in hazo_auth_config.ini
|
|
@@ -49,6 +51,14 @@ export type RegisterConfig = {
|
|
|
49
51
|
enable_facebook_oauth: boolean;
|
|
50
52
|
facebook_button_text: string | undefined;
|
|
51
53
|
};
|
|
54
|
+
/** Which indexed location fields to render on the registration form — see
|
|
55
|
+
* [hazo_auth__custom_fields] in hazo_auth_config.ini. */
|
|
56
|
+
locationFields: LocationFieldsConfig;
|
|
57
|
+
/** Arbitrary custom fields to render on the registration form, reusing the
|
|
58
|
+
* EXISTING [hazo_auth__app_user_data] JSON Schema config (ticket 09 does NOT
|
|
59
|
+
* introduce a second, parallel custom-field config format). Null when
|
|
60
|
+
* schema-based app_user_data editing isn't enabled. */
|
|
61
|
+
customFieldsSchema: AppUserDataSchema | null;
|
|
52
62
|
};
|
|
53
63
|
|
|
54
64
|
// section: helpers
|
|
@@ -106,6 +116,10 @@ export function get_register_config(): RegisterConfig {
|
|
|
106
116
|
// Get OAuth configuration (shared with login)
|
|
107
117
|
const oauthConfig = get_oauth_config();
|
|
108
118
|
|
|
119
|
+
// Location + arbitrary custom fields (ticket 09)
|
|
120
|
+
const locationFields = get_location_fields_config();
|
|
121
|
+
const customFieldsSchema = get_app_user_data_schema();
|
|
122
|
+
|
|
109
123
|
// For the register page, the Google button text is undefined unless the
|
|
110
124
|
// consumer explicitly overrides it — RegisterLayout falls back to
|
|
111
125
|
// `t("register.oauth.google_button_default")` ("Sign up with Google").
|
|
@@ -135,6 +149,8 @@ export function get_register_config(): RegisterConfig {
|
|
|
135
149
|
enable_facebook_oauth: oauthConfig.enable_facebook_oauth,
|
|
136
150
|
facebook_button_text: oauthConfig.facebook_button_text,
|
|
137
151
|
},
|
|
152
|
+
locationFields,
|
|
153
|
+
customFieldsSchema,
|
|
138
154
|
};
|
|
139
155
|
}
|
|
140
156
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// file_description: pure helper shared by registration_service and user_update_service —
|
|
2
|
+
// picks and trims the three indexed location columns (country / state_province / suburb)
|
|
3
|
+
// from caller-supplied data, dropping anything undefined or blank after trimming.
|
|
4
|
+
|
|
5
|
+
// section: types
|
|
6
|
+
export type LocationFieldsInput = {
|
|
7
|
+
country?: string;
|
|
8
|
+
state_province?: string;
|
|
9
|
+
suburb?: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// section: helpers
|
|
13
|
+
/**
|
|
14
|
+
* Returns only the location fields that were actually provided and non-blank,
|
|
15
|
+
* trimmed — ready to spread straight into an `insert`/`updateById` data object.
|
|
16
|
+
* @param location - Raw location input (e.g. from a registration or settings PATCH body)
|
|
17
|
+
* @returns A sparse object with only the fields worth persisting
|
|
18
|
+
*/
|
|
19
|
+
export function build_location_fields(location: LocationFieldsInput | undefined): Record<string, string> {
|
|
20
|
+
if (!location) return {};
|
|
21
|
+
|
|
22
|
+
const result: Record<string, string> = {};
|
|
23
|
+
for (const key of ["country", "state_province", "suburb"] as const) {
|
|
24
|
+
const value = location[key];
|
|
25
|
+
if (value === undefined) continue;
|
|
26
|
+
const trimmed = value.trim();
|
|
27
|
+
if (trimmed) result[key] = trimmed;
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
} from "../user_types_config.server.js";
|
|
19
19
|
import { write_legal_acceptance } from "../legal/legal_docs_service.js";
|
|
20
20
|
import { fire_auth_hook } from "../auth_hooks.js";
|
|
21
|
+
import { build_location_fields, type LocationFieldsInput } from "./location_fields_helper.js";
|
|
22
|
+
import { update_app_user_data } from "./app_user_data_service.js";
|
|
21
23
|
|
|
22
24
|
// section: types
|
|
23
25
|
export type RegistrationData = {
|
|
@@ -28,6 +30,14 @@ export type RegistrationData = {
|
|
|
28
30
|
legal_accepted?: Record<string, { hash: string }>;
|
|
29
31
|
ip?: string | null;
|
|
30
32
|
user_agent?: string | null;
|
|
33
|
+
/** Indexed location columns — only persisted for fields enabled via
|
|
34
|
+
* `[hazo_auth__custom_fields]` (the route handler is responsible for
|
|
35
|
+
* stripping anything not enabled before calling here; see register.ts). */
|
|
36
|
+
location?: LocationFieldsInput;
|
|
37
|
+
/** Arbitrary custom fields (ticket 09's `custom_field_*` config), merged into the
|
|
38
|
+
* existing `app_user_data` JSONB column via `update_app_user_data()` — no new
|
|
39
|
+
* column or config parser for these; see register_config.server.ts. */
|
|
40
|
+
custom_fields?: Record<string, unknown>;
|
|
31
41
|
};
|
|
32
42
|
|
|
33
43
|
export type RegistrationResult = {
|
|
@@ -98,6 +108,10 @@ export async function register_user(
|
|
|
98
108
|
}
|
|
99
109
|
}
|
|
100
110
|
|
|
111
|
+
// Indexed location columns (country / state_province / suburb) — additive,
|
|
112
|
+
// no-op when `data.location` is omitted (every pre-ticket-09 caller).
|
|
113
|
+
Object.assign(insert_data, build_location_fields(data.location));
|
|
114
|
+
|
|
101
115
|
// Set default profile picture if enabled
|
|
102
116
|
const profile_picture_config = get_profile_picture_config();
|
|
103
117
|
if (profile_picture_config.user_photo_default) {
|
|
@@ -127,6 +141,13 @@ export async function register_user(
|
|
|
127
141
|
};
|
|
128
142
|
}
|
|
129
143
|
|
|
144
|
+
// Arbitrary custom fields (JSON Schema-driven, [hazo_auth__app_user_data]) —
|
|
145
|
+
// merge mode is a no-op concern here (brand new user, nothing to merge over),
|
|
146
|
+
// kept consistent with update_app_user_data()'s only mode of operation elsewhere.
|
|
147
|
+
if (data.custom_fields && Object.keys(data.custom_fields).length > 0) {
|
|
148
|
+
await update_app_user_data(adapter, user_id, data.custom_fields, { merge: true });
|
|
149
|
+
}
|
|
150
|
+
|
|
130
151
|
void fire_auth_hook("on_user_created", {
|
|
131
152
|
user_id,
|
|
132
153
|
email,
|
|
@@ -6,6 +6,7 @@ import { map_ui_source_to_db, type ProfilePictureSourceUI } from "./profile_pict
|
|
|
6
6
|
import { create_app_logger } from "../app_logger.js";
|
|
7
7
|
import { sanitize_error_for_user } from "../utils/error_sanitizer.js";
|
|
8
8
|
import { get_filename, get_line_number } from "../utils/api_route_helpers.js";
|
|
9
|
+
import { build_location_fields, type LocationFieldsInput } from "./location_fields_helper.js";
|
|
9
10
|
|
|
10
11
|
// section: types
|
|
11
12
|
export type UserUpdateData = {
|
|
@@ -17,6 +18,10 @@ export type UserUpdateData = {
|
|
|
17
18
|
// Undefined means "leave unchanged" — the caller is expected to have already validated
|
|
18
19
|
// the value (see src/server/routes/update_user.ts).
|
|
19
20
|
preferred_locale?: string | null;
|
|
21
|
+
/** Indexed location columns (My Settings' "Location" card). Only non-blank,
|
|
22
|
+
* provided fields are persisted — omitted or blank fields are left unchanged
|
|
23
|
+
* (see build_location_fields; it has no "clear" semantics). */
|
|
24
|
+
location?: LocationFieldsInput;
|
|
20
25
|
};
|
|
21
26
|
|
|
22
27
|
export type UserUpdateResult = {
|
|
@@ -115,6 +120,8 @@ export async function update_user_profile(
|
|
|
115
120
|
update_data.preferred_locale = data.preferred_locale;
|
|
116
121
|
}
|
|
117
122
|
|
|
123
|
+
Object.assign(update_data, build_location_fields(data.location));
|
|
124
|
+
|
|
118
125
|
// If email changed, set email_verified to false
|
|
119
126
|
if (email_changed) {
|
|
120
127
|
update_data.email_verified = false;
|
|
@@ -19,6 +19,9 @@ 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;
|
|
22
25
|
lastLogon?: string;
|
|
23
26
|
loading: boolean;
|
|
24
27
|
authProviders?: string;
|
|
@@ -37,6 +40,11 @@ export type UseMySettingsResult = {
|
|
|
37
40
|
handleNameSave: (value: string) => Promise<void>;
|
|
38
41
|
handleEmailSave: (value: string) => Promise<void>;
|
|
39
42
|
handlePreferredLocaleSave: (localeCode: string) => Promise<void>;
|
|
43
|
+
handleLocationSave: (location: {
|
|
44
|
+
country?: string;
|
|
45
|
+
state_province?: string;
|
|
46
|
+
suburb?: string;
|
|
47
|
+
}) => Promise<void>;
|
|
40
48
|
refreshUserData: () => Promise<void>;
|
|
41
49
|
};
|
|
42
50
|
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;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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,CAAC,EAAE,MAA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O,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,mCAAmC,CAAC;AA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AA8B,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,15 @@ 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;
|
|
17
26
|
};
|
|
27
|
+
export type LocationFieldKey = "country" | "state_province" | "suburb";
|
|
18
28
|
export type UseRegisterFormResult = {
|
|
19
29
|
values: RegisterFormValues;
|
|
20
30
|
errors: RegisterFormErrors;
|
|
@@ -29,6 +39,10 @@ export type UseRegisterFormResult = {
|
|
|
29
39
|
handleCancel: () => void;
|
|
30
40
|
legal_accepted: Record<string, boolean>;
|
|
31
41
|
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;
|
|
32
46
|
};
|
|
33
|
-
export declare const use_register_form: <TClient>({ showNameField, passwordRequirements, dataClient, urlOnLogon, legalDocs, }: UseRegisterFormParams<TClient>) => UseRegisterFormResult;
|
|
47
|
+
export declare const use_register_form: <TClient>({ showNameField, passwordRequirements, dataClient, urlOnLogon, legalDocs, locationFields, customFieldsSchema, }: UseRegisterFormParams<TClient>) => UseRegisterFormResult;
|
|
34
48
|
//# 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,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C,OAAO,CAAC,eAAe,EAAE,UAAU,GAAG,kBAAkB,CAAC,EACzD,OAAO,CACR,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,OAAO,GAAG,OAAO,IAAI;IACrD,aAAa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AK,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,iHAQzC,qBAAqB,CAAC,OAAO,CAAC,KAAG,qBAmVnC,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, }) => {
|
|
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({ 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 } : {}))),
|
|
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,18 @@ 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
|
+
]);
|
|
204
263
|
const handleCancel = useCallback(() => {
|
|
205
264
|
const resetValues = buildInitialValues();
|
|
206
265
|
setValues(resetValues);
|
|
@@ -211,6 +270,8 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
211
270
|
});
|
|
212
271
|
setEmailTouched(false);
|
|
213
272
|
set_legal_accepted({});
|
|
273
|
+
setLocationValues({ country: "", state_province: "", suburb: "" });
|
|
274
|
+
setCustomFieldValues({});
|
|
214
275
|
}, []);
|
|
215
276
|
return {
|
|
216
277
|
values,
|
|
@@ -226,5 +287,9 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
226
287
|
handleCancel,
|
|
227
288
|
legal_accepted,
|
|
228
289
|
handleLegalAcceptedChange,
|
|
290
|
+
locationValues,
|
|
291
|
+
handleLocationFieldChange,
|
|
292
|
+
customFieldValues,
|
|
293
|
+
handleCustomFieldChange,
|
|
229
294
|
};
|
|
230
295
|
};
|