@thetechfossil/auth2 1.2.2 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.components.d.ts +14 -1
- package/dist/index.components.js +1288 -642
- package/dist/index.components.js.map +1 -1
- package/dist/index.components.mjs +1190 -547
- package/dist/index.components.mjs.map +1 -1
- package/dist/index.d.ts +51 -7
- package/dist/index.js +1368 -672
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1241 -547
- package/dist/index.mjs.map +1 -1
- package/dist/index.next.d.ts +44 -65
- package/dist/index.next.js +1402 -988
- package/dist/index.next.js.map +1 -1
- package/dist/index.next.mjs +1254 -836
- package/dist/index.next.mjs.map +1 -1
- package/dist/index.next.server.d.ts +57 -8
- package/dist/index.next.server.js +163 -14
- package/dist/index.next.server.js.map +1 -1
- package/dist/index.next.server.mjs +156 -15
- package/dist/index.next.server.mjs.map +1 -1
- package/dist/index.node.d.ts +19 -7
- package/dist/index.node.js +18 -12
- package/dist/index.node.js.map +1 -1
- package/dist/index.node.mjs +18 -12
- package/dist/index.node.mjs.map +1 -1
- package/next/index.js +2 -0
- package/next/index.mjs +2 -0
- package/next/package.json +5 -0
- package/next/server/package.json +5 -0
- package/next/server.js +2 -0
- package/next/server.mjs +2 -0
- package/package.json +21 -18
- package/README.NEW.md +0 -365
package/dist/index.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
'use strict';
|
|
2
3
|
|
|
3
4
|
var axios = require('axios');
|
|
4
|
-
var
|
|
5
|
+
var React3 = require('react');
|
|
5
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var PhoneInputWithCountry = require('react-phone-number-input');
|
|
8
|
+
require('react-phone-number-input/style.css');
|
|
6
9
|
|
|
7
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
11
|
|
|
9
12
|
var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
13
|
+
var React3__default = /*#__PURE__*/_interopDefault(React3);
|
|
14
|
+
var PhoneInputWithCountry__default = /*#__PURE__*/_interopDefault(PhoneInputWithCountry);
|
|
10
15
|
|
|
11
16
|
var __defProp = Object.defineProperty;
|
|
12
17
|
var __export = (target, all) => {
|
|
@@ -17,8 +22,9 @@ var HttpClient = class {
|
|
|
17
22
|
constructor(baseUrl, defaultHeaders = {}) {
|
|
18
23
|
this.csrfToken = null;
|
|
19
24
|
this.frontendBaseUrl = null;
|
|
25
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
20
26
|
this.axiosInstance = axios__default.default.create({
|
|
21
|
-
baseURL: baseUrl
|
|
27
|
+
baseURL: this.baseUrl,
|
|
22
28
|
headers: {
|
|
23
29
|
"Content-Type": "application/json",
|
|
24
30
|
...defaultHeaders
|
|
@@ -29,8 +35,16 @@ var HttpClient = class {
|
|
|
29
35
|
// 30 second timeout
|
|
30
36
|
});
|
|
31
37
|
this.axiosInstance.interceptors.request.use(
|
|
32
|
-
(config) => {
|
|
33
|
-
|
|
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) {
|
|
34
48
|
config.headers["x-csrf-token"] = this.csrfToken;
|
|
35
49
|
}
|
|
36
50
|
if (this.frontendBaseUrl) {
|
|
@@ -128,9 +142,6 @@ var AuthService = class {
|
|
|
128
142
|
this.httpClient.setFrontendBaseUrl(frontendBaseUrl);
|
|
129
143
|
}
|
|
130
144
|
}
|
|
131
|
-
if (this.config.csrfEnabled && typeof window !== "undefined") {
|
|
132
|
-
this.refreshCsrfToken();
|
|
133
|
-
}
|
|
134
145
|
}
|
|
135
146
|
loadTokenFromStorage() {
|
|
136
147
|
if (typeof window !== "undefined" && this.config.localStorageKey) {
|
|
@@ -232,7 +243,7 @@ var AuthService = class {
|
|
|
232
243
|
this.saveTokenToStorage(response.token);
|
|
233
244
|
return response;
|
|
234
245
|
}
|
|
235
|
-
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.")) {
|
|
236
247
|
return response;
|
|
237
248
|
}
|
|
238
249
|
if (response.success && response.message === "OTP verified successfully." && response.token) {
|
|
@@ -303,7 +314,7 @@ var AuthService = class {
|
|
|
303
314
|
if (!this.token) {
|
|
304
315
|
throw new Error("Not authenticated");
|
|
305
316
|
}
|
|
306
|
-
const response = await this.httpClient.post("/api/v1/user/update/
|
|
317
|
+
const response = await this.httpClient.post("/api/v1/user/update/profile", data);
|
|
307
318
|
if (response.success && response.token) {
|
|
308
319
|
this.token = response.token;
|
|
309
320
|
this.httpClient.setAuthToken(response.token);
|
|
@@ -344,7 +355,7 @@ var AuthService = class {
|
|
|
344
355
|
if (!this.token) {
|
|
345
356
|
throw new Error("Not authenticated");
|
|
346
357
|
}
|
|
347
|
-
const response = await this.httpClient.post("/api/v1/user/update/
|
|
358
|
+
const response = await this.httpClient.post("/api/v1/user/update/profile", { avatar });
|
|
348
359
|
if (response.success && response.token) {
|
|
349
360
|
this.token = response.token;
|
|
350
361
|
this.httpClient.setAuthToken(response.token);
|
|
@@ -407,21 +418,21 @@ var AuthService = class {
|
|
|
407
418
|
if (!this.token) {
|
|
408
419
|
throw new Error("Not authenticated");
|
|
409
420
|
}
|
|
410
|
-
const response = await this.httpClient.get("/api/v1/
|
|
421
|
+
const response = await this.httpClient.get("/api/v1/sessions");
|
|
411
422
|
return response;
|
|
412
423
|
}
|
|
413
424
|
async revokeSession(sessionId) {
|
|
414
425
|
if (!this.token) {
|
|
415
426
|
throw new Error("Not authenticated");
|
|
416
427
|
}
|
|
417
|
-
const response = await this.httpClient.delete(`/api/v1/
|
|
428
|
+
const response = await this.httpClient.delete(`/api/v1/sessions/${sessionId}`);
|
|
418
429
|
return response;
|
|
419
430
|
}
|
|
420
431
|
async revokeAllSessions() {
|
|
421
432
|
if (!this.token) {
|
|
422
433
|
throw new Error("Not authenticated");
|
|
423
434
|
}
|
|
424
|
-
const response = await this.httpClient.delete("/api/v1/
|
|
435
|
+
const response = await this.httpClient.delete("/api/v1/sessions/revoke/all");
|
|
425
436
|
this.token = null;
|
|
426
437
|
this.httpClient.removeAuthToken();
|
|
427
438
|
this.removeTokenFromStorage();
|
|
@@ -467,18 +478,69 @@ var AuthService = class {
|
|
|
467
478
|
return response;
|
|
468
479
|
}
|
|
469
480
|
};
|
|
470
|
-
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);
|
|
471
533
|
var AuthProvider = ({ children, config }) => {
|
|
472
534
|
const authConfig = {
|
|
473
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"),
|
|
474
536
|
localStorageKey: config?.localStorageKey || "auth_token",
|
|
475
537
|
csrfEnabled: config?.csrfEnabled !== void 0 ? config.csrfEnabled : true
|
|
476
538
|
};
|
|
477
|
-
const [authService] =
|
|
478
|
-
const [user, setUser] =
|
|
479
|
-
const [isLoaded, setIsLoaded] =
|
|
480
|
-
const [loading, setLoading] =
|
|
481
|
-
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 () => {
|
|
482
544
|
const authenticated = authService.isAuthenticated();
|
|
483
545
|
if (authenticated) {
|
|
484
546
|
try {
|
|
@@ -493,10 +555,10 @@ var AuthProvider = ({ children, config }) => {
|
|
|
493
555
|
}
|
|
494
556
|
setIsLoaded(true);
|
|
495
557
|
}, [authService]);
|
|
496
|
-
|
|
558
|
+
React3.useEffect(() => {
|
|
497
559
|
checkAuthStatus();
|
|
498
560
|
}, [checkAuthStatus]);
|
|
499
|
-
const signIn =
|
|
561
|
+
const signIn = React3.useCallback(async (data) => {
|
|
500
562
|
setLoading(true);
|
|
501
563
|
try {
|
|
502
564
|
const response = await authService.login(data);
|
|
@@ -508,7 +570,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
508
570
|
setLoading(false);
|
|
509
571
|
}
|
|
510
572
|
}, [authService]);
|
|
511
|
-
const signUp =
|
|
573
|
+
const signUp = React3.useCallback(async (data) => {
|
|
512
574
|
setLoading(true);
|
|
513
575
|
try {
|
|
514
576
|
const response = await authService.register(data);
|
|
@@ -517,7 +579,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
517
579
|
setLoading(false);
|
|
518
580
|
}
|
|
519
581
|
}, [authService]);
|
|
520
|
-
const signOut =
|
|
582
|
+
const signOut = React3.useCallback(async () => {
|
|
521
583
|
setLoading(true);
|
|
522
584
|
try {
|
|
523
585
|
await authService.logout();
|
|
@@ -526,7 +588,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
526
588
|
setLoading(false);
|
|
527
589
|
}
|
|
528
590
|
}, [authService]);
|
|
529
|
-
const verify =
|
|
591
|
+
const verify = React3.useCallback(async (data) => {
|
|
530
592
|
setLoading(true);
|
|
531
593
|
try {
|
|
532
594
|
const response = await authService.verify(data);
|
|
@@ -538,7 +600,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
538
600
|
setLoading(false);
|
|
539
601
|
}
|
|
540
602
|
}, [authService]);
|
|
541
|
-
const verifyEmailToken =
|
|
603
|
+
const verifyEmailToken = React3.useCallback(async (token) => {
|
|
542
604
|
setLoading(true);
|
|
543
605
|
try {
|
|
544
606
|
const response = await authService.verifyEmailToken(token);
|
|
@@ -550,7 +612,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
550
612
|
setLoading(false);
|
|
551
613
|
}
|
|
552
614
|
}, [authService]);
|
|
553
|
-
const updateProfile =
|
|
615
|
+
const updateProfile = React3.useCallback(async (data) => {
|
|
554
616
|
setLoading(true);
|
|
555
617
|
try {
|
|
556
618
|
const response = await authService.updateProfile(data);
|
|
@@ -562,7 +624,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
562
624
|
setLoading(false);
|
|
563
625
|
}
|
|
564
626
|
}, [authService]);
|
|
565
|
-
const getProfile =
|
|
627
|
+
const getProfile = React3.useCallback(async () => {
|
|
566
628
|
setLoading(true);
|
|
567
629
|
try {
|
|
568
630
|
const userData = await authService.getProfile();
|
|
@@ -572,13 +634,13 @@ var AuthProvider = ({ children, config }) => {
|
|
|
572
634
|
setLoading(false);
|
|
573
635
|
}
|
|
574
636
|
}, [authService]);
|
|
575
|
-
const signInWithOAuth =
|
|
637
|
+
const signInWithOAuth = React3.useCallback((provider) => {
|
|
576
638
|
authService.loginWithOAuth(provider);
|
|
577
639
|
}, [authService]);
|
|
578
|
-
const linkOAuthProvider =
|
|
640
|
+
const linkOAuthProvider = React3.useCallback((provider) => {
|
|
579
641
|
authService.linkOAuthProvider(provider);
|
|
580
642
|
}, [authService]);
|
|
581
|
-
const unlinkOAuthProvider =
|
|
643
|
+
const unlinkOAuthProvider = React3.useCallback(async (provider) => {
|
|
582
644
|
setLoading(true);
|
|
583
645
|
try {
|
|
584
646
|
return await authService.unlinkOAuthProvider(provider);
|
|
@@ -586,7 +648,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
586
648
|
setLoading(false);
|
|
587
649
|
}
|
|
588
650
|
}, [authService]);
|
|
589
|
-
const forgotPassword =
|
|
651
|
+
const forgotPassword = React3.useCallback(async (email) => {
|
|
590
652
|
setLoading(true);
|
|
591
653
|
try {
|
|
592
654
|
return await authService.forgotPassword(email);
|
|
@@ -594,7 +656,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
594
656
|
setLoading(false);
|
|
595
657
|
}
|
|
596
658
|
}, [authService]);
|
|
597
|
-
const resetPassword =
|
|
659
|
+
const resetPassword = React3.useCallback(async (token, password) => {
|
|
598
660
|
setLoading(true);
|
|
599
661
|
try {
|
|
600
662
|
return await authService.resetPassword(token, password);
|
|
@@ -602,7 +664,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
602
664
|
setLoading(false);
|
|
603
665
|
}
|
|
604
666
|
}, [authService]);
|
|
605
|
-
const changePassword =
|
|
667
|
+
const changePassword = React3.useCallback(async (oldPassword, newPassword) => {
|
|
606
668
|
setLoading(true);
|
|
607
669
|
try {
|
|
608
670
|
return await authService.changePassword(oldPassword, newPassword);
|
|
@@ -610,7 +672,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
610
672
|
setLoading(false);
|
|
611
673
|
}
|
|
612
674
|
}, [authService]);
|
|
613
|
-
const updateAvatar =
|
|
675
|
+
const updateAvatar = React3.useCallback(async (avatar) => {
|
|
614
676
|
setLoading(true);
|
|
615
677
|
try {
|
|
616
678
|
const response = await authService.updateAvatar(avatar);
|
|
@@ -622,7 +684,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
622
684
|
setLoading(false);
|
|
623
685
|
}
|
|
624
686
|
}, [authService]);
|
|
625
|
-
const requestEmailChange =
|
|
687
|
+
const requestEmailChange = React3.useCallback(async (newEmail) => {
|
|
626
688
|
setLoading(true);
|
|
627
689
|
try {
|
|
628
690
|
return await authService.requestEmailChange(newEmail);
|
|
@@ -630,7 +692,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
630
692
|
setLoading(false);
|
|
631
693
|
}
|
|
632
694
|
}, [authService]);
|
|
633
|
-
const verifyEmailChange =
|
|
695
|
+
const verifyEmailChange = React3.useCallback(async (token) => {
|
|
634
696
|
setLoading(true);
|
|
635
697
|
try {
|
|
636
698
|
const response = await authService.verifyEmailChange(token);
|
|
@@ -642,7 +704,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
642
704
|
setLoading(false);
|
|
643
705
|
}
|
|
644
706
|
}, [authService]);
|
|
645
|
-
const generate2FA =
|
|
707
|
+
const generate2FA = React3.useCallback(async () => {
|
|
646
708
|
setLoading(true);
|
|
647
709
|
try {
|
|
648
710
|
return await authService.generate2FA();
|
|
@@ -650,7 +712,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
650
712
|
setLoading(false);
|
|
651
713
|
}
|
|
652
714
|
}, [authService]);
|
|
653
|
-
const enable2FA =
|
|
715
|
+
const enable2FA = React3.useCallback(async (token) => {
|
|
654
716
|
setLoading(true);
|
|
655
717
|
try {
|
|
656
718
|
return await authService.enable2FA(token);
|
|
@@ -658,7 +720,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
658
720
|
setLoading(false);
|
|
659
721
|
}
|
|
660
722
|
}, [authService]);
|
|
661
|
-
const disable2FA =
|
|
723
|
+
const disable2FA = React3.useCallback(async (token) => {
|
|
662
724
|
setLoading(true);
|
|
663
725
|
try {
|
|
664
726
|
return await authService.disable2FA(token);
|
|
@@ -666,7 +728,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
666
728
|
setLoading(false);
|
|
667
729
|
}
|
|
668
730
|
}, [authService]);
|
|
669
|
-
const validate2FA =
|
|
731
|
+
const validate2FA = React3.useCallback(async (token) => {
|
|
670
732
|
setLoading(true);
|
|
671
733
|
try {
|
|
672
734
|
return await authService.validate2FA(token);
|
|
@@ -674,7 +736,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
674
736
|
setLoading(false);
|
|
675
737
|
}
|
|
676
738
|
}, [authService]);
|
|
677
|
-
const getSessions =
|
|
739
|
+
const getSessions = React3.useCallback(async () => {
|
|
678
740
|
setLoading(true);
|
|
679
741
|
try {
|
|
680
742
|
return await authService.getSessions();
|
|
@@ -682,7 +744,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
682
744
|
setLoading(false);
|
|
683
745
|
}
|
|
684
746
|
}, [authService]);
|
|
685
|
-
const revokeSession =
|
|
747
|
+
const revokeSession = React3.useCallback(async (sessionId) => {
|
|
686
748
|
setLoading(true);
|
|
687
749
|
try {
|
|
688
750
|
return await authService.revokeSession(sessionId);
|
|
@@ -690,7 +752,7 @@ var AuthProvider = ({ children, config }) => {
|
|
|
690
752
|
setLoading(false);
|
|
691
753
|
}
|
|
692
754
|
}, [authService]);
|
|
693
|
-
const revokeAllSessions =
|
|
755
|
+
const revokeAllSessions = React3.useCallback(async () => {
|
|
694
756
|
setLoading(true);
|
|
695
757
|
try {
|
|
696
758
|
const response = await authService.revokeAllSessions();
|
|
@@ -730,21 +792,21 @@ var AuthProvider = ({ children, config }) => {
|
|
|
730
792
|
revokeAllSessions,
|
|
731
793
|
authService
|
|
732
794
|
};
|
|
733
|
-
return /* @__PURE__ */ jsxRuntime.jsx(AuthContext.Provider, { value, children });
|
|
795
|
+
return /* @__PURE__ */ jsxRuntime.jsx(AuthContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(AuthThemeProvider, { children }) });
|
|
734
796
|
};
|
|
735
797
|
var useAuth = () => {
|
|
736
|
-
const context =
|
|
798
|
+
const context = React3.useContext(AuthContext);
|
|
737
799
|
if (context === void 0) {
|
|
738
800
|
throw new Error("useAuth must be used within an AuthProvider");
|
|
739
801
|
}
|
|
740
802
|
return context;
|
|
741
803
|
};
|
|
742
804
|
var useAuth2 = (config) => {
|
|
743
|
-
const [authService] =
|
|
744
|
-
const [user, setUser] =
|
|
745
|
-
const [isAuthenticated, setIsAuthenticated] =
|
|
746
|
-
const [loading, setLoading] =
|
|
747
|
-
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(() => {
|
|
748
810
|
const authenticated = authService.isAuthenticated();
|
|
749
811
|
setIsAuthenticated(authenticated);
|
|
750
812
|
if (authenticated) {
|
|
@@ -755,10 +817,10 @@ var useAuth2 = (config) => {
|
|
|
755
817
|
}
|
|
756
818
|
setLoading(false);
|
|
757
819
|
}, [authService]);
|
|
758
|
-
|
|
820
|
+
React3.useEffect(() => {
|
|
759
821
|
checkAuthStatus();
|
|
760
822
|
}, [checkAuthStatus]);
|
|
761
|
-
const register =
|
|
823
|
+
const register = React3.useCallback(async (data) => {
|
|
762
824
|
setLoading(true);
|
|
763
825
|
try {
|
|
764
826
|
const response = await authService.register(data);
|
|
@@ -767,7 +829,7 @@ var useAuth2 = (config) => {
|
|
|
767
829
|
setLoading(false);
|
|
768
830
|
}
|
|
769
831
|
}, [authService]);
|
|
770
|
-
const login =
|
|
832
|
+
const login = React3.useCallback(async (data) => {
|
|
771
833
|
setLoading(true);
|
|
772
834
|
try {
|
|
773
835
|
const response = await authService.login(data);
|
|
@@ -780,7 +842,7 @@ var useAuth2 = (config) => {
|
|
|
780
842
|
setLoading(false);
|
|
781
843
|
}
|
|
782
844
|
}, [authService]);
|
|
783
|
-
const verify =
|
|
845
|
+
const verify = React3.useCallback(async (data) => {
|
|
784
846
|
setLoading(true);
|
|
785
847
|
try {
|
|
786
848
|
const response = await authService.verify(data);
|
|
@@ -793,7 +855,7 @@ var useAuth2 = (config) => {
|
|
|
793
855
|
setLoading(false);
|
|
794
856
|
}
|
|
795
857
|
}, [authService]);
|
|
796
|
-
const verifyEmailToken =
|
|
858
|
+
const verifyEmailToken = React3.useCallback(async (token) => {
|
|
797
859
|
setLoading(true);
|
|
798
860
|
try {
|
|
799
861
|
const response = await authService.verifyEmailToken(token);
|
|
@@ -806,7 +868,7 @@ var useAuth2 = (config) => {
|
|
|
806
868
|
setLoading(false);
|
|
807
869
|
}
|
|
808
870
|
}, [authService]);
|
|
809
|
-
const logout =
|
|
871
|
+
const logout = React3.useCallback(async () => {
|
|
810
872
|
setLoading(true);
|
|
811
873
|
try {
|
|
812
874
|
await authService.logout();
|
|
@@ -816,7 +878,7 @@ var useAuth2 = (config) => {
|
|
|
816
878
|
setLoading(false);
|
|
817
879
|
}
|
|
818
880
|
}, [authService]);
|
|
819
|
-
const updateProfile =
|
|
881
|
+
const updateProfile = React3.useCallback(async (data) => {
|
|
820
882
|
setLoading(true);
|
|
821
883
|
try {
|
|
822
884
|
const response = await authService.updateProfile(data);
|
|
@@ -828,7 +890,7 @@ var useAuth2 = (config) => {
|
|
|
828
890
|
setLoading(false);
|
|
829
891
|
}
|
|
830
892
|
}, [authService]);
|
|
831
|
-
const getProfile =
|
|
893
|
+
const getProfile = React3.useCallback(async () => {
|
|
832
894
|
setLoading(true);
|
|
833
895
|
try {
|
|
834
896
|
const userData = await authService.getProfile();
|
|
@@ -838,7 +900,7 @@ var useAuth2 = (config) => {
|
|
|
838
900
|
setLoading(false);
|
|
839
901
|
}
|
|
840
902
|
}, [authService]);
|
|
841
|
-
const getAllUsers =
|
|
903
|
+
const getAllUsers = React3.useCallback(async () => {
|
|
842
904
|
setLoading(true);
|
|
843
905
|
try {
|
|
844
906
|
return await authService.getAllUsers();
|
|
@@ -846,7 +908,7 @@ var useAuth2 = (config) => {
|
|
|
846
908
|
setLoading(false);
|
|
847
909
|
}
|
|
848
910
|
}, [authService]);
|
|
849
|
-
const getUserById =
|
|
911
|
+
const getUserById = React3.useCallback(async (id) => {
|
|
850
912
|
setLoading(true);
|
|
851
913
|
try {
|
|
852
914
|
return await authService.getUserById(id);
|
|
@@ -869,6 +931,267 @@ var useAuth2 = (config) => {
|
|
|
869
931
|
getUserById
|
|
870
932
|
};
|
|
871
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
|
+
};
|
|
872
1195
|
var LoginForm = ({
|
|
873
1196
|
onSuccess,
|
|
874
1197
|
onLoginSuccess,
|
|
@@ -878,15 +1201,18 @@ var LoginForm = ({
|
|
|
878
1201
|
oauthProviders = ["google", "github"],
|
|
879
1202
|
showOAuthButtons = true
|
|
880
1203
|
}) => {
|
|
881
|
-
const
|
|
882
|
-
const [
|
|
883
|
-
const [
|
|
884
|
-
const [
|
|
885
|
-
const [
|
|
886
|
-
const [
|
|
887
|
-
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);
|
|
888
1214
|
const { login } = useAuth2({
|
|
889
|
-
baseUrl: config?.baseUrl ||
|
|
1215
|
+
baseUrl: config?.baseUrl || "http://localhost:7000"
|
|
890
1216
|
});
|
|
891
1217
|
const handleSubmit = async (e) => {
|
|
892
1218
|
e.preventDefault();
|
|
@@ -894,20 +1220,28 @@ var LoginForm = ({
|
|
|
894
1220
|
setError(null);
|
|
895
1221
|
try {
|
|
896
1222
|
let response;
|
|
1223
|
+
const loginData = {};
|
|
1224
|
+
if (usePhone && phoneNumber) {
|
|
1225
|
+
loginData.phoneNumber = phoneNumber;
|
|
1226
|
+
} else if (email) {
|
|
1227
|
+
loginData.email = email;
|
|
1228
|
+
}
|
|
897
1229
|
if (usePassword) {
|
|
898
|
-
|
|
1230
|
+
loginData.password = password;
|
|
1231
|
+
response = await login(loginData);
|
|
899
1232
|
} else {
|
|
900
|
-
response = await login(
|
|
1233
|
+
response = await login(loginData);
|
|
901
1234
|
}
|
|
902
1235
|
if (response.success) {
|
|
903
1236
|
onSuccess?.(response);
|
|
904
1237
|
if (onLoginSuccess) {
|
|
905
|
-
|
|
906
|
-
|
|
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);
|
|
907
1241
|
} else if (response.token) {
|
|
908
|
-
onLoginSuccess(
|
|
1242
|
+
onLoginSuccess(identifier, false);
|
|
909
1243
|
} else {
|
|
910
|
-
onLoginSuccess(
|
|
1244
|
+
onLoginSuccess(identifier, true);
|
|
911
1245
|
}
|
|
912
1246
|
}
|
|
913
1247
|
} else {
|
|
@@ -929,43 +1263,53 @@ var LoginForm = ({
|
|
|
929
1263
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
930
1264
|
maxWidth: "400px",
|
|
931
1265
|
margin: "0 auto",
|
|
932
|
-
padding: "
|
|
1266
|
+
padding: "24px",
|
|
933
1267
|
borderRadius: "12px",
|
|
934
1268
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
935
|
-
backgroundColor:
|
|
936
|
-
border:
|
|
1269
|
+
backgroundColor: colors.bgPrimary,
|
|
1270
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
937
1271
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: {
|
|
938
1272
|
display: "flex",
|
|
939
1273
|
flexDirection: "column"
|
|
940
1274
|
}, children: [
|
|
941
1275
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
|
|
942
1276
|
textAlign: "center",
|
|
943
|
-
marginBottom: "
|
|
944
|
-
color:
|
|
1277
|
+
marginBottom: "20px",
|
|
1278
|
+
color: colors.textPrimary,
|
|
945
1279
|
fontSize: "24px",
|
|
946
1280
|
fontWeight: 600
|
|
947
1281
|
}, children: usePassword ? "Login with Password" : "Login with OTP" }),
|
|
948
1282
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
949
1283
|
padding: "12px 16px",
|
|
950
|
-
marginBottom: "
|
|
951
|
-
backgroundColor:
|
|
952
|
-
color:
|
|
953
|
-
border:
|
|
1284
|
+
marginBottom: "16px",
|
|
1285
|
+
backgroundColor: colors.errorBg,
|
|
1286
|
+
color: colors.errorText,
|
|
1287
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
954
1288
|
borderRadius: "8px",
|
|
955
1289
|
fontSize: "14px",
|
|
956
1290
|
fontWeight: 500
|
|
957
1291
|
}, children: error }),
|
|
958
1292
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
959
|
-
marginBottom: "
|
|
1293
|
+
marginBottom: "16px"
|
|
960
1294
|
}, children: [
|
|
961
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", style: {
|
|
1295
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: usePhone ? "phone" : "email", style: {
|
|
962
1296
|
display: "block",
|
|
963
1297
|
marginBottom: "8px",
|
|
964
1298
|
fontWeight: 500,
|
|
965
|
-
color:
|
|
1299
|
+
color: colors.textSecondary,
|
|
966
1300
|
fontSize: "14px"
|
|
967
|
-
}, children: "Email:" }),
|
|
968
|
-
/* @__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(
|
|
969
1313
|
"input",
|
|
970
1314
|
{
|
|
971
1315
|
id: "email",
|
|
@@ -977,27 +1321,48 @@ var LoginForm = ({
|
|
|
977
1321
|
style: {
|
|
978
1322
|
width: "100%",
|
|
979
1323
|
padding: "12px 16px",
|
|
980
|
-
border:
|
|
1324
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
981
1325
|
borderRadius: "8px",
|
|
982
1326
|
fontSize: "16px",
|
|
983
1327
|
boxSizing: "border-box",
|
|
984
|
-
color:
|
|
1328
|
+
color: colors.textPrimary,
|
|
985
1329
|
transition: "all 0.2s ease",
|
|
986
|
-
backgroundColor:
|
|
1330
|
+
backgroundColor: colors.bgSecondary
|
|
987
1331
|
},
|
|
988
1332
|
placeholder: "Enter your email"
|
|
989
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
|
+
}
|
|
990
1355
|
)
|
|
991
1356
|
] }),
|
|
992
1357
|
usePassword && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
993
|
-
marginBottom: "
|
|
1358
|
+
marginBottom: "16px",
|
|
994
1359
|
position: "relative"
|
|
995
1360
|
}, children: [
|
|
996
1361
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "login-password", style: {
|
|
997
1362
|
display: "block",
|
|
998
1363
|
marginBottom: "8px",
|
|
999
1364
|
fontWeight: 500,
|
|
1000
|
-
color:
|
|
1365
|
+
color: colors.textSecondary,
|
|
1001
1366
|
fontSize: "14px"
|
|
1002
1367
|
}, children: "Password:" }),
|
|
1003
1368
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1012,13 +1377,13 @@ var LoginForm = ({
|
|
|
1012
1377
|
style: {
|
|
1013
1378
|
width: "100%",
|
|
1014
1379
|
padding: "12px 16px",
|
|
1015
|
-
border:
|
|
1380
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1016
1381
|
borderRadius: "8px",
|
|
1017
1382
|
fontSize: "16px",
|
|
1018
1383
|
boxSizing: "border-box",
|
|
1019
|
-
color:
|
|
1384
|
+
color: colors.textPrimary,
|
|
1020
1385
|
transition: "all 0.2s ease",
|
|
1021
|
-
backgroundColor:
|
|
1386
|
+
backgroundColor: colors.bgSecondary
|
|
1022
1387
|
},
|
|
1023
1388
|
placeholder: "Enter your password"
|
|
1024
1389
|
}
|
|
@@ -1036,7 +1401,7 @@ var LoginForm = ({
|
|
|
1036
1401
|
background: "none",
|
|
1037
1402
|
border: "none",
|
|
1038
1403
|
cursor: "pointer",
|
|
1039
|
-
color:
|
|
1404
|
+
color: colors.textTertiary,
|
|
1040
1405
|
fontSize: "14px"
|
|
1041
1406
|
},
|
|
1042
1407
|
children: showPassword ? "Hide" : "Show"
|
|
@@ -1046,8 +1411,8 @@ var LoginForm = ({
|
|
|
1046
1411
|
usePassword && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1047
1412
|
display: "flex",
|
|
1048
1413
|
alignItems: "center",
|
|
1049
|
-
marginBottom: "
|
|
1050
|
-
marginTop: "
|
|
1414
|
+
marginBottom: "12px",
|
|
1415
|
+
marginTop: "4px"
|
|
1051
1416
|
}, children: [
|
|
1052
1417
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1053
1418
|
"input",
|
|
@@ -1071,7 +1436,7 @@ var LoginForm = ({
|
|
|
1071
1436
|
htmlFor: "remember-me",
|
|
1072
1437
|
style: {
|
|
1073
1438
|
fontSize: "14px",
|
|
1074
|
-
color:
|
|
1439
|
+
color: colors.textSecondary,
|
|
1075
1440
|
cursor: "pointer",
|
|
1076
1441
|
userSelect: "none"
|
|
1077
1442
|
},
|
|
@@ -1086,7 +1451,7 @@ var LoginForm = ({
|
|
|
1086
1451
|
disabled: isLoading,
|
|
1087
1452
|
style: {
|
|
1088
1453
|
padding: "14px",
|
|
1089
|
-
backgroundColor:
|
|
1454
|
+
backgroundColor: colors.buttonPrimary,
|
|
1090
1455
|
color: "white",
|
|
1091
1456
|
border: "none",
|
|
1092
1457
|
borderRadius: "8px",
|
|
@@ -1094,16 +1459,16 @@ var LoginForm = ({
|
|
|
1094
1459
|
fontWeight: 600,
|
|
1095
1460
|
cursor: "pointer",
|
|
1096
1461
|
transition: "all 0.2s ease",
|
|
1097
|
-
marginTop: "
|
|
1462
|
+
marginTop: "4px"
|
|
1098
1463
|
},
|
|
1099
1464
|
children: isLoading ? usePassword ? "Logging in..." : "Sending OTP..." : usePassword ? "Login" : "Send OTP"
|
|
1100
1465
|
}
|
|
1101
1466
|
),
|
|
1102
1467
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1103
1468
|
textAlign: "center",
|
|
1104
|
-
marginTop: "
|
|
1105
|
-
paddingTop: "
|
|
1106
|
-
borderTop:
|
|
1469
|
+
marginTop: "16px",
|
|
1470
|
+
paddingTop: "16px",
|
|
1471
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1107
1472
|
}, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1108
1473
|
"button",
|
|
1109
1474
|
{
|
|
@@ -1113,7 +1478,7 @@ var LoginForm = ({
|
|
|
1113
1478
|
style: {
|
|
1114
1479
|
background: "none",
|
|
1115
1480
|
border: "none",
|
|
1116
|
-
color:
|
|
1481
|
+
color: colors.buttonPrimary,
|
|
1117
1482
|
textDecoration: "none",
|
|
1118
1483
|
cursor: "pointer",
|
|
1119
1484
|
fontSize: "14px",
|
|
@@ -1125,9 +1490,9 @@ var LoginForm = ({
|
|
|
1125
1490
|
}
|
|
1126
1491
|
) }),
|
|
1127
1492
|
showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1128
|
-
marginTop: "
|
|
1129
|
-
paddingTop: "
|
|
1130
|
-
borderTop:
|
|
1493
|
+
marginTop: "16px",
|
|
1494
|
+
paddingTop: "16px",
|
|
1495
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1131
1496
|
}, children: [
|
|
1132
1497
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1133
1498
|
position: "relative",
|
|
@@ -1139,15 +1504,15 @@ var LoginForm = ({
|
|
|
1139
1504
|
left: 0,
|
|
1140
1505
|
right: 0,
|
|
1141
1506
|
height: "1px",
|
|
1142
|
-
backgroundColor:
|
|
1507
|
+
backgroundColor: colors.borderPrimary
|
|
1143
1508
|
} }),
|
|
1144
1509
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1145
1510
|
position: "relative",
|
|
1146
1511
|
textAlign: "center"
|
|
1147
1512
|
}, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: {
|
|
1148
|
-
backgroundColor:
|
|
1513
|
+
backgroundColor: colors.bgPrimary,
|
|
1149
1514
|
padding: "0 12px",
|
|
1150
|
-
color:
|
|
1515
|
+
color: colors.textSecondary,
|
|
1151
1516
|
fontSize: "14px"
|
|
1152
1517
|
}, children: "Or continue with" }) })
|
|
1153
1518
|
] }),
|
|
@@ -1166,10 +1531,10 @@ var LoginForm = ({
|
|
|
1166
1531
|
justifyContent: "center",
|
|
1167
1532
|
gap: "8px",
|
|
1168
1533
|
padding: "10px 16px",
|
|
1169
|
-
backgroundColor:
|
|
1170
|
-
border:
|
|
1534
|
+
backgroundColor: colors.bgPrimary,
|
|
1535
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1171
1536
|
borderRadius: "8px",
|
|
1172
|
-
color:
|
|
1537
|
+
color: colors.textPrimary,
|
|
1173
1538
|
textDecoration: "none",
|
|
1174
1539
|
fontSize: "14px",
|
|
1175
1540
|
fontWeight: 500,
|
|
@@ -1177,12 +1542,12 @@ var LoginForm = ({
|
|
|
1177
1542
|
transition: "all 0.2s ease"
|
|
1178
1543
|
},
|
|
1179
1544
|
onMouseEnter: (e) => {
|
|
1180
|
-
e.currentTarget.style.backgroundColor =
|
|
1181
|
-
e.currentTarget.style.borderColor =
|
|
1545
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
1546
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
1182
1547
|
},
|
|
1183
1548
|
onMouseLeave: (e) => {
|
|
1184
|
-
e.currentTarget.style.backgroundColor =
|
|
1185
|
-
e.currentTarget.style.borderColor =
|
|
1549
|
+
e.currentTarget.style.backgroundColor = colors.bgPrimary;
|
|
1550
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
1186
1551
|
},
|
|
1187
1552
|
children: [
|
|
1188
1553
|
/* @__PURE__ */ jsxRuntime.jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
|
|
@@ -1257,11 +1622,11 @@ var LoginForm = ({
|
|
|
1257
1622
|
] }),
|
|
1258
1623
|
showRegisterLink && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1259
1624
|
textAlign: "center",
|
|
1260
|
-
marginTop: "
|
|
1261
|
-
paddingTop: "
|
|
1262
|
-
borderTop:
|
|
1625
|
+
marginTop: "16px",
|
|
1626
|
+
paddingTop: "16px",
|
|
1627
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1263
1628
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("p", { style: {
|
|
1264
|
-
color:
|
|
1629
|
+
color: colors.textSecondary,
|
|
1265
1630
|
fontSize: "14px"
|
|
1266
1631
|
}, children: [
|
|
1267
1632
|
"Don't have an account?",
|
|
@@ -1275,7 +1640,7 @@ var LoginForm = ({
|
|
|
1275
1640
|
style: {
|
|
1276
1641
|
background: "none",
|
|
1277
1642
|
border: "none",
|
|
1278
|
-
color:
|
|
1643
|
+
color: colors.buttonPrimary,
|
|
1279
1644
|
textDecoration: "none",
|
|
1280
1645
|
cursor: "pointer",
|
|
1281
1646
|
fontSize: "14px",
|
|
@@ -1295,16 +1660,19 @@ var RegisterForm = ({
|
|
|
1295
1660
|
showLoginLink = true,
|
|
1296
1661
|
authConfig,
|
|
1297
1662
|
oauthProviders = ["google", "github"],
|
|
1298
|
-
showOAuthButtons = true
|
|
1663
|
+
showOAuthButtons = true,
|
|
1664
|
+
invitationToken
|
|
1299
1665
|
}) => {
|
|
1300
|
-
const
|
|
1301
|
-
const [
|
|
1302
|
-
const [
|
|
1303
|
-
const [
|
|
1304
|
-
const [
|
|
1305
|
-
const [
|
|
1306
|
-
|
|
1307
|
-
|
|
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);
|
|
1308
1676
|
const getPasswordStrength = (pwd) => {
|
|
1309
1677
|
if (!pwd)
|
|
1310
1678
|
return { strength: "weak", score: 0, label: "" };
|
|
@@ -1327,7 +1695,7 @@ var RegisterForm = ({
|
|
|
1327
1695
|
};
|
|
1328
1696
|
getPasswordStrength(password);
|
|
1329
1697
|
const config = authConfig || {
|
|
1330
|
-
baseUrl:
|
|
1698
|
+
baseUrl: "http://localhost:7000"
|
|
1331
1699
|
};
|
|
1332
1700
|
const { register } = useAuth2(config);
|
|
1333
1701
|
const handleSubmit = async (e) => {
|
|
@@ -1345,17 +1713,45 @@ var RegisterForm = ({
|
|
|
1345
1713
|
return;
|
|
1346
1714
|
}
|
|
1347
1715
|
try {
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
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
|
+
}
|
|
1357
1739
|
} else {
|
|
1358
|
-
|
|
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
|
+
}
|
|
1359
1755
|
}
|
|
1360
1756
|
} catch (err) {
|
|
1361
1757
|
setError(err instanceof Error ? err.message : "An unknown error occurred");
|
|
@@ -1366,40 +1762,40 @@ var RegisterForm = ({
|
|
|
1366
1762
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1367
1763
|
maxWidth: "400px",
|
|
1368
1764
|
margin: "0 auto",
|
|
1369
|
-
padding: "
|
|
1765
|
+
padding: "24px",
|
|
1370
1766
|
borderRadius: "12px",
|
|
1371
1767
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
1372
|
-
backgroundColor:
|
|
1373
|
-
border:
|
|
1768
|
+
backgroundColor: colors.bgPrimary,
|
|
1769
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
1374
1770
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: {
|
|
1375
1771
|
display: "flex",
|
|
1376
1772
|
flexDirection: "column"
|
|
1377
1773
|
}, children: [
|
|
1378
1774
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
|
|
1379
1775
|
textAlign: "center",
|
|
1380
|
-
marginBottom: "
|
|
1381
|
-
color:
|
|
1776
|
+
marginBottom: "20px",
|
|
1777
|
+
color: colors.textPrimary,
|
|
1382
1778
|
fontSize: "24px",
|
|
1383
1779
|
fontWeight: 600
|
|
1384
1780
|
}, children: "Register" }),
|
|
1385
1781
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1386
1782
|
padding: "12px 16px",
|
|
1387
|
-
marginBottom: "
|
|
1388
|
-
backgroundColor:
|
|
1389
|
-
color:
|
|
1390
|
-
border:
|
|
1783
|
+
marginBottom: "16px",
|
|
1784
|
+
backgroundColor: colors.errorBg,
|
|
1785
|
+
color: colors.errorText,
|
|
1786
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
1391
1787
|
borderRadius: "8px",
|
|
1392
1788
|
fontSize: "14px",
|
|
1393
1789
|
fontWeight: 500
|
|
1394
1790
|
}, children: error }),
|
|
1395
1791
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1396
|
-
marginBottom: "
|
|
1792
|
+
marginBottom: "16px"
|
|
1397
1793
|
}, children: [
|
|
1398
1794
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "name", style: {
|
|
1399
1795
|
display: "block",
|
|
1400
1796
|
marginBottom: "8px",
|
|
1401
1797
|
fontWeight: 500,
|
|
1402
|
-
color:
|
|
1798
|
+
color: colors.textSecondary,
|
|
1403
1799
|
fontSize: "14px"
|
|
1404
1800
|
}, children: "Name:" }),
|
|
1405
1801
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1414,26 +1810,26 @@ var RegisterForm = ({
|
|
|
1414
1810
|
style: {
|
|
1415
1811
|
width: "100%",
|
|
1416
1812
|
padding: "12px 16px",
|
|
1417
|
-
border:
|
|
1813
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1418
1814
|
borderRadius: "8px",
|
|
1419
1815
|
fontSize: "16px",
|
|
1420
1816
|
boxSizing: "border-box",
|
|
1421
|
-
color:
|
|
1817
|
+
color: colors.textPrimary,
|
|
1422
1818
|
transition: "all 0.2s ease",
|
|
1423
|
-
backgroundColor:
|
|
1819
|
+
backgroundColor: colors.bgSecondary
|
|
1424
1820
|
},
|
|
1425
1821
|
placeholder: "Enter your name"
|
|
1426
1822
|
}
|
|
1427
1823
|
)
|
|
1428
1824
|
] }),
|
|
1429
1825
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1430
|
-
marginBottom: "
|
|
1826
|
+
marginBottom: "16px"
|
|
1431
1827
|
}, children: [
|
|
1432
1828
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "register-email", style: {
|
|
1433
1829
|
display: "block",
|
|
1434
1830
|
marginBottom: "8px",
|
|
1435
1831
|
fontWeight: 500,
|
|
1436
|
-
color:
|
|
1832
|
+
color: colors.textSecondary,
|
|
1437
1833
|
fontSize: "14px"
|
|
1438
1834
|
}, children: "Email:" }),
|
|
1439
1835
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1443,31 +1839,52 @@ var RegisterForm = ({
|
|
|
1443
1839
|
type: "email",
|
|
1444
1840
|
value: email,
|
|
1445
1841
|
onChange: (e) => setEmail(e.target.value),
|
|
1446
|
-
required:
|
|
1842
|
+
required: !phoneNumber,
|
|
1447
1843
|
disabled: isLoading,
|
|
1448
1844
|
style: {
|
|
1449
1845
|
width: "100%",
|
|
1450
1846
|
padding: "12px 16px",
|
|
1451
|
-
border:
|
|
1847
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1452
1848
|
borderRadius: "8px",
|
|
1453
1849
|
fontSize: "16px",
|
|
1454
1850
|
boxSizing: "border-box",
|
|
1455
|
-
color:
|
|
1851
|
+
color: colors.textPrimary,
|
|
1456
1852
|
transition: "all 0.2s ease",
|
|
1457
|
-
backgroundColor:
|
|
1853
|
+
backgroundColor: colors.bgSecondary
|
|
1458
1854
|
},
|
|
1459
1855
|
placeholder: "Enter your email"
|
|
1460
1856
|
}
|
|
1461
1857
|
)
|
|
1462
1858
|
] }),
|
|
1463
1859
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1464
|
-
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"
|
|
1465
1882
|
}, children: [
|
|
1466
1883
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
|
|
1467
1884
|
display: "block",
|
|
1468
1885
|
marginBottom: "8px",
|
|
1469
1886
|
fontWeight: 500,
|
|
1470
|
-
color:
|
|
1887
|
+
color: colors.textSecondary,
|
|
1471
1888
|
fontSize: "14px"
|
|
1472
1889
|
}, children: "Password:" }),
|
|
1473
1890
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1482,13 +1899,13 @@ var RegisterForm = ({
|
|
|
1482
1899
|
style: {
|
|
1483
1900
|
width: "100%",
|
|
1484
1901
|
padding: "12px 16px",
|
|
1485
|
-
border:
|
|
1902
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1486
1903
|
borderRadius: "8px",
|
|
1487
1904
|
fontSize: "16px",
|
|
1488
1905
|
boxSizing: "border-box",
|
|
1489
|
-
color:
|
|
1906
|
+
color: colors.textPrimary,
|
|
1490
1907
|
transition: "all 0.2s ease",
|
|
1491
|
-
backgroundColor:
|
|
1908
|
+
backgroundColor: colors.bgSecondary
|
|
1492
1909
|
},
|
|
1493
1910
|
placeholder: "Enter your password",
|
|
1494
1911
|
minLength: 6
|
|
@@ -1496,13 +1913,13 @@ var RegisterForm = ({
|
|
|
1496
1913
|
)
|
|
1497
1914
|
] }),
|
|
1498
1915
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1499
|
-
marginBottom: "
|
|
1916
|
+
marginBottom: "16px"
|
|
1500
1917
|
}, children: [
|
|
1501
1918
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "confirm-password", style: {
|
|
1502
1919
|
display: "block",
|
|
1503
1920
|
marginBottom: "8px",
|
|
1504
1921
|
fontWeight: 500,
|
|
1505
|
-
color:
|
|
1922
|
+
color: colors.textSecondary,
|
|
1506
1923
|
fontSize: "14px"
|
|
1507
1924
|
}, children: "Confirm Password:" }),
|
|
1508
1925
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1517,13 +1934,13 @@ var RegisterForm = ({
|
|
|
1517
1934
|
style: {
|
|
1518
1935
|
width: "100%",
|
|
1519
1936
|
padding: "12px 16px",
|
|
1520
|
-
border:
|
|
1937
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1521
1938
|
borderRadius: "8px",
|
|
1522
1939
|
fontSize: "16px",
|
|
1523
1940
|
boxSizing: "border-box",
|
|
1524
|
-
color:
|
|
1941
|
+
color: colors.textPrimary,
|
|
1525
1942
|
transition: "all 0.2s ease",
|
|
1526
|
-
backgroundColor:
|
|
1943
|
+
backgroundColor: colors.bgSecondary
|
|
1527
1944
|
},
|
|
1528
1945
|
placeholder: "Confirm your password"
|
|
1529
1946
|
}
|
|
@@ -1536,7 +1953,7 @@ var RegisterForm = ({
|
|
|
1536
1953
|
disabled: isLoading,
|
|
1537
1954
|
style: {
|
|
1538
1955
|
padding: "14px",
|
|
1539
|
-
backgroundColor:
|
|
1956
|
+
backgroundColor: colors.buttonPrimary,
|
|
1540
1957
|
color: "white",
|
|
1541
1958
|
border: "none",
|
|
1542
1959
|
borderRadius: "8px",
|
|
@@ -1544,15 +1961,15 @@ var RegisterForm = ({
|
|
|
1544
1961
|
fontWeight: 600,
|
|
1545
1962
|
cursor: "pointer",
|
|
1546
1963
|
transition: "all 0.2s ease",
|
|
1547
|
-
marginTop: "
|
|
1964
|
+
marginTop: "4px"
|
|
1548
1965
|
},
|
|
1549
1966
|
children: isLoading ? "Registering..." : "Register"
|
|
1550
1967
|
}
|
|
1551
1968
|
),
|
|
1552
1969
|
showOAuthButtons && oauthProviders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1553
|
-
marginTop: "
|
|
1554
|
-
paddingTop: "
|
|
1555
|
-
borderTop:
|
|
1970
|
+
marginTop: "16px",
|
|
1971
|
+
paddingTop: "16px",
|
|
1972
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1556
1973
|
}, children: [
|
|
1557
1974
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
1558
1975
|
position: "relative",
|
|
@@ -1564,15 +1981,15 @@ var RegisterForm = ({
|
|
|
1564
1981
|
left: 0,
|
|
1565
1982
|
right: 0,
|
|
1566
1983
|
height: "1px",
|
|
1567
|
-
backgroundColor:
|
|
1984
|
+
backgroundColor: colors.borderPrimary
|
|
1568
1985
|
} }),
|
|
1569
1986
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1570
1987
|
position: "relative",
|
|
1571
1988
|
textAlign: "center"
|
|
1572
1989
|
}, children: /* @__PURE__ */ jsxRuntime.jsx("span", { style: {
|
|
1573
|
-
backgroundColor:
|
|
1990
|
+
backgroundColor: colors.bgPrimary,
|
|
1574
1991
|
padding: "0 12px",
|
|
1575
|
-
color:
|
|
1992
|
+
color: colors.textSecondary,
|
|
1576
1993
|
fontSize: "14px"
|
|
1577
1994
|
}, children: "Or continue with" }) })
|
|
1578
1995
|
] }),
|
|
@@ -1591,10 +2008,10 @@ var RegisterForm = ({
|
|
|
1591
2008
|
justifyContent: "center",
|
|
1592
2009
|
gap: "8px",
|
|
1593
2010
|
padding: "10px 16px",
|
|
1594
|
-
backgroundColor:
|
|
1595
|
-
border:
|
|
2011
|
+
backgroundColor: colors.bgPrimary,
|
|
2012
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1596
2013
|
borderRadius: "8px",
|
|
1597
|
-
color:
|
|
2014
|
+
color: colors.textPrimary,
|
|
1598
2015
|
textDecoration: "none",
|
|
1599
2016
|
fontSize: "14px",
|
|
1600
2017
|
fontWeight: 500,
|
|
@@ -1602,12 +2019,12 @@ var RegisterForm = ({
|
|
|
1602
2019
|
transition: "all 0.2s ease"
|
|
1603
2020
|
},
|
|
1604
2021
|
onMouseEnter: (e) => {
|
|
1605
|
-
e.currentTarget.style.backgroundColor =
|
|
1606
|
-
e.currentTarget.style.borderColor =
|
|
2022
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
2023
|
+
e.currentTarget.style.borderColor = colors.buttonPrimary;
|
|
1607
2024
|
},
|
|
1608
2025
|
onMouseLeave: (e) => {
|
|
1609
|
-
e.currentTarget.style.backgroundColor =
|
|
1610
|
-
e.currentTarget.style.borderColor =
|
|
2026
|
+
e.currentTarget.style.backgroundColor = colors.bgPrimary;
|
|
2027
|
+
e.currentTarget.style.borderColor = colors.borderSecondary;
|
|
1611
2028
|
},
|
|
1612
2029
|
children: [
|
|
1613
2030
|
/* @__PURE__ */ jsxRuntime.jsxs("svg", { style: { width: "18px", height: "18px" }, viewBox: "0 0 24 24", children: [
|
|
@@ -1682,11 +2099,11 @@ var RegisterForm = ({
|
|
|
1682
2099
|
] }),
|
|
1683
2100
|
showLoginLink && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1684
2101
|
textAlign: "center",
|
|
1685
|
-
marginTop: "
|
|
1686
|
-
paddingTop: "
|
|
1687
|
-
borderTop:
|
|
2102
|
+
marginTop: "16px",
|
|
2103
|
+
paddingTop: "16px",
|
|
2104
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1688
2105
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("p", { style: {
|
|
1689
|
-
color:
|
|
2106
|
+
color: colors.textSecondary,
|
|
1690
2107
|
fontSize: "14px"
|
|
1691
2108
|
}, children: [
|
|
1692
2109
|
"Already have an account?",
|
|
@@ -1700,7 +2117,7 @@ var RegisterForm = ({
|
|
|
1700
2117
|
style: {
|
|
1701
2118
|
background: "none",
|
|
1702
2119
|
border: "none",
|
|
1703
|
-
color:
|
|
2120
|
+
color: colors.buttonPrimary,
|
|
1704
2121
|
textDecoration: "none",
|
|
1705
2122
|
cursor: "pointer",
|
|
1706
2123
|
fontSize: "14px",
|
|
@@ -1717,15 +2134,17 @@ var RegisterForm = ({
|
|
|
1717
2134
|
var OtpForm = ({
|
|
1718
2135
|
email,
|
|
1719
2136
|
onVerifySuccess,
|
|
1720
|
-
onBackToLogin
|
|
2137
|
+
onBackToLogin,
|
|
2138
|
+
baseUrl
|
|
1721
2139
|
}) => {
|
|
1722
|
-
const
|
|
1723
|
-
const [
|
|
1724
|
-
const [
|
|
1725
|
-
const [
|
|
1726
|
-
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);
|
|
1727
2146
|
const { verify, login } = useAuth2({
|
|
1728
|
-
baseUrl:
|
|
2147
|
+
baseUrl: baseUrl || process.env.NEXT_PUBLIC_AUTH_API_URL || "http://localhost:7000"
|
|
1729
2148
|
});
|
|
1730
2149
|
const handleSubmit = async (e) => {
|
|
1731
2150
|
e.preventDefault();
|
|
@@ -1788,8 +2207,8 @@ var OtpForm = ({
|
|
|
1788
2207
|
padding: "30px",
|
|
1789
2208
|
borderRadius: "12px",
|
|
1790
2209
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
1791
|
-
backgroundColor:
|
|
1792
|
-
border:
|
|
2210
|
+
backgroundColor: colors.bgPrimary,
|
|
2211
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
1793
2212
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, style: {
|
|
1794
2213
|
display: "flex",
|
|
1795
2214
|
flexDirection: "column"
|
|
@@ -1797,25 +2216,25 @@ var OtpForm = ({
|
|
|
1797
2216
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
|
|
1798
2217
|
textAlign: "center",
|
|
1799
2218
|
marginBottom: "24px",
|
|
1800
|
-
color:
|
|
2219
|
+
color: colors.textPrimary,
|
|
1801
2220
|
fontSize: "24px",
|
|
1802
2221
|
fontWeight: 600
|
|
1803
2222
|
}, children: "Verify OTP" }),
|
|
1804
2223
|
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: {
|
|
1805
2224
|
textAlign: "center",
|
|
1806
2225
|
marginBottom: "24px",
|
|
1807
|
-
color:
|
|
2226
|
+
color: colors.textSecondary,
|
|
1808
2227
|
fontSize: "14px"
|
|
1809
2228
|
}, children: [
|
|
1810
2229
|
"Enter the 6-digit code sent to ",
|
|
1811
|
-
/* @__PURE__ */ jsxRuntime.jsx("strong", { style: { color:
|
|
2230
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { style: { color: colors.textPrimary }, children: email })
|
|
1812
2231
|
] }),
|
|
1813
2232
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
1814
2233
|
padding: "12px 16px",
|
|
1815
2234
|
marginBottom: "20px",
|
|
1816
|
-
backgroundColor:
|
|
1817
|
-
color:
|
|
1818
|
-
border:
|
|
2235
|
+
backgroundColor: colors.errorBg,
|
|
2236
|
+
color: colors.errorText,
|
|
2237
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
1819
2238
|
borderRadius: "8px",
|
|
1820
2239
|
fontSize: "14px",
|
|
1821
2240
|
fontWeight: 500
|
|
@@ -1827,7 +2246,7 @@ var OtpForm = ({
|
|
|
1827
2246
|
display: "block",
|
|
1828
2247
|
marginBottom: "8px",
|
|
1829
2248
|
fontWeight: 500,
|
|
1830
|
-
color:
|
|
2249
|
+
color: colors.textSecondary,
|
|
1831
2250
|
fontSize: "14px"
|
|
1832
2251
|
}, children: "OTP Code:" }),
|
|
1833
2252
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1842,13 +2261,13 @@ var OtpForm = ({
|
|
|
1842
2261
|
style: {
|
|
1843
2262
|
width: "100%",
|
|
1844
2263
|
padding: "12px 16px",
|
|
1845
|
-
border:
|
|
2264
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
1846
2265
|
borderRadius: "8px",
|
|
1847
2266
|
fontSize: "20px",
|
|
1848
2267
|
boxSizing: "border-box",
|
|
1849
|
-
color:
|
|
2268
|
+
color: colors.textPrimary,
|
|
1850
2269
|
transition: "all 0.2s ease",
|
|
1851
|
-
backgroundColor:
|
|
2270
|
+
backgroundColor: colors.bgSecondary,
|
|
1852
2271
|
textAlign: "center",
|
|
1853
2272
|
letterSpacing: "5px"
|
|
1854
2273
|
},
|
|
@@ -1865,7 +2284,7 @@ var OtpForm = ({
|
|
|
1865
2284
|
disabled: isLoading || otp.length !== 6,
|
|
1866
2285
|
style: {
|
|
1867
2286
|
padding: "14px",
|
|
1868
|
-
backgroundColor:
|
|
2287
|
+
backgroundColor: colors.buttonPrimary,
|
|
1869
2288
|
color: "white",
|
|
1870
2289
|
border: "none",
|
|
1871
2290
|
borderRadius: "8px",
|
|
@@ -1882,7 +2301,7 @@ var OtpForm = ({
|
|
|
1882
2301
|
textAlign: "center",
|
|
1883
2302
|
marginTop: "20px",
|
|
1884
2303
|
paddingTop: "20px",
|
|
1885
|
-
borderTop:
|
|
2304
|
+
borderTop: `1px solid ${colors.borderPrimary}`
|
|
1886
2305
|
}, children: [
|
|
1887
2306
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1888
2307
|
"button",
|
|
@@ -1893,7 +2312,7 @@ var OtpForm = ({
|
|
|
1893
2312
|
style: {
|
|
1894
2313
|
background: "none",
|
|
1895
2314
|
border: "none",
|
|
1896
|
-
color: resendCooldown > 0 ?
|
|
2315
|
+
color: resendCooldown > 0 ? colors.textTertiary : colors.buttonPrimary,
|
|
1897
2316
|
textDecoration: "none",
|
|
1898
2317
|
cursor: resendCooldown > 0 ? "not-allowed" : "pointer",
|
|
1899
2318
|
fontSize: "14px",
|
|
@@ -1916,7 +2335,7 @@ var OtpForm = ({
|
|
|
1916
2335
|
style: {
|
|
1917
2336
|
background: "none",
|
|
1918
2337
|
border: "none",
|
|
1919
|
-
color:
|
|
2338
|
+
color: colors.buttonPrimary,
|
|
1920
2339
|
textDecoration: "none",
|
|
1921
2340
|
cursor: "pointer",
|
|
1922
2341
|
fontSize: "14px",
|
|
@@ -1935,9 +2354,9 @@ var AuthFlow = ({
|
|
|
1935
2354
|
initialStep = "login",
|
|
1936
2355
|
showTitle = true
|
|
1937
2356
|
}) => {
|
|
1938
|
-
const [step, setStep] =
|
|
1939
|
-
const [email, setEmail] =
|
|
1940
|
-
const [message, setMessage] =
|
|
2357
|
+
const [step, setStep] = React3.useState(initialStep);
|
|
2358
|
+
const [email, setEmail] = React3.useState("");
|
|
2359
|
+
const [message, setMessage] = React3.useState(null);
|
|
1941
2360
|
const handleLoginSuccess = (email2, needsOtpVerification) => {
|
|
1942
2361
|
setEmail(email2);
|
|
1943
2362
|
if (needsOtpVerification) {
|
|
@@ -2072,13 +2491,13 @@ var EmailVerificationPage = ({
|
|
|
2072
2491
|
onVerificationError,
|
|
2073
2492
|
baseUrl
|
|
2074
2493
|
}) => {
|
|
2075
|
-
const [isLoading, setIsLoading] =
|
|
2076
|
-
const [message, setMessage] =
|
|
2077
|
-
const [isSuccess, setIsSuccess] =
|
|
2494
|
+
const [isLoading, setIsLoading] = React3.useState(true);
|
|
2495
|
+
const [message, setMessage] = React3.useState("");
|
|
2496
|
+
const [isSuccess, setIsSuccess] = React3.useState(false);
|
|
2078
2497
|
const { verifyEmailToken } = useAuth2({
|
|
2079
2498
|
baseUrl: baseUrl || (typeof window !== "undefined" ? window.location.origin : "http://localhost:7000")
|
|
2080
2499
|
});
|
|
2081
|
-
|
|
2500
|
+
React3.useEffect(() => {
|
|
2082
2501
|
const verifyEmail = async () => {
|
|
2083
2502
|
if (!token) {
|
|
2084
2503
|
setIsLoading(false);
|
|
@@ -2183,18 +2602,31 @@ var EmailVerificationPage = ({
|
|
|
2183
2602
|
] })
|
|
2184
2603
|
] }) });
|
|
2185
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";
|
|
2186
2615
|
var SignIn = ({ redirectUrl, appearance }) => {
|
|
2187
2616
|
const { signIn, isSignedIn, loading: authLoading } = useAuth();
|
|
2188
|
-
const
|
|
2189
|
-
const [
|
|
2190
|
-
const [
|
|
2191
|
-
const [
|
|
2192
|
-
const [
|
|
2193
|
-
const [
|
|
2194
|
-
const [
|
|
2195
|
-
const [
|
|
2196
|
-
const [
|
|
2197
|
-
|
|
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(() => {
|
|
2198
2630
|
if (isSignedIn && redirectUrl) {
|
|
2199
2631
|
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
|
|
2200
2632
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -2207,25 +2639,26 @@ var SignIn = ({ redirectUrl, appearance }) => {
|
|
|
2207
2639
|
setError(null);
|
|
2208
2640
|
setSuccess(null);
|
|
2209
2641
|
try {
|
|
2642
|
+
const loginData = usePhone ? { phoneNumber } : { email };
|
|
2210
2643
|
if (needsOtp) {
|
|
2211
|
-
const response = await signIn({
|
|
2644
|
+
const response = await signIn({ ...loginData, otp });
|
|
2212
2645
|
if (response.success) {
|
|
2213
2646
|
setSuccess("Login successful!");
|
|
2214
2647
|
} else {
|
|
2215
2648
|
setError(response.message || "OTP verification failed");
|
|
2216
2649
|
}
|
|
2217
2650
|
} else if (usePassword) {
|
|
2218
|
-
const response = await signIn({
|
|
2651
|
+
const response = await signIn({ ...loginData, password });
|
|
2219
2652
|
if (response.success) {
|
|
2220
2653
|
setSuccess("Login successful!");
|
|
2221
2654
|
} else {
|
|
2222
2655
|
setError(response.message || "Login failed");
|
|
2223
2656
|
}
|
|
2224
2657
|
} else {
|
|
2225
|
-
const response = await signIn(
|
|
2226
|
-
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.")) {
|
|
2227
2660
|
setNeedsOtp(true);
|
|
2228
|
-
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.");
|
|
2229
2662
|
} else {
|
|
2230
2663
|
setError(response.message || "Failed to send OTP");
|
|
2231
2664
|
}
|
|
@@ -2243,238 +2676,366 @@ var SignIn = ({ redirectUrl, appearance }) => {
|
|
|
2243
2676
|
setSuccess(null);
|
|
2244
2677
|
setOtp("");
|
|
2245
2678
|
};
|
|
2679
|
+
const toggleLoginMethod = () => {
|
|
2680
|
+
setUsePhone(!usePhone);
|
|
2681
|
+
setNeedsOtp(false);
|
|
2682
|
+
setError(null);
|
|
2683
|
+
setSuccess(null);
|
|
2684
|
+
setOtp("");
|
|
2685
|
+
setEmail("");
|
|
2686
|
+
setPhoneNumber("");
|
|
2687
|
+
};
|
|
2246
2688
|
if (authLoading) {
|
|
2247
2689
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { textAlign: "center", padding: "40px" }, children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Loading..." }) });
|
|
2248
2690
|
}
|
|
2249
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
padding: "12px 16px",
|
|
2269
|
-
marginBottom: "20px",
|
|
2270
|
-
backgroundColor: "#fee",
|
|
2271
|
-
color: "#c33",
|
|
2272
|
-
border: "1px solid #fcc",
|
|
2273
|
-
borderRadius: "8px",
|
|
2274
|
-
fontSize: "14px"
|
|
2275
|
-
}, children: error }),
|
|
2276
|
-
success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2277
|
-
padding: "12px 16px",
|
|
2278
|
-
marginBottom: "20px",
|
|
2279
|
-
backgroundColor: "#efe",
|
|
2280
|
-
color: "#3c3",
|
|
2281
|
-
border: "1px solid #cfc",
|
|
2282
|
-
borderRadius: "8px",
|
|
2283
|
-
fontSize: "14px"
|
|
2284
|
-
}, children: success }),
|
|
2285
|
-
!needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2286
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "email", style: {
|
|
2287
|
-
display: "block",
|
|
2288
|
-
marginBottom: "8px",
|
|
2289
|
-
fontWeight: 500,
|
|
2290
|
-
color: "#374151",
|
|
2291
|
-
fontSize: "14px"
|
|
2292
|
-
}, children: "Email" }),
|
|
2293
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2294
|
-
"input",
|
|
2295
|
-
{
|
|
2296
|
-
id: "email",
|
|
2297
|
-
type: "email",
|
|
2298
|
-
value: email,
|
|
2299
|
-
onChange: (e) => setEmail(e.target.value),
|
|
2300
|
-
required: true,
|
|
2301
|
-
disabled: isLoading,
|
|
2302
|
-
style: {
|
|
2303
|
-
width: "100%",
|
|
2304
|
-
padding: "12px 16px",
|
|
2305
|
-
border: "1px solid #ddd",
|
|
2306
|
-
borderRadius: "8px",
|
|
2307
|
-
fontSize: "16px",
|
|
2308
|
-
boxSizing: "border-box",
|
|
2309
|
-
...appearance?.elements?.formFieldInput
|
|
2310
|
-
},
|
|
2311
|
-
placeholder: "Enter your email"
|
|
2312
|
-
}
|
|
2313
|
-
)
|
|
2314
|
-
] }),
|
|
2315
|
-
usePassword && !needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
|
|
2316
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
|
|
2317
|
-
display: "block",
|
|
2318
|
-
marginBottom: "8px",
|
|
2319
|
-
fontWeight: 500,
|
|
2320
|
-
color: "#374151",
|
|
2321
|
-
fontSize: "14px"
|
|
2322
|
-
}, children: "Password" }),
|
|
2323
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2324
|
-
"input",
|
|
2325
|
-
{
|
|
2326
|
-
id: "password",
|
|
2327
|
-
type: showPassword ? "text" : "password",
|
|
2328
|
-
value: password,
|
|
2329
|
-
onChange: (e) => setPassword(e.target.value),
|
|
2330
|
-
required: true,
|
|
2331
|
-
disabled: isLoading,
|
|
2332
|
-
style: {
|
|
2333
|
-
width: "100%",
|
|
2334
|
-
padding: "12px 16px",
|
|
2335
|
-
border: "1px solid #ddd",
|
|
2336
|
-
borderRadius: "8px",
|
|
2337
|
-
fontSize: "16px",
|
|
2338
|
-
boxSizing: "border-box",
|
|
2339
|
-
...appearance?.elements?.formFieldInput
|
|
2340
|
-
},
|
|
2341
|
-
placeholder: "Enter your password"
|
|
2342
|
-
}
|
|
2343
|
-
),
|
|
2344
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2345
|
-
"button",
|
|
2346
|
-
{
|
|
2347
|
-
type: "button",
|
|
2348
|
-
onClick: () => setShowPassword(!showPassword),
|
|
2349
|
-
style: {
|
|
2350
|
-
position: "absolute",
|
|
2351
|
-
right: "12px",
|
|
2352
|
-
top: "38px",
|
|
2353
|
-
background: "none",
|
|
2354
|
-
border: "none",
|
|
2355
|
-
cursor: "pointer",
|
|
2356
|
-
color: "#666",
|
|
2357
|
-
fontSize: "14px"
|
|
2358
|
-
},
|
|
2359
|
-
children: showPassword ? "Hide" : "Show"
|
|
2360
|
-
}
|
|
2361
|
-
)
|
|
2362
|
-
] }),
|
|
2363
|
-
needsOtp && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px" }, children: [
|
|
2364
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "otp", style: {
|
|
2365
|
-
display: "block",
|
|
2366
|
-
marginBottom: "8px",
|
|
2367
|
-
fontWeight: 500,
|
|
2368
|
-
color: "#374151",
|
|
2369
|
-
fontSize: "14px"
|
|
2370
|
-
}, children: "One-Time Password" }),
|
|
2371
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2372
|
-
"input",
|
|
2373
|
-
{
|
|
2374
|
-
id: "otp",
|
|
2375
|
-
type: "text",
|
|
2376
|
-
value: otp,
|
|
2377
|
-
onChange: (e) => setOtp(e.target.value),
|
|
2378
|
-
required: true,
|
|
2379
|
-
disabled: isLoading,
|
|
2380
|
-
maxLength: 6,
|
|
2381
|
-
style: {
|
|
2382
|
-
width: "100%",
|
|
2383
|
-
padding: "12px 16px",
|
|
2384
|
-
border: "1px solid #ddd",
|
|
2385
|
-
borderRadius: "8px",
|
|
2386
|
-
fontSize: "16px",
|
|
2387
|
-
boxSizing: "border-box",
|
|
2388
|
-
letterSpacing: "0.5em",
|
|
2389
|
-
textAlign: "center",
|
|
2390
|
-
...appearance?.elements?.formFieldInput
|
|
2391
|
-
},
|
|
2392
|
-
placeholder: "000000"
|
|
2393
|
-
}
|
|
2394
|
-
)
|
|
2395
|
-
] }),
|
|
2396
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2397
|
-
"button",
|
|
2398
|
-
{
|
|
2399
|
-
type: "submit",
|
|
2400
|
-
disabled: isLoading,
|
|
2401
|
-
style: {
|
|
2402
|
-
width: "100%",
|
|
2403
|
-
padding: "14px",
|
|
2404
|
-
backgroundColor: "#007bff",
|
|
2405
|
-
color: "white",
|
|
2406
|
-
border: "none",
|
|
2407
|
-
borderRadius: "8px",
|
|
2408
|
-
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",
|
|
2409
2710
|
fontWeight: 600,
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
fontSize: "14px"
|
|
2429
|
-
|
|
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
|
-
|
|
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
|
+
);
|
|
2457
3016
|
};
|
|
2458
3017
|
var SignUp = ({ redirectUrl, appearance }) => {
|
|
2459
3018
|
const { signUp, isSignedIn } = useAuth();
|
|
2460
|
-
const
|
|
2461
|
-
const [
|
|
2462
|
-
const [
|
|
2463
|
-
const [
|
|
2464
|
-
const [
|
|
2465
|
-
const [
|
|
2466
|
-
const [
|
|
2467
|
-
const [
|
|
2468
|
-
|
|
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(() => {
|
|
2469
3030
|
if (isSignedIn && redirectUrl) {
|
|
2470
3031
|
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_REGISTER || process.env.REACT_APP_AUTH_REDIRECT_AFTER_REGISTER || "/dashboard";
|
|
2471
3032
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2472
3033
|
window.location.href = `${baseUrl}${redirect}`;
|
|
2473
3034
|
}
|
|
2474
3035
|
}, [isSignedIn, redirectUrl]);
|
|
2475
|
-
const getPasswordStrength = (pwd) => {
|
|
3036
|
+
const getPasswordStrength = (pwd, colors2) => {
|
|
2476
3037
|
if (!pwd)
|
|
2477
|
-
return { strength: "weak", color:
|
|
3038
|
+
return { strength: "weak", color: colors2.borderSecondary };
|
|
2478
3039
|
let score = 0;
|
|
2479
3040
|
if (pwd.length >= 6)
|
|
2480
3041
|
score++;
|
|
@@ -2487,12 +3048,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2487
3048
|
if (/[^a-zA-Z\d]/.test(pwd))
|
|
2488
3049
|
score++;
|
|
2489
3050
|
if (score <= 2)
|
|
2490
|
-
return { strength: "weak", color:
|
|
3051
|
+
return { strength: "weak", color: colors2.errorText };
|
|
2491
3052
|
if (score <= 3)
|
|
2492
|
-
return { strength: "medium", color: "#fa4" };
|
|
2493
|
-
return { strength: "strong", color:
|
|
3053
|
+
return { strength: "medium", color: colors2.warningText || "#fa4" };
|
|
3054
|
+
return { strength: "strong", color: colors2.successText };
|
|
2494
3055
|
};
|
|
2495
|
-
const passwordStrength = getPasswordStrength(password);
|
|
3056
|
+
const passwordStrength = getPasswordStrength(password, colors);
|
|
2496
3057
|
const handleSubmit = async (e) => {
|
|
2497
3058
|
e.preventDefault();
|
|
2498
3059
|
setIsLoading(true);
|
|
@@ -2509,7 +3070,12 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2509
3070
|
return;
|
|
2510
3071
|
}
|
|
2511
3072
|
try {
|
|
2512
|
-
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);
|
|
2513
3079
|
if (response.success) {
|
|
2514
3080
|
setSuccess("Registration successful! Please check your email to verify your account.");
|
|
2515
3081
|
} else {
|
|
@@ -2521,20 +3087,20 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2521
3087
|
setIsLoading(false);
|
|
2522
3088
|
}
|
|
2523
3089
|
};
|
|
2524
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3090
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ThemeWrapper, { style: {
|
|
2525
3091
|
maxWidth: "400px",
|
|
2526
3092
|
margin: "0 auto",
|
|
2527
3093
|
padding: "30px",
|
|
2528
3094
|
borderRadius: "12px",
|
|
2529
3095
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
|
|
2530
|
-
backgroundColor:
|
|
2531
|
-
border:
|
|
3096
|
+
backgroundColor: colors.bgPrimary,
|
|
3097
|
+
border: `1px solid ${colors.borderPrimary}`,
|
|
2532
3098
|
...appearance?.elements?.card
|
|
2533
3099
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, children: [
|
|
2534
3100
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { style: {
|
|
2535
3101
|
textAlign: "center",
|
|
2536
3102
|
marginBottom: "24px",
|
|
2537
|
-
color:
|
|
3103
|
+
color: colors.textPrimary,
|
|
2538
3104
|
fontSize: "24px",
|
|
2539
3105
|
fontWeight: 600,
|
|
2540
3106
|
...appearance?.elements?.headerTitle
|
|
@@ -2542,18 +3108,18 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2542
3108
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2543
3109
|
padding: "12px 16px",
|
|
2544
3110
|
marginBottom: "20px",
|
|
2545
|
-
backgroundColor:
|
|
2546
|
-
color:
|
|
2547
|
-
border:
|
|
3111
|
+
backgroundColor: colors.errorBg,
|
|
3112
|
+
color: colors.errorText,
|
|
3113
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
2548
3114
|
borderRadius: "8px",
|
|
2549
3115
|
fontSize: "14px"
|
|
2550
3116
|
}, children: error }),
|
|
2551
3117
|
success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2552
3118
|
padding: "12px 16px",
|
|
2553
3119
|
marginBottom: "20px",
|
|
2554
|
-
backgroundColor:
|
|
2555
|
-
color:
|
|
2556
|
-
border:
|
|
3120
|
+
backgroundColor: colors.successBg,
|
|
3121
|
+
color: colors.successText,
|
|
3122
|
+
border: `1px solid ${colors.successBorder}`,
|
|
2557
3123
|
borderRadius: "8px",
|
|
2558
3124
|
fontSize: "14px"
|
|
2559
3125
|
}, children: success }),
|
|
@@ -2562,7 +3128,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2562
3128
|
display: "block",
|
|
2563
3129
|
marginBottom: "8px",
|
|
2564
3130
|
fontWeight: 500,
|
|
2565
|
-
color:
|
|
3131
|
+
color: colors.textSecondary,
|
|
2566
3132
|
fontSize: "14px"
|
|
2567
3133
|
}, children: "Full name" }),
|
|
2568
3134
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2572,15 +3138,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2572
3138
|
type: "text",
|
|
2573
3139
|
value: name,
|
|
2574
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
|
+
},
|
|
2575
3149
|
required: true,
|
|
2576
3150
|
disabled: isLoading,
|
|
2577
3151
|
style: {
|
|
2578
3152
|
width: "100%",
|
|
2579
3153
|
padding: "12px 16px",
|
|
2580
|
-
border:
|
|
3154
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2581
3155
|
borderRadius: "8px",
|
|
2582
3156
|
fontSize: "16px",
|
|
2583
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`,
|
|
2584
3163
|
...appearance?.elements?.formFieldInput
|
|
2585
3164
|
},
|
|
2586
3165
|
placeholder: "Enter your full name"
|
|
@@ -2592,7 +3171,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2592
3171
|
display: "block",
|
|
2593
3172
|
marginBottom: "8px",
|
|
2594
3173
|
fontWeight: 500,
|
|
2595
|
-
color:
|
|
3174
|
+
color: colors.textSecondary,
|
|
2596
3175
|
fontSize: "14px"
|
|
2597
3176
|
}, children: "Email" }),
|
|
2598
3177
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2602,27 +3181,60 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2602
3181
|
type: "email",
|
|
2603
3182
|
value: email,
|
|
2604
3183
|
onChange: (e) => setEmail(e.target.value),
|
|
2605
|
-
|
|
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,
|
|
2606
3193
|
disabled: isLoading,
|
|
2607
3194
|
style: {
|
|
2608
3195
|
width: "100%",
|
|
2609
3196
|
padding: "12px 16px",
|
|
2610
|
-
border:
|
|
3197
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2611
3198
|
borderRadius: "8px",
|
|
2612
3199
|
fontSize: "16px",
|
|
2613
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`,
|
|
2614
3206
|
...appearance?.elements?.formFieldInput
|
|
2615
3207
|
},
|
|
2616
3208
|
placeholder: "Enter your email"
|
|
2617
3209
|
}
|
|
2618
3210
|
)
|
|
2619
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
|
+
] }),
|
|
2620
3232
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "20px", position: "relative" }, children: [
|
|
2621
3233
|
/* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: "password", style: {
|
|
2622
3234
|
display: "block",
|
|
2623
3235
|
marginBottom: "8px",
|
|
2624
3236
|
fontWeight: 500,
|
|
2625
|
-
color:
|
|
3237
|
+
color: colors.textSecondary,
|
|
2626
3238
|
fontSize: "14px"
|
|
2627
3239
|
}, children: "Password" }),
|
|
2628
3240
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2632,16 +3244,29 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2632
3244
|
type: showPassword ? "text" : "password",
|
|
2633
3245
|
value: password,
|
|
2634
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
|
+
},
|
|
2635
3255
|
required: true,
|
|
2636
3256
|
disabled: isLoading,
|
|
2637
3257
|
minLength: 6,
|
|
2638
3258
|
style: {
|
|
2639
3259
|
width: "100%",
|
|
2640
3260
|
padding: "12px 16px",
|
|
2641
|
-
border:
|
|
3261
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2642
3262
|
borderRadius: "8px",
|
|
2643
3263
|
fontSize: "16px",
|
|
2644
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`,
|
|
2645
3270
|
...appearance?.elements?.formFieldInput
|
|
2646
3271
|
},
|
|
2647
3272
|
placeholder: "Create a password"
|
|
@@ -2659,7 +3284,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2659
3284
|
background: "none",
|
|
2660
3285
|
border: "none",
|
|
2661
3286
|
cursor: "pointer",
|
|
2662
|
-
color:
|
|
3287
|
+
color: colors.textTertiary,
|
|
2663
3288
|
fontSize: "14px"
|
|
2664
3289
|
},
|
|
2665
3290
|
children: showPassword ? "Hide" : "Show"
|
|
@@ -2668,7 +3293,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2668
3293
|
password && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginTop: "8px" }, children: [
|
|
2669
3294
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2670
3295
|
height: "4px",
|
|
2671
|
-
backgroundColor:
|
|
3296
|
+
backgroundColor: colors.borderSecondary,
|
|
2672
3297
|
borderRadius: "2px",
|
|
2673
3298
|
overflow: "hidden"
|
|
2674
3299
|
}, children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
@@ -2693,7 +3318,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2693
3318
|
display: "block",
|
|
2694
3319
|
marginBottom: "8px",
|
|
2695
3320
|
fontWeight: 500,
|
|
2696
|
-
color:
|
|
3321
|
+
color: colors.textSecondary,
|
|
2697
3322
|
fontSize: "14px"
|
|
2698
3323
|
}, children: "Confirm password" }),
|
|
2699
3324
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2703,15 +3328,28 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2703
3328
|
type: showPassword ? "text" : "password",
|
|
2704
3329
|
value: confirmPassword,
|
|
2705
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
|
+
},
|
|
2706
3339
|
required: true,
|
|
2707
3340
|
disabled: isLoading,
|
|
2708
3341
|
style: {
|
|
2709
3342
|
width: "100%",
|
|
2710
3343
|
padding: "12px 16px",
|
|
2711
|
-
border:
|
|
3344
|
+
border: `1px solid ${colors.borderSecondary}`,
|
|
2712
3345
|
borderRadius: "8px",
|
|
2713
3346
|
fontSize: "16px",
|
|
2714
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`,
|
|
2715
3353
|
...appearance?.elements?.formFieldInput
|
|
2716
3354
|
},
|
|
2717
3355
|
placeholder: "Confirm your password"
|
|
@@ -2723,16 +3361,25 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2723
3361
|
{
|
|
2724
3362
|
type: "submit",
|
|
2725
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
|
+
},
|
|
2726
3372
|
style: {
|
|
2727
3373
|
width: "100%",
|
|
2728
3374
|
padding: "14px",
|
|
2729
|
-
backgroundColor:
|
|
3375
|
+
backgroundColor: colors.buttonPrimary,
|
|
2730
3376
|
color: "white",
|
|
2731
3377
|
border: "none",
|
|
2732
3378
|
borderRadius: "8px",
|
|
2733
3379
|
fontSize: "16px",
|
|
2734
3380
|
fontWeight: 600,
|
|
2735
|
-
cursor: "pointer",
|
|
3381
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
3382
|
+
opacity: isLoading ? 0.6 : 1,
|
|
2736
3383
|
transition: "all 0.2s ease",
|
|
2737
3384
|
...appearance?.elements?.formButtonPrimary
|
|
2738
3385
|
},
|
|
@@ -2743,7 +3390,7 @@ var SignUp = ({ redirectUrl, appearance }) => {
|
|
|
2743
3390
|
};
|
|
2744
3391
|
var SignOut = ({ redirectUrl }) => {
|
|
2745
3392
|
const { signOut } = useAuth();
|
|
2746
|
-
|
|
3393
|
+
React3.useEffect(() => {
|
|
2747
3394
|
const performSignOut = async () => {
|
|
2748
3395
|
await signOut();
|
|
2749
3396
|
const redirect = redirectUrl || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGOUT || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGOUT || "/";
|
|
@@ -2756,9 +3403,10 @@ var SignOut = ({ redirectUrl }) => {
|
|
|
2756
3403
|
};
|
|
2757
3404
|
var UserButton = ({ showName = false, appearance }) => {
|
|
2758
3405
|
const { user, signOut } = useAuth();
|
|
2759
|
-
const
|
|
2760
|
-
const
|
|
2761
|
-
|
|
3406
|
+
const colors = useThemeColors();
|
|
3407
|
+
const [isOpen, setIsOpen] = React3.useState(false);
|
|
3408
|
+
const dropdownRef = React3.useRef(null);
|
|
3409
|
+
React3.useEffect(() => {
|
|
2762
3410
|
const handleClickOutside = (event) => {
|
|
2763
3411
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
2764
3412
|
setIsOpen(false);
|
|
@@ -2778,7 +3426,7 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2778
3426
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
2779
3427
|
window.location.href = `${baseUrl}${redirect}`;
|
|
2780
3428
|
};
|
|
2781
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3429
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(ThemeWrapper, { style: { position: "relative", ...appearance?.elements?.userButtonBox }, ref: dropdownRef, children: [
|
|
2782
3430
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2783
3431
|
"button",
|
|
2784
3432
|
{
|
|
@@ -2796,7 +3444,7 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2796
3444
|
...appearance?.elements?.userButtonTrigger
|
|
2797
3445
|
},
|
|
2798
3446
|
onMouseEnter: (e) => {
|
|
2799
|
-
e.currentTarget.style.backgroundColor =
|
|
3447
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
2800
3448
|
},
|
|
2801
3449
|
onMouseLeave: (e) => {
|
|
2802
3450
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
@@ -2806,15 +3454,15 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2806
3454
|
width: "36px",
|
|
2807
3455
|
height: "36px",
|
|
2808
3456
|
borderRadius: "50%",
|
|
2809
|
-
backgroundColor:
|
|
2810
|
-
color:
|
|
3457
|
+
backgroundColor: colors.buttonPrimary,
|
|
3458
|
+
color: colors.textPrimary,
|
|
2811
3459
|
display: "flex",
|
|
2812
3460
|
alignItems: "center",
|
|
2813
3461
|
justifyContent: "center",
|
|
2814
3462
|
fontSize: "14px",
|
|
2815
3463
|
fontWeight: 600
|
|
2816
3464
|
}, children: getInitials(user.name) }),
|
|
2817
|
-
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 })
|
|
2818
3466
|
]
|
|
2819
3467
|
}
|
|
2820
3468
|
),
|
|
@@ -2824,16 +3472,16 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2824
3472
|
right: 0,
|
|
2825
3473
|
marginTop: "8px",
|
|
2826
3474
|
width: "240px",
|
|
2827
|
-
backgroundColor:
|
|
3475
|
+
backgroundColor: colors.bgPrimary,
|
|
2828
3476
|
borderRadius: "12px",
|
|
2829
3477
|
boxShadow: "0 4px 20px rgba(0, 0, 0, 0.15)",
|
|
2830
|
-
border:
|
|
3478
|
+
border: `1px solid ${colors.borderPrimary}`,
|
|
2831
3479
|
zIndex: 1e3,
|
|
2832
3480
|
...appearance?.elements?.userButtonPopoverCard
|
|
2833
3481
|
}, children: [
|
|
2834
3482
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2835
3483
|
padding: "16px",
|
|
2836
|
-
borderBottom:
|
|
3484
|
+
borderBottom: `1px solid ${colors.borderPrimary}`
|
|
2837
3485
|
}, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
2838
3486
|
display: "flex",
|
|
2839
3487
|
alignItems: "center",
|
|
@@ -2843,8 +3491,8 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2843
3491
|
width: "48px",
|
|
2844
3492
|
height: "48px",
|
|
2845
3493
|
borderRadius: "50%",
|
|
2846
|
-
backgroundColor:
|
|
2847
|
-
color:
|
|
3494
|
+
backgroundColor: colors.buttonPrimary,
|
|
3495
|
+
color: colors.textPrimary,
|
|
2848
3496
|
display: "flex",
|
|
2849
3497
|
alignItems: "center",
|
|
2850
3498
|
justifyContent: "center",
|
|
@@ -2855,14 +3503,14 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2855
3503
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2856
3504
|
fontSize: "14px",
|
|
2857
3505
|
fontWeight: 600,
|
|
2858
|
-
color:
|
|
3506
|
+
color: colors.textPrimary,
|
|
2859
3507
|
overflow: "hidden",
|
|
2860
3508
|
textOverflow: "ellipsis",
|
|
2861
3509
|
whiteSpace: "nowrap"
|
|
2862
3510
|
}, children: user.name }),
|
|
2863
3511
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
2864
3512
|
fontSize: "12px",
|
|
2865
|
-
color:
|
|
3513
|
+
color: colors.textTertiary,
|
|
2866
3514
|
overflow: "hidden",
|
|
2867
3515
|
textOverflow: "ellipsis",
|
|
2868
3516
|
whiteSpace: "nowrap"
|
|
@@ -2882,12 +3530,12 @@ var UserButton = ({ showName = false, appearance }) => {
|
|
|
2882
3530
|
textAlign: "left",
|
|
2883
3531
|
cursor: "pointer",
|
|
2884
3532
|
fontSize: "14px",
|
|
2885
|
-
color:
|
|
3533
|
+
color: colors.textPrimary,
|
|
2886
3534
|
fontWeight: 500,
|
|
2887
3535
|
transition: "background-color 0.2s"
|
|
2888
3536
|
},
|
|
2889
3537
|
onMouseEnter: (e) => {
|
|
2890
|
-
e.currentTarget.style.backgroundColor =
|
|
3538
|
+
e.currentTarget.style.backgroundColor = colors.bgHover;
|
|
2891
3539
|
},
|
|
2892
3540
|
onMouseLeave: (e) => {
|
|
2893
3541
|
e.currentTarget.style.backgroundColor = "transparent";
|
|
@@ -2904,7 +3552,7 @@ var ProtectedRoute = ({
|
|
|
2904
3552
|
redirectTo
|
|
2905
3553
|
}) => {
|
|
2906
3554
|
const { isSignedIn, isLoaded } = useAuth();
|
|
2907
|
-
|
|
3555
|
+
React3.useEffect(() => {
|
|
2908
3556
|
if (isLoaded && !isSignedIn) {
|
|
2909
3557
|
const loginPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_TO_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_TO_LOGIN || "/auth/login";
|
|
2910
3558
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -2929,7 +3577,7 @@ var PublicRoute = ({
|
|
|
2929
3577
|
redirectTo
|
|
2930
3578
|
}) => {
|
|
2931
3579
|
const { isSignedIn, isLoaded } = useAuth();
|
|
2932
|
-
|
|
3580
|
+
React3.useEffect(() => {
|
|
2933
3581
|
if (isLoaded && isSignedIn) {
|
|
2934
3582
|
const dashboardPath = redirectTo || process.env.NEXT_PUBLIC_AUTH_REDIRECT_AFTER_LOGIN || process.env.REACT_APP_AUTH_REDIRECT_AFTER_LOGIN || "/dashboard";
|
|
2935
3583
|
const baseUrl = process.env.NEXT_PUBLIC_FRONTEND_BASE_URL || process.env.REACT_APP_FRONTEND_BASE_URL || (typeof window !== "undefined" ? window.location.origin : "");
|
|
@@ -2951,9 +3599,9 @@ var PublicRoute = ({
|
|
|
2951
3599
|
};
|
|
2952
3600
|
var VerifyEmail = ({ token, onSuccess, onError }) => {
|
|
2953
3601
|
const { verifyEmailToken } = useAuth();
|
|
2954
|
-
const [status, setStatus] =
|
|
2955
|
-
const [message, setMessage] =
|
|
2956
|
-
|
|
3602
|
+
const [status, setStatus] = React3.useState("loading");
|
|
3603
|
+
const [message, setMessage] = React3.useState("");
|
|
3604
|
+
React3.useEffect(() => {
|
|
2957
3605
|
const verify = async () => {
|
|
2958
3606
|
const verifyToken = token || (typeof window !== "undefined" ? new URLSearchParams(window.location.search).get("token") : null);
|
|
2959
3607
|
if (!verifyToken) {
|
|
@@ -3087,10 +3735,10 @@ var VerifyEmail = ({ token, onSuccess, onError }) => {
|
|
|
3087
3735
|
};
|
|
3088
3736
|
var ForgotPassword = ({ appearance }) => {
|
|
3089
3737
|
const { forgotPassword } = useAuth();
|
|
3090
|
-
const [email, setEmail] =
|
|
3091
|
-
const [isLoading, setIsLoading] =
|
|
3092
|
-
const [error, setError] =
|
|
3093
|
-
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);
|
|
3094
3742
|
const handleSubmit = async (e) => {
|
|
3095
3743
|
e.preventDefault();
|
|
3096
3744
|
setIsLoading(true);
|
|
@@ -3229,14 +3877,14 @@ var ForgotPassword = ({ appearance }) => {
|
|
|
3229
3877
|
};
|
|
3230
3878
|
var ResetPassword = ({ token, appearance }) => {
|
|
3231
3879
|
const { resetPassword } = useAuth();
|
|
3232
|
-
const [resetToken, setResetToken] =
|
|
3233
|
-
const [password, setPassword] =
|
|
3234
|
-
const [confirmPassword, setConfirmPassword] =
|
|
3235
|
-
const [showPassword, setShowPassword] =
|
|
3236
|
-
const [isLoading, setIsLoading] =
|
|
3237
|
-
const [error, setError] =
|
|
3238
|
-
const [success, setSuccess] =
|
|
3239
|
-
|
|
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(() => {
|
|
3240
3888
|
if (!resetToken && typeof window !== "undefined") {
|
|
3241
3889
|
const urlToken = new URLSearchParams(window.location.search).get("token");
|
|
3242
3890
|
if (urlToken) {
|
|
@@ -3491,13 +4139,13 @@ var ResetPassword = ({ token, appearance }) => {
|
|
|
3491
4139
|
};
|
|
3492
4140
|
var ChangePassword = ({ onSuccess, appearance }) => {
|
|
3493
4141
|
const { changePassword } = useAuth();
|
|
3494
|
-
const [oldPassword, setOldPassword] =
|
|
3495
|
-
const [newPassword, setNewPassword] =
|
|
3496
|
-
const [confirmPassword, setConfirmPassword] =
|
|
3497
|
-
const [showPasswords, setShowPasswords] =
|
|
3498
|
-
const [isLoading, setIsLoading] =
|
|
3499
|
-
const [error, setError] =
|
|
3500
|
-
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);
|
|
3501
4149
|
const getPasswordStrength = (pwd) => {
|
|
3502
4150
|
if (!pwd)
|
|
3503
4151
|
return { strength: "weak", color: "#ddd" };
|
|
@@ -3740,43 +4388,41 @@ var UserProfile = ({
|
|
|
3740
4388
|
showEmailChange = true,
|
|
3741
4389
|
showPasswordChange = true
|
|
3742
4390
|
}) => {
|
|
3743
|
-
const { user, updateProfile,
|
|
3744
|
-
const
|
|
3745
|
-
const [
|
|
3746
|
-
const [
|
|
3747
|
-
const [
|
|
3748
|
-
const [
|
|
3749
|
-
const [
|
|
3750
|
-
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) => {
|
|
3751
4401
|
e.preventDefault();
|
|
3752
4402
|
setIsLoading(true);
|
|
3753
4403
|
setError(null);
|
|
3754
4404
|
setSuccess(null);
|
|
3755
4405
|
try {
|
|
3756
|
-
const
|
|
3757
|
-
if (
|
|
3758
|
-
|
|
3759
|
-
} else {
|
|
3760
|
-
setError(response.message || "Failed to update name");
|
|
4406
|
+
const updates = {};
|
|
4407
|
+
if (name !== user?.name) {
|
|
4408
|
+
updates.name = name;
|
|
3761
4409
|
}
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
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);
|
|
3775
4422
|
if (response.success) {
|
|
3776
|
-
setSuccess("
|
|
3777
|
-
setAvatar("");
|
|
4423
|
+
setSuccess("Profile updated successfully!");
|
|
3778
4424
|
} else {
|
|
3779
|
-
setError(response.message || "Failed to update
|
|
4425
|
+
setError(response.message || "Failed to update profile");
|
|
3780
4426
|
}
|
|
3781
4427
|
} catch (err) {
|
|
3782
4428
|
setError(err instanceof Error ? err.message : "An error occurred");
|
|
@@ -3805,173 +4451,220 @@ var UserProfile = ({
|
|
|
3805
4451
|
};
|
|
3806
4452
|
if (!user)
|
|
3807
4453
|
return null;
|
|
3808
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { maxWidth: "
|
|
3809
|
-
/* @__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" }),
|
|
3810
4456
|
error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
3811
4457
|
padding: "12px 16px",
|
|
3812
4458
|
marginBottom: "20px",
|
|
3813
|
-
backgroundColor:
|
|
3814
|
-
color:
|
|
3815
|
-
border:
|
|
4459
|
+
backgroundColor: colors.errorBg,
|
|
4460
|
+
color: colors.errorText,
|
|
4461
|
+
border: `1px solid ${colors.errorBorder}`,
|
|
3816
4462
|
borderRadius: "8px",
|
|
3817
4463
|
fontSize: "14px"
|
|
3818
4464
|
}, children: error }),
|
|
3819
4465
|
success && /* @__PURE__ */ jsxRuntime.jsx("div", { style: {
|
|
3820
4466
|
padding: "12px 16px",
|
|
3821
4467
|
marginBottom: "20px",
|
|
3822
|
-
backgroundColor:
|
|
3823
|
-
color:
|
|
3824
|
-
border:
|
|
4468
|
+
backgroundColor: colors.successBg,
|
|
4469
|
+
color: colors.successText,
|
|
4470
|
+
border: `1px solid ${colors.successBorder}`,
|
|
3825
4471
|
borderRadius: "8px",
|
|
3826
4472
|
fontSize: "14px"
|
|
3827
4473
|
}, children: success }),
|
|
3828
4474
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
3829
|
-
padding: "
|
|
3830
|
-
backgroundColor:
|
|
3831
|
-
borderRadius: "
|
|
4475
|
+
padding: "24px",
|
|
4476
|
+
backgroundColor: colors.bgPrimary,
|
|
4477
|
+
borderRadius: "12px",
|
|
3832
4478
|
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3833
|
-
marginBottom: "
|
|
4479
|
+
marginBottom: "24px",
|
|
4480
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
3834
4481
|
}, children: [
|
|
3835
|
-
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "
|
|
3836
|
-
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit:
|
|
3837
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3838
|
-
"
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
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
|
+
] }),
|
|
3857
4566
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3858
4567
|
"button",
|
|
3859
4568
|
{
|
|
3860
4569
|
type: "submit",
|
|
3861
4570
|
disabled: isLoading,
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
border: "none",
|
|
3867
|
-
borderRadius: "8px",
|
|
3868
|
-
fontSize: "14px",
|
|
3869
|
-
fontWeight: 600,
|
|
3870
|
-
cursor: "pointer"
|
|
4571
|
+
onMouseEnter: (e) => {
|
|
4572
|
+
if (!isLoading) {
|
|
4573
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimaryHover;
|
|
4574
|
+
}
|
|
3871
4575
|
},
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
)
|
|
3875
|
-
] })
|
|
3876
|
-
] }),
|
|
3877
|
-
showAvatar && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
3878
|
-
padding: "20px",
|
|
3879
|
-
backgroundColor: "#fff",
|
|
3880
|
-
borderRadius: "8px",
|
|
3881
|
-
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3882
|
-
marginBottom: "20px"
|
|
3883
|
-
}, children: [
|
|
3884
|
-
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Update Avatar" }),
|
|
3885
|
-
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleUpdateAvatar, children: [
|
|
3886
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3887
|
-
"input",
|
|
3888
|
-
{
|
|
3889
|
-
type: "url",
|
|
3890
|
-
value: avatar,
|
|
3891
|
-
onChange: (e) => setAvatar(e.target.value),
|
|
3892
|
-
required: true,
|
|
3893
|
-
disabled: isLoading,
|
|
3894
|
-
style: {
|
|
3895
|
-
width: "100%",
|
|
3896
|
-
padding: "12px 16px",
|
|
3897
|
-
border: "1px solid #ddd",
|
|
3898
|
-
borderRadius: "8px",
|
|
3899
|
-
fontSize: "16px",
|
|
3900
|
-
boxSizing: "border-box",
|
|
3901
|
-
marginBottom: "12px"
|
|
4576
|
+
onMouseLeave: (e) => {
|
|
4577
|
+
e.currentTarget.style.backgroundColor = colors.buttonPrimary;
|
|
3902
4578
|
},
|
|
3903
|
-
placeholder: "Avatar URL"
|
|
3904
|
-
}
|
|
3905
|
-
),
|
|
3906
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3907
|
-
"button",
|
|
3908
|
-
{
|
|
3909
|
-
type: "submit",
|
|
3910
|
-
disabled: isLoading,
|
|
3911
4579
|
style: {
|
|
3912
|
-
padding: "
|
|
3913
|
-
backgroundColor:
|
|
4580
|
+
padding: "12px 24px",
|
|
4581
|
+
backgroundColor: colors.buttonPrimary,
|
|
3914
4582
|
color: "white",
|
|
3915
4583
|
border: "none",
|
|
3916
4584
|
borderRadius: "8px",
|
|
3917
4585
|
fontSize: "14px",
|
|
3918
4586
|
fontWeight: 600,
|
|
3919
|
-
cursor: "pointer"
|
|
4587
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
4588
|
+
opacity: isLoading ? 0.6 : 1,
|
|
4589
|
+
transition: "all 0.2s ease"
|
|
3920
4590
|
},
|
|
3921
|
-
children: "
|
|
4591
|
+
children: isLoading ? "Saving..." : "Save Changes"
|
|
3922
4592
|
}
|
|
3923
4593
|
)
|
|
3924
4594
|
] })
|
|
3925
4595
|
] }),
|
|
3926
4596
|
showEmailChange && /* @__PURE__ */ jsxRuntime.jsxs("div", { style: {
|
|
3927
|
-
padding: "
|
|
3928
|
-
backgroundColor:
|
|
3929
|
-
borderRadius: "
|
|
4597
|
+
padding: "24px",
|
|
4598
|
+
backgroundColor: colors.bgPrimary,
|
|
4599
|
+
borderRadius: "12px",
|
|
3930
4600
|
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
3931
|
-
marginBottom: "20px"
|
|
4601
|
+
marginBottom: "20px",
|
|
4602
|
+
border: `1px solid ${colors.borderPrimary}`
|
|
3932
4603
|
}, children: [
|
|
3933
|
-
/* @__PURE__ */ jsxRuntime.jsx("h3", { style: { marginBottom: "16px", fontSize: "18px", fontWeight: 600 }, children: "Change Email" }),
|
|
3934
|
-
/* @__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: [
|
|
3935
4606
|
"Current email: ",
|
|
3936
4607
|
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: user.email })
|
|
3937
4608
|
] }),
|
|
3938
4609
|
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleRequestEmailChange, children: [
|
|
3939
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3940
|
-
"
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
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
|
+
] }),
|
|
3959
4642
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3960
4643
|
"button",
|
|
3961
4644
|
{
|
|
3962
4645
|
type: "submit",
|
|
3963
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
|
+
},
|
|
3964
4655
|
style: {
|
|
3965
|
-
padding: "
|
|
3966
|
-
backgroundColor:
|
|
4656
|
+
padding: "12px 24px",
|
|
4657
|
+
backgroundColor: colors.buttonPrimary,
|
|
3967
4658
|
color: "white",
|
|
3968
4659
|
border: "none",
|
|
3969
4660
|
borderRadius: "8px",
|
|
3970
4661
|
fontSize: "14px",
|
|
3971
4662
|
fontWeight: 600,
|
|
3972
|
-
cursor: "pointer"
|
|
4663
|
+
cursor: isLoading ? "not-allowed" : "pointer",
|
|
4664
|
+
opacity: isLoading ? 0.6 : 1,
|
|
4665
|
+
transition: "all 0.2s ease"
|
|
3973
4666
|
},
|
|
3974
|
-
children: "Request Email Change"
|
|
4667
|
+
children: isLoading ? "Sending..." : "Request Email Change"
|
|
3975
4668
|
}
|
|
3976
4669
|
)
|
|
3977
4670
|
] })
|
|
@@ -3984,11 +4677,13 @@ var react_exports = {};
|
|
|
3984
4677
|
__export(react_exports, {
|
|
3985
4678
|
AuthFlow: () => AuthFlow,
|
|
3986
4679
|
AuthProvider: () => AuthProvider,
|
|
4680
|
+
AuthThemeProvider: () => AuthThemeProvider,
|
|
3987
4681
|
ChangePassword: () => ChangePassword,
|
|
3988
4682
|
EmailVerificationPage: () => EmailVerificationPage,
|
|
3989
4683
|
ForgotPassword: () => ForgotPassword,
|
|
3990
4684
|
LoginForm: () => LoginForm,
|
|
3991
4685
|
OtpForm: () => OtpForm,
|
|
4686
|
+
PhoneInput: () => PhoneInput,
|
|
3992
4687
|
ProtectedRoute: () => ProtectedRoute,
|
|
3993
4688
|
PublicRoute: () => PublicRoute,
|
|
3994
4689
|
RegisterForm: () => RegisterForm,
|
|
@@ -4000,7 +4695,8 @@ __export(react_exports, {
|
|
|
4000
4695
|
UserProfile: () => UserProfile,
|
|
4001
4696
|
VerifyEmail: () => VerifyEmail,
|
|
4002
4697
|
useAuth: () => useAuth,
|
|
4003
|
-
useAuthLegacy: () => useAuth2
|
|
4698
|
+
useAuthLegacy: () => useAuth2,
|
|
4699
|
+
useAuthTheme: () => useAuthTheme
|
|
4004
4700
|
});
|
|
4005
4701
|
|
|
4006
4702
|
// src/node/index.ts
|