hazo_auth 10.24.0 → 10.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/cli-src/lib/already_logged_in_config.server.ts +13 -0
  2. package/cli-src/lib/auth/auth_types.ts +6 -0
  3. package/cli-src/lib/auth/hazo_get_auth.server.ts +3 -0
  4. package/cli-src/lib/location_fields_config.server.ts +42 -0
  5. package/cli-src/lib/login_config.server.ts +3 -0
  6. package/cli-src/lib/my_settings_config.server.ts +6 -0
  7. package/cli-src/lib/register_config.server.ts +16 -0
  8. package/cli-src/lib/services/location_fields_helper.ts +30 -0
  9. package/cli-src/lib/services/registration_service.ts +21 -0
  10. package/cli-src/lib/services/user_update_service.ts +7 -0
  11. package/dist/components/layouts/legal/legal_acceptance_gate.d.ts +1 -1
  12. package/dist/components/layouts/legal/legal_acceptance_gate.d.ts.map +1 -1
  13. package/dist/components/layouts/legal/legal_acceptance_gate.js +5 -3
  14. package/dist/components/layouts/login/index.d.ts +8 -1
  15. package/dist/components/layouts/login/index.d.ts.map +1 -1
  16. package/dist/components/layouts/login/index.js +2 -2
  17. package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts +8 -0
  18. package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts.map +1 -1
  19. package/dist/components/layouts/my_settings/hooks/use_my_settings.js +37 -0
  20. package/dist/components/layouts/my_settings/index.d.ts +6 -1
  21. package/dist/components/layouts/my_settings/index.d.ts.map +1 -1
  22. package/dist/components/layouts/my_settings/index.js +3 -3
  23. package/dist/components/layouts/register/hooks/use_register_form.d.ts +15 -1
  24. package/dist/components/layouts/register/hooks/use_register_form.d.ts.map +1 -1
  25. package/dist/components/layouts/register/hooks/use_register_form.js +69 -4
  26. package/dist/components/layouts/register/index.d.ts +7 -1
  27. package/dist/components/layouts/register/index.d.ts.map +1 -1
  28. package/dist/components/layouts/register/index.js +30 -4
  29. package/dist/components/layouts/shared/components/already_logged_in_guard.d.ts +8 -1
  30. package/dist/components/layouts/shared/components/already_logged_in_guard.d.ts.map +1 -1
  31. package/dist/components/layouts/shared/components/already_logged_in_guard.js +15 -1
  32. package/dist/components/layouts/shared/hooks/use_auth_status.d.ts +3 -0
  33. package/dist/components/layouts/shared/hooks/use_auth_status.d.ts.map +1 -1
  34. package/dist/components/layouts/shared/hooks/use_auth_status.js +5 -2
  35. package/dist/components/ui/button.d.ts +1 -1
  36. package/dist/lib/already_logged_in_config.server.d.ts +8 -0
  37. package/dist/lib/already_logged_in_config.server.d.ts.map +1 -1
  38. package/dist/lib/already_logged_in_config.server.js +4 -0
  39. package/dist/lib/auth/auth_types.d.ts +3 -0
  40. package/dist/lib/auth/auth_types.d.ts.map +1 -1
  41. package/dist/lib/auth/hazo_get_auth.server.d.ts.map +1 -1
  42. package/dist/lib/auth/hazo_get_auth.server.js +3 -0
  43. package/dist/lib/location_fields_config.server.d.ts +22 -0
  44. package/dist/lib/location_fields_config.server.d.ts.map +1 -0
  45. package/dist/lib/location_fields_config.server.js +31 -0
  46. package/dist/lib/login_config.server.d.ts +2 -0
  47. package/dist/lib/login_config.server.d.ts.map +1 -1
  48. package/dist/lib/login_config.server.js +1 -0
  49. package/dist/lib/my_settings_config.server.d.ts +4 -0
  50. package/dist/lib/my_settings_config.server.d.ts.map +1 -1
  51. package/dist/lib/my_settings_config.server.js +3 -0
  52. package/dist/lib/register_config.server.d.ts +10 -0
  53. package/dist/lib/register_config.server.d.ts.map +1 -1
  54. package/dist/lib/register_config.server.js +7 -0
  55. package/dist/lib/services/location_fields_helper.d.ts +13 -0
  56. package/dist/lib/services/location_fields_helper.d.ts.map +1 -0
  57. package/dist/lib/services/location_fields_helper.js +24 -0
  58. package/dist/lib/services/registration_service.d.ts +9 -0
  59. package/dist/lib/services/registration_service.d.ts.map +1 -1
  60. package/dist/lib/services/registration_service.js +11 -0
  61. package/dist/lib/services/user_update_service.d.ts +5 -0
  62. package/dist/lib/services/user_update_service.d.ts.map +1 -1
  63. package/dist/lib/services/user_update_service.js +2 -0
  64. package/dist/locales/en.json +9 -0
  65. package/dist/page_components/my_settings.d.ts +9 -1
  66. package/dist/page_components/my_settings.d.ts.map +1 -1
  67. package/dist/page_components/my_settings.js +8 -2
  68. package/dist/server/routes/me.d.ts.map +1 -1
  69. package/dist/server/routes/me.js +5 -1
  70. package/dist/server/routes/register.d.ts.map +1 -1
  71. package/dist/server/routes/register.js +46 -0
  72. package/dist/server/routes/update_user.d.ts.map +1 -1
  73. package/dist/server/routes/update_user.js +24 -1
  74. package/dist/server_pages/login.d.ts.map +1 -1
  75. package/dist/server_pages/login.js +1 -1
  76. package/dist/server_pages/login_client_wrapper.d.ts +1 -1
  77. package/dist/server_pages/login_client_wrapper.d.ts.map +1 -1
  78. package/dist/server_pages/login_client_wrapper.js +2 -2
  79. package/dist/server_pages/my_settings.d.ts.map +1 -1
  80. package/dist/server_pages/my_settings.js +1 -1
  81. package/dist/server_pages/register.d.ts.map +1 -1
  82. package/dist/server_pages/register.js +1 -1
  83. package/dist/server_pages/register_client_wrapper.d.ts +4 -2
  84. package/dist/server_pages/register_client_wrapper.d.ts.map +1 -1
  85. package/dist/server_pages/register_client_wrapper.js +2 -2
  86. package/package.json +11 -11
