From a89fdd5f3ff0561070c29dbdb42990d239189ee3 Mon Sep 17 00:00:00 2001 From: AI Bot Date: Wed, 2 Sep 2026 12:23:43 +0530 Subject: [PATCH] feat: add confirmation state to DashboardSettings save button --- src/components/DashboardSettings.tsx | 42 ++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/src/components/DashboardSettings.tsx b/src/components/DashboardSettings.tsx index 33cdc61..e1ba9a8 100644 --- a/src/components/DashboardSettings.tsx +++ b/src/components/DashboardSettings.tsx @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; -import { X, Settings, Key, Sparkles, Image as ImageIcon, Lightbulb, Box } from 'lucide-react'; +import { X, Settings, Key, Sparkles, Image as ImageIcon, Lightbulb, Box, Check, Loader2 } from 'lucide-react'; import { cn } from '../lib/utils'; import { api } from '../lib/api'; @@ -17,6 +17,8 @@ export const DashboardSettings: React.FC = ({ isOpen, on const [openAiKey, setOpenAiKey] = useState(''); const [geminiApiKey, setGeminiApiKey] = useState(''); const [nanoBananaApiKey, setNanoBananaApiKey] = useState(''); + const [isSaving, setIsSaving] = useState(false); + const [isSaved, setIsSaved] = useState(false); useEffect(() => { if (isOpen) { @@ -31,10 +33,16 @@ export const DashboardSettings: React.FC = ({ isOpen, on }).catch(err => { console.error("Failed to load user keys", err); }); + // reset states + setIsSaving(false); + setIsSaved(false); } }, [isOpen]); const saveKeys = async () => { + setIsSaving(true); + setIsSaved(false); + const keys = { FAL_API_KEY: falApiKey, TRIPO_API_KEY: tripoApiKey, @@ -46,8 +54,13 @@ export const DashboardSettings: React.FC = ({ isOpen, on }; try { await api.saveUserKeys(keys); - onClose(); + setIsSaving(false); + setIsSaved(true); + setTimeout(() => { + onClose(); + }, 1500); // Close after showing success for a moment } catch (err) { + setIsSaving(false); console.error("Failed to save keys", err); alert("Failed to save API keys to database"); } @@ -218,10 +231,29 @@ export const DashboardSettings: React.FC = ({ isOpen, on