diff --git a/src/pages/dashboard/Settings.tsx b/src/pages/dashboard/Settings.tsx index 52c679b..c9e8ab0 100644 --- a/src/pages/dashboard/Settings.tsx +++ b/src/pages/dashboard/Settings.tsx @@ -1,179 +1,89 @@ import React, { useState } from 'react'; import { Card } from '../../components/ui/card'; import { Label } from '../../components/ui/label'; -import { Switch } from '../../components/ui/switch'; -import { Slider } from '../../components/ui/slider'; -import { Tabs, TabsContent, TabsList, TabsTrigger } from '../../components/ui/tabs'; +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() { - // Chat & RAG Settings - const [retainContext, setRetainContext] = useState(true); - const [contextWindowSize, setContextWindowSize] = useState(10); - const [showSourceAttribution, setShowSourceAttribution] = useState(true); - const [relevanceThreshold, setRelevanceThreshold] = useState(0.8); - - // UI Settings const { isDarkMode, toggleDarkMode } = useTheme(); - const [messageGrouping, setMessageGrouping] = useState(true); + const [isDeleting, setIsDeleting] = useState(false); - // Privacy Settings - const [saveHistory, setSaveHistory] = useState(true); - const [anonymizeData, setAnonymizeData] = useState(false); - const [shareAnalytics, setShareAnalytics] = useState(true); + const handleDeleteResources = async () => { + // Add confirmation dialog + const confirmed = window.confirm( + 'Are you sure you want to delete all resources? This action cannot be undone.' + ); - const handleSliderChange = (values: number[]): number => { - return values[0]; + 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
+Keep conversation context for more relevant responses
+ +Delete all resources from the database
Number of previous messages to consider (1-20)
-Show source documents for responses
-Minimum relevance score for document retrieval (0-1)
-Enable dark color theme
-Group consecutive messages from the same source
-Store conversation history locally
-Remove personal information from logs
-Help improve the app by sharing usage data
-