@@ -14,6 +14,14 @@ export type AlreadyLoggedInConfig = {
14
14
  /** Undefined when not configured — components fall back to their own i18n `t()` default. */
15
15
  returnHomeButtonLabel: string | undefined;
16
16
  returnHomePath: string;
17
+ /**
18
+ * When set, an already-authenticated user who lands on an auth page (login,
19
+ * register, forgot/reset password, email verification) is sent straight to
20
+ * this path instead of seeing the "already logged in" message + buttons.
21
+ * Undefined when not configured (default) — preserves the existing
22
+ * message/logout/return-home UX unchanged.
23
+ */
24
+ redirectPath: string | undefined;
17
25
  };
18
26
 
19
27
  // section: helpers
@@ -42,12 +50,17 @@ export function get_already_logged_in_config(): AlreadyLoggedInConfig {
42
50
  // Read return home path (defaults to "/")
43
51
  const returnHomePath = get_config_value(section, "return_home_path", "/");
44
52
 
53
+ // Read redirect path — undefined when not configured, so the guard keeps
54
+ // showing the message + buttons (back-compat default, opt-in feature).
55
+ const redirectPath = get_config_value_optional(section, "redirect_path");
56
+
45
57
  return {
46
58
  message,
47
59
  showLogoutButton,
48
60
  showReturnHomeButton,
49
61
  returnHomeButtonLabel,
50
62
  returnHomePath,
63
+ redirectPath,
51
64
  };
52
65
  }
53
66
 
@@ -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
+ }
@@ -24,6 +24,8 @@ export type LoginConfig = {
24
24
  showReturnHomeButton: boolean;
25
25
  returnHomeButtonLabel: string | undefined;
26
26
  returnHomePath: string;
27
+ /** See `AlreadyLoggedInConfig.redirectPath` — undefined unless `[hazo_auth__already_logged_in] redirect_path` is set. */
28
+ alreadyLoggedInRedirectPath: string | undefined;
27
29
  forgotPasswordPath: string;
28
30
  /** Undefined when not configured — falls back to `t("login.forgot_password_link_default")`. "" hides the link. */
29
31
  forgotPasswordLabel: string | undefined;
@@ -106,6 +108,7 @@ export function get_login_config(): LoginConfig {
106
108
  showReturnHomeButton: alreadyLoggedInConfig.showReturnHomeButton,
107
109
  returnHomeButtonLabel: alreadyLoggedInConfig.returnHomeButtonLabel,
108
110
  returnHomePath: alreadyLoggedInConfig.returnHomePath,
111
+ alreadyLoggedInRedirectPath: alreadyLoggedInConfig.redirectPath,
109
112
  forgotPasswordPath,
110
113
  forgotPasswordLabel,
111
114
  createAccountPath,
@@ -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;
@@ -2,6 +2,6 @@ interface LegalAcceptanceGateProps {
2
2
  children: React.ReactNode;
3
3
  apiBasePath?: string;
4
4
  }
5
- export declare function LegalAcceptanceGate({ children, apiBasePath }: LegalAcceptanceGateProps): import("react").JSX.Element | null;
5
+ export declare function LegalAcceptanceGate({ children, apiBasePath }: LegalAcceptanceGateProps): import("react").JSX.Element;
6
6
  export {};
7
7
  //# sourceMappingURL=legal_acceptance_gate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"legal_acceptance_gate.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/legal/legal_acceptance_gate.tsx"],"names":[],"mappings":"AASA,UAAU,wBAAwB;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAOD,wBAAgB,mBAAmB,CAAC,EAAE,QAAQ,EAAE,WAA8B,EAAE,EAAE,wBAAwB,sCAyHzG"}
1
+ {"version":3,"file":"legal_acceptance_gate.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/legal/legal_acceptance_gate.tsx"],"names":[],"mappings":"AASA,UAAU,wBAAwB;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAOD,wBAAgB,mBAAmB,CAAC,EAAE,QAAQ,EAAE,WAA8B,EAAE,EAAE,wBAAwB,+BA4HzG"}
@@ -77,9 +77,11 @@ export function LegalAcceptanceGate({ children, apiBasePath = '/api/hazo_auth' }
77
77
  set_submitting(false);
78
78
  }
79
79
  }
