import React, { useState } from 'react'; import { Card } from '../../components/ui/card'; import { Label } from '../../components/ui/label'; import { Switch } from '../../components/ui/Switch'; import { useTheme } from '../../contexts/ThemeContext'; import { Button } from '../../components/ui/Button'; import { supabase } from '../../lib/supabase'; import { Trash2 } from 'lucide-react'; function Settings() { const { isDarkMode, toggleDarkMode } = useTheme(); const [isDeleting, setIsDeleting] = useState(false); const handleDeleteResources = async () => { // Add confirmation dialog const confirmed = window.confirm( 'Are you sure you want to delete all resources? This action cannot be undone.' ); if (!confirmed) return; try { setIsDeleting(true); // Delete all records from documents table const { error: documentsError } = await supabase .from('documents') .delete() .neq('id', '0'); // Delete all records if (documentsError) throw documentsError; // Delete all records from n8n_chat_histories table const { error: chatHistoryError } = await supabase .from('n8n_chat_histories') .delete() .neq('id', '0'); // Delete all records if (chatHistoryError) throw chatHistoryError; alert('All resources have been deleted successfully'); } catch (error) { console.error('Error deleting resources:', error); alert('Failed to delete resources. Please try again.'); } finally { setIsDeleting(false); } }; return (
Enable dark color theme
Delete all resources from the database