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