80
- if (gate.status === 'loading')
81
- return null;
82
- if (gate.status === 'clear')
80
+ // Fail open: render children immediately while the check is in flight (SSR and
81
+ // first client paint both start in 'loading', since the fetch only happens inside
82
+ // useEffect) and once it resolves 'clear'. Only the genuine 'required' status below
83
+ // blocks the tree — never the undetermined state. See CHANGE_LOG.md.
84
+ if (gate.status === 'loading' || gate.status === 'clear')
83
85
  return _jsx(_Fragment, { children: children });
84
86
  const all_accepted = gate.docs.every((doc) => accepted[doc.key]);
85
87
  return (_jsx("div", { className: "min-h-screen flex items-center justify-center p-4", children: _jsxs("div", { className: "w-full max-w-lg space-y-6", children: [_jsxs("div", { children: [_jsx("h1", { className: "text-2xl font-bold", children: t("legal.gate.heading") }), _jsx("p", { className: "text-muted-foreground mt-1", children: t("legal.gate.description") })] }), gate.display_mode === 'combined' ? (_jsx(LegalDocCombinedView, { docs: gate.docs, accepted: gate.docs.length > 0 && gate.docs.every((d) => accepted[d.key]), onAcceptedChange: (value) => gate.docs.forEach((doc) => set_accepted((prev) => (Object.assign(Object.assign({}, prev), { [doc.key]: value })))) })) : (_jsx(LegalDocCheckboxList, { docs: gate.docs, accepted: accepted, onAcceptedChange: (key, value) => set_accepted((prev) => (Object.assign(Object.assign({}, prev), { [key]: value }))) })), error && _jsx("p", { className: "text-destructive text-sm", children: error }), _jsx(Button, { onClick: handle_submit, disabled: !all_accepted || submitting, className: "w-full", children: submitting ? t("legal.gate.saving") : t("legal.gate.continue_button") })] }) }));
