@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.js
CHANGED
|
@@ -2,12 +2,16 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var axios = require('axios');
|
|
5
|
-
var
|
|
5
|
+
var React3 = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var PhoneInputWithCountry = require('react-phone-number-input');
|
|
8
|
+
require('react-phone-number-input/style.css');
|
|
7
9
|
|
|
8
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
11
|
|
|
10
12
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
13
|
+
var React3__default = /*#__PURE__*/_interopDefault(React3);
|
|
14
|
+
var PhoneInputWithCountry__default = /*#__PURE__*/_interopDefault(PhoneInputWithCountry);
|
|
11
15
|
|
|
12
16
|
var __defProp = Object.defineProperty;
|
|
13
17
|
var __export = (target, all) => {
|
|
@@ -18,8 +22,9 @@ var HttpClient = class {
|
|
|
18
22
|
constructor(baseUrl, defaultHeaders = {}) {
|
|
19
23
|
this.csrfToken = null;
|
|
20
24
|
this.frontendBaseUrl = null;
|
|
25
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
21
26
|
this.axiosInstance = axios__default.default.create({
|
|
22
|
-
baseURL: baseUrl
|
|
27
|
+
baseURL: this.baseUrl,
|
|
23
28
|
headers: {
|
|
24
29
|
"Content-Type": "application/json",
|
|
25
30
|
...defaultHeaders
|
|
@@ -30,8 +35,16 @@ var HttpClient = class {
|
|
|
30
35
|
// 30 second timeout
|
|
31
36
|
});
|
|
32
37
|
this.axiosInstance.interceptors.request.use(
|
|
33
|
-
(config) => {
|
|
34
|
-
|
|
38
|
+
async (config) => {
|
|
39
|
+
const isMutatingRequest = ["post", "put", "delete", "patch"].includes(config.method?.toLowerCase() || "");
|
|
40
|
+
if (isMutatingRequest && !this.csrfToken && typeof window !== "undefined") {
|
|
41
|
+
try {
|
|
42
|
+
await this.refreshCsrfToken();
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.warn("Failed to fetch CSRF token:", error);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (this.csrfToken && isMutatingRequest) {
|
|
35
48
|
config.headers["x-csrf-token"] = this.csrfToken;
|
|
36
49
|
}
|
|
37
50
|
if (this.frontendBaseUrl) {
|
|
@@ -129,9 +142,6 @@ var AuthService = class {
|
|
|
129
142
|
this.httpClient.setFrontendBaseUrl(frontendBaseUrl);
|
|
130
143
|
}
|
|
131
144
|
}
|
|
132
|
-
if (this.config.csrfEnabled && typeof window !== "undefined") {
|
|
133
|
-
this.refreshCsrfToken();
|
|
134
|
-
}
|
|
135
145
|
}
|
|
136
146
|
loadTokenFromStorage() {
|
|
137
147
|
if (typeof window !== "undefined" && this.config.localStorageKey) {
|
|
@@ -233,7 +243,7 @@ var AuthService = class {
|
|
|
233
243
|
this.saveTokenToStorage(response.token);
|
|
234
244
|
return response;
|
|
235
245
|
}
|
|
236
|
-
if (response.success && response.message === "OTP sent to your email.") {
|
|
246
|
+
if (response.success && (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.")) {
|
|
237
247
|
return response;
|
|
238
248
|
}
|
|
239
249
|
if (response.success && response.message === "OTP verified successfully." && response.token) {
|
|
@@ -304,7 +314,7 @@ var AuthService = class {
|
|
|
304
314
|
if (!this.token) {
|
|
305
315
|
throw new Error("Not authenticated");
|
|
306
316
|
}
|
|
307
|
-
const response = await this.httpClient.post("/api/v1/user/update/
|
|
317
|
+
const response = await this.httpClient.post("/api/v1/user/update/profile", data);
|
|
308
318
|
if (response.success && response.token) {
|
|
309
319
|
this.token = response.token;
|
|
310
320
|
this.httpClient.setAuthToken(response.token);
|
|
@@ -345,7 +355,7 @@ var AuthService = class {
|
|
|
345
355
|
if (!this.token) {
|
|
346
356
|
throw new Error("Not authenticated");
|
|
347
357
|
}
|
|
348
|
-
const response = await this.httpClient.post("/api/v1/user/update/
|
|
358
|
+
const response = await this.httpClient.post("/api/v1/user/update/profile", { avatar });
|
|
349
359
|
if (response.success && response.token) {
|
|
350
360
|
this.token = response.token;
|
|
351
361
|
this.httpClient.setAuthToken(response.token);
|
|
@@ -468,18 +478,69 @@ var AuthService = class {
|
|
|
468
478
|
return response;
|
|
469
479
|
}
|
|
470
480
|
};
|
|
471
|
-
var
|
|
481
|
+
var ThemeContext = React3.createContext({ theme: "light", mounted: false });
|
|
482
|
+
function AuthThemeProvider({ children }) {
|
|
483
|
+
const [theme, setTheme] = React3.useState("light");
|
|
484
|
+
const [mounted, setMounted] = React3.useState(false);
|
|
485
|
+
React3.useEffect(() => {
|
|
486
|
+
const detectTheme = () => {
|
|
487
|
+
const htmlElement = document.documentElement;
|
|
488
|
+
const bodyElement = document.body;
|
|
489
|
+
if (htmlElement.classList.contains("dark") || bodyElement.classList.contains("dark")) {
|
|
490
|
+
return "dark";
|
|
491
|
+
}
|
|
492
|
+
if (htmlElement.classList.contains("light") || bodyElement.classList.contains("light")) {
|
|
493
|
+
return "light";
|
|
494
|
+
}
|
|
495
|
+
const dataTheme = htmlElement.getAttribute("data-theme") || bodyElement.getAttribute("data-theme");
|
|
496
|
+
if (dataTheme === "dark" || dataTheme === "light") {
|
|
497
|
+
return dataTheme;
|
|
498
|
+
}
|
|
499
|
+
if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
|
|
500
|
+
return "dark";
|
|
501
|
+
}
|
|
502
|
+
return "light";
|
|
503
|
+
};
|
|
504
|
+
const updateTheme = () => {
|
|
505
|
+
const detectedTheme = detectTheme();
|
|
506
|
+
setTheme(detectedTheme);
|
|
507
|
+
};
|
|
508
|
+
updateTheme();
|
|
509
|
+
setMounted(true);
|
|
510
|
+
const observer = new MutationObserver(updateTheme);
|
|
511
|
+
observer.observe(document.documentElement, {
|
|
512
|
+
attributes: true,
|
|
513
|
+
attributeFilter: ["class", "data-theme"]
|
|
514
|
+
});
|
|
515
|
+
observer.observe(document.body, {
|
|
516
|
+
attributes: true,
|
|
517
|
+
attributeFilter: ["class", "data-theme"]
|
|
518
|
+
});
|
|
519
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
520
|
+
const handleMediaChange = () => updateTheme();
|
|
521
|
+
mediaQuery.addEventListener("change", handleMediaChange);
|
|
522
|
+
return () => {
|
|
523
|
+
observer.disconnect();
|
|
524
|
+
mediaQuery.removeEventListener("change", handleMediaChange);
|
|
525
|
+
};
|
|
526
|
+
}, []);
|
|
527
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ThemeContext.Provider, { value: { theme, mounted }, children });
|
|
528
|
+
}
|
|
529
|
+
function useAuthTheme() {
|
|
530
|
+
return React3.useContext(ThemeContext);
|
|
531
|
+
}
|
|
532
|
+
var AuthContext = React3.createContext(void 0);
|
|
472
533
|
var AuthProvider = ({ children, config }) => {
|
|
473
534
|
const authConfig = {
|
|
474
535
|
baseUrl: config?.baseUrl || (typeof window !== "undefined" ? process.env.NEXT_PUBLIC_AUTH_API_URL || process.env.REACT_APP_AUTH_API_URL || "http://localhost:7000" : "http://localhost:7000"),
|
|
475
536
|
localStorageKey: config?.localStorageKey || "auth_token",
|
|
476
537
|
csrfEnabled: config?.csrfEnabled !== void 0 ? config.csrfEnabled : true
|
|
477
538
|
};
|
|
478
|
-
const [authService] =
|
|
479
|
-
const [user, setUser] =
|
|
480
|
-
const [isLoaded, setIsLoaded] =
|
|
481
|
-
const [loading, setLoading] =
|
|
482
|
-
const checkAuthStatus =
|
|
539
|
+
const [authService] = React3.useState(() => new AuthService(authConfig));
|
|
540
|
+
const [user, setUser] = React3.useState(null);
|
|
541
|
+
const [isLoaded, setIsLoaded] = React3.useState(false);
|
|
542
|
+
const [loading, setLoading] = React3.useState(false);
|
|
543
|
+
const checkAuthStatus = React3.useCallback(async () => {
|
|
483
544
|
const authenticated = authService.isAuthenticated();
|
|
484
545
|
if (authenticated) {
|
|
485
546
|
try {
|
|
@@ -494,10 +555,10 @@ var AuthProvider = ({ children, config }) => {
|
|
|
494
555
|
}
|
|
495
556
|
setIsLoaded(true);
|
|
496
557
|
}, [authService]);
|
|
497
|
-
|
|
558
|
+
React3.useEffect(() => {
|
|
498
559
|
checkAuthStatus();
|
|
499
560
|
}, [checkAuthStatus]);
|
|
500
|
-
const signIn =
|
|
561
|
+
const signIn = React3.useCallback(async (data) => {
|
|
501
562
|
setLoading(true);
|
|
502
563
|
try {
|
|
503
564
|
const response = await authService.login(data);
|
|
@@ -509,7 +570,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
509
570
|
setLoading(false);
|
|
510
571
|
}
|
|
511
572
|
}, [authService]);
|
|
512
|
-
const signUp =
|
|
573
|
+
const signUp = React3.useCallback(async (data) => {
|
|
513
574
|
setLoading(true);
|
|
514
575
|
try {
|
|
515
576
|
const response = await authService.register(data);
|
|
@@ -518,7 +579,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
518
579
|
setLoading(false);
|
|
519
580
|
}
|
|
520
581
|
}, [authService]);
|
|
521
|
-
const signOut =
|
|
582
|
+
const signOut = React3.useCallback(async () => {
|
|
522
583
|
setLoading(true);
|
|
523
584
|
try {
|
|
524
585
|
await authService.logout();
|
|
@@ -527,7 +588,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
527
588
|
setLoading(false);
|
|
528
589
|
}
|
|
529
590
|
}, [authService]);
|
|
530
|
-
const verify =
|
|
591
|
+
const verify = React3.useCallback(async (data) => {
|
|
531
592
|
setLoading(true);
|
|
532
593
|
try {
|
|
533
594
|
const response = await authService.verify(data);
|
|
@@ -539,7 +600,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
539
600
|
setLoading(false);
|
|
540
601
|
}
|
|
541
602
|
}, [authService]);
|
|
542
|
-
const verifyEmailToken =
|
|
603
|
+
const verifyEmailToken = React3.useCallback(async (token) => {
|
|
543
604
|
setLoading(true);
|
|
544
605
|
try {
|
|
545
606
|
const response = await authService.verifyEmailToken(token);
|
|
@@ -551,7 +612,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
551
612
|
setLoading(false);
|
|
552
613
|
}
|
|
553
614
|
}, [authService]);
|
|
554
|
-
const updateProfile =
|
|
615
|
+
const updateProfile = React3.useCallback(async (data) => {
|
|
555
616
|
setLoading(true);
|
|
556
617
|
try {
|
|
557
618
|
const response = await authService.updateProfile(data);
|
|
@@ -563,7 +624,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
563
624
|
setLoading(false);
|
|
564
625
|
}
|
|
565
626
|
}, [authService]);
|
|
566
|
-
const getProfile =
|
|
627
|
+
const getProfile = React3.useCallback(async () => {
|
|
567
628
|
setLoading(true);
|
|
568
629
|
try {
|
|
569
630
|
const userData = await authService.getProfile();
|
|
@@ -573,13 +634,13 @@ var AuthProvider = ({ children, config }) => {
|
|
|
573
634
|
setLoading(false);
|
|
574
635
|
}
|
|
575
636
|
}, [authService]);
|
|
576
|
-
const signInWithOAuth =
|
|
637
|
+
const signInWithOAuth = React3.useCallback((provider) => {
|
|
577
638
|
authService.loginWithOAuth(provider);
|
|
578
639
|
}, [authService]);
|
|
579
|
-
const linkOAuthProvider =
|
|
640
|
+
const linkOAuthProvider = React3.useCallback((provider) => {
|
|
580
641
|
authService.linkOAuthProvider(provider);
|
|
581
642
|
}, [authService]);
|
|
582
|
-
const unlinkOAuthProvider =
|
|
643
|
+
const unlinkOAuthProvider = React3.useCallback(async (provider) => {
|
|
583
644
|
setLoading(true);
|
|
584
645
|
try {
|
|
585
646
|
return await authService.unlinkOAuthProvider(provider);
|
|
@@ -587,7 +648,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
587
648
|
setLoading(false);
|
|
588
649
|
}
|
|
589
650
|
}, [authService]);
|
|
590
|
-
const forgotPassword =
|
|
651
|
+
const forgotPassword = React3.useCallback(async (email) => {
|
|
591
652
|
setLoading(true);
|
|
592
653
|
try {
|
|
593
654
|
return await authService.forgotPassword(email);
|
|
@@ -595,7 +656,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
595
656
|
setLoading(false);
|
|
596
657
|
}
|
|
597
658
|
}, [authService]);
|
|
598
|
-
const resetPassword =
|
|
659
|
+
const resetPassword = React3.useCallback(async (token, password) => {
|
|
599
660
|
setLoading(true);
|
|
600
661
|
try {
|
|
601
662
|
return await authService.resetPassword(token, password);
|
|
@@ -603,7 +664,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
603
664
|
setLoading(false);
|
|
604
665
|
}
|
|
605
666
|
}, [authService]);
|
|
606
|
-
const changePassword =
|
|
667
|
+
const changePassword = React3.useCallback(async (oldPassword, newPassword) => {
|
|
607
668
|
setLoading(true);
|
|
608
669
|
try {
|
|
609
670
|
return await authService.changePassword(oldPassword, newPassword);
|
|
@@ -611,7 +672,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
611
672
|
setLoading(false);
|
|
612
673
|
}
|
|
613
674
|
}, [authService]);
|
|
614
|
-
const updateAvatar =
|
|
675
|
+
const updateAvatar = React3.useCallback(async (avatar) => {
|
|
615
676
|
setLoading(true);
|
|
616
677
|
try {
|
|
617
678
|
const response = await authService.updateAvatar(avatar);
|
|
@@ -623,7 +684,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
623
684
|
setLoading(false);
|
|
624
685
|
}
|
|
625
686
|
}, [authService]);
|
|
626
|
-
const requestEmailChange =
|
|
687
|
+
const requestEmailChange = React3.useCallback(async (newEmail) => {
|
|
627
688
|
setLoading(true);
|
|
628
689
|
try {
|
|
629
690
|
return await authService.requestEmailChange(newEmail);
|
|
@@ -631,7 +692,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
631
692
|
setLoading(false);
|
|
632
693
|
}
|
|
633
694
|
}, [authService]);
|
|
634
|
-
const verifyEmailChange =
|
|
695
|
+
const verifyEmailChange = React3.useCallback(async (token) => {
|
|
635
696
|
setLoading(true);
|
|
636
697
|
try {
|
|
637
698
|
const response = await authService.verifyEmailChange(token);
|
|
@@ -643,7 +704,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
643
704
|
setLoading(false);
|
|
644
705
|
}
|
|
645
706
|
}, [authService]);
|
|
646
|
-
const generate2FA =
|
|
707
|
+
const generate2FA = React3.useCallback(async () => {
|
|
647
708
|
setLoading(true);
|
|
648
709
|
try {
|
|
649
710
|
return await authService.generate2FA();
|
|
@@ -651,7 +712,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
651
712
|
setLoading(false);
|
|
652
713
|
}
|
|
653
714
|
}, [authService]);
|
|
654
|
-
const enable2FA =
|
|
715
|
+
const enable2FA = React3.useCallback(async (token) => {
|
|
655
716
|
setLoading(true);
|
|
656
717
|
try {
|
|
657
718
|
return await authService.enable2FA(token);
|
|
@@ -659,7 +720,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
659
720
|
setLoading(false);
|
|
660
721
|
}
|
|
661
722
|
}, [authService]);
|
|
662
|
-
const disable2FA =
|
|
723
|
+
const disable2FA = React3.useCallback(async (token) => {
|
|
663
724
|
setLoading(true);
|
|
664
725
|
try {
|
|
665
726
|
return await authService.disable2FA(token);
|
|
@@ -667,7 +728,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
667
728
|
setLoading(false);
|
|
668
729
|
}
|
|
669
730
|
}, [authService]);
|
|
670
|
-
const validate2FA =
|
|
731
|
+
const validate2FA = React3.useCallback(async (token) => {
|
|
671
732
|
setLoading(true);
|
|
672
733
|
try {
|
|
673
734
|
return await authService.validate2FA(token);
|
|
@@ -675,7 +736,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
675
736
|
setLoading(false);
|
|
676
737
|
}
|
|
677
738
|
}, [authService]);
|
|
678
|
-
const getSessions =
|
|
739
|
+
const getSessions = React3.useCallback(async () => {
|
|
679
740
|
setLoading(true);
|
|
680
741
|
try {
|
|
681
742
|
return await authService.getSessions();
|
|
@@ -683,7 +744,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
683
744
|
setLoading(false);
|
|
684
745
|
}
|
|
685
746
|
}, [authService]);
|
|
686
|
-
const revokeSession =
|
|
747
|
+
const revokeSession = React3.useCallback(async (sessionId) => {
|
|
687
748
|
setLoading(true);
|
|
688
749
|
try {
|
|
689
750
|
return await authService.revokeSession(sessionId);
|
|
@@ -691,7 +752,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
691
752
|
setLoading(false);
|
|
692
753
|
}
|
|
693
754
|
}, [authService]);
|
|
694
|
-
const revokeAllSessions =
|
|
755
|
+
const revokeAllSessions = React3.useCallback(async () => {
|
|
695
756
|
setLoading(true);
|
|
696
757
|
try {
|
|
697
758
|
const response = await authService.revokeAllSessions();
|
|
@@ -731,21 +792,21 @@ var AuthProvider = ({ children, config }) => {
|
|
|
731
792
|
revokeAllSessions,
|
|
732
793
|
authService
|
|
733
794
|
};
|
|
734
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AuthContext.Provider, { value, children });
|
|
795
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AuthContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(AuthThemeProvider, { children }) });
|
|
735
796
|
};
|
|
736
797
|
var useAuth = () => {
|
|
737
|
-
const context =
|
|
798
|
+
const context = React3.useContext(AuthContext);
|
|
738
799
|
if (context === void 0) {
|
|
739
800
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
740
801
|
}
|
|
741
802
|
return context;
|
|
742
803
|
};
|
|
743
804
|
var useAuth2 = (config) => {
|
|
744
|
-
const [authService] =
|
|
745
|
-
const [user, setUser] =
|
|
746
|
-
const [isAuthenticated, setIsAuthenticated] =
|
|
747
|
-
const [loading, setLoading] =
|
|
748
|
-
const checkAuthStatus =
|
|
805
|
+
const [authService] = React3.useState(() => new AuthService(config));
|
|
806
|
+
const [user, setUser] = React3.useState(null);
|
|
807
|
+
const [isAuthenticated, setIsAuthenticated] = React3.useState(false);
|
|
808
|
+
const [loading, setLoading] = React3.useState(true);
|
|
809
|
+
const checkAuthStatus = React3.useCallback(() => {
|
|
749
810
|
const authenticated = authService.isAuthenticated();
|
|
750
811
|
setIsAuthenticated(authenticated);
|
|
751
812
|
if (authenticated) {
|
|
@@ -756,10 +817,10 @@ var useAuth2 = (config) => {
|
|
|
756
817
|
}
|
|
757
818
|
setLoading(false);
|
|
758
819
|
}, [authService]);
|
|
759
|
-
|
|
820
|
+
React3.useEffect(() => {
|
|
760
821
|
checkAuthStatus();
|
|
761
822
|
}, [checkAuthStatus]);
|
|
762
|
-
const register =
|
|
823
|
+
const register = React3.useCallback(async (data) => {
|
|
763
824
|
setLoading(true);
|
|
764
825
|
try {
|
|
765
826
|
const response = await authService.register(data);
|
|
@@ -768,7 +829,7 @@ var useAuth2 = (config) => {
|
|
|
768
829
|
setLoading(false);
|
|
769
830
|
}
|
|
770
831
|
}, [authService]);
|
|
771
|
-
const login =
|
|
832
|
+
const login = React3.useCallback(async (data) => {
|
|
772
833
|
setLoading(true);
|
|
773
834
|
try {
|
|
774
835
|
const response = await authService.login(data);
|
|
@@ -781,7 +842,7 @@ var useAuth2 = (config) => {
|
|
|
781
842
|
setLoading(false);
|
|
782
843
|
}
|
|
783
844
|
}, [authService]);
|
|
784
|
-
const verify =
|
|
845
|
+
const verify = React3.useCallback(async (data) => {
|
|
785
846
|
setLoading(true);
|
|
786
847
|
try {
|
|
787
848
|
const response = await authService.verify(data);
|
|
@@ -794,7 +855,7 @@ var useAuth2 = (config) => {
|
|
|
794
855
|
setLoading(false);
|
|
795
856
|
}
|
|
796
857
|
}, [authService]);
|
|
797
|
-
const verifyEmailToken =
|
|
858
|
+
const verifyEmailToken = React3.useCallback(async (token) => {
|
|
798
859
|
setLoading(true);
|
|
799
860
|
try {
|
|
800
861
|
const response = await authService.verifyEmailToken(token);
|
|
@@ -807,7 +868,7 @@ var useAuth2 = (config) => {
|
|
|
807
868
|
setLoading(false);
|
|
808
869
|
}
|
|
809
870
|
}, [authService]);
|
|
810
|
-
const logout =
|
|
871
|
+
const logout = React3.useCallback(async () => {
|
|
811
872
|
setLoading(true);
|
|
812
873
|
try {
|
|
813
874
|
await authService.logout();
|
|
@@ -817,7 +878,7 @@ var useAuth2 = (config) => {
|
|
|
817
878
|
setLoading(false);
|
|
818
879
|
}
|
|
819
880
|
}, [authService]);
|
|
820
|
-
const updateProfile =
|
|
881
|
+
const updateProfile = React3.useCallback(async (data) => {
|
|
821
882
|
setLoading(true);
|
|
822
883
|
try {
|
|
823
884
|
const response = await authService.updateProfile(data);
|
|
@@ -829,7 +890,7 @@ var useAuth2 = (config) => {
|
|
|
829
890
|
setLoading(false);
|
|
830
891
|
}
|
|
831
892
|
}, [authService]);
|
|
832
|
-
const getProfile =
|
|
893
|
+
const getProfile = React3.useCallback(async () => {
|
|
833
894
|
setLoading(true);
|
|
834
895
|
try {
|
|
835
896
|
const userData = await authService.getProfile();
|
|
@@ -839,7 +900,7 @@ var useAuth2 = (config) => {
|
|
|
839
900
|
setLoading(false);
|
|
840
901
|
}
|
|
841
902
|
}, [authService]);
|
|
842
|
-
const getAllUsers =
|
|
903
|
+
const getAllUsers = React3.useCallback(async () => {
|
|
843
904
|
setLoading(true);
|
|
844
905
|
try {
|
|
845
906
|
return await authService.getAllUsers();
|
|
@@ -847,7 +908,7 @@ var useAuth2 = (config) => {
|
|
|
847
908
|
setLoading(false);
|
|
848
909
|
}
|
|
849
910
|
}, [authService]);
|
|
850
|
-
const getUserById =
|
|
911
|
+
const getUserById = React3.useCallback(async (id) => {
|
|
851
912
|
setLoading(true);
|
|
852
913
|
try {
|
|
853
914
|
return await authService.getUserById(id);
|
|
@@ -870,6 +931,267 @@ var useAuth2 = (config) => {
|
|
|
870
931
|
getUserById
|
|
871
932
|
};
|
|
872
933
|
};
|
|
934
|
+
|
|
935
|
+
// src/react/hooks/useThemeColors.ts
|
|
936
|
+
var lightTheme = {
|
|
937
|
+
bgPrimary: "var(--auth-bg-primary, #ffffff)",
|
|
938
|
+
bgSecondary: "var(--auth-bg-secondary, #f8fafc)",
|
|
939
|
+
bgHover: "var(--auth-bg-hover, #f1f5f9)",
|
|
940
|
+
textPrimary: "var(--auth-text-primary, #0f172a)",
|
|
941
|
+
textSecondary: "var(--auth-text-secondary, #475569)",
|
|
942
|
+
textTertiary: "var(--auth-text-tertiary, #94a3b8)",
|
|
943
|
+
borderPrimary: "var(--auth-border-primary, #e2e8f0)",
|
|
944
|
+
borderSecondary: "var(--auth-border-secondary, #cbd5e1)",
|
|
945
|
+
buttonPrimary: "var(--auth-button-primary, #3b82f6)",
|
|
946
|
+
buttonPrimaryHover: "var(--auth-button-primary-hover, #2563eb)",
|
|
947
|
+
errorBg: "var(--auth-error-bg, #fef2f2)",
|
|
948
|
+
errorText: "var(--auth-error-text, #dc2626)",
|
|
949
|
+
errorBorder: "var(--auth-error-border, #fecaca)",
|
|
950
|
+
successBg: "var(--auth-success-bg, #f0fdf4)",
|
|
951
|
+
successText: "var(--auth-success-text, #16a34a)",
|
|
952
|
+
successBorder: "var(--auth-success-border, #bbf7d0)"
|
|
953
|
+
};
|
|
954
|
+
var darkTheme = {
|
|
955
|
+
bgPrimary: "var(--auth-bg-primary, #1f2937)",
|
|
956
|
+
bgSecondary: "var(--auth-bg-secondary, #111827)",
|
|
957
|
+
bgHover: "var(--auth-bg-hover, #374151)",
|
|
958
|
+
textPrimary: "var(--auth-text-primary, #f9fafb)",
|
|
959
|
+
textSecondary: "var(--auth-text-secondary, #e5e7eb)",
|
|
960
|
+
textTertiary: "var(--auth-text-tertiary, #d1d5db)",
|
|
961
|
+
borderPrimary: "var(--auth-border-primary, #374151)",
|
|
962
|
+
borderSecondary: "var(--auth-border-secondary, #4b5563)",
|
|
963
|
+
buttonPrimary: "var(--auth-button-primary, #3b82f6)",
|
|
964
|
+
buttonPrimaryHover: "var(--auth-button-primary-hover, #2563eb)",
|
|
965
|
+
errorBg: "var(--auth-error-bg, #7f1d1d)",
|
|
966
|
+
errorText: "var(--auth-error-text, #fecaca)",
|
|
967
|
+
errorBorder: "var(--auth-error-border, #991b1b)",
|
|
968
|
+
successBg: "var(--auth-success-bg, #14532d)",
|
|
969
|
+
successText: "var(--auth-success-text, #bbf7d0)",
|
|
970
|
+
successBorder: "var(--auth-success-border, #166534)"
|
|
971
|
+
};
|
|
972
|
+
function useThemeColors() {
|
|
973
|
+
const { theme } = useAuthTheme();
|
|
974
|
+
return theme === "dark" ? darkTheme : lightTheme;
|
|
975
|
+
}
|
|
976
|
+
var CustomPhoneInput = React3__default.default.forwardRef((props, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
977
|
+
"input",
|
|
978
|
+
{
|
|
979
|
+
...props,
|
|
980
|
+
ref,
|
|
981
|
+
className: "PhoneInputInput"
|
|
982
|
+
}
|
|
983
|
+
));
|
|
984
|
+
CustomPhoneInput.displayName = "CustomPhoneInput";
|
|
985
|
+
var PhoneInput = ({
|
|
986
|
+
value,
|
|
987
|
+
onChange,
|
|
988
|
+
disabled = false,
|
|
989
|
+
required = false,
|
|
990
|
+
placeholder = "Enter phone number",
|
|
991
|
+
id = "phone",
|
|
992
|
+
style = {}
|
|
993
|
+
}) => {
|
|
994
|
+
const colors = useThemeColors();
|
|
995
|
+
const [defaultCountry, setDefaultCountry] = React3.useState("US");
|
|
996
|
+
const styleContent = React3.useMemo(() => `
|
|
997
|
+
.PhoneInput {
|
|
998
|
+
display: flex;
|
|
999
|
+
align-items: center;
|
|
1000
|
+
gap: 8px;
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
.PhoneInputCountry {
|
|
1004
|
+
position: relative;
|
|
1005
|
+
align-self: stretch;
|
|
1006
|
+
display: flex;
|
|
1007
|
+
align-items: center;
|
|
1008
|
+
padding: 0 8px;
|
|
1009
|
+
border: 1px solid ${colors.borderSecondary};
|
|
1010
|
+
border-radius: 8px;
|
|
1011
|
+
background-color: ${colors.bgSecondary};
|
|
1012
|
+
transition: all 0.2s ease;
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
.PhoneInputCountry:focus-within {
|
|
1016
|
+
border-color: ${colors.buttonPrimary};
|
|
1017
|
+
outline: 2px solid ${colors.buttonPrimary}40;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
.PhoneInputCountryIcon {
|
|
1021
|
+
width: 24px;
|
|
1022
|
+
height: 24px;
|
|
1023
|
+
margin-right: 4px;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
.PhoneInputCountryIcon--border {
|
|
1027
|
+
box-shadow: none;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
.PhoneInputCountrySelect {
|
|
1031
|
+
position: absolute;
|
|
1032
|
+
top: 0;
|
|
1033
|
+
left: 0;
|
|
1034
|
+
height: 100%;
|
|
1035
|
+
width: 100%;
|
|
1036
|
+
z-index: 1;
|
|
1037
|
+
border: 0;
|
|
1038
|
+
opacity: 0;
|
|
1039
|
+
cursor: pointer;
|
|
1040
|
+
color: ${colors.textPrimary};
|
|
1041
|
+
background-color: ${colors.bgSecondary};
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
.PhoneInputCountrySelect:disabled {
|
|
1045
|
+
cursor: not-allowed;
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/* Dropdown menu styling */
|
|
1049
|
+
.PhoneInputCountrySelect option {
|
|
1050
|
+
background-color: ${colors.bgPrimary};
|
|
1051
|
+
color: ${colors.textPrimary};
|
|
1052
|
+
padding: 8px 12px;
|
|
1053
|
+
font-size: 14px;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
.PhoneInputCountrySelect option:hover,
|
|
1057
|
+
.PhoneInputCountrySelect option:focus,
|
|
1058
|
+
.PhoneInputCountrySelect option:checked {
|
|
1059
|
+
background-color: ${colors.buttonPrimary};
|
|
1060
|
+
color: white;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
.PhoneInputCountrySelectArrow {
|
|
1064
|
+
display: block;
|
|
1065
|
+
content: '';
|
|
1066
|
+
width: 0.3em;
|
|
1067
|
+
height: 0.3em;
|
|
1068
|
+
margin-left: 0.35em;
|
|
1069
|
+
border-style: solid;
|
|
1070
|
+
border-color: ${colors.textPrimary};
|
|
1071
|
+
border-top-width: 0;
|
|
1072
|
+
border-bottom-width: 1px;
|
|
1073
|
+
border-left-width: 0;
|
|
1074
|
+
border-right-width: 1px;
|
|
1075
|
+
transform: rotate(45deg);
|
|
1076
|
+
opacity: 0.7;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
.PhoneInputInput {
|
|
1080
|
+
flex: 1;
|
|
1081
|
+
min-width: 0;
|
|
1082
|
+
padding: 12px 16px;
|
|
1083
|
+
border: 1px solid ${colors.borderSecondary};
|
|
1084
|
+
border-radius: 8px;
|
|
1085
|
+
font-size: 16px;
|
|
1086
|
+
background-color: ${colors.bgSecondary};
|
|
1087
|
+
color: ${colors.textPrimary};
|
|
1088
|
+
transition: all 0.2s ease;
|
|
1089
|
+
-webkit-text-fill-color: ${colors.textPrimary};
|
|
1090
|
+
-webkit-box-shadow: 0 0 0 1000px ${colors.bgSecondary} inset;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
.PhoneInputInput:focus {
|
|
1094
|
+
border-color: ${colors.buttonPrimary};
|
|
1095
|
+
outline: 2px solid ${colors.buttonPrimary}40;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
.PhoneInputInput:disabled {
|
|
1099
|
+
cursor: not-allowed;
|
|
1100
|
+
opacity: 0.6;
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
.PhoneInputInput::placeholder {
|
|
1104
|
+
color: ${colors.textTertiary};
|
|
1105
|
+
opacity: 0.6;
|
|
1106
|
+
}
|
|
1107
|
+
`, [colors]);
|
|
1108
|
+
React3.useEffect(() => {
|
|
1109
|
+
const detectCountry = async () => {
|
|
1110
|
+
try {
|
|
1111
|
+
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
1112
|
+
const timezoneToCountry = {
|
|
1113
|
+
"America/New_York": "US",
|
|
1114
|
+
"America/Chicago": "US",
|
|
1115
|
+
"America/Denver": "US",
|
|
1116
|
+
"America/Los_Angeles": "US",
|
|
1117
|
+
"America/Phoenix": "US",
|
|
1118
|
+
"America/Anchorage": "US",
|
|
1119
|
+
"Pacific/Honolulu": "US",
|
|
1120
|
+
"Europe/London": "GB",
|
|
1121
|
+
"Europe/Paris": "FR",
|
|
1122
|
+
"Europe/Berlin": "DE",
|
|
1123
|
+
"Europe/Rome": "IT",
|
|
1124
|
+
"Europe/Madrid": "ES",
|
|
1125
|
+
"Asia/Dubai": "AE",
|
|
1126
|
+
"Asia/Kolkata": "IN",
|
|
1127
|
+
"Asia/Shanghai": "CN",
|
|
1128
|
+
"Asia/Tokyo": "JP",
|
|
1129
|
+
"Asia/Seoul": "KR",
|
|
1130
|
+
"Asia/Singapore": "SG",
|
|
1131
|
+
"Asia/Hong_Kong": "HK",
|
|
1132
|
+
"Australia/Sydney": "AU",
|
|
1133
|
+
"Pacific/Auckland": "NZ",
|
|
1134
|
+
"America/Toronto": "CA",
|
|
1135
|
+
"America/Vancouver": "CA",
|
|
1136
|
+
"America/Mexico_City": "MX",
|
|
1137
|
+
"America/Sao_Paulo": "BR",
|
|
1138
|
+
"America/Buenos_Aires": "AR",
|
|
1139
|
+
"Africa/Cairo": "EG",
|
|
1140
|
+
"Africa/Johannesburg": "ZA",
|
|
1141
|
+
"Africa/Lagos": "NG",
|
|
1142
|
+
"Africa/Nairobi": "KE"
|
|
1143
|
+
};
|
|
1144
|
+
const detectedCountry = timezoneToCountry[timezone];
|
|
1145
|
+
if (detectedCountry) {
|
|
1146
|
+
setDefaultCountry(detectedCountry);
|
|
1147
|
+
return;
|
|
1148
|
+
}
|
|
1149
|
+
const response = await fetch("https://ipapi.co/json/", {
|
|
1150
|
+
signal: AbortSignal.timeout(3e3)
|
|
1151
|
+
// 3 second timeout
|
|
1152
|
+
});
|
|
1153
|
+
if (response.ok) {
|
|
1154
|
+
const data = await response.json();
|
|
1155
|
+
if (data.country_code) {
|
|
1156
|
+
setDefaultCountry(data.country_code);
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
} catch (error) {
|
|
1160
|
+
console.log("Country detection failed, using default US");
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
detectCountry();
|
|
1164
|
+
}, []);
|
|
1165
|
+
const handleChange = React3.useMemo(() => (val) => {
|
|
1166
|
+
onChange(val || "");
|
|
1167
|
+
}, [onChange]);
|
|
1168
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1169
|
+
"div",
|
|
1170
|
+
{
|
|
1171
|
+
style: {
|
|
1172
|
+
width: "100%",
|
|
1173
|
+
...style
|
|
1174
|
+
},
|
|
1175
|
+
children: [
|
|
1176
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: styleContent }),
|
|
1177
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1178
|
+
PhoneInputWithCountry__default.default,
|
|
1179
|
+
{
|
|
1180
|
+
id,
|
|
1181
|
+
international: true,
|
|
1182
|
+
defaultCountry,
|
|
1183
|
+
value: value || "",
|
|
1184
|
+
onChange: handleChange,
|
|
1185
|
+
disabled,
|
|
1186
|
+
placeholder,
|
|
1187
|
+
inputComponent: CustomPhoneInput
|
|
1188
|
+
},
|
|
1189
|
+
id
|
|
1190
|
+
)
|
|
1191
|
+
]
|
|
1192
|
+
}
|
|
1193
|
+
);
|
|
1194
|
+
};
|
|
873
1195
|
var LoginForm = ({
|
|
874
1196
|
onSuccess,
|
|
875
1197
|
onLoginSuccess,
|
|
@@ -879,15 +1201,18 @@ var LoginForm = ({
|
|
|
879
1201
|
oauthProviders = ["google", "github"],
|
|
880
1202
|
showOAuthButtons = true
|
|
881
1203
|
}) => {
|
|
882
|
-
const
|
|
883
|
-
const [
|
|
884
|
-
const [
|
|
885
|
-
const [
|
|
886
|
-
const [
|
|
887
|
-
const [
|
|
888
|
-
const [
|
|
1204
|
+
const colors = useThemeColors();
|
|
1205
|
+
const [email, setEmail] = React3.useState("");
|
|
1206
|
+
const [phoneNumber, setPhoneNumber] = React3.useState("");
|
|
1207
|
+
const [usePhone, setUsePhone] = React3.useState(false);
|
|
1208
|
+
const [password, setPassword] = React3.useState("");
|
|
1209
|
+
const [usePassword, setUsePassword] = React3.useState(false);
|
|
1210
|
+
const [showPassword, setShowPassword] = React3.useState(false);
|
|
1211
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
1212
|
+
const [error, setError] = React3.useState(null);
|
|
1213
|
+
const [rememberMe, setRememberMe] = React3.useState(false);
|
|
889
1214
|
const { login } = useAuth2({
|
|
890
|
-
baseUrl: config?.baseUrl ||
|
|
1215
|
+
baseUrl: config?.baseUrl || "http://localhost:7000"
|
|
891
1216
|
});
|
|
892
1217
|
const handleSubmit = async (e) => {
|
|
893
1218
|
e.preventDefault();
|
|
@@ -895,20 +1220,28 @@ var LoginForm = ({
|
|
|
895
1220
|
setError(null);
|
|
896
1221
|
try {
|
|
897
1222
|
let response;
|
|
1223
|
+
const loginData = {};
|
|
1224
|
+
if (usePhone && phoneNumber) {
|
|
1225
|
+
loginData.phoneNumber = phoneNumber;
|
|
1226
|
+
} else if (email) {
|
|
1227
|
+
loginData.email = email;
|
|
1228
|
+
}
|
|
898
1229
|
if (usePassword) {
|
|
899
|
-
|
|
1230
|
+
loginData.password = password;
|
|
1231
|
+
response = await login(loginData);
|
|
900
1232
|
} else {
|
|
901
|
-
response = await login(
|
|
1233
|
+
response = await login(loginData);
|
|
902
1234
|
}
|
|
903
1235
|
if (response.success) {
|
|
904
1236
|
onSuccess?.(response);
|
|
905
1237
|
if (onLoginSuccess) {
|
|
906
|
-
|
|
907
|
-
|
|
1238
|
+
const identifier = usePhone ? phoneNumber : email;
|
|
1239
|
+
if (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.") {
|
|
1240
|
+
onLoginSuccess(identifier, true);
|
|
908
1241
|
} else if (response.token) {
|
|
909
|
-
onLoginSuccess(
|
|
1242
|
+
onLoginSuccess(identifier, false);
|
|
910
1243
|
} else {
|
|
911
|
-
onLoginSuccess(
|
|
1244
|
+
onLoginSuccess(identifier, true);
|
|
912
1245
|
}
|
|
913
1246
|
}
|
|
914
1247
|
} else {
|
|
@@ -930,43 +1263,53 @@ var LoginForm = ({
|
|
|
930
1263
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
931
1264
|
maxWidth: "400px",
|
|
932
1265
|
margin: "0 auto",
|
|
933
|
-
padding: "
|
|
1266
|
+
padding: "24px",
|
|
934
1267
|
borderRadius: "12px",
|
|
935
1268
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
936
|
-
backgroundColor:
|
|
937
|
-
border:
|
|
1269
|
+
backgroundColor: colors.bgPrimary,
|
|
1270
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
938
1271
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: {
|
|
939
1272
|
display: "flex",
|
|
940
1273
|
flexDirection: "column"
|
|
941
1274
|
}, children: [
|
|
942
1275
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
|
|
943
1276
|
textAlign: "center",
|
|
944
|
-
marginBottom: "
|
|
945
|
-
color:
|
|
1277
|
+
marginBottom: "20px",
|
|
1278
|
+
color: colors.textPrimary,
|
|
946
1279
|
fontSize: "24px",
|
|
947
1280
|
fontWeight: 600
|
|
948
1281
|
}, children: usePassword ? "Login with Password" : "Login with OTP" }),
|
|
949
1282
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
950
1283
|
padding: "12px 16px",
|
|
951
|
-
marginBottom: "
|
|
952
|
-
backgroundColor:
|
|
953
|
-
color:
|
|
954
|
-
border:
|
|
1284
|
+
marginBottom: "16px",
|
|
1285
|
+
backgroundColor: colors.errorBg,
|
|
1286
|
+
color: colors.errorText,
|
|
1287
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
955
1288
|
borderRadius: "8px",
|
|
956
1289
|
fontSize: "14px",
|
|
957
1290
|
fontWeight: 500
|
|
958
1291
|
}, children: error }),
|
|
959
1292
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
960
|
-
marginBottom: "
|
|
1293
|
+
marginBottom: "16px"
|
|
961
1294
|
}, children: [
|
|
962
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", style: {
|
|
1295
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: usePhone ? "phone" : "email", style: {
|
|
963
1296
|
display: "block",
|
|
964
1297
|
marginBottom: "8px",
|
|
965
1298
|
fontWeight: 500,
|
|
966
|
-
color:
|
|
1299
|
+
color: colors.textSecondary,
|
|
967
1300
|
fontSize: "14px"
|
|
968
|
-
}, children: "Email:" }),
|
|
969
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1301
|
+
}, children: usePhone ? "Phone Number:" : "Email:" }),
|
|
1302
|
+
usePhone ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1303
|
+
PhoneInput,
|
|
1304
|
+
{
|
|
1305
|
+
id: "phone",
|
|
1306
|
+
value: phoneNumber,
|
|
1307
|
+
onChange: setPhoneNumber,
|
|
1308
|
+
required: true,
|
|
1309
|
+
disabled: isLoading,
|
|
1310
|
+
placeholder: "1234567890"
|
|
1311
|
+
}
|
|
1312
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
970
1313
|
"input",
|
|
971
1314
|
{
|
|
972
1315
|
id: "email",
|
|
@@ -978,27 +1321,48 @@ var LoginForm = ({
|
|
|
978
1321
|
style: {
|
|
979
1322
|
width: "100%",
|
|
980
1323
|
padding: "12px 16px",
|
|
981
|
-
border:
|
|
1324
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
982
1325
|
borderRadius: "8px",
|
|
983
1326
|
fontSize: "16px",
|
|
984
1327
|
boxSizing: "border-box",
|
|
985
|
-
color:
|
|
1328
|
+
color: colors.textPrimary,
|
|
986
1329
|
transition: "all 0.2s ease",
|
|
987
|
-
backgroundColor:
|
|
1330
|
+
backgroundColor: colors.bgSecondary
|
|
988
1331
|
},
|
|
989
1332
|
placeholder: "Enter your email"
|
|
990
1333
|
}
|
|
1334
|
+
),
|
|
1335
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1336
|
+
"button",
|
|
1337
|
+
{
|
|
1338
|
+
type: "button",
|
|
1339
|
+
onClick: () => setUsePhone(!usePhone),
|
|
1340
|
+
disabled: isLoading,
|
|
1341
|
+
style: {
|
|
1342
|
+
marginTop: "8px",
|
|
1343
|
+
background: "none",
|
|
1344
|
+
border: "none",
|
|
1345
|
+
color: colors.buttonPrimary,
|
|
1346
|
+
textDecoration: "none",
|
|
1347
|
+
cursor: "pointer",
|
|
1348
|
+
fontSize: "13px",
|
|
1349
|
+
fontWeight: 500,
|
|
1350
|
+
padding: "0",
|
|
1351
|
+
transition: "color 0.2s ease"
|
|
1352
|
+
},
|
|
1353
|
+
children: usePhone ? "Use email instead" : "Use phone number instead"
|
|
1354
|
+
}
|
|
991
1355
|
)
|
|
992
1356
|
] }),
|
|
993
1357
|
usePassword && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
994
|
-
marginBottom: "
|
|
1358
|
+
marginBottom: "16px",
|
|
995
1359
|
position: "relative"
|
|
996
1360
|
}, children: [
|
|
997
1361
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "login-password", style: {
|
|
998
1362
|
display: "block",
|
|
999
1363
|
marginBottom: "8px",
|
|
1000
1364
|
fontWeight: 500,
|
|
1001
|
-
color:
|
|
1365
|
+
color: colors.textSecondary,
|
|
1002
1366
|
fontSize: "14px"
|
|
1003
1367
|
}, children: "Password:" }),
|
|
1004
1368
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1013,13 +1377,13 @@ var LoginForm = ({
|
|
|
1013
1377
|
style: {
|
|
1014
1378
|
width: "100%",
|
|
1015
1379
|
padding: "12px 16px",
|
|
1016
|
-
border:
|
|
1380
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1017
1381
|
borderRadius: "8px",
|
|
1018
1382
|
fontSize: "16px",
|
|
1019
1383
|
boxSizing: "border-box",
|
|
1020
|
-
color:
|
|
1384
|
+
color: colors.textPrimary,
|
|
1021
1385
|
transition: "all 0.2s ease",
|
|
1022
|
-
backgroundColor:
|
|
1386
|
+
backgroundColor: colors.bgSecondary
|
|
1023
1387
|
},
|
|
1024
1388
|
placeholder: "Enter your password"
|
|
1025
1389
|
}
|
|
@@ -1037,7 +1401,7 @@ var LoginForm = ({
|
|
|
1037
1401
|
background: "none",
|
|
1038
1402
|
border: "none",
|
|
1039
1403
|
cursor: "pointer",
|
|
1040
|
-
color:
|
|
1404
|
+
color: colors.textTertiary,
|
|
1041
1405
|
fontSize: "14px"
|
|
1042
1406
|
},
|
|
1043
1407
|
children: showPassword ? "Hide" : "Show"
|
|
@@ -1047,8 +1411,8 @@ var LoginForm = ({
|
|
|
1047
1411
|
usePassword && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1048
1412
|
display: "flex",
|
|
1049
1413
|
alignItems: "center",
|
|
1050
|
-
marginBottom: "
|
|
1051
|
-
marginTop: "
|
|
1414
|
+
marginBottom: "12px",
|
|
1415
|
+
marginTop: "4px"
|
|
1052
1416
|
}, children: [
|
|
1053
1417
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1054
1418
|
"input",
|
|
@@ -1072,7 +1436,7 @@ var LoginForm = ({
|
|
|
1072
1436
|
htmlFor: "remember-me",
|
|
1073
1437
|
style: {
|
|
1074
1438
|
fontSize: "14px",
|
|
1075
|
-
color:
|
|
1439
|
+
color: colors.textSecondary,
|
|
1076
1440
|
cursor: "pointer",
|
|
1077
1441
|
userSelect: "none"
|
|
1078
1442
|
},
|
|
@@ -1087,7 +1451,7 @@ var LoginForm = ({
|
|
|
1087
1451
|
disabled: isLoading,
|
|
1088
1452
|
style: {
|
|
1089
1453
|
padding: "14px",
|
|
1090
|
-
backgroundColor:
|
|
1454
|
+
backgroundColor: colors.buttonPrimary,
|
|
1091
1455
|
color: "white",
|
|
1092
1456
|
border: "none",
|
|
1093
1457
|
borderRadius: "8px",
|
|
@@ -1095,16 +1459,16 @@ var LoginForm = ({
|
|
|
1095
1459
|
fontWeight: 600,
|
|
1096
1460
|
cursor: "pointer",
|
|
1097
1461
|
transition: "all 0.2s ease",
|
|
1098
|
-
marginTop: "
|
|
1462
|
+
marginTop: "4px"
|
|
1099
1463
|
},
|
|
1100
1464
|
children: isLoading ? usePassword ? "Logging in..." : "Sending OTP..." : usePassword ? "Login" : "Send OTP"
|
|
1101
1465
|
}
|
|
1102
1466
|
),
|
|
1103
1467
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1104
1468
|
textAlign: "center",
|
|
1105
|
-
marginTop: "
|
|
1106
|
-
paddingTop: "
|
|
1107
|
-
borderTop:
|
|
1469
|
+
marginTop: "16px",
|
|
1470
|
+
paddingTop: "16px",
|
|
1471
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1108
1472
|
}, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1109
1473
|
"button",
|
|
1110
1474
|
{
|
|
@@ -1114,7 +1478,7 @@ var LoginForm = ({
|
|
|
1114
1478
|
style: {
|
|
1115
1479
|
background: "none",
|
|
1116
1480
|
border: "none",
|
|
1117
|
-
color:
|
|
1481
|
+
color: colors.buttonPrimary,
|
|
1118
1482
|
textDecoration: "none",
|
|
1119
1483
|
cursor: "pointer",
|
|
1120
1484
|
fontSize: "14px",
|
|
@@ -1126,9 +1490,9 @@ var LoginForm = ({
|
|
|
1126
1490
|
}
|
|
1127
1491
|
) }),
|
|
1128
1492
|
showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1129
|
-
marginTop: "
|
|
1130
|
-
paddingTop: "
|
|
1131
|
-
borderTop:
|
|
1493
|
+
marginTop: "16px",
|
|
1494
|
+
paddingTop: "16px",
|
|
1495
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1132
1496
|
}, children: [
|
|
1133
1497
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1134
1498
|
position: "relative",
|
|
@@ -1140,15 +1504,15 @@ var LoginForm = ({
|
|
|
1140
1504
|
left: 0,
|
|
1141
1505
|
right: 0,
|
|
1142
1506
|
height: "1px",
|
|
1143
|
-
backgroundColor:
|
|
1507
|
+
backgroundColor: colors.borderPrimary
|
|
1144
1508
|
} }),
|
|
1145
1509
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1146
1510
|
position: "relative",
|
|
1147
1511
|
textAlign: "center"
|
|
1148
1512
|
}, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: {
|
|
1149
|
-
backgroundColor:
|
|
1513
|
+
backgroundColor: colors.bgPrimary,
|
|
1150
1514
|
padding: "0 12px",
|
|
1151
|
-
color:
|
|
1515
|
+
color: colors.textSecondary,
|
|
1152
1516
|
fontSize: "14px"
|
|
1153
1517
|
}, children: "Or continue with" }) })
|
|
1154
1518
|
] }),
|
|
@@ -1167,10 +1531,10 @@ var LoginForm = ({
|
|
|
1167
1531
|
justifyContent: "center",
|
|
1168
1532
|
gap: "8px",
|
|
1169
1533
|
padding: "10px 16px",
|
|
1170
|
-
backgroundColor:
|
|
1171
|
-
border:
|
|
1534
|
+
backgroundColor: colors.bgPrimary,
|
|
1535
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1172
1536
|
borderRadius: "8px",
|
|
1173
|
-
color:
|
|
1537
|
+
color: colors.textPrimary,
|
|
1174
1538
|
textDecoration: "none",
|
|
1175
1539
|
fontSize: "14px",
|
|
1176
1540
|
fontWeight: 500,
|
|
@@ -1178,12 +1542,12 @@ var LoginForm = ({
|
|
|
1178
1542
|
transition: "all 0.2s ease"
|
|
1179
1543
|
},
|
|
1180
1544
|
onMouseEnter: (e) => {
|
|
1181
|
-
e.currentTarget.style.backgroundColor =
|
|
1182
|
-
e.currentTarget.style.borderColor =
|
|
1545
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
1546
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
1183
1547
|
},
|
|
1184
1548
|
onMouseLeave: (e) => {
|
|
1185
|
-
e.currentTarget.style.backgroundColor =
|
|
1186
|
-
e.currentTarget.style.borderColor =
|
|
1549
|
+
e.currentTarget.style.backgroundColor = colors.bgPrimary;
|
|
1550
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
1187
1551
|
},
|
|
1188
1552
|
children: [
|
|
1189
1553
|
/* @__PURE__ */ jsxRuntime.jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
|
|
@@ -1258,11 +1622,11 @@ var LoginForm = ({
|
|
|
1258
1622
|
] }),
|
|
1259
1623
|
showRegisterLink && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1260
1624
|
textAlign: "center",
|
|
1261
|
-
marginTop: "
|
|
1262
|
-
paddingTop: "
|
|
1263
|
-
borderTop:
|
|
1625
|
+
marginTop: "16px",
|
|
1626
|
+
paddingTop: "16px",
|
|
1627
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1264
1628
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("p", { style: {
|
|
1265
|
-
color:
|
|
1629
|
+
color: colors.textSecondary,
|
|
1266
1630
|
fontSize: "14px"
|
|
1267
1631
|
}, children: [
|
|
1268
1632
|
"Don't have an account?",
|
|
@@ -1276,7 +1640,7 @@ var LoginForm = ({
|
|
|
1276
1640
|
style: {
|
|
1277
1641
|
background: "none",
|
|
1278
1642
|
border: "none",
|
|
1279
|
-
color:
|
|
1643
|
+
color: colors.buttonPrimary,
|
|
1280
1644
|
textDecoration: "none",
|
|
1281
1645
|
cursor: "pointer",
|
|
1282
1646
|
fontSize: "14px",
|
|
@@ -1296,16 +1660,19 @@ var RegisterForm = ({
|
|
|
1296
1660
|
showLoginLink = true,
|
|
1297
1661
|
authConfig,
|
|
1298
1662
|
oauthProviders = ["google", "github"],
|
|
1299
|
-
showOAuthButtons = true
|
|
1663
|
+
showOAuthButtons = true,
|
|
1664
|
+
invitationToken
|
|
1300
1665
|
}) => {
|
|
1301
|
-
const
|
|
1302
|
-
const [
|
|
1303
|
-
const [
|
|
1304
|
-
const [
|
|
1305
|
-
const [
|
|
1306
|
-
const [
|
|
1307
|
-
|
|
1308
|
-
|
|
1666
|
+
const colors = useThemeColors();
|
|
1667
|
+
const [name, setName] = React3.useState("");
|
|
1668
|
+
const [email, setEmail] = React3.useState("");
|
|
1669
|
+
const [phoneNumber, setPhoneNumber] = React3.useState("");
|
|
1670
|
+
const [password, setPassword] = React3.useState("");
|
|
1671
|
+
const [confirmPassword, setConfirmPassword] = React3.useState("");
|
|
1672
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
1673
|
+
const [error, setError] = React3.useState(null);
|
|
1674
|
+
React3.useState(false);
|
|
1675
|
+
React3.useState(false);
|
|
1309
1676
|
const getPasswordStrength = (pwd) => {
|
|
1310
1677
|
if (!pwd)
|
|
1311
1678
|
return { strength: "weak", score: 0, label: "" };
|
|
@@ -1328,7 +1695,7 @@ var RegisterForm = ({
|
|
|
1328
1695
|
};
|
|
1329
1696
|
getPasswordStrength(password);
|
|
1330
1697
|
const config = authConfig || {
|
|
1331
|
-
baseUrl:
|
|
1698
|
+
baseUrl: "http://localhost:7000"
|
|
1332
1699
|
};
|
|
1333
1700
|
const { register } = useAuth2(config);
|
|
1334
1701
|
const handleSubmit = async (e) => {
|
|
@@ -1346,17 +1713,45 @@ var RegisterForm = ({
|
|
|
1346
1713
|
return;
|
|
1347
1714
|
}
|
|
1348
1715
|
try {
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1716
|
+
if (invitationToken) {
|
|
1717
|
+
const response = await fetch(`${config.baseUrl}/api/v1/auth/signup-with-invitation`, {
|
|
1718
|
+
method: "POST",
|
|
1719
|
+
headers: {
|
|
1720
|
+
"Content-Type": "application/json"
|
|
1721
|
+
},
|
|
1722
|
+
body: JSON.stringify({
|
|
1723
|
+
name,
|
|
1724
|
+
email,
|
|
1725
|
+
password,
|
|
1726
|
+
phoneNumber: phoneNumber || void 0,
|
|
1727
|
+
invitationToken
|
|
1728
|
+
})
|
|
1729
|
+
});
|
|
1730
|
+
const data = await response.json();
|
|
1731
|
+
if (response.ok && data.success) {
|
|
1732
|
+
if (typeof window !== "undefined" && data.token) {
|
|
1733
|
+
localStorage.setItem("auth_token", data.token);
|
|
1734
|
+
}
|
|
1735
|
+
onRegisterSuccess?.();
|
|
1736
|
+
} else {
|
|
1737
|
+
setError(data.error || data.message || "Registration failed");
|
|
1738
|
+
}
|
|
1358
1739
|
} else {
|
|
1359
|
-
|
|
1740
|
+
const registerData = {
|
|
1741
|
+
name,
|
|
1742
|
+
password,
|
|
1743
|
+
frontendBaseUrl: typeof window !== "undefined" ? process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || window.location.origin : void 0
|
|
1744
|
+
};
|
|
1745
|
+
if (email)
|
|
1746
|
+
registerData.email = email;
|
|
1747
|
+
if (phoneNumber)
|
|
1748
|
+
registerData.phoneNumber = phoneNumber;
|
|
1749
|
+
const response = await register(registerData);
|
|
1750
|
+
if (response.success) {
|
|
1751
|
+
onRegisterSuccess?.();
|
|
1752
|
+
} else {
|
|
1753
|
+
setError(response.message || "Registration failed");
|
|
1754
|
+
}
|
|
1360
1755
|
}
|
|
1361
1756
|
} catch (err) {
|
|
1362
1757
|
setError(err instanceof Error ? err.message : "An unknown error occurred");
|
|
@@ -1367,40 +1762,40 @@ var RegisterForm = ({
|
|
|
1367
1762
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1368
1763
|
maxWidth: "400px",
|
|
1369
1764
|
margin: "0 auto",
|
|
1370
|
-
padding: "
|
|
1765
|
+
padding: "24px",
|
|
1371
1766
|
borderRadius: "12px",
|
|
1372
1767
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
1373
|
-
backgroundColor:
|
|
1374
|
-
border:
|
|
1768
|
+
backgroundColor: colors.bgPrimary,
|
|
1769
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
1375
1770
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: {
|
|
1376
1771
|
display: "flex",
|
|
1377
1772
|
flexDirection: "column"
|
|
1378
1773
|
}, children: [
|
|
1379
1774
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
|
|
1380
1775
|
textAlign: "center",
|
|
1381
|
-
marginBottom: "
|
|
1382
|
-
color:
|
|
1776
|
+
marginBottom: "20px",
|
|
1777
|
+
color: colors.textPrimary,
|
|
1383
1778
|
fontSize: "24px",
|
|
1384
1779
|
fontWeight: 600
|
|
1385
1780
|
}, children: "Register" }),
|
|
1386
1781
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1387
1782
|
padding: "12px 16px",
|
|
1388
|
-
marginBottom: "
|
|
1389
|
-
backgroundColor:
|
|
1390
|
-
color:
|
|
1391
|
-
border:
|
|
1783
|
+
marginBottom: "16px",
|
|
1784
|
+
backgroundColor: colors.errorBg,
|
|
1785
|
+
color: colors.errorText,
|
|
1786
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
1392
1787
|
borderRadius: "8px",
|
|
1393
1788
|
fontSize: "14px",
|
|
1394
1789
|
fontWeight: 500
|
|
1395
1790
|
}, children: error }),
|
|
1396
1791
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1397
|
-
marginBottom: "
|
|
1792
|
+
marginBottom: "16px"
|
|
1398
1793
|
}, children: [
|
|
1399
1794
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "name", style: {
|
|
1400
1795
|
display: "block",
|
|
1401
1796
|
marginBottom: "8px",
|
|
1402
1797
|
fontWeight: 500,
|
|
1403
|
-
color:
|
|
1798
|
+
color: colors.textSecondary,
|
|
1404
1799
|
fontSize: "14px"
|
|
1405
1800
|
}, children: "Name:" }),
|
|
1406
1801
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1415,26 +1810,26 @@ var RegisterForm = ({
|
|
|
1415
1810
|
style: {
|
|
1416
1811
|
width: "100%",
|
|
1417
1812
|
padding: "12px 16px",
|
|
1418
|
-
border:
|
|
1813
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1419
1814
|
borderRadius: "8px",
|
|
1420
1815
|
fontSize: "16px",
|
|
1421
1816
|
boxSizing: "border-box",
|
|
1422
|
-
color:
|
|
1817
|
+
color: colors.textPrimary,
|
|
1423
1818
|
transition: "all 0.2s ease",
|
|
1424
|
-
backgroundColor:
|
|
1819
|
+
backgroundColor: colors.bgSecondary
|
|
1425
1820
|
},
|
|
1426
1821
|
placeholder: "Enter your name"
|
|
1427
1822
|
}
|
|
1428
1823
|
)
|
|
1429
1824
|
] }),
|
|
1430
1825
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1431
|
-
marginBottom: "
|
|
1826
|
+
marginBottom: "16px"
|
|
1432
1827
|
}, children: [
|
|
1433
1828
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "register-email", style: {
|
|
1434
1829
|
display: "block",
|
|
1435
1830
|
marginBottom: "8px",
|
|
1436
1831
|
fontWeight: 500,
|
|
1437
|
-
color:
|
|
1832
|
+
color: colors.textSecondary,
|
|
1438
1833
|
fontSize: "14px"
|
|
1439
1834
|
}, children: "Email:" }),
|
|
1440
1835
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1444,31 +1839,52 @@ var RegisterForm = ({
|
|
|
1444
1839
|
type: "email",
|
|
1445
1840
|
value: email,
|
|
1446
1841
|
onChange: (e) => setEmail(e.target.value),
|
|
1447
|
-
required:
|
|
1842
|
+
required: !phoneNumber,
|
|
1448
1843
|
disabled: isLoading,
|
|
1449
1844
|
style: {
|
|
1450
1845
|
width: "100%",
|
|
1451
1846
|
padding: "12px 16px",
|
|
1452
|
-
border:
|
|
1847
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1453
1848
|
borderRadius: "8px",
|
|
1454
1849
|
fontSize: "16px",
|
|
1455
1850
|
boxSizing: "border-box",
|
|
1456
|
-
color:
|
|
1851
|
+
color: colors.textPrimary,
|
|
1457
1852
|
transition: "all 0.2s ease",
|
|
1458
|
-
backgroundColor:
|
|
1853
|
+
backgroundColor: colors.bgSecondary
|
|
1459
1854
|
},
|
|
1460
1855
|
placeholder: "Enter your email"
|
|
1461
1856
|
}
|
|
1462
1857
|
)
|
|
1463
1858
|
] }),
|
|
1464
1859
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1465
|
-
marginBottom: "
|
|
1860
|
+
marginBottom: "16px"
|
|
1861
|
+
}, children: [
|
|
1862
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "register-phone", style: {
|
|
1863
|
+
display: "block",
|
|
1864
|
+
marginBottom: "8px",
|
|
1865
|
+
fontWeight: 500,
|
|
1866
|
+
color: colors.textSecondary,
|
|
1867
|
+
fontSize: "14px"
|
|
1868
|
+
}, children: "Phone Number (Optional):" }),
|
|
1869
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1870
|
+
PhoneInput,
|
|
1871
|
+
{
|
|
1872
|
+
id: "register-phone",
|
|
1873
|
+
value: phoneNumber,
|
|
1874
|
+
onChange: setPhoneNumber,
|
|
1875
|
+
disabled: isLoading,
|
|
1876
|
+
placeholder: "1234567890"
|
|
1877
|
+
}
|
|
1878
|
+
)
|
|
1879
|
+
] }),
|
|
1880
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1881
|
+
marginBottom: "16px"
|
|
1466
1882
|
}, children: [
|
|
1467
1883
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
|
|
1468
1884
|
display: "block",
|
|
1469
1885
|
marginBottom: "8px",
|
|
1470
1886
|
fontWeight: 500,
|
|
1471
|
-
color:
|
|
1887
|
+
color: colors.textSecondary,
|
|
1472
1888
|
fontSize: "14px"
|
|
1473
1889
|
}, children: "Password:" }),
|
|
1474
1890
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1483,13 +1899,13 @@ var RegisterForm = ({
|
|
|
1483
1899
|
style: {
|
|
1484
1900
|
width: "100%",
|
|
1485
1901
|
padding: "12px 16px",
|
|
1486
|
-
border:
|
|
1902
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1487
1903
|
borderRadius: "8px",
|
|
1488
1904
|
fontSize: "16px",
|
|
1489
1905
|
boxSizing: "border-box",
|
|
1490
|
-
color:
|
|
1906
|
+
color: colors.textPrimary,
|
|
1491
1907
|
transition: "all 0.2s ease",
|
|
1492
|
-
backgroundColor:
|
|
1908
|
+
backgroundColor: colors.bgSecondary
|
|
1493
1909
|
},
|
|
1494
1910
|
placeholder: "Enter your password",
|
|
1495
1911
|
minLength: 6
|
|
@@ -1497,13 +1913,13 @@ var RegisterForm = ({
|
|
|
1497
1913
|
)
|
|
1498
1914
|
] }),
|
|
1499
1915
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1500
|
-
marginBottom: "
|
|
1916
|
+
marginBottom: "16px"
|
|
1501
1917
|
}, children: [
|
|
1502
1918
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "confirm-password", style: {
|
|
1503
1919
|
display: "block",
|
|
1504
1920
|
marginBottom: "8px",
|
|
1505
1921
|
fontWeight: 500,
|
|
1506
|
-
color:
|
|
1922
|
+
color: colors.textSecondary,
|
|
1507
1923
|
fontSize: "14px"
|
|
1508
1924
|
}, children: "Confirm Password:" }),
|
|
1509
1925
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1518,13 +1934,13 @@ var RegisterForm = ({
|
|
|
1518
1934
|
style: {
|
|
1519
1935
|
width: "100%",
|
|
1520
1936
|
padding: "12px 16px",
|
|
1521
|
-
border:
|
|
1937
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1522
1938
|
borderRadius: "8px",
|
|
1523
1939
|
fontSize: "16px",
|
|
1524
1940
|
boxSizing: "border-box",
|
|
1525
|
-
color:
|
|
1941
|
+
color: colors.textPrimary,
|
|
1526
1942
|
transition: "all 0.2s ease",
|
|
1527
|
-
backgroundColor:
|
|
1943
|
+
backgroundColor: colors.bgSecondary
|
|
1528
1944
|
},
|
|
1529
1945
|
placeholder: "Confirm your password"
|
|
1530
1946
|
}
|
|
@@ -1537,7 +1953,7 @@ var RegisterForm = ({
|
|
|
1537
1953
|
disabled: isLoading,
|
|
1538
1954
|
style: {
|
|
1539
1955
|
padding: "14px",
|
|
1540
|
-
backgroundColor:
|
|
1956
|
+
backgroundColor: colors.buttonPrimary,
|
|
1541
1957
|
color: "white",
|
|
1542
1958
|
border: "none",
|
|
1543
1959
|
borderRadius: "8px",
|
|
@@ -1545,15 +1961,15 @@ var RegisterForm = ({
|
|
|
1545
1961
|
fontWeight: 600,
|
|
1546
1962
|
cursor: "pointer",
|
|
1547
1963
|
transition: "all 0.2s ease",
|
|
1548
|
-
marginTop: "
|
|
1964
|
+
marginTop: "4px"
|
|
1549
1965
|
},
|
|
1550
1966
|
children: isLoading ? "Registering..." : "Register"
|
|
1551
1967
|
}
|
|
1552
1968
|
),
|
|
1553
1969
|
showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1554
|
-
marginTop: "
|
|
1555
|
-
paddingTop: "
|
|
1556
|
-
borderTop:
|
|
1970
|
+
marginTop: "16px",
|
|
1971
|
+
paddingTop: "16px",
|
|
1972
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1557
1973
|
}, children: [
|
|
1558
1974
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1559
1975
|
position: "relative",
|
|
@@ -1565,15 +1981,15 @@ var RegisterForm = ({
|
|
|
1565
1981
|
left: 0,
|
|
1566
1982
|
right: 0,
|
|
1567
1983
|
height: "1px",
|
|
1568
|
-
backgroundColor:
|
|
1984
|
+
backgroundColor: colors.borderPrimary
|
|
1569
1985
|
} }),
|
|
1570
1986
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1571
1987
|
position: "relative",
|
|
1572
1988
|
textAlign: "center"
|
|
1573
1989
|
}, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: {
|
|
1574
|
-
backgroundColor:
|
|
1990
|
+
backgroundColor: colors.bgPrimary,
|
|
1575
1991
|
padding: "0 12px",
|
|
1576
|
-
color:
|
|
1992
|
+
color: colors.textSecondary,
|
|
1577
1993
|
fontSize: "14px"
|
|
1578
1994
|
}, children: "Or continue with" }) })
|
|
1579
1995
|
] }),
|
|
@@ -1592,10 +2008,10 @@ var RegisterForm = ({
|
|
|
1592
2008
|
justifyContent: "center",
|
|
1593
2009
|
gap: "8px",
|
|
1594
2010
|
padding: "10px 16px",
|
|
1595
|
-
backgroundColor:
|
|
1596
|
-
border:
|
|
2011
|
+
backgroundColor: colors.bgPrimary,
|
|
2012
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1597
2013
|
borderRadius: "8px",
|
|
1598
|
-
color:
|
|
2014
|
+
color: colors.textPrimary,
|
|
1599
2015
|
textDecoration: "none",
|
|
1600
2016
|
fontSize: "14px",
|
|
1601
2017
|
fontWeight: 500,
|
|
@@ -1603,12 +2019,12 @@ var RegisterForm = ({
|
|
|
1603
2019
|
transition: "all 0.2s ease"
|
|
1604
2020
|
},
|
|
1605
2021
|
onMouseEnter: (e) => {
|
|
1606
|
-
e.currentTarget.style.backgroundColor =
|
|
1607
|
-
e.currentTarget.style.borderColor =
|
|
2022
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
2023
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
1608
2024
|
},
|
|
1609
2025
|
onMouseLeave: (e) => {
|
|
1610
|
-
e.currentTarget.style.backgroundColor =
|
|
1611
|
-
e.currentTarget.style.borderColor =
|
|
2026
|
+
e.currentTarget.style.backgroundColor = colors.bgPrimary;
|
|
2027
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
1612
2028
|
},
|
|
1613
2029
|
children: [
|
|
1614
2030
|
/* @__PURE__ */ jsxRuntime.jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
|
|
@@ -1683,11 +2099,11 @@ var RegisterForm = ({
|
|
|
1683
2099
|
] }),
|
|
1684
2100
|
showLoginLink && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1685
2101
|
textAlign: "center",
|
|
1686
|
-
marginTop: "
|
|
1687
|
-
paddingTop: "
|
|
1688
|
-
borderTop:
|
|
2102
|
+
marginTop: "16px",
|
|
2103
|
+
paddingTop: "16px",
|
|
2104
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1689
2105
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("p", { style: {
|
|
1690
|
-
color:
|
|
2106
|
+
color: colors.textSecondary,
|
|
1691
2107
|
fontSize: "14px"
|
|
1692
2108
|
}, children: [
|
|
1693
2109
|
"Already have an account?",
|
|
@@ -1701,7 +2117,7 @@ var RegisterForm = ({
|
|
|
1701
2117
|
style: {
|
|
1702
2118
|
background: "none",
|
|
1703
2119
|
border: "none",
|
|
1704
|
-
color:
|
|
2120
|
+
color: colors.buttonPrimary,
|
|
1705
2121
|
textDecoration: "none",
|
|
1706
2122
|
cursor: "pointer",
|
|
1707
2123
|
fontSize: "14px",
|
|
@@ -1718,15 +2134,17 @@ var RegisterForm = ({
|
|
|
1718
2134
|
var OtpForm = ({
|
|
1719
2135
|
email,
|
|
1720
2136
|
onVerifySuccess,
|
|
1721
|
-
onBackToLogin
|
|
2137
|
+
onBackToLogin,
|
|
2138
|
+
baseUrl
|
|
1722
2139
|
}) => {
|
|
1723
|
-
const
|
|
1724
|
-
const [
|
|
1725
|
-
const [
|
|
1726
|
-
const [
|
|
1727
|
-
const [
|
|
2140
|
+
const colors = useThemeColors();
|
|
2141
|
+
const [otp, setOtp] = React3.useState("");
|
|
2142
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
2143
|
+
const [error, setError] = React3.useState(null);
|
|
2144
|
+
const [resendCooldown, setResendCooldown] = React3.useState(0);
|
|
2145
|
+
const [resendLoading, setResendLoading] = React3.useState(false);
|
|
1728
2146
|
const { verify, login } = useAuth2({
|
|
1729
|
-
baseUrl:
|
|
2147
|
+
baseUrl: baseUrl || process.env.NEXT_PUBLIC_AUTH_API_URL || "http://localhost:7000"
|
|
1730
2148
|
});
|
|
1731
2149
|
const handleSubmit = async (e) => {
|
|
1732
2150
|
e.preventDefault();
|
|
@@ -1789,8 +2207,8 @@ var OtpForm = ({
|
|
|
1789
2207
|
padding: "30px",
|
|
1790
2208
|
borderRadius: "12px",
|
|
1791
2209
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
1792
|
-
backgroundColor:
|
|
1793
|
-
border:
|
|
2210
|
+
backgroundColor: colors.bgPrimary,
|
|
2211
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
1794
2212
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: {
|
|
1795
2213
|
display: "flex",
|
|
1796
2214
|
flexDirection: "column"
|
|
@@ -1798,25 +2216,25 @@ var OtpForm = ({
|
|
|
1798
2216
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
|
|
1799
2217
|
textAlign: "center",
|
|
1800
2218
|
marginBottom: "24px",
|
|
1801
|
-
color:
|
|
2219
|
+
color: colors.textPrimary,
|
|
1802
2220
|
fontSize: "24px",
|
|
1803
2221
|
fontWeight: 600
|
|
1804
2222
|
}, children: "Verify OTP" }),
|
|
1805
2223
|
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: {
|
|
1806
2224
|
textAlign: "center",
|
|
1807
2225
|
marginBottom: "24px",
|
|
1808
|
-
color:
|
|
2226
|
+
color: colors.textSecondary,
|
|
1809
2227
|
fontSize: "14px"
|
|
1810
2228
|
}, children: [
|
|
1811
2229
|
"Enter the 6-digit code sent to ",
|
|
1812
|
-
/* @__PURE__ */ jsxRuntime.jsx("strong", { style: { color:
|
|
2230
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { style: { color: colors.textPrimary }, children: email })
|
|
1813
2231
|
] }),
|
|
1814
2232
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1815
2233
|
padding: "12px 16px",
|
|
1816
2234
|
marginBottom: "20px",
|
|
1817
|
-
backgroundColor:
|
|
1818
|
-
color:
|
|
1819
|
-
border:
|
|
2235
|
+
backgroundColor: colors.errorBg,
|
|
2236
|
+
color: colors.errorText,
|
|
2237
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
1820
2238
|
borderRadius: "8px",
|
|
1821
2239
|
fontSize: "14px",
|
|
1822
2240
|
fontWeight: 500
|
|
@@ -1828,7 +2246,7 @@ var OtpForm = ({
|
|
|
1828
2246
|
display: "block",
|
|
1829
2247
|
marginBottom: "8px",
|
|
1830
2248
|
fontWeight: 500,
|
|
1831
|
-
color:
|
|
2249
|
+
color: colors.textSecondary,
|
|
1832
2250
|
fontSize: "14px"
|
|
1833
2251
|
}, children: "OTP Code:" }),
|
|
1834
2252
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1843,13 +2261,13 @@ var OtpForm = ({
|
|
|
1843
2261
|
style: {
|
|
1844
2262
|
width: "100%",
|
|
1845
2263
|
padding: "12px 16px",
|
|
1846
|
-
border:
|
|
2264
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1847
2265
|
borderRadius: "8px",
|
|
1848
2266
|
fontSize: "20px",
|
|
1849
2267
|
boxSizing: "border-box",
|
|
1850
|
-
color:
|
|
2268
|
+
color: colors.textPrimary,
|
|
1851
2269
|
transition: "all 0.2s ease",
|
|
1852
|
-
backgroundColor:
|
|
2270
|
+
backgroundColor: colors.bgSecondary,
|
|
1853
2271
|
textAlign: "center",
|
|
1854
2272
|
letterSpacing: "5px"
|
|
1855
2273
|
},
|
|
@@ -1866,7 +2284,7 @@ var OtpForm = ({
|
|
|
1866
2284
|
disabled: isLoading || otp.length !== 6,
|
|
1867
2285
|
style: {
|
|
1868
2286
|
padding: "14px",
|
|
1869
|
-
backgroundColor:
|
|
2287
|
+
backgroundColor: colors.buttonPrimary,
|
|
1870
2288
|
color: "white",
|
|
1871
2289
|
border: "none",
|
|
1872
2290
|
borderRadius: "8px",
|
|
@@ -1883,7 +2301,7 @@ var OtpForm = ({
|
|
|
1883
2301
|
textAlign: "center",
|
|
1884
2302
|
marginTop: "20px",
|
|
1885
2303
|
paddingTop: "20px",
|
|
1886
|
-
borderTop:
|
|
2304
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1887
2305
|
}, children: [
|
|
1888
2306
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1889
2307
|
"button",
|
|
@@ -1894,7 +2312,7 @@ var OtpForm = ({
|
|
|
1894
2312
|
style: {
|
|
1895
2313
|
background: "none",
|
|
1896
2314
|
border: "none",
|
|
1897
|
-
color: resendCooldown > 0 ?
|
|
2315
|
+
color: resendCooldown > 0 ? colors.textTertiary : colors.buttonPrimary,
|
|
1898
2316
|
textDecoration: "none",
|
|
1899
2317
|
cursor: resendCooldown > 0 ? "not-allowed" : "pointer",
|
|
1900
2318
|
fontSize: "14px",
|
|
@@ -1917,7 +2335,7 @@ var OtpForm = ({
|
|
|
1917
2335
|
style: {
|
|
1918
2336
|
background: "none",
|
|
1919
2337
|
border: "none",
|
|
1920
|
-
color:
|
|
2338
|
+
color: colors.buttonPrimary,
|
|
1921
2339
|
textDecoration: "none",
|
|
1922
2340
|
cursor: "pointer",
|
|
1923
2341
|
fontSize: "14px",
|
|
@@ -1936,9 +2354,9 @@ var AuthFlow = ({
|
|
|
1936
2354
|
initialStep = "login",
|
|
1937
2355
|
showTitle = true
|
|
1938
2356
|
}) => {
|
|
1939
|
-
const [step, setStep] =
|
|
1940
|
-
const [email, setEmail] =
|
|
1941
|
-
const [message, setMessage] =
|
|
2357
|
+
const [step, setStep] = React3.useState(initialStep);
|
|
2358
|
+
const [email, setEmail] = React3.useState("");
|
|
2359
|
+
const [message, setMessage] = React3.useState(null);
|
|
1942
2360
|
const handleLoginSuccess = (email2, needsOtpVerification) => {
|
|
1943
2361
|
setEmail(email2);
|
|
1944
2362
|
if (needsOtpVerification) {
|
|
@@ -2073,13 +2491,13 @@ var EmailVerificationPage = ({
|
|
|
2073
2491
|
onVerificationError,
|
|
2074
2492
|
baseUrl
|
|
2075
2493
|
}) => {
|
|
2076
|
-
const [isLoading, setIsLoading] =
|
|
2077
|
-
const [message, setMessage] =
|
|
2078
|
-
const [isSuccess, setIsSuccess] =
|
|
2494
|
+
const [isLoading, setIsLoading] = React3.useState(true);
|
|
2495
|
+
const [message, setMessage] = React3.useState("");
|
|
2496
|
+
const [isSuccess, setIsSuccess] = React3.useState(false);
|
|
2079
2497
|
const { verifyEmailToken } = useAuth2({
|
|
2080
2498
|
baseUrl: baseUrl || (typeof window !== "undefined" ? window.location.origin : "http://localhost:7000")
|
|
2081
2499
|
});
|
|
2082
|
-
|
|
2500
|
+
React3.useEffect(() => {
|
|
2083
2501
|
const verifyEmail = async () => {
|
|
2084
2502
|
if (!token) {
|
|
2085
2503
|
setIsLoading(false);
|
|
@@ -2184,18 +2602,31 @@ var EmailVerificationPage = ({
|
|
|
2184
2602
|
] })
|
|
2185
2603
|
] }) });
|
|
2186
2604
|
};
|
|
2605
|
+
var ThemeWrapper = React3.forwardRef(
|
|
2606
|
+
({ children, className = "", style }, ref) => {
|
|
2607
|
+
const { theme, mounted } = useAuthTheme();
|
|
2608
|
+
if (!mounted) {
|
|
2609
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className, style, children });
|
|
2610
|
+
}
|
|
2611
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: `${theme} ${className}`, style, children });
|
|
2612
|
+
}
|
|
2613
|
+
);
|
|
2614
|
+
ThemeWrapper.displayName = "ThemeWrapper";
|
|
2187
2615
|
var SignIn = ({ redirectUrl, appearance }) => {
|
|
2188
2616
|
const { signIn, isSignedIn, loading: authLoading } = useAuth();
|
|
2189
|
-
const
|
|
2190
|
-
const [
|
|
2191
|
-
const [
|
|
2192
|
-
const [
|
|
2193
|
-
const [
|
|
2194
|
-
const [
|
|
2195
|
-
const [
|
|
2196
|
-
const [
|
|
2197
|
-
const [
|
|
2198
|
-
|
|
2617
|
+
const colors = useThemeColors();
|
|
2618
|
+
const [email, setEmail] = React3.useState("");
|
|
2619
|
+
const [phoneNumber, setPhoneNumber] = React3.useState("");
|
|
2620
|
+
const [password, setPassword] = React3.useState("");
|
|
2621
|
+
const [otp, setOtp] = React3.useState("");
|
|
2622
|
+
const [usePassword, setUsePassword] = React3.useState(false);
|
|
2623
|
+
const [usePhone, setUsePhone] = React3.useState(false);
|
|
2624
|
+
const [showPassword, setShowPassword] = React3.useState(false);
|
|
2625
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
2626
|
+
const [error, setError] = React3.useState(null);
|
|
2627
|
+
const [needsOtp, setNeedsOtp] = React3.useState(false);
|
|
2628
|
+
const [success, setSuccess] = React3.useState(null);
|
|
2629
|
+
React3.useEffect(() => {
|
|
2199
2630
|
if (isSignedIn && redirectUrl) {
|
|
2200
2631
|
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
|
|
2201
2632
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -2208,25 +2639,26 @@ var SignIn = ({ redirectUrl, appearance }) => {
|
|
|
2208
2639
|
setError(null);
|
|
2209
2640
|
setSuccess(null);
|
|
2210
2641
|
try {
|
|
2642
|
+
const loginData = usePhone ? { phoneNumber } : { email };
|
|
2211
2643
|
if (needsOtp) {
|
|
2212
|
-
const response = await signIn({
|
|
2644
|
+
const response = await signIn({ ...loginData, otp });
|
|
2213
2645
|
if (response.success) {
|
|
2214
2646
|
setSuccess("Login successful!");
|
|
2215
2647
|
} else {
|
|
2216
2648
|
setError(response.message || "OTP verification failed");
|
|
2217
2649
|
}
|
|
2218
2650
|
} else if (usePassword) {
|
|
2219
|
-
const response = await signIn({
|
|
2651
|
+
const response = await signIn({ ...loginData, password });
|
|
2220
2652
|
if (response.success) {
|
|
2221
2653
|
setSuccess("Login successful!");
|
|
2222
2654
|
} else {
|
|
2223
2655
|
setError(response.message || "Login failed");
|
|
2224
2656
|
}
|
|
2225
2657
|
} else {
|
|
2226
|
-
const response = await signIn(
|
|
2227
|
-
if (response.success && response.message === "OTP sent to your email.") {
|
|
2658
|
+
const response = await signIn(loginData);
|
|
2659
|
+
if (response.success && (response.message === "OTP sent to your email." || response.message === "OTP sent to your phone number.")) {
|
|
2228
2660
|
setNeedsOtp(true);
|
|
2229
|
-
setSuccess("OTP sent to your email. Please check your inbox.");
|
|
2661
|
+
setSuccess(usePhone ? "OTP sent to your phone. Please check your messages." : "OTP sent to your email. Please check your inbox.");
|
|
2230
2662
|
} else {
|
|
2231
2663
|
setError(response.message || "Failed to send OTP");
|
|
2232
2664
|
}
|
|
@@ -2244,238 +2676,366 @@ var SignIn = ({ redirectUrl, appearance }) => {
|
|
|
2244
2676
|
setSuccess(null);
|
|
2245
2677
|
setOtp("");
|
|
2246
2678
|
};
|
|
2679
|
+
const toggleLoginMethod = () => {
|
|
2680
|
+
setUsePhone(!usePhone);
|
|
2681
|
+
setNeedsOtp(false);
|
|
2682
|
+
setError(null);
|
|
2683
|
+
setSuccess(null);
|
|
2684
|
+
setOtp("");
|
|
2685
|
+
setEmail("");
|
|
2686
|
+
setPhoneNumber("");
|
|
2687
|
+
};
|
|
2247
2688
|
if (authLoading) {
|
|
2248
2689
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", padding: "40px" }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Loading..." }) });
|
|
2249
2690
|
}
|
|
2250
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
padding: "12px 16px",
|
|
2270
|
-
marginBottom: "20px",
|
|
2271
|
-
backgroundColor: "#fee",
|
|
2272
|
-
color: "#c33",
|
|
2273
|
-
border: "1px solid #fcc",
|
|
2274
|
-
borderRadius: "8px",
|
|
2275
|
-
fontSize: "14px"
|
|
2276
|
-
}, children: error }),
|
|
2277
|
-
success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2278
|
-
padding: "12px 16px",
|
|
2279
|
-
marginBottom: "20px",
|
|
2280
|
-
backgroundColor: "#efe",
|
|
2281
|
-
color: "#3c3",
|
|
2282
|
-
border: "1px solid #cfc",
|
|
2283
|
-
borderRadius: "8px",
|
|
2284
|
-
fontSize: "14px"
|
|
2285
|
-
}, children: success }),
|
|
2286
|
-
!needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2287
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", style: {
|
|
2288
|
-
display: "block",
|
|
2289
|
-
marginBottom: "8px",
|
|
2290
|
-
fontWeight: 500,
|
|
2291
|
-
color: "#374151",
|
|
2292
|
-
fontSize: "14px"
|
|
2293
|
-
}, children: "Email" }),
|
|
2294
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2295
|
-
"input",
|
|
2296
|
-
{
|
|
2297
|
-
id: "email",
|
|
2298
|
-
type: "email",
|
|
2299
|
-
value: email,
|
|
2300
|
-
onChange: (e) => setEmail(e.target.value),
|
|
2301
|
-
required: true,
|
|
2302
|
-
disabled: isLoading,
|
|
2303
|
-
style: {
|
|
2304
|
-
width: "100%",
|
|
2305
|
-
padding: "12px 16px",
|
|
2306
|
-
border: "1px solid #ddd",
|
|
2307
|
-
borderRadius: "8px",
|
|
2308
|
-
fontSize: "16px",
|
|
2309
|
-
boxSizing: "border-box",
|
|
2310
|
-
...appearance?.elements?.formFieldInput
|
|
2311
|
-
},
|
|
2312
|
-
placeholder: "Enter your email"
|
|
2313
|
-
}
|
|
2314
|
-
)
|
|
2315
|
-
] }),
|
|
2316
|
-
usePassword && !needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
|
|
2317
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
|
|
2318
|
-
display: "block",
|
|
2319
|
-
marginBottom: "8px",
|
|
2320
|
-
fontWeight: 500,
|
|
2321
|
-
color: "#374151",
|
|
2322
|
-
fontSize: "14px"
|
|
2323
|
-
}, children: "Password" }),
|
|
2324
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2325
|
-
"input",
|
|
2326
|
-
{
|
|
2327
|
-
id: "password",
|
|
2328
|
-
type: showPassword ? "text" : "password",
|
|
2329
|
-
value: password,
|
|
2330
|
-
onChange: (e) => setPassword(e.target.value),
|
|
2331
|
-
required: true,
|
|
2332
|
-
disabled: isLoading,
|
|
2333
|
-
style: {
|
|
2334
|
-
width: "100%",
|
|
2335
|
-
padding: "12px 16px",
|
|
2336
|
-
border: "1px solid #ddd",
|
|
2337
|
-
borderRadius: "8px",
|
|
2338
|
-
fontSize: "16px",
|
|
2339
|
-
boxSizing: "border-box",
|
|
2340
|
-
...appearance?.elements?.formFieldInput
|
|
2341
|
-
},
|
|
2342
|
-
placeholder: "Enter your password"
|
|
2343
|
-
}
|
|
2344
|
-
),
|
|
2345
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2346
|
-
"button",
|
|
2347
|
-
{
|
|
2348
|
-
type: "button",
|
|
2349
|
-
onClick: () => setShowPassword(!showPassword),
|
|
2350
|
-
style: {
|
|
2351
|
-
position: "absolute",
|
|
2352
|
-
right: "12px",
|
|
2353
|
-
top: "38px",
|
|
2354
|
-
background: "none",
|
|
2355
|
-
border: "none",
|
|
2356
|
-
cursor: "pointer",
|
|
2357
|
-
color: "#666",
|
|
2358
|
-
fontSize: "14px"
|
|
2359
|
-
},
|
|
2360
|
-
children: showPassword ? "Hide" : "Show"
|
|
2361
|
-
}
|
|
2362
|
-
)
|
|
2363
|
-
] }),
|
|
2364
|
-
needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2365
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "otp", style: {
|
|
2366
|
-
display: "block",
|
|
2367
|
-
marginBottom: "8px",
|
|
2368
|
-
fontWeight: 500,
|
|
2369
|
-
color: "#374151",
|
|
2370
|
-
fontSize: "14px"
|
|
2371
|
-
}, children: "One-Time Password" }),
|
|
2372
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2373
|
-
"input",
|
|
2374
|
-
{
|
|
2375
|
-
id: "otp",
|
|
2376
|
-
type: "text",
|
|
2377
|
-
value: otp,
|
|
2378
|
-
onChange: (e) => setOtp(e.target.value),
|
|
2379
|
-
required: true,
|
|
2380
|
-
disabled: isLoading,
|
|
2381
|
-
maxLength: 6,
|
|
2382
|
-
style: {
|
|
2383
|
-
width: "100%",
|
|
2384
|
-
padding: "12px 16px",
|
|
2385
|
-
border: "1px solid #ddd",
|
|
2386
|
-
borderRadius: "8px",
|
|
2387
|
-
fontSize: "16px",
|
|
2388
|
-
boxSizing: "border-box",
|
|
2389
|
-
letterSpacing: "0.5em",
|
|
2390
|
-
textAlign: "center",
|
|
2391
|
-
...appearance?.elements?.formFieldInput
|
|
2392
|
-
},
|
|
2393
|
-
placeholder: "000000"
|
|
2394
|
-
}
|
|
2395
|
-
)
|
|
2396
|
-
] }),
|
|
2397
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2398
|
-
"button",
|
|
2399
|
-
{
|
|
2400
|
-
type: "submit",
|
|
2401
|
-
disabled: isLoading,
|
|
2402
|
-
style: {
|
|
2403
|
-
width: "100%",
|
|
2404
|
-
padding: "14px",
|
|
2405
|
-
backgroundColor: "#007bff",
|
|
2406
|
-
color: "white",
|
|
2407
|
-
border: "none",
|
|
2408
|
-
borderRadius: "8px",
|
|
2409
|
-
fontSize: "16px",
|
|
2691
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2692
|
+
ThemeWrapper,
|
|
2693
|
+
{
|
|
2694
|
+
style: {
|
|
2695
|
+
maxWidth: "400px",
|
|
2696
|
+
margin: "0 auto",
|
|
2697
|
+
padding: "30px",
|
|
2698
|
+
borderRadius: "12px",
|
|
2699
|
+
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
2700
|
+
backgroundColor: colors.bgPrimary,
|
|
2701
|
+
border: `1px solid ${colors.borderPrimary}`,
|
|
2702
|
+
...appearance?.elements?.card
|
|
2703
|
+
},
|
|
2704
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
|
|
2705
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
|
|
2706
|
+
textAlign: "center",
|
|
2707
|
+
marginBottom: "24px",
|
|
2708
|
+
color: colors.textPrimary,
|
|
2709
|
+
fontSize: "24px",
|
|
2410
2710
|
fontWeight: 600,
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
fontSize: "14px"
|
|
2430
|
-
|
|
2431
|
-
},
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2711
|
+
...appearance?.elements?.headerTitle
|
|
2712
|
+
}, children: needsOtp ? "Enter OTP" : usePassword ? "Sign in with password" : "Sign in" }),
|
|
2713
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2714
|
+
padding: "12px 16px",
|
|
2715
|
+
marginBottom: "20px",
|
|
2716
|
+
backgroundColor: colors.errorBg,
|
|
2717
|
+
color: colors.errorText,
|
|
2718
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
2719
|
+
borderRadius: "8px",
|
|
2720
|
+
fontSize: "14px"
|
|
2721
|
+
}, children: error }),
|
|
2722
|
+
success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2723
|
+
padding: "12px 16px",
|
|
2724
|
+
marginBottom: "20px",
|
|
2725
|
+
backgroundColor: colors.successBg,
|
|
2726
|
+
color: colors.successText,
|
|
2727
|
+
border: `1px solid ${colors.successBorder}`,
|
|
2728
|
+
borderRadius: "8px",
|
|
2729
|
+
fontSize: "14px"
|
|
2730
|
+
}, children: success }),
|
|
2731
|
+
!needsOtp && !usePhone && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2732
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", style: {
|
|
2733
|
+
display: "block",
|
|
2734
|
+
marginBottom: "8px",
|
|
2735
|
+
fontWeight: 500,
|
|
2736
|
+
color: colors.textSecondary,
|
|
2737
|
+
fontSize: "14px"
|
|
2738
|
+
}, children: "Email" }),
|
|
2739
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2740
|
+
"input",
|
|
2741
|
+
{
|
|
2742
|
+
id: "email",
|
|
2743
|
+
type: "email",
|
|
2744
|
+
value: email,
|
|
2745
|
+
onChange: (e) => setEmail(e.target.value),
|
|
2746
|
+
onFocus: (e) => {
|
|
2747
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
2748
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
2749
|
+
},
|
|
2750
|
+
onBlur: (e) => {
|
|
2751
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
2752
|
+
e.currentTarget.style.outline = "none";
|
|
2753
|
+
},
|
|
2754
|
+
required: true,
|
|
2755
|
+
disabled: isLoading,
|
|
2756
|
+
style: {
|
|
2757
|
+
width: "100%",
|
|
2758
|
+
padding: "12px 16px",
|
|
2759
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2760
|
+
borderRadius: "8px",
|
|
2761
|
+
fontSize: "16px",
|
|
2762
|
+
boxSizing: "border-box",
|
|
2763
|
+
backgroundColor: colors.bgSecondary,
|
|
2764
|
+
color: colors.textPrimary,
|
|
2765
|
+
transition: "all 0.2s ease",
|
|
2766
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
2767
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2768
|
+
...appearance?.elements?.formFieldInput
|
|
2769
|
+
},
|
|
2770
|
+
placeholder: "Enter your email"
|
|
2771
|
+
}
|
|
2772
|
+
)
|
|
2773
|
+
] }),
|
|
2774
|
+
!needsOtp && usePhone && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2775
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "phoneNumber", style: {
|
|
2776
|
+
display: "block",
|
|
2777
|
+
marginBottom: "8px",
|
|
2778
|
+
fontWeight: 500,
|
|
2779
|
+
color: colors.textSecondary,
|
|
2780
|
+
fontSize: "14px"
|
|
2781
|
+
}, children: "Phone Number" }),
|
|
2782
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2783
|
+
"input",
|
|
2784
|
+
{
|
|
2785
|
+
id: "phoneNumber",
|
|
2786
|
+
type: "tel",
|
|
2787
|
+
value: phoneNumber,
|
|
2788
|
+
onChange: (e) => setPhoneNumber(e.target.value),
|
|
2789
|
+
onFocus: (e) => {
|
|
2790
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
2791
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
2792
|
+
},
|
|
2793
|
+
onBlur: (e) => {
|
|
2794
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
2795
|
+
e.currentTarget.style.outline = "none";
|
|
2796
|
+
},
|
|
2797
|
+
required: true,
|
|
2798
|
+
disabled: isLoading,
|
|
2799
|
+
style: {
|
|
2800
|
+
width: "100%",
|
|
2801
|
+
padding: "12px 16px",
|
|
2802
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2803
|
+
borderRadius: "8px",
|
|
2804
|
+
fontSize: "16px",
|
|
2805
|
+
boxSizing: "border-box",
|
|
2806
|
+
backgroundColor: colors.bgSecondary,
|
|
2807
|
+
color: colors.textPrimary,
|
|
2808
|
+
transition: "all 0.2s ease",
|
|
2809
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
2810
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2811
|
+
...appearance?.elements?.formFieldInput
|
|
2812
|
+
},
|
|
2813
|
+
placeholder: "Enter your phone number"
|
|
2814
|
+
}
|
|
2815
|
+
)
|
|
2816
|
+
] }),
|
|
2817
|
+
usePassword && !needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
|
|
2818
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
|
|
2819
|
+
display: "block",
|
|
2820
|
+
marginBottom: "8px",
|
|
2821
|
+
fontWeight: 500,
|
|
2822
|
+
color: colors.textSecondary,
|
|
2823
|
+
fontSize: "14px"
|
|
2824
|
+
}, children: "Password" }),
|
|
2825
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2826
|
+
"input",
|
|
2827
|
+
{
|
|
2828
|
+
id: "password",
|
|
2829
|
+
type: showPassword ? "text" : "password",
|
|
2830
|
+
value: password,
|
|
2831
|
+
onChange: (e) => setPassword(e.target.value),
|
|
2832
|
+
onFocus: (e) => {
|
|
2833
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
2834
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
2835
|
+
},
|
|
2836
|
+
onBlur: (e) => {
|
|
2837
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
2838
|
+
e.currentTarget.style.outline = "none";
|
|
2839
|
+
},
|
|
2840
|
+
required: true,
|
|
2841
|
+
disabled: isLoading,
|
|
2842
|
+
style: {
|
|
2843
|
+
width: "100%",
|
|
2844
|
+
padding: "12px 16px",
|
|
2845
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2846
|
+
borderRadius: "8px",
|
|
2847
|
+
fontSize: "16px",
|
|
2848
|
+
boxSizing: "border-box",
|
|
2849
|
+
backgroundColor: colors.bgSecondary,
|
|
2850
|
+
color: colors.textPrimary,
|
|
2851
|
+
transition: "all 0.2s ease",
|
|
2852
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
2853
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2854
|
+
...appearance?.elements?.formFieldInput
|
|
2855
|
+
},
|
|
2856
|
+
placeholder: "Enter your password"
|
|
2857
|
+
}
|
|
2858
|
+
),
|
|
2859
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2860
|
+
"button",
|
|
2861
|
+
{
|
|
2862
|
+
type: "button",
|
|
2863
|
+
onClick: () => setShowPassword(!showPassword),
|
|
2864
|
+
style: {
|
|
2865
|
+
position: "absolute",
|
|
2866
|
+
right: "12px",
|
|
2867
|
+
top: "38px",
|
|
2868
|
+
background: "none",
|
|
2869
|
+
border: "none",
|
|
2870
|
+
cursor: "pointer",
|
|
2871
|
+
color: colors.textTertiary,
|
|
2872
|
+
fontSize: "14px"
|
|
2873
|
+
},
|
|
2874
|
+
children: showPassword ? "Hide" : "Show"
|
|
2875
|
+
}
|
|
2876
|
+
)
|
|
2877
|
+
] }),
|
|
2878
|
+
needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2879
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "otp", style: {
|
|
2880
|
+
display: "block",
|
|
2881
|
+
marginBottom: "8px",
|
|
2882
|
+
fontWeight: 500,
|
|
2883
|
+
color: colors.textSecondary,
|
|
2884
|
+
fontSize: "14px"
|
|
2885
|
+
}, children: "One-Time Password" }),
|
|
2886
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2887
|
+
"input",
|
|
2888
|
+
{
|
|
2889
|
+
id: "otp",
|
|
2890
|
+
type: "text",
|
|
2891
|
+
value: otp,
|
|
2892
|
+
onChange: (e) => setOtp(e.target.value),
|
|
2893
|
+
onFocus: (e) => {
|
|
2894
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
2895
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
2896
|
+
},
|
|
2897
|
+
onBlur: (e) => {
|
|
2898
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
2899
|
+
e.currentTarget.style.outline = "none";
|
|
2900
|
+
},
|
|
2901
|
+
required: true,
|
|
2902
|
+
disabled: isLoading,
|
|
2903
|
+
maxLength: 6,
|
|
2904
|
+
style: {
|
|
2905
|
+
width: "100%",
|
|
2906
|
+
padding: "12px 16px",
|
|
2907
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2908
|
+
borderRadius: "8px",
|
|
2909
|
+
fontSize: "16px",
|
|
2910
|
+
boxSizing: "border-box",
|
|
2911
|
+
letterSpacing: "0.5em",
|
|
2912
|
+
textAlign: "center",
|
|
2913
|
+
backgroundColor: colors.bgSecondary,
|
|
2914
|
+
color: colors.textPrimary,
|
|
2915
|
+
transition: "all 0.2s ease",
|
|
2916
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
2917
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2918
|
+
...appearance?.elements?.formFieldInput
|
|
2919
|
+
},
|
|
2920
|
+
placeholder: "000000"
|
|
2921
|
+
}
|
|
2922
|
+
)
|
|
2923
|
+
] }),
|
|
2924
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2925
|
+
"button",
|
|
2926
|
+
{
|
|
2927
|
+
type: "submit",
|
|
2928
|
+
disabled: isLoading,
|
|
2929
|
+
onMouseEnter: (e) => {
|
|
2930
|
+
if (!isLoading) {
|
|
2931
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
|
|
2932
|
+
}
|
|
2933
|
+
},
|
|
2934
|
+
onMouseLeave: (e) => {
|
|
2935
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimary;
|
|
2936
|
+
},
|
|
2937
|
+
style: {
|
|
2938
|
+
width: "100%",
|
|
2939
|
+
padding: "14px",
|
|
2940
|
+
backgroundColor: colors.buttonPrimary,
|
|
2941
|
+
color: "white",
|
|
2942
|
+
border: "none",
|
|
2943
|
+
borderRadius: "8px",
|
|
2944
|
+
fontSize: "16px",
|
|
2945
|
+
fontWeight: 600,
|
|
2946
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
2947
|
+
opacity: isLoading ? 0.6 : 1,
|
|
2948
|
+
transition: "all 0.2s ease",
|
|
2949
|
+
...appearance?.elements?.formButtonPrimary
|
|
2950
|
+
},
|
|
2951
|
+
children: isLoading ? "Please wait..." : needsOtp ? "Verify OTP" : usePassword ? "Sign in" : usePhone ? "Continue with phone" : "Continue with email"
|
|
2952
|
+
}
|
|
2953
|
+
),
|
|
2954
|
+
!needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { textAlign: "center", marginTop: "16px" }, children: [
|
|
2955
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2956
|
+
"button",
|
|
2957
|
+
{
|
|
2958
|
+
type: "button",
|
|
2959
|
+
onClick: toggleAuthMethod,
|
|
2960
|
+
disabled: isLoading,
|
|
2961
|
+
style: {
|
|
2962
|
+
background: "none",
|
|
2963
|
+
border: "none",
|
|
2964
|
+
color: colors.buttonPrimary,
|
|
2965
|
+
cursor: "pointer",
|
|
2966
|
+
fontSize: "14px",
|
|
2967
|
+
fontWeight: 600,
|
|
2968
|
+
marginRight: "16px"
|
|
2969
|
+
},
|
|
2970
|
+
children: usePassword ? "Use OTP code instead" : "Use password instead"
|
|
2971
|
+
}
|
|
2972
|
+
),
|
|
2973
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2974
|
+
"button",
|
|
2975
|
+
{
|
|
2976
|
+
type: "button",
|
|
2977
|
+
onClick: toggleLoginMethod,
|
|
2978
|
+
disabled: isLoading,
|
|
2979
|
+
style: {
|
|
2980
|
+
background: "none",
|
|
2981
|
+
border: "none",
|
|
2982
|
+
color: colors.buttonPrimary,
|
|
2983
|
+
cursor: "pointer",
|
|
2984
|
+
fontSize: "14px",
|
|
2985
|
+
fontWeight: 600
|
|
2986
|
+
},
|
|
2987
|
+
children: usePhone ? "Use email instead" : "Use phone instead"
|
|
2988
|
+
}
|
|
2989
|
+
)
|
|
2990
|
+
] }),
|
|
2991
|
+
needsOtp && /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", marginTop: "16px" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2992
|
+
"button",
|
|
2993
|
+
{
|
|
2994
|
+
type: "button",
|
|
2995
|
+
onClick: () => {
|
|
2996
|
+
setNeedsOtp(false);
|
|
2997
|
+
setOtp("");
|
|
2998
|
+
setError(null);
|
|
2999
|
+
setSuccess(null);
|
|
3000
|
+
},
|
|
3001
|
+
disabled: isLoading,
|
|
3002
|
+
style: {
|
|
3003
|
+
background: "none",
|
|
3004
|
+
border: "none",
|
|
3005
|
+
color: colors.buttonPrimary,
|
|
3006
|
+
cursor: "pointer",
|
|
3007
|
+
fontSize: "14px",
|
|
3008
|
+
fontWeight: 600
|
|
3009
|
+
},
|
|
3010
|
+
children: "Back to sign in"
|
|
3011
|
+
}
|
|
3012
|
+
) })
|
|
3013
|
+
] })
|
|
3014
|
+
}
|
|
3015
|
+
);
|
|
2458
3016
|
};
|
|
2459
3017
|
var SignUp = ({ redirectUrl, appearance }) => {
|
|
2460
3018
|
const { signUp, isSignedIn } = useAuth();
|
|
2461
|
-
const
|
|
2462
|
-
const [
|
|
2463
|
-
const [
|
|
2464
|
-
const [
|
|
2465
|
-
const [
|
|
2466
|
-
const [
|
|
2467
|
-
const [
|
|
2468
|
-
const [
|
|
2469
|
-
|
|
3019
|
+
const colors = useThemeColors();
|
|
3020
|
+
const [name, setName] = React3.useState("");
|
|
3021
|
+
const [email, setEmail] = React3.useState("");
|
|
3022
|
+
const [phoneNumber, setPhoneNumber] = React3.useState("");
|
|
3023
|
+
const [password, setPassword] = React3.useState("");
|
|
3024
|
+
const [confirmPassword, setConfirmPassword] = React3.useState("");
|
|
3025
|
+
const [showPassword, setShowPassword] = React3.useState(false);
|
|
3026
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
3027
|
+
const [error, setError] = React3.useState(null);
|
|
3028
|
+
const [success, setSuccess] = React3.useState(null);
|
|
3029
|
+
React3.useEffect(() => {
|
|
2470
3030
|
if (isSignedIn && redirectUrl) {
|
|
2471
3031
|
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_REGISTER || process.env.REACT_APP_AUTH_REDIRECT_AFTER_REGISTER || "/dashboard";
|
|
2472
3032
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2473
3033
|
window.location.href = `${baseUrl}${redirect}`;
|
|
2474
3034
|
}
|
|
2475
3035
|
}, [isSignedIn, redirectUrl]);
|
|
2476
|
-
const getPasswordStrength = (pwd) => {
|
|
3036
|
+
const getPasswordStrength = (pwd, colors2) => {
|
|
2477
3037
|
if (!pwd)
|
|
2478
|
-
return { strength: "weak", color:
|
|
3038
|
+
return { strength: "weak", color: colors2.borderSecondary };
|
|
2479
3039
|
let score = 0;
|
|
2480
3040
|
if (pwd.length >= 6)
|
|
2481
3041
|
score++;
|
|
@@ -2488,12 +3048,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2488
3048
|
if (/[^a-zA-Z\d]/.test(pwd))
|
|
2489
3049
|
score++;
|
|
2490
3050
|
if (score <= 2)
|
|
2491
|
-
return { strength: "weak", color:
|
|
3051
|
+
return { strength: "weak", color: colors2.errorText };
|
|
2492
3052
|
if (score <= 3)
|
|
2493
|
-
return { strength: "medium", color: "#fa4" };
|
|
2494
|
-
return { strength: "strong", color:
|
|
3053
|
+
return { strength: "medium", color: colors2.warningText || "#fa4" };
|
|
3054
|
+
return { strength: "strong", color: colors2.successText };
|
|
2495
3055
|
};
|
|
2496
|
-
const passwordStrength = getPasswordStrength(password);
|
|
3056
|
+
const passwordStrength = getPasswordStrength(password, colors);
|
|
2497
3057
|
const handleSubmit = async (e) => {
|
|
2498
3058
|
e.preventDefault();
|
|
2499
3059
|
setIsLoading(true);
|
|
@@ -2510,7 +3070,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2510
3070
|
return;
|
|
2511
3071
|
}
|
|
2512
3072
|
try {
|
|
2513
|
-
const
|
|
3073
|
+
const signUpData = { name, password };
|
|
3074
|
+
if (email)
|
|
3075
|
+
signUpData.email = email;
|
|
3076
|
+
if (phoneNumber)
|
|
3077
|
+
signUpData.phoneNumber = phoneNumber;
|
|
3078
|
+
const response = await signUp(signUpData);
|
|
2514
3079
|
if (response.success) {
|
|
2515
3080
|
setSuccess("Registration successful! Please check your email to verify your account.");
|
|
2516
3081
|
} else {
|
|
@@ -2522,20 +3087,20 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2522
3087
|
setIsLoading(false);
|
|
2523
3088
|
}
|
|
2524
3089
|
};
|
|
2525
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3090
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ThemeWrapper, { style: {
|
|
2526
3091
|
maxWidth: "400px",
|
|
2527
3092
|
margin: "0 auto",
|
|
2528
3093
|
padding: "30px",
|
|
2529
3094
|
borderRadius: "12px",
|
|
2530
3095
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
2531
|
-
backgroundColor:
|
|
2532
|
-
border:
|
|
3096
|
+
backgroundColor: colors.bgPrimary,
|
|
3097
|
+
border: `1px solid ${colors.borderPrimary}`,
|
|
2533
3098
|
...appearance?.elements?.card
|
|
2534
3099
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
|
|
2535
3100
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
|
|
2536
3101
|
textAlign: "center",
|
|
2537
3102
|
marginBottom: "24px",
|
|
2538
|
-
color:
|
|
3103
|
+
color: colors.textPrimary,
|
|
2539
3104
|
fontSize: "24px",
|
|
2540
3105
|
fontWeight: 600,
|
|
2541
3106
|
...appearance?.elements?.headerTitle
|
|
@@ -2543,18 +3108,18 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2543
3108
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2544
3109
|
padding: "12px 16px",
|
|
2545
3110
|
marginBottom: "20px",
|
|
2546
|
-
backgroundColor:
|
|
2547
|
-
color:
|
|
2548
|
-
border:
|
|
3111
|
+
backgroundColor: colors.errorBg,
|
|
3112
|
+
color: colors.errorText,
|
|
3113
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
2549
3114
|
borderRadius: "8px",
|
|
2550
3115
|
fontSize: "14px"
|
|
2551
3116
|
}, children: error }),
|
|
2552
3117
|
success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2553
3118
|
padding: "12px 16px",
|
|
2554
3119
|
marginBottom: "20px",
|
|
2555
|
-
backgroundColor:
|
|
2556
|
-
color:
|
|
2557
|
-
border:
|
|
3120
|
+
backgroundColor: colors.successBg,
|
|
3121
|
+
color: colors.successText,
|
|
3122
|
+
border: `1px solid ${colors.successBorder}`,
|
|
2558
3123
|
borderRadius: "8px",
|
|
2559
3124
|
fontSize: "14px"
|
|
2560
3125
|
}, children: success }),
|
|
@@ -2563,7 +3128,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2563
3128
|
display: "block",
|
|
2564
3129
|
marginBottom: "8px",
|
|
2565
3130
|
fontWeight: 500,
|
|
2566
|
-
color:
|
|
3131
|
+
color: colors.textSecondary,
|
|
2567
3132
|
fontSize: "14px"
|
|
2568
3133
|
}, children: "Full name" }),
|
|
2569
3134
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2573,15 +3138,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2573
3138
|
type: "text",
|
|
2574
3139
|
value: name,
|
|
2575
3140
|
onChange: (e) => setName(e.target.value),
|
|
3141
|
+
onFocus: (e) => {
|
|
3142
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
3143
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
3144
|
+
},
|
|
3145
|
+
onBlur: (e) => {
|
|
3146
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
3147
|
+
e.currentTarget.style.outline = "none";
|
|
3148
|
+
},
|
|
2576
3149
|
required: true,
|
|
2577
3150
|
disabled: isLoading,
|
|
2578
3151
|
style: {
|
|
2579
3152
|
width: "100%",
|
|
2580
3153
|
padding: "12px 16px",
|
|
2581
|
-
border:
|
|
3154
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2582
3155
|
borderRadius: "8px",
|
|
2583
3156
|
fontSize: "16px",
|
|
2584
3157
|
boxSizing: "border-box",
|
|
3158
|
+
backgroundColor: colors.bgSecondary,
|
|
3159
|
+
color: colors.textPrimary,
|
|
3160
|
+
transition: "all 0.2s ease",
|
|
3161
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
3162
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2585
3163
|
...appearance?.elements?.formFieldInput
|
|
2586
3164
|
},
|
|
2587
3165
|
placeholder: "Enter your full name"
|
|
@@ -2593,7 +3171,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2593
3171
|
display: "block",
|
|
2594
3172
|
marginBottom: "8px",
|
|
2595
3173
|
fontWeight: 500,
|
|
2596
|
-
color:
|
|
3174
|
+
color: colors.textSecondary,
|
|
2597
3175
|
fontSize: "14px"
|
|
2598
3176
|
}, children: "Email" }),
|
|
2599
3177
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2603,27 +3181,60 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2603
3181
|
type: "email",
|
|
2604
3182
|
value: email,
|
|
2605
3183
|
onChange: (e) => setEmail(e.target.value),
|
|
2606
|
-
|
|
3184
|
+
onFocus: (e) => {
|
|
3185
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
3186
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
3187
|
+
},
|
|
3188
|
+
onBlur: (e) => {
|
|
3189
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
3190
|
+
e.currentTarget.style.outline = "none";
|
|
3191
|
+
},
|
|
3192
|
+
required: !phoneNumber,
|
|
2607
3193
|
disabled: isLoading,
|
|
2608
3194
|
style: {
|
|
2609
3195
|
width: "100%",
|
|
2610
3196
|
padding: "12px 16px",
|
|
2611
|
-
border:
|
|
3197
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2612
3198
|
borderRadius: "8px",
|
|
2613
3199
|
fontSize: "16px",
|
|
2614
3200
|
boxSizing: "border-box",
|
|
3201
|
+
backgroundColor: colors.bgSecondary,
|
|
3202
|
+
color: colors.textPrimary,
|
|
3203
|
+
transition: "all 0.2s ease",
|
|
3204
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
3205
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2615
3206
|
...appearance?.elements?.formFieldInput
|
|
2616
3207
|
},
|
|
2617
3208
|
placeholder: "Enter your email"
|
|
2618
3209
|
}
|
|
2619
3210
|
)
|
|
2620
3211
|
] }),
|
|
3212
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
3213
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "phoneNumber", style: {
|
|
3214
|
+
display: "block",
|
|
3215
|
+
marginBottom: "8px",
|
|
3216
|
+
fontWeight: 500,
|
|
3217
|
+
color: colors.textSecondary,
|
|
3218
|
+
fontSize: "14px"
|
|
3219
|
+
}, children: "Phone Number (Optional)" }),
|
|
3220
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3221
|
+
PhoneInput,
|
|
3222
|
+
{
|
|
3223
|
+
id: "phoneNumber",
|
|
3224
|
+
value: phoneNumber,
|
|
3225
|
+
onChange: setPhoneNumber,
|
|
3226
|
+
disabled: isLoading,
|
|
3227
|
+
placeholder: "1234567890",
|
|
3228
|
+
style: appearance?.elements?.formFieldInput
|
|
3229
|
+
}
|
|
3230
|
+
)
|
|
3231
|
+
] }),
|
|
2621
3232
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
|
|
2622
3233
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
|
|
2623
3234
|
display: "block",
|
|
2624
3235
|
marginBottom: "8px",
|
|
2625
3236
|
fontWeight: 500,
|
|
2626
|
-
color:
|
|
3237
|
+
color: colors.textSecondary,
|
|
2627
3238
|
fontSize: "14px"
|
|
2628
3239
|
}, children: "Password" }),
|
|
2629
3240
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2633,16 +3244,29 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2633
3244
|
type: showPassword ? "text" : "password",
|
|
2634
3245
|
value: password,
|
|
2635
3246
|
onChange: (e) => setPassword(e.target.value),
|
|
3247
|
+
onFocus: (e) => {
|
|
3248
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
3249
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
3250
|
+
},
|
|
3251
|
+
onBlur: (e) => {
|
|
3252
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
3253
|
+
e.currentTarget.style.outline = "none";
|
|
3254
|
+
},
|
|
2636
3255
|
required: true,
|
|
2637
3256
|
disabled: isLoading,
|
|
2638
3257
|
minLength: 6,
|
|
2639
3258
|
style: {
|
|
2640
3259
|
width: "100%",
|
|
2641
3260
|
padding: "12px 16px",
|
|
2642
|
-
border:
|
|
3261
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2643
3262
|
borderRadius: "8px",
|
|
2644
3263
|
fontSize: "16px",
|
|
2645
3264
|
boxSizing: "border-box",
|
|
3265
|
+
backgroundColor: colors.bgSecondary,
|
|
3266
|
+
color: colors.textPrimary,
|
|
3267
|
+
transition: "all 0.2s ease",
|
|
3268
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
3269
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2646
3270
|
...appearance?.elements?.formFieldInput
|
|
2647
3271
|
},
|
|
2648
3272
|
placeholder: "Create a password"
|
|
@@ -2660,7 +3284,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2660
3284
|
background: "none",
|
|
2661
3285
|
border: "none",
|
|
2662
3286
|
cursor: "pointer",
|
|
2663
|
-
color:
|
|
3287
|
+
color: colors.textTertiary,
|
|
2664
3288
|
fontSize: "14px"
|
|
2665
3289
|
},
|
|
2666
3290
|
children: showPassword ? "Hide" : "Show"
|
|
@@ -2669,7 +3293,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2669
3293
|
password && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: "8px" }, children: [
|
|
2670
3294
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2671
3295
|
height: "4px",
|
|
2672
|
-
backgroundColor:
|
|
3296
|
+
backgroundColor: colors.borderSecondary,
|
|
2673
3297
|
borderRadius: "2px",
|
|
2674
3298
|
overflow: "hidden"
|
|
2675
3299
|
}, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
@@ -2694,7 +3318,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2694
3318
|
display: "block",
|
|
2695
3319
|
marginBottom: "8px",
|
|
2696
3320
|
fontWeight: 500,
|
|
2697
|
-
color:
|
|
3321
|
+
color: colors.textSecondary,
|
|
2698
3322
|
fontSize: "14px"
|
|
2699
3323
|
}, children: "Confirm password" }),
|
|
2700
3324
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2704,15 +3328,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2704
3328
|
type: showPassword ? "text" : "password",
|
|
2705
3329
|
value: confirmPassword,
|
|
2706
3330
|
onChange: (e) => setConfirmPassword(e.target.value),
|
|
3331
|
+
onFocus: (e) => {
|
|
3332
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
3333
|
+
e.currentTarget.style.outline = `2px solid ${colors.buttonPrimary}40`;
|
|
3334
|
+
},
|
|
3335
|
+
onBlur: (e) => {
|
|
3336
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
3337
|
+
e.currentTarget.style.outline = "none";
|
|
3338
|
+
},
|
|
2707
3339
|
required: true,
|
|
2708
3340
|
disabled: isLoading,
|
|
2709
3341
|
style: {
|
|
2710
3342
|
width: "100%",
|
|
2711
3343
|
padding: "12px 16px",
|
|
2712
|
-
border:
|
|
3344
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2713
3345
|
borderRadius: "8px",
|
|
2714
3346
|
fontSize: "16px",
|
|
2715
3347
|
boxSizing: "border-box",
|
|
3348
|
+
backgroundColor: colors.bgSecondary,
|
|
3349
|
+
color: colors.textPrimary,
|
|
3350
|
+
transition: "all 0.2s ease",
|
|
3351
|
+
WebkitTextFillColor: colors.textPrimary,
|
|
3352
|
+
WebkitBoxShadow: `0 0 0 1000px ${colors.bgSecondary} inset`,
|
|
2716
3353
|
...appearance?.elements?.formFieldInput
|
|
2717
3354
|
},
|
|
2718
3355
|
placeholder: "Confirm your password"
|
|
@@ -2724,16 +3361,25 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2724
3361
|
{
|
|
2725
3362
|
type: "submit",
|
|
2726
3363
|
disabled: isLoading,
|
|
3364
|
+
onMouseEnter: (e) => {
|
|
3365
|
+
if (!isLoading) {
|
|
3366
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
|
|
3367
|
+
}
|
|
3368
|
+
},
|
|
3369
|
+
onMouseLeave: (e) => {
|
|
3370
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimary;
|
|
3371
|
+
},
|
|
2727
3372
|
style: {
|
|
2728
3373
|
width: "100%",
|
|
2729
3374
|
padding: "14px",
|
|
2730
|
-
backgroundColor:
|
|
3375
|
+
backgroundColor: colors.buttonPrimary,
|
|
2731
3376
|
color: "white",
|
|
2732
3377
|
border: "none",
|
|
2733
3378
|
borderRadius: "8px",
|
|
2734
3379
|
fontSize: "16px",
|
|
2735
3380
|
fontWeight: 600,
|
|
2736
|
-
cursor: "pointer",
|
|
3381
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
3382
|
+
opacity: isLoading ? 0.6 : 1,
|
|
2737
3383
|
transition: "all 0.2s ease",
|
|
2738
3384
|
...appearance?.elements?.formButtonPrimary
|
|
2739
3385
|
},
|
|
@@ -2744,7 +3390,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2744
3390
|
};
|
|
2745
3391
|
var SignOut = ({ redirectUrl }) => {
|
|
2746
3392
|
const { signOut } = useAuth();
|
|
2747
|
-
|
|
3393
|
+
React3.useEffect(() => {
|
|
2748
3394
|
const performSignOut = async () => {
|
|
2749
3395
|
await signOut();
|
|
2750
3396
|
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
|
|
@@ -2757,9 +3403,10 @@ var SignOut = ({ redirectUrl }) => {
|
|
|
2757
3403
|
};
|
|
2758
3404
|
var UserButton = ({ showName = false, appearance }) => {
|
|
2759
3405
|
const { user, signOut } = useAuth();
|
|
2760
|
-
const
|
|
2761
|
-
const
|
|
2762
|
-
|
|
3406
|
+
const colors = useThemeColors();
|
|
3407
|
+
const [isOpen, setIsOpen] = React3.useState(false);
|
|
3408
|
+
const dropdownRef = React3.useRef(null);
|
|
3409
|
+
React3.useEffect(() => {
|
|
2763
3410
|
const handleClickOutside = (event) => {
|
|
2764
3411
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
2765
3412
|
setIsOpen(false);
|
|
@@ -2779,7 +3426,7 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2779
3426
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2780
3427
|
window.location.href = `${baseUrl}${redirect}`;
|
|
2781
3428
|
};
|
|
2782
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3429
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ThemeWrapper, { style: { position: "relative", ...appearance?.elements?.userButtonBox }, ref: dropdownRef, children: [
|
|
2783
3430
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2784
3431
|
"button",
|
|
2785
3432
|
{
|
|
@@ -2797,7 +3444,7 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2797
3444
|
...appearance?.elements?.userButtonTrigger
|
|
2798
3445
|
},
|
|
2799
3446
|
onMouseEnter: (e) => {
|
|
2800
|
-
e.currentTarget.style.backgroundColor =
|
|
3447
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
2801
3448
|
},
|
|
2802
3449
|
onMouseLeave: (e) => {
|
|
2803
3450
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
@@ -2807,15 +3454,15 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2807
3454
|
width: "36px",
|
|
2808
3455
|
height: "36px",
|
|
2809
3456
|
borderRadius: "50%",
|
|
2810
|
-
backgroundColor:
|
|
2811
|
-
color:
|
|
3457
|
+
backgroundColor: colors.buttonPrimary,
|
|
3458
|
+
color: colors.textPrimary,
|
|
2812
3459
|
display: "flex",
|
|
2813
3460
|
alignItems: "center",
|
|
2814
3461
|
justifyContent: "center",
|
|
2815
3462
|
fontSize: "14px",
|
|
2816
3463
|
fontWeight: 600
|
|
2817
3464
|
}, children: getInitials(user.name) }),
|
|
2818
|
-
showName && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "14px", fontWeight: 500, color:
|
|
3465
|
+
showName && /* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "14px", fontWeight: 500, color: colors.textPrimary }, children: user.name })
|
|
2819
3466
|
]
|
|
2820
3467
|
}
|
|
2821
3468
|
),
|
|
@@ -2825,16 +3472,16 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2825
3472
|
right: 0,
|
|
2826
3473
|
marginTop: "8px",
|
|
2827
3474
|
width: "240px",
|
|
2828
|
-
backgroundColor:
|
|
3475
|
+
backgroundColor: colors.bgPrimary,
|
|
2829
3476
|
borderRadius: "12px",
|
|
2830
3477
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.15)",
|
|
2831
|
-
border:
|
|
3478
|
+
border: `1px solid ${colors.borderPrimary}`,
|
|
2832
3479
|
zIndex: 1e3,
|
|
2833
3480
|
...appearance?.elements?.userButtonPopoverCard
|
|
2834
3481
|
}, children: [
|
|
2835
3482
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2836
3483
|
padding: "16px",
|
|
2837
|
-
borderBottom:
|
|
3484
|
+
borderBottom: `1px solid ${colors.borderPrimary}`
|
|
2838
3485
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
2839
3486
|
display: "flex",
|
|
2840
3487
|
alignItems: "center",
|
|
@@ -2844,8 +3491,8 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2844
3491
|
width: "48px",
|
|
2845
3492
|
height: "48px",
|
|
2846
3493
|
borderRadius: "50%",
|
|
2847
|
-
backgroundColor:
|
|
2848
|
-
color:
|
|
3494
|
+
backgroundColor: colors.buttonPrimary,
|
|
3495
|
+
color: colors.textPrimary,
|
|
2849
3496
|
display: "flex",
|
|
2850
3497
|
alignItems: "center",
|
|
2851
3498
|
justifyContent: "center",
|
|
@@ -2856,14 +3503,14 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2856
3503
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2857
3504
|
fontSize: "14px",
|
|
2858
3505
|
fontWeight: 600,
|
|
2859
|
-
color:
|
|
3506
|
+
color: colors.textPrimary,
|
|
2860
3507
|
overflow: "hidden",
|
|
2861
3508
|
textOverflow: "ellipsis",
|
|
2862
3509
|
whiteSpace: "nowrap"
|
|
2863
3510
|
}, children: user.name }),
|
|
2864
3511
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2865
3512
|
fontSize: "12px",
|
|
2866
|
-
color:
|
|
3513
|
+
color: colors.textTertiary,
|
|
2867
3514
|
overflow: "hidden",
|
|
2868
3515
|
textOverflow: "ellipsis",
|
|
2869
3516
|
whiteSpace: "nowrap"
|
|
@@ -2883,12 +3530,12 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2883
3530
|
textAlign: "left",
|
|
2884
3531
|
cursor: "pointer",
|
|
2885
3532
|
fontSize: "14px",
|
|
2886
|
-
color:
|
|
3533
|
+
color: colors.textPrimary,
|
|
2887
3534
|
fontWeight: 500,
|
|
2888
3535
|
transition: "background-color 0.2s"
|
|
2889
3536
|
},
|
|
2890
3537
|
onMouseEnter: (e) => {
|
|
2891
|
-
e.currentTarget.style.backgroundColor =
|
|
3538
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
2892
3539
|
},
|
|
2893
3540
|
onMouseLeave: (e) => {
|
|
2894
3541
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
@@ -2905,7 +3552,7 @@ var ProtectedRoute = ({
|
|
|
2905
3552
|
redirectTo
|
|
2906
3553
|
}) => {
|
|
2907
3554
|
const { isSignedIn, isLoaded } = useAuth();
|
|
2908
|
-
|
|
3555
|
+
React3.useEffect(() => {
|
|
2909
3556
|
if (isLoaded && !isSignedIn) {
|
|
2910
3557
|
const loginPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
|
|
2911
3558
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -2930,7 +3577,7 @@ var PublicRoute = ({
|
|
|
2930
3577
|
redirectTo
|
|
2931
3578
|
}) => {
|
|
2932
3579
|
const { isSignedIn, isLoaded } = useAuth();
|
|
2933
|
-
|
|
3580
|
+
React3.useEffect(() => {
|
|
2934
3581
|
if (isLoaded && isSignedIn) {
|
|
2935
3582
|
const dashboardPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
|
|
2936
3583
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -2952,9 +3599,9 @@ var PublicRoute = ({
|
|
|
2952
3599
|
};
|
|
2953
3600
|
var VerifyEmail = ({ token, onSuccess, onError }) => {
|
|
2954
3601
|
const { verifyEmailToken } = useAuth();
|
|
2955
|
-
const [status, setStatus] =
|
|
2956
|
-
const [message, setMessage] =
|
|
2957
|
-
|
|
3602
|
+
const [status, setStatus] = React3.useState("loading");
|
|
3603
|
+
const [message, setMessage] = React3.useState("");
|
|
3604
|
+
React3.useEffect(() => {
|
|
2958
3605
|
const verify = async () => {
|
|
2959
3606
|
const verifyToken = token || (typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("token") : null);
|
|
2960
3607
|
if (!verifyToken) {
|
|
@@ -3088,10 +3735,10 @@ var VerifyEmail = ({ token, onSuccess, onError }) => {
|
|
|
3088
3735
|
};
|
|
3089
3736
|
var ForgotPassword = ({ appearance }) => {
|
|
3090
3737
|
const { forgotPassword } = useAuth();
|
|
3091
|
-
const [email, setEmail] =
|
|
3092
|
-
const [isLoading, setIsLoading] =
|
|
3093
|
-
const [error, setError] =
|
|
3094
|
-
const [success, setSuccess] =
|
|
3738
|
+
const [email, setEmail] = React3.useState("");
|
|
3739
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
3740
|
+
const [error, setError] = React3.useState(null);
|
|
3741
|
+
const [success, setSuccess] = React3.useState(null);
|
|
3095
3742
|
const handleSubmit = async (e) => {
|
|
3096
3743
|
e.preventDefault();
|
|
3097
3744
|
setIsLoading(true);
|
|
@@ -3230,14 +3877,14 @@ var ForgotPassword = ({ appearance }) => {
|
|
|
3230
3877
|
};
|
|
3231
3878
|
var ResetPassword = ({ token, appearance }) => {
|
|
3232
3879
|
const { resetPassword } = useAuth();
|
|
3233
|
-
const [resetToken, setResetToken] =
|
|
3234
|
-
const [password, setPassword] =
|
|
3235
|
-
const [confirmPassword, setConfirmPassword] =
|
|
3236
|
-
const [showPassword, setShowPassword] =
|
|
3237
|
-
const [isLoading, setIsLoading] =
|
|
3238
|
-
const [error, setError] =
|
|
3239
|
-
const [success, setSuccess] =
|
|
3240
|
-
|
|
3880
|
+
const [resetToken, setResetToken] = React3.useState(token || "");
|
|
3881
|
+
const [password, setPassword] = React3.useState("");
|
|
3882
|
+
const [confirmPassword, setConfirmPassword] = React3.useState("");
|
|
3883
|
+
const [showPassword, setShowPassword] = React3.useState(false);
|
|
3884
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
3885
|
+
const [error, setError] = React3.useState(null);
|
|
3886
|
+
const [success, setSuccess] = React3.useState(false);
|
|
3887
|
+
React3.useEffect(() => {
|
|
3241
3888
|
if (!resetToken && typeof window !== "undefined") {
|
|
3242
3889
|
const urlToken = new URLSearchParams(window.location.search).get("token");
|
|
3243
3890
|
if (urlToken) {
|
|
@@ -3492,13 +4139,13 @@ var ResetPassword = ({ token, appearance }) => {
|
|
|
3492
4139
|
};
|
|
3493
4140
|
var ChangePassword = ({ onSuccess, appearance }) => {
|
|
3494
4141
|
const { changePassword } = useAuth();
|
|
3495
|
-
const [oldPassword, setOldPassword] =
|
|
3496
|
-
const [newPassword, setNewPassword] =
|
|
3497
|
-
const [confirmPassword, setConfirmPassword] =
|
|
3498
|
-
const [showPasswords, setShowPasswords] =
|
|
3499
|
-
const [isLoading, setIsLoading] =
|
|
3500
|
-
const [error, setError] =
|
|
3501
|
-
const [success, setSuccess] =
|
|
4142
|
+
const [oldPassword, setOldPassword] = React3.useState("");
|
|
4143
|
+
const [newPassword, setNewPassword] = React3.useState("");
|
|
4144
|
+
const [confirmPassword, setConfirmPassword] = React3.useState("");
|
|
4145
|
+
const [showPasswords, setShowPasswords] = React3.useState(false);
|
|
4146
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
4147
|
+
const [error, setError] = React3.useState(null);
|
|
4148
|
+
const [success, setSuccess] = React3.useState(false);
|
|
3502
4149
|
const getPasswordStrength = (pwd) => {
|
|
3503
4150
|
if (!pwd)
|
|
3504
4151
|
return { strength: "weak", color: "#ddd" };
|
|
@@ -3741,43 +4388,41 @@ var UserProfile = ({
|
|
|
3741
4388
|
showEmailChange = true,
|
|
3742
4389
|
showPasswordChange = true
|
|
3743
4390
|
}) => {
|
|
3744
|
-
const { user, updateProfile,
|
|
3745
|
-
const
|
|
3746
|
-
const [
|
|
3747
|
-
const [
|
|
3748
|
-
const [
|
|
3749
|
-
const [
|
|
3750
|
-
const [
|
|
3751
|
-
const
|
|
4391
|
+
const { user, updateProfile, requestEmailChange } = useAuth();
|
|
4392
|
+
const colors = useThemeColors();
|
|
4393
|
+
const [name, setName] = React3.useState(user?.name || "");
|
|
4394
|
+
const [avatar, setAvatar] = React3.useState(user?.avatar || "");
|
|
4395
|
+
const [phoneNumber, setPhoneNumber] = React3.useState(user?.phoneNumber || "");
|
|
4396
|
+
const [newEmail, setNewEmail] = React3.useState("");
|
|
4397
|
+
const [isLoading, setIsLoading] = React3.useState(false);
|
|
4398
|
+
const [error, setError] = React3.useState(null);
|
|
4399
|
+
const [success, setSuccess] = React3.useState(null);
|
|
4400
|
+
const handleUpdateProfile = async (e) => {
|
|
3752
4401
|
e.preventDefault();
|
|
3753
4402
|
setIsLoading(true);
|
|
3754
4403
|
setError(null);
|
|
3755
4404
|
setSuccess(null);
|
|
3756
4405
|
try {
|
|
3757
|
-
const
|
|
3758
|
-
if (
|
|
3759
|
-
|
|
3760
|
-
} else {
|
|
3761
|
-
setError(response.message || "Failed to update name");
|
|
4406
|
+
const updates = {};
|
|
4407
|
+
if (name !== user?.name) {
|
|
4408
|
+
updates.name = name;
|
|
3762
4409
|
}
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
const response = await updateAvatar(avatar);
|
|
4410
|
+
if (showAvatar && avatar !== user?.avatar) {
|
|
4411
|
+
updates.avatar = avatar;
|
|
4412
|
+
}
|
|
4413
|
+
if (phoneNumber !== user?.phoneNumber) {
|
|
4414
|
+
updates.phoneNumber = phoneNumber;
|
|
4415
|
+
}
|
|
4416
|
+
if (Object.keys(updates).length === 0) {
|
|
4417
|
+
setError("No changes to save");
|
|
4418
|
+
setIsLoading(false);
|
|
4419
|
+
return;
|
|
4420
|
+
}
|
|
4421
|
+
const response = await updateProfile(updates);
|
|
3776
4422
|
if (response.success) {
|
|
3777
|
-
setSuccess("
|
|
3778
|
-
setAvatar("");
|
|
4423
|
+
setSuccess("Profile updated successfully!");
|
|
3779
4424
|
} else {
|
|
3780
|
-
setError(response.message || "Failed to update
|
|
4425
|
+
setError(response.message || "Failed to update profile");
|
|
3781
4426
|
}
|
|
3782
4427
|
} catch (err) {
|
|
3783
4428
|
setError(err instanceof Error ? err.message : "An error occurred");
|
|
@@ -3806,173 +4451,220 @@ var UserProfile = ({
|
|
|
3806
4451
|
};
|
|
3807
4452
|
if (!user)
|
|
3808
4453
|
return null;
|
|
3809
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { maxWidth: "
|
|
3810
|
-
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600 }, children: "Profile Settings" }),
|
|
4454
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { maxWidth: "700px", margin: "0 auto", padding: "20px" }, children: [
|
|
4455
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: { marginBottom: "24px", fontSize: "24px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Settings" }),
|
|
3811
4456
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
3812
4457
|
padding: "12px 16px",
|
|
3813
4458
|
marginBottom: "20px",
|
|
3814
|
-
backgroundColor:
|
|
3815
|
-
color:
|
|
3816
|
-
border:
|
|
4459
|
+
backgroundColor: colors.errorBg,
|
|
4460
|
+
color: colors.errorText,
|
|
4461
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
3817
4462
|
borderRadius: "8px",
|
|
3818
4463
|
fontSize: "14px"
|
|
3819
4464
|
}, children: error }),
|
|
3820
4465
|
success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
3821
4466
|
padding: "12px 16px",
|
|
3822
4467
|
marginBottom: "20px",
|
|
3823
|
-
backgroundColor:
|
|
3824
|
-
color:
|
|
3825
|
-
border:
|
|
4468
|
+
backgroundColor: colors.successBg,
|
|
4469
|
+
color: colors.successText,
|
|
4470
|
+
border: `1px solid ${colors.successBorder}`,
|
|
3826
4471
|
borderRadius: "8px",
|
|
3827
4472
|
fontSize: "14px"
|
|
3828
4473
|
}, children: success }),
|
|
3829
4474
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
3830
|
-
padding: "
|
|
3831
|
-
backgroundColor:
|
|
3832
|
-
borderRadius: "
|
|
4475
|
+
padding: "24px",
|
|
4476
|
+
backgroundColor: colors.bgPrimary,
|
|
4477
|
+
borderRadius: "12px",
|
|
3833
4478
|
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3834
|
-
marginBottom: "
|
|
4479
|
+
marginBottom: "24px",
|
|
4480
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
3835
4481
|
}, children: [
|
|
3836
|
-
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "
|
|
3837
|
-
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit:
|
|
3838
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3839
|
-
"
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
4482
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "20px", fontSize: "18px", fontWeight: 600, color: colors.textPrimary }, children: "Profile Information" }),
|
|
4483
|
+
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleUpdateProfile, children: [
|
|
4484
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
4485
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "name", style: {
|
|
4486
|
+
display: "block",
|
|
4487
|
+
marginBottom: "8px",
|
|
4488
|
+
fontWeight: 500,
|
|
4489
|
+
color: colors.textSecondary,
|
|
4490
|
+
fontSize: "14px"
|
|
4491
|
+
}, children: "Full Name" }),
|
|
4492
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4493
|
+
"input",
|
|
4494
|
+
{
|
|
4495
|
+
id: "name",
|
|
4496
|
+
type: "text",
|
|
4497
|
+
value: name,
|
|
4498
|
+
onChange: (e) => setName(e.target.value),
|
|
4499
|
+
required: true,
|
|
4500
|
+
disabled: isLoading,
|
|
4501
|
+
style: {
|
|
4502
|
+
width: "100%",
|
|
4503
|
+
padding: "12px 16px",
|
|
4504
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
4505
|
+
borderRadius: "8px",
|
|
4506
|
+
fontSize: "16px",
|
|
4507
|
+
boxSizing: "border-box",
|
|
4508
|
+
backgroundColor: colors.bgSecondary,
|
|
4509
|
+
color: colors.textPrimary,
|
|
4510
|
+
transition: "all 0.2s ease"
|
|
4511
|
+
},
|
|
4512
|
+
placeholder: "Manish Batra"
|
|
4513
|
+
}
|
|
4514
|
+
)
|
|
4515
|
+
] }),
|
|
4516
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
4517
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "phoneNumber", style: {
|
|
4518
|
+
display: "block",
|
|
4519
|
+
marginBottom: "8px",
|
|
4520
|
+
fontWeight: 500,
|
|
4521
|
+
color: colors.textSecondary,
|
|
4522
|
+
fontSize: "14px"
|
|
4523
|
+
}, children: "Phone Number" }),
|
|
4524
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4525
|
+
PhoneInput,
|
|
4526
|
+
{
|
|
4527
|
+
id: "phoneNumber",
|
|
4528
|
+
value: phoneNumber,
|
|
4529
|
+
onChange: setPhoneNumber,
|
|
4530
|
+
disabled: isLoading,
|
|
4531
|
+
placeholder: "1234567890"
|
|
4532
|
+
}
|
|
4533
|
+
)
|
|
4534
|
+
] }),
|
|
4535
|
+
showAvatar && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
4536
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "avatar", style: {
|
|
4537
|
+
display: "block",
|
|
4538
|
+
marginBottom: "8px",
|
|
4539
|
+
fontWeight: 500,
|
|
4540
|
+
color: colors.textSecondary,
|
|
4541
|
+
fontSize: "14px"
|
|
4542
|
+
}, children: "Avatar URL" }),
|
|
4543
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4544
|
+
"input",
|
|
4545
|
+
{
|
|
4546
|
+
id: "avatar",
|
|
4547
|
+
type: "url",
|
|
4548
|
+
value: avatar,
|
|
4549
|
+
onChange: (e) => setAvatar(e.target.value),
|
|
4550
|
+
disabled: isLoading,
|
|
4551
|
+
style: {
|
|
4552
|
+
width: "100%",
|
|
4553
|
+
padding: "12px 16px",
|
|
4554
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
4555
|
+
borderRadius: "8px",
|
|
4556
|
+
fontSize: "16px",
|
|
4557
|
+
boxSizing: "border-box",
|
|
4558
|
+
backgroundColor: colors.bgSecondary,
|
|
4559
|
+
color: colors.textPrimary,
|
|
4560
|
+
transition: "all 0.2s ease"
|
|
4561
|
+
},
|
|
4562
|
+
placeholder: "https://example.com/avatar.jpg"
|
|
4563
|
+
}
|
|
4564
|
+
)
|
|
4565
|
+
] }),
|
|
3858
4566
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3859
4567
|
"button",
|
|
3860
4568
|
{
|
|
3861
4569
|
type: "submit",
|
|
3862
4570
|
disabled: isLoading,
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
border: "none",
|
|
3868
|
-
borderRadius: "8px",
|
|
3869
|
-
fontSize: "14px",
|
|
3870
|
-
fontWeight: 600,
|
|
3871
|
-
cursor: "pointer"
|
|
4571
|
+
onMouseEnter: (e) => {
|
|
4572
|
+
if (!isLoading) {
|
|
4573
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
|
|
4574
|
+
}
|
|
3872
4575
|
},
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
)
|
|
3876
|
-
] })
|
|
3877
|
-
] }),
|
|
3878
|
-
showAvatar && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
3879
|
-
padding: "20px",
|
|
3880
|
-
backgroundColor: "#fff",
|
|
3881
|
-
borderRadius: "8px",
|
|
3882
|
-
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3883
|
-
marginBottom: "20px"
|
|
3884
|
-
}, children: [
|
|
3885
|
-
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Update Avatar" }),
|
|
3886
|
-
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleUpdateAvatar, children: [
|
|
3887
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3888
|
-
"input",
|
|
3889
|
-
{
|
|
3890
|
-
type: "url",
|
|
3891
|
-
value: avatar,
|
|
3892
|
-
onChange: (e) => setAvatar(e.target.value),
|
|
3893
|
-
required: true,
|
|
3894
|
-
disabled: isLoading,
|
|
3895
|
-
style: {
|
|
3896
|
-
width: "100%",
|
|
3897
|
-
padding: "12px 16px",
|
|
3898
|
-
border: "1px solid #ddd",
|
|
3899
|
-
borderRadius: "8px",
|
|
3900
|
-
fontSize: "16px",
|
|
3901
|
-
boxSizing: "border-box",
|
|
3902
|
-
marginBottom: "12px"
|
|
4576
|
+
onMouseLeave: (e) => {
|
|
4577
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimary;
|
|
3903
4578
|
},
|
|
3904
|
-
placeholder: "Avatar URL"
|
|
3905
|
-
}
|
|
3906
|
-
),
|
|
3907
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3908
|
-
"button",
|
|
3909
|
-
{
|
|
3910
|
-
type: "submit",
|
|
3911
|
-
disabled: isLoading,
|
|
3912
4579
|
style: {
|
|
3913
|
-
padding: "
|
|
3914
|
-
backgroundColor:
|
|
4580
|
+
padding: "12px 24px",
|
|
4581
|
+
backgroundColor: colors.buttonPrimary,
|
|
3915
4582
|
color: "white",
|
|
3916
4583
|
border: "none",
|
|
3917
4584
|
borderRadius: "8px",
|
|
3918
4585
|
fontSize: "14px",
|
|
3919
4586
|
fontWeight: 600,
|
|
3920
|
-
cursor: "pointer"
|
|
4587
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
4588
|
+
opacity: isLoading ? 0.6 : 1,
|
|
4589
|
+
transition: "all 0.2s ease"
|
|
3921
4590
|
},
|
|
3922
|
-
children: "
|
|
4591
|
+
children: isLoading ? "Saving..." : "Save Changes"
|
|
3923
4592
|
}
|
|
3924
4593
|
)
|
|
3925
4594
|
] })
|
|
3926
4595
|
] }),
|
|
3927
4596
|
showEmailChange && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
3928
|
-
padding: "
|
|
3929
|
-
backgroundColor:
|
|
3930
|
-
borderRadius: "
|
|
4597
|
+
padding: "24px",
|
|
4598
|
+
backgroundColor: colors.bgPrimary,
|
|
4599
|
+
borderRadius: "12px",
|
|
3931
4600
|
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3932
|
-
marginBottom: "20px"
|
|
4601
|
+
marginBottom: "20px",
|
|
4602
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
3933
4603
|
}, children: [
|
|
3934
|
-
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Change Email" }),
|
|
3935
|
-
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: { fontSize: "14px", color:
|
|
4604
|
+
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600, color: colors.textPrimary }, children: "Change Email" }),
|
|
4605
|
+
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: { fontSize: "14px", color: colors.textSecondary, marginBottom: "16px" }, children: [
|
|
3936
4606
|
"Current email: ",
|
|
3937
4607
|
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: user.email })
|
|
3938
4608
|
] }),
|
|
3939
4609
|
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleRequestEmailChange, children: [
|
|
3940
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3941
|
-
"
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
4610
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "16px" }, children: [
|
|
4611
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "newEmail", style: {
|
|
4612
|
+
display: "block",
|
|
4613
|
+
marginBottom: "8px",
|
|
4614
|
+
fontWeight: 500,
|
|
4615
|
+
color: colors.textSecondary,
|
|
4616
|
+
fontSize: "14px"
|
|
4617
|
+
}, children: "New Email Address" }),
|
|
4618
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4619
|
+
"input",
|
|
4620
|
+
{
|
|
4621
|
+
id: "newEmail",
|
|
4622
|
+
type: "email",
|
|
4623
|
+
value: newEmail,
|
|
4624
|
+
onChange: (e) => setNewEmail(e.target.value),
|
|
4625
|
+
required: true,
|
|
4626
|
+
disabled: isLoading,
|
|
4627
|
+
style: {
|
|
4628
|
+
width: "100%",
|
|
4629
|
+
padding: "12px 16px",
|
|
4630
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
4631
|
+
borderRadius: "8px",
|
|
4632
|
+
fontSize: "16px",
|
|
4633
|
+
boxSizing: "border-box",
|
|
4634
|
+
backgroundColor: colors.bgSecondary,
|
|
4635
|
+
color: colors.textPrimary,
|
|
4636
|
+
transition: "all 0.2s ease"
|
|
4637
|
+
},
|
|
4638
|
+
placeholder: "newemail@example.com"
|
|
4639
|
+
}
|
|
4640
|
+
)
|
|
4641
|
+
] }),
|
|
3960
4642
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3961
4643
|
"button",
|
|
3962
4644
|
{
|
|
3963
4645
|
type: "submit",
|
|
3964
4646
|
disabled: isLoading,
|
|
4647
|
+
onMouseEnter: (e) => {
|
|
4648
|
+
if (!isLoading) {
|
|
4649
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
|
|
4650
|
+
}
|
|
4651
|
+
},
|
|
4652
|
+
onMouseLeave: (e) => {
|
|
4653
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimary;
|
|
4654
|
+
},
|
|
3965
4655
|
style: {
|
|
3966
|
-
padding: "
|
|
3967
|
-
backgroundColor:
|
|
4656
|
+
padding: "12px 24px",
|
|
4657
|
+
backgroundColor: colors.buttonPrimary,
|
|
3968
4658
|
color: "white",
|
|
3969
4659
|
border: "none",
|
|
3970
4660
|
borderRadius: "8px",
|
|
3971
4661
|
fontSize: "14px",
|
|
3972
4662
|
fontWeight: 600,
|
|
3973
|
-
cursor: "pointer"
|
|
4663
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
4664
|
+
opacity: isLoading ? 0.6 : 1,
|
|
4665
|
+
transition: "all 0.2s ease"
|
|
3974
4666
|
},
|
|
3975
|
-
children: "Request Email Change"
|
|
4667
|
+
children: isLoading ? "Sending..." : "Request Email Change"
|
|
3976
4668
|
}
|
|
3977
4669
|
)
|
|
3978
4670
|
] })
|
|
@@ -3985,11 +4677,13 @@ var react_exports = {};
|
|
|
3985
4677
|
__export(react_exports, {
|
|
3986
4678
|
AuthFlow: () => AuthFlow,
|
|
3987
4679
|
AuthProvider: () => AuthProvider,
|
|
4680
|
+
AuthThemeProvider: () => AuthThemeProvider,
|
|
3988
4681
|
ChangePassword: () => ChangePassword,
|
|
3989
4682
|
EmailVerificationPage: () => EmailVerificationPage,
|
|
3990
4683
|
ForgotPassword: () => ForgotPassword,
|
|
3991
4684
|
LoginForm: () => LoginForm,
|
|
3992
4685
|
OtpForm: () => OtpForm,
|
|
4686
|
+
PhoneInput: () => PhoneInput,
|
|
3993
4687
|
ProtectedRoute: () => ProtectedRoute,
|
|
3994
4688
|
PublicRoute: () => PublicRoute,
|
|
3995
4689
|
RegisterForm: () => RegisterForm,
|
|
@@ -4001,7 +4695,8 @@ __export(react_exports, {
|
|
|
4001
4695
|
UserProfile: () => UserProfile,
|
|
4002
4696
|
VerifyEmail: () => VerifyEmail,
|
|
4003
4697
|
useAuth: () => useAuth,
|
|
4004
|
-
useAuthLegacy: () => useAuth2
|
|
4698
|
+
useAuthLegacy: () => useAuth2,
|
|
4699
|
+
useAuthTheme: () => useAuthTheme
|
|
4005
4700
|
});
|
|
4006
4701
|
|
|
4007
4702
|
// src/node/index.ts
|