"use client"; import { useState, useEffect } from "react"; import { motion, AnimatePresence } from "framer-motion"; import { X, Save, RotateCcw, Check } from "lucide-react"; import { Button } from "@/components/ui/Button"; import { CHATBOT_CONFIG, type ChatbotConfig, getChatbotConfig, saveChatbotConfig, resetChatbotConfig } from "@/lib/chatbotConfig"; import { cn } from "@/lib/utils"; interface SettingsModalProps { isOpen: boolean; onClose: () => void; } export function SettingsModal({ isOpen, onClose }: SettingsModalProps) { const [config, setConfig] = useState(CHATBOT_CONFIG); const [saved, setSaved] = useState(false); // Load current config when modal opens useEffect(() => { if (isOpen) { setConfig(getChatbotConfig()); setSaved(false); } }, [isOpen]); const handleChange = (field: keyof ChatbotConfig, value: string) => { setConfig((prev) => ({ ...prev, [field]: value })); }; const handleSave = () => { saveChatbotConfig(config); setSaved(true); // Close after showing success setTimeout(() => { onClose(); }, 800); }; const handleReset = () => { setConfig(CHATBOT_CONFIG); resetChatbotConfig(); }; return ( {isOpen && ( <> {/* Backdrop */} {/* Modal */}
e.stopPropagation()} > {/* Header */}

Pengaturan Chatbot

{/* Body */}
{/* Name */}
handleChange("name", e.target.value)} maxLength={30} className="w-full rounded-xl border border-neutral-200 bg-white px-4 py-2.5 text-sm text-neutral-900 placeholder:text-neutral-400 transition-all duration-200 outline-none focus:border-brand-green focus:ring-3 focus:ring-brand-green/10" placeholder="Contoh: EMA" />

{config.name.length}/30 karakter

{/* Caption */}
handleChange("caption", e.target.value)} maxLength={50} className="w-full rounded-xl border border-neutral-200 bg-white px-4 py-2.5 text-sm text-neutral-900 placeholder:text-neutral-400 transition-all duration-200 outline-none focus:border-brand-green focus:ring-3 focus:ring-brand-green/10" placeholder="Contoh: Expert Mining Assistant" />

{config.caption.length}/50 karakter

{/* Description */}