Improve OpenRouter API key configuration persistence and UI feedback

Update the settings page to properly persist the OpenRouter API key, provide visual feedback on existing configurations, and adjust save button logic based on configuration status.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda
Replit-Commit-Checkpoint-Type: intermediate_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/35Hxx7C
This commit is contained in:
michaelschal committed 2025-10-02 06:14:39 +00:00
1 parent 70dd8a4c87
commit 12d20541e2
1 file changed
+22 -6
+22 -6
View File
@@ -51,6 +51,9 @@ export default function Settings() {
}
}, [openrouterConfig]);
// Vérifier si une config OpenRouter existe déjà
const hasExistingConfig = !!openrouterConfig;
const saveCloudinaryMutation = useMutation({
mutationFn: () =>
apiRequest('POST', '/api/cloudinary/config', {
@@ -187,14 +190,22 @@ export default function Settings() {
type="password"
value={openrouterApiKey}
onChange={(e) => setOpenrouterApiKey(e.target.value)}
placeholder="sk-or-v1-..."
placeholder={hasExistingConfig ? "••••••••••••••••" : "sk-or-v1-..."}
data-testid="input-openrouter-api-key"
/>
<p className="text-xs text-muted-foreground">
Obtenez votre clé API sur{" "}
<a href="https://openrouter.ai/keys" target="_blank" rel="noopener noreferrer" className="underline">
openrouter.ai
</a>
{hasExistingConfig ? (
<>
<span className="text-green-600 dark:text-green-400">✓ Clé API configurée</span> - Laissez vide pour garder la clé actuelle
</>
) : (
<>
Obtenez votre clé API sur{" "}
<a href="https://openrouter.ai/keys" target="_blank" rel="noopener noreferrer" className="underline">
openrouter.ai
</a>
</>
)}
</p>
</div>
<div className="space-y-2">
@@ -231,7 +242,12 @@ export default function Settings() {
</div>
<Button
onClick={() => saveOpenrouterMutation.mutate()}
disabled={saveOpenrouterMutation.isPending || !openrouterApiKey || !openrouterModel || !openrouterSystemPrompt}
disabled={
saveOpenrouterMutation.isPending ||
!openrouterModel ||
!openrouterSystemPrompt ||
(!hasExistingConfig && !openrouterApiKey)
}
data-testid="button-save-openrouter"
className="w-full"
>