fix(config): remove unused import, reorder hooks, and improve variable naming
Reorder validateKey function and useEffect to avoid referencing before definition. Rename loop variable from 't' to 'tool' for clarity. 💘 Generated with Crush Assisted-by: MiniMax-M2.7 via Crush <crush@charm.land>
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { useState, useEffect, useCallback } from 'react'
|
import { useState, useEffect, useCallback } from 'react'
|
||||||
import { User, Brain, RefreshCw, Wrench, Monitor, AlertTriangle, X } from 'lucide-react'
|
import { User, Brain, RefreshCw, Wrench, Monitor, AlertTriangle } from 'lucide-react'
|
||||||
import { useI18n } from '../i18n'
|
import { useI18n } from '../i18n'
|
||||||
|
|
||||||
const PANELS = [
|
const PANELS = [
|
||||||
@@ -311,16 +311,6 @@ function PanelProviders({ providers, editProvider, providerForm, setProviderForm
|
|||||||
const [validating, setValidating] = useState(null)
|
const [validating, setValidating] = useState(null)
|
||||||
const [keyStatus, setKeyStatus] = useState({})
|
const [keyStatus, setKeyStatus] = useState({})
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
providers.forEach(p => {
|
|
||||||
if (p.apiKey && !keyStatus[p.name]) {
|
|
||||||
validateKey(p)
|
|
||||||
} else if (!p.apiKey) {
|
|
||||||
setKeyStatus(prev => ({ ...prev, [p.name]: { valid: false, checked: true, error: 'Aucune clé' } }))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}, [providers])
|
|
||||||
|
|
||||||
const validateKey = async (p) => {
|
const validateKey = async (p) => {
|
||||||
setValidating(p.name)
|
setValidating(p.name)
|
||||||
try {
|
try {
|
||||||
@@ -332,6 +322,16 @@ function PanelProviders({ providers, editProvider, providerForm, setProviderForm
|
|||||||
setValidating(null)
|
setValidating(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
providers.forEach(p => {
|
||||||
|
if (p.apiKey && !keyStatus[p.name]) {
|
||||||
|
validateKey(p)
|
||||||
|
} else if (!p.apiKey) {
|
||||||
|
setKeyStatus(prev => ({ ...prev, [p.name]: { valid: false, checked: true, error: 'Aucune clé' } }))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, [providers])
|
||||||
|
|
||||||
const handleValidate = async (name, apiKey, model, baseUrl) => {
|
const handleValidate = async (name, apiKey, model, baseUrl) => {
|
||||||
setValidating(name)
|
setValidating(name)
|
||||||
try {
|
try {
|
||||||
@@ -412,7 +412,7 @@ function PanelUpdates({ updates, tools, checking, updating, needsUpdateCount, in
|
|||||||
window.dispatchEvent(new CustomEvent('ask-ai-terminal', { detail: { message: `Installe l'outil ${tool} sur mon système. Vérifie d'abord s'il est déjà installé, puis installe-le si nécessaire avec les commandes appropriées.` } }))
|
window.dispatchEvent(new CustomEvent('ask-ai-terminal', { detail: { message: `Installe l'outil ${tool} sur mon système. Vérifie d'abord s'il est déjà installé, puis installe-le si nécessaire avec les commandes appropriées.` } }))
|
||||||
}
|
}
|
||||||
|
|
||||||
const missingTools = tools.filter(t => !t.installed)
|
const missingTools = tools.filter(tool => !tool.installed)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Reference in New Issue
Block a user