import React from 'react'; import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'; import { Settings as SettingsIcon, Save, ToggleLeft, ToggleRight } from 'lucide-react'; import { apiClient } from '../lib/api'; const Settings: React.FC = () => { const queryClient = useQueryClient(); const { data: settings, isLoading, error } = useQuery({ queryKey: ['settings'], queryFn: () => apiClient.getSettings(), }); const updateMutation = useMutation({ mutationFn: (data: any) => apiClient.updateSettings(data), onSuccess: () => { queryClient.invalidateQueries({ queryKey: ['settings'] }); }, }); const handleToggle = (key: string, value: boolean) => { updateMutation.mutate({ [key]: value }); }; if (isLoading) { return (
Failed to load settings
Configure your system preferences
Control how articles are processed and handled
Enable automatic fetching and processing of articles from feeds
Require manual approval before articles are published to platforms
Updating settings...
Failed to update settings. Please try again.
Settings updated successfully!