hazo_auth 10.18.4 → 10.22.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/README.md +6 -0
- package/SETUP_CHECKLIST.md +27 -0
- package/cli-src/lib/already_logged_in_config.server.ts +11 -7
- package/cli-src/lib/auth_hooks.ts +52 -0
- package/cli-src/lib/config/config_loader.server.ts +34 -0
- package/cli-src/lib/email_verification_config.server.ts +2 -2
- package/cli-src/lib/forgot_password_config.server.ts +2 -2
- package/cli-src/lib/login_config.server.ts +25 -19
- package/cli-src/lib/my_settings_config.server.ts +22 -15
- package/cli-src/lib/navbar_config.server.ts +12 -8
- package/cli-src/lib/oauth_config.server.ts +14 -22
- package/cli-src/lib/otp_config.server.ts +11 -4
- package/cli-src/lib/profile_pic_menu_config.server.ts +16 -5
- package/cli-src/lib/register_config.server.ts +21 -16
- package/cli-src/lib/reset_password_config.server.ts +11 -17
- package/cli-src/lib/services/oauth_service.ts +16 -0
- package/cli-src/lib/services/otp_service.ts +7 -0
- package/cli-src/lib/services/registration_service.ts +8 -0
- package/cli-src/lib/ui_shell_config.server.ts +11 -13
- package/cli-src/lib/utils/password_validator.ts +12 -5
- package/dist/components/layouts/create_firm/index.d.ts.map +1 -1
- package/dist/components/layouts/create_firm/index.js +4 -3
- package/dist/components/layouts/dev_lock/index.d.ts.map +1 -1
- package/dist/components/layouts/dev_lock/index.js +4 -2
- package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts +5 -4
- package/dist/components/layouts/email_verification/config/email_verification_field_config.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/config/email_verification_field_config.js +32 -29
- package/dist/components/layouts/email_verification/hooks/use_email_verification.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/hooks/use_email_verification.js +14 -13
- package/dist/components/layouts/email_verification/index.d.ts.map +1 -1
- package/dist/components/layouts/email_verification/index.js +13 -9
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts +3 -2
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/config/forgot_password_field_config.js +21 -18
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/hooks/use_forgot_password_form.js +10 -9
- package/dist/components/layouts/forgot_password/index.d.ts.map +1 -1
- package/dist/components/layouts/forgot_password/index.js +15 -6
- package/dist/components/layouts/legal/legal_acceptance_gate.d.ts.map +1 -1
- package/dist/components/layouts/legal/legal_acceptance_gate.js +5 -3
- package/dist/components/layouts/legal/legal_doc_checkbox_list.d.ts.map +1 -1
- package/dist/components/layouts/legal/legal_doc_checkbox_list.js +3 -1
- package/dist/components/layouts/legal/legal_doc_combined_view.d.ts.map +1 -1
- package/dist/components/layouts/legal/legal_doc_combined_view.js +3 -1
- package/dist/components/layouts/login/config/login_field_config.d.ts +3 -2
- package/dist/components/layouts/login/config/login_field_config.d.ts.map +1 -1
- package/dist/components/layouts/login/config/login_field_config.js +29 -26
- package/dist/components/layouts/login/hooks/use_login_form.d.ts.map +1 -1
- package/dist/components/layouts/login/hooks/use_login_form.js +8 -7
- package/dist/components/layouts/login/index.d.ts +4 -4
- package/dist/components/layouts/login/index.d.ts.map +1 -1
- package/dist/components/layouts/login/index.js +33 -22
- package/dist/components/layouts/my_settings/components/connected_accounts_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/connected_accounts_section.js +7 -4
- package/dist/components/layouts/my_settings/components/danger_zone_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/danger_zone_section.js +15 -6
- package/dist/components/layouts/my_settings/components/editable_field.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/editable_field.js +4 -2
- package/dist/components/layouts/my_settings/components/language_picker_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/language_picker_section.js +7 -3
- package/dist/components/layouts/my_settings/components/password_change_dialog.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/password_change_dialog.js +28 -21
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_dialog.js +12 -9
- package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_gravatar_tab.js +3 -1
- package/dist/components/layouts/my_settings/components/profile_picture_library_tab.js +14 -11
- package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_upload_tab.js +26 -15
- package/dist/components/layouts/my_settings/components/set_password_section.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/set_password_section.js +24 -14
- package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts +2 -1
- package/dist/components/layouts/my_settings/config/my_settings_field_config.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/config/my_settings_field_config.js +10 -10
- package/dist/components/layouts/my_settings/index.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/index.js +35 -27
- package/dist/components/layouts/otp/index.d.ts.map +1 -1
- package/dist/components/layouts/otp/index.js +8 -3
- package/dist/components/layouts/register/config/register_field_config.d.ts +3 -2
- package/dist/components/layouts/register/config/register_field_config.d.ts.map +1 -1
- package/dist/components/layouts/register/config/register_field_config.js +45 -42
- package/dist/components/layouts/register/hooks/use_register_form.d.ts.map +1 -1
- package/dist/components/layouts/register/hooks/use_register_form.js +12 -11
- package/dist/components/layouts/register/index.d.ts +4 -4
- package/dist/components/layouts/register/index.d.ts.map +1 -1
- package/dist/components/layouts/register/index.js +25 -19
- package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts +4 -3
- package/dist/components/layouts/reset_password/config/reset_password_field_config.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/config/reset_password_field_config.js +17 -17
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/hooks/use_reset_password_form.js +14 -13
- package/dist/components/layouts/reset_password/index.d.ts.map +1 -1
- package/dist/components/layouts/reset_password/index.js +12 -7
- package/dist/components/layouts/shared/components/already_logged_in_guard.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/already_logged_in_guard.js +6 -2
- package/dist/components/layouts/shared/components/auth_navbar.d.ts +1 -1
- package/dist/components/layouts/shared/components/auth_navbar.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/auth_navbar.js +7 -2
- package/dist/components/layouts/shared/components/facebook_sign_in_button.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/facebook_sign_in_button.js +5 -2
- package/dist/components/layouts/shared/components/floating_home_link.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/floating_home_link.js +6 -3
- package/dist/components/layouts/shared/components/form_action_buttons.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/form_action_buttons.js +9 -4
- package/dist/components/layouts/shared/components/google_sign_in_button.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/google_sign_in_button.js +5 -2
- package/dist/components/layouts/shared/components/logout_button.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/logout_button.js +6 -5
- package/dist/components/layouts/shared/components/oauth_divider.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/oauth_divider.js +8 -3
- package/dist/components/layouts/shared/components/password_field.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/password_field.js +3 -1
- package/dist/components/layouts/shared/components/profile_pic_menu.d.ts +4 -0
- package/dist/components/layouts/shared/components/profile_pic_menu.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/profile_pic_menu.js +26 -18
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.d.ts +1 -0
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/profile_pic_menu_wrapper.js +1 -1
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/sidebar_layout_wrapper.js +3 -1
- package/dist/components/layouts/shared/components/standalone_layout_wrapper.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/standalone_layout_wrapper.js +6 -2
- package/dist/components/layouts/shared/components/unauthorized_guard.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/unauthorized_guard.js +7 -3
- package/dist/components/layouts/shared/config/layout_customization.d.ts +6 -0
- package/dist/components/layouts/shared/config/layout_customization.d.ts.map +1 -1
- package/dist/components/layouts/shared/config/layout_customization.js +26 -1
- package/dist/components/layouts/shared/utils/validation.d.ts +9 -2
- package/dist/components/layouts/shared/utils/validation.d.ts.map +1 -1
- package/dist/components/layouts/shared/utils/validation.js +16 -8
- package/dist/components/layouts/user_management/components/roles_matrix.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/roles_matrix.js +21 -18
- package/dist/components/layouts/user_management/components/scope_hierarchy_tab.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/scope_hierarchy_tab.js +32 -31
- package/dist/components/layouts/user_management/components/user_scopes_tab.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/user_scopes_tab.js +26 -20
- package/dist/components/layouts/user_management/index.d.ts.map +1 -1
- package/dist/components/layouts/user_management/index.js +47 -43
- package/dist/components/otp/OTPRequestForm.d.ts.map +1 -1
- package/dist/components/otp/OTPRequestForm.js +10 -5
- package/dist/components/otp/OTPVerifyForm.d.ts.map +1 -1
- package/dist/components/otp/OTPVerifyForm.js +12 -7
- package/dist/components/permission_denied_dialog.client.d.ts.map +1 -1
- package/dist/components/permission_denied_dialog.client.js +12 -9
- package/dist/components/ui/sheet.d.ts +1 -1
- package/dist/components/ui/sidebar.js +5 -5
- package/dist/contexts/hazo_auth_config.d.ts +13 -0
- package/dist/contexts/hazo_auth_config.d.ts.map +1 -1
- package/dist/contexts/hazo_auth_config.js +4 -1
- package/dist/contexts/hazo_auth_provider.d.ts +22 -2
- package/dist/contexts/hazo_auth_provider.d.ts.map +1 -1
- package/dist/contexts/hazo_auth_provider.js +18 -2
- package/dist/lib/already_logged_in_config.server.d.ts +4 -2
- package/dist/lib/already_logged_in_config.server.d.ts.map +1 -1
- package/dist/lib/already_logged_in_config.server.js +7 -5
- package/dist/lib/auth_hooks.d.ts +20 -0
- package/dist/lib/auth_hooks.d.ts.map +1 -0
- package/dist/lib/auth_hooks.js +32 -0
- package/dist/lib/config/config_loader.server.d.ts +23 -0
- package/dist/lib/config/config_loader.server.d.ts.map +1 -1
- package/dist/lib/config/config_loader.server.js +29 -0
- package/dist/lib/email_verification_config.server.d.ts +2 -2
- package/dist/lib/email_verification_config.server.d.ts.map +1 -1
- package/dist/lib/forgot_password_config.server.d.ts +2 -2
- package/dist/lib/forgot_password_config.server.d.ts.map +1 -1
- package/dist/lib/login_config.server.d.ts +8 -5
- package/dist/lib/login_config.server.d.ts.map +1 -1
- package/dist/lib/login_config.server.js +13 -6
- package/dist/lib/my_settings_config.server.d.ts.map +1 -1
- package/dist/lib/my_settings_config.server.js +22 -15
- package/dist/lib/navbar_config.server.d.ts +3 -2
- package/dist/lib/navbar_config.server.d.ts.map +1 -1
- package/dist/lib/navbar_config.server.js +4 -2
- package/dist/lib/oauth_config.server.d.ts +6 -6
- package/dist/lib/oauth_config.server.d.ts.map +1 -1
- package/dist/lib/oauth_config.server.js +8 -4
- package/dist/lib/otp_config.server.d.ts +2 -2
- package/dist/lib/otp_config.server.d.ts.map +1 -1
- package/dist/lib/otp_config.server.js +4 -2
- package/dist/lib/profile_pic_menu_config.server.d.ts +6 -2
- package/dist/lib/profile_pic_menu_config.server.d.ts.map +1 -1
- package/dist/lib/profile_pic_menu_config.server.js +5 -3
- package/dist/lib/register_config.server.d.ts +7 -6
- package/dist/lib/register_config.server.d.ts.map +1 -1
- package/dist/lib/register_config.server.js +8 -4
- package/dist/lib/reset_password_config.server.d.ts +6 -4
- package/dist/lib/reset_password_config.server.d.ts.map +1 -1
- package/dist/lib/reset_password_config.server.js +5 -5
- package/dist/lib/services/oauth_service.d.ts.map +1 -1
- package/dist/lib/services/oauth_service.js +13 -0
- package/dist/lib/services/otp_service.d.ts.map +1 -1
- package/dist/lib/services/otp_service.js +6 -0
- package/dist/lib/services/registration_service.d.ts.map +1 -1
- package/dist/lib/services/registration_service.js +7 -0
- package/dist/lib/ui_shell_config.server.d.ts +6 -2
- package/dist/lib/ui_shell_config.server.d.ts.map +1 -1
- package/dist/lib/ui_shell_config.server.js +5 -3
- package/dist/lib/utils/password_validator.d.ts.map +1 -1
- package/dist/lib/utils/password_validator.js +5 -5
- package/dist/locales/en.json +517 -0
- package/dist/server/routes/library_photos.d.ts +2 -2
- package/dist/server/routes/set_password.js +1 -1
- package/dist/server-lib.d.ts +2 -0
- package/dist/server-lib.d.ts.map +1 -1
- package/dist/server-lib.js +2 -0
- package/dist/server_pages/forgot_password.d.ts +3 -2
- package/dist/server_pages/forgot_password.d.ts.map +1 -1
- package/dist/server_pages/forgot_password.js +8 -7
- package/dist/server_pages/forgot_password_client_wrapper.d.ts +2 -1
- package/dist/server_pages/forgot_password_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/forgot_password_client_wrapper.js +3 -1
- package/dist/server_pages/login.d.ts.map +1 -1
- package/dist/server_pages/login.js +9 -7
- package/dist/server_pages/login_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/login_client_wrapper.js +3 -1
- package/dist/server_pages/otp.d.ts +6 -3
- package/dist/server_pages/otp.d.ts.map +1 -1
- package/dist/server_pages/otp.js +11 -8
- package/dist/server_pages/register.d.ts.map +1 -1
- package/dist/server_pages/register.js +7 -6
- package/dist/server_pages/register_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/register_client_wrapper.js +3 -1
- package/dist/server_pages/reset_password.d.ts.map +1 -1
- package/dist/server_pages/reset_password.js +7 -6
- package/dist/server_pages/reset_password_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/reset_password_client_wrapper.js +3 -1
- package/dist/server_pages/verify_email.d.ts.map +1 -1
- package/dist/server_pages/verify_email.js +6 -5
- package/dist/server_pages/verify_email_client_wrapper.d.ts.map +1 -1
- package/dist/server_pages/verify_email_client_wrapper.js +4 -2
- package/dist/strings/default_strings.d.ts +15 -0
- package/dist/strings/default_strings.d.ts.map +1 -1
- package/dist/strings/default_strings.js +67 -11
- package/dist/strings/index.d.ts +1 -1
- package/dist/strings/index.d.ts.map +1 -1
- package/dist/strings/index.js +1 -1
- package/dist/strings/strings_context.d.ts +20 -3
- package/dist/strings/strings_context.d.ts.map +1 -1
- package/dist/strings/strings_context.js +39 -5
- package/dist/strings/strings_provider.d.ts +1 -5
- package/dist/strings/strings_provider.d.ts.map +1 -1
- package/dist/strings/strings_provider.js +5 -1
- package/package.json +27 -19
|
@@ -18,21 +18,32 @@ import { FacebookSignInButton } from "../shared/components/facebook_sign_in_butt
|
|
|
18
18
|
import { OAuthDivider } from "../shared/components/oauth_divider.js";
|
|
19
19
|
import { LOGIN_FIELD_IDS, createLoginFieldDefinitions, resolveLoginButtonPalette, resolveLoginLabels, } from "./config/login_field_config.js";
|
|
20
20
|
import { use_login_form, } from "./hooks/use_login_form.js";
|
|
21
|
+
import { useAuthT } from "../../../contexts/hazo_auth_provider.js";
|
|
21
22
|
const ORDERED_FIELDS = [
|
|
22
23
|
LOGIN_FIELD_IDS.EMAIL,
|
|
23
24
|
LOGIN_FIELD_IDS.PASSWORD,
|
|
24
25
|
];
|
|
25
26
|
// section: component
|
|
26
|
-
export default function login_layout({ image_src, image_alt, image_background_color = "#f1f5f9", field_overrides, labels, button_colors, data_client, logger, redirectRoute, successMessage
|
|
27
|
-
var _a, _b, _c;
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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, }) {
|
|
28
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
29
|
+
const t = useAuthT();
|
|
30
|
+
const resolvedSuccessMessage = successMessage !== null && successMessage !== void 0 ? successMessage : t("login.success_message_default");
|
|
31
|
+
const resolvedAlreadyLoggedInMessage = alreadyLoggedInMessage !== null && alreadyLoggedInMessage !== void 0 ? alreadyLoggedInMessage : t("shared.guard.already_logged_in_prop_default");
|
|
32
|
+
const resolvedReturnHomeButtonLabel = returnHomeButtonLabel !== null && returnHomeButtonLabel !== void 0 ? returnHomeButtonLabel : t("shared.guard.return_home_default");
|
|
33
|
+
const resolvedForgotPasswordLabel = forgot_password_label !== null && forgot_password_label !== void 0 ? forgot_password_label : t("login.forgot_password_link_default");
|
|
34
|
+
const resolvedCreateAccountLabel = create_account_label !== null && create_account_label !== void 0 ? create_account_label : t("login.create_account_link_default");
|
|
35
|
+
// Resolve OAuth config per-field (not `oauth || {defaults}` as a whole
|
|
36
|
+
// object) — a caller can pass a partial `oauth` prop (e.g. only
|
|
37
|
+
// `enable_google: false`) and still get `t()`-resolved locale-aware text for
|
|
38
|
+
// any field it didn't set. A whole-object fallback would silently force
|
|
39
|
+
// English for every OAuth field the moment ANY field was supplied.
|
|
40
|
+
const oauthConfig = {
|
|
41
|
+
enable_google: (_a = oauth === null || oauth === void 0 ? void 0 : oauth.enable_google) !== null && _a !== void 0 ? _a : true,
|
|
42
|
+
enable_email_password: (_b = oauth === null || oauth === void 0 ? void 0 : oauth.enable_email_password) !== null && _b !== void 0 ? _b : true,
|
|
43
|
+
google_button_text: (_c = oauth === null || oauth === void 0 ? void 0 : oauth.google_button_text) !== null && _c !== void 0 ? _c : t("shared.oauth.google_button_default"),
|
|
44
|
+
oauth_divider_text: (_d = oauth === null || oauth === void 0 ? void 0 : oauth.oauth_divider_text) !== null && _d !== void 0 ? _d : t("shared.oauth_divider_default"),
|
|
45
|
+
enable_facebook_oauth: (_e = oauth === null || oauth === void 0 ? void 0 : oauth.enable_facebook_oauth) !== null && _e !== void 0 ? _e : false,
|
|
46
|
+
facebook_button_text: (_f = oauth === null || oauth === void 0 ? void 0 : oauth.facebook_button_text) !== null && _f !== void 0 ? _f : t("shared.oauth.facebook_button_default"),
|
|
36
47
|
};
|
|
37
48
|
// Read OAuth error from URL query params (e.g., ?error=AccessDenied)
|
|
38
49
|
const searchParams = useSearchParams();
|
|
@@ -51,31 +62,31 @@ export default function login_layout({ image_src, image_alt, image_background_co
|
|
|
51
62
|
const oauthCallbackUrl = safeRedirect
|
|
52
63
|
? `/api/hazo_auth/oauth/google/callback?next=${encodeURIComponent(safeRedirect)}`
|
|
53
64
|
: "/api/hazo_auth/oauth/google/callback";
|
|
54
|
-
const effectiveRedirectRoute = (
|
|
65
|
+
const effectiveRedirectRoute = (_g = redirectRoute !== null && redirectRoute !== void 0 ? redirectRoute : safeRedirect) !== null && _g !== void 0 ? _g : undefined;
|
|
55
66
|
const getOAuthErrorMessage = (error) => {
|
|
56
67
|
switch (error) {
|
|
57
68
|
case "AccessDenied":
|
|
58
|
-
return "
|
|
69
|
+
return t("shared.oauth_error.access_denied");
|
|
59
70
|
case "OAuthSignin":
|
|
60
71
|
case "OAuthCallback":
|
|
61
72
|
case "OAuthCreateAccount":
|
|
62
|
-
return "
|
|
73
|
+
return t("shared.oauth_error.signin_failed");
|
|
63
74
|
default:
|
|
64
|
-
return "
|
|
75
|
+
return t("shared.oauth_error.generic");
|
|
65
76
|
}
|
|
66
77
|
};
|
|
67
|
-
const fieldDefinitions = createLoginFieldDefinitions(field_overrides);
|
|
68
|
-
const resolvedLabels = resolveLoginLabels(labels);
|
|
78
|
+
const fieldDefinitions = createLoginFieldDefinitions(t, field_overrides);
|
|
79
|
+
const resolvedLabels = resolveLoginLabels(t, labels);
|
|
69
80
|
const resolvedButtonPalette = resolveLoginButtonPalette(button_colors);
|
|
70
81
|
const form = use_login_form({
|
|
71
82
|
dataClient: data_client,
|
|
72
83
|
logger,
|
|
73
84
|
redirectRoute: effectiveRedirectRoute,
|
|
74
|
-
successMessage,
|
|
85
|
+
successMessage: resolvedSuccessMessage,
|
|
75
86
|
urlOnLogon: urlOnLogon,
|
|
76
87
|
defaultValues: default_values ? {
|
|
77
|
-
[LOGIN_FIELD_IDS.EMAIL]: (
|
|
78
|
-
[LOGIN_FIELD_IDS.PASSWORD]: (
|
|
88
|
+
[LOGIN_FIELD_IDS.EMAIL]: (_h = default_values.email) !== null && _h !== void 0 ? _h : "",
|
|
89
|
+
[LOGIN_FIELD_IDS.PASSWORD]: (_j = default_values.password) !== null && _j !== void 0 ? _j : "",
|
|
79
90
|
} : undefined,
|
|
80
91
|
});
|
|
81
92
|
const renderFields = (formState) => {
|
|
@@ -101,8 +112,8 @@ export default function login_layout({ image_src, image_alt, image_background_co
|
|
|
101
112
|
// Form content — used in both layout modes. In "two_column" mode it's slotted
|
|
102
113
|
// into TwoColumnAuthLayout's `formContent`; in "form_only" mode it's returned
|
|
103
114
|
// as the entire output for the consumer to compose into their own chrome.
|
|
104
|
-
const successContent = (_jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), _jsxs("div", { className: "cls_login_layout_success flex flex-col items-center justify-center gap-4 p-8 text-center", children: [_jsx(CheckCircle, { className: "cls_login_layout_success_icon h-16 w-16 text-green-600", "aria-hidden": "true" }), _jsx("p", { className: "cls_login_layout_success_message text-lg font-medium text-slate-900", children:
|
|
105
|
-
const mainContent = (_jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), oauthError && (_jsxs("div", { className: "cls_login_layout_oauth_error flex items-center gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700", children: [_jsx(AlertCircle, { className: "h-4 w-4 shrink-0", "aria-hidden": "true" }), _jsx("span", { children: getOAuthErrorMessage(oauthError) })] })), oauthConfig.enable_google && (_jsx("div", { className: "cls_login_layout_oauth_section", children: _jsx(GoogleSignInButton, { label: oauthConfig.google_button_text, callbackUrl: oauthCallbackUrl }) })), oauthConfig.enable_facebook_oauth && (_jsx("div", { className: "cls_login_layout_facebook_section", children: _jsx(FacebookSignInButton, { label: oauthConfig.facebook_button_text || "
|
|
115
|
+
const successContent = (_jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), _jsxs("div", { className: "cls_login_layout_success flex flex-col items-center justify-center gap-4 p-8 text-center", children: [_jsx(CheckCircle, { className: "cls_login_layout_success_icon h-16 w-16 text-green-600", "aria-hidden": "true" }), _jsx("p", { className: "cls_login_layout_success_message text-lg font-medium text-slate-900", children: resolvedSuccessMessage })] })] }));
|
|
116
|
+
const mainContent = (_jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), oauthError && (_jsxs("div", { className: "cls_login_layout_oauth_error flex items-center gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700", children: [_jsx(AlertCircle, { className: "h-4 w-4 shrink-0", "aria-hidden": "true" }), _jsx("span", { children: getOAuthErrorMessage(oauthError) })] })), oauthConfig.enable_google && (_jsx("div", { className: "cls_login_layout_oauth_section", children: _jsx(GoogleSignInButton, { label: oauthConfig.google_button_text, callbackUrl: oauthCallbackUrl }) })), oauthConfig.enable_facebook_oauth && (_jsx("div", { className: "cls_login_layout_facebook_section", children: _jsx(FacebookSignInButton, { label: oauthConfig.facebook_button_text || t("shared.oauth.facebook_button_default"), callbackUrl: "/api/hazo_auth/oauth/facebook/callback" }) })), (oauthConfig.enable_google || oauthConfig.enable_facebook_oauth) && oauthConfig.enable_email_password && (_jsx(OAuthDivider, { text: oauthConfig.oauth_divider_text })), oauthConfig.enable_email_password && (_jsxs("form", { className: "cls_login_layout_form_fields flex flex-col gap-5", onSubmit: form.handleSubmit, "aria-label": t("login.aria.form"), children: [renderFields(form), _jsx(FormActionButtons, { submitLabel: resolvedLabels.submitButton, cancelLabel: resolvedLabels.cancelButton, buttonPalette: resolvedButtonPalette, isSubmitDisabled: form.isSubmitDisabled, onCancel: form.handleCancel, submitAriaLabel: t("login.aria.submit"), cancelAriaLabel: t("login.aria.cancel") }), ((forgot_password_path && resolvedForgotPasswordLabel) || (show_create_account_link && create_account_path && resolvedCreateAccountLabel)) && (_jsxs("div", { className: "cls_login_layout_support_links flex flex-col gap-1 text-sm text-muted-foreground", children: [forgot_password_path && resolvedForgotPasswordLabel && (_jsx(Link, { href: forgot_password_path, className: "cls_login_layout_forgot_password_link text-primary underline-offset-4 hover:underline", "aria-label": t("login.aria.forgot_password_link"), children: resolvedForgotPasswordLabel })), show_create_account_link && create_account_path && resolvedCreateAccountLabel && (_jsx(Link, { href: create_account_path, className: "cls_login_layout_create_account_link text-primary underline-offset-4 hover:underline", "aria-label": t("login.aria.create_account_link"), children: resolvedCreateAccountLabel }))] }))] })), show_create_account_link && create_account_path && resolvedCreateAccountLabel && !oauthConfig.enable_email_password && (oauthConfig.enable_google || oauthConfig.enable_facebook_oauth) && (_jsx("div", { className: "cls_login_layout_support_links mt-4 text-center text-sm text-muted-foreground", children: _jsx(Link, { href: create_account_path, className: "cls_login_layout_create_account_link text-primary underline-offset-4 hover:underline", "aria-label": t("login.aria.create_account_link"), children: resolvedCreateAccountLabel }) }))] }));
|
|
106
117
|
// Form-only mode: return the content directly. Consumer is expected to wrap
|
|
107
118
|
// it in their own page/brand chrome. We deliberately skip AlreadyLoggedInGuard
|
|
108
119
|
// here — its 2-col fallback would defeat the purpose of form_only. Consumer
|
|
@@ -115,7 +126,7 @@ export default function login_layout({ image_src, image_alt, image_background_co
|
|
|
115
126
|
return (_jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: image_alt, imageBackgroundColor: image_background_color, formContent: successContent }));
|
|
116
127
|
}
|
|
117
128
|
// Two-column mode (default): main flow with already-logged-in guard.
|
|
118
|
-
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message:
|
|
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 }) }));
|
|
119
130
|
}
|
|
120
131
|
// Same-origin path validator for the `?redirect=` query param. Accepts
|
|
121
132
|
// values like "/foo" or "/foo?bar". Rejects anything that could redirect
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connected_accounts_section.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/connected_accounts_section.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connected_accounts_section.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/connected_accounts_section.tsx"],"names":[],"mappings":"AASA,MAAM,MAAM,6BAA6B,GAAG;IAC1C,0CAA0C;IAC1C,eAAe,EAAE,OAAO,CAAC;IACzB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oBAAoB;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAGF;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,eAAe,EACf,KAAK,EACL,OAAO,EACP,OAAe,GAChB,EAAE,6BAA6B,+BAqD/B"}
|
|
@@ -4,14 +4,17 @@
|
|
|
4
4
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
5
|
// section: imports
|
|
6
6
|
import { GoogleIcon } from "../../shared/components/google_icon.js";
|
|
7
|
+
import { useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
7
8
|
// section: component
|
|
8
9
|
/**
|
|
9
10
|
* Connected Accounts Section for My Settings
|
|
10
11
|
* Shows which OAuth providers are linked to the user's account
|
|
11
12
|
* Currently supports Google, designed for future extensibility
|
|
12
13
|
*/
|
|
13
|
-
export function ConnectedAccountsSection({ googleConnected, email, heading
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
export function ConnectedAccountsSection({ googleConnected, email, heading, loading = false, }) {
|
|
15
|
+
const t = useAuthT();
|
|
16
|
+
const resolvedHeading = heading !== null && heading !== void 0 ? heading : t("my_settings.connected_accounts.heading");
|
|
17
|
+
return (_jsxs("div", { className: "cls_my_settings_connected_accounts_section bg-white rounded-lg border border-[var(--hazo-border)] p-6", children: [_jsx("h2", { className: "cls_my_settings_section_heading text-lg font-semibold text-[var(--hazo-text-primary)] mb-4", children: resolvedHeading }), _jsx("div", { className: "cls_connected_accounts_list flex flex-col gap-3", children: _jsxs("div", { className: "cls_connected_account_item flex items-center justify-between p-3 rounded-md border border-[var(--hazo-border)] bg-[var(--hazo-surface-muted)]", children: [_jsxs("div", { className: "cls_connected_account_info flex items-center gap-3", children: [_jsx("div", { className: "cls_connected_account_icon flex items-center justify-center w-10 h-10 rounded-full bg-white border border-[var(--hazo-border)]", children: _jsx(GoogleIcon, { width: 20, height: 20 }) }), _jsxs("div", { className: "cls_connected_account_details flex flex-col", children: [_jsx("span", { className: "cls_connected_account_name font-medium text-[var(--hazo-text-primary)]", children: t("my_settings.connected_accounts.google_name") }), googleConnected && email && (_jsx("span", { className: "cls_connected_account_email text-sm text-[var(--hazo-text-muted)]", children: email }))] })] }), _jsx("div", { className: "cls_connected_account_status", children: loading ? (_jsx("span", { className: "cls_connected_account_loading text-sm text-[var(--hazo-text-muted)] animate-pulse", children: t("my_settings.connected_accounts.loading") })) : googleConnected ? (_jsxs("span", { className: "cls_connected_account_connected inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium bg-green-100 text-green-700", children: [_jsx("span", { className: "cls_connected_indicator w-1.5 h-1.5 rounded-full bg-green-500" }), t("my_settings.connected_accounts.connected")] })) : (_jsxs("span", { className: "cls_connected_account_not_connected inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium bg-slate-100 text-slate-600", children: [_jsx("span", { className: "cls_not_connected_indicator w-1.5 h-1.5 rounded-full bg-slate-400" }), t("my_settings.connected_accounts.not_connected")] })) })] }) }), _jsx("p", { className: "cls_connected_accounts_help text-sm text-[var(--hazo-text-muted)] mt-4", children: googleConnected
|
|
18
|
+
? t("my_settings.connected_accounts.help_connected")
|
|
19
|
+
: t("my_settings.connected_accounts.help_not_connected") })] }));
|
|
17
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"danger_zone_section.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/danger_zone_section.tsx"],"names":[],"mappings":"AA2BA,MAAM,MAAM,sBAAsB,GAAG;IACnC,+FAA+F;IAC/F,KAAK,EAAE,MAAM,CAAC;IACd,uHAAuH;IACvH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,4DAA4D;IAC5D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAGF;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,OAAe,EACf,
|
|
1
|
+
{"version":3,"file":"danger_zone_section.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/danger_zone_section.tsx"],"names":[],"mappings":"AA2BA,MAAM,MAAM,sBAAsB,GAAG;IACnC,+FAA+F;IAC/F,KAAK,EAAE,MAAM,CAAC;IACd,uHAAuH;IACvH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sBAAsB;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sCAAsC;IACtC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iEAAiE;IACjE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,oDAAoD;IACpD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,4DAA4D;IAC5D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAGF;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,OAAe,EACf,OAAO,EACP,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,YAAiC,GAClC,EAAE,sBAAsB,sCAwKxB"}
|
|
@@ -15,7 +15,7 @@ import { Input } from "../../../ui/input.js";
|
|
|
15
15
|
import { AlertDialog, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "../../../ui/alert-dialog.js";
|
|
16
16
|
import { FormFieldWrapper } from "../../shared/components/form_field_wrapper.js";
|
|
17
17
|
import { trigger_auth_status_refresh } from "../../shared/hooks/use_auth_status.js";
|
|
18
|
-
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider.js";
|
|
18
|
+
import { useHazoAuthConfig, useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
19
19
|
// section: component
|
|
20
20
|
/**
|
|
21
21
|
* Danger Zone Section for My Settings
|
|
@@ -25,9 +25,18 @@ import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider.js";
|
|
|
25
25
|
* account-deletion API route and signs the user out on success.
|
|
26
26
|
* Renders nothing when `enabled` is false (config-gated, default off).
|
|
27
27
|
*/
|
|
28
|
-
export function DangerZoneSection({ email, enabled = false, heading
|
|
28
|
+
export function DangerZoneSection({ email, enabled = false, heading, description, deleteButtonLabel, dialogTitle, dialogDescription, confirmInputLabel, confirmButtonLabel, cancelButtonLabel, redirectPath = "/hazo_auth/login", }) {
|
|
29
29
|
const { apiBasePath } = useHazoAuthConfig();
|
|
30
|
+
const t = useAuthT();
|
|
30
31
|
const router = useRouter();
|
|
32
|
+
const resolvedHeading = heading !== null && heading !== void 0 ? heading : t("my_settings.danger_zone.heading");
|
|
33
|
+
const resolvedDescription = description !== null && description !== void 0 ? description : t("my_settings.danger_zone.description");
|
|
34
|
+
const resolvedDeleteButtonLabel = deleteButtonLabel !== null && deleteButtonLabel !== void 0 ? deleteButtonLabel : t("my_settings.danger_zone.delete_button");
|
|
35
|
+
const resolvedDialogTitle = dialogTitle !== null && dialogTitle !== void 0 ? dialogTitle : t("my_settings.danger_zone.dialog_title");
|
|
36
|
+
const resolvedDialogDescription = dialogDescription !== null && dialogDescription !== void 0 ? dialogDescription : t("my_settings.danger_zone.dialog_description");
|
|
37
|
+
const resolvedConfirmInputLabel = confirmInputLabel !== null && confirmInputLabel !== void 0 ? confirmInputLabel : t("my_settings.danger_zone.confirm_input_label");
|
|
38
|
+
const resolvedConfirmButtonLabel = confirmButtonLabel !== null && confirmButtonLabel !== void 0 ? confirmButtonLabel : t("my_settings.danger_zone.confirm_button");
|
|
39
|
+
const resolvedCancelButtonLabel = cancelButtonLabel !== null && cancelButtonLabel !== void 0 ? cancelButtonLabel : t("shared.cancel_button");
|
|
31
40
|
const [dialogOpen, setDialogOpen] = useState(false);
|
|
32
41
|
const [confirmEmail, setConfirmEmail] = useState("");
|
|
33
42
|
const [loading, setLoading] = useState(false);
|
|
@@ -68,12 +77,12 @@ export function DangerZoneSection({ email, enabled = false, heading = "Danger Zo
|
|
|
68
77
|
});
|
|
69
78
|
const data = await response.json();
|
|
70
79
|
if (!response.ok || !data.success) {
|
|
71
|
-
const errorMessage = data.error || "
|
|
80
|
+
const errorMessage = data.error || t("my_settings.danger_zone.error.default");
|
|
72
81
|
toast.error(errorMessage);
|
|
73
82
|
setLoading(false);
|
|
74
83
|
return;
|
|
75
84
|
}
|
|
76
|
-
toast.success("
|
|
85
|
+
toast.success(t("my_settings.danger_zone.success"));
|
|
77
86
|
setDialogOpen(false);
|
|
78
87
|
resetDialogState();
|
|
79
88
|
// Sign the user out client-side and send them away from the now-deleted account
|
|
@@ -81,7 +90,7 @@ export function DangerZoneSection({ email, enabled = false, heading = "Danger Zo
|
|
|
81
90
|
router.push(redirectPath);
|
|
82
91
|
}
|
|
83
92
|
catch (error) {
|
|
84
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
93
|
+
const errorMessage = error instanceof Error ? error.message : t("my_settings.danger_zone.error.default");
|
|
85
94
|
toast.error(errorMessage);
|
|
86
95
|
setLoading(false);
|
|
87
96
|
}
|
|
@@ -89,5 +98,5 @@ export function DangerZoneSection({ email, enabled = false, heading = "Danger Zo
|
|
|
89
98
|
if (!enabled) {
|
|
90
99
|
return null;
|
|
91
100
|
}
|
|
92
|
-
return (_jsxs("div", { className: "cls_my_settings_danger_zone_section bg-white rounded-lg border border-red-200 p-6", children: [_jsxs("div", { className: "cls_danger_zone_header flex items-center gap-2 mb-2", children: [_jsx(AlertTriangle, { className: "h-5 w-5 text-red-600", "aria-hidden": "true" }), _jsx("h2", { className: "cls_danger_zone_heading text-lg font-semibold text-red-700", children:
|
|
101
|
+
return (_jsxs("div", { className: "cls_my_settings_danger_zone_section bg-white rounded-lg border border-red-200 p-6", children: [_jsxs("div", { className: "cls_danger_zone_header flex items-center gap-2 mb-2", children: [_jsx(AlertTriangle, { className: "h-5 w-5 text-red-600", "aria-hidden": "true" }), _jsx("h2", { className: "cls_danger_zone_heading text-lg font-semibold text-red-700", children: resolvedHeading })] }), _jsx("p", { className: "cls_danger_zone_description text-sm text-[var(--hazo-text-muted)] mb-4", children: resolvedDescription }), _jsx("div", { className: "cls_danger_zone_actions flex justify-end", children: _jsx(Button, { type: "button", onClick: () => setDialogOpen(true), variant: "destructive", className: "cls_danger_zone_delete_button", "aria-label": resolvedDeleteButtonLabel, children: resolvedDeleteButtonLabel }) }), _jsx(AlertDialog, { open: dialogOpen, onOpenChange: handleOpenChange, children: _jsxs(AlertDialogContent, { className: "cls_delete_account_dialog", children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { className: "cls_delete_account_dialog_title", children: resolvedDialogTitle }), _jsx(AlertDialogDescription, { className: "cls_delete_account_dialog_description", children: resolvedDialogDescription })] }), _jsx("div", { className: "cls_delete_account_dialog_content py-2", children: _jsx(FormFieldWrapper, { fieldId: "delete-account-confirm-email", label: resolvedConfirmInputLabel, input: _jsx(Input, { id: "delete-account-confirm-email", type: "email", value: confirmEmail, onChange: (event) => setConfirmEmail(event.target.value), placeholder: email, autoComplete: "off", disabled: loading, "aria-label": resolvedConfirmInputLabel, className: "cls_delete_account_confirm_input" }) }) }), _jsxs(AlertDialogFooter, { children: [_jsx(Button, { type: "button", onClick: handleDeleteAccount, disabled: !emailMatches || loading, variant: "destructive", className: "cls_delete_account_confirm_button", "aria-label": resolvedConfirmButtonLabel, children: loading ? t("my_settings.danger_zone.deleting") : resolvedConfirmButtonLabel }), _jsx(Button, { type: "button", onClick: () => handleOpenChange(false), disabled: loading, variant: "outline", className: "cls_delete_account_cancel_button", "aria-label": resolvedCancelButtonLabel, children: resolvedCancelButtonLabel })] })] }) })] }));
|
|
93
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editable_field.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/editable_field.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"editable_field.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/editable_field.tsx"],"names":[],"mappings":"AAaA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,CAAC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAC9C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAGF;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,KAAK,EACL,IAAa,EACb,WAAW,EACX,MAAM,EACN,QAAQ,EACR,UAAU,EACV,QAAgB,EAChB,SAAS,GACV,EAAE,kBAAkB,+BAuIpB"}
|
|
@@ -8,6 +8,7 @@ import { Input } from "../../../ui/input.js";
|
|
|
8
8
|
import { Label } from "../../../ui/label.js";
|
|
9
9
|
import { Button } from "../../../ui/button.js";
|
|
10
10
|
import { Pencil, CheckCircle2, XCircle } from "lucide-react";
|
|
11
|
+
import { useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
11
12
|
// section: component
|
|
12
13
|
/**
|
|
13
14
|
* Editable field component with pencil icon for edit mode
|
|
@@ -16,6 +17,7 @@ import { Pencil, CheckCircle2, XCircle } from "lucide-react";
|
|
|
16
17
|
* @returns Editable field component
|
|
17
18
|
*/
|
|
18
19
|
export function EditableField({ label, value, type = "text", placeholder, onSave, onCancel, validation, disabled = false, ariaLabel, }) {
|
|
20
|
+
const t = useAuthT();
|
|
19
21
|
const [isEditing, setIsEditing] = useState(false);
|
|
20
22
|
const [editValue, setEditValue] = useState(value);
|
|
21
23
|
const [error, setError] = useState(null);
|
|
@@ -54,7 +56,7 @@ export function EditableField({ label, value, type = "text", placeholder, onSave
|
|
|
54
56
|
setIsEditing(false);
|
|
55
57
|
}
|
|
56
58
|
catch (error) {
|
|
57
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
59
|
+
const errorMessage = error instanceof Error ? error.message : t("my_settings.editable_field.save_error_default");
|
|
58
60
|
setError(errorMessage);
|
|
59
61
|
}
|
|
60
62
|
finally {
|
|
@@ -69,5 +71,5 @@ export function EditableField({ label, value, type = "text", placeholder, onSave
|
|
|
69
71
|
handleCancel();
|
|
70
72
|
}
|
|
71
73
|
};
|
|
72
|
-
return (_jsxs("div", { className: "cls_editable_field flex flex-col gap-2", children: [_jsx(Label, { htmlFor: `editable-field-${label}`, className: "cls_editable_field_label text-sm font-medium text-[var(--hazo-text-secondary)]", children: label }), _jsx("div", { className: "cls_editable_field_input_container flex items-center gap-2", children: isEditing ? (_jsxs(_Fragment, { children: [_jsx(Input, { id: `editable-field-${label}`, type: type, value: editValue, onChange: (e) => setEditValue(e.target.value), onKeyDown: handleKeyDown, placeholder: placeholder, disabled: isSaving, "aria-label": ariaLabel || label, className: "cls_editable_field_input flex-1" }), _jsx(Button, { type: "button", onClick: handleSave, disabled: isSaving, variant: "ghost", size: "icon", className: "cls_editable_field_save_button text-green-600 hover:text-green-700 hover:bg-green-50", "aria-label": "
|
|
74
|
+
return (_jsxs("div", { className: "cls_editable_field flex flex-col gap-2", children: [_jsx(Label, { htmlFor: `editable-field-${label}`, className: "cls_editable_field_label text-sm font-medium text-[var(--hazo-text-secondary)]", children: label }), _jsx("div", { className: "cls_editable_field_input_container flex items-center gap-2", children: isEditing ? (_jsxs(_Fragment, { children: [_jsx(Input, { id: `editable-field-${label}`, type: type, value: editValue, onChange: (e) => setEditValue(e.target.value), onKeyDown: handleKeyDown, placeholder: placeholder, disabled: isSaving, "aria-label": ariaLabel || label, className: "cls_editable_field_input flex-1" }), _jsx(Button, { type: "button", onClick: handleSave, disabled: isSaving, variant: "ghost", size: "icon", className: "cls_editable_field_save_button text-green-600 hover:text-green-700 hover:bg-green-50", "aria-label": t("my_settings.editable_field.save_aria_default"), children: _jsx(CheckCircle2, { className: "h-5 w-5", "aria-hidden": "true" }) }), _jsx(Button, { type: "button", onClick: handleCancel, disabled: isSaving, variant: "ghost", size: "icon", className: "cls_editable_field_cancel_button text-red-600 hover:text-red-700 hover:bg-red-50", "aria-label": t("my_settings.editable_field.cancel_aria_default"), children: _jsx(XCircle, { className: "h-5 w-5", "aria-hidden": "true" }) })] })) : (_jsxs(_Fragment, { children: [_jsx(Input, { id: `editable-field-${label}`, type: type, value: value || "", readOnly: true, disabled: true, placeholder: value ? undefined : placeholder || t("my_settings.editable_field.not_set_placeholder"), "aria-label": ariaLabel || label, className: "cls_editable_field_display flex-1 bg-[var(--hazo-bg-subtle)] cursor-not-allowed" }), !disabled && (_jsx(Button, { type: "button", onClick: handleEdit, variant: "ghost", size: "icon", className: "cls_editable_field_edit_button text-[var(--hazo-text-muted)] hover:text-[var(--hazo-text-secondary)] hover:bg-[var(--hazo-bg-subtle)]", "aria-label": t("my_settings.editable_field.edit_aria_default", { label }), children: _jsx(Pencil, { className: "h-5 w-5", "aria-hidden": "true" }) }))] })) }), error && (_jsx("p", { className: "cls_editable_field_error text-sm text-red-600", role: "alert", children: error }))] }));
|
|
73
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"language_picker_section.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/language_picker_section.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"language_picker_section.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/language_picker_section.tsx"],"names":[],"mappings":"AAmBA,MAAM,MAAM,eAAe,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,0BAA0B,GAAG;IACvC,sFAAsF;IACtF,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC,8EAA8E;IAC9E,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,6EAA6E;IAC7E,cAAc,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAGF;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,QAAgB,EAChB,KAAK,EACL,WAAW,GACZ,EAAE,0BAA0B,sCAsD5B"}
|
|
@@ -8,6 +8,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
8
8
|
import { useState } from "react";
|
|
9
9
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "../../../ui/select.js";
|
|
10
10
|
import { FormFieldWrapper } from "../../shared/components/form_field_wrapper.js";
|
|
11
|
+
import { useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
11
12
|
// section: component
|
|
12
13
|
/**
|
|
13
14
|
* Renders a Select for choosing a preferred locale.
|
|
@@ -15,7 +16,10 @@ import { FormFieldWrapper } from "../../shared/components/form_field_wrapper.js"
|
|
|
15
16
|
* @param props - Component props
|
|
16
17
|
* @returns Language picker field, or null when not applicable
|
|
17
18
|
*/
|
|
18
|
-
export function LanguagePickerSection({ availableLocales, currentLocale, onLocaleChange, disabled = false, label
|
|
19
|
+
export function LanguagePickerSection({ availableLocales, currentLocale, onLocaleChange, disabled = false, label, placeholder, }) {
|
|
20
|
+
const t = useAuthT();
|
|
21
|
+
const resolvedLabel = label !== null && label !== void 0 ? label : t("my_settings.language_picker.label");
|
|
22
|
+
const resolvedPlaceholder = placeholder !== null && placeholder !== void 0 ? placeholder : t("my_settings.language_picker.placeholder");
|
|
19
23
|
const [saving, setSaving] = useState(false);
|
|
20
24
|
if (!availableLocales || availableLocales.length < 2) {
|
|
21
25
|
return null;
|
|
@@ -34,7 +38,7 @@ export function LanguagePickerSection({ availableLocales, currentLocale, onLocal
|
|
|
34
38
|
setSaving(false);
|
|
35
39
|
}
|
|
36
40
|
};
|
|
37
|
-
return (_jsx("div", { className: "cls_language_picker_section", children: _jsx(FormFieldWrapper, { fieldId: "preferred-locale", label:
|
|
41
|
+
return (_jsx("div", { className: "cls_language_picker_section", children: _jsx(FormFieldWrapper, { fieldId: "preferred-locale", label: resolvedLabel, input: _jsxs(Select, { value: currentLocale !== null && currentLocale !== void 0 ? currentLocale : undefined, onValueChange: (value) => {
|
|
38
42
|
void handleValueChange(value);
|
|
39
|
-
}, disabled: disabled || saving, children: [_jsx(SelectTrigger, { id: "preferred-locale", className: "cls_language_picker_section_trigger", "aria-label":
|
|
43
|
+
}, disabled: disabled || saving, children: [_jsx(SelectTrigger, { id: "preferred-locale", className: "cls_language_picker_section_trigger", "aria-label": resolvedLabel, children: _jsx(SelectValue, { placeholder: resolvedPlaceholder }) }), _jsx(SelectContent, { children: availableLocales.map((locale) => (_jsx(SelectItem, { value: locale.code, children: locale.label }, locale.code))) })] }) }) }));
|
|
40
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password_change_dialog.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/password_change_dialog.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"password_change_dialog.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/password_change_dialog.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAI3F,MAAM,MAAM,aAAa,GAAG;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,oBAAoB,EAAE,0BAA0B,CAAC;IACjD,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAGF;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,GAClB,EAAE,yBAAyB,+BAuP3B"}
|
|
@@ -8,6 +8,7 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, }
|
|
|
8
8
|
import { Button } from "../../../ui/button.js";
|
|
9
9
|
import { PasswordField } from "../../shared/components/password_field.js";
|
|
10
10
|
import { FormFieldWrapper } from "../../shared/components/form_field_wrapper.js";
|
|
11
|
+
import { useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
11
12
|
// section: component
|
|
12
13
|
/**
|
|
13
14
|
* Dialog component for changing password
|
|
@@ -16,7 +17,13 @@ import { FormFieldWrapper } from "../../shared/components/form_field_wrapper.js"
|
|
|
16
17
|
* @param props - Component props including open state, onSave callback, password requirements
|
|
17
18
|
* @returns Password change dialog component
|
|
18
19
|
*/
|
|
19
|
-
export function PasswordChangeDialog({ open, onOpenChange, onSave, passwordRequirements, buttonPalette, currentPasswordLabel
|
|
20
|
+
export function PasswordChangeDialog({ open, onOpenChange, onSave, passwordRequirements, buttonPalette, currentPasswordLabel, newPasswordLabel, confirmPasswordLabel, saveButtonLabel, cancelButtonLabel, }) {
|
|
21
|
+
const t = useAuthT();
|
|
22
|
+
const resolvedCurrentPasswordLabel = currentPasswordLabel !== null && currentPasswordLabel !== void 0 ? currentPasswordLabel : t("my_settings.password_change_dialog.current_password_label_default");
|
|
23
|
+
const resolvedNewPasswordLabel = newPasswordLabel !== null && newPasswordLabel !== void 0 ? newPasswordLabel : t("my_settings.password_change_dialog.new_password_label_default");
|
|
24
|
+
const resolvedConfirmPasswordLabel = confirmPasswordLabel !== null && confirmPasswordLabel !== void 0 ? confirmPasswordLabel : t("my_settings.password_change_dialog.confirm_password_label_default");
|
|
25
|
+
const resolvedSaveButtonLabel = saveButtonLabel !== null && saveButtonLabel !== void 0 ? saveButtonLabel : t("shared.save_button");
|
|
26
|
+
const resolvedCancelButtonLabel = cancelButtonLabel !== null && cancelButtonLabel !== void 0 ? cancelButtonLabel : t("shared.cancel_button");
|
|
20
27
|
const [currentPassword, setCurrentPassword] = useState("");
|
|
21
28
|
const [newPassword, setNewPassword] = useState("");
|
|
22
29
|
const [confirmPassword, setConfirmPassword] = useState("");
|
|
@@ -27,40 +34,40 @@ export function PasswordChangeDialog({ open, onOpenChange, onSave, passwordRequi
|
|
|
27
34
|
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
28
35
|
const validatePassword = (password) => {
|
|
29
36
|
if (!password || password.length < passwordRequirements.minimum_length) {
|
|
30
|
-
return
|
|
37
|
+
return t("my_settings.set_password.validation.min_length", { length: passwordRequirements.minimum_length });
|
|
31
38
|
}
|
|
32
39
|
const errors = [];
|
|
33
40
|
if (passwordRequirements.require_uppercase && !/[A-Z]/.test(password)) {
|
|
34
|
-
errors.push("
|
|
41
|
+
errors.push(t("my_settings.set_password.validation.uppercase_item"));
|
|
35
42
|
}
|
|
36
43
|
if (passwordRequirements.require_lowercase && !/[a-z]/.test(password)) {
|
|
37
|
-
errors.push("
|
|
44
|
+
errors.push(t("my_settings.set_password.validation.lowercase_item"));
|
|
38
45
|
}
|
|
39
46
|
if (passwordRequirements.require_number && !/[0-9]/.test(password)) {
|
|
40
|
-
errors.push("
|
|
47
|
+
errors.push(t("my_settings.set_password.validation.number_item"));
|
|
41
48
|
}
|
|
42
49
|
if (passwordRequirements.require_special && !/[^A-Za-z0-9]/.test(password)) {
|
|
43
|
-
errors.push("
|
|
50
|
+
errors.push(t("my_settings.set_password.validation.special_item"));
|
|
44
51
|
}
|
|
45
52
|
if (errors.length > 0) {
|
|
46
|
-
return
|
|
53
|
+
return t("my_settings.set_password.validation.missing_requirements", { list: errors.join(", ") });
|
|
47
54
|
}
|
|
48
55
|
return null;
|
|
49
56
|
};
|
|
50
57
|
const validateForm = () => {
|
|
51
58
|
const newErrors = {};
|
|
52
59
|
if (!currentPassword) {
|
|
53
|
-
newErrors.currentPassword = "
|
|
60
|
+
newErrors.currentPassword = t("my_settings.password_change_dialog.current_password_required");
|
|
54
61
|
}
|
|
55
62
|
const newPasswordError = validatePassword(newPassword);
|
|
56
63
|
if (newPasswordError) {
|
|
57
64
|
newErrors.newPassword = newPasswordError;
|
|
58
65
|
}
|
|
59
66
|
if (!confirmPassword) {
|
|
60
|
-
newErrors.confirmPassword = "
|
|
67
|
+
newErrors.confirmPassword = t("my_settings.set_password.validation.confirm_required");
|
|
61
68
|
}
|
|
62
69
|
else if (newPassword !== confirmPassword) {
|
|
63
|
-
newErrors.confirmPassword = "
|
|
70
|
+
newErrors.confirmPassword = t("my_settings.set_password.validation.mismatch");
|
|
64
71
|
}
|
|
65
72
|
setErrors(newErrors);
|
|
66
73
|
return Object.keys(newErrors).length === 0;
|
|
@@ -80,7 +87,7 @@ export function PasswordChangeDialog({ open, onOpenChange, onSave, passwordRequi
|
|
|
80
87
|
onOpenChange(false);
|
|
81
88
|
}
|
|
82
89
|
catch (error) {
|
|
83
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
90
|
+
const errorMessage = error instanceof Error ? error.message : t("my_settings.password_change_dialog.error_default");
|
|
84
91
|
setErrors({ currentPassword: errorMessage });
|
|
85
92
|
}
|
|
86
93
|
finally {
|
|
@@ -97,33 +104,33 @@ export function PasswordChangeDialog({ open, onOpenChange, onSave, passwordRequi
|
|
|
97
104
|
// Format password requirements for display
|
|
98
105
|
const getPasswordRequirements = () => {
|
|
99
106
|
const requirements = [];
|
|
100
|
-
requirements.push(
|
|
107
|
+
requirements.push(t("my_settings.password_change_dialog.requirements.min_length", { length: passwordRequirements.minimum_length }));
|
|
101
108
|
if (passwordRequirements.require_uppercase) {
|
|
102
|
-
requirements.push("
|
|
109
|
+
requirements.push(t("my_settings.password_change_dialog.requirements.uppercase"));
|
|
103
110
|
}
|
|
104
111
|
if (passwordRequirements.require_lowercase) {
|
|
105
|
-
requirements.push("
|
|
112
|
+
requirements.push(t("my_settings.password_change_dialog.requirements.lowercase"));
|
|
106
113
|
}
|
|
107
114
|
if (passwordRequirements.require_number) {
|
|
108
|
-
requirements.push("
|
|
115
|
+
requirements.push(t("my_settings.password_change_dialog.requirements.number"));
|
|
109
116
|
}
|
|
110
117
|
if (passwordRequirements.require_special) {
|
|
111
|
-
requirements.push("
|
|
118
|
+
requirements.push(t("my_settings.password_change_dialog.requirements.special"));
|
|
112
119
|
}
|
|
113
120
|
return requirements;
|
|
114
121
|
};
|
|
115
122
|
const passwordRequirementsList = getPasswordRequirements();
|
|
116
|
-
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "cls_password_change_dialog max-w-md", children: [_jsxs(DialogHeader, { className: "cls_password_change_dialog_header", children: [_jsx(DialogTitle, { className: "cls_password_change_dialog_title", children: "
|
|
123
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "cls_password_change_dialog max-w-md", children: [_jsxs(DialogHeader, { className: "cls_password_change_dialog_header", children: [_jsx(DialogTitle, { className: "cls_password_change_dialog_title", children: t("my_settings.password_change_dialog.title") }), _jsx(DialogDescription, { className: "cls_password_change_dialog_description", children: t("my_settings.password_change_dialog.description") })] }), _jsxs("div", { className: "cls_password_change_dialog_content flex flex-col gap-4 py-4", children: [_jsx(FormFieldWrapper, { fieldId: "current-password", label: resolvedCurrentPasswordLabel, input: _jsx(PasswordField, { inputId: "current-password", ariaLabel: resolvedCurrentPasswordLabel, value: currentPassword, placeholder: t("my_settings.current_password_placeholder_default"), autoComplete: "current-password", isVisible: currentPasswordVisible, onChange: (value) => {
|
|
117
124
|
setCurrentPassword(value);
|
|
118
125
|
if (errors.currentPassword) {
|
|
119
126
|
setErrors(Object.assign(Object.assign({}, errors), { currentPassword: undefined }));
|
|
120
127
|
}
|
|
121
|
-
}, onToggleVisibility: () => setCurrentPasswordVisible(!currentPasswordVisible), errorMessage: errors.currentPassword }) }), _jsx(FormFieldWrapper, { fieldId: "new-password", label:
|
|
128
|
+
}, onToggleVisibility: () => setCurrentPasswordVisible(!currentPasswordVisible), errorMessage: errors.currentPassword }) }), _jsx(FormFieldWrapper, { fieldId: "new-password", label: resolvedNewPasswordLabel, input: _jsx(PasswordField, { inputId: "new-password", ariaLabel: resolvedNewPasswordLabel, value: newPassword, placeholder: t("my_settings.set_password.new_password_placeholder"), autoComplete: "new-password", isVisible: newPasswordVisible, onChange: (value) => {
|
|
122
129
|
setNewPassword(value);
|
|
123
130
|
if (errors.newPassword) {
|
|
124
131
|
setErrors(Object.assign(Object.assign({}, errors), { newPassword: undefined }));
|
|
125
132
|
}
|
|
126
|
-
}, onToggleVisibility: () => setNewPasswordVisible(!newPasswordVisible), errorMessage: errors.newPassword }) }), passwordRequirementsList.length > 0 && (_jsxs("div", { className: "cls_password_change_dialog_requirements text-xs text-[var(--hazo-text-muted)]", children: [_jsx("p", { className: "cls_password_change_dialog_requirements_label font-medium mb-1", children: "
|
|
133
|
+
}, onToggleVisibility: () => setNewPasswordVisible(!newPasswordVisible), errorMessage: errors.newPassword }) }), passwordRequirementsList.length > 0 && (_jsxs("div", { className: "cls_password_change_dialog_requirements text-xs text-[var(--hazo-text-muted)]", children: [_jsx("p", { className: "cls_password_change_dialog_requirements_label font-medium mb-1", children: t("my_settings.password_change_dialog.requirements_label") }), _jsx("ul", { className: "cls_password_change_dialog_requirements_list list-disc list-inside space-y-0.5", children: passwordRequirementsList.map((req, index) => (_jsx("li", { children: req }, index))) })] })), _jsx(FormFieldWrapper, { fieldId: "confirm-password", label: resolvedConfirmPasswordLabel, input: _jsx(PasswordField, { inputId: "confirm-password", ariaLabel: resolvedConfirmPasswordLabel, value: confirmPassword, placeholder: t("my_settings.set_password.confirm_password_placeholder"), autoComplete: "new-password", isVisible: confirmPasswordVisible, onChange: (value) => {
|
|
127
134
|
setConfirmPassword(value);
|
|
128
135
|
if (errors.confirmPassword) {
|
|
129
136
|
setErrors(Object.assign(Object.assign({}, errors), { confirmPassword: undefined }));
|
|
@@ -131,8 +138,8 @@ export function PasswordChangeDialog({ open, onOpenChange, onSave, passwordRequi
|
|
|
131
138
|
}, onToggleVisibility: () => setConfirmPasswordVisible(!confirmPasswordVisible), errorMessage: errors.confirmPassword }) })] }), _jsxs("div", { className: "cls_password_change_dialog_actions flex justify-end gap-3 pt-4 border-t", children: [_jsx(Button, { type: "button", onClick: handleSave, disabled: isSubmitting, className: "cls_password_change_dialog_save_button", style: buttonPalette ? {
|
|
132
139
|
backgroundColor: buttonPalette.submitBackground,
|
|
133
140
|
color: buttonPalette.submitText,
|
|
134
|
-
} : undefined, "aria-label":
|
|
141
|
+
} : undefined, "aria-label": resolvedSaveButtonLabel, children: resolvedSaveButtonLabel }), _jsx(Button, { type: "button", onClick: handleCancel, disabled: isSubmitting, variant: "outline", className: "cls_password_change_dialog_cancel_button", style: buttonPalette ? {
|
|
135
142
|
borderColor: buttonPalette.cancelBorder,
|
|
136
143
|
color: buttonPalette.cancelText,
|
|
137
|
-
} : undefined, "aria-label":
|
|
144
|
+
} : undefined, "aria-label": resolvedCancelButtonLabel, children: resolvedCancelButtonLabel })] })] }) }));
|
|
138
145
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile_picture_dialog.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/profile_picture_dialog.tsx"],"names":[],"mappings":"AAuBA,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,CAAC,iBAAiB,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvG,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,oBAAoB,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IACpE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE;QACR,6BAA6B,EAAE,MAAM,CAAC;QACtC,sBAAsB,EAAE,MAAM,CAAC;QAC/B,2BAA2B,EAAE,MAAM,CAAC;QACpC,uBAAuB,EAAE,MAAM,CAAC;KACjC,CAAC;IACF,OAAO,EAAE;QACP,aAAa,EAAE,MAAM,CAAC;QACtB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,yBAAyB,EAAE,MAAM,CAAC;QAClC,uBAAuB,EAAE,MAAM,CAAC;QAChC,0BAA0B,EAAE,MAAM,CAAC;QACnC,0BAA0B,EAAE,MAAM,CAAC;QACnC,+BAA+B,EAAE,MAAM,CAAC;QACxC,4BAA4B,EAAE,MAAM,CAAC;KACtC,CAAC;IACF,SAAS,EAAE;QACT,wBAAwB,EAAE,MAAM,EAAE,CAAC;QACnC,wBAAwB,EAAE,MAAM,EAAE,CAAC;KACpC,CAAC;CACH,CAAC;AAGF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,KAAK,EACL,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,EACpB,
|
|
1
|
+
{"version":3,"file":"profile_picture_dialog.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/profile_picture_dialog.tsx"],"names":[],"mappings":"AAuBA,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,MAAM,EAAE,CAAC,iBAAiB,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvG,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,oBAAoB,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IACpE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE;QACR,6BAA6B,EAAE,MAAM,CAAC;QACtC,sBAAsB,EAAE,MAAM,CAAC;QAC/B,2BAA2B,EAAE,MAAM,CAAC;QACpC,uBAAuB,EAAE,MAAM,CAAC;KACjC,CAAC;IACF,OAAO,EAAE;QACP,aAAa,EAAE,MAAM,CAAC;QACtB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,yBAAyB,EAAE,MAAM,CAAC;QAClC,uBAAuB,EAAE,MAAM,CAAC;QAChC,0BAA0B,EAAE,MAAM,CAAC;QACnC,0BAA0B,EAAE,MAAM,CAAC;QACnC,+BAA+B,EAAE,MAAM,CAAC;QACxC,4BAA4B,EAAE,MAAM,CAAC;KACtC,CAAC;IACF,SAAS,EAAE;QACT,wBAAwB,EAAE,MAAM,EAAE,CAAC;QACnC,wBAAwB,EAAE,MAAM,EAAE,CAAC;KACpC,CAAC;CACH,CAAC;AAGF;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,IAAI,EACJ,YAAY,EACZ,MAAM,EACN,KAAK,EACL,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,EACxB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,QAAgB,EAChB,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE,yBAAyB,+BAmT3B"}
|
|
@@ -12,7 +12,7 @@ import { ProfilePictureLibraryTab } from "./profile_picture_library_tab.js";
|
|
|
12
12
|
import { ProfilePictureGravatarTab } from "./profile_picture_gravatar_tab.js";
|
|
13
13
|
import { toast } from "sonner";
|
|
14
14
|
import { cn } from "../../../../lib/utils.js";
|
|
15
|
-
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider.js";
|
|
15
|
+
import { useHazoAuthConfig, useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
16
16
|
// section: component
|
|
17
17
|
/**
|
|
18
18
|
* Profile picture dialog component with tabs for Upload, Library, and Gravatar
|
|
@@ -20,8 +20,11 @@ import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider.js";
|
|
|
20
20
|
* @param props - Component props including open state, save handler, and configuration
|
|
21
21
|
* @returns Profile picture dialog component
|
|
22
22
|
*/
|
|
23
|
-
export function ProfilePictureDialog({ open, onOpenChange, onSave, email, allowPhotoUpload, maxPhotoSize, libraryPhotoPath, currentProfilePictureUrl, currentProfileSource, saveButtonLabel
|
|
23
|
+
export function ProfilePictureDialog({ open, onOpenChange, onSave, email, allowPhotoUpload, maxPhotoSize, libraryPhotoPath, currentProfilePictureUrl, currentProfileSource, saveButtonLabel, cancelButtonLabel, disabled = false, messages, uiSizes, fileTypes, }) {
|
|
24
24
|
const { apiBasePath } = useHazoAuthConfig();
|
|
25
|
+
const t = useAuthT();
|
|
26
|
+
const resolvedSaveLabel = saveButtonLabel !== null && saveButtonLabel !== void 0 ? saveButtonLabel : t("my_settings.profile_picture_dialog.save_button");
|
|
27
|
+
const resolvedCancelLabel = cancelButtonLabel !== null && cancelButtonLabel !== void 0 ? cancelButtonLabel : t("my_settings.profile_picture_dialog.cancel_button");
|
|
25
28
|
const [useUpload, setUseUpload] = useState(false);
|
|
26
29
|
const [useLibrary, setUseLibrary] = useState(false);
|
|
27
30
|
const [useGravatar, setUseGravatar] = useState(false);
|
|
@@ -135,16 +138,16 @@ export function ProfilePictureDialog({ open, onOpenChange, onSave, email, allowP
|
|
|
135
138
|
});
|
|
136
139
|
const data = await response.json();
|
|
137
140
|
if (!response.ok || !data.success) {
|
|
138
|
-
const errorMessage = data.error || "
|
|
141
|
+
const errorMessage = data.error || t("my_settings.profile_picture_dialog.upload_failed");
|
|
139
142
|
toast.error(errorMessage);
|
|
140
143
|
setUploadedFile(null);
|
|
141
144
|
return;
|
|
142
145
|
}
|
|
143
146
|
setSelectedPhotoUrl(data.profile_picture_url);
|
|
144
|
-
toast.success("
|
|
147
|
+
toast.success(t("my_settings.profile_picture_dialog.upload_success"));
|
|
145
148
|
}
|
|
146
149
|
catch (error) {
|
|
147
|
-
const errorMessage = error instanceof Error ? error.message : "
|
|
150
|
+
const errorMessage = error instanceof Error ? error.message : t("my_settings.profile_picture_dialog.upload_failed");
|
|
148
151
|
toast.error(errorMessage);
|
|
149
152
|
setUploadedFile(null);
|
|
150
153
|
}
|
|
@@ -161,15 +164,15 @@ export function ProfilePictureDialog({ open, onOpenChange, onSave, email, allowP
|
|
|
161
164
|
};
|
|
162
165
|
const handleSave = async () => {
|
|
163
166
|
if (!selectedSource) {
|
|
164
|
-
toast.error("
|
|
167
|
+
toast.error(t("my_settings.profile_picture_dialog.select_source"));
|
|
165
168
|
return;
|
|
166
169
|
}
|
|
167
170
|
if (selectedSource === "upload" && !selectedPhotoUrl) {
|
|
168
|
-
toast.error("
|
|
171
|
+
toast.error(t("my_settings.profile_picture_dialog.upload_first"));
|
|
169
172
|
return;
|
|
170
173
|
}
|
|
171
174
|
if (selectedSource === "library" && !selectedPhotoUrl) {
|
|
172
|
-
toast.error("
|
|
175
|
+
toast.error(t("my_settings.profile_picture_dialog.select_library_photo"));
|
|
173
176
|
return;
|
|
174
177
|
}
|
|
175
178
|
if (selectedSource === "gravatar") {
|
|
@@ -196,5 +199,5 @@ export function ProfilePictureDialog({ open, onOpenChange, onSave, email, allowP
|
|
|
196
199
|
setUploadedFile(null);
|
|
197
200
|
onOpenChange(false);
|
|
198
201
|
};
|
|
199
|
-
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "cls_profile_picture_dialog max-w-4xl max-h-[90vh] overflow-y-auto", children: [_jsxs(DialogHeader, { className: "cls_profile_picture_dialog_header", children: [_jsx(DialogTitle, { className: "cls_profile_picture_dialog_title", children: "
|
|
202
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { className: "cls_profile_picture_dialog max-w-4xl max-h-[90vh] overflow-y-auto", children: [_jsxs(DialogHeader, { className: "cls_profile_picture_dialog_header", children: [_jsx(DialogTitle, { className: "cls_profile_picture_dialog_title", children: t("my_settings.profile_picture_dialog.title") }), _jsx(DialogDescription, { className: "cls_profile_picture_dialog_description", children: t("my_settings.profile_picture_dialog.description") })] }), _jsxs(Tabs, { value: activeTab, onValueChange: setActiveTab, className: "cls_profile_picture_dialog_tabs", children: [_jsxs(TabsList, { className: "cls_profile_picture_dialog_tabs_list", children: [allowPhotoUpload && (_jsx(TabsTrigger, { value: "upload", className: cn("cls_profile_picture_dialog_tabs_trigger", useUpload && "!text-blue-600 font-semibold data-[state=active]:!text-blue-600"), children: t("my_settings.profile_picture_dialog.tab_upload") })), _jsx(TabsTrigger, { value: "library", className: cn("cls_profile_picture_dialog_tabs_trigger", useLibrary && "!text-blue-600 font-semibold data-[state=active]:!text-blue-600"), children: t("my_settings.profile_picture_dialog.tab_library") }), _jsx(TabsTrigger, { value: "gravatar", className: cn("cls_profile_picture_dialog_tabs_trigger", useGravatar && "!text-blue-600 font-semibold data-[state=active]:!text-blue-600"), children: t("my_settings.profile_picture_dialog.tab_gravatar") })] }), allowPhotoUpload && (_jsx(TabsContent, { value: "upload", className: "cls_profile_picture_dialog_tabs_content", children: _jsx(ProfilePictureUploadTab, { useUpload: useUpload, onUseUploadChange: handleUseUploadChange, onFileSelect: handleFileSelect, maxSize: maxPhotoSize, uploadEnabled: allowPhotoUpload, disabled: disabled || uploading, currentPreview: currentProfilePictureUrl || selectedPhotoUrl || undefined, photoUploadDisabledMessage: messages.photo_upload_disabled_message, imageCompressionMaxDimension: uiSizes.image_compression_max_dimension, uploadFileHardLimitBytes: uiSizes.upload_file_hard_limit_bytes, allowedImageMimeTypes: fileTypes.allowed_image_mime_types }) })), _jsx(TabsContent, { value: "library", className: "cls_profile_picture_dialog_tabs_content", children: _jsx(ProfilePictureLibraryTab, { useLibrary: useLibrary, onUseLibraryChange: handleUseLibraryChange, onPhotoSelect: handlePhotoSelect, disabled: disabled, libraryPhotoPath: libraryPhotoPath, currentPhotoUrl: selectedPhotoUrl || undefined, libraryTooltipMessage: messages.library_tooltip_message, tooltipIconSizeSmall: uiSizes.tooltip_icon_size_small, libraryPhotoGridColumns: uiSizes.library_photo_grid_columns, libraryPhotoPreviewSize: uiSizes.library_photo_preview_size }) }), _jsx(TabsContent, { value: "gravatar", className: "cls_profile_picture_dialog_tabs_content", children: _jsx(ProfilePictureGravatarTab, { email: email, useGravatar: useGravatar, onUseGravatarChange: handleUseGravatarChange, disabled: disabled, gravatarSetupMessage: messages.gravatar_setup_message, gravatarNoAccountMessage: messages.gravatar_no_account_message, gravatarSize: uiSizes.gravatar_size }) })] }), _jsxs("div", { className: "cls_profile_picture_dialog_actions flex justify-end gap-3 pt-4 border-t", children: [_jsx(Button, { type: "button", onClick: handleSave, disabled: disabled || uploading || !selectedSource, className: "cls_profile_picture_dialog_save_button", "aria-label": resolvedSaveLabel, children: resolvedSaveLabel }), _jsx(Button, { type: "button", onClick: handleCancel, disabled: disabled || uploading, variant: "outline", className: "cls_profile_picture_dialog_cancel_button", "aria-label": resolvedCancelLabel, children: resolvedCancelLabel })] })] }) }));
|
|
200
203
|
}
|