@lastbrain/ai-ui-react 1.0.52 → 1.0.53
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.
|
@@ -5,6 +5,12 @@ import { useLB } from "../context/LBAuthProvider";
|
|
|
5
5
|
import { LBApiKeySelector } from "./LBApiKeySelector";
|
|
6
6
|
import { Mail, Lock, Sparkles, X, Loader2, AlertCircle } from "lucide-react";
|
|
7
7
|
export function LBSigninModal({ isOpen, onClose }) {
|
|
8
|
+
// React Hooks doivent être appelés avant toute condition ou return
|
|
9
|
+
const [email, setEmail] = useState("");
|
|
10
|
+
const [password, setPassword] = useState("");
|
|
11
|
+
const [loading, setLoading] = useState(false);
|
|
12
|
+
const [error, setError] = useState("");
|
|
13
|
+
const [showKeySelector, setShowKeySelector] = useState(false);
|
|
8
14
|
// Vérifier si LBProvider est disponible
|
|
9
15
|
let login;
|
|
10
16
|
let selectApiKeyWithToken;
|
|
@@ -21,17 +27,12 @@ export function LBSigninModal({ isOpen, onClose }) {
|
|
|
21
27
|
// LBProvider n'est pas disponible, ne pas rendre le modal
|
|
22
28
|
return null;
|
|
23
29
|
}
|
|
24
|
-
const [email, setEmail] = useState("");
|
|
25
|
-
const [password, setPassword] = useState("");
|
|
26
|
-
const [loading, setLoading] = useState(false);
|
|
27
|
-
const [error, setError] = useState("");
|
|
28
|
-
const [showKeySelector, setShowKeySelector] = useState(false);
|
|
29
30
|
// Si le status est "needs_key_selection", afficher le sélecteur
|
|
30
31
|
useEffect(() => {
|
|
31
|
-
if (lbStatus === "needs_key_selection" && apiKeys.length > 0) {
|
|
32
|
+
if (lbStatus === "needs_key_selection" && apiKeys.length > 0 && !showKeySelector) {
|
|
32
33
|
setShowKeySelector(true);
|
|
33
34
|
}
|
|
34
|
-
}, [lbStatus, apiKeys.length]);
|
|
35
|
+
}, [lbStatus, apiKeys.length, showKeySelector]);
|
|
35
36
|
if (!isOpen || !login)
|
|
36
37
|
return null;
|
|
37
38
|
const handleSubmit = async (e) => {
|
|
@@ -76,9 +77,8 @@ export function LBSigninModal({ isOpen, onClose }) {
|
|
|
76
77
|
};
|
|
77
78
|
const handleCancelKeySelection = () => {
|
|
78
79
|
setShowKeySelector(false);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
setError("");
|
|
80
|
+
// Fermer complètement le modal au lieu de rester dans l'état de sélection
|
|
81
|
+
onClose();
|
|
82
82
|
};
|
|
83
83
|
// Si on doit afficher le sélecteur de clés
|
|
84
84
|
if (showKeySelector && apiKeys.length > 0) {
|
package/package.json
CHANGED
|
@@ -11,6 +11,13 @@ export interface LBSigninModalProps {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export function LBSigninModal({ isOpen, onClose }: LBSigninModalProps) {
|
|
14
|
+
// React Hooks doivent être appelés avant toute condition ou return
|
|
15
|
+
const [email, setEmail] = useState("");
|
|
16
|
+
const [password, setPassword] = useState("");
|
|
17
|
+
const [loading, setLoading] = useState(false);
|
|
18
|
+
const [error, setError] = useState("");
|
|
19
|
+
const [showKeySelector, setShowKeySelector] = useState(false);
|
|
20
|
+
|
|
14
21
|
// Vérifier si LBProvider est disponible
|
|
15
22
|
let login:
|
|
16
23
|
| ((
|
|
@@ -37,18 +44,12 @@ export function LBSigninModal({ isOpen, onClose }: LBSigninModalProps) {
|
|
|
37
44
|
return null;
|
|
38
45
|
}
|
|
39
46
|
|
|
40
|
-
const [email, setEmail] = useState("");
|
|
41
|
-
const [password, setPassword] = useState("");
|
|
42
|
-
const [loading, setLoading] = useState(false);
|
|
43
|
-
const [error, setError] = useState("");
|
|
44
|
-
const [showKeySelector, setShowKeySelector] = useState(false);
|
|
45
|
-
|
|
46
47
|
// Si le status est "needs_key_selection", afficher le sélecteur
|
|
47
48
|
useEffect(() => {
|
|
48
|
-
if (lbStatus === "needs_key_selection" && apiKeys.length > 0) {
|
|
49
|
+
if (lbStatus === "needs_key_selection" && apiKeys.length > 0 && !showKeySelector) {
|
|
49
50
|
setShowKeySelector(true);
|
|
50
51
|
}
|
|
51
|
-
}, [lbStatus, apiKeys.length]);
|
|
52
|
+
}, [lbStatus, apiKeys.length, showKeySelector]);
|
|
52
53
|
|
|
53
54
|
if (!isOpen || !login) return null;
|
|
54
55
|
|
|
@@ -96,9 +97,8 @@ export function LBSigninModal({ isOpen, onClose }: LBSigninModalProps) {
|
|
|
96
97
|
|
|
97
98
|
const handleCancelKeySelection = () => {
|
|
98
99
|
setShowKeySelector(false);
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
setError("");
|
|
100
|
+
// Fermer complètement le modal au lieu de rester dans l'état de sélection
|
|
101
|
+
onClose();
|
|
102
102
|
};
|
|
103
103
|
|
|
104
104
|
// Si on doit afficher le sélecteur de clés
|