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,6 +18,7 @@ import { PasswordField } from "../shared/components/password_field.js";
|
|
|
18
18
|
import { FormFieldWrapper } from "../shared/components/form_field_wrapper.js";
|
|
19
19
|
import { Pencil, Trash2 } from "lucide-react";
|
|
20
20
|
import { cn } from "../../../lib/utils.js";
|
|
21
|
+
import { useAuthT } from "../../../contexts/hazo_auth_provider.js";
|
|
21
22
|
// section: component
|
|
22
23
|
/**
|
|
23
24
|
* My Settings layout component with tabs for profile and security settings
|
|
@@ -26,17 +27,47 @@ import { cn } from "../../../lib/utils.js";
|
|
|
26
27
|
* @param props - Component props including labels, button colors, password requirements, etc.
|
|
27
28
|
* @returns My settings layout component
|
|
28
29
|
*/
|
|
29
|
-
export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage
|
|
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, }) {
|
|
30
31
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
31
|
-
const
|
|
32
|
+
const t = useAuthT();
|
|
33
|
+
const resolvedLabels = resolveMySettingsLabels(t, labels);
|
|
32
34
|
const resolvedButtonPalette = resolveMySettingsButtonPalette(button_colors);
|
|
35
|
+
const resolvedUnauthorizedMessage = unauthorizedMessage !== null && unauthorizedMessage !== void 0 ? unauthorizedMessage : t("shared.guard.unauthorized_message_default");
|
|
36
|
+
const resolvedLoginButtonLabel = loginButtonLabel !== null && loginButtonLabel !== void 0 ? loginButtonLabel : t("shared.guard.login_button_default");
|
|
37
|
+
const resolvedHeading = heading !== null && heading !== void 0 ? heading : t("my_settings.page_title");
|
|
38
|
+
const resolvedSubHeading = subHeading !== null && subHeading !== void 0 ? subHeading : t("my_settings.sub_heading_default");
|
|
39
|
+
const resolvedProfilePhotoLabel = profilePhotoLabel !== null && profilePhotoLabel !== void 0 ? profilePhotoLabel : t("my_settings.profile_photo_label_default");
|
|
40
|
+
const resolvedProfilePhotoRecommendation = profilePhotoRecommendation !== null && profilePhotoRecommendation !== void 0 ? profilePhotoRecommendation : t("my_settings.profile_photo_recommendation_default");
|
|
41
|
+
const resolvedUploadPhotoButtonLabel = uploadPhotoButtonLabel !== null && uploadPhotoButtonLabel !== void 0 ? uploadPhotoButtonLabel : t("my_settings.upload_photo_button_default");
|
|
42
|
+
const resolvedRemovePhotoButtonLabel = removePhotoButtonLabel !== null && removePhotoButtonLabel !== void 0 ? removePhotoButtonLabel : t("my_settings.remove_photo_button_default");
|
|
43
|
+
const resolvedProfileInformationLabel = profileInformationLabel !== null && profileInformationLabel !== void 0 ? profileInformationLabel : t("my_settings.profile_information_label_default");
|
|
44
|
+
const resolvedPasswordLabel = passwordLabel !== null && passwordLabel !== void 0 ? passwordLabel : t("my_settings.password_label_default");
|
|
45
|
+
const resolvedCurrentPasswordLabel = currentPasswordLabel !== null && currentPasswordLabel !== void 0 ? currentPasswordLabel : t("my_settings.current_password_label_default");
|
|
46
|
+
const resolvedNewPasswordLabel = newPasswordLabel !== null && newPasswordLabel !== void 0 ? newPasswordLabel : t("my_settings.set_password.new_password_label");
|
|
47
|
+
const resolvedConfirmPasswordLabel = confirmPasswordLabel !== null && confirmPasswordLabel !== void 0 ? confirmPasswordLabel : t("my_settings.set_password.confirm_password_label");
|
|
48
|
+
const validateName = (name) => {
|
|
49
|
+
if (name.trim() === "") {
|
|
50
|
+
return t("my_settings.name_field.validation_empty_default");
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
};
|
|
54
|
+
const validateEmail = (email) => {
|
|
55
|
+
if (!email || email.trim() === "") {
|
|
56
|
+
return t("my_settings.email_field.validation_required_default");
|
|
57
|
+
}
|
|
58
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
59
|
+
if (!emailRegex.test(email)) {
|
|
60
|
+
return t("my_settings.email_field.validation_invalid_format_default");
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
};
|
|
33
64
|
const settings = use_my_settings({
|
|
34
65
|
passwordRequirements: password_requirements,
|
|
35
66
|
});
|
|
36
|
-
return (_jsx(UnauthorizedGuard, { message:
|
|
67
|
+
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("my_settings.email_field.label_default"), value: settings.email, type: "email", placeholder: t("my_settings.email_field.placeholder_default"), onSave: settings.handleEmailSave, validation: validateEmail, disabled: settings.loading, ariaLabel: t("my_settings.email_field.aria_label_default") })), _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: {
|
|
37
68
|
backgroundColor: resolvedButtonPalette.submitBackground,
|
|
38
69
|
color: resolvedButtonPalette.submitText,
|
|
39
|
-
}, "aria-label": "
|
|
70
|
+
}, "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) => {
|
|
40
71
|
if (open) {
|
|
41
72
|
settings.handleProfilePictureEdit();
|
|
42
73
|
}
|
|
@@ -45,26 +76,3 @@ export default function my_settings_layout({ className, labels, button_colors, p
|
|
|
45
76
|
}
|
|
46
77
|
}, onSave: settings.handleProfilePictureSave, email: settings.email, allowPhotoUpload: profilePicture.allow_photo_upload, maxPhotoSize: profilePicture.max_photo_size, libraryPhotoPath: profilePicture.library_photo_path, currentProfilePictureUrl: settings.profilePictureUrl, currentProfileSource: settings.profileSource, disabled: settings.loading, messages: messages, uiSizes: uiSizes, fileTypes: fileTypes })] }) }));
|
|
47
78
|
}
|
|
48
|
-
// section: validation_helpers
|
|
49
|
-
/**
|
|
50
|
-
* Validates name (optional, but if provided should not be empty)
|
|
51
|
-
*/
|
|
52
|
-
function validateName(name) {
|
|
53
|
-
if (name.trim() === "") {
|
|
54
|
-
return "Name cannot be empty";
|
|
55
|
-
}
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Validates email format
|
|
60
|
-
*/
|
|
61
|
-
function validateEmail(email) {
|
|
62
|
-
if (!email || email.trim() === "") {
|
|
63
|
-
return "Email is required";
|
|
64
|
-
}
|
|
65
|
-
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
66
|
-
if (!emailRegex.test(email)) {
|
|
67
|
-
return "Invalid email address format";
|
|
68
|
-
}
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/otp/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/otp/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAIhE,MAAM,WAAW,cAAc;IAC7B,mEAAmE;IACnE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4EAA4E;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAGD,wBAAgB,SAAS,CAAC,EACxB,YAAkB,EAClB,KAAK,EACL,QAAQ,EACR,OAAO,EACP,KAAK,EACL,SAAiD,EACjD,SAAS,GACV,EAAE,cAAc,GAAG,KAAK,CAAC,YAAY,CAgCrC;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -7,10 +7,15 @@ import * as React from "react";
|
|
|
7
7
|
import { OTPRequestForm } from "../../otp/OTPRequestForm.js";
|
|
8
8
|
import { OTPVerifyForm } from "../../otp/OTPVerifyForm.js";
|
|
9
9
|
import { TwoColumnAuthLayout } from "../shared/components/two_column_auth_layout.js";
|
|
10
|
+
import { useAuthT } from "../../../contexts/hazo_auth_provider.js";
|
|
10
11
|
// section: component
|
|
11
|
-
export function OTPLayout({ redirect_url = "/", title
|
|
12
|
+
export function OTPLayout({ redirect_url = "/", title, subtitle, ctaText, theme, image_src = "/hazo_auth/images/login_default.jpg", image_alt, }) {
|
|
13
|
+
const t = useAuthT();
|
|
14
|
+
const resolvedTitle = title !== null && title !== void 0 ? title : t("otp.layout.title");
|
|
15
|
+
const resolvedSubtitle = subtitle !== null && subtitle !== void 0 ? subtitle : t("otp.layout.subtitle");
|
|
16
|
+
const resolvedImageAlt = image_alt !== null && image_alt !== void 0 ? image_alt : t("otp.layout.image_alt");
|
|
12
17
|
const [sent_to, set_sent_to] = React.useState(null);
|
|
13
|
-
const formContent = (_jsxs("div", { className: "mx-auto w-full max-w-sm py-12", children: [_jsx("h1", { className: `text-2xl font-semibold ${
|
|
14
|
-
return (_jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt:
|
|
18
|
+
const formContent = (_jsxs("div", { className: "mx-auto w-full max-w-sm py-12", children: [_jsx("h1", { className: `text-2xl font-semibold ${resolvedSubtitle ? "mb-2" : "mb-6"}`, children: resolvedTitle }), resolvedSubtitle && (_jsx("p", { className: "text-sm text-muted-foreground mb-6", children: resolvedSubtitle })), sent_to ? (_jsx(OTPVerifyForm, { email: sent_to, redirect_url: redirect_url, submit_label: ctaText })) : (_jsx(OTPRequestForm, { on_sent: (email) => set_sent_to(email) }))] }));
|
|
19
|
+
return (_jsx(TwoColumnAuthLayout, { imageSrc: image_src, imageAlt: resolvedImageAlt, formContent: formContent }));
|
|
15
20
|
}
|
|
16
21
|
export default OTPLayout;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LayoutFieldMap, LayoutFieldMapOverrides } from "../../shared/config/layout_customization";
|
|
2
2
|
import { type ButtonPaletteDefaults, type ButtonPaletteOverrides, type LayoutLabelDefaults, type LayoutLabelOverrides, type PasswordRequirementOptions, type PasswordRequirementOverrides } from "../../shared/config/layout_customization.js";
|
|
3
|
+
import type { AuthTFunction } from "../../../../contexts/hazo_auth_config";
|
|
3
4
|
export declare const REGISTER_FIELD_IDS: {
|
|
4
5
|
readonly NAME: "name";
|
|
5
6
|
readonly EMAIL: "email_address";
|
|
@@ -7,8 +8,8 @@ export declare const REGISTER_FIELD_IDS: {
|
|
|
7
8
|
readonly CONFIRM_PASSWORD: "confirm_password";
|
|
8
9
|
};
|
|
9
10
|
export type RegisterFieldId = (typeof REGISTER_FIELD_IDS)[keyof typeof REGISTER_FIELD_IDS];
|
|
10
|
-
export declare const createRegisterFieldDefinitions: (overrides?: LayoutFieldMapOverrides) => LayoutFieldMap;
|
|
11
|
-
export declare const resolveRegisterLabels: (overrides?: LayoutLabelOverrides) => LayoutLabelDefaults;
|
|
11
|
+
export declare const createRegisterFieldDefinitions: (t: AuthTFunction, overrides?: LayoutFieldMapOverrides) => LayoutFieldMap;
|
|
12
|
+
export declare const resolveRegisterLabels: (t: AuthTFunction, overrides?: LayoutLabelOverrides) => LayoutLabelDefaults;
|
|
12
13
|
export declare const resolveRegisterButtonPalette: (overrides?: ButtonPaletteOverrides) => ButtonPaletteDefaults;
|
|
13
14
|
export declare const resolveRegisterPasswordRequirements: (overrides?: PasswordRequirementOverrides) => PasswordRequirementOptions;
|
|
14
15
|
//# sourceMappingURL=register_field_config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register_field_config.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/register/config/register_field_config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACxG,OAAO,
|
|
1
|
+
{"version":3,"file":"register_field_config.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/register/config/register_field_config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACxG,OAAO,EAML,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EAClC,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAG3E,eAAO,MAAM,kBAAkB;;;;;CAKrB,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAC;AA0C3F,eAAO,MAAM,8BAA8B,GACzC,GAAG,aAAa,EAChB,YAAY,uBAAuB,mBACoC,CAAC;AAU1E,eAAO,MAAM,qBAAqB,GAAI,GAAG,aAAa,EAAE,YAAY,oBAAoB,wBAC/B,CAAC;AAU1D,eAAO,MAAM,4BAA4B,GAAI,YAAY,sBAAsB,0BACZ,CAAC;AAWpE,eAAO,MAAM,mCAAmC,GAC9C,YAAY,4BAA4B,+BACiC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolveButtonPalette, resolveFieldDefinitions, resolveLabels, resolvePasswordRequirements, } from "../../shared/config/layout_customization.js";
|
|
1
|
+
import { resolveButtonPalette, resolveFieldDefinitions, resolveLabels, resolvePasswordRequirements, SHARED_EMAIL_FIELD_COPY, } from "../../shared/config/layout_customization.js";
|
|
2
2
|
// section: field_identifiers
|
|
3
3
|
export const REGISTER_FIELD_IDS = {
|
|
4
4
|
NAME: "name",
|
|
@@ -7,49 +7,52 @@ export const REGISTER_FIELD_IDS = {
|
|
|
7
7
|
CONFIRM_PASSWORD: "confirm_password",
|
|
8
8
|
};
|
|
9
9
|
// section: field_definitions
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
10
|
+
const buildRegisterFieldDefinitions = (t) => {
|
|
11
|
+
const sharedEmailFieldCopy = SHARED_EMAIL_FIELD_COPY(t);
|
|
12
|
+
return {
|
|
13
|
+
[REGISTER_FIELD_IDS.NAME]: {
|
|
14
|
+
id: REGISTER_FIELD_IDS.NAME,
|
|
15
|
+
label: t("register.field.name.label"),
|
|
16
|
+
type: "text",
|
|
17
|
+
autoComplete: "name",
|
|
18
|
+
placeholder: t("register.field.name.placeholder"),
|
|
19
|
+
ariaLabel: t("register.field.name.aria_label"),
|
|
20
|
+
},
|
|
21
|
+
[REGISTER_FIELD_IDS.EMAIL]: {
|
|
22
|
+
id: REGISTER_FIELD_IDS.EMAIL,
|
|
23
|
+
label: sharedEmailFieldCopy.label,
|
|
24
|
+
type: "email",
|
|
25
|
+
autoComplete: "email",
|
|
26
|
+
placeholder: sharedEmailFieldCopy.placeholder,
|
|
27
|
+
ariaLabel: sharedEmailFieldCopy.ariaLabel,
|
|
28
|
+
},
|
|
29
|
+
[REGISTER_FIELD_IDS.PASSWORD]: {
|
|
30
|
+
id: REGISTER_FIELD_IDS.PASSWORD,
|
|
31
|
+
label: t("register.field.password.label"),
|
|
32
|
+
type: "password",
|
|
33
|
+
autoComplete: "new-password",
|
|
34
|
+
placeholder: t("register.field.password.placeholder"),
|
|
35
|
+
ariaLabel: t("register.field.password.aria_label"),
|
|
36
|
+
},
|
|
37
|
+
[REGISTER_FIELD_IDS.CONFIRM_PASSWORD]: {
|
|
38
|
+
id: REGISTER_FIELD_IDS.CONFIRM_PASSWORD,
|
|
39
|
+
label: t("register.field.confirm_password.label"),
|
|
40
|
+
type: "password",
|
|
41
|
+
autoComplete: "new-password",
|
|
42
|
+
placeholder: t("register.field.confirm_password.placeholder"),
|
|
43
|
+
ariaLabel: t("register.field.confirm_password.aria_label"),
|
|
44
|
+
},
|
|
45
|
+
};
|
|
43
46
|
};
|
|
44
|
-
export const createRegisterFieldDefinitions = (overrides) => resolveFieldDefinitions(
|
|
47
|
+
export const createRegisterFieldDefinitions = (t, overrides) => resolveFieldDefinitions(buildRegisterFieldDefinitions(t), overrides);
|
|
45
48
|
// section: label_defaults
|
|
46
|
-
const
|
|
47
|
-
heading: "
|
|
48
|
-
subHeading: "
|
|
49
|
-
submitButton: "
|
|
50
|
-
cancelButton: "
|
|
51
|
-
};
|
|
52
|
-
export const resolveRegisterLabels = (overrides) => resolveLabels(
|
|
49
|
+
const buildRegisterLabelDefaults = (t) => ({
|
|
50
|
+
heading: t("register.heading"),
|
|
51
|
+
subHeading: t("register.sub_heading"),
|
|
52
|
+
submitButton: t("register.submit_button"),
|
|
53
|
+
cancelButton: t("shared.cancel_button"),
|
|
54
|
+
});
|
|
55
|
+
export const resolveRegisterLabels = (t, overrides) => resolveLabels(buildRegisterLabelDefaults(t), overrides);
|
|
53
56
|
// section: button_palette_defaults
|
|
54
57
|
const REGISTER_BUTTON_PALETTE_DEFAULTS = {
|
|
55
58
|
submitBackground: "#0f172a",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_register_form.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/register/hooks/use_register_form.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACzH,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAG3F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AASvE,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AACjE,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,GAAG;IACrF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C,OAAO,CAAC,eAAe,EAAE,UAAU,GAAG,kBAAkB,CAAC,EACzD,OAAO,CACR,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,OAAO,GAAG,OAAO,IAAI;IACrD,aAAa,EAAE,OAAO,CAAC;IACvB,oBAAoB,EAAE,0BAA0B,CAAC;IACjD,4BAA4B,CAAC,EAAE,4BAA4B,CAAC;IAC5D,UAAU,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,kBAAkB,EAAE,uBAAuB,CAAC;IAC5C,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,wBAAwB,EAAE,CAAC,OAAO,EAAE,UAAU,GAAG,kBAAkB,KAAK,IAAI,CAAC;IAC7E,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;IAChE,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,yBAAyB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAClE,CAAC;AAYF,eAAO,MAAM,iBAAiB,GAAI,OAAO,EAAG,6EAMzC,qBAAqB,CAAC,OAAO,CAAC,KAAG,
|
|
1
|
+
{"version":3,"file":"use_register_form.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/register/hooks/use_register_form.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AACzH,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAG3F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wCAAwC,CAAC;AASvE,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AACjE,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC,GAAG;IACrF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAC1C,OAAO,CAAC,eAAe,EAAE,UAAU,GAAG,kBAAkB,CAAC,EACzD,OAAO,CACR,CAAC;AAEF,MAAM,MAAM,qBAAqB,CAAC,OAAO,GAAG,OAAO,IAAI;IACrD,aAAa,EAAE,OAAO,CAAC;IACvB,oBAAoB,EAAE,0BAA0B,CAAC;IACjD,4BAA4B,CAAC,EAAE,4BAA4B,CAAC;IAC5D,UAAU,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,MAAM,EAAE,kBAAkB,CAAC;IAC3B,kBAAkB,EAAE,uBAAuB,CAAC;IAC5C,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrE,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,wBAAwB,EAAE,CAAC,OAAO,EAAE,UAAU,GAAG,kBAAkB,KAAK,IAAI,CAAC;IAC7E,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;IAChE,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,yBAAyB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAClE,CAAC;AAYF,eAAO,MAAM,iBAAiB,GAAI,OAAO,EAAG,6EAMzC,qBAAqB,CAAC,OAAO,CAAC,KAAG,qBAgRnC,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { useCallback, useMemo, useState } from "react";
|
|
|
4
4
|
import { toast } from "sonner";
|
|
5
5
|
import { REGISTER_FIELD_IDS } from "../config/register_field_config.js";
|
|
6
6
|
import { validateEmail, validatePassword } from "../../shared/utils/validation.js";
|
|
7
|
-
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider.js";
|
|
7
|
+
import { useHazoAuthConfig, useAuthT } from "../../../../contexts/hazo_auth_provider.js";
|
|
8
8
|
// section: constants
|
|
9
9
|
const PASSWORD_FIELDS = [
|
|
10
10
|
REGISTER_FIELD_IDS.PASSWORD,
|
|
@@ -20,6 +20,7 @@ const buildInitialValues = () => ({
|
|
|
20
20
|
// section: hook
|
|
21
21
|
export const use_register_form = ({ showNameField, passwordRequirements, dataClient, urlOnLogon, legalDocs, }) => {
|
|
22
22
|
const { apiBasePath } = useHazoAuthConfig();
|
|
23
|
+
const t = useAuthT();
|
|
23
24
|
const initialValues = useMemo(() => buildInitialValues(), []);
|
|
24
25
|
const [values, setValues] = useState(initialValues);
|
|
25
26
|
const [errors, setErrors] = useState({});
|
|
@@ -86,7 +87,7 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
86
87
|
const updatedErrors = Object.assign({}, previousErrors);
|
|
87
88
|
// Only validate email on change if it has been touched (blurred)
|
|
88
89
|
if (fieldId === REGISTER_FIELD_IDS.EMAIL && emailTouched) {
|
|
89
|
-
const emailError = validateEmail(value);
|
|
90
|
+
const emailError = validateEmail(value, t);
|
|
90
91
|
if (emailError) {
|
|
91
92
|
updatedErrors[REGISTER_FIELD_IDS.EMAIL] = emailError;
|
|
92
93
|
}
|
|
@@ -95,7 +96,7 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
if (PASSWORD_FIELDS.includes(fieldId)) {
|
|
98
|
-
const passwordError = validatePassword(nextValues[REGISTER_FIELD_IDS.PASSWORD], passwordRequirements);
|
|
99
|
+
const passwordError = validatePassword(nextValues[REGISTER_FIELD_IDS.PASSWORD], passwordRequirements, t);
|
|
99
100
|
if (passwordError) {
|
|
100
101
|
updatedErrors[REGISTER_FIELD_IDS.PASSWORD] = passwordError;
|
|
101
102
|
}
|
|
@@ -105,7 +106,7 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
105
106
|
if (nextValues[REGISTER_FIELD_IDS.CONFIRM_PASSWORD].trim().length > 0 &&
|
|
106
107
|
nextValues[REGISTER_FIELD_IDS.PASSWORD] !==
|
|
107
108
|
nextValues[REGISTER_FIELD_IDS.CONFIRM_PASSWORD]) {
|
|
108
|
-
updatedErrors[REGISTER_FIELD_IDS.CONFIRM_PASSWORD] = "
|
|
109
|
+
updatedErrors[REGISTER_FIELD_IDS.CONFIRM_PASSWORD] = t("validation.passwords_do_not_match");
|
|
109
110
|
}
|
|
110
111
|
else {
|
|
111
112
|
delete updatedErrors[REGISTER_FIELD_IDS.CONFIRM_PASSWORD];
|
|
@@ -122,7 +123,7 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
122
123
|
setErrors((previousErrors) => {
|
|
123
124
|
const updatedErrors = Object.assign({}, previousErrors);
|
|
124
125
|
const emailValue = values[REGISTER_FIELD_IDS.EMAIL];
|
|
125
|
-
const emailError = validateEmail(emailValue);
|
|
126
|
+
const emailError = validateEmail(emailValue, t);
|
|
126
127
|
if (emailError) {
|
|
127
128
|
updatedErrors[REGISTER_FIELD_IDS.EMAIL] = emailError;
|
|
128
129
|
}
|
|
@@ -135,8 +136,8 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
135
136
|
const handleSubmit = useCallback(async (event) => {
|
|
136
137
|
event.preventDefault();
|
|
137
138
|
// Final validation
|
|
138
|
-
const emailError = validateEmail(values[REGISTER_FIELD_IDS.EMAIL]);
|
|
139
|
-
const passwordError = validatePassword(values[REGISTER_FIELD_IDS.PASSWORD], passwordRequirements);
|
|
139
|
+
const emailError = validateEmail(values[REGISTER_FIELD_IDS.EMAIL], t);
|
|
140
|
+
const passwordError = validatePassword(values[REGISTER_FIELD_IDS.PASSWORD], passwordRequirements, t);
|
|
140
141
|
if (emailError || passwordError) {
|
|
141
142
|
setErrors(Object.assign(Object.assign({}, (emailError ? { [REGISTER_FIELD_IDS.EMAIL]: emailError } : {})), (passwordError ? { [REGISTER_FIELD_IDS.PASSWORD]: passwordError } : {})));
|
|
142
143
|
return;
|
|
@@ -145,7 +146,7 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
145
146
|
if (values[REGISTER_FIELD_IDS.PASSWORD] !==
|
|
146
147
|
values[REGISTER_FIELD_IDS.CONFIRM_PASSWORD]) {
|
|
147
148
|
setErrors({
|
|
148
|
-
[REGISTER_FIELD_IDS.CONFIRM_PASSWORD]: "
|
|
149
|
+
[REGISTER_FIELD_IDS.CONFIRM_PASSWORD]: t("validation.passwords_do_not_match"),
|
|
149
150
|
});
|
|
150
151
|
return;
|
|
151
152
|
}
|
|
@@ -168,11 +169,11 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
168
169
|
});
|
|
169
170
|
const data = await response.json();
|
|
170
171
|
if (!response.ok) {
|
|
171
|
-
throw new Error(data.error || "
|
|
172
|
+
throw new Error(data.error || t("register.failed_message"));
|
|
172
173
|
}
|
|
173
174
|
// Show success notification
|
|
174
|
-
toast.success("
|
|
175
|
-
description: "
|
|
175
|
+
toast.success(t("register.success_toast_title"), {
|
|
176
|
+
description: t("register.success_toast_description"),
|
|
176
177
|
});
|
|
177
178
|
// Reset form on success
|
|
178
179
|
const resetValues = buildInitialValues();
|
|
@@ -6,10 +6,10 @@ export type OAuthLayoutConfig = {
|
|
|
6
6
|
enable_google: boolean;
|
|
7
7
|
/** Enable traditional email/password login */
|
|
8
8
|
enable_email_password: boolean;
|
|
9
|
-
/** Text displayed on the Google sign-in button */
|
|
10
|
-
google_button_text
|
|
11
|
-
/** Text displayed on the divider between OAuth and email/password form */
|
|
12
|
-
oauth_divider_text
|
|
9
|
+
/** Text displayed on the Google sign-in button. Undefined falls back to `t("register.oauth.google_button_default")`. */
|
|
10
|
+
google_button_text?: string;
|
|
11
|
+
/** Text displayed on the divider between OAuth and email/password form. Undefined falls back to `t("shared.oauth_divider_default")`. */
|
|
12
|
+
oauth_divider_text?: string;
|
|
13
13
|
/** Enable Facebook OAuth login */
|
|
14
14
|
enable_facebook_oauth?: boolean;
|
|
15
15
|
/** Text displayed on the Facebook sign-in button */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/register/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EAClC,MAAM,uCAAuC,CAAC;AAY/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAOlD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,gCAAgC;IAChC,aAAa,EAAE,OAAO,CAAC;IACvB,8CAA8C;IAC9C,qBAAqB,EAAE,OAAO,CAAC;IAC/B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/register/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EAClC,MAAM,uCAAuC,CAAC;AAY/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAOlD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,gCAAgC;IAChC,aAAa,EAAE,OAAO,CAAC;IACvB,8CAA8C;IAC9C,qBAAqB,EAAE,OAAO,CAAC;IAC/B,wHAAwH;IACxH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,wIAAwI;IACxI,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kCAAkC;IAClC,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,oDAAoD;IACpD,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,OAAO,GAAG,OAAO,IAAI;IACnD,6HAA6H;IAC7H,SAAS,CAAC,EAAE,MAAM,GAAG,eAAe,CAAC;IACrC,0GAA0G;IAC1G,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,qBAAqB,CAAC,EAAE,4BAA4B,CAAC;IACrD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACvC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,qGAAqG;IACrG,MAAM,CAAC,EAAE,YAAY,GAAG,WAAW,CAAC;CACrC,CAAC;AAYF,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,OAAO,EAAE,EAC/C,SAAS,EACT,SAAS,EACT,sBAAkC,EAClC,eAAe,EACf,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,eAAsB,EACtB,WAAW,EACX,sBAAsB,EACtB,gBAAuB,EACvB,oBAA4B,EAC5B,qBAAqB,EACrB,cAAoB,EACpB,UAA+B,EAC/B,WAAW,EACX,UAAU,EACV,KAAK,EACL,MAAqB,GACtB,EAAE,mBAAmB,CAAC,OAAO,CAAC,+BA8R9B"}
|
|
@@ -21,7 +21,7 @@ import { REGISTER_FIELD_IDS, createRegisterFieldDefinitions, resolveRegisterButt
|
|
|
21
21
|
import { use_register_form, } from "./hooks/use_register_form.js";
|
|
22
22
|
import { LegalDocCheckboxList } from "../legal/legal_doc_checkbox_list.js";
|
|
23
23
|
import { LegalDocCombinedView } from "../legal/legal_doc_combined_view.js";
|
|
24
|
-
import { useHazoAuthConfig } from "../../../contexts/hazo_auth_provider.js";
|
|
24
|
+
import { useHazoAuthConfig, useAuthT } from "../../../contexts/hazo_auth_provider.js";
|
|
25
25
|
const ORDERED_FIELDS = [
|
|
26
26
|
REGISTER_FIELD_IDS.NAME,
|
|
27
27
|
REGISTER_FIELD_IDS.EMAIL,
|
|
@@ -29,16 +29,22 @@ const ORDERED_FIELDS = [
|
|
|
29
29
|
REGISTER_FIELD_IDS.CONFIRM_PASSWORD,
|
|
30
30
|
];
|
|
31
31
|
// section: component
|
|
32
|
-
export default function register_layout({ image_src, image_alt, image_background_color = "#f1f5f9", field_overrides, labels, button_colors, password_requirements, show_name_field = true, data_client, alreadyLoggedInMessage
|
|
33
|
-
var _a;
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
export default function register_layout({ image_src, image_alt, image_background_color = "#f1f5f9", field_overrides, labels, button_colors, password_requirements, show_name_field = true, data_client, alreadyLoggedInMessage, showLogoutButton = true, showReturnHomeButton = false, returnHomeButtonLabel, returnHomePath = "/", signInPath = "/hazo_auth/login", signInLabel, urlOnLogon, oauth, layout = "two_column", }) {
|
|
33
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
34
|
+
const t = useAuthT();
|
|
35
|
+
const resolvedAlreadyLoggedInMessage = alreadyLoggedInMessage !== null && alreadyLoggedInMessage !== void 0 ? alreadyLoggedInMessage : t("shared.guard.already_logged_in_prop_default");
|
|
36
|
+
const resolvedReturnHomeButtonLabel = returnHomeButtonLabel !== null && returnHomeButtonLabel !== void 0 ? returnHomeButtonLabel : t("shared.guard.return_home_default");
|
|
37
|
+
const resolvedSignInLabel = signInLabel !== null && signInLabel !== void 0 ? signInLabel : t("shared.sign_in_default");
|
|
38
|
+
// Resolve OAuth config per-field (not `oauth || {defaults}` as a whole
|
|
39
|
+
// object) — see LoginLayout for the full rationale: a partial `oauth` prop
|
|
40
|
+
// must still get `t()`-resolved locale-aware text for any field it left unset.
|
|
41
|
+
const oauthConfig = {
|
|
42
|
+
enable_google: (_a = oauth === null || oauth === void 0 ? void 0 : oauth.enable_google) !== null && _a !== void 0 ? _a : true,
|
|
43
|
+
enable_email_password: (_b = oauth === null || oauth === void 0 ? void 0 : oauth.enable_email_password) !== null && _b !== void 0 ? _b : true,
|
|
44
|
+
google_button_text: (_c = oauth === null || oauth === void 0 ? void 0 : oauth.google_button_text) !== null && _c !== void 0 ? _c : t("register.oauth.google_button_default"),
|
|
45
|
+
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"),
|
|
46
|
+
enable_facebook_oauth: (_e = oauth === null || oauth === void 0 ? void 0 : oauth.enable_facebook_oauth) !== null && _e !== void 0 ? _e : false,
|
|
47
|
+
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"),
|
|
42
48
|
};
|
|
43
49
|
// Read OAuth error from URL query params (e.g., ?error=AccessDenied)
|
|
44
50
|
const searchParams = useSearchParams();
|
|
@@ -53,17 +59,17 @@ export default function register_layout({ image_src, image_alt, image_background
|
|
|
53
59
|
const oauthCallbackUrl = safeRedirect
|
|
54
60
|
? `/api/hazo_auth/oauth/google/callback?next=${encodeURIComponent(safeRedirect)}`
|
|
55
61
|
: "/api/hazo_auth/oauth/google/callback";
|
|
56
|
-
const effectiveUrlOnLogon = (
|
|
62
|
+
const effectiveUrlOnLogon = (_g = urlOnLogon !== null && urlOnLogon !== void 0 ? urlOnLogon : safeRedirect) !== null && _g !== void 0 ? _g : undefined;
|
|
57
63
|
const getOAuthErrorMessage = (error) => {
|
|
58
64
|
switch (error) {
|
|
59
65
|
case "AccessDenied":
|
|
60
|
-
return "
|
|
66
|
+
return t("shared.oauth_error.access_denied");
|
|
61
67
|
case "OAuthSignin":
|
|
62
68
|
case "OAuthCallback":
|
|
63
69
|
case "OAuthCreateAccount":
|
|
64
|
-
return "
|
|
70
|
+
return t("shared.oauth_error.signin_failed");
|
|
65
71
|
default:
|
|
66
|
-
return "
|
|
72
|
+
return t("shared.oauth_error.generic");
|
|
67
73
|
}
|
|
68
74
|
};
|
|
69
75
|
const { apiBasePath } = useHazoAuthConfig();
|
|
@@ -81,8 +87,8 @@ export default function register_layout({ image_src, image_alt, image_background
|
|
|
81
87
|
})
|
|
82
88
|
.catch(() => { });
|
|
83
89
|
}, [apiBasePath]);
|
|
84
|
-
const fieldDefinitions = createRegisterFieldDefinitions(field_overrides);
|
|
85
|
-
const resolvedLabels = resolveRegisterLabels(labels);
|
|
90
|
+
const fieldDefinitions = createRegisterFieldDefinitions(t, field_overrides);
|
|
91
|
+
const resolvedLabels = resolveRegisterLabels(t, labels);
|
|
86
92
|
const resolvedButtonPalette = resolveRegisterButtonPalette(button_colors);
|
|
87
93
|
const resolvedPasswordRequirements = resolveRegisterPasswordRequirements(password_requirements);
|
|
88
94
|
const form = use_register_form({
|
|
@@ -118,13 +124,13 @@ export default function register_layout({ image_src, image_alt, image_background
|
|
|
118
124
|
// Form content — used in both layout modes. See `login_layout` for the
|
|
119
125
|
// rationale: keeps the form independent of TwoColumnAuthLayout / AuthPageShell
|
|
120
126
|
// so consumers can compose it into their own brand chrome.
|
|
121
|
-
const mainContent = (_jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), oauthError && (_jsxs("div", { className: "cls_register_layout_oauth_error flex items-center gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700", children: [_jsx(AlertCircle, { className: "h-4 w-4 shrink-0", "aria-hidden": "true" }), _jsx("span", { children: getOAuthErrorMessage(oauthError) })] })), oauthConfig.enable_google && (_jsx("div", { className: "cls_register_layout_oauth_section", children: _jsx(GoogleSignInButton, { label: oauthConfig.google_button_text, callbackUrl: oauthCallbackUrl }) })), oauthConfig.enable_facebook_oauth && (_jsx("div", { className: "cls_register_layout_facebook_section", children: _jsx(FacebookSignInButton, { label: oauthConfig.facebook_button_text || "
|
|
127
|
+
const mainContent = (_jsxs(_Fragment, { children: [_jsx(FormHeader, { heading: resolvedLabels.heading, subHeading: resolvedLabels.subHeading }), oauthError && (_jsxs("div", { className: "cls_register_layout_oauth_error flex items-center gap-2 rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700", children: [_jsx(AlertCircle, { className: "h-4 w-4 shrink-0", "aria-hidden": "true" }), _jsx("span", { children: getOAuthErrorMessage(oauthError) })] })), oauthConfig.enable_google && (_jsx("div", { className: "cls_register_layout_oauth_section", children: _jsx(GoogleSignInButton, { label: oauthConfig.google_button_text, callbackUrl: oauthCallbackUrl }) })), oauthConfig.enable_facebook_oauth && (_jsx("div", { className: "cls_register_layout_facebook_section", children: _jsx(FacebookSignInButton, { label: oauthConfig.facebook_button_text || t("shared.oauth.facebook_button_default"), callbackUrl: "/api/hazo_auth/oauth/facebook/callback" }) })), (oauthConfig.enable_google || oauthConfig.enable_facebook_oauth) && oauthConfig.enable_email_password && (_jsx(OAuthDivider, { text: oauthConfig.oauth_divider_text })), oauthConfig.enable_email_password && (_jsxs("form", { className: "cls_register_layout_form_fields flex flex-col gap-5", onSubmit: form.handleSubmit, "aria-label": t("register.aria.form"), children: [renderFields(form), legal_docs.length > 0 && (_jsx("div", { className: "space-y-2", children: legal_display_mode === 'combined' ? (_jsx(LegalDocCombinedView, { docs: legal_docs, accepted: legal_docs.every(doc => form.legal_accepted[doc.key]), onAcceptedChange: (value) => legal_docs.forEach(doc => form.handleLegalAcceptedChange(doc.key, value)) })) : (_jsx(LegalDocCheckboxList, { docs: legal_docs, accepted: form.legal_accepted, onAcceptedChange: form.handleLegalAcceptedChange })) })), _jsx(FormActionButtons, { submitLabel: resolvedLabels.submitButton, cancelLabel: resolvedLabels.cancelButton, buttonPalette: resolvedButtonPalette, isSubmitDisabled: form.isSubmitDisabled, onCancel: form.handleCancel, submitAriaLabel: t("register.aria.submit"), cancelAriaLabel: t("register.aria.cancel") }), _jsxs("div", { className: "cls_register_layout_sign_in_link flex items-center justify-center gap-1 text-sm text-muted-foreground", children: [_jsx("span", { children: t("register.sign_in_prompt") }), _jsx(Link, { href: signInPath, className: "cls_register_layout_sign_in_link_text text-primary underline-offset-4 hover:underline", "aria-label": t("register.aria.sign_in_link"), children: resolvedSignInLabel })] }), form.isSubmitting && (_jsx("div", { className: "cls_register_submitting_indicator text-sm text-slate-600 text-center", children: t("register.submitting_indicator") }))] })), !oauthConfig.enable_email_password && (oauthConfig.enable_google || oauthConfig.enable_facebook_oauth) && (_jsxs("div", { className: "cls_register_layout_sign_in_link mt-4 flex items-center justify-center gap-1 text-sm text-muted-foreground", children: [_jsx("span", { children: t("register.sign_in_prompt") }), _jsx(Link, { href: signInPath, className: "cls_register_layout_sign_in_link_text text-primary underline-offset-4 hover:underline", "aria-label": t("register.aria.sign_in_link"), children: resolvedSignInLabel })] }))] }));
|
|
122
128
|
// form_only mode: emit just the form content. See login_layout for the
|
|
123
129
|
// rationale; AlreadyLoggedInGuard is intentionally skipped here.
|
|
124
130
|
if (layout === "form_only") {
|
|
125
131
|
return mainContent;
|
|
126
132
|
}
|
|
127
|
-
return (_jsx(AlreadyLoggedInGuard, { image_src: image_src, image_alt: image_alt, image_background_color: image_background_color, message:
|
|
133
|
+
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 }) }));
|
|
128
134
|
}
|
|
129
135
|
// Same-origin path validator. See login/index.tsx for the rationale.
|
|
130
136
|
function isSafeRedirectPath(value) {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { LayoutFieldMap, LayoutFieldMapOverrides } from "../../shared/config/layout_customization";
|
|
2
2
|
import { type ButtonPaletteDefaults, type ButtonPaletteOverrides, type LayoutLabelDefaults, type LayoutLabelOverrides, type PasswordRequirementOptions, type PasswordRequirementOverrides } from "../../shared/config/layout_customization.js";
|
|
3
|
+
import type { AuthTFunction } from "../../../../contexts/hazo_auth_config";
|
|
3
4
|
export declare const RESET_PASSWORD_FIELD_IDS: {
|
|
4
5
|
readonly PASSWORD: "password";
|
|
5
6
|
readonly CONFIRM_PASSWORD: "confirm_password";
|
|
6
7
|
};
|
|
7
8
|
export type ResetPasswordFieldId = (typeof RESET_PASSWORD_FIELD_IDS)[keyof typeof RESET_PASSWORD_FIELD_IDS];
|
|
8
|
-
export declare const createResetPasswordFieldDefinitions: (overrides?: LayoutFieldMapOverrides) => LayoutFieldMap;
|
|
9
|
-
export declare const resolveResetPasswordLabels: (overrides?: LayoutLabelOverrides) => LayoutLabelDefaults;
|
|
9
|
+
export declare const createResetPasswordFieldDefinitions: (t: AuthTFunction, overrides?: LayoutFieldMapOverrides) => LayoutFieldMap;
|
|
10
|
+
export declare const resolveResetPasswordLabels: (t: AuthTFunction, overrides?: LayoutLabelOverrides) => LayoutLabelDefaults;
|
|
10
11
|
export declare const resolveResetPasswordButtonPalette: (overrides?: ButtonPaletteOverrides) => ButtonPaletteDefaults;
|
|
11
12
|
export declare const resolveResetPasswordPasswordRequirements: (overrides?: PasswordRequirementOverrides) => PasswordRequirementOptions;
|
|
12
|
-
export declare const
|
|
13
|
+
export declare const getResetPasswordAlreadyLoggedInMessageDefault: (t: AuthTFunction) => string;
|
|
13
14
|
//# sourceMappingURL=reset_password_field_config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reset_password_field_config.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/reset_password/config/reset_password_field_config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACxG,OAAO,EAIL,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EAElC,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"reset_password_field_config.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/reset_password/config/reset_password_field_config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AACxG,OAAO,EAIL,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,EAElC,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAG3E,eAAO,MAAM,wBAAwB;;;CAG3B,CAAC;AAEX,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,OAAO,wBAAwB,CAAC,CAAC;AAsB5G,eAAO,MAAM,mCAAmC,GAC9C,GAAG,aAAa,EAChB,YAAY,uBAAuB,mBACyC,CAAC;AAU/E,eAAO,MAAM,0BAA0B,GAAI,GAAG,aAAa,EAAE,YAAY,oBAAoB,wBAC/B,CAAC;AAU/D,eAAO,MAAM,iCAAiC,GAAI,YAAY,sBAAsB,0BACX,CAAC;AAW1E,eAAO,MAAM,wCAAwC,GACnD,YAAY,4BAA4B,+BAC+C,CAAC;AAG1F,eAAO,MAAM,6CAA6C,GAAI,GAAG,aAAa,WACjC,CAAC"}
|
|
@@ -5,33 +5,33 @@ export const RESET_PASSWORD_FIELD_IDS = {
|
|
|
5
5
|
CONFIRM_PASSWORD: "confirm_password",
|
|
6
6
|
};
|
|
7
7
|
// section: field_definitions
|
|
8
|
-
const
|
|
8
|
+
const buildResetPasswordFieldDefinitions = (t) => ({
|
|
9
9
|
[RESET_PASSWORD_FIELD_IDS.PASSWORD]: {
|
|
10
10
|
id: RESET_PASSWORD_FIELD_IDS.PASSWORD,
|
|
11
|
-
label: "
|
|
11
|
+
label: t("reset_password.field.password.label"),
|
|
12
12
|
type: "password",
|
|
13
13
|
autoComplete: "new-password",
|
|
14
|
-
placeholder: "
|
|
15
|
-
ariaLabel: "
|
|
14
|
+
placeholder: t("reset_password.field.password.placeholder"),
|
|
15
|
+
ariaLabel: t("reset_password.field.password.aria_label"),
|
|
16
16
|
},
|
|
17
17
|
[RESET_PASSWORD_FIELD_IDS.CONFIRM_PASSWORD]: {
|
|
18
18
|
id: RESET_PASSWORD_FIELD_IDS.CONFIRM_PASSWORD,
|
|
19
|
-
label: "
|
|
19
|
+
label: t("reset_password.field.confirm_password.label"),
|
|
20
20
|
type: "password",
|
|
21
21
|
autoComplete: "new-password",
|
|
22
|
-
placeholder: "
|
|
23
|
-
ariaLabel: "
|
|
22
|
+
placeholder: t("reset_password.field.confirm_password.placeholder"),
|
|
23
|
+
ariaLabel: t("reset_password.field.confirm_password.aria_label"),
|
|
24
24
|
},
|
|
25
|
-
};
|
|
26
|
-
export const createResetPasswordFieldDefinitions = (overrides) => resolveFieldDefinitions(
|
|
25
|
+
});
|
|
26
|
+
export const createResetPasswordFieldDefinitions = (t, overrides) => resolveFieldDefinitions(buildResetPasswordFieldDefinitions(t), overrides);
|
|
27
27
|
// section: label_defaults
|
|
28
|
-
const
|
|
29
|
-
heading: "
|
|
30
|
-
subHeading: "
|
|
31
|
-
submitButton: "
|
|
32
|
-
cancelButton: "
|
|
33
|
-
};
|
|
34
|
-
export const resolveResetPasswordLabels = (overrides) => resolveLabels(
|
|
28
|
+
const buildResetPasswordLabelDefaults = (t) => ({
|
|
29
|
+
heading: t("reset_password.heading"),
|
|
30
|
+
subHeading: t("reset_password.sub_heading"),
|
|
31
|
+
submitButton: t("reset_password.submit_button"),
|
|
32
|
+
cancelButton: t("shared.cancel_button"),
|
|
33
|
+
});
|
|
34
|
+
export const resolveResetPasswordLabels = (t, overrides) => resolveLabels(buildResetPasswordLabelDefaults(t), overrides);
|
|
35
35
|
// section: button_palette_defaults
|
|
36
36
|
const RESET_PASSWORD_BUTTON_PALETTE_DEFAULTS = {
|
|
37
37
|
submitBackground: "#0f172a",
|
|
@@ -50,4 +50,4 @@ const RESET_PASSWORD_PASSWORD_REQUIREMENT_DEFAULTS = {
|
|
|
50
50
|
};
|
|
51
51
|
export const resolveResetPasswordPasswordRequirements = (overrides) => resolvePasswordRequirements(RESET_PASSWORD_PASSWORD_REQUIREMENT_DEFAULTS, overrides);
|
|
52
52
|
// section: already_logged_in_label
|
|
53
|
-
export const
|
|
53
|
+
export const getResetPasswordAlreadyLoggedInMessageDefault = (t) => t("shared.guard.already_logged_in_message");
|