@@ -38,6 +38,13 @@ export type LoginLayoutProps<TClient = unknown> = {
38
38
  showReturnHomeButton?: boolean;
39
39
  returnHomeButtonLabel?: string;
40
40
  returnHomePath?: string;
41
+ /**
42
+ * When set, an already-authenticated user is sent straight to this path
43
+ * instead of seeing the "already logged in" message. See
44
+ * `AlreadyLoggedInGuard`'s `redirectPath` prop. Ignored in `form_only`
45
+ * mode (the guard is skipped there entirely).
46
+ */
47
+ alreadyLoggedInRedirectPath?: string;
41
48
  forgot_password_path?: string;
42
49
  forgot_password_label?: string;
43
50
  create_account_path?: string;
@@ -64,5 +71,5 @@ export type LoginLayoutProps<TClient = unknown> = {
64
71
  */
65
72
  layout?: "two_column" | "form_only";
66
73
  };
67
- export default function login_layout<TClient>({ image_src, image_alt, image_background_color, field_overrides, labels, button_colors, data_client, logger, redirectRoute, successMessage, alreadyLoggedInMessage, showLogoutButton, showReturnHomeButton, returnHomeButtonLabel, returnHomePath, forgot_password_path, forgot_password_label, create_account_path, create_account_label, show_create_account_link, urlOnLogon, oauth, layout, default_values, }: LoginLayoutProps<TClient>): import("react").JSX.Element;
74
+ export default function login_layout<TClient>({ image_src, image_alt, image_background_color, field_overrides, labels, button_colors, data_client, logger, redirectRoute, successMessage, alreadyLoggedInMessage, showLogoutButton, showReturnHomeButton, returnHomeButtonLabel, returnHomePath, alreadyLoggedInRedirectPath, forgot_password_path, forgot_password_label, create_account_path, create_account_label, show_create_account_link, urlOnLogon, oauth, layout, default_values, }: LoginLayoutProps<TClient>): import("react").JSX.Element;
68
75
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts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,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACvD;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC;CACrC,CAAC;AAUF,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,OAAO,EAAE,EAC5C,SAAS,EACT,SAAS,EACT,sBAAkC,EAClC,eAAe,EACf,MAAM,EACN,aAAa,EACb,WAAW,EACX,MAAM,EACN,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,gBAAuB,EACvB,oBAA4B,EAC5B,qBAAqB,EACrB,cAAoB,EACpB,2BAA2B,EAC3B,oBAAmD,EACnD,qBAAqB,EACrB,mBAA2C,EAC3C,oBAAoB,EACpB,wBAA+B,EAC/B,UAAU,EACV,KAAK,EACL,MAAqB,EACrB,cAAc,GACf,EAAE,gBAAgB,CAAC,OAAO,CAAC,+BAkS3B"}
@@ -24,7 +24,7 @@ const ORDERED_FIELDS = [
24
24
  LOGIN_FIELD_IDS.PASSWORD,
25
25
  ];
26
26
  // section: component
27
- export default function login_layout({ image_src, image_alt, image_background_color = "#f1f5f9", field_overrides, labels, button_colors, data_client, logger, redirectRoute, successMessage, alreadyLoggedInMessage, showLogoutButton = true, showReturnHomeButton = false, returnHomeButtonLabel, returnHomePath = "/", forgot_password_path = "/hazo_auth/forgot_password", forgot_password_label, create_account_path = "/hazo_auth/register", create_account_label, show_create_account_link = true, urlOnLogon, oauth, layout = "two_column", default_values, }) {
27
+ export default function login_layout({ image_src, image_alt, image_background_color = "#f1f5f9", field_overrides, labels, button_colors, data_client, logger, redirectRoute, successMessage, alreadyLoggedInMessage, showLogoutButton = true, showReturnHomeButton = false, returnHomeButtonLabel, returnHomePath = "/", alreadyLoggedInRedirectPath, forgot_password_path = "/hazo_auth/forgot_password", forgot_password_label, create_account_path = "/hazo_auth/register", create_account_label, show_create_account_link = true, urlOnLogon, oauth, layout = "two_column", default_values, }) {
28
28
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
29
29
  const t = useAuthT();
30
30
  const resolvedSuccessMessage = successMessage !== null && successMessage !== void 0 ? successMessage : t("login.success_message_default");
@@ -126,7 +126,7 @@ export default function login_layout({ image_src, image_alt, image_background_co
126
126
  return (_jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: successContent }));
127
127
  }
128
128
  // Two-column mode (default): main flow with already-logged-in guard.
129
- return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: resolvedAlreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: mainContent }) }));
129
+ return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message: resolvedAlreadyLoggedInMessage, showLogoutButton: showLogoutButton, showReturnHomeButton: showReturnHomeButton, returnHomeButtonLabel: resolvedReturnHomeButtonLabel, returnHomePath: returnHomePath, redirectPath: alreadyLoggedInRedirectPath, children: _jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: mainContent }) }));
130
130
  }
131
131
  // Same-origin path validator for the `?redirect=` query param. Accepts
132
132
  // values like "/foo" or "/foo?bar". Rejects anything that could redirect
@@ -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;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,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IAGjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,OAAO,CAAC;IA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
@@ -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;AAC3C,OAAO,KAAK,EACV,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,uCAAuC,CAAC;AAS/C,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,qBAAqB,EAAE,0BAA0B,CAAC;IAClD,cAAc,EAAE;QACd,kBAAkB,EAAE,OAAO,CAAC;QAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,EAAE,OAAO,CAAC;QAC5B,4BAA4B,EAAE,UAAU,GAAG,SAAS,CAAC;QACrD,4BAA4B,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;QACtD,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,UAAU,EAAE;QACV,eAAe,EAAE,OAAO,CAAC;QACzB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,mBAAmB,EAAE,OAAO,CAAC;KAC9B,CAAC;IACF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC;;;OAGG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAA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,cAAyE,EACzE,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,+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: ((_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: {
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) => {