@thetechfossil/auth2 1.2.3 → 1.2.5
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 +1284 -638
- package/dist/index.components.js.map +1 -1
- package/dist/index.components.mjs +1186 -543
- package/dist/index.components.mjs.map +1 -1
- package/dist/index.d.ts +48 -5
- package/dist/index.js +1364 -669
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1237 -544
- package/dist/index.mjs.map +1 -1
- package/dist/index.next.d.ts +41 -6
- package/dist/index.next.js +1382 -687
- package/dist/index.next.js.map +1 -1
- package/dist/index.next.mjs +1234 -544
- package/dist/index.next.mjs.map +1 -1
- package/dist/index.next.server.d.ts +16 -5
- package/dist/index.next.server.js +16 -9
- package/dist/index.next.server.js.map +1 -1
- package/dist/index.next.server.mjs +16 -9
- package/dist/index.next.server.mjs.map +1 -1
- package/dist/index.node.d.ts +16 -5
- package/dist/index.node.js +15 -9
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +15 -9
- package/dist/index.node.mjs.map +1 -1
- package/package.json +90 -87
- package/README.NEW.md +0 -365
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import axios from 'axios';
|
|
3
|
-
import { createContext, useState, useCallback, useEffect,
|
|
3
|
+
import React3, { createContext, forwardRef, useContext, useState, useCallback, useEffect, useRef, useMemo } from 'react';
|
|
4
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';
|
|
5
7
|
|
|
6
8
|
var __defProp = Object.defineProperty;
|
|
7
9
|
var __export = (target, all) => {
|
|
@@ -12,8 +14,9 @@ var HttpClient = class {
|
|
|
12
14
|
constructor(baseUrl, defaultHeaders = {}) {
|
|
13
15
|
this.csrfToken = null;
|
|
14
16
|
this.frontendBaseUrl = null;
|
|
17
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
15
18
|
this.axiosInstance = axios.create({
|
|
16
|
-
baseURL: baseUrl
|
|
19
|
+
baseURL: this.baseUrl,
|
|
17
20
|
headers: {
|
|
18
21
|
"Content-Type": "application/json",
|
|
19
22
|
...defaultHeaders
|
|
@@ -24,8 +27,16 @@ var HttpClient = class {
|
|
|
24
27
|
// 30 second timeout
|
|
25
28
|
});
|
|
26
29
|
this.axiosInstance.interceptors.request.use(
|
|
27
|
-
(config) => {
|
|
28
|
-
|
|
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) {
|
|
29
40
|
config.headers["x-csrf-token"] = this.csrfToken;
|
|
30
41
|
}
|
|
31
42
|
if (this.frontendBaseUrl) {
|
|
@@ -123,9 +134,6 @@ var AuthService = class {
|
|
|
123
134
|
this.httpClient.setFrontendBaseUrl(frontendBaseUrl);
|
|
124
135
|
}
|
|
125
136
|
}
|
|
126
|
-
if (this.config.csrfEnabled && typeof window !== "undefined") {
|
|
127
|
-
this.refreshCsrfToken();
|
|
128
|
-
}
|
|
129
137
|
}
|
|
130
138
|
loadTokenFromStorage() {
|
|
131
139
|
if (typeof window !== "undefined" && this.config.localStorageKey) {
|
|
@@ -227,7 +235,7 @@ var AuthService = class {
|
|
|
227
235
|
this.saveTokenToStorage(response.token);
|
|
228
236
|
return response;
|
|
229
237
|
}
|
|
230
|
-
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.")) {
|
|
231
239
|
return response;
|
|
232
240
|
}
|
|
233
241
|
if (response.success && response.message === "OTP verified successfully." && response.token) {
|
|
@@ -298,7 +306,7 @@ var AuthService = class {
|
|
|
298
306
|
if (!this.token) {
|
|
299
307
|
throw new Error("Not authenticated");
|
|
300
308
|
}
|
|
301
|
-
const response = await this.httpClient.post("/api/v1/user/update/
|
|
309
|
+
const response = await this.httpClient.post("/api/v1/user/update/profile", data);
|
|
302
310
|
if (response.success && response.token) {
|
|
303
311
|
this.token = response.token;
|
|
304
312
|
this.httpClient.setAuthToken(response.token);
|
|
@@ -339,7 +347,7 @@ var AuthService = class {
|
|
|
339
347
|
if (!this.token) {
|
|
340
348
|
throw new Error("Not authenticated");
|
|
341
349
|
}
|
|
342
|
-
const response = await this.httpClient.post("/api/v1/user/update/
|
|
350
|
+
const response = await this.httpClient.post("/api/v1/user/update/profile", { avatar });
|
|
343
351
|
if (response.success && response.token) {
|
|
344
352
|
this.token = response.token;
|
|
345
353
|
this.httpClient.setAuthToken(response.token);
|
|
@@ -462,6 +470,57 @@ var AuthService = class {
|
|
|
462
470
|
return response;
|
|
463
471
|
}
|
|
464
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
|
+
}
|
|
465
524
|
var AuthContext = createContext(void 0);
|
|
466
525
|
var AuthProvider = ({ children, config }) => {
|
|
467
526
|
const authConfig = {
|
|
@@ -725,7 +784,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
725
784
|
revokeAllSessions,
|
|
726
785
|
authService
|
|
727
786
|
};
|
|
728
|
-
return /* @__PURE__ */ jsx(AuthContext.Provider, { value, children });
|
|
787
|
+
return /* @__PURE__ */ jsx(AuthContext.Provider, { value, children: /* @__PURE__ */ jsx(AuthThemeProvider, { children }) });
|
|
729
788
|
};
|
|
730
789
|
var useAuth = () => {
|
|
731
790
|
const context = useContext(AuthContext);
|
|
@@ -864,6 +923,267 @@ var useAuth2 = (config) => {
|
|
|
864
923
|
getUserById
|
|
865
924
|
};
|
|
866
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
|
+
};
|
|
867
1187
|
var LoginForm = ({
|
|
868
1188
|
onSuccess,
|
|
869
1189
|
onLoginSuccess,
|
|
@@ -873,7 +1193,10 @@ var LoginForm = ({
|
|
|
873
1193
|
oauthProviders = ["google", "github"],
|
|
874
1194
|
showOAuthButtons = true
|
|
875
1195
|
}) => {
|
|
1196
|
+
const colors = useThemeColors();
|
|
876
1197
|
const [email, setEmail] = useState("");
|
|
1198
|
+
const [phoneNumber, setPhoneNumber] = useState("");
|
|
1199
|
+
const [usePhone, setUsePhone] = useState(false);
|
|
877
1200
|
const [password, setPassword] = useState("");
|
|
878
1201
|
const [usePassword, setUsePassword] = useState(false);
|
|
879
1202
|
const [showPassword, setShowPassword] = useState(false);
|
|
@@ -881,7 +1204,7 @@ var LoginForm = ({
|
|
|
881
1204
|
const [error, setError] = useState(null);
|
|
882
1205
|
const [rememberMe, setRememberMe] = useState(false);
|
|
883
1206
|
const { login } = useAuth2({
|
|
884
|
-
baseUrl: config?.baseUrl ||
|
|
1207
|
+
baseUrl: config?.baseUrl || "http://localhost:7000"
|
|
885
1208
|
});
|
|
886
1209
|
const handleSubmit = async (e) => {
|
|
887
1210
|
e.preventDefault();
|
|
@@ -889,20 +1212,28 @@ var LoginForm = ({
|
|
|
889
1212
|
setError(null);
|
|
890
1213
|
try {
|
|
891
1214
|
let response;
|
|
1215
|
+
const loginData = {};
|
|
1216
|
+
if (usePhone && phoneNumber) {
|
|
1217
|
+
loginData.phoneNumber = phoneNumber;
|
|
1218
|
+
} else if (email) {
|
|
1219
|
+
loginData.email = email;
|
|
1220
|
+
}
|
|
892
1221
|
if (usePassword) {
|
|
893
|
-
|
|
1222
|
+
loginData.password = password;
|
|
1223
|
+
response = await login(loginData);
|
|
894
1224
|
} else {
|
|
895
|
-
response = await login(
|
|
1225
|
+
response = await login(loginData);
|
|
896
1226
|
}
|
|
897
1227
|
if (response.success) {
|
|
898
1228
|
onSuccess?.(response);
|
|
899
1229
|
if (onLoginSuccess) {
|
|
900
|
-
|
|
901
|
-
|
|
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);
|
|
902
1233
|
} else if (response.token) {
|
|
903
|
-
onLoginSuccess(
|
|
1234
|
+
onLoginSuccess(identifier, false);
|
|
904
1235
|
} else {
|
|
905
|
-
onLoginSuccess(
|
|
1236
|
+
onLoginSuccess(identifier, true);
|
|
906
1237
|
}
|
|
907
1238
|
}
|
|
908
1239
|
} else {
|
|
@@ -924,43 +1255,53 @@ var LoginForm = ({
|
|
|
924
1255
|
return /* @__PURE__ */ jsx("div", { style: {
|
|
925
1256
|
maxWidth: "400px",
|
|
926
1257
|
margin: "0 auto",
|
|
927
|
-
padding: "
|
|
1258
|
+
padding: "24px",
|
|
928
1259
|
borderRadius: "12px",
|
|
929
1260
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
930
|
-
backgroundColor:
|
|
931
|
-
border:
|
|
1261
|
+
backgroundColor: colors.bgPrimary,
|
|
1262
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
932
1263
|
}, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, style: {
|
|
933
1264
|
display: "flex",
|
|
934
1265
|
flexDirection: "column"
|
|
935
1266
|
}, children: [
|
|
936
1267
|
/* @__PURE__ */ jsx("h2", { style: {
|
|
937
1268
|
textAlign: "center",
|
|
938
|
-
marginBottom: "
|
|
939
|
-
color:
|
|
1269
|
+
marginBottom: "20px",
|
|
1270
|
+
color: colors.textPrimary,
|
|
940
1271
|
fontSize: "24px",
|
|
941
1272
|
fontWeight: 600
|
|
942
1273
|
}, children: usePassword ? "Login with Password" : "Login with OTP" }),
|
|
943
1274
|
error && /* @__PURE__ */ jsx("div", { style: {
|
|
944
1275
|
padding: "12px 16px",
|
|
945
|
-
marginBottom: "
|
|
946
|
-
backgroundColor:
|
|
947
|
-
color:
|
|
948
|
-
border:
|
|
1276
|
+
marginBottom: "16px",
|
|
1277
|
+
backgroundColor: colors.errorBg,
|
|
1278
|
+
color: colors.errorText,
|
|
1279
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
949
1280
|
borderRadius: "8px",
|
|
950
1281
|
fontSize: "14px",
|
|
951
1282
|
fontWeight: 500
|
|
952
1283
|
}, children: error }),
|
|
953
1284
|
/* @__PURE__ */ jsxs("div", { style: {
|
|
954
|
-
marginBottom: "
|
|
1285
|
+
marginBottom: "16px"
|
|
955
1286
|
}, children: [
|
|
956
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "email", style: {
|
|
1287
|
+
/* @__PURE__ */ jsx("label", { htmlFor: usePhone ? "phone" : "email", style: {
|
|
957
1288
|
display: "block",
|
|
958
1289
|
marginBottom: "8px",
|
|
959
1290
|
fontWeight: 500,
|
|
960
|
-
color:
|
|
1291
|
+
color: colors.textSecondary,
|
|
961
1292
|
fontSize: "14px"
|
|
962
|
-
}, children: "Email:" }),
|
|
963
|
-
/* @__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(
|
|
964
1305
|
"input",
|
|
965
1306
|
{
|
|
966
1307
|
id: "email",
|
|
@@ -972,27 +1313,48 @@ var LoginForm = ({
|
|
|
972
1313
|
style: {
|
|
973
1314
|
width: "100%",
|
|
974
1315
|
padding: "12px 16px",
|
|
975
|
-
border:
|
|
1316
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
976
1317
|
borderRadius: "8px",
|
|
977
1318
|
fontSize: "16px",
|
|
978
1319
|
boxSizing: "border-box",
|
|
979
|
-
color:
|
|
1320
|
+
color: colors.textPrimary,
|
|
980
1321
|
transition: "all 0.2s ease",
|
|
981
|
-
backgroundColor:
|
|
1322
|
+
backgroundColor: colors.bgSecondary
|
|
982
1323
|
},
|
|
983
1324
|
placeholder: "Enter your email"
|
|
984
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
|
+
}
|
|
985
1347
|
)
|
|
986
1348
|
] }),
|
|
987
1349
|
usePassword && /* @__PURE__ */ jsxs("div", { style: {
|
|
988
|
-
marginBottom: "
|
|
1350
|
+
marginBottom: "16px",
|
|
989
1351
|
position: "relative"
|
|
990
1352
|
}, children: [
|
|
991
1353
|
/* @__PURE__ */ jsx("label", { htmlFor: "login-password", style: {
|
|
992
1354
|
display: "block",
|
|
993
1355
|
marginBottom: "8px",
|
|
994
1356
|
fontWeight: 500,
|
|
995
|
-
color:
|
|
1357
|
+
color: colors.textSecondary,
|
|
996
1358
|
fontSize: "14px"
|
|
997
1359
|
}, children: "Password:" }),
|
|
998
1360
|
/* @__PURE__ */ jsx(
|
|
@@ -1007,13 +1369,13 @@ var LoginForm = ({
|
|
|
1007
1369
|
style: {
|
|
1008
1370
|
width: "100%",
|
|
1009
1371
|
padding: "12px 16px",
|
|
1010
|
-
border:
|
|
1372
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1011
1373
|
borderRadius: "8px",
|
|
1012
1374
|
fontSize: "16px",
|
|
1013
1375
|
boxSizing: "border-box",
|
|
1014
|
-
color:
|
|
1376
|
+
color: colors.textPrimary,
|
|
1015
1377
|
transition: "all 0.2s ease",
|
|
1016
|
-
backgroundColor:
|
|
1378
|
+
backgroundColor: colors.bgSecondary
|
|
1017
1379
|
},
|
|
1018
1380
|
placeholder: "Enter your password"
|
|
1019
1381
|
}
|
|
@@ -1031,7 +1393,7 @@ var LoginForm = ({
|
|
|
1031
1393
|
background: "none",
|
|
1032
1394
|
border: "none",
|
|
1033
1395
|
cursor: "pointer",
|
|
1034
|
-
color:
|
|
1396
|
+
color: colors.textTertiary,
|
|
1035
1397
|
fontSize: "14px"
|
|
1036
1398
|
},
|
|
1037
1399
|
children: showPassword ? "Hide" : "Show"
|
|
@@ -1041,8 +1403,8 @@ var LoginForm = ({
|
|
|
1041
1403
|
usePassword && /* @__PURE__ */ jsxs("div", { style: {
|
|
1042
1404
|
display: "flex",
|
|
1043
1405
|
alignItems: "center",
|
|
1044
|
-
marginBottom: "
|
|
1045
|
-
marginTop: "
|
|
1406
|
+
marginBottom: "12px",
|
|
1407
|
+
marginTop: "4px"
|
|
1046
1408
|
}, children: [
|
|
1047
1409
|
/* @__PURE__ */ jsx(
|
|
1048
1410
|
"input",
|
|
@@ -1066,7 +1428,7 @@ var LoginForm = ({
|
|
|
1066
1428
|
htmlFor: "remember-me",
|
|
1067
1429
|
style: {
|
|
1068
1430
|
fontSize: "14px",
|
|
1069
|
-
color:
|
|
1431
|
+
color: colors.textSecondary,
|
|
1070
1432
|
cursor: "pointer",
|
|
1071
1433
|
userSelect: "none"
|
|
1072
1434
|
},
|
|
@@ -1081,7 +1443,7 @@ var LoginForm = ({
|
|
|
1081
1443
|
disabled: isLoading,
|
|
1082
1444
|
style: {
|
|
1083
1445
|
padding: "14px",
|
|
1084
|
-
backgroundColor:
|
|
1446
|
+
backgroundColor: colors.buttonPrimary,
|
|
1085
1447
|
color: "white",
|
|
1086
1448
|
border: "none",
|
|
1087
1449
|
borderRadius: "8px",
|
|
@@ -1089,16 +1451,16 @@ var LoginForm = ({
|
|
|
1089
1451
|
fontWeight: 600,
|
|
1090
1452
|
cursor: "pointer",
|
|
1091
1453
|
transition: "all 0.2s ease",
|
|
1092
|
-
marginTop: "
|
|
1454
|
+
marginTop: "4px"
|
|
1093
1455
|
},
|
|
1094
1456
|
children: isLoading ? usePassword ? "Logging in..." : "Sending OTP..." : usePassword ? "Login" : "Send OTP"
|
|
1095
1457
|
}
|
|
1096
1458
|
),
|
|
1097
1459
|
/* @__PURE__ */ jsx("div", { style: {
|
|
1098
1460
|
textAlign: "center",
|
|
1099
|
-
marginTop: "
|
|
1100
|
-
paddingTop: "
|
|
1101
|
-
borderTop:
|
|
1461
|
+
marginTop: "16px",
|
|
1462
|
+
paddingTop: "16px",
|
|
1463
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1102
1464
|
}, children: /* @__PURE__ */ jsx(
|
|
1103
1465
|
"button",
|
|
1104
1466
|
{
|
|
@@ -1108,7 +1470,7 @@ var LoginForm = ({
|
|
|
1108
1470
|
style: {
|
|
1109
1471
|
background: "none",
|
|
1110
1472
|
border: "none",
|
|
1111
|
-
color:
|
|
1473
|
+
color: colors.buttonPrimary,
|
|
1112
1474
|
textDecoration: "none",
|
|
1113
1475
|
cursor: "pointer",
|
|
1114
1476
|
fontSize: "14px",
|
|
@@ -1120,9 +1482,9 @@ var LoginForm = ({
|
|
|
1120
1482
|
}
|
|
1121
1483
|
) }),
|
|
1122
1484
|
showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxs("div", { style: {
|
|
1123
|
-
marginTop: "
|
|
1124
|
-
paddingTop: "
|
|
1125
|
-
borderTop:
|
|
1485
|
+
marginTop: "16px",
|
|
1486
|
+
paddingTop: "16px",
|
|
1487
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1126
1488
|
}, children: [
|
|
1127
1489
|
/* @__PURE__ */ jsxs("div", { style: {
|
|
1128
1490
|
position: "relative",
|
|
@@ -1134,15 +1496,15 @@ var LoginForm = ({
|
|
|
1134
1496
|
left: 0,
|
|
1135
1497
|
right: 0,
|
|
1136
1498
|
height: "1px",
|
|
1137
|
-
backgroundColor:
|
|
1499
|
+
backgroundColor: colors.borderPrimary
|
|
1138
1500
|
} }),
|
|
1139
1501
|
/* @__PURE__ */ jsx("div", { style: {
|
|
1140
1502
|
position: "relative",
|
|
1141
1503
|
textAlign: "center"
|
|
1142
1504
|
}, children: /* @__PURE__ */ jsx("span", { style: {
|
|
1143
|
-
backgroundColor:
|
|
1505
|
+
backgroundColor: colors.bgPrimary,
|
|
1144
1506
|
padding: "0 12px",
|
|
1145
|
-
color:
|
|
1507
|
+
color: colors.textSecondary,
|
|
1146
1508
|
fontSize: "14px"
|
|
1147
1509
|
}, children: "Or continue with" }) })
|
|
1148
1510
|
] }),
|
|
@@ -1161,10 +1523,10 @@ var LoginForm = ({
|
|
|
1161
1523
|
justifyContent: "center",
|
|
1162
1524
|
gap: "8px",
|
|
1163
1525
|
padding: "10px 16px",
|
|
1164
|
-
backgroundColor:
|
|
1165
|
-
border:
|
|
1526
|
+
backgroundColor: colors.bgPrimary,
|
|
1527
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1166
1528
|
borderRadius: "8px",
|
|
1167
|
-
color:
|
|
1529
|
+
color: colors.textPrimary,
|
|
1168
1530
|
textDecoration: "none",
|
|
1169
1531
|
fontSize: "14px",
|
|
1170
1532
|
fontWeight: 500,
|
|
@@ -1172,12 +1534,12 @@ var LoginForm = ({
|
|
|
1172
1534
|
transition: "all 0.2s ease"
|
|
1173
1535
|
},
|
|
1174
1536
|
onMouseEnter: (e) => {
|
|
1175
|
-
e.currentTarget.style.backgroundColor =
|
|
1176
|
-
e.currentTarget.style.borderColor =
|
|
1537
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
1538
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
1177
1539
|
},
|
|
1178
1540
|
onMouseLeave: (e) => {
|
|
1179
|
-
e.currentTarget.style.backgroundColor =
|
|
1180
|
-
e.currentTarget.style.borderColor =
|
|
1541
|
+
e.currentTarget.style.backgroundColor = colors.bgPrimary;
|
|
1542
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
1181
1543
|
},
|
|
1182
1544
|
children: [
|
|
1183
1545
|
/* @__PURE__ */ jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
|
|
@@ -1252,11 +1614,11 @@ var LoginForm = ({
|
|
|
1252
1614
|
] }),
|
|
1253
1615
|
showRegisterLink && /* @__PURE__ */ jsx("div", { style: {
|
|
1254
1616
|
textAlign: "center",
|
|
1255
|
-
marginTop: "
|
|
1256
|
-
paddingTop: "
|
|
1257
|
-
borderTop:
|
|
1617
|
+
marginTop: "16px",
|
|
1618
|
+
paddingTop: "16px",
|
|
1619
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1258
1620
|
}, children: /* @__PURE__ */ jsxs("p", { style: {
|
|
1259
|
-
color:
|
|
1621
|
+
color: colors.textSecondary,
|
|
1260
1622
|
fontSize: "14px"
|
|
1261
1623
|
}, children: [
|
|
1262
1624
|
"Don't have an account?",
|
|
@@ -1270,7 +1632,7 @@ var LoginForm = ({
|
|
|
1270
1632
|
style: {
|
|
1271
1633
|
background: "none",
|
|
1272
1634
|
border: "none",
|
|
1273
|
-
color:
|
|
1635
|
+
color: colors.buttonPrimary,
|
|
1274
1636
|
textDecoration: "none",
|
|
1275
1637
|
cursor: "pointer",
|
|
1276
1638
|
fontSize: "14px",
|
|
@@ -1290,10 +1652,13 @@ var RegisterForm = ({
|
|
|
1290
1652
|
showLoginLink = true,
|
|
1291
1653
|
authConfig,
|
|
1292
1654
|
oauthProviders = ["google", "github"],
|
|
1293
|
-
showOAuthButtons = true
|
|
1655
|
+
showOAuthButtons = true,
|
|
1656
|
+
invitationToken
|
|
1294
1657
|
}) => {
|
|
1658
|
+
const colors = useThemeColors();
|
|
1295
1659
|
const [name, setName] = useState("");
|
|
1296
1660
|
const [email, setEmail] = useState("");
|
|
1661
|
+
const [phoneNumber, setPhoneNumber] = useState("");
|
|
1297
1662
|
const [password, setPassword] = useState("");
|
|
1298
1663
|
const [confirmPassword, setConfirmPassword] = useState("");
|
|
1299
1664
|
const [isLoading, setIsLoading] = useState(false);
|
|
@@ -1322,7 +1687,7 @@ var RegisterForm = ({
|
|
|
1322
1687
|
};
|
|
1323
1688
|
getPasswordStrength(password);
|
|
1324
1689
|
const config = authConfig || {
|
|
1325
|
-
baseUrl:
|
|
1690
|
+
baseUrl: "http://localhost:7000"
|
|
1326
1691
|
};
|
|
1327
1692
|
const { register } = useAuth2(config);
|
|
1328
1693
|
const handleSubmit = async (e) => {
|
|
@@ -1340,17 +1705,45 @@ var RegisterForm = ({
|
|
|
1340
1705
|
return;
|
|
1341
1706
|
}
|
|
1342
1707
|
try {
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
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
|
+
}
|
|
1352
1731
|
} else {
|
|
1353
|
-
|
|
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
|
+
}
|
|
1354
1747
|
}
|
|
1355
1748
|
} catch (err) {
|
|
1356
1749
|
setError(err instanceof Error ? err.message : "An unknown error occurred");
|
|
@@ -1361,40 +1754,40 @@ var RegisterForm = ({
|
|
|
1361
1754
|
return /* @__PURE__ */ jsx("div", { style: {
|
|
1362
1755
|
maxWidth: "400px",
|
|
1363
1756
|
margin: "0 auto",
|
|
1364
|
-
padding: "
|
|
1757
|
+
padding: "24px",
|
|
1365
1758
|
borderRadius: "12px",
|
|
1366
1759
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
1367
|
-
backgroundColor:
|
|
1368
|
-
border:
|
|
1760
|
+
backgroundColor: colors.bgPrimary,
|
|
1761
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
1369
1762
|
}, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, style: {
|
|
1370
1763
|
display: "flex",
|
|
1371
1764
|
flexDirection: "column"
|
|
1372
1765
|
}, children: [
|
|
1373
1766
|
/* @__PURE__ */ jsx("h2", { style: {
|
|
1374
1767
|
textAlign: "center",
|
|
1375
|
-
marginBottom: "
|
|
1376
|
-
color:
|
|
1768
|
+
marginBottom: "20px",
|
|
1769
|
+
color: colors.textPrimary,
|
|
1377
1770
|
fontSize: "24px",
|
|
1378
1771
|
fontWeight: 600
|
|
1379
1772
|
}, children: "Register" }),
|
|
1380
1773
|
error && /* @__PURE__ */ jsx("div", { style: {
|
|
1381
1774
|
padding: "12px 16px",
|
|
1382
|
-
marginBottom: "
|
|
1383
|
-
backgroundColor:
|
|
1384
|
-
color:
|
|
1385
|
-
border:
|
|
1775
|
+
marginBottom: "16px",
|
|
1776
|
+
backgroundColor: colors.errorBg,
|
|
1777
|
+
color: colors.errorText,
|
|
1778
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
1386
1779
|
borderRadius: "8px",
|
|
1387
1780
|
fontSize: "14px",
|
|
1388
1781
|
fontWeight: 500
|
|
1389
1782
|
}, children: error }),
|
|
1390
1783
|
/* @__PURE__ */ jsxs("div", { style: {
|
|
1391
|
-
marginBottom: "
|
|
1784
|
+
marginBottom: "16px"
|
|
1392
1785
|
}, children: [
|
|
1393
1786
|
/* @__PURE__ */ jsx("label", { htmlFor: "name", style: {
|
|
1394
1787
|
display: "block",
|
|
1395
1788
|
marginBottom: "8px",
|
|
1396
1789
|
fontWeight: 500,
|
|
1397
|
-
color:
|
|
1790
|
+
color: colors.textSecondary,
|
|
1398
1791
|
fontSize: "14px"
|
|
1399
1792
|
}, children: "Name:" }),
|
|
1400
1793
|
/* @__PURE__ */ jsx(
|
|
@@ -1409,26 +1802,26 @@ var RegisterForm = ({
|
|
|
1409
1802
|
style: {
|
|
1410
1803
|
width: "100%",
|
|
1411
1804
|
padding: "12px 16px",
|
|
1412
|
-
border:
|
|
1805
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1413
1806
|
borderRadius: "8px",
|
|
1414
1807
|
fontSize: "16px",
|
|
1415
1808
|
boxSizing: "border-box",
|
|
1416
|
-
color:
|
|
1809
|
+
color: colors.textPrimary,
|
|
1417
1810
|
transition: "all 0.2s ease",
|
|
1418
|
-
backgroundColor:
|
|
1811
|
+
backgroundColor: colors.bgSecondary
|
|
1419
1812
|
},
|
|
1420
1813
|
placeholder: "Enter your name"
|
|
1421
1814
|
}
|
|
1422
1815
|
)
|
|
1423
1816
|
] }),
|
|
1424
1817
|
/* @__PURE__ */ jsxs("div", { style: {
|
|
1425
|
-
marginBottom: "
|
|
1818
|
+
marginBottom: "16px"
|
|
1426
1819
|
}, children: [
|
|
1427
1820
|
/* @__PURE__ */ jsx("label", { htmlFor: "register-email", style: {
|
|
1428
1821
|
display: "block",
|
|
1429
1822
|
marginBottom: "8px",
|
|
1430
1823
|
fontWeight: 500,
|
|
1431
|
-
color:
|
|
1824
|
+
color: colors.textSecondary,
|
|
1432
1825
|
fontSize: "14px"
|
|
1433
1826
|
}, children: "Email:" }),
|
|
1434
1827
|
/* @__PURE__ */ jsx(
|
|
@@ -1438,31 +1831,52 @@ var RegisterForm = ({
|
|
|
1438
1831
|
type: "email",
|
|
1439
1832
|
value: email,
|
|
1440
1833
|
onChange: (e) => setEmail(e.target.value),
|
|
1441
|
-
required:
|
|
1834
|
+
required: !phoneNumber,
|
|
1442
1835
|
disabled: isLoading,
|
|
1443
1836
|
style: {
|
|
1444
1837
|
width: "100%",
|
|
1445
1838
|
padding: "12px 16px",
|
|
1446
|
-
border:
|
|
1839
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1447
1840
|
borderRadius: "8px",
|
|
1448
1841
|
fontSize: "16px",
|
|
1449
1842
|
boxSizing: "border-box",
|
|
1450
|
-
color:
|
|
1843
|
+
color: colors.textPrimary,
|
|
1451
1844
|
transition: "all 0.2s ease",
|
|
1452
|
-
backgroundColor:
|
|
1845
|
+
backgroundColor: colors.bgSecondary
|
|
1453
1846
|
},
|
|
1454
1847
|
placeholder: "Enter your email"
|
|
1455
1848
|
}
|
|
1456
1849
|
)
|
|
1457
1850
|
] }),
|
|
1458
1851
|
/* @__PURE__ */ jsxs("div", { style: {
|
|
1459
|
-
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"
|
|
1460
1874
|
}, children: [
|
|
1461
1875
|
/* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
|
|
1462
1876
|
display: "block",
|
|
1463
1877
|
marginBottom: "8px",
|
|
1464
1878
|
fontWeight: 500,
|
|
1465
|
-
color:
|
|
1879
|
+
color: colors.textSecondary,
|
|
1466
1880
|
fontSize: "14px"
|
|
1467
1881
|
}, children: "Password:" }),
|
|
1468
1882
|
/* @__PURE__ */ jsx(
|
|
@@ -1477,13 +1891,13 @@ var RegisterForm = ({
|
|
|
1477
1891
|
style: {
|
|
1478
1892
|
width: "100%",
|
|
1479
1893
|
padding: "12px 16px",
|
|
1480
|
-
border:
|
|
1894
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1481
1895
|
borderRadius: "8px",
|
|
1482
1896
|
fontSize: "16px",
|
|
1483
1897
|
boxSizing: "border-box",
|
|
1484
|
-
color:
|
|
1898
|
+
color: colors.textPrimary,
|
|
1485
1899
|
transition: "all 0.2s ease",
|
|
1486
|
-
backgroundColor:
|
|
1900
|
+
backgroundColor: colors.bgSecondary
|
|
1487
1901
|
},
|
|
1488
1902
|
placeholder: "Enter your password",
|
|
1489
1903
|
minLength: 6
|
|
@@ -1491,13 +1905,13 @@ var RegisterForm = ({
|
|
|
1491
1905
|
)
|
|
1492
1906
|
] }),
|
|
1493
1907
|
/* @__PURE__ */ jsxs("div", { style: {
|
|
1494
|
-
marginBottom: "
|
|
1908
|
+
marginBottom: "16px"
|
|
1495
1909
|
}, children: [
|
|
1496
1910
|
/* @__PURE__ */ jsx("label", { htmlFor: "confirm-password", style: {
|
|
1497
1911
|
display: "block",
|
|
1498
1912
|
marginBottom: "8px",
|
|
1499
1913
|
fontWeight: 500,
|
|
1500
|
-
color:
|
|
1914
|
+
color: colors.textSecondary,
|
|
1501
1915
|
fontSize: "14px"
|
|
1502
1916
|
}, children: "Confirm Password:" }),
|
|
1503
1917
|
/* @__PURE__ */ jsx(
|
|
@@ -1512,13 +1926,13 @@ var RegisterForm = ({
|
|
|
1512
1926
|
style: {
|
|
1513
1927
|
width: "100%",
|
|
1514
1928
|
padding: "12px 16px",
|
|
1515
|
-
border:
|
|
1929
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1516
1930
|
borderRadius: "8px",
|
|
1517
1931
|
fontSize: "16px",
|
|
1518
1932
|
boxSizing: "border-box",
|
|
1519
|
-
color:
|
|
1933
|
+
color: colors.textPrimary,
|
|
1520
1934
|
transition: "all 0.2s ease",
|
|
1521
|
-
backgroundColor:
|
|
1935
|
+
backgroundColor: colors.bgSecondary
|
|
1522
1936
|
},
|
|
1523
1937
|
placeholder: "Confirm your password"
|
|
1524
1938
|
}
|
|
@@ -1531,7 +1945,7 @@ var RegisterForm = ({
|
|
|
1531
1945
|
disabled: isLoading,
|
|
1532
1946
|
style: {
|
|
1533
1947
|
padding: "14px",
|
|
1534
|
-
backgroundColor:
|
|
1948
|
+
backgroundColor: colors.buttonPrimary,
|
|
1535
1949
|
color: "white",
|
|
1536
1950
|
border: "none",
|
|
1537
1951
|
borderRadius: "8px",
|
|
@@ -1539,15 +1953,15 @@ var RegisterForm = ({
|
|
|
1539
1953
|
fontWeight: 600,
|
|
1540
1954
|
cursor: "pointer",
|
|
1541
1955
|
transition: "all 0.2s ease",
|
|
1542
|
-
marginTop: "
|
|
1956
|
+
marginTop: "4px"
|
|
1543
1957
|
},
|
|
1544
1958
|
children: isLoading ? "Registering..." : "Register"
|
|
1545
1959
|
}
|
|
1546
1960
|
),
|
|
1547
1961
|
showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxs("div", { style: {
|
|
1548
|
-
marginTop: "
|
|
1549
|
-
paddingTop: "
|
|
1550
|
-
borderTop:
|
|
1962
|
+
marginTop: "16px",
|
|
1963
|
+
paddingTop: "16px",
|
|
1964
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1551
1965
|
}, children: [
|
|
1552
1966
|
/* @__PURE__ */ jsxs("div", { style: {
|
|
1553
1967
|
position: "relative",
|
|
@@ -1559,15 +1973,15 @@ var RegisterForm = ({
|
|
|
1559
1973
|
left: 0,
|
|
1560
1974
|
right: 0,
|
|
1561
1975
|
height: "1px",
|
|
1562
|
-
backgroundColor:
|
|
1976
|
+
backgroundColor: colors.borderPrimary
|
|
1563
1977
|
} }),
|
|
1564
1978
|
/* @__PURE__ */ jsx("div", { style: {
|
|
1565
1979
|
position: "relative",
|
|
1566
1980
|
textAlign: "center"
|
|
1567
1981
|
}, children: /* @__PURE__ */ jsx("span", { style: {
|
|
1568
|
-
backgroundColor:
|
|
1982
|
+
backgroundColor: colors.bgPrimary,
|
|
1569
1983
|
padding: "0 12px",
|
|
1570
|
-
color:
|
|
1984
|
+
color: colors.textSecondary,
|
|
1571
1985
|
fontSize: "14px"
|
|
1572
1986
|
}, children: "Or continue with" }) })
|
|
1573
1987
|
] }),
|
|
@@ -1586,10 +2000,10 @@ var RegisterForm = ({
|
|
|
1586
2000
|
justifyContent: "center",
|
|
1587
2001
|
gap: "8px",
|
|
1588
2002
|
padding: "10px 16px",
|
|
1589
|
-
backgroundColor:
|
|
1590
|
-
border:
|
|
2003
|
+
backgroundColor: colors.bgPrimary,
|
|
2004
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1591
2005
|
borderRadius: "8px",
|
|
1592
|
-
color:
|
|
2006
|
+
color: colors.textPrimary,
|
|
1593
2007
|
textDecoration: "none",
|
|
1594
2008
|
fontSize: "14px",
|
|
1595
2009
|
fontWeight: 500,
|
|
@@ -1597,12 +2011,12 @@ var RegisterForm = ({
|
|
|
1597
2011
|
transition: "all 0.2s ease"
|
|
1598
2012
|
},
|
|
1599
2013
|
onMouseEnter: (e) => {
|
|
1600
|
-
e.currentTarget.style.backgroundColor =
|
|
1601
|
-
e.currentTarget.style.borderColor =
|
|
2014
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
2015
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
1602
2016
|
},
|
|
1603
2017
|
onMouseLeave: (e) => {
|
|
1604
|
-
e.currentTarget.style.backgroundColor =
|
|
1605
|
-
e.currentTarget.style.borderColor =
|
|
2018
|
+
e.currentTarget.style.backgroundColor = colors.bgPrimary;
|
|
2019
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
1606
2020
|
},
|
|
1607
2021
|
children: [
|
|
1608
2022
|
/* @__PURE__ */ jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
|
|
@@ -1677,11 +2091,11 @@ var RegisterForm = ({
|
|
|
1677
2091
|
] }),
|
|
1678
2092
|
showLoginLink && /* @__PURE__ */ jsx("div", { style: {
|
|
1679
2093
|
textAlign: "center",
|
|
1680
|
-
marginTop: "
|
|
1681
|
-
paddingTop: "
|
|
1682
|
-
borderTop:
|
|
2094
|
+
marginTop: "16px",
|
|
2095
|
+
paddingTop: "16px",
|
|
2096
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1683
2097
|
}, children: /* @__PURE__ */ jsxs("p", { style: {
|
|
1684
|
-
color:
|
|
2098
|
+
color: colors.textSecondary,
|
|
1685
2099
|
fontSize: "14px"
|
|
1686
2100
|
}, children: [
|
|
1687
2101
|
"Already have an account?",
|
|
@@ -1695,7 +2109,7 @@ var RegisterForm = ({
|
|
|
1695
2109
|
style: {
|
|
1696
2110
|
background: "none",
|
|
1697
2111
|
border: "none",
|
|
1698
|
-
color:
|
|
2112
|
+
color: colors.buttonPrimary,
|
|
1699
2113
|
textDecoration: "none",
|
|
1700
2114
|
cursor: "pointer",
|
|
1701
2115
|
fontSize: "14px",
|
|
@@ -1712,15 +2126,17 @@ var RegisterForm = ({
|
|
|
1712
2126
|
var OtpForm = ({
|
|
1713
2127
|
email,
|
|
1714
2128
|
onVerifySuccess,
|
|
1715
|
-
onBackToLogin
|
|
2129
|
+
onBackToLogin,
|
|
2130
|
+
baseUrl
|
|
1716
2131
|
}) => {
|
|
2132
|
+
const colors = useThemeColors();
|
|
1717
2133
|
const [otp, setOtp] = useState("");
|
|
1718
2134
|
const [isLoading, setIsLoading] = useState(false);
|
|
1719
2135
|
const [error, setError] = useState(null);
|
|
1720
2136
|
const [resendCooldown, setResendCooldown] = useState(0);
|
|
1721
2137
|
const [resendLoading, setResendLoading] = useState(false);
|
|
1722
2138
|
const { verify, login } = useAuth2({
|
|
1723
|
-
baseUrl:
|
|
2139
|
+
baseUrl: baseUrl || process.env.NEXT_PUBLIC_AUTH_API_URL || "http://localhost:7000"
|
|
1724
2140
|
});
|
|
1725
2141
|
const handleSubmit = async (e) => {
|
|
1726
2142
|
e.preventDefault();
|
|
@@ -1783,8 +2199,8 @@ var OtpForm = ({
|
|
|
1783
2199
|
padding: "30px",
|
|
1784
2200
|
borderRadius: "12px",
|
|
1785
2201
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
1786
|
-
backgroundColor:
|
|
1787
|
-
border:
|
|
2202
|
+
backgroundColor: colors.bgPrimary,
|
|
2203
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
1788
2204
|
}, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, style: {
|
|
1789
2205
|
display: "flex",
|
|
1790
2206
|
flexDirection: "column"
|
|
@@ -1792,25 +2208,25 @@ var OtpForm = ({
|
|
|
1792
2208
|
/* @__PURE__ */ jsx("h2", { style: {
|
|
1793
2209
|
textAlign: "center",
|
|
1794
2210
|
marginBottom: "24px",
|
|
1795
|
-
color:
|
|
2211
|
+
color: colors.textPrimary,
|
|
1796
2212
|
fontSize: "24px",
|
|
1797
2213
|
fontWeight: 600
|
|
1798
2214
|
}, children: "Verify OTP" }),
|
|
1799
2215
|
/* @__PURE__ */ jsxs("p", { style: {
|
|
1800
2216
|
textAlign: "center",
|
|
1801
2217
|
marginBottom: "24px",
|
|
1802
|
-
color:
|
|
2218
|
+
color: colors.textSecondary,
|
|
1803
2219
|
fontSize: "14px"
|
|
1804
2220
|
}, children: [
|
|
1805
2221
|
"Enter the 6-digit code sent to ",
|
|
1806
|
-
/* @__PURE__ */ jsx("strong", { style: { color:
|
|
2222
|
+
/* @__PURE__ */ jsx("strong", { style: { color: colors.textPrimary }, children: email })
|
|
1807
2223
|
] }),
|
|
1808
2224
|
error && /* @__PURE__ */ jsx("div", { style: {
|
|
1809
2225
|
padding: "12px 16px",
|
|
1810
2226
|
marginBottom: "20px",
|
|
1811
|
-
backgroundColor:
|
|
1812
|
-
color:
|
|
1813
|
-
border:
|
|
2227
|
+
backgroundColor: colors.errorBg,
|
|
2228
|
+
color: colors.errorText,
|
|
2229
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
1814
2230
|
borderRadius: "8px",
|
|
1815
2231
|
fontSize: "14px",
|
|
1816
2232
|
fontWeight: 500
|
|
@@ -1822,7 +2238,7 @@ var OtpForm = ({
|
|
|
1822
2238
|
display: "block",
|
|
1823
2239
|
marginBottom: "8px",
|
|
1824
2240
|
fontWeight: 500,
|
|
1825
|
-
color:
|
|
2241
|
+
color: colors.textSecondary,
|
|
1826
2242
|
fontSize: "14px"
|
|
1827
2243
|
}, children: "OTP Code:" }),
|
|
1828
2244
|
/* @__PURE__ */ jsx(
|
|
@@ -1837,13 +2253,13 @@ var OtpForm = ({
|
|
|
1837
2253
|
style: {
|
|
1838
2254
|
width: "100%",
|
|
1839
2255
|
padding: "12px 16px",
|
|
1840
|
-
border:
|
|
2256
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1841
2257
|
borderRadius: "8px",
|
|
1842
2258
|
fontSize: "20px",
|
|
1843
2259
|
boxSizing: "border-box",
|
|
1844
|
-
color:
|
|
2260
|
+
color: colors.textPrimary,
|
|
1845
2261
|
transition: "all 0.2s ease",
|
|
1846
|
-
backgroundColor:
|
|
2262
|
+
backgroundColor: colors.bgSecondary,
|
|
1847
2263
|
textAlign: "center",
|
|
1848
2264
|
letterSpacing: "5px"
|
|
1849
2265
|
},
|
|
@@ -1860,7 +2276,7 @@ var OtpForm = ({
|
|
|
1860
2276
|
disabled: isLoading || otp.length !== 6,
|
|
1861
2277
|
style: {
|
|
1862
2278
|
padding: "14px",
|
|
1863
|
-
backgroundColor:
|
|
2279
|
+
backgroundColor: colors.buttonPrimary,
|
|
1864
2280
|
color: "white",
|
|
1865
2281
|
border: "none",
|
|
1866
2282
|
borderRadius: "8px",
|
|
@@ -1877,7 +2293,7 @@ var OtpForm = ({
|
|
|
1877
2293
|
textAlign: "center",
|
|
1878
2294
|
marginTop: "20px",
|
|
1879
2295
|
paddingTop: "20px",
|
|
1880
|
-
borderTop:
|
|
2296
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1881
2297
|
}, children: [
|
|
1882
2298
|
/* @__PURE__ */ jsx(
|
|
1883
2299
|
"button",
|
|
@@ -1888,7 +2304,7 @@ var OtpForm = ({
|
|
|
1888
2304
|
style: {
|
|
1889
2305
|
background: "none",
|
|
1890
2306
|
border: "none",
|
|
1891
|
-
color: resendCooldown > 0 ?
|
|
2307
|
+
color: resendCooldown > 0 ? colors.textTertiary : colors.buttonPrimary,
|
|
1892
2308
|
textDecoration: "none",
|
|
1893
2309
|
cursor: resendCooldown > 0 ? "not-allowed" : "pointer",
|
|
1894
2310
|
fontSize: "14px",
|
|
@@ -1911,7 +2327,7 @@ var OtpForm = ({
|
|
|
1911
2327
|
style: {
|
|
1912
2328
|
background: "none",
|
|
1913
2329
|
border: "none",
|
|
1914
|
-
color:
|
|
2330
|
+
color: colors.buttonPrimary,
|
|
1915
2331
|
textDecoration: "none",
|
|
1916
2332
|
cursor: "pointer",
|
|
1917
2333
|
fontSize: "14px",
|
|
@@ -2178,12 +2594,25 @@ var EmailVerificationPage = ({
|
|
|
2178
2594
|
] })
|
|
2179
2595
|
] }) });
|
|
2180
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";
|
|
2181
2607
|
var SignIn = ({ redirectUrl, appearance }) => {
|
|
2182
2608
|
const { signIn, isSignedIn, loading: authLoading } = useAuth();
|
|
2609
|
+
const colors = useThemeColors();
|
|
2183
2610
|
const [email, setEmail] = useState("");
|
|
2611
|
+
const [phoneNumber, setPhoneNumber] = useState("");
|
|
2184
2612
|
const [password, setPassword] = useState("");
|
|
2185
2613
|
const [otp, setOtp] = useState("");
|
|
2186
2614
|
const [usePassword, setUsePassword] = useState(false);
|
|
2615
|
+
const [usePhone, setUsePhone] = useState(false);
|
|
2187
2616
|
const [showPassword, setShowPassword] = useState(false);
|
|
2188
2617
|
const [isLoading, setIsLoading] = useState(false);
|
|
2189
2618
|
const [error, setError] = useState(null);
|
|
@@ -2202,25 +2631,26 @@ var SignIn = ({ redirectUrl, appearance }) => {
|
|
|
2202
2631
|
setError(null);
|
|
2203
2632
|
setSuccess(null);
|
|
2204
2633
|
try {
|
|
2634
|
+
const loginData = usePhone ? { phoneNumber } : { email };
|
|
2205
2635
|
if (needsOtp) {
|
|
2206
|
-
const response = await signIn({
|
|
2636
|
+
const response = await signIn({ ...loginData, otp });
|
|
2207
2637
|
if (response.success) {
|
|
2208
2638
|
setSuccess("Login successful!");
|
|
2209
2639
|
} else {
|
|
2210
2640
|
setError(response.message || "OTP verification failed");
|
|
2211
2641
|
}
|
|
2212
2642
|
} else if (usePassword) {
|
|
2213
|
-
const response = await signIn({
|
|
2643
|
+
const response = await signIn({ ...loginData, password });
|
|
2214
2644
|
if (response.success) {
|
|
2215
2645
|
setSuccess("Login successful!");
|
|
2216
2646
|
} else {
|
|
2217
2647
|
setError(response.message || "Login failed");
|
|
2218
2648
|
}
|
|
2219
2649
|
} else {
|
|
2220
|
-
const response = await signIn(
|
|
2221
|
-
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.")) {
|
|
2222
2652
|
setNeedsOtp(true);
|
|
2223
|
-
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.");
|
|
2224
2654
|
} else {
|
|
2225
2655
|
setError(response.message || "Failed to send OTP");
|
|
2226
2656
|
}
|
|
@@ -2238,222 +2668,350 @@ var SignIn = ({ redirectUrl, appearance }) => {
|
|
|
2238
2668
|
setSuccess(null);
|
|
2239
2669
|
setOtp("");
|
|
2240
2670
|
};
|
|
2671
|
+
const toggleLoginMethod = () => {
|
|
2672
|
+
setUsePhone(!usePhone);
|
|
2673
|
+
setNeedsOtp(false);
|
|
2674
|
+
setError(null);
|
|
2675
|
+
setSuccess(null);
|
|
2676
|
+
setOtp("");
|
|
2677
|
+
setEmail("");
|
|
2678
|
+
setPhoneNumber("");
|
|
2679
|
+
};
|
|
2241
2680
|
if (authLoading) {
|
|
2242
2681
|
return /* @__PURE__ */ jsx("div", { style: { textAlign: "center", padding: "40px" }, children: /* @__PURE__ */ jsx("div", { children: "Loading..." }) });
|
|
2243
2682
|
}
|
|
2244
|
-
return /* @__PURE__ */ jsx(
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
padding: "12px 16px",
|
|
2264
|
-
marginBottom: "20px",
|
|
2265
|
-
backgroundColor: "#fee",
|
|
2266
|
-
color: "#c33",
|
|
2267
|
-
border: "1px solid #fcc",
|
|
2268
|
-
borderRadius: "8px",
|
|
2269
|
-
fontSize: "14px"
|
|
2270
|
-
}, children: error }),
|
|
2271
|
-
success && /* @__PURE__ */ jsx("div", { style: {
|
|
2272
|
-
padding: "12px 16px",
|
|
2273
|
-
marginBottom: "20px",
|
|
2274
|
-
backgroundColor: "#efe",
|
|
2275
|
-
color: "#3c3",
|
|
2276
|
-
border: "1px solid #cfc",
|
|
2277
|
-
borderRadius: "8px",
|
|
2278
|
-
fontSize: "14px"
|
|
2279
|
-
}, children: success }),
|
|
2280
|
-
!needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2281
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "email", style: {
|
|
2282
|
-
display: "block",
|
|
2283
|
-
marginBottom: "8px",
|
|
2284
|
-
fontWeight: 500,
|
|
2285
|
-
color: "#374151",
|
|
2286
|
-
fontSize: "14px"
|
|
2287
|
-
}, children: "Email" }),
|
|
2288
|
-
/* @__PURE__ */ jsx(
|
|
2289
|
-
"input",
|
|
2290
|
-
{
|
|
2291
|
-
id: "email",
|
|
2292
|
-
type: "email",
|
|
2293
|
-
value: email,
|
|
2294
|
-
onChange: (e) => setEmail(e.target.value),
|
|
2295
|
-
required: true,
|
|
2296
|
-
disabled: isLoading,
|
|
2297
|
-
style: {
|
|
2298
|
-
width: "100%",
|
|
2299
|
-
padding: "12px 16px",
|
|
2300
|
-
border: "1px solid #ddd",
|
|
2301
|
-
borderRadius: "8px",
|
|
2302
|
-
fontSize: "16px",
|
|
2303
|
-
boxSizing: "border-box",
|
|
2304
|
-
...appearance?.elements?.formFieldInput
|
|
2305
|
-
},
|
|
2306
|
-
placeholder: "Enter your email"
|
|
2307
|
-
}
|
|
2308
|
-
)
|
|
2309
|
-
] }),
|
|
2310
|
-
usePassword && !needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
|
|
2311
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
|
|
2312
|
-
display: "block",
|
|
2313
|
-
marginBottom: "8px",
|
|
2314
|
-
fontWeight: 500,
|
|
2315
|
-
color: "#374151",
|
|
2316
|
-
fontSize: "14px"
|
|
2317
|
-
}, children: "Password" }),
|
|
2318
|
-
/* @__PURE__ */ jsx(
|
|
2319
|
-
"input",
|
|
2320
|
-
{
|
|
2321
|
-
id: "password",
|
|
2322
|
-
type: showPassword ? "text" : "password",
|
|
2323
|
-
value: password,
|
|
2324
|
-
onChange: (e) => setPassword(e.target.value),
|
|
2325
|
-
required: true,
|
|
2326
|
-
disabled: isLoading,
|
|
2327
|
-
style: {
|
|
2328
|
-
width: "100%",
|
|
2329
|
-
padding: "12px 16px",
|
|
2330
|
-
border: "1px solid #ddd",
|
|
2331
|
-
borderRadius: "8px",
|
|
2332
|
-
fontSize: "16px",
|
|
2333
|
-
boxSizing: "border-box",
|
|
2334
|
-
...appearance?.elements?.formFieldInput
|
|
2335
|
-
},
|
|
2336
|
-
placeholder: "Enter your password"
|
|
2337
|
-
}
|
|
2338
|
-
),
|
|
2339
|
-
/* @__PURE__ */ jsx(
|
|
2340
|
-
"button",
|
|
2341
|
-
{
|
|
2342
|
-
type: "button",
|
|
2343
|
-
onClick: () => setShowPassword(!showPassword),
|
|
2344
|
-
style: {
|
|
2345
|
-
position: "absolute",
|
|
2346
|
-
right: "12px",
|
|
2347
|
-
top: "38px",
|
|
2348
|
-
background: "none",
|
|
2349
|
-
border: "none",
|
|
2350
|
-
cursor: "pointer",
|
|
2351
|
-
color: "#666",
|
|
2352
|
-
fontSize: "14px"
|
|
2353
|
-
},
|
|
2354
|
-
children: showPassword ? "Hide" : "Show"
|
|
2355
|
-
}
|
|
2356
|
-
)
|
|
2357
|
-
] }),
|
|
2358
|
-
needsOtp && /* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2359
|
-
/* @__PURE__ */ jsx("label", { htmlFor: "otp", style: {
|
|
2360
|
-
display: "block",
|
|
2361
|
-
marginBottom: "8px",
|
|
2362
|
-
fontWeight: 500,
|
|
2363
|
-
color: "#374151",
|
|
2364
|
-
fontSize: "14px"
|
|
2365
|
-
}, children: "One-Time Password" }),
|
|
2366
|
-
/* @__PURE__ */ jsx(
|
|
2367
|
-
"input",
|
|
2368
|
-
{
|
|
2369
|
-
id: "otp",
|
|
2370
|
-
type: "text",
|
|
2371
|
-
value: otp,
|
|
2372
|
-
onChange: (e) => setOtp(e.target.value),
|
|
2373
|
-
required: true,
|
|
2374
|
-
disabled: isLoading,
|
|
2375
|
-
maxLength: 6,
|
|
2376
|
-
style: {
|
|
2377
|
-
width: "100%",
|
|
2378
|
-
padding: "12px 16px",
|
|
2379
|
-
border: "1px solid #ddd",
|
|
2380
|
-
borderRadius: "8px",
|
|
2381
|
-
fontSize: "16px",
|
|
2382
|
-
boxSizing: "border-box",
|
|
2383
|
-
letterSpacing: "0.5em",
|
|
2384
|
-
textAlign: "center",
|
|
2385
|
-
...appearance?.elements?.formFieldInput
|
|
2386
|
-
},
|
|
2387
|
-
placeholder: "000000"
|
|
2388
|
-
}
|
|
2389
|
-
)
|
|
2390
|
-
] }),
|
|
2391
|
-
/* @__PURE__ */ jsx(
|
|
2392
|
-
"button",
|
|
2393
|
-
{
|
|
2394
|
-
type: "submit",
|
|
2395
|
-
disabled: isLoading,
|
|
2396
|
-
style: {
|
|
2397
|
-
width: "100%",
|
|
2398
|
-
padding: "14px",
|
|
2399
|
-
backgroundColor: "#007bff",
|
|
2400
|
-
color: "white",
|
|
2401
|
-
border: "none",
|
|
2402
|
-
borderRadius: "8px",
|
|
2403
|
-
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",
|
|
2404
2702
|
fontWeight: 600,
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
fontSize: "14px"
|
|
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
|
-
|
|
2451
|
-
|
|
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
|
+
);
|
|
2452
3008
|
};
|
|
2453
3009
|
var SignUp = ({ redirectUrl, appearance }) => {
|
|
2454
3010
|
const { signUp, isSignedIn } = useAuth();
|
|
3011
|
+
const colors = useThemeColors();
|
|
2455
3012
|
const [name, setName] = useState("");
|
|
2456
3013
|
const [email, setEmail] = useState("");
|
|
3014
|
+
const [phoneNumber, setPhoneNumber] = useState("");
|
|
2457
3015
|
const [password, setPassword] = useState("");
|
|
2458
3016
|
const [confirmPassword, setConfirmPassword] = useState("");
|
|
2459
3017
|
const [showPassword, setShowPassword] = useState(false);
|
|
@@ -2467,9 +3025,9 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2467
3025
|
window.location.href = `${baseUrl}${redirect}`;
|
|
2468
3026
|
}
|
|
2469
3027
|
}, [isSignedIn, redirectUrl]);
|
|
2470
|
-
const getPasswordStrength = (pwd) => {
|
|
3028
|
+
const getPasswordStrength = (pwd, colors2) => {
|
|
2471
3029
|
if (!pwd)
|
|
2472
|
-
return { strength: "weak", color:
|
|
3030
|
+
return { strength: "weak", color: colors2.borderSecondary };
|
|
2473
3031
|
let score = 0;
|
|
2474
3032
|
if (pwd.length >= 6)
|
|
2475
3033
|
score++;
|
|
@@ -2482,12 +3040,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2482
3040
|
if (/[^a-zA-Z\d]/.test(pwd))
|
|
2483
3041
|
score++;
|
|
2484
3042
|
if (score <= 2)
|
|
2485
|
-
return { strength: "weak", color:
|
|
3043
|
+
return { strength: "weak", color: colors2.errorText };
|
|
2486
3044
|
if (score <= 3)
|
|
2487
|
-
return { strength: "medium", color: "#fa4" };
|
|
2488
|
-
return { strength: "strong", color:
|
|
3045
|
+
return { strength: "medium", color: colors2.warningText || "#fa4" };
|
|
3046
|
+
return { strength: "strong", color: colors2.successText };
|
|
2489
3047
|
};
|
|
2490
|
-
const passwordStrength = getPasswordStrength(password);
|
|
3048
|
+
const passwordStrength = getPasswordStrength(password, colors);
|
|
2491
3049
|
const handleSubmit = async (e) => {
|
|
2492
3050
|
e.preventDefault();
|
|
2493
3051
|
setIsLoading(true);
|
|
@@ -2504,7 +3062,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2504
3062
|
return;
|
|
2505
3063
|
}
|
|
2506
3064
|
try {
|
|
2507
|
-
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);
|
|
2508
3071
|
if (response.success) {
|
|
2509
3072
|
setSuccess("Registration successful! Please check your email to verify your account.");
|
|
2510
3073
|
} else {
|
|
@@ -2516,20 +3079,20 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2516
3079
|
setIsLoading(false);
|
|
2517
3080
|
}
|
|
2518
3081
|
};
|
|
2519
|
-
return /* @__PURE__ */ jsx(
|
|
3082
|
+
return /* @__PURE__ */ jsx(ThemeWrapper, { style: {
|
|
2520
3083
|
maxWidth: "400px",
|
|
2521
3084
|
margin: "0 auto",
|
|
2522
3085
|
padding: "30px",
|
|
2523
3086
|
borderRadius: "12px",
|
|
2524
3087
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
2525
|
-
backgroundColor:
|
|
2526
|
-
border:
|
|
3088
|
+
backgroundColor: colors.bgPrimary,
|
|
3089
|
+
border: `1px solid ${colors.borderPrimary}`,
|
|
2527
3090
|
...appearance?.elements?.card
|
|
2528
3091
|
}, children: /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, children: [
|
|
2529
3092
|
/* @__PURE__ */ jsx("h2", { style: {
|
|
2530
3093
|
textAlign: "center",
|
|
2531
3094
|
marginBottom: "24px",
|
|
2532
|
-
color:
|
|
3095
|
+
color: colors.textPrimary,
|
|
2533
3096
|
fontSize: "24px",
|
|
2534
3097
|
fontWeight: 600,
|
|
2535
3098
|
...appearance?.elements?.headerTitle
|
|
@@ -2537,18 +3100,18 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2537
3100
|
error && /* @__PURE__ */ jsx("div", { style: {
|
|
2538
3101
|
padding: "12px 16px",
|
|
2539
3102
|
marginBottom: "20px",
|
|
2540
|
-
backgroundColor:
|
|
2541
|
-
color:
|
|
2542
|
-
border:
|
|
3103
|
+
backgroundColor: colors.errorBg,
|
|
3104
|
+
color: colors.errorText,
|
|
3105
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
2543
3106
|
borderRadius: "8px",
|
|
2544
3107
|
fontSize: "14px"
|
|
2545
3108
|
}, children: error }),
|
|
2546
3109
|
success && /* @__PURE__ */ jsx("div", { style: {
|
|
2547
3110
|
padding: "12px 16px",
|
|
2548
3111
|
marginBottom: "20px",
|
|
2549
|
-
backgroundColor:
|
|
2550
|
-
color:
|
|
2551
|
-
border:
|
|
3112
|
+
backgroundColor: colors.successBg,
|
|
3113
|
+
color: colors.successText,
|
|
3114
|
+
border: `1px solid ${colors.successBorder}`,
|
|
2552
3115
|
borderRadius: "8px",
|
|
2553
3116
|
fontSize: "14px"
|
|
2554
3117
|
}, children: success }),
|
|
@@ -2557,7 +3120,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2557
3120
|
display: "block",
|
|
2558
3121
|
marginBottom: "8px",
|
|
2559
3122
|
fontWeight: 500,
|
|
2560
|
-
color:
|
|
3123
|
+
color: colors.textSecondary,
|
|
2561
3124
|
fontSize: "14px"
|
|
2562
3125
|
}, children: "Full name" }),
|
|
2563
3126
|
/* @__PURE__ */ jsx(
|
|
@@ -2567,15 +3130,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2567
3130
|
type: "text",
|
|
2568
3131
|
value: name,
|
|
2569
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
|
+
},
|
|
2570
3141
|
required: true,
|
|
2571
3142
|
disabled: isLoading,
|
|
2572
3143
|
style: {
|
|
2573
3144
|
width: "100%",
|
|
2574
3145
|
padding: "12px 16px",
|
|
2575
|
-
border:
|
|
3146
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2576
3147
|
borderRadius: "8px",
|
|
2577
3148
|
fontSize: "16px",
|
|
2578
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`,
|
|
2579
3155
|
...appearance?.elements?.formFieldInput
|
|
2580
3156
|
},
|
|
2581
3157
|
placeholder: "Enter your full name"
|
|
@@ -2587,7 +3163,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2587
3163
|
display: "block",
|
|
2588
3164
|
marginBottom: "8px",
|
|
2589
3165
|
fontWeight: 500,
|
|
2590
|
-
color:
|
|
3166
|
+
color: colors.textSecondary,
|
|
2591
3167
|
fontSize: "14px"
|
|
2592
3168
|
}, children: "Email" }),
|
|
2593
3169
|
/* @__PURE__ */ jsx(
|
|
@@ -2597,27 +3173,60 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2597
3173
|
type: "email",
|
|
2598
3174
|
value: email,
|
|
2599
3175
|
onChange: (e) => setEmail(e.target.value),
|
|
2600
|
-
|
|
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,
|
|
2601
3185
|
disabled: isLoading,
|
|
2602
3186
|
style: {
|
|
2603
3187
|
width: "100%",
|
|
2604
3188
|
padding: "12px 16px",
|
|
2605
|
-
border:
|
|
3189
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2606
3190
|
borderRadius: "8px",
|
|
2607
3191
|
fontSize: "16px",
|
|
2608
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`,
|
|
2609
3198
|
...appearance?.elements?.formFieldInput
|
|
2610
3199
|
},
|
|
2611
3200
|
placeholder: "Enter your email"
|
|
2612
3201
|
}
|
|
2613
3202
|
)
|
|
2614
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
|
+
] }),
|
|
2615
3224
|
/* @__PURE__ */ jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
|
|
2616
3225
|
/* @__PURE__ */ jsx("label", { htmlFor: "password", style: {
|
|
2617
3226
|
display: "block",
|
|
2618
3227
|
marginBottom: "8px",
|
|
2619
3228
|
fontWeight: 500,
|
|
2620
|
-
color:
|
|
3229
|
+
color: colors.textSecondary,
|
|
2621
3230
|
fontSize: "14px"
|
|
2622
3231
|
}, children: "Password" }),
|
|
2623
3232
|
/* @__PURE__ */ jsx(
|
|
@@ -2627,16 +3236,29 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2627
3236
|
type: showPassword ? "text" : "password",
|
|
2628
3237
|
value: password,
|
|
2629
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
|
+
},
|
|
2630
3247
|
required: true,
|
|
2631
3248
|
disabled: isLoading,
|
|
2632
3249
|
minLength: 6,
|
|
2633
3250
|
style: {
|
|
2634
3251
|
width: "100%",
|
|
2635
3252
|
padding: "12px 16px",
|
|
2636
|
-
border:
|
|
3253
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2637
3254
|
borderRadius: "8px",
|
|
2638
3255
|
fontSize: "16px",
|
|
2639
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`,
|
|
2640
3262
|
...appearance?.elements?.formFieldInput
|
|
2641
3263
|
},
|
|
2642
3264
|
placeholder: "Create a password"
|
|
@@ -2654,7 +3276,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2654
3276
|
background: "none",
|
|
2655
3277
|
border: "none",
|
|
2656
3278
|
cursor: "pointer",
|
|
2657
|
-
color:
|
|
3279
|
+
color: colors.textTertiary,
|
|
2658
3280
|
fontSize: "14px"
|
|
2659
3281
|
},
|
|
2660
3282
|
children: showPassword ? "Hide" : "Show"
|
|
@@ -2663,7 +3285,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2663
3285
|
password && /* @__PURE__ */ jsxs("div", { style: { marginTop: "8px" }, children: [
|
|
2664
3286
|
/* @__PURE__ */ jsx("div", { style: {
|
|
2665
3287
|
height: "4px",
|
|
2666
|
-
backgroundColor:
|
|
3288
|
+
backgroundColor: colors.borderSecondary,
|
|
2667
3289
|
borderRadius: "2px",
|
|
2668
3290
|
overflow: "hidden"
|
|
2669
3291
|
}, children: /* @__PURE__ */ jsx("div", { style: {
|
|
@@ -2688,7 +3310,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2688
3310
|
display: "block",
|
|
2689
3311
|
marginBottom: "8px",
|
|
2690
3312
|
fontWeight: 500,
|
|
2691
|
-
color:
|
|
3313
|
+
color: colors.textSecondary,
|
|
2692
3314
|
fontSize: "14px"
|
|
2693
3315
|
}, children: "Confirm password" }),
|
|
2694
3316
|
/* @__PURE__ */ jsx(
|
|
@@ -2698,15 +3320,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2698
3320
|
type: showPassword ? "text" : "password",
|
|
2699
3321
|
value: confirmPassword,
|
|
2700
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
|
+
},
|
|
2701
3331
|
required: true,
|
|
2702
3332
|
disabled: isLoading,
|
|
2703
3333
|
style: {
|
|
2704
3334
|
width: "100%",
|
|
2705
3335
|
padding: "12px 16px",
|
|
2706
|
-
border:
|
|
3336
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2707
3337
|
borderRadius: "8px",
|
|
2708
3338
|
fontSize: "16px",
|
|
2709
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`,
|
|
2710
3345
|
...appearance?.elements?.formFieldInput
|
|
2711
3346
|
},
|
|
2712
3347
|
placeholder: "Confirm your password"
|
|
@@ -2718,16 +3353,25 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2718
3353
|
{
|
|
2719
3354
|
type: "submit",
|
|
2720
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
|
+
},
|
|
2721
3364
|
style: {
|
|
2722
3365
|
width: "100%",
|
|
2723
3366
|
padding: "14px",
|
|
2724
|
-
backgroundColor:
|
|
3367
|
+
backgroundColor: colors.buttonPrimary,
|
|
2725
3368
|
color: "white",
|
|
2726
3369
|
border: "none",
|
|
2727
3370
|
borderRadius: "8px",
|
|
2728
3371
|
fontSize: "16px",
|
|
2729
3372
|
fontWeight: 600,
|
|
2730
|
-
cursor: "pointer",
|
|
3373
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
3374
|
+
opacity: isLoading ? 0.6 : 1,
|
|
2731
3375
|
transition: "all 0.2s ease",
|
|
2732
3376
|
...appearance?.elements?.formButtonPrimary
|
|
2733
3377
|
},
|
|
@@ -2751,6 +3395,7 @@ var SignOut = ({ redirectUrl }) => {
|
|
|
2751
3395
|
};
|
|
2752
3396
|
var UserButton = ({ showName = false, appearance }) => {
|
|
2753
3397
|
const { user, signOut } = useAuth();
|
|
3398
|
+
const colors = useThemeColors();
|
|
2754
3399
|
const [isOpen, setIsOpen] = useState(false);
|
|
2755
3400
|
const dropdownRef = useRef(null);
|
|
2756
3401
|
useEffect(() => {
|
|
@@ -2773,7 +3418,7 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2773
3418
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2774
3419
|
window.location.href = `${baseUrl}${redirect}`;
|
|
2775
3420
|
};
|
|
2776
|
-
return /* @__PURE__ */ jsxs(
|
|
3421
|
+
return /* @__PURE__ */ jsxs(ThemeWrapper, { style: { position: "relative", ...appearance?.elements?.userButtonBox }, ref: dropdownRef, children: [
|
|
2777
3422
|
/* @__PURE__ */ jsxs(
|
|
2778
3423
|
"button",
|
|
2779
3424
|
{
|
|
@@ -2791,7 +3436,7 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2791
3436
|
...appearance?.elements?.userButtonTrigger
|
|
2792
3437
|
},
|
|
2793
3438
|
onMouseEnter: (e) => {
|
|
2794
|
-
e.currentTarget.style.backgroundColor =
|
|
3439
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
2795
3440
|
},
|
|
2796
3441
|
onMouseLeave: (e) => {
|
|
2797
3442
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
@@ -2801,15 +3446,15 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2801
3446
|
width: "36px",
|
|
2802
3447
|
height: "36px",
|
|
2803
3448
|
borderRadius: "50%",
|
|
2804
|
-
backgroundColor:
|
|
2805
|
-
color:
|
|
3449
|
+
backgroundColor: colors.buttonPrimary,
|
|
3450
|
+
color: colors.textPrimary,
|
|
2806
3451
|
display: "flex",
|
|
2807
3452
|
alignItems: "center",
|
|
2808
3453
|
justifyContent: "center",
|
|
2809
3454
|
fontSize: "14px",
|
|
2810
3455
|
fontWeight: 600
|
|
2811
3456
|
}, children: getInitials(user.name) }),
|
|
2812
|
-
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 })
|
|
2813
3458
|
]
|
|
2814
3459
|
}
|
|
2815
3460
|
),
|
|
@@ -2819,16 +3464,16 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2819
3464
|
right: 0,
|
|
2820
3465
|
marginTop: "8px",
|
|
2821
3466
|
width: "240px",
|
|
2822
|
-
backgroundColor:
|
|
3467
|
+
backgroundColor: colors.bgPrimary,
|
|
2823
3468
|
borderRadius: "12px",
|
|
2824
3469
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.15)",
|
|
2825
|
-
border:
|
|
3470
|
+
border: `1px solid ${colors.borderPrimary}`,
|
|
2826
3471
|
zIndex: 1e3,
|
|
2827
3472
|
...appearance?.elements?.userButtonPopoverCard
|
|
2828
3473
|
}, children: [
|
|
2829
3474
|
/* @__PURE__ */ jsx("div", { style: {
|
|
2830
3475
|
padding: "16px",
|
|
2831
|
-
borderBottom:
|
|
3476
|
+
borderBottom: `1px solid ${colors.borderPrimary}`
|
|
2832
3477
|
}, children: /* @__PURE__ */ jsxs("div", { style: {
|
|
2833
3478
|
display: "flex",
|
|
2834
3479
|
alignItems: "center",
|
|
@@ -2838,8 +3483,8 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2838
3483
|
width: "48px",
|
|
2839
3484
|
height: "48px",
|
|
2840
3485
|
borderRadius: "50%",
|
|
2841
|
-
backgroundColor:
|
|
2842
|
-
color:
|
|
3486
|
+
backgroundColor: colors.buttonPrimary,
|
|
3487
|
+
color: colors.textPrimary,
|
|
2843
3488
|
display: "flex",
|
|
2844
3489
|
alignItems: "center",
|
|
2845
3490
|
justifyContent: "center",
|
|
@@ -2850,14 +3495,14 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2850
3495
|
/* @__PURE__ */ jsx("div", { style: {
|
|
2851
3496
|
fontSize: "14px",
|
|
2852
3497
|
fontWeight: 600,
|
|
2853
|
-
color:
|
|
3498
|
+
color: colors.textPrimary,
|
|
2854
3499
|
overflow: "hidden",
|
|
2855
3500
|
textOverflow: "ellipsis",
|
|
2856
3501
|
whiteSpace: "nowrap"
|
|
2857
3502
|
}, children: user.name }),
|
|
2858
3503
|
/* @__PURE__ */ jsx("div", { style: {
|
|
2859
3504
|
fontSize: "12px",
|
|
2860
|
-
color:
|
|
3505
|
+
color: colors.textTertiary,
|
|
2861
3506
|
overflow: "hidden",
|
|
2862
3507
|
textOverflow: "ellipsis",
|
|
2863
3508
|
whiteSpace: "nowrap"
|
|
@@ -2877,12 +3522,12 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2877
3522
|
textAlign: "left",
|
|
2878
3523
|
cursor: "pointer",
|
|
2879
3524
|
fontSize: "14px",
|
|
2880
|
-
color:
|
|
3525
|
+
color: colors.textPrimary,
|
|
2881
3526
|
fontWeight: 500,
|
|
2882
3527
|
transition: "background-color 0.2s"
|
|
2883
3528
|
},
|
|
2884
3529
|
onMouseEnter: (e) => {
|
|
2885
|
-
e.currentTarget.style.backgroundColor =
|
|
3530
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
2886
3531
|
},
|
|
2887
3532
|
onMouseLeave: (e) => {
|
|
2888
3533
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
@@ -3735,43 +4380,41 @@ var UserProfile = ({
|
|
|
3735
4380
|
showEmailChange = true,
|
|
3736
4381
|
showPasswordChange = true
|
|
3737
4382
|
}) => {
|
|
3738
|
-
const { user, updateProfile,
|
|
4383
|
+
const { user, updateProfile, requestEmailChange } = useAuth();
|
|
4384
|
+
const colors = useThemeColors();
|
|
3739
4385
|
const [name, setName] = useState(user?.name || "");
|
|
3740
|
-
const [avatar, setAvatar] = useState("");
|
|
4386
|
+
const [avatar, setAvatar] = useState(user?.avatar || "");
|
|
4387
|
+
const [phoneNumber, setPhoneNumber] = useState(user?.phoneNumber || "");
|
|
3741
4388
|
const [newEmail, setNewEmail] = useState("");
|
|
3742
4389
|
const [isLoading, setIsLoading] = useState(false);
|
|
3743
4390
|
const [error, setError] = useState(null);
|
|
3744
4391
|
const [success, setSuccess] = useState(null);
|
|
3745
|
-
const
|
|
4392
|
+
const handleUpdateProfile = async (e) => {
|
|
3746
4393
|
e.preventDefault();
|
|
3747
4394
|
setIsLoading(true);
|
|
3748
4395
|
setError(null);
|
|
3749
4396
|
setSuccess(null);
|
|
3750
4397
|
try {
|
|
3751
|
-
const
|
|
3752
|
-
if (
|
|
3753
|
-
|
|
3754
|
-
} else {
|
|
3755
|
-
setError(response.message || "Failed to update name");
|
|
4398
|
+
const updates = {};
|
|
4399
|
+
if (name !== user?.name) {
|
|
4400
|
+
updates.name = name;
|
|
3756
4401
|
}
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
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);
|
|
3770
4414
|
if (response.success) {
|
|
3771
|
-
setSuccess("
|
|
3772
|
-
setAvatar("");
|
|
4415
|
+
setSuccess("Profile updated successfully!");
|
|
3773
4416
|
} else {
|
|
3774
|
-
setError(response.message || "Failed to update
|
|
4417
|
+
setError(response.message || "Failed to update profile");
|
|
3775
4418
|
}
|
|
3776
4419
|
} catch (err) {
|
|
3777
4420
|
setError(err instanceof Error ? err.message : "An error occurred");
|
|
@@ -3800,173 +4443,220 @@ var UserProfile = ({
|
|
|
3800
4443
|
};
|
|
3801
4444
|
if (!user)
|
|
3802
4445
|
return null;
|
|
3803
|
-
return /* @__PURE__ */ jsxs("div", { style: { maxWidth: "
|
|
3804
|
-
/* @__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" }),
|
|
3805
4448
|
error && /* @__PURE__ */ jsx("div", { style: {
|
|
3806
4449
|
padding: "12px 16px",
|
|
3807
4450
|
marginBottom: "20px",
|
|
3808
|
-
backgroundColor:
|
|
3809
|
-
color:
|
|
3810
|
-
border:
|
|
4451
|
+
backgroundColor: colors.errorBg,
|
|
4452
|
+
color: colors.errorText,
|
|
4453
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
3811
4454
|
borderRadius: "8px",
|
|
3812
4455
|
fontSize: "14px"
|
|
3813
4456
|
}, children: error }),
|
|
3814
4457
|
success && /* @__PURE__ */ jsx("div", { style: {
|
|
3815
4458
|
padding: "12px 16px",
|
|
3816
4459
|
marginBottom: "20px",
|
|
3817
|
-
backgroundColor:
|
|
3818
|
-
color:
|
|
3819
|
-
border:
|
|
4460
|
+
backgroundColor: colors.successBg,
|
|
4461
|
+
color: colors.successText,
|
|
4462
|
+
border: `1px solid ${colors.successBorder}`,
|
|
3820
4463
|
borderRadius: "8px",
|
|
3821
4464
|
fontSize: "14px"
|
|
3822
4465
|
}, children: success }),
|
|
3823
4466
|
/* @__PURE__ */ jsxs("div", { style: {
|
|
3824
|
-
padding: "
|
|
3825
|
-
backgroundColor:
|
|
3826
|
-
borderRadius: "
|
|
4467
|
+
padding: "24px",
|
|
4468
|
+
backgroundColor: colors.bgPrimary,
|
|
4469
|
+
borderRadius: "12px",
|
|
3827
4470
|
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3828
|
-
marginBottom: "
|
|
4471
|
+
marginBottom: "24px",
|
|
4472
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
3829
4473
|
}, children: [
|
|
3830
|
-
/* @__PURE__ */ jsx("h3", { style: { marginBottom: "
|
|
3831
|
-
/* @__PURE__ */ jsxs("form", { onSubmit:
|
|
3832
|
-
/* @__PURE__ */
|
|
3833
|
-
"
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
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
|
+
] }),
|
|
3852
4558
|
/* @__PURE__ */ jsx(
|
|
3853
4559
|
"button",
|
|
3854
4560
|
{
|
|
3855
4561
|
type: "submit",
|
|
3856
4562
|
disabled: isLoading,
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
border: "none",
|
|
3862
|
-
borderRadius: "8px",
|
|
3863
|
-
fontSize: "14px",
|
|
3864
|
-
fontWeight: 600,
|
|
3865
|
-
cursor: "pointer"
|
|
4563
|
+
onMouseEnter: (e) => {
|
|
4564
|
+
if (!isLoading) {
|
|
4565
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
|
|
4566
|
+
}
|
|
3866
4567
|
},
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
)
|
|
3870
|
-
] })
|
|
3871
|
-
] }),
|
|
3872
|
-
showAvatar && /* @__PURE__ */ jsxs("div", { style: {
|
|
3873
|
-
padding: "20px",
|
|
3874
|
-
backgroundColor: "#fff",
|
|
3875
|
-
borderRadius: "8px",
|
|
3876
|
-
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3877
|
-
marginBottom: "20px"
|
|
3878
|
-
}, children: [
|
|
3879
|
-
/* @__PURE__ */ jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Update Avatar" }),
|
|
3880
|
-
/* @__PURE__ */ jsxs("form", { onSubmit: handleUpdateAvatar, children: [
|
|
3881
|
-
/* @__PURE__ */ jsx(
|
|
3882
|
-
"input",
|
|
3883
|
-
{
|
|
3884
|
-
type: "url",
|
|
3885
|
-
value: avatar,
|
|
3886
|
-
onChange: (e) => setAvatar(e.target.value),
|
|
3887
|
-
required: true,
|
|
3888
|
-
disabled: isLoading,
|
|
3889
|
-
style: {
|
|
3890
|
-
width: "100%",
|
|
3891
|
-
padding: "12px 16px",
|
|
3892
|
-
border: "1px solid #ddd",
|
|
3893
|
-
borderRadius: "8px",
|
|
3894
|
-
fontSize: "16px",
|
|
3895
|
-
boxSizing: "border-box",
|
|
3896
|
-
marginBottom: "12px"
|
|
4568
|
+
onMouseLeave: (e) => {
|
|
4569
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimary;
|
|
3897
4570
|
},
|
|
3898
|
-
placeholder: "Avatar URL"
|
|
3899
|
-
}
|
|
3900
|
-
),
|
|
3901
|
-
/* @__PURE__ */ jsx(
|
|
3902
|
-
"button",
|
|
3903
|
-
{
|
|
3904
|
-
type: "submit",
|
|
3905
|
-
disabled: isLoading,
|
|
3906
4571
|
style: {
|
|
3907
|
-
padding: "
|
|
3908
|
-
backgroundColor:
|
|
4572
|
+
padding: "12px 24px",
|
|
4573
|
+
backgroundColor: colors.buttonPrimary,
|
|
3909
4574
|
color: "white",
|
|
3910
4575
|
border: "none",
|
|
3911
4576
|
borderRadius: "8px",
|
|
3912
4577
|
fontSize: "14px",
|
|
3913
4578
|
fontWeight: 600,
|
|
3914
|
-
cursor: "pointer"
|
|
4579
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
4580
|
+
opacity: isLoading ? 0.6 : 1,
|
|
4581
|
+
transition: "all 0.2s ease"
|
|
3915
4582
|
},
|
|
3916
|
-
children: "
|
|
4583
|
+
children: isLoading ? "Saving..." : "Save Changes"
|
|
3917
4584
|
}
|
|
3918
4585
|
)
|
|
3919
4586
|
] })
|
|
3920
4587
|
] }),
|
|
3921
4588
|
showEmailChange && /* @__PURE__ */ jsxs("div", { style: {
|
|
3922
|
-
padding: "
|
|
3923
|
-
backgroundColor:
|
|
3924
|
-
borderRadius: "
|
|
4589
|
+
padding: "24px",
|
|
4590
|
+
backgroundColor: colors.bgPrimary,
|
|
4591
|
+
borderRadius: "12px",
|
|
3925
4592
|
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3926
|
-
marginBottom: "20px"
|
|
4593
|
+
marginBottom: "20px",
|
|
4594
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
3927
4595
|
}, children: [
|
|
3928
|
-
/* @__PURE__ */ jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Change Email" }),
|
|
3929
|
-
/* @__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: [
|
|
3930
4598
|
"Current email: ",
|
|
3931
4599
|
/* @__PURE__ */ jsx("strong", { children: user.email })
|
|
3932
4600
|
] }),
|
|
3933
4601
|
/* @__PURE__ */ jsxs("form", { onSubmit: handleRequestEmailChange, children: [
|
|
3934
|
-
/* @__PURE__ */
|
|
3935
|
-
"
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
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
|
+
] }),
|
|
3954
4634
|
/* @__PURE__ */ jsx(
|
|
3955
4635
|
"button",
|
|
3956
4636
|
{
|
|
3957
4637
|
type: "submit",
|
|
3958
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
|
+
},
|
|
3959
4647
|
style: {
|
|
3960
|
-
padding: "
|
|
3961
|
-
backgroundColor:
|
|
4648
|
+
padding: "12px 24px",
|
|
4649
|
+
backgroundColor: colors.buttonPrimary,
|
|
3962
4650
|
color: "white",
|
|
3963
4651
|
border: "none",
|
|
3964
4652
|
borderRadius: "8px",
|
|
3965
4653
|
fontSize: "14px",
|
|
3966
4654
|
fontWeight: 600,
|
|
3967
|
-
cursor: "pointer"
|
|
4655
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
4656
|
+
opacity: isLoading ? 0.6 : 1,
|
|
4657
|
+
transition: "all 0.2s ease"
|
|
3968
4658
|
},
|
|
3969
|
-
children: "Request Email Change"
|
|
4659
|
+
children: isLoading ? "Sending..." : "Request Email Change"
|
|
3970
4660
|
}
|
|
3971
4661
|
)
|
|
3972
4662
|
] })
|
|
@@ -3979,11 +4669,13 @@ var react_exports = {};
|
|
|
3979
4669
|
__export(react_exports, {
|
|
3980
4670
|
AuthFlow: () => AuthFlow,
|
|
3981
4671
|
AuthProvider: () => AuthProvider,
|
|
4672
|
+
AuthThemeProvider: () => AuthThemeProvider,
|
|
3982
4673
|
ChangePassword: () => ChangePassword,
|
|
3983
4674
|
EmailVerificationPage: () => EmailVerificationPage,
|
|
3984
4675
|
ForgotPassword: () => ForgotPassword,
|
|
3985
4676
|
LoginForm: () => LoginForm,
|
|
3986
4677
|
OtpForm: () => OtpForm,
|
|
4678
|
+
PhoneInput: () => PhoneInput,
|
|
3987
4679
|
ProtectedRoute: () => ProtectedRoute,
|
|
3988
4680
|
PublicRoute: () => PublicRoute,
|
|
3989
4681
|
RegisterForm: () => RegisterForm,
|
|
@@ -3995,7 +4687,8 @@ __export(react_exports, {
|
|
|
3995
4687
|
UserProfile: () => UserProfile,
|
|
3996
4688
|
VerifyEmail: () => VerifyEmail,
|
|
3997
4689
|
useAuth: () => useAuth,
|
|
3998
|
-
useAuthLegacy: () => useAuth2
|
|
4690
|
+
useAuthLegacy: () => useAuth2,
|
|
4691
|
+
useAuthTheme: () => useAuthTheme
|
|
3999
4692
|
});
|
|
4000
4693
|
|
|
4001
4694
|
// src/node/index.ts
|