@thetechfossil/auth2 1.2.2 → 1.2.4
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/dist/index.components.d.ts +14 -1
- package/dist/index.components.js +1288 -642
- package/dist/index.components.js.map +1 -1
- package/dist/index.components.mjs +1190 -547
- package/dist/index.components.mjs.map +1 -1
- package/dist/index.d.ts +51 -7
- package/dist/index.js +1368 -672
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1241 -547
- package/dist/index.mjs.map +1 -1
- package/dist/index.next.d.ts +44 -65
- package/dist/index.next.js +1402 -988
- package/dist/index.next.js.map +1 -1
- package/dist/index.next.mjs +1254 -836
- package/dist/index.next.mjs.map +1 -1
- package/dist/index.next.server.d.ts +57 -8
- package/dist/index.next.server.js +163 -14
- package/dist/index.next.server.js.map +1 -1
- package/dist/index.next.server.mjs +156 -15
- package/dist/index.next.server.mjs.map +1 -1
- package/dist/index.node.d.ts +19 -7
- package/dist/index.node.js +18 -12
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +18 -12
- package/dist/index.node.mjs.map +1 -1
- package/next/index.js +2 -0
- package/next/index.mjs +2 -0
- package/next/package.json +5 -0
- package/next/server/package.json +5 -0
- package/next/server.js +2 -0
- package/next/server.mjs +2 -0
- package/package.json +21 -18
- package/README.NEW.md +0 -365
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import axios from 'axios';
|
|
2
|
-
import { createContext, useState, useCallback, useEffect,
|
|
3
|
+
import React3, { createContext, forwardRef, useContext, useState, useCallback, useEffect, useRef, useMemo } from 'react';
|
|
3
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
+
import PhoneInputWithCountry from 'react-phone-number-input';
|
|
6
|
+
import 'react-phone-number-input/style.css';
|
|
4
7
|
|
|
5
8
|
var __defProp = Object.defineProperty;
|
|
6
9
|
var __export = (target, all) => {
|
|
@@ -11,8 +14,9 @@ var HttpClient = class {
|
|
|
11
14
|
constructor(baseUrl, defaultHeaders = {}) {
|
|
12
15
|
this.csrfToken = null;
|
|
13
16
|
this.frontendBaseUrl = null;
|
|
17
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
14
18
|
this.axiosInstance = axios.create({
|
|
15
|
-
baseURL: baseUrl
|
|
19
|
+
baseURL: this.baseUrl,
|
|
16
20
|
headers: {
|
|
17
21
|
"Content-Type": "application/json",
|
|
18
22
|
...defaultHeaders
|
|
@@ -23,8 +27,16 @@ var HttpClient = class {
|
|
|
23
27
|
// 30 second timeout
|
|
24
28
|
});
|
|
25
29
|
this.axiosInstance.interceptors.request.use(
|
|
26
|
-
(config) => {
|
|
27
|
-
|
|
30
|
+
async (config) => {
|
|
31
|
+
const isMutatingRequest = ["post", "put", "delete", "patch"].includes(config.method?.toLowerCase() || "");
|
|
32
|
+
if (isMutatingRequest && !this.csrfToken && typeof window !== "undefined") {
|
|
33
|
+
try {
|
|
34
|
+
await this.refreshCsrfToken();
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.warn("Failed to fetch CSRF token:", error);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (this.csrfToken && isMutatingRequest) {
|
|
28
40
|
config.headers["x-csrf-token"] = this.csrfToken;
|
|
29
41
|
}
|
|
30
42
|
if (this.frontendBaseUrl) {
|
|
@@ -122,9 +134,6 @@ var AuthService = class {
|
|
|
122
134
|
this.httpClient.setFrontendBaseUrl(frontendBaseUrl);
|
|
123
135
|
}
|
|
124
136
|
}
|
|
125
|
-
if (this.config.csrfEnabled && typeof window !== "undefined") {
|
|
126
|
-
this.refreshCsrfToken();
|
|
127
|
-
}
|
|
128
137
|
}
|
|
129
138
|
loadTokenFromStorage() {
|
|
130
139
|
if (typeof window !== "undefined" && this.config.localStorageKey) {
|
|
@@ -226,7 +235,7 @@ var AuthService = class {
|
|
|
226
235
|
this.saveTokenToStorage(response.token);
|
|
227
236
|
return response;
|
|
228
237
|
}
|
|
229
|
-
if (response.success && response.message === "OTP sent to your email.") {
|
|
238
|
+
if (response.success && (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.")) {
|
|
230
239
|
return response;
|
|
231
240
|
}
|
|
232
241
|
if (response.success && response.message === "OTP verified successfully." && response.token) {
|
|
@@ -297,7 +306,7 @@ var AuthService = class {
|
|
|
297
306
|
if (!this.token) {
|
|
298
307
|
throw new Error("Not authenticated");
|
|
299
308
|
}
|
|
300
|
-
const response = await this.httpClient.post("/api/v1/user/update/
|
|
309
|
+
const response = await this.httpClient.post("/api/v1/user/update/profile", data);
|
|
301
310
|
if (response.success && response.token) {
|
|
302
311
|
this.token = response.token;
|
|
303
312
|
this.httpClient.setAuthToken(response.token);
|
|
@@ -338,7 +347,7 @@ var AuthService = class {
|
|
|
338
347
|
if (!this.token) {
|
|
339
348
|
throw new Error("Not authenticated");
|
|
340
349
|
}
|
|
341
|
-
const response = await this.httpClient.post("/api/v1/user/update/
|
|
350
|
+
const response = await this.httpClient.post("/api/v1/user/update/profile", { avatar });
|
|
342
351
|
if (response.success && response.token) {
|
|
343
352
|
this.token = response.token;
|
|
344
353
|
this.httpClient.setAuthToken(response.token);
|
|
@@ -401,21 +410,21 @@ var AuthService = class {
|
|
|
401
410
|
if (!this.token) {
|
|
402
411
|
throw new Error("Not authenticated");
|
|
403
412
|
}
|
|
404
|
-
const response = await this.httpClient.get("/api/v1/
|
|
413
|
+
const response = await this.httpClient.get("/api/v1/sessions");
|
|
405
414
|
return response;
|
|
406
415
|
}
|
|
407
416
|
async revokeSession(sessionId) {
|
|
408
417
|
if (!this.token) {
|
|
409
418
|
throw new Error("Not authenticated");
|
|
410
419
|
}
|
|
411
|
-
const response = await this.httpClient.delete(`/api/v1/
|
|
420
|
+
const response = await this.httpClient.delete(`/api/v1/sessions/${sessionId}`);
|
|
412
421
|
return response;
|
|
413
422
|
}
|
|
414
423
|
async revokeAllSessions() {
|
|
415
424
|
if (!this.token) {
|
|
416
425
|
throw new Error("Not authenticated");
|
|
417
426
|
}
|
|
418
|
-
const response = await this.httpClient.delete("/api/v1/
|
|
427
|
+
const response = await this.httpClient.delete("/api/v1/sessions/revoke/all");
|
|
419
428
|
this.token = null;
|
|
420
429
|
this.httpClient.removeAuthToken();
|
|
421
430
|
this.removeTokenFromStorage();
|
|
@@ -461,6 +470,57 @@ var AuthService = class {
|
|
|
461
470
|
return response;
|
|
462
471
|
}
|
|
463
472
|
};
|
|
473
|
+
var ThemeContext = createContext({ theme: "light", mounted: false });
|
|
474
|
+
function AuthThemeProvider({ children }) {
|
|
475
|
+
const [theme, setTheme] = useState("light");
|
|
476
|
+
const [mounted, setMounted] = useState(false);
|
|
477
|
+
useEffect(() => {
|
|
478
|
+
const detectTheme = () => {
|
|
479
|
+
const htmlElement = document.documentElement;
|
|
480
|
+
const bodyElement = document.body;
|
|
481
|
+
if (htmlElement.classList.contains("dark") || bodyElement.classList.contains("dark")) {
|
|
482
|
+
return "dark";
|
|
483
|
+
}
|
|
484
|
+
if (htmlElement.classList.contains("light") || bodyElement.classList.contains("light")) {
|
|
485
|
+
return "light";
|
|
486
|
+
}
|
|
487
|
+
const dataTheme = htmlElement.getAttribute("data-theme") || bodyElement.getAttribute("data-theme");
|
|
488
|
+
if (dataTheme === "dark" || dataTheme === "light") {
|
|
489
|
+
return dataTheme;
|
|
490
|
+
}
|
|
491
|
+
if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
492
|
+
return "dark";
|
|
493
|
+
}
|
|
494
|
+
return "light";
|
|
495
|
+
};
|
|
496
|
+
const updateTheme = () => {
|
|
497
|
+
const detectedTheme = detectTheme();
|
|
498
|
+
setTheme(detectedTheme);
|
|
499
|
+
};
|
|
500
|
+
updateTheme();
|
|
501
|
+
setMounted(true);
|
|
502
|
+
const observer = new MutationObserver(updateTheme);
|
|
503
|
+
observer.observe(document.documentElement, {
|
|
504
|
+
attributes: true,
|
|
505
|
+
attributeFilter: ["class", "data-theme"]
|
|
506
|
+
});
|
|
507
|
+
observer.observe(document.body, {
|
|
508
|
+
attributes: true,
|
|
509
|
+
attributeFilter: ["class", "data-theme"]
|
|
510
|
+
});
|
|
511
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
512
|
+
const handleMediaChange = () => updateTheme();
|
|
513
|
+
mediaQuery.addEventListener("change", handleMediaChange);
|
|
514
|
+
return () => {
|
|
515
|
+
observer.disconnect();
|
|
516
|
+
mediaQuery.removeEventListener("change", handleMediaChange);
|
|
517
|
+
};
|
|
518
|
+
}, []);
|
|
519
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: { theme, mounted }, children });
|
|
520
|
+
}
|
|
521
|
+
function useAuthTheme() {
|
|
522
|
+
return useContext(ThemeContext);
|
|
523
|
+
}
|
|
464
524
|
var AuthContext = createContext(void 0);
|
|
465
525
|
var AuthProvider = ({ children, config }) => {
|
|
466
526
|
const authConfig = {
|
|
@@ -724,7 +784,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
724
784
|
revokeAllSessions,
|
|
725
785
|
authService
|
|
726
786
|
};
|
|
727
|
-
return /* @__PURE__ */ jsx(AuthContext.Provider, { value, children });
|
|
787
|
+
return /* @__PURE__ */ jsx(AuthContext.Provider, { value, children: /* @__PURE__ */ jsx(AuthThemeProvider, { children }) });
|
|
728
788
|
};
|
|
729
789
|
var useAuth = () => {
|
|
730
790
|
const context = useContext(AuthContext);
|
|
@@ -863,6 +923,267 @@ var useAuth2 = (config) => {
|
|
|
863
923
|
getUserById
|
|
864
924
|
};
|
|
865
925
|
};
|
|
926
|
+
|
|
927
|
+
// src/react/hooks/useThemeColors.ts
|
|
928
|
+
var lightTheme = {
|
|
929
|
+
bgPrimary: "var(--auth-bg-primary, #ffffff)",
|
|
930
|
+
bgSecondary: "var(--auth-bg-secondary, #f8fafc)",
|
|
931
|
+
bgHover: "var(--auth-bg-hover, #f1f5f9)",
|
|
932
|
+
textPrimary: "var(--auth-text-primary, #0f172a)",
|
|
933
|
+
textSecondary: "var(--auth-text-secondary, #475569)",
|
|
934
|
+
textTertiary: "var(--auth-text-tertiary, #94a3b8)",
|
|
935
|
+
borderPrimary: "var(--auth-border-primary, #e2e8f0)",
|
|
936
|
+
borderSecondary: "var(--auth-border-secondary, #cbd5e1)",
|
|
937
|
+
buttonPrimary: "var(--auth-button-primary, #3b82f6)",
|
|
938
|
+
buttonPrimaryHover: "var(--auth-button-primary-hover, #2563eb)",
|
|
939
|
+
errorBg: "var(--auth-error-bg, #fef2f2)",
|
|
940
|
+
errorText: "var(--auth-error-text, #dc2626)",
|
|
941
|
+
errorBorder: "var(--auth-error-border, #fecaca)",
|
|
942
|
+
successBg: "var(--auth-success-bg, #f0fdf4)",
|
|
943
|
+
successText: "var(--auth-success-text, #16a34a)",
|
|
944
|
+
successBorder: "var(--auth-success-border, #bbf7d0)"
|
|
945
|
+
};
|
|
946
|
+
var darkTheme = {
|
|
947
|
+
bgPrimary: "var(--auth-bg-primary, #1f2937)",
|
|
948
|
+
bgSecondary: "var(--auth-bg-secondary, #111827)",
|
|
949
|
+
bgHover: "var(--auth-bg-hover, #374151)",
|
|
950
|
+
textPrimary: "var(--auth-text-primary, #f9fafb)",
|
|
951
|
+
textSecondary: "var(--auth-text-secondary, #e5e7eb)",
|
|
952
|
+
textTertiary: "var(--auth-text-tertiary, #d1d5db)",
|
|
953
|
+
borderPrimary: "var(--auth-border-primary, #374151)",
|
|
954
|
+
borderSecondary: "var(--auth-border-secondary, #4b5563)",
|
|
955
|
+
buttonPrimary: "var(--auth-button-primary, #3b82f6)",
|
|
956
|
+
buttonPrimaryHover: "var(--auth-button-primary-hover, #2563eb)",
|
|
957
|
+
errorBg: "var(--auth-error-bg, #7f1d1d)",
|
|
958
|
+
errorText: "var(--auth-error-text, #fecaca)",
|
|
959
|
+
errorBorder: "var(--auth-error-border, #991b1b)",
|
|
960
|
+
successBg: "var(--auth-success-bg, #14532d)",
|
|
961
|
+
successText: "var(--auth-success-text, #bbf7d0)",
|
|
962
|
+
successBorder: "var(--auth-success-border, #166534)"
|
|
963
|
+
};
|
|
964
|
+
function useThemeColors() {
|
|
965
|
+
const { theme } = useAuthTheme();
|
|
966
|
+
return theme === "dark" ? darkTheme : lightTheme;
|
|
967
|
+
}
|
|
968
|
+
var CustomPhoneInput = React3.forwardRef((props, ref) => /* @__PURE__ */ jsx(
|
|
969
|
+
"input",
|
|
970
|
+
{
|
|
971
|
+
...props,
|
|
972
|
+
ref,
|
|
973
|
+
className: "PhoneInputInput"
|
|
974
|
+
}
|
|
975
|
+
));
|
|
976
|
+
CustomPhoneInput.displayName = "CustomPhoneInput";
|
|
977
|
+
var PhoneInput = ({
|
|
978
|
+
value,
|
|
979
|
+
onChange,
|
|
980
|
+
disabled = false,
|
|
981
|
+
required = false,
|
|
982
|
+
placeholder = "Enter phone number",
|
|
983
|
+
id = "phone",
|
|
984
|
+
style = {}
|
|
985
|
+
}) => {
|
|
986
|
+
const colors = useThemeColors();
|
|
987
|
+
const [defaultCountry, setDefaultCountry] = useState("US");
|
|
988
|
+
const styleContent = useMemo(() => `
|
|
989
|
+
.PhoneInput {
|
|
990
|
+
display: flex;
|
|
991
|
+
align-items: center;
|
|
992
|
+
gap: 8px;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
.PhoneInputCountry {
|
|
996
|
+
position: relative;
|
|
997
|
+
align-self: stretch;
|
|
998
|
+
display: flex;
|
|
999
|
+
align-items: center;
|
|
1000
|
+
padding: 0 8px;
|
|
1001
|
+
border: 1px solid ${colors.borderSecondary};
|
|
1002
|
+
border-radius: 8px;
|
|
1003
|
+
background-color: ${colors.bgSecondary};
|
|
1004
|
+
transition: all 0.2s ease;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
.PhoneInputCountry:focus-within {
|
|
1008
|
+
border-color: ${colors.buttonPrimary};
|
|
1009
|
+
outline: 2px solid ${colors.buttonPrimary}40;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
.PhoneInputCountryIcon {
|
|
1013
|
+
width: 24px;
|
|
1014
|
+
height: 24px;
|
|
1015
|
+
margin-right: 4px;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
.PhoneInputCountryIcon--border {
|
|
1019
|
+
box-shadow: none;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
.PhoneInputCountrySelect {
|
|
1023
|
+
position: absolute;
|
|
1024
|
+
top: 0;
|
|
1025
|
+
left: 0;
|
|
1026
|
+
height: 100%;
|
|
1027
|
+
width: 100%;
|
|
1028
|
+
z-index: 1;
|
|
1029
|
+
border: 0;
|
|
1030
|
+
opacity: 0;
|
|
1031
|
+
cursor: pointer;
|
|
1032
|
+
color: ${colors.textPrimary};
|
|
1033
|
+
background-color: ${colors.bgSecondary};
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
.PhoneInputCountrySelect:disabled {
|
|
1037
|
+
cursor: not-allowed;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
/* Dropdown menu styling */
|
|
1041
|
+
.PhoneInputCountrySelect option {
|
|
1042
|
+
background-color: ${colors.bgPrimary};
|
|
1043
|
+
color: ${colors.textPrimary};
|
|
1044
|
+
padding: 8px 12px;
|
|
1045
|
+
font-size: 14px;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
.PhoneInputCountrySelect option:hover,
|
|
1049
|
+
.PhoneInputCountrySelect option:focus,
|
|
1050
|
+
.PhoneInputCountrySelect option:checked {
|
|
1051
|
+
background-color: ${colors.buttonPrimary};
|
|
1052
|
+
color: white;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
.PhoneInputCountrySelectArrow {
|
|
1056
|
+
display: block;
|
|
1057
|
+
content: '';
|
|
1058
|
+
width: 0.3em;
|
|
1059
|
+
height: 0.3em;
|
|
1060
|
+
margin-left: 0.35em;
|
|
1061
|
+
border-style: solid;
|
|
1062
|
+
border-color: ${colors.textPrimary};
|
|
1063
|
+
border-top-width: 0;
|
|
1064
|
+
border-bottom-width: 1px;
|
|
1065
|
+
border-left-width: 0;
|
|
1066
|
+
border-right-width: 1px;
|
|
1067
|
+
transform: rotate(45deg);
|
|
1068
|
+
opacity: 0.7;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
.PhoneInputInput {
|
|
1072
|
+
flex: 1;
|
|
1073
|
+
min-width: 0;
|
|
1074
|
+
padding: 12px 16px;
|
|
1075
|
+
border: 1px solid ${colors.borderSecondary};
|
|
1076
|
+
border-radius: 8px;
|
|
1077
|
+
font-size: 16px;
|
|
1078
|
+
background-color: ${colors.bgSecondary};
|
|
1079
|
+
color: ${colors.textPrimary};
|
|
1080
|
+
transition: all 0.2s ease;
|
|
1081
|
+
-webkit-text-fill-color: ${colors.textPrimary};
|
|
1082
|
+
-webkit-box-shadow: 0 0 0 1000px ${colors.bgSecondary} inset;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
.PhoneInputInput:focus {
|
|
1086
|
+
border-color: ${colors.buttonPrimary};
|
|
1087
|
+
outline: 2px solid ${colors.buttonPrimary}40;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
.PhoneInputInput:disabled {
|
|
1091
|
+
cursor: not-allowed;
|
|
1092
|
+
opacity: 0.6;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
.PhoneInputInput::placeholder {
|
|
1096
|
+
color: ${colors.textTertiary};
|
|
1097
|
+
opacity: 0.6;
|
|
1098
|
+
}
|
|
1099
|
+
`, [colors]);
|
|
1100
|
+
useEffect(() => {
|
|
1101
|
+
const detectCountry = async () => {
|
|
1102
|
+
try {
|
|
1103
|
+
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1104
|
+
const timezoneToCountry = {
|
|
1105
|
+
"America/New_York": "US",
|
|
1106
|
+
"America/Chicago": "US",
|
|
1107
|
+
"America/Denver": "US",
|
|
1108
|
+
"America/Los_Angeles": "US",
|
|
1109
|
+
"America/Phoenix": "US",
|
|
1110
|
+
"America/Anchorage": "US",
|
|
1111
|
+
"Pacific/Honolulu": "US",
|
|
1112
|
+
"Europe/London": "GB",
|
|
1113
|
+
"Europe/Paris": "FR",
|
|
1114
|
+
"Europe/Berlin": "DE",
|
|
1115
|
+
"Europe/Rome": "IT",
|
|
1116
|
+
"Europe/Madrid": "ES",
|
|
1117
|
+
"Asia/Dubai": "AE",
|
|
1118
|
+
"Asia/Kolkata": "IN",
|
|
1119
|
+
"Asia/Shanghai": "CN",
|
|
1120
|
+
"Asia/Tokyo": "JP",
|
|
1121
|
+
"Asia/Seoul": "KR",
|
|
1122
|
+
"Asia/Singapore": "SG",
|
|
1123
|
+
"Asia/Hong_Kong": "HK",
|
|
1124
|
+
"Australia/Sydney": "AU",
|
|
1125
|
+
"Pacific/Auckland": "NZ",
|
|
1126
|
+
"America/Toronto": "CA",
|
|
1127
|
+
"America/Vancouver": "CA",
|
|
1128
|
+
"America/Mexico_City": "MX",
|
|
1129
|
+
"America/Sao_Paulo": "BR",
|
|
1130
|
+
"America/Buenos_Aires": "AR",
|
|
1131
|
+
"Africa/Cairo": "EG",
|
|
1132
|
+
"Africa/Johannesburg": "ZA",
|
|
1133
|
+
"Africa/Lagos": "NG",
|
|
1134
|
+
"Africa/Nairobi": "KE"
|
|
1135
|
+
};
|
|
1136
|
+
const detectedCountry = timezoneToCountry[timezone];
|
|
1137
|
+
if (detectedCountry) {
|
|
1138
|
+
setDefaultCountry(detectedCountry);
|
|
1139
|
+
return;
|
|
1140
|
+
}
|
|
1141
|
+
const response = await fetch("https://ipapi.co/json/", {
|
|
1142
|
+
signal: AbortSignal.timeout(3e3)
|
|
1143
|
+
// 3 second timeout
|
|
1144
|
+
});
|
|
1145
|
+
if (response.ok) {
|
|
1146
|
+
const data = await response.json();
|
|
1147
|
+
if (data.country_code) {
|
|
1148
|
+
setDefaultCountry(data.country_code);
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
} catch (error) {
|
|
1152
|
+
console.log("Country detection failed, using default US");
|
|
1153
|
+
}
|
|
1154
|
+
};
|
|
1155
|
+
detectCountry();
|
|
1156
|
+
}, []);
|
|
1157
|
+
const handleChange = useMemo(() => (val) => {
|
|
1158
|
+
onChange(val || "");
|
|
1159
|
+
}, [onChange]);
|
|
1160
|
+
return /* @__PURE__ */ jsxs(
|
|
1161
|
+
"div",
|
|
1162
|
+
{
|
|
1163
|
+
style: {
|
|
1164
|
+
width: "100%",
|
|
1165
|
+
...style
|
|
1166
|
+
},
|
|
1167
|
+
children: [
|
|
1168
|
+
/* @__PURE__ */ jsx("style", { children: styleContent }),
|
|
1169
|
+
/* @__PURE__ */ jsx(
|
|
1170
|
+
PhoneInputWithCountry,
|
|
1171
|
+
{
|
|
1172
|
+
id,
|
|
1173
|
+
international: true,
|
|
1174
|
+
defaultCountry,
|
|
1175
|
+
value: value || "",
|
|
1176
|
+
onChange: handleChange,
|
|
1177
|
+
disabled,
|
|
1178
|
+
placeholder,
|
|
1179
|
+
inputComponent: CustomPhoneInput
|
|
1180
|
+
},
|
|
1181
|
+
id
|
|
1182
|
+
)
|
|
1183
|
+
]
|
|
1184
|
+
}
|
|
1185
|
+
);
|
|
1186
|
+
};
|
|
866
1187
|
var LoginForm = ({
|
|
867
1188
|
onSuccess,
|
|
868
1189
|
onLoginSuccess,
|
|
@@ -872,7 +1193,10 @@ var LoginForm = ({
|
|
|
872
1193
|
oauthProviders = ["google", "github"],
|
|
873
1194
|
showOAuthButtons = true
|
|
874
1195
|
}) => {
|
|
1196
|
+
const colors = useThemeColors();
|
|
875
1197
|
const [email, setEmail] = useState("");
|
|
1198
|
+
const [phoneNumber, setPhoneNumber] = useState("");
|
|
1199
|
+
const [usePhone, setUsePhone] = useState(false);
|
|
876
1200
|
const [password, setPassword] = useState("");
|
|
877
1201
|
const [usePassword, setUsePassword] = useState(false);
|
|
878
1202
|
const [showPassword, setShowPassword] = useState(false);
|
|
@@ -880,7 +1204,7 @@ var LoginForm = ({
|
|
|
880
1204
|
const [error, setError] = useState(null);
|
|
881
1205
|
const [rememberMe, setRememberMe] = useState(false);
|
|
882
1206
|
const { login } = useAuth2({
|
|
883
|
-
baseUrl: config?.baseUrl ||
|
|
1207
|
+
baseUrl: config?.baseUrl || "http://localhost:7000"
|
|
884
1208
|
});
|
|
885
1209
|
const handleSubmit = async (e) => {
|
|
886
1210
|
e.preventDefault();
|
|
@@ -888,20 +1212,28 @@ var LoginForm = ({
|
|
|
888
1212
|
setError(null);
|
|
889
1213
|
try {
|
|
890
1214
|
let response;
|
|
1215
|
+
const loginData = {};
|
|
1216
|
+
if (usePhone && phoneNumber) {
|
|
1217
|
+
loginData.phoneNumber = phoneNumber;
|
|
1218
|
+
} else if (email) {
|
|
1219
|
+
loginData.email = email;
|
|
1220
|
+
}
|
|
891
1221
|
if (usePassword) {
|
|
892
|
-
|
|
1222
|
+
loginData.password = password;
|
|
1223
|
+
response = await login(loginData);
|
|
893
1224
|
} else {
|
|
894
|
-
response = await login(
|
|
1225
|
+
response = await login(loginData);
|
|
895
1226
|
}
|
|
896
1227
|
if (response.success) {
|
|
897
1228
|
onSuccess?.(response);
|
|
898
1229
|
if (onLoginSuccess) {
|
|
899
|
-
|
|
900
|
-
|
|
1230
|
+
const identifier = usePhone ? phoneNumber : email;
|
|
1231
|
+
if (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.") {
|
|
1232
|
+
onLoginSuccess(identifier, true);
|
|
901
1233
|
} else if (response.token) {
|
|
902
|
-
onLoginSuccess(
|
|
1234
|
+
onLoginSuccess(identifier, false);
|
|
903
1235
|
} else {
|
|
904
|
-
onLoginSuccess(
|
|
1236
|
+
onLoginSuccess(identifier, true);
|
|
905
1237
|
}
|
|
906
1238
|
}
|
|
907
1239
|
} else {
|
|
@@ -923,43 +1255,53 @@ var LoginForm = ({
|
|
|
923
1255
|
return /* @__PURE__ */ jsx("div", { style: {
|
|
924
1256
|
maxWidth: "400px",
|
|
925
1257
|
margin: "0 auto",
|
|
926
|
-
padding: "
|
|
1258
|
+
padding: "24px",
|
|
927
1259
|
borderRadius: "12px",
|
|
928
1260
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
929
|
-
backgroundColor:
|
|
930
|
-
border:
|
|
1261
|
+
backgroundColor: colors.bgPrimary,
|
|
1262
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
931
1263
|
}, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, style: {
|
|
932
1264
|
display: "flex",
|
|
933
1265
|
flexDirection: "column"
|
|
934
1266
|
}, children: [
|
|
935
1267
|
/* @__PURE__ */ jsx("h2", { style: {
|
|
936
1268
|
textAlign: "center",
|
|
937
|
-
marginBottom: "
|
|
938
|
-
color:
|
|
1269
|
+
marginBottom: "20px",
|
|
1270
|
+
color: colors.textPrimary,
|
|
939
1271
|
fontSize: "24px",
|
|
940
1272
|
fontWeight: 600
|
|
941
1273
|
}, children: usePassword ? "Login with Password" : "Login with OTP" }),
|
|
942
1274
|
error && /* @__PURE__ */ jsx("div", { style: {
|
|
943
1275
|
padding: "12px 16px",
|
|
944
|
-
marginBottom: "
|
|
945
|
-
backgroundColor:
|
|
946
|
-
color:
|
|
947
|
-
border:
|
|
1276
|
+
marginBottom: "16px",
|
|
1277
|
+
backgroundColor: colors.errorBg,
|
|
1278
|
+
color: colors.errorText,
|
|
1279
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
948
1280
|
borderRadius: "8px",
|
|
949
1281
|
fontSize: "14px",
|
|
950
1282
|
fontWeight: 500
|
|
951
1283
|
}, children: error }),
|
|
952
1284
|
/* @__PURE__ */ jsxs("div", { style: {
|
|
953
|
-
marginBottom: "
|
|
1285
|
+
marginBottom: "16px"
|
|
954
1286
|
}, children: [
|
|
955
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "email", style: {
|
|
1287
|
+
/* @__PURE__ */ jsx("label", { htmlFor: usePhone ? "phone" : "email", style: {
|
|
956
1288
|
display: "block",
|
|
957
1289
|
marginBottom: "8px",
|
|
958
1290
|
fontWeight: 500,
|
|
959
|
-
color:
|
|
1291
|
+
color: colors.textSecondary,
|
|
960
1292
|
fontSize: "14px"
|
|
961
|
-
}, children: "Email:" }),
|
|
962
|
-
/* @__PURE__ */ jsx(
|
|
1293
|
+
}, children: usePhone ? "Phone Number:" : "Email:" }),
|
|
1294
|
+
usePhone ? /* @__PURE__ */ jsx(
|
|
1295
|
+
PhoneInput,
|
|
1296
|
+
{
|
|
1297
|
+
id: "phone",
|
|
1298
|
+
value: phoneNumber,
|
|
1299
|
+
onChange: setPhoneNumber,
|
|
1300
|
+
required: true,
|
|
1301
|
+
disabled: isLoading,
|
|
1302
|
+
placeholder: "1234567890"
|
|
1303
|
+
}
|
|
1304
|
+
) : /* @__PURE__ */ jsx(
|
|
963
1305
|
"input",
|
|
964
1306
|
{
|
|
965
1307
|
id: "email",
|
|
@@ -971,27 +1313,48 @@ var LoginForm = ({
|
|
|
971
1313
|
style: {
|
|
972
1314
|
width: "100%",
|
|
973
1315
|
padding: "12px 16px",
|
|
974
|
-
border:
|
|
1316
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
975
1317
|
borderRadius: "8px",
|
|
976
1318
|
fontSize: "16px",
|
|
977
1319
|
boxSizing: "border-box",
|
|
978
|
-
color:
|
|
1320
|
+
color: colors.textPrimary,
|
|
979
1321
|
transition: "all 0.2s ease",
|
|
980
|
-
backgroundColor:
|
|
1322
|
+
backgroundColor: colors.bgSecondary
|
|
981
1323
|
},
|
|
982
1324
|
placeholder: "Enter your email"
|
|
983
1325
|
}
|
|
1326
|
+
),
|
|
1327
|
+
/* @__PURE__ */ jsx(
|
|
1328
|
+
"button",
|
|
1329
|
+
{
|
|
1330
|
+
type: "button",
|
|
1331
|
+
onClick: () => setUsePhone(!usePhone),
|
|
1332
|
+
disabled: isLoading,
|
|
1333
|
+
style: {
|
|
1334
|
+
marginTop: "8px",
|
|
1335
|
+
background: "none",
|
|
1336
|
+
border: "none",
|
|
1337
|
+
color: colors.buttonPrimary,
|
|
1338
|
+
textDecoration: "none",
|
|
1339
|
+
cursor: "pointer",
|
|
1340
|
+
fontSize: "13px",
|
|
1341
|
+
fontWeight: 500,
|
|
1342
|
+
padding: "0",
|
|
1343
|
+
transition: "color 0.2s ease"
|
|
1344
|
+
},
|
|
1345
|
+
children: usePhone ? "Use email instead" : "Use phone number instead"
|
|
1346
|
+
}
|
|
984
1347
|
)
|
|
985
1348
|
] }),
|
|
986
1349
|
usePassword && /* @__PURE__ */ jsxs("div", { style: {
|
|
987
|
-
marginBottom: "
|
|
1350
|
+
marginBottom: "16px",
|
|
988
1351
|
position: "relative"
|
|
989
1352
|
}, children: [
|
|
990
1353
|
/* @__PURE__ */ jsx("label", { htmlFor: "login-password", style: {
|
|
991
1354
|
display: "block",
|
|
992
1355
|
marginBottom: "8px",
|
|
993
1356
|
fontWeight: 500,
|
|
994
|
-
color:
|
|
1357
|
+
color: colors.textSecondary,
|
|
995
1358
|
fontSize: "14px"
|
|
996
1359
|
}, children: "Password:" }),
|
|
997
1360
|
/* @__PURE__ */ jsx(
|
|
@@ -1006,13 +1369,13 @@ var LoginForm = ({
|
|
|
1006
1369
|
style: {
|
|
1007
1370
|
width: "100%",
|
|
1008
1371
|
padding: "12px 16px",
|
|
1009
|
-
border:
|
|
1372
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1010
1373
|
borderRadius: "8px",
|
|
1011
1374
|
fontSize: "16px",
|
|
1012
1375
|
boxSizing: "border-box",
|
|
1013
|
-
color:
|
|
1376
|
+
color: colors.textPrimary,
|
|
1014
1377
|
transition: "all 0.2s ease",
|
|
1015
|
-
backgroundColor:
|
|
1378
|
+
backgroundColor: colors.bgSecondary
|
|
1016
1379
|
},
|
|
1017
1380
|
placeholder: "Enter your password"
|
|
1018
1381
|
}
|
|
@@ -1030,7 +1393,7 @@ var LoginForm = ({
|
|
|
1030
1393
|
background: "none",
|
|
1031
1394
|
border: "none",
|
|
1032
1395
|
cursor: "pointer",
|
|
1033
|
-
color:
|
|
1396
|
+
color: colors.textTertiary,
|
|
1034
1397
|
fontSize: "14px"
|
|
1035
1398
|
},
|
|
1036
1399
|
children: showPassword ? "Hide" : "Show"
|
|
@@ -1040,8 +1403,8 @@ var LoginForm = ({
|
|
|
1040
1403
|
usePassword && /* @__PURE__ */ jsxs("div", { style: {
|
|
1041
1404
|
display: "flex",
|
|
1042
1405
|
alignItems: "center",
|
|
1043
|
-
marginBottom: "
|
|
1044
|
-
marginTop: "
|
|
1406
|
+
marginBottom: "12px",
|
|
1407
|
+
marginTop: "4px"
|
|
1045
1408
|
}, children: [
|
|
1046
1409
|
/* @__PURE__ */ jsx(
|
|
1047
1410
|
"input",
|
|
@@ -1065,7 +1428,7 @@ var LoginForm = ({
|
|
|
1065
1428
|
htmlFor: "remember-me",
|
|
1066
1429
|
style: {
|
|
1067
1430
|
fontSize: "14px",
|
|
1068
|
-
color:
|
|
1431
|
+
color: colors.textSecondary,
|
|
1069
1432
|
cursor: "pointer",
|
|
1070
1433
|
userSelect: "none"
|
|
1071
1434
|
},
|
|
@@ -1080,7 +1443,7 @@ var LoginForm = ({
|
|
|
1080
1443
|
disabled: isLoading,
|
|
1081
1444
|
style: {
|
|
1082
1445
|
padding: "14px",
|
|
1083
|
-
backgroundColor:
|
|
1446
|
+
backgroundColor: colors.buttonPrimary,
|
|
1084
1447
|
color: "white",
|
|
1085
1448
|
border: "none",
|
|
1086
1449
|
borderRadius: "8px",
|
|
@@ -1088,16 +1451,16 @@ var LoginForm = ({
|
|
|
1088
1451
|
fontWeight: 600,
|
|
1089
1452
|
cursor: "pointer",
|
|
1090
1453
|
transition: "all 0.2s ease",
|
|
1091
|
-
marginTop: "
|
|
1454
|
+
marginTop: "4px"
|
|
1092
1455
|
},
|
|
1093
1456
|
children: isLoading ? usePassword ? "Logging in..." : "Sending OTP..." : usePassword ? "Login" : "Send OTP"
|
|
1094
1457
|
}
|
|
1095
1458
|
),
|
|
1096
1459
|
/* @__PURE__ */ jsx("div", { style: {
|
|
1097
1460
|
textAlign: "center",
|
|
1098
|
-
marginTop: "
|
|
1099
|
-
paddingTop: "
|
|
1100
|
-
borderTop:
|
|
1461
|
+
marginTop: "16px",
|
|
1462
|
+
paddingTop: "16px",
|
|
1463
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1101
1464
|
}, children: /* @__PURE__ */ jsx(
|
|
1102
1465
|
"button",
|
|
1103
1466
|
{
|
|
@@ -1107,7 +1470,7 @@ var LoginForm = ({
|
|
|
1107
1470
|
style: {
|
|
1108
1471
|
background: "none",
|
|
1109
1472
|
border: "none",
|
|
1110
|
-
color:
|
|
1473
|
+
color: colors.buttonPrimary,
|
|
1111
1474
|
textDecoration: "none",
|
|
1112
1475
|
cursor: "pointer",
|
|
1113
1476
|
fontSize: "14px",
|
|
@@ -1119,9 +1482,9 @@ var LoginForm = ({
|
|
|
1119
1482
|
}
|
|
1120
1483
|
) }),
|
|
1121
1484
|
showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxs("div", { style: {
|
|
1122
|
-
marginTop: "
|
|
1123
|
-
paddingTop: "
|
|
1124
|
-
borderTop:
|
|
1485
|
+
marginTop: "16px",
|
|
1486
|
+
paddingTop: "16px",
|
|
1487
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1125
1488
|
}, children: [
|
|
1126
1489
|
/* @__PURE__ */ jsxs("div", { style: {
|
|
1127
1490
|
position: "relative",
|
|
@@ -1133,15 +1496,15 @@ var LoginForm = ({
|
|
|
1133
1496
|
left: 0,
|
|
1134
1497
|
right: 0,
|
|
1135
1498
|
height: "1px",
|
|
1136
|
-
backgroundColor:
|
|
1499
|
+
backgroundColor: colors.borderPrimary
|
|
1137
1500
|
} }),
|
|
1138
1501
|
/* @__PURE__ */ jsx("div", { style: {
|
|
1139
1502
|
position: "relative",
|
|
1140
1503
|
textAlign: "center"
|
|
1141
1504
|
}, children: /* @__PURE__ */ jsx("span", { style: {
|
|
1142
|
-
backgroundColor:
|
|
1505
|
+
backgroundColor: colors.bgPrimary,
|
|
1143
1506
|
padding: "0 12px",
|
|
1144
|
-
color:
|
|
1507
|
+
color: colors.textSecondary,
|
|
1145
1508
|
fontSize: "14px"
|
|
1146
1509
|
}, children: "Or continue with" }) })
|
|
1147
1510
|
] }),
|
|
@@ -1160,10 +1523,10 @@ var LoginForm = ({
|
|
|
1160
1523
|
justifyContent: "center",
|
|
1161
1524
|
gap: "8px",
|
|
1162
1525
|
padding: "10px 16px",
|
|
1163
|
-
backgroundColor:
|
|
1164
|
-
border:
|
|
1526
|
+
backgroundColor: colors.bgPrimary,
|
|
1527
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1165
1528
|
borderRadius: "8px",
|
|
1166
|
-
color:
|
|
1529
|
+
color: colors.textPrimary,
|
|
1167
1530
|
textDecoration: "none",
|
|
1168
1531
|
fontSize: "14px",
|
|
1169
1532
|
fontWeight: 500,
|
|
@@ -1171,12 +1534,12 @@ var LoginForm = ({
|
|
|
1171
1534
|
transition: "all 0.2s ease"
|
|
1172
1535
|
},
|
|
1173
1536
|
onMouseEnter: (e) => {
|
|
1174
|
-
e.currentTarget.style.backgroundColor =
|
|
1175
|
-
e.currentTarget.style.borderColor =
|
|
1537
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
1538
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
1176
1539
|
},
|
|
1177
1540
|
onMouseLeave: (e) => {
|
|
1178
|
-
e.currentTarget.style.backgroundColor =
|
|
1179
|
-
e.currentTarget.style.borderColor =
|
|
1541
|
+
e.currentTarget.style.backgroundColor = colors.bgPrimary;
|
|
1542
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
1180
1543
|
},
|
|
1181
1544
|
children: [
|
|
1182
1545
|
/* @__PURE__ */ jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
|
|
@@ -1251,11 +1614,11 @@ var LoginForm = ({
|
|
|
1251
1614
|
] }),
|
|
1252
1615
|
showRegisterLink && /* @__PURE__ */ jsx("div", { style: {
|
|
1253
1616
|
textAlign: "center",
|
|
1254
|
-
marginTop: "
|
|
1255
|
-
paddingTop: "
|
|
1256
|
-
borderTop:
|
|
1617
|
+
marginTop: "16px",
|
|
1618
|
+
paddingTop: "16px",
|
|
1619
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1257
1620
|
}, children: /* @__PURE__ */ jsxs("p", { style: {
|
|
1258
|
-
color:
|
|
1621
|
+
color: colors.textSecondary,
|
|
1259
1622
|
fontSize: "14px"
|
|
1260
1623
|
}, children: [
|
|
1261
1624
|
"Don't have an account?",
|
|
@@ -1269,7 +1632,7 @@ var LoginForm = ({
|
|
|
1269
1632
|
style: {
|
|
1270
1633
|
background: "none",
|
|
1271
1634
|
border: "none",
|
|
1272
|
-
color:
|
|
1635
|
+
color: colors.buttonPrimary,
|
|
1273
1636
|
textDecoration: "none",
|
|
1274
1637
|
cursor: "pointer",
|
|
1275
1638
|
fontSize: "14px",
|
|
@@ -1289,10 +1652,13 @@ var RegisterForm = ({
|
|
|
1289
1652
|
showLoginLink = true,
|
|
1290
1653
|
authConfig,
|
|
1291
1654
|
oauthProviders = ["google", "github"],
|
|
1292
|
-
showOAuthButtons = true
|
|
1655
|
+
showOAuthButtons = true,
|
|
1656
|
+
invitationToken
|
|
1293
1657
|
}) => {
|
|
1658
|
+
const colors = useThemeColors();
|
|
1294
1659
|
const [name, setName] = useState("");
|
|
1295
1660
|
const [email, setEmail] = useState("");
|
|
1661
|
+
const [phoneNumber, setPhoneNumber] = useState("");
|
|
1296
1662
|
const [password, setPassword] = useState("");
|
|
1297
1663
|
const [confirmPassword, setConfirmPassword] = useState("");
|
|
1298
1664
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -1321,7 +1687,7 @@ var RegisterForm = ({
|
|
|
1321
1687
|
};
|
|
1322
1688
|
getPasswordStrength(password);
|
|
1323
1689
|
const config = authConfig || {
|
|
1324
|
-
baseUrl:
|
|
1690
|
+
baseUrl: "http://localhost:7000"
|
|
1325
1691
|
};
|
|
1326
1692
|
const { register } = useAuth2(config);
|
|
1327
1693
|
const handleSubmit = async (e) => {
|
|
@@ -1339,17 +1705,45 @@ var RegisterForm = ({
|
|
|
1339
1705
|
return;
|
|
1340
1706
|
}
|
|
1341
1707
|
try {
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1708
|
+
if (invitationToken) {
|
|
1709
|
+
const response = await fetch(`${config.baseUrl}/api/v1/auth/signup-with-invitation`, {
|
|
1710
|
+
method: "POST",
|
|
1711
|
+
headers: {
|
|
1712
|
+
"Content-Type": "application/json"
|
|
1713
|
+
},
|
|
1714
|
+
body: JSON.stringify({
|
|
1715
|
+
name,
|
|
1716
|
+
email,
|
|
1717
|
+
password,
|
|
1718
|
+
phoneNumber: phoneNumber || void 0,
|
|
1719
|
+
invitationToken
|
|
1720
|
+
})
|
|
1721
|
+
});
|
|
1722
|
+
const data = await response.json();
|
|
1723
|
+
if (response.ok && data.success) {
|
|
1724
|
+
if (typeof window !== "undefined" && data.token) {
|
|
1725
|
+
localStorage.setItem("auth_token", data.token);
|
|
1726
|
+
}
|
|
1727
|
+
onRegisterSuccess?.();
|
|
1728
|
+
} else {
|
|
1729
|
+
setError(data.error || data.message || "Registration failed");
|
|
1730
|
+
}
|
|
1351
1731
|
} else {
|
|
1352
|
-
|
|
1732
|
+
const registerData = {
|
|
1733
|
+
name,
|
|
1734
|
+
password,
|
|
1735
|
+
frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
|
|
1736
|
+
};
|
|
1737
|
+
if (email)
|
|
1738
|
+
registerData.email = email;
|
|
1739
|
+
if (phoneNumber)
|
|
1740
|
+
registerData.phoneNumber = phoneNumber;
|
|
1741
|
+
const response = await register(registerData);
|
|
1742
|
+
if (response.success) {
|
|
1743
|
+
onRegisterSuccess?.();
|
|
1744
|
+
} else {
|
|
1745
|
+
setError(response.message || "Registration failed");
|
|
1746
|
+
}
|
|
1353
1747
|
}
|
|
1354
1748
|
} catch (err) {
|
|
1355
1749
|
setError(err instanceof Error ? err.message : "An unknown error occurred");
|
|
@@ -1360,40 +1754,40 @@ var RegisterForm = ({
|
|
|
1360
1754
|
return /* @__PURE__ */ jsx("div", { style: {
|
|
1361
1755
|
maxWidth: "400px",
|
|
1362
1756
|
margin: "0 auto",
|
|
1363
|
-
padding: "
|
|
1757
|
+
padding: "24px",
|
|
1364
1758
|
borderRadius: "12px",
|
|
1365
1759
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
1366
|
-
backgroundColor:
|
|
1367
|
-
border:
|
|
1760
|
+
backgroundColor: colors.bgPrimary,
|
|
1761
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
1368
1762
|
}, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, style: {
|
|
1369
1763
|
display: "flex",
|
|
1370
1764
|
flexDirection: "column"
|
|
1371
1765
|
}, children: [
|
|
1372
1766
|
/* @__PURE__ */ jsx("h2", { style: {
|
|
1373
1767
|
textAlign: "center",
|
|
1374
|
-
marginBottom: "
|
|
1375
|
-
color:
|
|
1768
|
+
marginBottom: "20px",
|
|
1769
|
+
color: colors.textPrimary,
|
|
1376
1770
|
fontSize: "24px",
|
|
1377
1771
|
fontWeight: 600
|
|
1378
1772
|
}, children: "Register" }),
|
|
1379
1773
|
error && /* @__PURE__ */ jsx("div", { style: {
|
|
1380
1774
|
padding: "12px 16px",
|
|
1381
|
-
marginBottom: "
|
|
1382
|
-
backgroundColor:
|
|
1383
|
-
color:
|
|
1384
|
-
border:
|
|
1775
|
+
marginBottom: "16px",
|
|
1776
|
+
backgroundColor: colors.errorBg,
|
|
1777
|
+
color: colors.errorText,
|
|
1778
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
1385
1779
|
borderRadius: "8px",
|
|
1386
1780
|
fontSize: "14px",
|
|
1387
1781
|
fontWeight: 500
|
|
1388
1782
|
}, children: error }),
|
|
1389
1783
|
/* @__PURE__ */ jsxs("div", { style: {
|
|
1390
|
-
marginBottom: "
|
|
1784
|
+
marginBottom: "16px"
|
|
1391
1785
|
}, children: [
|
|
1392
1786
|
/* @__PURE__ */ jsx("label", { htmlFor: "name", style: {
|
|
1393
1787
|
display: "block",
|
|
1394
1788
|
marginBottom: "8px",
|
|
1395
1789
|
fontWeight: 500,
|
|
1396
|
-
color:
|
|
1790
|
+
color: colors.textSecondary,
|
|
1397
1791
|
fontSize: "14px"
|
|
1398
1792
|
}, children: "Name:" }),
|
|
1399
1793
|
/* @__PURE__ */ jsx(
|
|
@@ -1408,26 +1802,26 @@ var RegisterForm = ({
|
|
|
1408
1802
|
style: {
|
|
1409
1803
|
width: "100%",
|
|
1410
1804
|
padding: "12px 16px",
|
|
1411
|
-
border:
|
|
1805
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1412
1806
|
borderRadius: "8px",
|
|
1413
1807
|
fontSize: "16px",
|
|
1414
1808
|
boxSizing: "border-box",
|
|
1415
|
-
color:
|
|
1809
|
+
color: colors.textPrimary,
|
|
1416
1810
|
transition: "all 0.2s ease",
|
|
1417
|
-
backgroundColor:
|
|
1811
|
+
backgroundColor: colors.bgSecondary
|
|
1418
1812
|
},
|
|
1419
1813
|
placeholder: "Enter your name"
|
|
1420
1814
|
}
|
|
1421
1815
|
)
|
|
1422
1816
|
] }),
|
|
1423
1817
|
/* @__PURE__ */ jsxs("div", { style: {
|
|
1424
|
-
marginBottom: "
|
|
1818
|
+
marginBottom: "16px"
|
|
1425
1819
|
}, children: [
|
|
1426
1820
|
/* @__PURE__ */ jsx("label", { htmlFor: "register-email", style: {
|
|
1427
1821
|
display: "block",
|
|
1428
1822
|
marginBottom: "8px",
|
|
1429
1823
|
fontWeight: 500,
|
|
1430
|
-
color:
|
|
1824
|
+
color: colors.textSecondary,
|
|
1431
1825
|
fontSize: "14px"
|
|
1432
1826
|
}, children: "Email:" }),
|
|
1433
1827
|
/* @__PURE__ */ jsx(
|
|
@@ -1437,31 +1831,52 @@ var RegisterForm = ({
|
|
|
1437
1831
|
type: "email",
|
|
1438
1832
|
value: email,
|
|
1439
1833
|
onChange: (e) => setEmail(e.target.value),
|
|
1440
|
-
required:
|
|
1834
|
+
required: !phoneNumber,
|
|
1441
1835
|
disabled: isLoading,
|
|
1442
1836
|
style: {
|
|
1443
1837
|
width: "100%",
|
|
1444
1838
|
padding: "12px 16px",
|
|
1445
|
-
border:
|
|
1839
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1446
1840
|
borderRadius: "8px",
|
|
1447
1841
|
fontSize: "16px",
|
|
1448
1842
|
boxSizing: "border-box",
|
|
1449
|
-
color:
|
|
1843
|
+
color: colors.textPrimary,
|
|
1450
1844
|
transition: "all 0.2s ease",
|
|
1451
|
-
backgroundColor:
|
|
1845
|
+
backgroundColor: colors.bgSecondary
|
|
1452
1846
|
},
|
|
1453
1847
|
placeholder: "Enter your email"
|
|
1454
1848
|
}
|
|
1455
1849
|
)
|
|
1456
1850
|
] }),
|
|
1457
1851
|
/* @__PURE__ */ jsxs("div", { style: {
|
|
1458
|
-
marginBottom: "
|
|
1852
|
+
marginBottom: "16px"
|
|
1853
|
+
}, children: [
|
|
1854
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "register-phone", style: {
|
|
1855
|
+
display: "block",
|
|
1856
|
+
marginBottom: "8px",
|
|
1857
|
+
fontWeight: 500,
|
|
1858
|
+
color: colors.textSecondary,
|
|
1859
|
+
fontSize: "14px"
|
|
1860
|
+
}, children: "Phone Number (Optional):" }),
|
|
1861
|
+
/* @__PURE__ */ jsx(
|
|
1862
|
+
PhoneInput,
|
|
1863
|
+
{
|
|
1864
|
+
id: "register-phone",
|
|
1865
|
+
value: phoneNumber,
|
|
1866
|
+
onChange: setPhoneNumber,
|
|
1867
|
+
disabled: isLoading,
|
|
1868
|
+
placeholder: "1234567890"
|
|
1869
|
+
}
|
|
1870
|
+
)
|
|
1871
|
+
] }),
|
|
1872
|
+
/* @__PURE__ */ jsxs("div", { style: {
|
|
1873
|
+
marginBottom: "16px"
|
|
1459
1874
|
}, children: [
|
|
1460
1875
|
/* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
|
|
1461
1876
|
display: "block",
|
|
1462
1877
|
marginBottom: "8px",
|
|
1463
1878
|
fontWeight: 500,
|
|
1464
|
-
color:
|
|
1879
|
+
color: colors.textSecondary,
|
|
1465
1880
|
fontSize: "14px"
|
|
1466
1881
|
}, children: "Password:" }),
|
|
1467
1882
|
/* @__PURE__ */ jsx(
|
|
@@ -1476,13 +1891,13 @@ var RegisterForm = ({
|
|
|
1476
1891
|
style: {
|
|
1477
1892
|
width: "100%",
|
|
1478
1893
|
padding: "12px 16px",
|
|
1479
|
-
border:
|
|
1894
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1480
1895
|
borderRadius: "8px",
|
|
1481
1896
|
fontSize: "16px",
|
|
1482
1897
|
boxSizing: "border-box",
|
|
1483
|
-
color:
|
|
1898
|
+
color: colors.textPrimary,
|
|
1484
1899
|
transition: "all 0.2s ease",
|
|
1485
|
-
backgroundColor:
|
|
1900
|
+
backgroundColor: colors.bgSecondary
|
|
1486
1901
|
},
|
|
1487
1902
|
placeholder: "Enter your password",
|
|
1488
1903
|
minLength: 6
|
|
@@ -1490,13 +1905,13 @@ var RegisterForm = ({
|
|
|
1490
1905
|
)
|
|
1491
1906
|
] }),
|
|
1492
1907
|
/* @__PURE__ */ jsxs("div", { style: {
|
|
1493
|
-
marginBottom: "
|
|
1908
|
+
marginBottom: "16px"
|
|
1494
1909
|
}, children: [
|
|
1495
1910
|
/* @__PURE__ */ jsx("label", { htmlFor: "confirm-password", style: {
|
|
1496
1911
|
display: "block",
|
|
1497
1912
|
marginBottom: "8px",
|
|
1498
1913
|
fontWeight: 500,
|
|
1499
|
-
color:
|
|
1914
|
+
color: colors.textSecondary,
|
|
1500
1915
|
fontSize: "14px"
|
|
1501
1916
|
}, children: "Confirm Password:" }),
|
|
1502
1917
|
/* @__PURE__ */ jsx(
|
|
@@ -1511,13 +1926,13 @@ var RegisterForm = ({
|
|
|
1511
1926
|
style: {
|
|
1512
1927
|
width: "100%",
|
|
1513
1928
|
padding: "12px 16px",
|
|
1514
|
-
border:
|
|
1929
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1515
1930
|
borderRadius: "8px",
|
|
1516
1931
|
fontSize: "16px",
|
|
1517
1932
|
boxSizing: "border-box",
|
|
1518
|
-
color:
|
|
1933
|
+
color: colors.textPrimary,
|
|
1519
1934
|
transition: "all 0.2s ease",
|
|
1520
|
-
backgroundColor:
|
|
1935
|
+
backgroundColor: colors.bgSecondary
|
|
1521
1936
|
},
|
|
1522
1937
|
placeholder: "Confirm your password"
|
|
1523
1938
|
}
|
|
@@ -1530,7 +1945,7 @@ var RegisterForm = ({
|
|
|
1530
1945
|
disabled: isLoading,
|
|
1531
1946
|
style: {
|
|
1532
1947
|
padding: "14px",
|
|
1533
|
-
backgroundColor:
|
|
1948
|
+
backgroundColor: colors.buttonPrimary,
|
|
1534
1949
|
color: "white",
|
|
1535
1950
|
border: "none",
|
|
1536
1951
|
borderRadius: "8px",
|
|
@@ -1538,15 +1953,15 @@ var RegisterForm = ({
|
|
|
1538
1953
|
fontWeight: 600,
|
|
1539
1954
|
cursor: "pointer",
|
|
1540
1955
|
transition: "all 0.2s ease",
|
|
1541
|
-
marginTop: "
|
|
1956
|
+
marginTop: "4px"
|
|
1542
1957
|
},
|
|
1543
1958
|
children: isLoading ? "Registering..." : "Register"
|
|
1544
1959
|
}
|
|
1545
1960
|
),
|
|
1546
1961
|
showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxs("div", { style: {
|
|
1547
|
-
marginTop: "
|
|
1548
|
-
paddingTop: "
|
|
1549
|
-
borderTop:
|
|
1962
|
+
marginTop: "16px",
|
|
1963
|
+
paddingTop: "16px",
|
|
1964
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1550
1965
|
}, children: [
|
|
1551
1966
|
/* @__PURE__ */ jsxs("div", { style: {
|
|
1552
1967
|
position: "relative",
|
|
@@ -1558,15 +1973,15 @@ var RegisterForm = ({
|
|
|
1558
1973
|
left: 0,
|
|
1559
1974
|
right: 0,
|
|
1560
1975
|
height: "1px",
|
|
1561
|
-
backgroundColor:
|
|
1976
|
+
backgroundColor: colors.borderPrimary
|
|
1562
1977
|
} }),
|
|
1563
1978
|
/* @__PURE__ */ jsx("div", { style: {
|
|
1564
1979
|
position: "relative",
|
|
1565
1980
|
textAlign: "center"
|
|
1566
1981
|
}, children: /* @__PURE__ */ jsx("span", { style: {
|
|
1567
|
-
backgroundColor:
|
|
1982
|
+
backgroundColor: colors.bgPrimary,
|
|
1568
1983
|
padding: "0 12px",
|
|
1569
|
-
color:
|
|
1984
|
+
color: colors.textSecondary,
|
|
1570
1985
|
fontSize: "14px"
|
|
1571
1986
|
}, children: "Or continue with" }) })
|
|
1572
1987
|
] }),
|
|
@@ -1585,10 +2000,10 @@ var RegisterForm = ({
|
|
|
1585
2000
|
justifyContent: "center",
|
|
1586
2001
|
gap: "8px",
|
|
1587
2002
|
padding: "10px 16px",
|
|
1588
|
-
backgroundColor:
|
|
1589
|
-
border:
|
|
2003
|
+
backgroundColor: colors.bgPrimary,
|
|
2004
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1590
2005
|
borderRadius: "8px",
|
|
1591
|
-
color:
|
|
2006
|
+
color: colors.textPrimary,
|
|
1592
2007
|
textDecoration: "none",
|
|
1593
2008
|
fontSize: "14px",
|
|
1594
2009
|
fontWeight: 500,
|
|
@@ -1596,12 +2011,12 @@ var RegisterForm = ({
|
|
|
1596
2011
|
transition: "all 0.2s ease"
|
|
1597
2012
|
},
|
|
1598
2013
|
onMouseEnter: (e) => {
|
|
1599
|
-
e.currentTarget.style.backgroundColor =
|
|
1600
|
-
e.currentTarget.style.borderColor =
|
|
2014
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
2015
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
1601
2016
|
},
|
|
1602
2017
|
onMouseLeave: (e) => {
|
|
1603
|
-
e.currentTarget.style.backgroundColor =
|
|
1604
|
-
e.currentTarget.style.borderColor =
|
|
2018
|
+
e.currentTarget.style.backgroundColor = colors.bgPrimary;
|
|
2019
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
1605
2020
|
},
|
|
1606
2021
|
children: [
|
|
1607
2022
|
/* @__PURE__ */ jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
|
|
@@ -1676,11 +2091,11 @@ var RegisterForm = ({
|
|
|
1676
2091
|
] }),
|
|
1677
2092
|
showLoginLink && /* @__PURE__ */ jsx("div", { style: {
|
|
1678
2093
|
textAlign: "center",
|
|
1679
|
-
marginTop: "
|
|
1680
|
-
paddingTop: "
|
|
1681
|
-
borderTop:
|
|
2094
|
+
marginTop: "16px",
|
|
2095
|
+
paddingTop: "16px",
|
|
2096
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1682
2097
|
}, children: /* @__PURE__ */ jsxs("p", { style: {
|
|
1683
|
-
color:
|
|
2098
|
+
color: colors.textSecondary,
|
|
1684
2099
|
fontSize: "14px"
|
|
1685
2100
|
}, children: [
|
|
1686
2101
|
"Already have an account?",
|
|
@@ -1694,7 +2109,7 @@ var RegisterForm = ({
|
|
|
1694
2109
|
style: {
|
|
1695
2110
|
background: "none",
|
|
1696
2111
|
border: "none",
|
|
1697
|
-
color:
|
|
2112
|
+
color: colors.buttonPrimary,
|
|
1698
2113
|
textDecoration: "none",
|
|
1699
2114
|
cursor: "pointer",
|
|
1700
2115
|
fontSize: "14px",
|
|
@@ -1711,15 +2126,17 @@ var RegisterForm = ({
|
|
|
1711
2126
|
var OtpForm = ({
|
|
1712
2127
|
email,
|
|
1713
2128
|
onVerifySuccess,
|
|
1714
|
-
onBackToLogin
|
|
2129
|
+
onBackToLogin,
|
|
2130
|
+
baseUrl
|
|
1715
2131
|
}) => {
|
|
2132
|
+
const colors = useThemeColors();
|
|
1716
2133
|
const [otp, setOtp] = useState("");
|
|
1717
2134
|
const [isLoading, setIsLoading] = useState(false);
|
|
1718
2135
|
const [error, setError] = useState(null);
|
|
1719
2136
|
const [resendCooldown, setResendCooldown] = useState(0);
|
|
1720
2137
|
const [resendLoading, setResendLoading] = useState(false);
|
|
1721
2138
|
const { verify, login } = useAuth2({
|
|
1722
|
-
baseUrl:
|
|
2139
|
+
baseUrl: baseUrl || process.env.NEXT_PUBLIC_AUTH_API_URL || "http://localhost:7000"
|
|
1723
2140
|
});
|
|
1724
2141
|
const handleSubmit = async (e) => {
|
|
1725
2142
|
e.preventDefault();
|
|
@@ -1782,8 +2199,8 @@ var OtpForm = ({
|
|
|
1782
2199
|
padding: "30px",
|
|
1783
2200
|
borderRadius: "12px",
|
|
1784
2201
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
1785
|
-
backgroundColor:
|
|
1786
|
-
border:
|
|
2202
|
+
backgroundColor: colors.bgPrimary,
|
|
2203
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
1787
2204
|
}, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, style: {
|
|
1788
2205
|
display: "flex",
|
|
1789
2206
|
flexDirection: "column"
|
|
@@ -1791,25 +2208,25 @@ var OtpForm = ({
|
|
|
1791
2208
|
/* @__PURE__ */ jsx("h2", { style: {
|
|
1792
2209
|
textAlign: "center",
|
|
1793
2210
|
marginBottom: "24px",
|
|
1794
|
-
color:
|
|
2211
|
+
color: colors.textPrimary,
|
|
1795
2212
|
fontSize: "24px",
|
|
1796
2213
|
fontWeight: 600
|
|
1797
2214
|
}, children: "Verify OTP" }),
|
|
1798
2215
|
/* @__PURE__ */ jsxs("p", { style: {
|
|
1799
2216
|
textAlign: "center",
|
|
1800
2217
|
marginBottom: "24px",
|
|
1801
|
-
color:
|
|
2218
|
+
color: colors.textSecondary,
|
|
1802
2219
|
fontSize: "14px"
|
|
1803
2220
|
}, children: [
|
|
1804
2221
|
"Enter the 6-digit code sent to ",
|
|
1805
|
-
/* @__PURE__ */ jsx("strong", { style: { color:
|
|
2222
|
+
/* @__PURE__ */ jsx("strong", { style: { color: colors.textPrimary }, children: email })
|
|
1806
2223
|
] }),
|
|
1807
2224
|
error && /* @__PURE__ */ jsx("div", { style: {
|
|
1808
2225
|
padding: "12px 16px",
|
|
1809
2226
|
marginBottom: "20px",
|
|
1810
|
-
backgroundColor:
|
|
1811
|
-
color:
|
|
1812
|
-
border:
|
|
2227
|
+
backgroundColor: colors.errorBg,
|
|
2228
|
+
color: colors.errorText,
|
|
2229
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
1813
2230
|
borderRadius: "8px",
|
|
1814
2231
|
fontSize: "14px",
|
|
1815
2232
|
fontWeight: 500
|
|
@@ -1821,7 +2238,7 @@ var OtpForm = ({
|
|
|
1821
2238
|
display: "block",
|
|
1822
2239
|
marginBottom: "8px",
|
|
1823
2240
|
fontWeight: 500,
|
|
1824
|
-
color:
|
|
2241
|
+
color: colors.textSecondary,
|
|
1825
2242
|
fontSize: "14px"
|
|
1826
2243
|
}, children: "OTP Code:" }),
|
|
1827
2244
|
/* @__PURE__ */ jsx(
|
|
@@ -1836,13 +2253,13 @@ var OtpForm = ({
|
|
|
1836
2253
|
style: {
|
|
1837
2254
|
width: "100%",
|
|
1838
2255
|
padding: "12px 16px",
|
|
1839
|
-
border:
|
|
2256
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1840
2257
|
borderRadius: "8px",
|
|
1841
2258
|
fontSize: "20px",
|
|
1842
2259
|
boxSizing: "border-box",
|
|
1843
|
-
color:
|
|
2260
|
+
color: colors.textPrimary,
|
|
1844
2261
|
transition: "all 0.2s ease",
|
|
1845
|
-
backgroundColor:
|
|
2262
|
+
backgroundColor: colors.bgSecondary,
|
|
1846
2263
|
textAlign: "center",
|
|
1847
2264
|
letterSpacing: "5px"
|
|
1848
2265
|
},
|
|
@@ -1859,7 +2276,7 @@ var OtpForm = ({
|
|
|
1859
2276
|
disabled: isLoading || otp.length !== 6,
|
|
1860
2277
|
style: {
|
|
1861
2278
|
padding: "14px",
|
|
1862
|
-
backgroundColor:
|
|
2279
|
+
backgroundColor: colors.buttonPrimary,
|
|
1863
2280
|
color: "white",
|
|
1864
2281
|
border: "none",
|
|
1865
2282
|
borderRadius: "8px",
|
|
@@ -1876,7 +2293,7 @@ var OtpForm = ({
|
|
|
1876
2293
|
textAlign: "center",
|
|
1877
2294
|
marginTop: "20px",
|
|
1878
2295
|
paddingTop: "20px",
|
|
1879
|
-
borderTop:
|
|
2296
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1880
2297
|
}, children: [
|
|
1881
2298
|
/* @__PURE__ */ jsx(
|
|
1882
2299
|
"button",
|
|
@@ -1887,7 +2304,7 @@ var OtpForm = ({
|
|
|
1887
2304
|
style: {
|
|
1888
2305
|
background: "none",
|
|
1889
2306
|
border: "none",
|
|
1890
|
-
color: resendCooldown > 0 ?
|
|
2307
|
+
color: resendCooldown > 0 ? colors.textTertiary : colors.buttonPrimary,
|
|
1891
2308
|
textDecoration: "none",
|
|
1892
2309
|
cursor: resendCooldown > 0 ? "not-allowed" : "pointer",
|
|
1893
2310
|
fontSize: "14px",
|
|
@@ -1910,7 +2327,7 @@ var OtpForm = ({
|
|
|
1910
2327
|
style: {
|
|
1911
2328
|
background: "none",
|
|
1912
2329
|
border: "none",
|
|
1913
|
-
color:
|
|
2330
|
+
color: colors.buttonPrimary,
|
|
1914
2331
|
textDecoration: "none",
|
|
1915
2332
|
cursor: "pointer",
|
|
1916
2333
|
fontSize: "14px",
|
|
@@ -2177,12 +2594,25 @@ var EmailVerificationPage = ({
|
|
|
2177
2594
|
] })
|
|
2178
2595
|
] }) });
|
|
2179
2596
|
};
|
|
2597
|
+
var ThemeWrapper = forwardRef(
|
|
2598
|
+
({ children, className = "", style }, ref) => {
|
|
2599
|
+
const { theme, mounted } = useAuthTheme();
|
|
2600
|
+
if (!mounted) {
|
|
2601
|
+
return /* @__PURE__ */ jsx("div", { ref, className, style, children });
|
|
2602
|
+
}
|
|
2603
|
+
return /* @__PURE__ */ jsx("div", { ref, className: `${theme} ${className}`, style, children });
|
|
2604
|
+
}
|
|
2605
|
+
);
|
|
2606
|
+
ThemeWrapper.displayName = "ThemeWrapper";
|
|
2180
2607
|
var SignIn = ({ redirectUrl, appearance }) => {
|
|
2181
2608
|
const { signIn, isSignedIn, loading: authLoading } = useAuth();
|
|
2609
|
+
const colors = useThemeColors();
|
|
2182
2610
|
const [email, setEmail] = useState("");
|
|
2611
|
+
const [phoneNumber, setPhoneNumber] = useState("");
|
|
2183
2612
|
const [password, setPassword] = useState("");
|
|
2184
2613
|
const [otp, setOtp] = useState("");
|
|
2185
2614
|
const [usePassword, setUsePassword] = useState(false);
|
|
2615
|
+
const [usePhone, setUsePhone] = useState(false);
|
|
2186
2616
|
const [showPassword, setShowPassword] = useState(false);
|
|
2187
2617
|
const [isLoading, setIsLoading] = useState(false);
|
|
2188
2618
|
const [error, setError] = useState(null);
|
|
@@ -2201,25 +2631,26 @@ var SignIn = ({ redirectUrl, appearance }) => {
|
|
|
2201
2631
|
setError(null);
|
|
2202
2632
|
setSuccess(null);
|
|
2203
2633
|
try {
|
|
2634
|
+
const loginData = usePhone ? { phoneNumber } : { email };
|
|
2204
2635
|
if (needsOtp) {
|
|
2205
|
-
const response = await signIn({
|
|
2636
|
+
const response = await signIn({ ...loginData, otp });
|
|
2206
2637
|
if (response.success) {
|
|
2207
2638
|
setSuccess("Login successful!");
|
|
2208
2639
|
} else {
|
|
2209
2640
|
setError(response.message || "OTP verification failed");
|
|
2210
2641
|
}
|
|
2211
2642
|
} else if (usePassword) {
|
|
2212
|
-
const response = await signIn({
|
|
2643
|
+
const response = await signIn({ ...loginData, password });
|
|
2213
2644
|
if (response.success) {
|
|
2214
2645
|
setSuccess("Login successful!");
|
|
2215
2646
|
} else {
|
|
2216
2647
|
setError(response.message || "Login failed");
|
|
2217
2648
|
}
|
|
2218
2649
|
} else {
|
|
2219
|
-
const response = await signIn(
|
|
2220
|
-
if (response.success && response.message === "OTP sent to your email.") {
|
|
2650
|
+
const response = await signIn(loginData);
|
|
2651
|
+
if (response.success && (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.")) {
|
|
2221
2652
|
setNeedsOtp(true);
|
|
2222
|
-
setSuccess("OTP sent to your email. Please check your inbox.");
|
|
2653
|
+
setSuccess(usePhone ? "OTP sent to your phone. Please check your messages." : "OTP sent to your email. Please check your inbox.");
|
|
2223
2654
|
} else {
|
|
2224
2655
|
setError(response.message || "Failed to send OTP");
|
|
2225
2656
|
}
|
|
@@ -2237,222 +2668,350 @@ var SignIn = ({ redirectUrl, appearance }) => {
|
|
|
2237
2668
|
setSuccess(null);
|
|
2238
2669
|
setOtp("");
|
|
2239
2670
|
};
|
|
2671
|
+
const toggleLoginMethod = () => {
|
|
2672
|
+
setUsePhone(!usePhone);
|
|
2673
|
+
setNeedsOtp(false);
|
|
2674
|
+
setError(null);
|
|
2675
|
+
setSuccess(null);
|
|
2676
|
+
setOtp("");
|
|
2677
|
+
setEmail("");
|
|
2678
|
+
setPhoneNumber("");
|
|
2679
|
+
};
|
|
2240
2680
|
if (authLoading) {
|
|
2241
2681
|
return /* @__PURE__ */ jsx("div", { style: { textAlign: "center", padding: "40px" }, children: /* @__PURE__ */ jsx("div", { children: "Loading..." }) });
|
|
2242
2682
|
}
|
|
2243
|
-
return /* @__PURE__ */ jsx(
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
padding: "12px 16px",
|
|
2263
|
-
marginBottom: "20px",
|
|
2264
|
-
backgroundColor: "#fee",
|
|
2265
|
-
color: "#c33",
|
|
2266
|
-
border: "1px solid #fcc",
|
|
2267
|
-
borderRadius: "8px",
|
|
2268
|
-
fontSize: "14px"
|
|
2269
|
-
}, children: error }),
|
|
2270
|
-
success && /* @__PURE__ */ jsx("div", { style: {
|
|
2271
|
-
padding: "12px 16px",
|
|
2272
|
-
marginBottom: "20px",
|
|
2273
|
-
backgroundColor: "#efe",
|
|
2274
|
-
color: "#3c3",
|
|
2275
|
-
border: "1px solid #cfc",
|
|
2276
|
-
borderRadius: "8px",
|
|
2277
|
-
fontSize: "14px"
|
|
2278
|
-
}, children: success }),
|
|
2279
|
-
!needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2280
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "email", style: {
|
|
2281
|
-
display: "block",
|
|
2282
|
-
marginBottom: "8px",
|
|
2283
|
-
fontWeight: 500,
|
|
2284
|
-
color: "#374151",
|
|
2285
|
-
fontSize: "14px"
|
|
2286
|
-
}, children: "Email" }),
|
|
2287
|
-
/* @__PURE__ */ jsx(
|
|
2288
|
-
"input",
|
|
2289
|
-
{
|
|
2290
|
-
id: "email",
|
|
2291
|
-
type: "email",
|
|
2292
|
-
value: email,
|
|
2293
|
-
onChange: (e) => setEmail(e.target.value),
|
|
2294
|
-
required: true,
|
|
2295
|
-
disabled: isLoading,
|
|
2296
|
-
style: {
|
|
2297
|
-
width: "100%",
|
|
2298
|
-
padding: "12px 16px",
|
|
2299
|
-
border: "1px solid #ddd",
|
|
2300
|
-
borderRadius: "8px",
|
|
2301
|
-
fontSize: "16px",
|
|
2302
|
-
boxSizing: "border-box",
|
|
2303
|
-
...appearance?.elements?.formFieldInput
|
|
2304
|
-
},
|
|
2305
|
-
placeholder: "Enter your email"
|
|
2306
|
-
}
|
|
2307
|
-
)
|
|
2308
|
-
] }),
|
|
2309
|
-
usePassword && !needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
|
|
2310
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
|
|
2311
|
-
display: "block",
|
|
2312
|
-
marginBottom: "8px",
|
|
2313
|
-
fontWeight: 500,
|
|
2314
|
-
color: "#374151",
|
|
2315
|
-
fontSize: "14px"
|
|
2316
|
-
}, children: "Password" }),
|
|
2317
|
-
/* @__PURE__ */ jsx(
|
|
2318
|
-
"input",
|
|
2319
|
-
{
|
|
2320
|
-
id: "password",
|
|
2321
|
-
type: showPassword ? "text" : "password",
|
|
2322
|
-
value: password,
|
|
2323
|
-
onChange: (e) => setPassword(e.target.value),
|
|
2324
|
-
required: true,
|
|
2325
|
-
disabled: isLoading,
|
|
2326
|
-
style: {
|
|
2327
|
-
width: "100%",
|
|
2328
|
-
padding: "12px 16px",
|
|
2329
|
-
border: "1px solid #ddd",
|
|
2330
|
-
borderRadius: "8px",
|
|
2331
|
-
fontSize: "16px",
|
|
2332
|
-
boxSizing: "border-box",
|
|
2333
|
-
...appearance?.elements?.formFieldInput
|
|
2334
|
-
},
|
|
2335
|
-
placeholder: "Enter your password"
|
|
2336
|
-
}
|
|
2337
|
-
),
|
|
2338
|
-
/* @__PURE__ */ jsx(
|
|
2339
|
-
"button",
|
|
2340
|
-
{
|
|
2341
|
-
type: "button",
|
|
2342
|
-
onClick: () => setShowPassword(!showPassword),
|
|
2343
|
-
style: {
|
|
2344
|
-
position: "absolute",
|
|
2345
|
-
right: "12px",
|
|
2346
|
-
top: "38px",
|
|
2347
|
-
background: "none",
|
|
2348
|
-
border: "none",
|
|
2349
|
-
cursor: "pointer",
|
|
2350
|
-
color: "#666",
|
|
2351
|
-
fontSize: "14px"
|
|
2352
|
-
},
|
|
2353
|
-
children: showPassword ? "Hide" : "Show"
|
|
2354
|
-
}
|
|
2355
|
-
)
|
|
2356
|
-
] }),
|
|
2357
|
-
needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2358
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "otp", style: {
|
|
2359
|
-
display: "block",
|
|
2360
|
-
marginBottom: "8px",
|
|
2361
|
-
fontWeight: 500,
|
|
2362
|
-
color: "#374151",
|
|
2363
|
-
fontSize: "14px"
|
|
2364
|
-
}, children: "One-Time Password" }),
|
|
2365
|
-
/* @__PURE__ */ jsx(
|
|
2366
|
-
"input",
|
|
2367
|
-
{
|
|
2368
|
-
id: "otp",
|
|
2369
|
-
type: "text",
|
|
2370
|
-
value: otp,
|
|
2371
|
-
onChange: (e) => setOtp(e.target.value),
|
|
2372
|
-
required: true,
|
|
2373
|
-
disabled: isLoading,
|
|
2374
|
-
maxLength: 6,
|
|
2375
|
-
style: {
|
|
2376
|
-
width: "100%",
|
|
2377
|
-
padding: "12px 16px",
|
|
2378
|
-
border: "1px solid #ddd",
|
|
2379
|
-
borderRadius: "8px",
|
|
2380
|
-
fontSize: "16px",
|
|
2381
|
-
boxSizing: "border-box",
|
|
2382
|
-
letterSpacing: "0.5em",
|
|
2383
|
-
textAlign: "center",
|
|
2384
|
-
...appearance?.elements?.formFieldInput
|
|
2385
|
-
},
|
|
2386
|
-
placeholder: "000000"
|
|
2387
|
-
}
|
|
2388
|
-
)
|
|
2389
|
-
] }),
|
|
2390
|
-
/* @__PURE__ */ jsx(
|
|
2391
|
-
"button",
|
|
2392
|
-
{
|
|
2393
|
-
type: "submit",
|
|
2394
|
-
disabled: isLoading,
|
|
2395
|
-
style: {
|
|
2396
|
-
width: "100%",
|
|
2397
|
-
padding: "14px",
|
|
2398
|
-
backgroundColor: "#007bff",
|
|
2399
|
-
color: "white",
|
|
2400
|
-
border: "none",
|
|
2401
|
-
borderRadius: "8px",
|
|
2402
|
-
fontSize: "16px",
|
|
2683
|
+
return /* @__PURE__ */ jsx(
|
|
2684
|
+
ThemeWrapper,
|
|
2685
|
+
{
|
|
2686
|
+
style: {
|
|
2687
|
+
maxWidth: "400px",
|
|
2688
|
+
margin: "0 auto",
|
|
2689
|
+
padding: "30px",
|
|
2690
|
+
borderRadius: "12px",
|
|
2691
|
+
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
2692
|
+
backgroundColor: colors.bgPrimary,
|
|
2693
|
+
border: `1px solid ${colors.borderPrimary}`,
|
|
2694
|
+
...appearance?.elements?.card
|
|
2695
|
+
},
|
|
2696
|
+
children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
|
|
2697
|
+
/* @__PURE__ */ jsx("h2", { style: {
|
|
2698
|
+
textAlign: "center",
|
|
2699
|
+
marginBottom: "24px",
|
|
2700
|
+
color: colors.textPrimary,
|
|
2701
|
+
fontSize: "24px",
|
|
2403
2702
|
fontWeight: 600,
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
fontSize: "14px"
|
|
2423
|
-
|
|
2424
|
-
},
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2703
|
+
...appearance?.elements?.headerTitle
|
|
2704
|
+
}, children: needsOtp ? "Enter OTP" : usePassword ? "Sign in with password" : "Sign in" }),
|
|
2705
|
+
error && /* @__PURE__ */ jsx("div", { style: {
|
|
2706
|
+
padding: "12px 16px",
|
|
2707
|
+
marginBottom: "20px",
|
|
2708
|
+
backgroundColor: colors.errorBg,
|
|
2709
|
+
color: colors.errorText,
|
|
2710
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
2711
|
+
borderRadius: "8px",
|
|
2712
|
+
fontSize: "14px"
|
|
2713
|
+
}, children: error }),
|
|
2714
|
+
success && /* @__PURE__ */ jsx("div", { style: {
|
|
2715
|
+
padding: "12px 16px",
|
|
2716
|
+
marginBottom: "20px",
|
|
2717
|
+
backgroundColor: colors.successBg,
|
|
2718
|
+
color: colors.successText,
|
|
2719
|
+
border: `1px solid ${colors.successBorder}`,
|
|
2720
|
+
borderRadius: "8px",
|
|
2721
|
+
fontSize: "14px"
|
|
2722
|
+
}, children: success }),
|
|
2723
|
+
!needsOtp && !usePhone && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2724
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "email", style: {
|
|
2725
|
+
display: "block",
|
|
2726
|
+
marginBottom: "8px",
|
|
2727
|
+
fontWeight: 500,
|
|
2728
|
+
color: colors.textSecondary,
|
|
2729
|
+
fontSize: "14px"
|
|
2730
|
+
}, children: "Email" }),
|
|
2731
|
+
/* @__PURE__ */ jsx(
|
|
2732
|
+
"input",
|
|
2733
|
+
{
|
|
2734
|
+
id: "email",
|
|
2735
|
+
type: "email",
|
|
2736
|
+
value: email,
|
|
2737
|
+
onChange: (e) => setEmail(e.target.value),
|
|
2738
|
+
onFocus: (e) => {
|
|
2739
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
2740
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
2741
|
+
},
|
|
2742
|
+
onBlur: (e) => {
|
|
2743
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
2744
|
+
e.currentTarget.style.outline = "none";
|
|
2745
|
+
},
|
|
2746
|
+
required: true,
|
|
2747
|
+
disabled: isLoading,
|
|
2748
|
+
style: {
|
|
2749
|
+
width: "100%",
|
|
2750
|
+
padding: "12px 16px",
|
|
2751
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2752
|
+
borderRadius: "8px",
|
|
2753
|
+
fontSize: "16px",
|
|
2754
|
+
boxSizing: "border-box",
|
|
2755
|
+
backgroundColor: colors.bgSecondary,
|
|
2756
|
+
color: colors.textPrimary,
|
|
2757
|
+
transition: "all 0.2s ease",
|
|
2758
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
2759
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2760
|
+
...appearance?.elements?.formFieldInput
|
|
2761
|
+
},
|
|
2762
|
+
placeholder: "Enter your email"
|
|
2763
|
+
}
|
|
2764
|
+
)
|
|
2765
|
+
] }),
|
|
2766
|
+
!needsOtp && usePhone && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2767
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "phoneNumber", style: {
|
|
2768
|
+
display: "block",
|
|
2769
|
+
marginBottom: "8px",
|
|
2770
|
+
fontWeight: 500,
|
|
2771
|
+
color: colors.textSecondary,
|
|
2772
|
+
fontSize: "14px"
|
|
2773
|
+
}, children: "Phone Number" }),
|
|
2774
|
+
/* @__PURE__ */ jsx(
|
|
2775
|
+
"input",
|
|
2776
|
+
{
|
|
2777
|
+
id: "phoneNumber",
|
|
2778
|
+
type: "tel",
|
|
2779
|
+
value: phoneNumber,
|
|
2780
|
+
onChange: (e) => setPhoneNumber(e.target.value),
|
|
2781
|
+
onFocus: (e) => {
|
|
2782
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
2783
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
2784
|
+
},
|
|
2785
|
+
onBlur: (e) => {
|
|
2786
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
2787
|
+
e.currentTarget.style.outline = "none";
|
|
2788
|
+
},
|
|
2789
|
+
required: true,
|
|
2790
|
+
disabled: isLoading,
|
|
2791
|
+
style: {
|
|
2792
|
+
width: "100%",
|
|
2793
|
+
padding: "12px 16px",
|
|
2794
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2795
|
+
borderRadius: "8px",
|
|
2796
|
+
fontSize: "16px",
|
|
2797
|
+
boxSizing: "border-box",
|
|
2798
|
+
backgroundColor: colors.bgSecondary,
|
|
2799
|
+
color: colors.textPrimary,
|
|
2800
|
+
transition: "all 0.2s ease",
|
|
2801
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
2802
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2803
|
+
...appearance?.elements?.formFieldInput
|
|
2804
|
+
},
|
|
2805
|
+
placeholder: "Enter your phone number"
|
|
2806
|
+
}
|
|
2807
|
+
)
|
|
2808
|
+
] }),
|
|
2809
|
+
usePassword && !needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
|
|
2810
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
|
|
2811
|
+
display: "block",
|
|
2812
|
+
marginBottom: "8px",
|
|
2813
|
+
fontWeight: 500,
|
|
2814
|
+
color: colors.textSecondary,
|
|
2815
|
+
fontSize: "14px"
|
|
2816
|
+
}, children: "Password" }),
|
|
2817
|
+
/* @__PURE__ */ jsx(
|
|
2818
|
+
"input",
|
|
2819
|
+
{
|
|
2820
|
+
id: "password",
|
|
2821
|
+
type: showPassword ? "text" : "password",
|
|
2822
|
+
value: password,
|
|
2823
|
+
onChange: (e) => setPassword(e.target.value),
|
|
2824
|
+
onFocus: (e) => {
|
|
2825
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
2826
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
2827
|
+
},
|
|
2828
|
+
onBlur: (e) => {
|
|
2829
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
2830
|
+
e.currentTarget.style.outline = "none";
|
|
2831
|
+
},
|
|
2832
|
+
required: true,
|
|
2833
|
+
disabled: isLoading,
|
|
2834
|
+
style: {
|
|
2835
|
+
width: "100%",
|
|
2836
|
+
padding: "12px 16px",
|
|
2837
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2838
|
+
borderRadius: "8px",
|
|
2839
|
+
fontSize: "16px",
|
|
2840
|
+
boxSizing: "border-box",
|
|
2841
|
+
backgroundColor: colors.bgSecondary,
|
|
2842
|
+
color: colors.textPrimary,
|
|
2843
|
+
transition: "all 0.2s ease",
|
|
2844
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
2845
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2846
|
+
...appearance?.elements?.formFieldInput
|
|
2847
|
+
},
|
|
2848
|
+
placeholder: "Enter your password"
|
|
2849
|
+
}
|
|
2850
|
+
),
|
|
2851
|
+
/* @__PURE__ */ jsx(
|
|
2852
|
+
"button",
|
|
2853
|
+
{
|
|
2854
|
+
type: "button",
|
|
2855
|
+
onClick: () => setShowPassword(!showPassword),
|
|
2856
|
+
style: {
|
|
2857
|
+
position: "absolute",
|
|
2858
|
+
right: "12px",
|
|
2859
|
+
top: "38px",
|
|
2860
|
+
background: "none",
|
|
2861
|
+
border: "none",
|
|
2862
|
+
cursor: "pointer",
|
|
2863
|
+
color: colors.textTertiary,
|
|
2864
|
+
fontSize: "14px"
|
|
2865
|
+
},
|
|
2866
|
+
children: showPassword ? "Hide" : "Show"
|
|
2867
|
+
}
|
|
2868
|
+
)
|
|
2869
|
+
] }),
|
|
2870
|
+
needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2871
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "otp", style: {
|
|
2872
|
+
display: "block",
|
|
2873
|
+
marginBottom: "8px",
|
|
2874
|
+
fontWeight: 500,
|
|
2875
|
+
color: colors.textSecondary,
|
|
2876
|
+
fontSize: "14px"
|
|
2877
|
+
}, children: "One-Time Password" }),
|
|
2878
|
+
/* @__PURE__ */ jsx(
|
|
2879
|
+
"input",
|
|
2880
|
+
{
|
|
2881
|
+
id: "otp",
|
|
2882
|
+
type: "text",
|
|
2883
|
+
value: otp,
|
|
2884
|
+
onChange: (e) => setOtp(e.target.value),
|
|
2885
|
+
onFocus: (e) => {
|
|
2886
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
2887
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
2888
|
+
},
|
|
2889
|
+
onBlur: (e) => {
|
|
2890
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
2891
|
+
e.currentTarget.style.outline = "none";
|
|
2892
|
+
},
|
|
2893
|
+
required: true,
|
|
2894
|
+
disabled: isLoading,
|
|
2895
|
+
maxLength: 6,
|
|
2896
|
+
style: {
|
|
2897
|
+
width: "100%",
|
|
2898
|
+
padding: "12px 16px",
|
|
2899
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2900
|
+
borderRadius: "8px",
|
|
2901
|
+
fontSize: "16px",
|
|
2902
|
+
boxSizing: "border-box",
|
|
2903
|
+
letterSpacing: "0.5em",
|
|
2904
|
+
textAlign: "center",
|
|
2905
|
+
backgroundColor: colors.bgSecondary,
|
|
2906
|
+
color: colors.textPrimary,
|
|
2907
|
+
transition: "all 0.2s ease",
|
|
2908
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
2909
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2910
|
+
...appearance?.elements?.formFieldInput
|
|
2911
|
+
},
|
|
2912
|
+
placeholder: "000000"
|
|
2913
|
+
}
|
|
2914
|
+
)
|
|
2915
|
+
] }),
|
|
2916
|
+
/* @__PURE__ */ jsx(
|
|
2917
|
+
"button",
|
|
2918
|
+
{
|
|
2919
|
+
type: "submit",
|
|
2920
|
+
disabled: isLoading,
|
|
2921
|
+
onMouseEnter: (e) => {
|
|
2922
|
+
if (!isLoading) {
|
|
2923
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
|
|
2924
|
+
}
|
|
2925
|
+
},
|
|
2926
|
+
onMouseLeave: (e) => {
|
|
2927
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimary;
|
|
2928
|
+
},
|
|
2929
|
+
style: {
|
|
2930
|
+
width: "100%",
|
|
2931
|
+
padding: "14px",
|
|
2932
|
+
backgroundColor: colors.buttonPrimary,
|
|
2933
|
+
color: "white",
|
|
2934
|
+
border: "none",
|
|
2935
|
+
borderRadius: "8px",
|
|
2936
|
+
fontSize: "16px",
|
|
2937
|
+
fontWeight: 600,
|
|
2938
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
2939
|
+
opacity: isLoading ? 0.6 : 1,
|
|
2940
|
+
transition: "all 0.2s ease",
|
|
2941
|
+
...appearance?.elements?.formButtonPrimary
|
|
2942
|
+
},
|
|
2943
|
+
children: isLoading ? "Please wait..." : needsOtp ? "Verify OTP" : usePassword ? "Sign in" : usePhone ? "Continue with phone" : "Continue with email"
|
|
2944
|
+
}
|
|
2945
|
+
),
|
|
2946
|
+
!needsOtp && /* @__PURE__ */ jsxs("div", { style: { textAlign: "center", marginTop: "16px" }, children: [
|
|
2947
|
+
/* @__PURE__ */ jsx(
|
|
2948
|
+
"button",
|
|
2949
|
+
{
|
|
2950
|
+
type: "button",
|
|
2951
|
+
onClick: toggleAuthMethod,
|
|
2952
|
+
disabled: isLoading,
|
|
2953
|
+
style: {
|
|
2954
|
+
background: "none",
|
|
2955
|
+
border: "none",
|
|
2956
|
+
color: colors.buttonPrimary,
|
|
2957
|
+
cursor: "pointer",
|
|
2958
|
+
fontSize: "14px",
|
|
2959
|
+
fontWeight: 600,
|
|
2960
|
+
marginRight: "16px"
|
|
2961
|
+
},
|
|
2962
|
+
children: usePassword ? "Use OTP code instead" : "Use password instead"
|
|
2963
|
+
}
|
|
2964
|
+
),
|
|
2965
|
+
/* @__PURE__ */ jsx(
|
|
2966
|
+
"button",
|
|
2967
|
+
{
|
|
2968
|
+
type: "button",
|
|
2969
|
+
onClick: toggleLoginMethod,
|
|
2970
|
+
disabled: isLoading,
|
|
2971
|
+
style: {
|
|
2972
|
+
background: "none",
|
|
2973
|
+
border: "none",
|
|
2974
|
+
color: colors.buttonPrimary,
|
|
2975
|
+
cursor: "pointer",
|
|
2976
|
+
fontSize: "14px",
|
|
2977
|
+
fontWeight: 600
|
|
2978
|
+
},
|
|
2979
|
+
children: usePhone ? "Use email instead" : "Use phone instead"
|
|
2980
|
+
}
|
|
2981
|
+
)
|
|
2982
|
+
] }),
|
|
2983
|
+
needsOtp && /* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginTop: "16px" }, children: /* @__PURE__ */ jsx(
|
|
2984
|
+
"button",
|
|
2985
|
+
{
|
|
2986
|
+
type: "button",
|
|
2987
|
+
onClick: () => {
|
|
2988
|
+
setNeedsOtp(false);
|
|
2989
|
+
setOtp("");
|
|
2990
|
+
setError(null);
|
|
2991
|
+
setSuccess(null);
|
|
2992
|
+
},
|
|
2993
|
+
disabled: isLoading,
|
|
2994
|
+
style: {
|
|
2995
|
+
background: "none",
|
|
2996
|
+
border: "none",
|
|
2997
|
+
color: colors.buttonPrimary,
|
|
2998
|
+
cursor: "pointer",
|
|
2999
|
+
fontSize: "14px",
|
|
3000
|
+
fontWeight: 600
|
|
3001
|
+
},
|
|
3002
|
+
children: "Back to sign in"
|
|
3003
|
+
}
|
|
3004
|
+
) })
|
|
3005
|
+
] })
|
|
3006
|
+
}
|
|
3007
|
+
);
|
|
2451
3008
|
};
|
|
2452
3009
|
var SignUp = ({ redirectUrl, appearance }) => {
|
|
2453
3010
|
const { signUp, isSignedIn } = useAuth();
|
|
3011
|
+
const colors = useThemeColors();
|
|
2454
3012
|
const [name, setName] = useState("");
|
|
2455
3013
|
const [email, setEmail] = useState("");
|
|
3014
|
+
const [phoneNumber, setPhoneNumber] = useState("");
|
|
2456
3015
|
const [password, setPassword] = useState("");
|
|
2457
3016
|
const [confirmPassword, setConfirmPassword] = useState("");
|
|
2458
3017
|
const [showPassword, setShowPassword] = useState(false);
|
|
@@ -2466,9 +3025,9 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2466
3025
|
window.location.href = `${baseUrl}${redirect}`;
|
|
2467
3026
|
}
|
|
2468
3027
|
}, [isSignedIn, redirectUrl]);
|
|
2469
|
-
const getPasswordStrength = (pwd) => {
|
|
3028
|
+
const getPasswordStrength = (pwd, colors2) => {
|
|
2470
3029
|
if (!pwd)
|
|
2471
|
-
return { strength: "weak", color:
|
|
3030
|
+
return { strength: "weak", color: colors2.borderSecondary };
|
|
2472
3031
|
let score = 0;
|
|
2473
3032
|
if (pwd.length >= 6)
|
|
2474
3033
|
score++;
|
|
@@ -2481,12 +3040,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2481
3040
|
if (/[^a-zA-Z\d]/.test(pwd))
|
|
2482
3041
|
score++;
|
|
2483
3042
|
if (score <= 2)
|
|
2484
|
-
return { strength: "weak", color:
|
|
3043
|
+
return { strength: "weak", color: colors2.errorText };
|
|
2485
3044
|
if (score <= 3)
|
|
2486
|
-
return { strength: "medium", color: "#fa4" };
|
|
2487
|
-
return { strength: "strong", color:
|
|
3045
|
+
return { strength: "medium", color: colors2.warningText || "#fa4" };
|
|
3046
|
+
return { strength: "strong", color: colors2.successText };
|
|
2488
3047
|
};
|
|
2489
|
-
const passwordStrength = getPasswordStrength(password);
|
|
3048
|
+
const passwordStrength = getPasswordStrength(password, colors);
|
|
2490
3049
|
const handleSubmit = async (e) => {
|
|
2491
3050
|
e.preventDefault();
|
|
2492
3051
|
setIsLoading(true);
|
|
@@ -2503,7 +3062,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2503
3062
|
return;
|
|
2504
3063
|
}
|
|
2505
3064
|
try {
|
|
2506
|
-
const
|
|
3065
|
+
const signUpData = { name, password };
|
|
3066
|
+
if (email)
|
|
3067
|
+
signUpData.email = email;
|
|
3068
|
+
if (phoneNumber)
|
|
3069
|
+
signUpData.phoneNumber = phoneNumber;
|
|
3070
|
+
const response = await signUp(signUpData);
|
|
2507
3071
|
if (response.success) {
|
|
2508
3072
|
setSuccess("Registration successful! Please check your email to verify your account.");
|
|
2509
3073
|
} else {
|
|
@@ -2515,20 +3079,20 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2515
3079
|
setIsLoading(false);
|
|
2516
3080
|
}
|
|
2517
3081
|
};
|
|
2518
|
-
return /* @__PURE__ */ jsx(
|
|
3082
|
+
return /* @__PURE__ */ jsx(ThemeWrapper, { style: {
|
|
2519
3083
|
maxWidth: "400px",
|
|
2520
3084
|
margin: "0 auto",
|
|
2521
3085
|
padding: "30px",
|
|
2522
3086
|
borderRadius: "12px",
|
|
2523
3087
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
2524
|
-
backgroundColor:
|
|
2525
|
-
border:
|
|
3088
|
+
backgroundColor: colors.bgPrimary,
|
|
3089
|
+
border: `1px solid ${colors.borderPrimary}`,
|
|
2526
3090
|
...appearance?.elements?.card
|
|
2527
3091
|
}, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
|
|
2528
3092
|
/* @__PURE__ */ jsx("h2", { style: {
|
|
2529
3093
|
textAlign: "center",
|
|
2530
3094
|
marginBottom: "24px",
|
|
2531
|
-
color:
|
|
3095
|
+
color: colors.textPrimary,
|
|
2532
3096
|
fontSize: "24px",
|
|
2533
3097
|
fontWeight: 600,
|
|
2534
3098
|
...appearance?.elements?.headerTitle
|
|
@@ -2536,18 +3100,18 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2536
3100
|
error && /* @__PURE__ */ jsx("div", { style: {
|
|
2537
3101
|
padding: "12px 16px",
|
|
2538
3102
|
marginBottom: "20px",
|
|
2539
|
-
backgroundColor:
|
|
2540
|
-
color:
|
|
2541
|
-
border:
|
|
3103
|
+
backgroundColor: colors.errorBg,
|
|
3104
|
+
color: colors.errorText,
|
|
3105
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
2542
3106
|
borderRadius: "8px",
|
|
2543
3107
|
fontSize: "14px"
|
|
2544
3108
|
}, children: error }),
|
|
2545
3109
|
success && /* @__PURE__ */ jsx("div", { style: {
|
|
2546
3110
|
padding: "12px 16px",
|
|
2547
3111
|
marginBottom: "20px",
|
|
2548
|
-
backgroundColor:
|
|
2549
|
-
color:
|
|
2550
|
-
border:
|
|
3112
|
+
backgroundColor: colors.successBg,
|
|
3113
|
+
color: colors.successText,
|
|
3114
|
+
border: `1px solid ${colors.successBorder}`,
|
|
2551
3115
|
borderRadius: "8px",
|
|
2552
3116
|
fontSize: "14px"
|
|
2553
3117
|
}, children: success }),
|
|
@@ -2556,7 +3120,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2556
3120
|
display: "block",
|
|
2557
3121
|
marginBottom: "8px",
|
|
2558
3122
|
fontWeight: 500,
|
|
2559
|
-
color:
|
|
3123
|
+
color: colors.textSecondary,
|
|
2560
3124
|
fontSize: "14px"
|
|
2561
3125
|
}, children: "Full name" }),
|
|
2562
3126
|
/* @__PURE__ */ jsx(
|
|
@@ -2566,15 +3130,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2566
3130
|
type: "text",
|
|
2567
3131
|
value: name,
|
|
2568
3132
|
onChange: (e) => setName(e.target.value),
|
|
3133
|
+
onFocus: (e) => {
|
|
3134
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
3135
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
3136
|
+
},
|
|
3137
|
+
onBlur: (e) => {
|
|
3138
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
3139
|
+
e.currentTarget.style.outline = "none";
|
|
3140
|
+
},
|
|
2569
3141
|
required: true,
|
|
2570
3142
|
disabled: isLoading,
|
|
2571
3143
|
style: {
|
|
2572
3144
|
width: "100%",
|
|
2573
3145
|
padding: "12px 16px",
|
|
2574
|
-
border:
|
|
3146
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2575
3147
|
borderRadius: "8px",
|
|
2576
3148
|
fontSize: "16px",
|
|
2577
3149
|
boxSizing: "border-box",
|
|
3150
|
+
backgroundColor: colors.bgSecondary,
|
|
3151
|
+
color: colors.textPrimary,
|
|
3152
|
+
transition: "all 0.2s ease",
|
|
3153
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
3154
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2578
3155
|
...appearance?.elements?.formFieldInput
|
|
2579
3156
|
},
|
|
2580
3157
|
placeholder: "Enter your full name"
|
|
@@ -2586,7 +3163,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2586
3163
|
display: "block",
|
|
2587
3164
|
marginBottom: "8px",
|
|
2588
3165
|
fontWeight: 500,
|
|
2589
|
-
color:
|
|
3166
|
+
color: colors.textSecondary,
|
|
2590
3167
|
fontSize: "14px"
|
|
2591
3168
|
}, children: "Email" }),
|
|
2592
3169
|
/* @__PURE__ */ jsx(
|
|
@@ -2596,27 +3173,60 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2596
3173
|
type: "email",
|
|
2597
3174
|
value: email,
|
|
2598
3175
|
onChange: (e) => setEmail(e.target.value),
|
|
2599
|
-
|
|
3176
|
+
onFocus: (e) => {
|
|
3177
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
3178
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
3179
|
+
},
|
|
3180
|
+
onBlur: (e) => {
|
|
3181
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
3182
|
+
e.currentTarget.style.outline = "none";
|
|
3183
|
+
},
|
|
3184
|
+
required: !phoneNumber,
|
|
2600
3185
|
disabled: isLoading,
|
|
2601
3186
|
style: {
|
|
2602
3187
|
width: "100%",
|
|
2603
3188
|
padding: "12px 16px",
|
|
2604
|
-
border:
|
|
3189
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2605
3190
|
borderRadius: "8px",
|
|
2606
3191
|
fontSize: "16px",
|
|
2607
3192
|
boxSizing: "border-box",
|
|
3193
|
+
backgroundColor: colors.bgSecondary,
|
|
3194
|
+
color: colors.textPrimary,
|
|
3195
|
+
transition: "all 0.2s ease",
|
|
3196
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
3197
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2608
3198
|
...appearance?.elements?.formFieldInput
|
|
2609
3199
|
},
|
|
2610
3200
|
placeholder: "Enter your email"
|
|
2611
3201
|
}
|
|
2612
3202
|
)
|
|
2613
3203
|
] }),
|
|
3204
|
+
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
3205
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "phoneNumber", style: {
|
|
3206
|
+
display: "block",
|
|
3207
|
+
marginBottom: "8px",
|
|
3208
|
+
fontWeight: 500,
|
|
3209
|
+
color: colors.textSecondary,
|
|
3210
|
+
fontSize: "14px"
|
|
3211
|
+
}, children: "Phone Number (Optional)" }),
|
|
3212
|
+
/* @__PURE__ */ jsx(
|
|
3213
|
+
PhoneInput,
|
|
3214
|
+
{
|
|
3215
|
+
id: "phoneNumber",
|
|
3216
|
+
value: phoneNumber,
|
|
3217
|
+
onChange: setPhoneNumber,
|
|
3218
|
+
disabled: isLoading,
|
|
3219
|
+
placeholder: "1234567890",
|
|
3220
|
+
style: appearance?.elements?.formFieldInput
|
|
3221
|
+
}
|
|
3222
|
+
)
|
|
3223
|
+
] }),
|
|
2614
3224
|
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
|
|
2615
3225
|
/* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
|
|
2616
3226
|
display: "block",
|
|
2617
3227
|
marginBottom: "8px",
|
|
2618
3228
|
fontWeight: 500,
|
|
2619
|
-
color:
|
|
3229
|
+
color: colors.textSecondary,
|
|
2620
3230
|
fontSize: "14px"
|
|
2621
3231
|
}, children: "Password" }),
|
|
2622
3232
|
/* @__PURE__ */ jsx(
|
|
@@ -2626,16 +3236,29 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2626
3236
|
type: showPassword ? "text" : "password",
|
|
2627
3237
|
value: password,
|
|
2628
3238
|
onChange: (e) => setPassword(e.target.value),
|
|
3239
|
+
onFocus: (e) => {
|
|
3240
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
3241
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
3242
|
+
},
|
|
3243
|
+
onBlur: (e) => {
|
|
3244
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
3245
|
+
e.currentTarget.style.outline = "none";
|
|
3246
|
+
},
|
|
2629
3247
|
required: true,
|
|
2630
3248
|
disabled: isLoading,
|
|
2631
3249
|
minLength: 6,
|
|
2632
3250
|
style: {
|
|
2633
3251
|
width: "100%",
|
|
2634
3252
|
padding: "12px 16px",
|
|
2635
|
-
border:
|
|
3253
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2636
3254
|
borderRadius: "8px",
|
|
2637
3255
|
fontSize: "16px",
|
|
2638
3256
|
boxSizing: "border-box",
|
|
3257
|
+
backgroundColor: colors.bgSecondary,
|
|
3258
|
+
color: colors.textPrimary,
|
|
3259
|
+
transition: "all 0.2s ease",
|
|
3260
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
3261
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2639
3262
|
...appearance?.elements?.formFieldInput
|
|
2640
3263
|
},
|
|
2641
3264
|
placeholder: "Create a password"
|
|
@@ -2653,7 +3276,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2653
3276
|
background: "none",
|
|
2654
3277
|
border: "none",
|
|
2655
3278
|
cursor: "pointer",
|
|
2656
|
-
color:
|
|
3279
|
+
color: colors.textTertiary,
|
|
2657
3280
|
fontSize: "14px"
|
|
2658
3281
|
},
|
|
2659
3282
|
children: showPassword ? "Hide" : "Show"
|
|
@@ -2662,7 +3285,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2662
3285
|
password && /* @__PURE__ */ jsxs("div", { style: { marginTop: "8px" }, children: [
|
|
2663
3286
|
/* @__PURE__ */ jsx("div", { style: {
|
|
2664
3287
|
height: "4px",
|
|
2665
|
-
backgroundColor:
|
|
3288
|
+
backgroundColor: colors.borderSecondary,
|
|
2666
3289
|
borderRadius: "2px",
|
|
2667
3290
|
overflow: "hidden"
|
|
2668
3291
|
}, children: /* @__PURE__ */ jsx("div", { style: {
|
|
@@ -2687,7 +3310,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2687
3310
|
display: "block",
|
|
2688
3311
|
marginBottom: "8px",
|
|
2689
3312
|
fontWeight: 500,
|
|
2690
|
-
color:
|
|
3313
|
+
color: colors.textSecondary,
|
|
2691
3314
|
fontSize: "14px"
|
|
2692
3315
|
}, children: "Confirm password" }),
|
|
2693
3316
|
/* @__PURE__ */ jsx(
|
|
@@ -2697,15 +3320,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2697
3320
|
type: showPassword ? "text" : "password",
|
|
2698
3321
|
value: confirmPassword,
|
|
2699
3322
|
onChange: (e) => setConfirmPassword(e.target.value),
|
|
3323
|
+
onFocus: (e) => {
|
|
3324
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
3325
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
3326
|
+
},
|
|
3327
|
+
onBlur: (e) => {
|
|
3328
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
3329
|
+
e.currentTarget.style.outline = "none";
|
|
3330
|
+
},
|
|
2700
3331
|
required: true,
|
|
2701
3332
|
disabled: isLoading,
|
|
2702
3333
|
style: {
|
|
2703
3334
|
width: "100%",
|
|
2704
3335
|
padding: "12px 16px",
|
|
2705
|
-
border:
|
|
3336
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2706
3337
|
borderRadius: "8px",
|
|
2707
3338
|
fontSize: "16px",
|
|
2708
3339
|
boxSizing: "border-box",
|
|
3340
|
+
backgroundColor: colors.bgSecondary,
|
|
3341
|
+
color: colors.textPrimary,
|
|
3342
|
+
transition: "all 0.2s ease",
|
|
3343
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
3344
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2709
3345
|
...appearance?.elements?.formFieldInput
|
|
2710
3346
|
},
|
|
2711
3347
|
placeholder: "Confirm your password"
|
|
@@ -2717,16 +3353,25 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2717
3353
|
{
|
|
2718
3354
|
type: "submit",
|
|
2719
3355
|
disabled: isLoading,
|
|
3356
|
+
onMouseEnter: (e) => {
|
|
3357
|
+
if (!isLoading) {
|
|
3358
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
|
|
3359
|
+
}
|
|
3360
|
+
},
|
|
3361
|
+
onMouseLeave: (e) => {
|
|
3362
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimary;
|
|
3363
|
+
},
|
|
2720
3364
|
style: {
|
|
2721
3365
|
width: "100%",
|
|
2722
3366
|
padding: "14px",
|
|
2723
|
-
backgroundColor:
|
|
3367
|
+
backgroundColor: colors.buttonPrimary,
|
|
2724
3368
|
color: "white",
|
|
2725
3369
|
border: "none",
|
|
2726
3370
|
borderRadius: "8px",
|
|
2727
3371
|
fontSize: "16px",
|
|
2728
3372
|
fontWeight: 600,
|
|
2729
|
-
cursor: "pointer",
|
|
3373
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
3374
|
+
opacity: isLoading ? 0.6 : 1,
|
|
2730
3375
|
transition: "all 0.2s ease",
|
|
2731
3376
|
...appearance?.elements?.formButtonPrimary
|
|
2732
3377
|
},
|
|
@@ -2750,6 +3395,7 @@ var SignOut = ({ redirectUrl }) => {
|
|
|
2750
3395
|
};
|
|
2751
3396
|
var UserButton = ({ showName = false, appearance }) => {
|
|
2752
3397
|
const { user, signOut } = useAuth();
|
|
3398
|
+
const colors = useThemeColors();
|
|
2753
3399
|
const [isOpen, setIsOpen] = useState(false);
|
|
2754
3400
|
const dropdownRef = useRef(null);
|
|
2755
3401
|
useEffect(() => {
|
|
@@ -2772,7 +3418,7 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2772
3418
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2773
3419
|
window.location.href = `${baseUrl}${redirect}`;
|
|
2774
3420
|
};
|
|
2775
|
-
return /* @__PURE__ */ jsxs(
|
|
3421
|
+
return /* @__PURE__ */ jsxs(ThemeWrapper, { style: { position: "relative", ...appearance?.elements?.userButtonBox }, ref: dropdownRef, children: [
|
|
2776
3422
|
/* @__PURE__ */ jsxs(
|
|
2777
3423
|
"button",
|
|
2778
3424
|
{
|
|
@@ -2790,7 +3436,7 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2790
3436
|
...appearance?.elements?.userButtonTrigger
|
|
2791
3437
|
},
|
|
2792
3438
|
onMouseEnter: (e) => {
|
|
2793
|
-
e.currentTarget.style.backgroundColor =
|
|
3439
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
2794
3440
|
},
|
|
2795
3441
|
onMouseLeave: (e) => {
|
|
2796
3442
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
@@ -2800,15 +3446,15 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2800
3446
|
width: "36px",
|
|
2801
3447
|
height: "36px",
|
|
2802
3448
|
borderRadius: "50%",
|
|
2803
|
-
backgroundColor:
|
|
2804
|
-
color:
|
|
3449
|
+
backgroundColor: colors.buttonPrimary,
|
|
3450
|
+
color: colors.textPrimary,
|
|
2805
3451
|
display: "flex",
|
|
2806
3452
|
alignItems: "center",
|
|
2807
3453
|
justifyContent: "center",
|
|
2808
3454
|
fontSize: "14px",
|
|
2809
3455
|
fontWeight: 600
|
|
2810
3456
|
}, children: getInitials(user.name) }),
|
|
2811
|
-
showName && /* @__PURE__ */ jsx("span", { style: { fontSize: "14px", fontWeight: 500, color:
|
|
3457
|
+
showName && /* @__PURE__ */ jsx("span", { style: { fontSize: "14px", fontWeight: 500, color: colors.textPrimary }, children: user.name })
|
|
2812
3458
|
]
|
|
2813
3459
|
}
|
|
2814
3460
|
),
|
|
@@ -2818,16 +3464,16 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2818
3464
|
right: 0,
|
|
2819
3465
|
marginTop: "8px",
|
|
2820
3466
|
width: "240px",
|
|
2821
|
-
backgroundColor:
|
|
3467
|
+
backgroundColor: colors.bgPrimary,
|
|
2822
3468
|
borderRadius: "12px",
|
|
2823
3469
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.15)",
|
|
2824
|
-
border:
|
|
3470
|
+
border: `1px solid ${colors.borderPrimary}`,
|
|
2825
3471
|
zIndex: 1e3,
|
|
2826
3472
|
...appearance?.elements?.userButtonPopoverCard
|
|
2827
3473
|
}, children: [
|
|
2828
3474
|
/* @__PURE__ */ jsx("div", { style: {
|
|
2829
3475
|
padding: "16px",
|
|
2830
|
-
borderBottom:
|
|
3476
|
+
borderBottom: `1px solid ${colors.borderPrimary}`
|
|
2831
3477
|
}, children: /* @__PURE__ */ jsxs("div", { style: {
|
|
2832
3478
|
display: "flex",
|
|
2833
3479
|
alignItems: "center",
|
|
@@ -2837,8 +3483,8 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2837
3483
|
width: "48px",
|
|
2838
3484
|
height: "48px",
|
|
2839
3485
|
borderRadius: "50%",
|
|
2840
|
-
backgroundColor:
|
|
2841
|
-
color:
|
|
3486
|
+
backgroundColor: colors.buttonPrimary,
|
|
3487
|
+
color: colors.textPrimary,
|
|
2842
3488
|
display: "flex",
|
|
2843
3489
|
alignItems: "center",
|
|
2844
3490
|
justifyContent: "center",
|
|
@@ -2849,14 +3495,14 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2849
3495
|
/* @__PURE__ */ jsx("div", { style: {
|
|
2850
3496
|
fontSize: "14px",
|
|
2851
3497
|
fontWeight: 600,
|
|
2852
|
-
color:
|
|
3498
|
+
color: colors.textPrimary,
|
|
2853
3499
|
overflow: "hidden",
|
|
2854
3500
|
textOverflow: "ellipsis",
|
|
2855
3501
|
whiteSpace: "nowrap"
|
|
2856
3502
|
}, children: user.name }),
|
|
2857
3503
|
/* @__PURE__ */ jsx("div", { style: {
|
|
2858
3504
|
fontSize: "12px",
|
|
2859
|
-
color:
|
|
3505
|
+
color: colors.textTertiary,
|
|
2860
3506
|
overflow: "hidden",
|
|
2861
3507
|
textOverflow: "ellipsis",
|
|
2862
3508
|
whiteSpace: "nowrap"
|
|
@@ -2876,12 +3522,12 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2876
3522
|
textAlign: "left",
|
|
2877
3523
|
cursor: "pointer",
|
|
2878
3524
|
fontSize: "14px",
|
|
2879
|
-
color:
|
|
3525
|
+
color: colors.textPrimary,
|
|
2880
3526
|
fontWeight: 500,
|
|
2881
3527
|
transition: "background-color 0.2s"
|
|
2882
3528
|
},
|
|
2883
3529
|
onMouseEnter: (e) => {
|
|
2884
|
-
e.currentTarget.style.backgroundColor =
|
|
3530
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
2885
3531
|
},
|
|
2886
3532
|
onMouseLeave: (e) => {
|
|
2887
3533
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
@@ -3734,43 +4380,41 @@ var UserProfile = ({
|
|
|
3734
4380
|
showEmailChange = true,
|
|
3735
4381
|
showPasswordChange = true
|
|
3736
4382
|
}) => {
|
|
3737
|
-
const { user, updateProfile,
|
|
4383
|
+
const { user, updateProfile, requestEmailChange } = useAuth();
|
|
4384
|
+
const colors = useThemeColors();
|
|
3738
4385
|
const [name, setName] = useState(user?.name || "");
|
|
3739
|
-
const [avatar, setAvatar] = useState("");
|
|
4386
|
+
const [avatar, setAvatar] = useState(user?.avatar || "");
|
|
4387
|
+
const [phoneNumber, setPhoneNumber] = useState(user?.phoneNumber || "");
|
|
3740
4388
|
const [newEmail, setNewEmail] = useState("");
|
|
3741
4389
|
const [isLoading, setIsLoading] = useState(false);
|
|
3742
4390
|
const [error, setError] = useState(null);
|
|
3743
4391
|
const [success, setSuccess] = useState(null);
|
|
3744
|
-
const
|
|
4392
|
+
const handleUpdateProfile = async (e) => {
|
|
3745
4393
|
e.preventDefault();
|
|
3746
4394
|
setIsLoading(true);
|
|
3747
4395
|
setError(null);
|
|
3748
4396
|
setSuccess(null);
|
|
3749
4397
|
try {
|
|
3750
|
-
const
|
|
3751
|
-
if (
|
|
3752
|
-
|
|
3753
|
-
} else {
|
|
3754
|
-
setError(response.message || "Failed to update name");
|
|
4398
|
+
const updates = {};
|
|
4399
|
+
if (name !== user?.name) {
|
|
4400
|
+
updates.name = name;
|
|
3755
4401
|
}
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
const response = await updateAvatar(avatar);
|
|
4402
|
+
if (showAvatar && avatar !== user?.avatar) {
|
|
4403
|
+
updates.avatar = avatar;
|
|
4404
|
+
}
|
|
4405
|
+
if (phoneNumber !== user?.phoneNumber) {
|
|
4406
|
+
updates.phoneNumber = phoneNumber;
|
|
4407
|
+
}
|
|
4408
|
+
if (Object.keys(updates).length === 0) {
|
|
4409
|
+
setError("No changes to save");
|
|
4410
|
+
setIsLoading(false);
|
|
4411
|
+
return;
|
|
4412
|
+
}
|
|
4413
|
+
const response = await updateProfile(updates);
|
|
3769
4414
|
if (response.success) {
|
|
3770
|
-
setSuccess("
|
|
3771
|
-
setAvatar("");
|
|
4415
|
+
setSuccess("Profile updated successfully!");
|
|
3772
4416
|
} else {
|
|
3773
|
-
setError(response.message || "Failed to update
|
|
4417
|
+
setError(response.message || "Failed to update profile");
|
|
3774
4418
|
}
|
|
3775
4419
|
} catch (err) {
|
|
3776
4420
|
setError(err instanceof Error ? err.message : "An error occurred");
|
|
@@ -3799,173 +4443,220 @@ var UserProfile = ({
|
|
|
3799
4443
|
};
|
|
3800
4444
|
if (!user)
|
|
3801
4445
|
return null;
|
|
3802
|
-
return /* @__PURE__ */ jsxs("div", { style: { maxWidth: "
|
|
3803
|
-
/* @__PURE__ */ jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600 }, children: "Profile Settings" }),
|
|
4446
|
+
return /* @__PURE__ */ jsxs("div", { style: { maxWidth: "700px", margin: "0 auto", padding: "20px" }, children: [
|
|
4447
|
+
/* @__PURE__ */ jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Settings" }),
|
|
3804
4448
|
error && /* @__PURE__ */ jsx("div", { style: {
|
|
3805
4449
|
padding: "12px 16px",
|
|
3806
4450
|
marginBottom: "20px",
|
|
3807
|
-
backgroundColor:
|
|
3808
|
-
color:
|
|
3809
|
-
border:
|
|
4451
|
+
backgroundColor: colors.errorBg,
|
|
4452
|
+
color: colors.errorText,
|
|
4453
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
3810
4454
|
borderRadius: "8px",
|
|
3811
4455
|
fontSize: "14px"
|
|
3812
4456
|
}, children: error }),
|
|
3813
4457
|
success && /* @__PURE__ */ jsx("div", { style: {
|
|
3814
4458
|
padding: "12px 16px",
|
|
3815
4459
|
marginBottom: "20px",
|
|
3816
|
-
backgroundColor:
|
|
3817
|
-
color:
|
|
3818
|
-
border:
|
|
4460
|
+
backgroundColor: colors.successBg,
|
|
4461
|
+
color: colors.successText,
|
|
4462
|
+
border: `1px solid ${colors.successBorder}`,
|
|
3819
4463
|
borderRadius: "8px",
|
|
3820
4464
|
fontSize: "14px"
|
|
3821
4465
|
}, children: success }),
|
|
3822
4466
|
/* @__PURE__ */ jsxs("div", { style: {
|
|
3823
|
-
padding: "
|
|
3824
|
-
backgroundColor:
|
|
3825
|
-
borderRadius: "
|
|
4467
|
+
padding: "24px",
|
|
4468
|
+
backgroundColor: colors.bgPrimary,
|
|
4469
|
+
borderRadius: "12px",
|
|
3826
4470
|
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3827
|
-
marginBottom: "
|
|
4471
|
+
marginBottom: "24px",
|
|
4472
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
3828
4473
|
}, children: [
|
|
3829
|
-
/* @__PURE__ */ jsx("h3", { style: { marginBottom: "
|
|
3830
|
-
/* @__PURE__ */ jsxs("form", { onSubmit:
|
|
3831
|
-
/* @__PURE__ */
|
|
3832
|
-
"
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
4474
|
+
/* @__PURE__ */ jsx("h3", { style: { marginBottom: "20px", fontSize: "18px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Information" }),
|
|
4475
|
+
/* @__PURE__ */ jsxs("form", { onSubmit: handleUpdateProfile, children: [
|
|
4476
|
+
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
4477
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "name", style: {
|
|
4478
|
+
display: "block",
|
|
4479
|
+
marginBottom: "8px",
|
|
4480
|
+
fontWeight: 500,
|
|
4481
|
+
color: colors.textSecondary,
|
|
4482
|
+
fontSize: "14px"
|
|
4483
|
+
}, children: "Full Name" }),
|
|
4484
|
+
/* @__PURE__ */ jsx(
|
|
4485
|
+
"input",
|
|
4486
|
+
{
|
|
4487
|
+
id: "name",
|
|
4488
|
+
type: "text",
|
|
4489
|
+
value: name,
|
|
4490
|
+
onChange: (e) => setName(e.target.value),
|
|
4491
|
+
required: true,
|
|
4492
|
+
disabled: isLoading,
|
|
4493
|
+
style: {
|
|
4494
|
+
width: "100%",
|
|
4495
|
+
padding: "12px 16px",
|
|
4496
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
4497
|
+
borderRadius: "8px",
|
|
4498
|
+
fontSize: "16px",
|
|
4499
|
+
boxSizing: "border-box",
|
|
4500
|
+
backgroundColor: colors.bgSecondary,
|
|
4501
|
+
color: colors.textPrimary,
|
|
4502
|
+
transition: "all 0.2s ease"
|
|
4503
|
+
},
|
|
4504
|
+
placeholder: "Manish Batra"
|
|
4505
|
+
}
|
|
4506
|
+
)
|
|
4507
|
+
] }),
|
|
4508
|
+
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
4509
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "phoneNumber", style: {
|
|
4510
|
+
display: "block",
|
|
4511
|
+
marginBottom: "8px",
|
|
4512
|
+
fontWeight: 500,
|
|
4513
|
+
color: colors.textSecondary,
|
|
4514
|
+
fontSize: "14px"
|
|
4515
|
+
}, children: "Phone Number" }),
|
|
4516
|
+
/* @__PURE__ */ jsx(
|
|
4517
|
+
PhoneInput,
|
|
4518
|
+
{
|
|
4519
|
+
id: "phoneNumber",
|
|
4520
|
+
value: phoneNumber,
|
|
4521
|
+
onChange: setPhoneNumber,
|
|
4522
|
+
disabled: isLoading,
|
|
4523
|
+
placeholder: "1234567890"
|
|
4524
|
+
}
|
|
4525
|
+
)
|
|
4526
|
+
] }),
|
|
4527
|
+
showAvatar && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
4528
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "avatar", style: {
|
|
4529
|
+
display: "block",
|
|
4530
|
+
marginBottom: "8px",
|
|
4531
|
+
fontWeight: 500,
|
|
4532
|
+
color: colors.textSecondary,
|
|
4533
|
+
fontSize: "14px"
|
|
4534
|
+
}, children: "Avatar URL" }),
|
|
4535
|
+
/* @__PURE__ */ jsx(
|
|
4536
|
+
"input",
|
|
4537
|
+
{
|
|
4538
|
+
id: "avatar",
|
|
4539
|
+
type: "url",
|
|
4540
|
+
value: avatar,
|
|
4541
|
+
onChange: (e) => setAvatar(e.target.value),
|
|
4542
|
+
disabled: isLoading,
|
|
4543
|
+
style: {
|
|
4544
|
+
width: "100%",
|
|
4545
|
+
padding: "12px 16px",
|
|
4546
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
4547
|
+
borderRadius: "8px",
|
|
4548
|
+
fontSize: "16px",
|
|
4549
|
+
boxSizing: "border-box",
|
|
4550
|
+
backgroundColor: colors.bgSecondary,
|
|
4551
|
+
color: colors.textPrimary,
|
|
4552
|
+
transition: "all 0.2s ease"
|
|
4553
|
+
},
|
|
4554
|
+
placeholder: "https://example.com/avatar.jpg"
|
|
4555
|
+
}
|
|
4556
|
+
)
|
|
4557
|
+
] }),
|
|
3851
4558
|
/* @__PURE__ */ jsx(
|
|
3852
4559
|
"button",
|
|
3853
4560
|
{
|
|
3854
4561
|
type: "submit",
|
|
3855
4562
|
disabled: isLoading,
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
border: "none",
|
|
3861
|
-
borderRadius: "8px",
|
|
3862
|
-
fontSize: "14px",
|
|
3863
|
-
fontWeight: 600,
|
|
3864
|
-
cursor: "pointer"
|
|
4563
|
+
onMouseEnter: (e) => {
|
|
4564
|
+
if (!isLoading) {
|
|
4565
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
|
|
4566
|
+
}
|
|
3865
4567
|
},
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
)
|
|
3869
|
-
] })
|
|
3870
|
-
] }),
|
|
3871
|
-
showAvatar && /* @__PURE__ */ jsxs("div", { style: {
|
|
3872
|
-
padding: "20px",
|
|
3873
|
-
backgroundColor: "#fff",
|
|
3874
|
-
borderRadius: "8px",
|
|
3875
|
-
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3876
|
-
marginBottom: "20px"
|
|
3877
|
-
}, children: [
|
|
3878
|
-
/* @__PURE__ */ jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Update Avatar" }),
|
|
3879
|
-
/* @__PURE__ */ jsxs("form", { onSubmit: handleUpdateAvatar, children: [
|
|
3880
|
-
/* @__PURE__ */ jsx(
|
|
3881
|
-
"input",
|
|
3882
|
-
{
|
|
3883
|
-
type: "url",
|
|
3884
|
-
value: avatar,
|
|
3885
|
-
onChange: (e) => setAvatar(e.target.value),
|
|
3886
|
-
required: true,
|
|
3887
|
-
disabled: isLoading,
|
|
3888
|
-
style: {
|
|
3889
|
-
width: "100%",
|
|
3890
|
-
padding: "12px 16px",
|
|
3891
|
-
border: "1px solid #ddd",
|
|
3892
|
-
borderRadius: "8px",
|
|
3893
|
-
fontSize: "16px",
|
|
3894
|
-
boxSizing: "border-box",
|
|
3895
|
-
marginBottom: "12px"
|
|
4568
|
+
onMouseLeave: (e) => {
|
|
4569
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimary;
|
|
3896
4570
|
},
|
|
3897
|
-
placeholder: "Avatar URL"
|
|
3898
|
-
}
|
|
3899
|
-
),
|
|
3900
|
-
/* @__PURE__ */ jsx(
|
|
3901
|
-
"button",
|
|
3902
|
-
{
|
|
3903
|
-
type: "submit",
|
|
3904
|
-
disabled: isLoading,
|
|
3905
4571
|
style: {
|
|
3906
|
-
padding: "
|
|
3907
|
-
backgroundColor:
|
|
4572
|
+
padding: "12px 24px",
|
|
4573
|
+
backgroundColor: colors.buttonPrimary,
|
|
3908
4574
|
color: "white",
|
|
3909
4575
|
border: "none",
|
|
3910
4576
|
borderRadius: "8px",
|
|
3911
4577
|
fontSize: "14px",
|
|
3912
4578
|
fontWeight: 600,
|
|
3913
|
-
cursor: "pointer"
|
|
4579
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
4580
|
+
opacity: isLoading ? 0.6 : 1,
|
|
4581
|
+
transition: "all 0.2s ease"
|
|
3914
4582
|
},
|
|
3915
|
-
children: "
|
|
4583
|
+
children: isLoading ? "Saving..." : "Save Changes"
|
|
3916
4584
|
}
|
|
3917
4585
|
)
|
|
3918
4586
|
] })
|
|
3919
4587
|
] }),
|
|
3920
4588
|
showEmailChange && /* @__PURE__ */ jsxs("div", { style: {
|
|
3921
|
-
padding: "
|
|
3922
|
-
backgroundColor:
|
|
3923
|
-
borderRadius: "
|
|
4589
|
+
padding: "24px",
|
|
4590
|
+
backgroundColor: colors.bgPrimary,
|
|
4591
|
+
borderRadius: "12px",
|
|
3924
4592
|
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3925
|
-
marginBottom: "20px"
|
|
4593
|
+
marginBottom: "20px",
|
|
4594
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
3926
4595
|
}, children: [
|
|
3927
|
-
/* @__PURE__ */ jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Change Email" }),
|
|
3928
|
-
/* @__PURE__ */ jsxs("p", { style: { fontSize: "14px", color:
|
|
4596
|
+
/* @__PURE__ */ jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600, color: colors.textPrimary }, children: "Change Email" }),
|
|
4597
|
+
/* @__PURE__ */ jsxs("p", { style: { fontSize: "14px", color: colors.textSecondary, marginBottom: "16px" }, children: [
|
|
3929
4598
|
"Current email: ",
|
|
3930
4599
|
/* @__PURE__ */ jsx("strong", { children: user.email })
|
|
3931
4600
|
] }),
|
|
3932
4601
|
/* @__PURE__ */ jsxs("form", { onSubmit: handleRequestEmailChange, children: [
|
|
3933
|
-
/* @__PURE__ */
|
|
3934
|
-
"
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
4602
|
+
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "16px" }, children: [
|
|
4603
|
+
/* @__PURE__ */ jsx("label", { htmlFor: "newEmail", style: {
|
|
4604
|
+
display: "block",
|
|
4605
|
+
marginBottom: "8px",
|
|
4606
|
+
fontWeight: 500,
|
|
4607
|
+
color: colors.textSecondary,
|
|
4608
|
+
fontSize: "14px"
|
|
4609
|
+
}, children: "New Email Address" }),
|
|
4610
|
+
/* @__PURE__ */ jsx(
|
|
4611
|
+
"input",
|
|
4612
|
+
{
|
|
4613
|
+
id: "newEmail",
|
|
4614
|
+
type: "email",
|
|
4615
|
+
value: newEmail,
|
|
4616
|
+
onChange: (e) => setNewEmail(e.target.value),
|
|
4617
|
+
required: true,
|
|
4618
|
+
disabled: isLoading,
|
|
4619
|
+
style: {
|
|
4620
|
+
width: "100%",
|
|
4621
|
+
padding: "12px 16px",
|
|
4622
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
4623
|
+
borderRadius: "8px",
|
|
4624
|
+
fontSize: "16px",
|
|
4625
|
+
boxSizing: "border-box",
|
|
4626
|
+
backgroundColor: colors.bgSecondary,
|
|
4627
|
+
color: colors.textPrimary,
|
|
4628
|
+
transition: "all 0.2s ease"
|
|
4629
|
+
},
|
|
4630
|
+
placeholder: "newemail@example.com"
|
|
4631
|
+
}
|
|
4632
|
+
)
|
|
4633
|
+
] }),
|
|
3953
4634
|
/* @__PURE__ */ jsx(
|
|
3954
4635
|
"button",
|
|
3955
4636
|
{
|
|
3956
4637
|
type: "submit",
|
|
3957
4638
|
disabled: isLoading,
|
|
4639
|
+
onMouseEnter: (e) => {
|
|
4640
|
+
if (!isLoading) {
|
|
4641
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
|
|
4642
|
+
}
|
|
4643
|
+
},
|
|
4644
|
+
onMouseLeave: (e) => {
|
|
4645
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimary;
|
|
4646
|
+
},
|
|
3958
4647
|
style: {
|
|
3959
|
-
padding: "
|
|
3960
|
-
backgroundColor:
|
|
4648
|
+
padding: "12px 24px",
|
|
4649
|
+
backgroundColor: colors.buttonPrimary,
|
|
3961
4650
|
color: "white",
|
|
3962
4651
|
border: "none",
|
|
3963
4652
|
borderRadius: "8px",
|
|
3964
4653
|
fontSize: "14px",
|
|
3965
4654
|
fontWeight: 600,
|
|
3966
|
-
cursor: "pointer"
|
|
4655
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
4656
|
+
opacity: isLoading ? 0.6 : 1,
|
|
4657
|
+
transition: "all 0.2s ease"
|
|
3967
4658
|
},
|
|
3968
|
-
children: "Request Email Change"
|
|
4659
|
+
children: isLoading ? "Sending..." : "Request Email Change"
|
|
3969
4660
|
}
|
|
3970
4661
|
)
|
|
3971
4662
|
] })
|
|
@@ -3978,11 +4669,13 @@ var react_exports = {};
|
|
|
3978
4669
|
__export(react_exports, {
|
|
3979
4670
|
AuthFlow: () => AuthFlow,
|
|
3980
4671
|
AuthProvider: () => AuthProvider,
|
|
4672
|
+
AuthThemeProvider: () => AuthThemeProvider,
|
|
3981
4673
|
ChangePassword: () => ChangePassword,
|
|
3982
4674
|
EmailVerificationPage: () => EmailVerificationPage,
|
|
3983
4675
|
ForgotPassword: () => ForgotPassword,
|
|
3984
4676
|
LoginForm: () => LoginForm,
|
|
3985
4677
|
OtpForm: () => OtpForm,
|
|
4678
|
+
PhoneInput: () => PhoneInput,
|
|
3986
4679
|
ProtectedRoute: () => ProtectedRoute,
|
|
3987
4680
|
PublicRoute: () => PublicRoute,
|
|
3988
4681
|
RegisterForm: () => RegisterForm,
|
|
@@ -3994,7 +4687,8 @@ __export(react_exports, {
|
|
|
3994
4687
|
UserProfile: () => UserProfile,
|
|
3995
4688
|
VerifyEmail: () => VerifyEmail,
|
|
3996
4689
|
useAuth: () => useAuth,
|
|
3997
|
-
useAuthLegacy: () => useAuth2
|
|
4690
|
+
useAuthLegacy: () => useAuth2,
|
|
4691
|
+
useAuthTheme: () => useAuthTheme
|
|
3998
4692
|
});
|
|
3999
4693
|
|
|
4000
4694
|
// src/node/index.ts
|