hazo_auth 1.6.7 → 3.0.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 +114 -14
- 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 +5 -3
- package/dist/components/layouts/email_verification/index.d.ts +2 -1
- package/dist/components/layouts/email_verification/index.d.ts.map +1 -1
- 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 +3 -1
- package/dist/components/layouts/forgot_password/index.d.ts +2 -1
- package/dist/components/layouts/forgot_password/index.d.ts.map +1 -1
- package/dist/components/layouts/login/hooks/use_login_form.d.ts.map +1 -1
- package/dist/components/layouts/login/hooks/use_login_form.js +3 -1
- package/dist/components/layouts/login/index.d.ts +2 -1
- package/dist/components/layouts/login/index.d.ts.map +1 -1
- 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 +3 -1
- package/dist/components/layouts/my_settings/components/profile_picture_library_tab.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/components/profile_picture_library_tab.js +4 -2
- package/dist/components/layouts/my_settings/hooks/use_my_settings.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/hooks/use_my_settings.js +7 -5
- package/dist/components/layouts/my_settings/index.d.ts +2 -1
- package/dist/components/layouts/my_settings/index.d.ts.map +1 -1
- package/dist/components/layouts/my_settings/index.js +3 -2
- package/dist/components/layouts/register/hooks/use_register_form.d.ts.map +1 -1
- package/dist/components/layouts/register/hooks/use_register_form.js +3 -1
- package/dist/components/layouts/register/index.d.ts +2 -1
- package/dist/components/layouts/register/index.d.ts.map +1 -1
- 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 +4 -2
- package/dist/components/layouts/reset_password/index.d.ts +2 -1
- package/dist/components/layouts/reset_password/index.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/already_logged_in_guard.d.ts +2 -1
- package/dist/components/layouts/shared/components/already_logged_in_guard.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/logout_button.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/logout_button.js +3 -1
- package/dist/components/layouts/shared/components/profile_pic_menu.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/profile_pic_menu.js +8 -4
- package/dist/components/layouts/shared/components/two_column_auth_layout.d.ts +2 -1
- package/dist/components/layouts/shared/components/two_column_auth_layout.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/visual_panel.d.ts +2 -1
- package/dist/components/layouts/shared/components/visual_panel.d.ts.map +1 -1
- package/dist/components/layouts/shared/components/visual_panel.js +2 -1
- package/dist/components/layouts/shared/hooks/use_auth_status.d.ts.map +1 -1
- package/dist/components/layouts/shared/hooks/use_auth_status.js +4 -2
- package/dist/components/layouts/shared/hooks/use_hazo_auth.d.ts.map +1 -1
- package/dist/components/layouts/shared/hooks/use_hazo_auth.js +4 -2
- package/dist/components/layouts/shared/index.d.ts +0 -2
- package/dist/components/layouts/shared/index.d.ts.map +1 -1
- package/dist/components/layouts/shared/index.js +2 -2
- package/dist/components/layouts/user_management/components/roles_matrix.d.ts.map +1 -1
- package/dist/components/layouts/user_management/components/roles_matrix.js +8 -6
- package/dist/components/layouts/user_management/index.d.ts.map +1 -1
- package/dist/components/layouts/user_management/index.js +15 -13
- package/dist/contexts/hazo_auth_config.d.ts +18 -0
- package/dist/contexts/hazo_auth_config.d.ts.map +1 -0
- package/dist/contexts/hazo_auth_config.js +10 -0
- package/dist/contexts/hazo_auth_provider.d.ts +73 -0
- package/dist/contexts/hazo_auth_provider.d.ts.map +1 -0
- package/dist/contexts/hazo_auth_provider.js +82 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/lib/config/default_config.d.ts +237 -0
- package/dist/lib/config/default_config.d.ts.map +1 -0
- package/dist/lib/config/default_config.js +159 -0
- package/dist/lib/email_verification_config.server.d.ts +4 -0
- package/dist/lib/email_verification_config.server.d.ts.map +1 -1
- package/dist/lib/email_verification_config.server.js +12 -0
- package/dist/lib/forgot_password_config.server.d.ts +4 -0
- package/dist/lib/forgot_password_config.server.d.ts.map +1 -1
- package/dist/lib/forgot_password_config.server.js +12 -0
- package/dist/lib/login_config.server.d.ts +4 -0
- package/dist/lib/login_config.server.d.ts.map +1 -1
- package/dist/lib/login_config.server.js +10 -0
- package/dist/lib/password_requirements_config.server.d.ts +1 -1
- package/dist/lib/password_requirements_config.server.d.ts.map +1 -1
- package/dist/lib/password_requirements_config.server.js +8 -7
- package/dist/lib/register_config.server.d.ts +4 -0
- package/dist/lib/register_config.server.d.ts.map +1 -1
- package/dist/lib/register_config.server.js +10 -0
- package/dist/lib/reset_password_config.server.d.ts +4 -0
- package/dist/lib/reset_password_config.server.d.ts.map +1 -1
- package/dist/lib/reset_password_config.server.js +10 -0
- package/dist/page_components/forgot_password.d.ts.map +1 -1
- package/dist/page_components/forgot_password.js +14 -0
- package/dist/page_components/login.d.ts +4 -0
- package/dist/page_components/login.d.ts.map +1 -1
- package/dist/page_components/login.js +14 -0
- package/dist/page_components/register.d.ts.map +1 -1
- package/dist/page_components/register.js +14 -0
- package/dist/page_components/reset_password.d.ts.map +1 -1
- package/dist/page_components/reset_password.js +14 -0
- package/dist/page_components/verify_email.d.ts.map +1 -1
- package/dist/page_components/verify_email.js +14 -0
- package/dist/pages/forgot_password.d.ts +52 -0
- package/dist/pages/forgot_password.d.ts.map +1 -0
- package/dist/pages/forgot_password.js +41 -0
- package/dist/pages/index.d.ts +33 -0
- package/dist/pages/index.d.ts.map +1 -0
- package/dist/pages/index.js +28 -0
- package/dist/pages/login.d.ts +43 -0
- package/dist/pages/login.d.ts.map +1 -0
- package/dist/pages/login.js +45 -0
- package/dist/pages/my_settings.d.ts +54 -0
- package/dist/pages/my_settings.d.ts.map +1 -0
- package/dist/pages/my_settings.js +57 -0
- package/dist/pages/register.d.ts +44 -0
- package/dist/pages/register.d.ts.map +1 -0
- package/dist/pages/register.js +46 -0
- package/dist/pages/reset_password.d.ts +43 -0
- package/dist/pages/reset_password.d.ts.map +1 -0
- package/dist/pages/reset_password.js +42 -0
- package/dist/pages/verify_email.d.ts +52 -0
- package/dist/pages/verify_email.d.ts.map +1 -0
- package/dist/pages/verify_email.js +41 -0
- package/dist/server_pages/forgot_password.d.ts +53 -0
- package/dist/server_pages/forgot_password.d.ts.map +1 -0
- package/dist/server_pages/forgot_password.js +40 -0
- package/dist/server_pages/forgot_password_client_wrapper.d.ts +15 -0
- package/dist/server_pages/forgot_password_client_wrapper.d.ts.map +1 -0
- package/dist/server_pages/forgot_password_client_wrapper.js +27 -0
- package/dist/server_pages/index.d.ts +13 -0
- package/dist/server_pages/index.d.ts.map +1 -0
- package/dist/server_pages/index.js +7 -0
- package/dist/server_pages/login.d.ts +43 -0
- package/dist/server_pages/login.d.ts.map +1 -0
- package/dist/server_pages/login.js +39 -0
- package/dist/server_pages/login_client_wrapper.d.ts +13 -0
- package/dist/server_pages/login_client_wrapper.d.ts.map +1 -0
- package/dist/server_pages/login_client_wrapper.js +29 -0
- package/dist/server_pages/my_settings.d.ts +53 -0
- package/dist/server_pages/my_settings.d.ts.map +1 -0
- package/dist/server_pages/my_settings.js +57 -0
- package/dist/server_pages/register.d.ts +45 -0
- package/dist/server_pages/register.d.ts.map +1 -0
- package/dist/server_pages/register.js +41 -0
- package/dist/server_pages/register_client_wrapper.d.ts +13 -0
- package/dist/server_pages/register_client_wrapper.d.ts.map +1 -0
- package/dist/server_pages/register_client_wrapper.js +27 -0
- package/dist/server_pages/reset_password.d.ts +44 -0
- package/dist/server_pages/reset_password.d.ts.map +1 -0
- package/dist/server_pages/reset_password.js +40 -0
- package/dist/server_pages/reset_password_client_wrapper.d.ts +13 -0
- package/dist/server_pages/reset_password_client_wrapper.d.ts.map +1 -0
- package/dist/server_pages/reset_password_client_wrapper.js +27 -0
- package/dist/server_pages/verify_email.d.ts +53 -0
- package/dist/server_pages/verify_email.d.ts.map +1 -0
- package/dist/server_pages/verify_email.js +40 -0
- package/dist/server_pages/verify_email_client_wrapper.d.ts +15 -0
- package/dist/server_pages/verify_email_client_wrapper.d.ts.map +1 -0
- package/dist/server_pages/verify_email_client_wrapper.js +27 -0
- package/package.json +34 -10
package/README.md
CHANGED
|
@@ -2,9 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
A reusable authentication UI component package powered by Next.js, TailwindCSS, and shadcn. It integrates `hazo_config` for configuration management and `hazo_connect` for data access, enabling future components to stay aligned with platform conventions.
|
|
4
4
|
|
|
5
|
-
### What's New
|
|
5
|
+
### What's New in v2.0 🚀
|
|
6
6
|
|
|
7
|
-
- **
|
|
7
|
+
**Zero-Config Server Components** - Authentication pages now work out-of-the-box with ZERO configuration required!
|
|
8
|
+
|
|
9
|
+
- ✅ **True "Drop In and Use"** - Pages initialize everything server-side, no loading state
|
|
10
|
+
- ✅ **Better Performance** - Smaller JS bundles, faster page loads, immediate rendering
|
|
11
|
+
- ✅ **Flexible API Paths** - Customize endpoints globally via `HazoAuthProvider` context
|
|
12
|
+
- ✅ **Embeddable Components** - MySettings and UserManagement adapt to any layout
|
|
13
|
+
- ✅ **Sensible Defaults** - INI files are now optional, defaults built-in
|
|
14
|
+
|
|
15
|
+
**Migrating from v1.x?** See [MIGRATION.md](./MIGRATION.md) for a complete upgrade guide.
|
|
16
|
+
|
|
17
|
+
### Also Includes (v1.6.6+)
|
|
18
|
+
|
|
19
|
+
- **JWT Session Tokens for Edge-Compatible Authentication**: Secure Edge Runtime authentication in Next.js proxy/middleware files. See [Proxy/Middleware Authentication](#proxymiddleware-authentication) for details.
|
|
8
20
|
|
|
9
21
|
## Table of Contents
|
|
10
22
|
|
|
@@ -63,25 +75,113 @@ npx hazo_auth validate # Check your setup and configuration
|
|
|
63
75
|
npx hazo_auth --help # Show all commands
|
|
64
76
|
```
|
|
65
77
|
|
|
66
|
-
### Using Zero-Config Page Components
|
|
78
|
+
### Using Zero-Config Page Components (v2.0+)
|
|
79
|
+
|
|
80
|
+
**NEW in v2.0:** All pages are now React Server Components that initialize everything on the server. No configuration, no loading state, no hassle!
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
// app/login/page.tsx - That's literally it!
|
|
84
|
+
import { LoginPage } from "hazo_auth/pages/login";
|
|
85
|
+
|
|
86
|
+
export default function Page() {
|
|
87
|
+
return <LoginPage />;
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**What happens behind the scenes:**
|
|
92
|
+
- ✅ Database connection initialized server-side via hazo_connect singleton
|
|
93
|
+
- ✅ Configuration loaded from hazo_auth_config.ini (or uses sensible defaults)
|
|
94
|
+
- ✅ All props automatically configured
|
|
95
|
+
- ✅ Page renders immediately - NO loading state!
|
|
96
|
+
|
|
97
|
+
**Available zero-config pages:**
|
|
98
|
+
|
|
99
|
+
| Page | Import | Description |
|
|
100
|
+
|------|--------|-------------|
|
|
101
|
+
| **LoginPage** | `hazo_auth/pages/login` | Login form with forgot password link |
|
|
102
|
+
| **RegisterPage** | `hazo_auth/pages/register` | Registration with password validation |
|
|
103
|
+
| **ForgotPasswordPage** | `hazo_auth/pages/forgot_password` | Request password reset email |
|
|
104
|
+
| **ResetPasswordPage** | `hazo_auth/pages/reset_password` | Set new password with token |
|
|
105
|
+
| **VerifyEmailPage** | `hazo_auth/pages/verify_email` | Email verification handler |
|
|
106
|
+
| **MySettingsPage** | `hazo_auth/pages/my_settings` | User profile and password change |
|
|
107
|
+
|
|
108
|
+
**Example - Complete Auth Flow:**
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
// app/login/page.tsx
|
|
112
|
+
import { LoginPage } from "hazo_auth/pages/login";
|
|
113
|
+
export default function Page() {
|
|
114
|
+
return <LoginPage />;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// app/register/page.tsx
|
|
118
|
+
import { RegisterPage } from "hazo_auth/pages/register";
|
|
119
|
+
export default function Page() {
|
|
120
|
+
return <RegisterPage />;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// app/settings/page.tsx
|
|
124
|
+
import { MySettingsPage } from "hazo_auth/pages/my_settings";
|
|
125
|
+
export default function Page() {
|
|
126
|
+
return <MySettingsPage />;
|
|
127
|
+
}
|
|
128
|
+
```
|
|
67
129
|
|
|
68
|
-
|
|
130
|
+
**Customizing Visual Appearance (Optional):**
|
|
69
131
|
|
|
70
132
|
```typescript
|
|
71
|
-
//
|
|
133
|
+
// All pages accept optional visual props
|
|
72
134
|
import { LoginPage } from "hazo_auth/pages/login";
|
|
73
|
-
|
|
135
|
+
|
|
136
|
+
export default function Page() {
|
|
137
|
+
return (
|
|
138
|
+
<LoginPage
|
|
139
|
+
image_src="/custom-login-image.jpg"
|
|
140
|
+
image_alt="My company logo"
|
|
141
|
+
image_background_color="#f0f0f0"
|
|
142
|
+
/>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Embedding MySettings in Your Dashboard:**
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
// MySettings is now container-agnostic!
|
|
151
|
+
import { MySettingsPage } from "hazo_auth/pages/my_settings";
|
|
152
|
+
|
|
153
|
+
export default function DashboardPage() {
|
|
154
|
+
return (
|
|
155
|
+
<DashboardLayout>
|
|
156
|
+
<Sidebar />
|
|
157
|
+
<main className="p-6">
|
|
158
|
+
<MySettingsPage className="max-w-4xl mx-auto" />
|
|
159
|
+
</main>
|
|
160
|
+
</DashboardLayout>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
74
163
|
```
|
|
75
164
|
|
|
76
|
-
|
|
77
|
-
- `LoginPage` - Login form with sensible defaults
|
|
78
|
-
- `RegisterPage` - Registration with password requirements
|
|
79
|
-
- `ForgotPasswordPage` - Password reset request
|
|
80
|
-
- `ResetPasswordPage` - Set new password
|
|
81
|
-
- `VerifyEmailPage` - Email verification
|
|
82
|
-
- `MySettingsPage` - User profile and settings
|
|
165
|
+
**Custom API Paths:**
|
|
83
166
|
|
|
84
|
-
|
|
167
|
+
If you use custom API endpoints (not `/api/hazo_auth/`), wrap your app with `HazoAuthProvider`:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
// app/layout.tsx
|
|
171
|
+
import { HazoAuthProvider } from "hazo_auth";
|
|
172
|
+
|
|
173
|
+
export default function RootLayout({ children }) {
|
|
174
|
+
return (
|
|
175
|
+
<html>
|
|
176
|
+
<body>
|
|
177
|
+
<HazoAuthProvider apiBasePath="/api/v1/auth">
|
|
178
|
+
{children}
|
|
179
|
+
</HazoAuthProvider>
|
|
180
|
+
</body>
|
|
181
|
+
</html>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
```
|
|
85
185
|
|
|
86
186
|
### Manual Setup (Advanced)
|
|
87
187
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_email_verification.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/email_verification/hooks/use_email_verification.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAgC,KAAK,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"use_email_verification.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/email_verification/hooks/use_email_verification.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAgC,KAAK,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AAKxH,MAAM,MAAM,2BAA2B,GAAG,MAAM,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC;AACnF,MAAM,MAAM,2BAA2B,GAAG,OAAO,CAAC,MAAM,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC,GAAG;IAC5F,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,0BAA0B,CAAC,OAAO,GAAG,OAAO,IAAI;IAC1D,UAAU,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,2BAA2B,CAAC;IACpC,MAAM,EAAE,2BAA2B,CAAC;IACpC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,CAAC,OAAO,EAAE,wBAAwB,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9E,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,kBAAkB,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;IACtE,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B,CAAC;AAQF,eAAO,MAAM,sBAAsB,GAAI,OAAO,EAAG,2CAI9C,0BAA0B,CAAC,OAAO,CAAC,KAAG,0BAsPxC,CAAC"}
|
|
@@ -5,12 +5,14 @@ import { useRouter, useSearchParams } from "next/navigation";
|
|
|
5
5
|
import { toast } from "sonner";
|
|
6
6
|
import { EMAIL_VERIFICATION_FIELD_IDS } from "../config/email_verification_field_config";
|
|
7
7
|
import { validateEmail } from "../../shared/utils/validation";
|
|
8
|
+
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider";
|
|
8
9
|
// section: helpers
|
|
9
10
|
const buildInitialValues = (initialEmail) => ({
|
|
10
11
|
[EMAIL_VERIFICATION_FIELD_IDS.EMAIL]: initialEmail || "",
|
|
11
12
|
});
|
|
12
13
|
// section: hook
|
|
13
14
|
export const use_email_verification = ({ dataClient, redirectDelay = 5, loginPath = "/hazo_auth/login", }) => {
|
|
15
|
+
const { apiBasePath } = useHazoAuthConfig();
|
|
14
16
|
const router = useRouter();
|
|
15
17
|
const searchParams = useSearchParams();
|
|
16
18
|
const token = searchParams.get("token");
|
|
@@ -48,7 +50,7 @@ export const use_email_verification = ({ dataClient, redirectDelay = 5, loginPat
|
|
|
48
50
|
setIsError(false);
|
|
49
51
|
setErrorMessage(undefined);
|
|
50
52
|
try {
|
|
51
|
-
const response = await fetch(
|
|
53
|
+
const response = await fetch(`${apiBasePath}/verify_email?token=${encodeURIComponent(token)}`, {
|
|
52
54
|
method: "GET",
|
|
53
55
|
});
|
|
54
56
|
const data = await response.json();
|
|
@@ -79,7 +81,7 @@ export const use_email_verification = ({ dataClient, redirectDelay = 5, loginPat
|
|
|
79
81
|
setErrorMessage(errorMessage);
|
|
80
82
|
// Try to extract email from error response if available
|
|
81
83
|
try {
|
|
82
|
-
const response = await fetch(
|
|
84
|
+
const response = await fetch(`${apiBasePath}/verify_email?token=${encodeURIComponent(token)}`, {
|
|
83
85
|
method: "GET",
|
|
84
86
|
});
|
|
85
87
|
const data = await response.json();
|
|
@@ -155,7 +157,7 @@ export const use_email_verification = ({ dataClient, redirectDelay = 5, loginPat
|
|
|
155
157
|
setIsSubmitting(true);
|
|
156
158
|
setErrors({});
|
|
157
159
|
try {
|
|
158
|
-
const response = await fetch(
|
|
160
|
+
const response = await fetch(`${apiBasePath}/resend_verification`, {
|
|
159
161
|
method: "POST",
|
|
160
162
|
headers: {
|
|
161
163
|
"Content-Type": "application/json",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { StaticImageData } from "next/image";
|
|
1
2
|
import { type ButtonPaletteOverrides, type LayoutFieldMapOverrides, type LayoutLabelOverrides } from "../shared/config/layout_customization";
|
|
2
3
|
import { type EmailVerificationSuccessLabels, type EmailVerificationErrorLabels } from "./config/email_verification_field_config";
|
|
3
4
|
import { type LayoutDataClient } from "../shared/data/layout_data_client";
|
|
4
5
|
export type EmailVerificationLayoutProps<TClient = unknown> = {
|
|
5
|
-
image_src: string;
|
|
6
|
+
image_src: string | StaticImageData;
|
|
6
7
|
image_alt: string;
|
|
7
8
|
image_background_color?: string;
|
|
8
9
|
field_overrides?: LayoutFieldMapOverrides;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/email_verification/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/email_verification/index.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAKlD,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAC1B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAOL,KAAK,8BAA8B,EACnC,KAAK,4BAA4B,EAClC,MAAM,0CAA0C,CAAC;AAKlD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAM1E,MAAM,MAAM,4BAA4B,CAAC,OAAO,GAAG,OAAO,IAAI;IAC5D,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,cAAc,CAAC,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAC;IACzD,YAAY,CAAC,EAAE,OAAO,CAAC,4BAA4B,CAAC,CAAC;IACrD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,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,WAAW,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;CACxC,CAAC;AASF,MAAM,CAAC,OAAO,UAAU,yBAAyB,CAAC,OAAO,EAAE,EACzD,SAAS,EACT,SAAS,EACT,sBAAkC,EAClC,eAAe,EACf,MAAM,EACN,aAAa,EACb,cAAc,EACd,YAAY,EACZ,cAAkB,EAClB,UAA+B,EAC/B,aAAyB,EACzB,WAAW,EACX,yBAAyB,EACzB,gBAAuB,EACvB,oBAA4B,EAC5B,qBAAqC,EACrC,cAAoB,GACrB,EAAE,4BAA4B,CAAC,OAAO,CAAC,2CAkOvC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_forgot_password_form.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/forgot_password/hooks/use_forgot_password_form.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAA6B,KAAK,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"use_forgot_password_form.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/forgot_password/hooks/use_forgot_password_form.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAA6B,KAAK,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAK/G,MAAM,MAAM,wBAAwB,GAAG,MAAM,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AAC7E,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,GAAG;IACtF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,2BAA2B,CAAC,OAAO,GAAG,OAAO,IAAI;IAC3D,UAAU,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE,wBAAwB,CAAC;IACjC,MAAM,EAAE,wBAAwB,CAAC;IACjC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,EAAE,CAAC,OAAO,EAAE,qBAAqB,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3E,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;IAChE,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B,CAAC;AAQF,eAAO,MAAM,wBAAwB,GAAI,OAAO,EAAG,iBAEhD,2BAA2B,CAAC,OAAO,CAAC,KAAG,2BA4IzC,CAAC"}
|
|
@@ -4,12 +4,14 @@ import { useCallback, useMemo, useState } from "react";
|
|
|
4
4
|
import { toast } from "sonner";
|
|
5
5
|
import { FORGOT_PASSWORD_FIELD_IDS } from "../config/forgot_password_field_config";
|
|
6
6
|
import { validateEmail } from "../../shared/utils/validation";
|
|
7
|
+
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider";
|
|
7
8
|
// section: helpers
|
|
8
9
|
const buildInitialValues = () => ({
|
|
9
10
|
[FORGOT_PASSWORD_FIELD_IDS.EMAIL]: "",
|
|
10
11
|
});
|
|
11
12
|
// section: hook
|
|
12
13
|
export const use_forgot_password_form = ({ dataClient, }) => {
|
|
14
|
+
const { apiBasePath } = useHazoAuthConfig();
|
|
13
15
|
const [values, setValues] = useState(buildInitialValues);
|
|
14
16
|
const [errors, setErrors] = useState({});
|
|
15
17
|
const [emailTouched, setEmailTouched] = useState(false);
|
|
@@ -71,7 +73,7 @@ export const use_forgot_password_form = ({ dataClient, }) => {
|
|
|
71
73
|
setIsSubmitting(true);
|
|
72
74
|
setErrors({});
|
|
73
75
|
try {
|
|
74
|
-
const response = await fetch(
|
|
76
|
+
const response = await fetch(`${apiBasePath}/forgot_password`, {
|
|
75
77
|
method: "POST",
|
|
76
78
|
headers: {
|
|
77
79
|
"Content-Type": "application/json",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { StaticImageData } from "next/image";
|
|
1
2
|
import { type ButtonPaletteOverrides, type LayoutFieldMapOverrides, type LayoutLabelOverrides } from "../shared/config/layout_customization";
|
|
2
3
|
import { type LayoutDataClient } from "../shared/data/layout_data_client";
|
|
3
4
|
export type ForgotPasswordLayoutProps<TClient = unknown> = {
|
|
4
|
-
image_src: string;
|
|
5
|
+
image_src: string | StaticImageData;
|
|
5
6
|
image_alt: string;
|
|
6
7
|
image_background_color?: string;
|
|
7
8
|
field_overrides?: LayoutFieldMapOverrides;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/forgot_password/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/forgot_password/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAMlD,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAC1B,MAAM,uCAAuC,CAAC;AAW/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAI1E,MAAM,MAAM,yBAAyB,CAAC,OAAO,GAAG,OAAO,IAAI;IACzD,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,WAAW,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,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;CACzB,CAAC;AASF,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,OAAO,EAAE,EACtD,SAAS,EACT,SAAS,EACT,sBAAkC,EAClC,eAAe,EACf,MAAM,EACN,aAAa,EACb,WAAW,EACX,YAAiC,EACjC,aAAyB,EACzB,sBAAoD,EACpD,gBAAuB,EACvB,oBAA4B,EAC5B,qBAAqC,EACrC,cAAoB,GACrB,EAAE,yBAAyB,CAAC,OAAO,CAAC,2CA+GpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_login_form.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/login/hooks/use_login_form.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"use_login_form.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/login/hooks/use_login_form.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAOlF,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;AAC3D,MAAM,MAAM,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;AACpE,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,OAAO,GAAG,OAAO,IAAI;IAClD,UAAU,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACtC,MAAM,CAAC,EAAE;QACP,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;QAChE,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;QACjE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;QAChE,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;KAClE,CAAC;IACF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,EAAE,eAAe,CAAC;IACxB,kBAAkB,EAAE,uBAAuB,CAAC;IAC5C,gBAAgB,EAAE,OAAO,CAAC;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClE,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,wBAAwB,EAAE,MAAM,IAAI,CAAC;IACrC,YAAY,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;IAChE,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B,CAAC;AAkBF,eAAO,MAAM,cAAc,GAAI,OAAO,EAAG,oEAMtC,kBAAkB,CAAC,OAAO,CAAC,KAAG,kBA2NhC,CAAC"}
|
|
@@ -6,6 +6,7 @@ import { LOGIN_FIELD_IDS } from "../config/login_field_config";
|
|
|
6
6
|
import { validateEmail } from "../../shared/utils/validation";
|
|
7
7
|
import { get_client_ip } from "../../shared/utils/ip_address";
|
|
8
8
|
import { trigger_auth_status_refresh } from "../../shared/hooks/use_auth_status";
|
|
9
|
+
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider";
|
|
9
10
|
// section: helpers
|
|
10
11
|
const buildInitialValues = () => ({
|
|
11
12
|
[LOGIN_FIELD_IDS.EMAIL]: "",
|
|
@@ -21,6 +22,7 @@ const get_line_number = () => {
|
|
|
21
22
|
// section: hook
|
|
22
23
|
export const use_login_form = ({ dataClient, logger, redirectRoute, successMessage = "Successfully logged in", urlOnLogon, }) => {
|
|
23
24
|
const router = useRouter();
|
|
25
|
+
const { apiBasePath } = useHazoAuthConfig();
|
|
24
26
|
const [values, setValues] = useState(buildInitialValues);
|
|
25
27
|
const [errors, setErrors] = useState({});
|
|
26
28
|
const [passwordVisibility, setPasswordVisibility] = useState({
|
|
@@ -110,7 +112,7 @@ export const use_login_form = ({ dataClient, logger, redirectRoute, successMessa
|
|
|
110
112
|
const currentIp = clientIp === "unknown" ? await get_client_ip() : clientIp;
|
|
111
113
|
setClientIp(currentIp);
|
|
112
114
|
// Attempt login via API route
|
|
113
|
-
const response = await fetch(
|
|
115
|
+
const response = await fetch(`${apiBasePath}/login`, {
|
|
114
116
|
method: "POST",
|
|
115
117
|
headers: {
|
|
116
118
|
"Content-Type": "application/json",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { StaticImageData } from "next/image";
|
|
1
2
|
import { type ButtonPaletteOverrides, type LayoutFieldMapOverrides, type LayoutLabelOverrides } from "../shared/config/layout_customization";
|
|
2
3
|
import { type LayoutDataClient } from "../shared/data/layout_data_client";
|
|
3
4
|
export type LoginLayoutProps<TClient = unknown> = {
|
|
4
|
-
image_src: string;
|
|
5
|
+
image_src: string | StaticImageData;
|
|
5
6
|
image_alt: string;
|
|
6
7
|
image_background_color?: string;
|
|
7
8
|
field_overrides?: LayoutFieldMapOverrides;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/login/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/login/index.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AASlD,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAC1B,MAAM,uCAAuC,CAAC;AAW/C,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAG1E,MAAM,MAAM,gBAAgB,CAAC,OAAO,GAAG,OAAO,IAAI;IAChD,SAAS,EAAE,MAAM,GAAG,eAAe,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,eAAe,CAAC,EAAE,uBAAuB,CAAC;IAC1C,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,WAAW,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,CAAC,EAAE;QACP,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;QAChE,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;QACjE,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;QAChE,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;KAClE,CAAC;IACF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,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,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAUF,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,OAAO,EAAE,EAC5C,SAAS,EACT,SAAS,EACT,sBAAkC,EAClC,eAAe,EACf,MAAM,EACN,aAAa,EACb,WAAW,EACX,MAAM,EACN,aAAa,EACb,cAAyC,EACzC,sBAAoD,EACpD,gBAAuB,EACvB,oBAA4B,EAC5B,qBAAqC,EACrC,cAAoB,EACpB,oBAAmD,EACnD,qBAA0C,EAC1C,mBAA2C,EAC3C,oBAAuC,EACvC,UAAU,GACX,EAAE,gBAAgB,CAAC,OAAO,CAAC,2CAiK3B"}
|
|
@@ -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":"
|
|
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,eAAwB,EACxB,iBAA4B,EAC5B,QAAgB,EAChB,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE,yBAAyB,2CAgT3B"}
|
|
@@ -12,6 +12,7 @@ import { ProfilePictureLibraryTab } from "./profile_picture_library_tab";
|
|
|
12
12
|
import { ProfilePictureGravatarTab } from "./profile_picture_gravatar_tab";
|
|
13
13
|
import { toast } from "sonner";
|
|
14
14
|
import { cn } from "../../../../lib/utils";
|
|
15
|
+
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider";
|
|
15
16
|
// section: component
|
|
16
17
|
/**
|
|
17
18
|
* Profile picture dialog component with tabs for Upload, Library, and Gravatar
|
|
@@ -20,6 +21,7 @@ import { cn } from "../../../../lib/utils";
|
|
|
20
21
|
* @returns Profile picture dialog component
|
|
21
22
|
*/
|
|
22
23
|
export function ProfilePictureDialog({ open, onOpenChange, onSave, email, allowPhotoUpload, maxPhotoSize, libraryPhotoPath, currentProfilePictureUrl, currentProfileSource, saveButtonLabel = "Save", cancelButtonLabel = "Cancel", disabled = false, messages, uiSizes, fileTypes, }) {
|
|
24
|
+
const { apiBasePath } = useHazoAuthConfig();
|
|
23
25
|
const [useUpload, setUseUpload] = useState(false);
|
|
24
26
|
const [useLibrary, setUseLibrary] = useState(false);
|
|
25
27
|
const [useGravatar, setUseGravatar] = useState(false);
|
|
@@ -126,7 +128,7 @@ export function ProfilePictureDialog({ open, onOpenChange, onSave, email, allowP
|
|
|
126
128
|
try {
|
|
127
129
|
const formData = new FormData();
|
|
128
130
|
formData.append("file", file);
|
|
129
|
-
const response = await fetch(
|
|
131
|
+
const response = await fetch(`${apiBasePath}/upload_profile_picture`, {
|
|
130
132
|
method: "POST",
|
|
131
133
|
credentials: "include",
|
|
132
134
|
body: formData,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile_picture_library_tab.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/profile_picture_library_tab.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"profile_picture_library_tab.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/components/profile_picture_library_tab.tsx"],"names":[],"mappings":"AAeA,MAAM,MAAM,6BAA6B,GAAG;IAC1C,UAAU,EAAE,OAAO,CAAC;IACpB,kBAAkB,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,uBAAuB,EAAE,MAAM,CAAC;IAChC,uBAAuB,EAAE,MAAM,CAAC;CACjC,CAAC;AAGF;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,EACvC,UAAU,EACV,kBAAkB,EAClB,aAAa,EACb,QAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,uBAAuB,GACxB,EAAE,6BAA6B,2CAwQ/B"}
|
|
@@ -10,6 +10,7 @@ import { Avatar, AvatarFallback } from "../../../ui/avatar";
|
|
|
10
10
|
import { VerticalTabs, VerticalTabsList, VerticalTabsTrigger } from "../../../ui/vertical-tabs";
|
|
11
11
|
import { Loader2 } from "lucide-react";
|
|
12
12
|
import { HazoUITooltip } from "../../../ui/hazo_ui_tooltip";
|
|
13
|
+
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider";
|
|
13
14
|
// section: component
|
|
14
15
|
/**
|
|
15
16
|
* Library tab component for profile picture dialog
|
|
@@ -19,6 +20,7 @@ import { HazoUITooltip } from "../../../ui/hazo_ui_tooltip";
|
|
|
19
20
|
* @returns Library tab component
|
|
20
21
|
*/
|
|
21
22
|
export function ProfilePictureLibraryTab({ useLibrary, onUseLibraryChange, onPhotoSelect, disabled = false, libraryPhotoPath, currentPhotoUrl, libraryTooltipMessage, tooltipIconSizeSmall, libraryPhotoGridColumns, libraryPhotoPreviewSize, }) {
|
|
23
|
+
const { apiBasePath } = useHazoAuthConfig();
|
|
22
24
|
const [categories, setCategories] = useState([]);
|
|
23
25
|
const [selectedCategory, setSelectedCategory] = useState(null);
|
|
24
26
|
const [photos, setPhotos] = useState([]);
|
|
@@ -30,7 +32,7 @@ export function ProfilePictureLibraryTab({ useLibrary, onUseLibraryChange, onPho
|
|
|
30
32
|
const loadCategories = async () => {
|
|
31
33
|
setLoadingCategories(true);
|
|
32
34
|
try {
|
|
33
|
-
const response = await fetch(
|
|
35
|
+
const response = await fetch(`${apiBasePath}/library_photos`);
|
|
34
36
|
const data = await response.json();
|
|
35
37
|
if (data.success && data.categories) {
|
|
36
38
|
setCategories(data.categories);
|
|
@@ -70,7 +72,7 @@ export function ProfilePictureLibraryTab({ useLibrary, onUseLibraryChange, onPho
|
|
|
70
72
|
const loadPhotos = async () => {
|
|
71
73
|
setLoadingPhotos(true);
|
|
72
74
|
try {
|
|
73
|
-
const response = await fetch(
|
|
75
|
+
const response = await fetch(`${apiBasePath}/library_photos?category=${encodeURIComponent(selectedCategory)}`);
|
|
74
76
|
const data = await response.json();
|
|
75
77
|
if (data.success && data.photos) {
|
|
76
78
|
setPhotos(data.photos);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use_my_settings.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/hooks/use_my_settings.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"use_my_settings.d.ts","sourceRoot":"","sources":["../../../../../src/components/layouts/my_settings/hooks/use_my_settings.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AAI3F,MAAM,MAAM,cAAc,GAAG;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,sBAAsB,EAAE,OAAO,CAAC;IAChC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,sBAAsB,EAAE,OAAO,CAAC;IAChC,MAAM,EAAE;QACN,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAChC,eAAe,CAAC,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAEhC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,aAAa,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IAGjB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,yBAAyB,EAAE,CAAC,KAAK,EAAE,iBAAiB,GAAG,aAAa,GAAG,iBAAiB,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjH,wBAAwB,EAAE,CAAC,KAAK,EAAE,iBAAiB,GAAG,aAAa,GAAG,iBAAiB,KAAK,IAAI,CAAC;IACjG,kBAAkB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,sBAAsB,EAAE,OAAO,CAAC;IAGhC,wBAAwB,EAAE,OAAO,CAAC;IAClC,wBAAwB,EAAE,MAAM,IAAI,CAAC;IACrC,+BAA+B,EAAE,MAAM,IAAI,CAAC;IAC5C,wBAAwB,EAAE,CAAC,iBAAiB,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,GAAG,SAAS,GAAG,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzH,0BAA0B,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAGhD,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAGlD,eAAe,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,oBAAoB,EAAE,0BAA0B,CAAC;CAClD,CAAC;AA4BF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,EAC9B,oBAAoB,GACrB,EAAE,mBAAmB,GAAG,mBAAmB,CA2W3C"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { useState, useCallback } from "react";
|
|
6
6
|
import { use_auth_status, trigger_auth_status_refresh } from "../../shared/hooks/use_auth_status";
|
|
7
7
|
import { toast } from "sonner";
|
|
8
|
+
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider";
|
|
8
9
|
// section: helpers
|
|
9
10
|
/**
|
|
10
11
|
* Validates email format
|
|
@@ -36,6 +37,7 @@ const validateName = (name) => {
|
|
|
36
37
|
* @returns My settings hook result with state and actions
|
|
37
38
|
*/
|
|
38
39
|
export function use_my_settings({ passwordRequirements, }) {
|
|
40
|
+
const { apiBasePath } = useHazoAuthConfig();
|
|
39
41
|
const authStatus = use_auth_status();
|
|
40
42
|
// Password fields state
|
|
41
43
|
const [passwordFields, setPasswordFields] = useState({
|
|
@@ -72,7 +74,7 @@ export function use_my_settings({ passwordRequirements, }) {
|
|
|
72
74
|
throw new Error(validationError);
|
|
73
75
|
}
|
|
74
76
|
try {
|
|
75
|
-
const response = await fetch(
|
|
77
|
+
const response = await fetch(`${apiBasePath}/update_user`, {
|
|
76
78
|
method: "PATCH",
|
|
77
79
|
headers: {
|
|
78
80
|
"Content-Type": "application/json",
|
|
@@ -105,7 +107,7 @@ export function use_my_settings({ passwordRequirements, }) {
|
|
|
105
107
|
throw new Error(validationError);
|
|
106
108
|
}
|
|
107
109
|
try {
|
|
108
|
-
const response = await fetch(
|
|
110
|
+
const response = await fetch(`${apiBasePath}/update_user`, {
|
|
109
111
|
method: "PATCH",
|
|
110
112
|
headers: {
|
|
111
113
|
"Content-Type": "application/json",
|
|
@@ -216,7 +218,7 @@ export function use_my_settings({ passwordRequirements, }) {
|
|
|
216
218
|
return;
|
|
217
219
|
}
|
|
218
220
|
try {
|
|
219
|
-
const response = await fetch(
|
|
221
|
+
const response = await fetch(`${apiBasePath}/change_password`, {
|
|
220
222
|
method: "POST",
|
|
221
223
|
headers: {
|
|
222
224
|
"Content-Type": "application/json",
|
|
@@ -274,7 +276,7 @@ export function use_my_settings({ passwordRequirements, }) {
|
|
|
274
276
|
*/
|
|
275
277
|
const handleProfilePictureSave = useCallback(async (profilePictureUrl, profileSource) => {
|
|
276
278
|
try {
|
|
277
|
-
const response = await fetch(
|
|
279
|
+
const response = await fetch(`${apiBasePath}/update_user`, {
|
|
278
280
|
method: "PATCH",
|
|
279
281
|
headers: {
|
|
280
282
|
"Content-Type": "application/json",
|
|
@@ -308,7 +310,7 @@ export function use_my_settings({ passwordRequirements, }) {
|
|
|
308
310
|
*/
|
|
309
311
|
const handleProfilePictureRemove = useCallback(async () => {
|
|
310
312
|
try {
|
|
311
|
-
const response = await fetch(
|
|
313
|
+
const response = await fetch(`${apiBasePath}/remove_profile_picture`, {
|
|
312
314
|
method: "DELETE",
|
|
313
315
|
headers: {
|
|
314
316
|
"Content-Type": "application/json",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type MySettingsLabelOverrides } from "./config/my_settings_field_config";
|
|
2
2
|
import type { PasswordRequirementOptions, ButtonPaletteOverrides } from "../shared/config/layout_customization";
|
|
3
3
|
export type MySettingsLayoutProps = {
|
|
4
|
+
className?: string;
|
|
4
5
|
labels?: MySettingsLabelOverrides;
|
|
5
6
|
button_colors?: ButtonPaletteOverrides;
|
|
6
7
|
password_requirements: PasswordRequirementOptions;
|
|
@@ -60,5 +61,5 @@ export type MySettingsLayoutProps = {
|
|
|
60
61
|
* @param props - Component props including labels, button colors, password requirements, etc.
|
|
61
62
|
* @returns My settings layout component
|
|
62
63
|
*/
|
|
63
|
-
export default function my_settings_layout({ labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage, loginButtonLabel, loginPath, heading, subHeading, profilePhotoLabel, profilePhotoRecommendation, uploadPhotoButtonLabel, removePhotoButtonLabel, profileInformationLabel, passwordLabel, currentPasswordLabel, newPasswordLabel, confirmPasswordLabel, messages, uiSizes, fileTypes, }: MySettingsLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
64
|
+
export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage, loginButtonLabel, loginPath, heading, subHeading, profilePhotoLabel, profilePhotoRecommendation, uploadPhotoButtonLabel, removePhotoButtonLabel, profileInformationLabel, passwordLabel, currentPasswordLabel, newPasswordLabel, confirmPasswordLabel, messages, uiSizes, fileTypes, }: MySettingsLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
64
65
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/my_settings/index.tsx"],"names":[],"mappings":"AAWA,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/layouts/my_settings/index.tsx"],"names":[],"mappings":"AAWA,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,0BAA0B,EAC1B,sBAAsB,EACvB,MAAM,uCAAuC,CAAC;AAQ/C,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,aAAa,CAAC,EAAE,sBAAsB,CAAC;IACvC,qBAAqB,EAAE,0BAA0B,CAAC;IAClD,cAAc,EAAE;QACd,kBAAkB,EAAE,OAAO,CAAC;QAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,cAAc,EAAE,MAAM,CAAC;QACvB,kBAAkB,EAAE,OAAO,CAAC;QAC5B,4BAA4B,EAAE,UAAU,GAAG,SAAS,CAAC;QACrD,4BAA4B,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;QACtD,kBAAkB,EAAE,MAAM,CAAC;KAC5B,CAAC;IACF,UAAU,EAAE;QACV,eAAe,EAAE,OAAO,CAAC;QACzB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,mBAAmB,EAAE,OAAO,CAAC;KAC9B,CAAC;IACF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,0BAA0B,CAAC,EAAE,MAAM,CAAC;IACpC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,EAAE;QACR,6BAA6B,EAAE,MAAM,CAAC;QACtC,sBAAsB,EAAE,MAAM,CAAC;QAC/B,2BAA2B,EAAE,MAAM,CAAC;QACpC,uBAAuB,EAAE,MAAM,CAAC;KACjC,CAAC;IACF,OAAO,EAAE;QACP,aAAa,EAAE,MAAM,CAAC;QACtB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,yBAAyB,EAAE,MAAM,CAAC;QAClC,uBAAuB,EAAE,MAAM,CAAC;QAChC,0BAA0B,EAAE,MAAM,CAAC;QACnC,0BAA0B,EAAE,MAAM,CAAC;QACnC,+BAA+B,EAAE,MAAM,CAAC;QACxC,4BAA4B,EAAE,MAAM,CAAC;KACtC,CAAC;IACF,SAAS,EAAE;QACT,wBAAwB,EAAE,MAAM,EAAE,CAAC;QACnC,wBAAwB,EAAE,MAAM,EAAE,CAAC;KACpC,CAAC;CACH,CAAC;AAGF;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EACzC,SAAS,EACT,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,UAAU,EACV,mBAAkE,EAClE,gBAAgC,EAChC,SAA8B,EAC9B,OAA4B,EAC5B,UAAoE,EACpE,iBAAmC,EACnC,0BAAqE,EACrE,sBAA2C,EAC3C,sBAAiC,EACjC,uBAA+C,EAC/C,aAA0B,EAC1B,oBAAyC,EACzC,gBAAiC,EACjC,oBAAyC,EACzC,QAAQ,EACR,OAAO,EACP,SAAS,GACV,EAAE,qBAAqB,2CAqNvB"}
|
|
@@ -13,6 +13,7 @@ import { resolveMySettingsLabels, resolveMySettingsButtonPalette, } from "./conf
|
|
|
13
13
|
import { PasswordField } from "../shared/components/password_field";
|
|
14
14
|
import { FormFieldWrapper } from "../shared/components/form_field_wrapper";
|
|
15
15
|
import { Pencil, Trash2 } from "lucide-react";
|
|
16
|
+
import { cn } from "../../../lib/utils";
|
|
16
17
|
// section: component
|
|
17
18
|
/**
|
|
18
19
|
* My Settings layout component with tabs for profile and security settings
|
|
@@ -21,14 +22,14 @@ import { Pencil, Trash2 } from "lucide-react";
|
|
|
21
22
|
* @param props - Component props including labels, button colors, password requirements, etc.
|
|
22
23
|
* @returns My settings layout component
|
|
23
24
|
*/
|
|
24
|
-
export default function my_settings_layout({ labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage = "You must be logged in to access this page.", loginButtonLabel = "Go to login", loginPath = "/hazo_auth/login", heading = "Account Settings", subHeading = "Manage your profile, password, and email preferences.", profilePhotoLabel = "Profile Photo", profilePhotoRecommendation = "Recommended size: 200x200px. JPG, PNG.", uploadPhotoButtonLabel = "Upload New Photo", removePhotoButtonLabel = "Remove", profileInformationLabel = "Profile Information", passwordLabel = "Password", currentPasswordLabel = "Current Password", newPasswordLabel = "New Password", confirmPasswordLabel = "Confirm Password", messages, uiSizes, fileTypes, }) {
|
|
25
|
+
export default function my_settings_layout({ className, labels, button_colors, password_requirements, profilePicture, userFields, unauthorizedMessage = "You must be logged in to access this page.", loginButtonLabel = "Go to login", loginPath = "/hazo_auth/login", heading = "Account Settings", subHeading = "Manage your profile, password, and email preferences.", profilePhotoLabel = "Profile Photo", profilePhotoRecommendation = "Recommended size: 200x200px. JPG, PNG.", uploadPhotoButtonLabel = "Upload New Photo", removePhotoButtonLabel = "Remove", profileInformationLabel = "Profile Information", passwordLabel = "Password", currentPasswordLabel = "Current Password", newPasswordLabel = "New Password", confirmPasswordLabel = "Confirm Password", messages, uiSizes, fileTypes, }) {
|
|
25
26
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
26
27
|
const resolvedLabels = resolveMySettingsLabels(labels);
|
|
27
28
|
const resolvedButtonPalette = resolveMySettingsButtonPalette(button_colors);
|
|
28
29
|
const settings = use_my_settings({
|
|
29
30
|
passwordRequirements: password_requirements,
|
|
30
31
|
});
|
|
31
|
-
return (_jsx(UnauthorizedGuard, { message: unauthorizedMessage, loginButtonLabel: loginButtonLabel, loginPath: loginPath, children: _jsxs("div", { className: "cls_my_settings_layout flex flex-col gap-6 p-6
|
|
32
|
+
return (_jsx(UnauthorizedGuard, { message: unauthorizedMessage, loginButtonLabel: loginButtonLabel, 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: heading }), _jsx("p", { className: "cls_my_settings_layout_subheading text-[var(--hazo-text-muted)]", children: subHeading })] }), _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: profilePhotoLabel }), _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": uploadPhotoButtonLabel, 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": removePhotoButtonLabel, 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: profileInformationLabel }), _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: "Full Name", value: settings.name, type: "text", placeholder: "Enter your full name", onSave: settings.handleNameSave, validation: validateName, disabled: settings.loading, ariaLabel: "Full name input field" })), userFields.show_email_field && (_jsx(EditableField, { label: "Email Address", value: settings.email, type: "email", placeholder: "Enter your email address", onSave: settings.handleEmailSave, validation: validateEmail, disabled: settings.loading, ariaLabel: "Email address input field" }))] })] }), userFields.show_password_field && (_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: passwordLabel }), _jsxs("div", { className: "cls_my_settings_layout_password_fields flex flex-col gap-6", children: [_jsx(FormFieldWrapper, { fieldId: "current-password", label: currentPasswordLabel, input: _jsx(PasswordField, { inputId: "current-password", ariaLabel: currentPasswordLabel, value: ((_a = settings.passwordFields) === null || _a === void 0 ? void 0 : _a.currentPassword) || "", placeholder: "Enter your current password", 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: newPasswordLabel, input: _jsx(PasswordField, { inputId: "new-password", ariaLabel: newPasswordLabel, value: ((_e = settings.passwordFields) === null || _e === void 0 ? void 0 : _e.newPassword) || "", placeholder: "Enter your new password", 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: confirmPasswordLabel, input: _jsx(PasswordField, { inputId: "confirm-password", ariaLabel: confirmPasswordLabel, value: ((_j = settings.passwordFields) === null || _j === void 0 ? void 0 : _j.confirmPassword) || "", placeholder: "Confirm your new password", 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: {
|
|
32
33
|
backgroundColor: resolvedButtonPalette.submitBackground,
|
|
33
34
|
color: resolvedButtonPalette.submitText,
|
|
34
35
|
}, "aria-label": "Save password", children: "Save Password" }) })] })), _jsx(ProfilePictureDialog, { open: settings.profilePictureDialogOpen, onOpenChange: (open) => {
|
|
@@ -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;
|
|
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;AAW3F,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;CACrB,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;CAC1B,CAAC;AAYF,eAAO,MAAM,iBAAiB,GAAI,OAAO,EAAG,kEAKzC,qBAAqB,CAAC,OAAO,CAAC,KAAG,qBAmPnC,CAAC"}
|
|
@@ -4,6 +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";
|
|
6
6
|
import { validateEmail, validatePassword } from "../../shared/utils/validation";
|
|
7
|
+
import { useHazoAuthConfig } from "../../../../contexts/hazo_auth_provider";
|
|
7
8
|
// section: constants
|
|
8
9
|
const PASSWORD_FIELDS = [
|
|
9
10
|
REGISTER_FIELD_IDS.PASSWORD,
|
|
@@ -18,6 +19,7 @@ const buildInitialValues = () => ({
|
|
|
18
19
|
});
|
|
19
20
|
// section: hook
|
|
20
21
|
export const use_register_form = ({ showNameField, passwordRequirements, dataClient, urlOnLogon, }) => {
|
|
22
|
+
const { apiBasePath } = useHazoAuthConfig();
|
|
21
23
|
const initialValues = useMemo(() => buildInitialValues(), []);
|
|
22
24
|
const [values, setValues] = useState(initialValues);
|
|
23
25
|
const [errors, setErrors] = useState({});
|
|
@@ -141,7 +143,7 @@ export const use_register_form = ({ showNameField, passwordRequirements, dataCli
|
|
|
141
143
|
setIsSubmitting(true);
|
|
142
144
|
setErrors({});
|
|
143
145
|
try {
|
|
144
|
-
const response = await fetch(
|
|
146
|
+
const response = await fetch(`${apiBasePath}/register`, {
|
|
145
147
|
method: "POST",
|
|
146
148
|
headers: {
|
|
147
149
|
"Content-Type": "application/json",
|