import React, { useState, useEffect } from 'react' import { useForm } from 'react-hook-form' import { zodResolver } from '@hookform/resolvers/zod' import { FiMoon, FiSun, FiRefreshCw, FiAlertTriangle } from 'react-icons/fi' import { useConfigStore } from '../../stores/configStore' import { advancedConfigSchema, type AdvancedConfigForm } from '../../schemas/configuration' import Typography from '../../components/ui/Typography' import { Label } from '../../components/ui/label' import { Switch } from '../../components/ui/switch' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../components/ui/select' import { Button } from '../../components/ui/Button' import { useLegalStore } from '../../stores/legalStore' interface AdvancedSettingsProps { } export const AdvancedSettings: React.FC = () => { const { config, setTheme, setAutoStart, setLogLevel } = useConfigStore() const { reset: resetLegal, legalAcceptance } = useLegalStore() const [showResetConfirm, setShowResetConfirm] = useState(false) const { register, watch, reset } = useForm({ resolver: zodResolver(advancedConfigSchema), defaultValues: { theme: config?.advanced?.theme || 'light', autoStart: config?.advanced?.autoStart || false, logLevel: config?.advanced?.logLevel || 'info' } }) useEffect(() => { if (config?.advanced) { reset({ theme: config.advanced.theme || 'light', autoStart: config.advanced.autoStart || false, logLevel: config.advanced.logLevel || 'info' }) } }, [config, reset]) const watchTheme = watch('theme') const watchAutoStart = watch('autoStart') const watchLogLevel = watch('logLevel') useEffect(() => { const next = watchTheme || 'light' if (config?.advanced?.theme !== next) { const updateTheme = async () => { await setTheme(next) } updateTheme() } }, [watchTheme, setTheme, config?.advanced?.theme]) useEffect(() => { const next = watchAutoStart || false if (config?.advanced?.autoStart !== next) { setAutoStart(next) } }, [watchAutoStart, setAutoStart, config?.advanced?.autoStart]) useEffect(() => { const next = watchLogLevel || 'info' if (config?.advanced?.logLevel !== next) { setLogLevel(next) } }, [watchLogLevel, setLogLevel, config?.advanced?.logLevel]) return (
Advanced Settings
Customize your application preferences and behavior.
Theme
Automatically launch the application when your computer starts
{ reset({ ...watch(), autoStart: checked }) }} />
Controls the verbosity of logs.
Legal Agreements Manage your acceptance of Terms of Service and Privacy Policy
{legalAcceptance.termsAccepted && (
Terms accepted on {new Date(legalAcceptance.termsAcceptedAt || '').toLocaleDateString()}
)} {legalAcceptance.privacyAccepted && (
Privacy Policy accepted on {new Date(legalAcceptance.privacyAcceptedAt || '').toLocaleDateString()}
)} {(!legalAcceptance.termsAccepted || !legalAcceptance.privacyAccepted) && ( No legal agreements accepted yet )}
{!showResetConfirm ? ( ) : (
Reset Legal Agreements? This will reset your acceptance of Terms of Service and Privacy Policy. You'll need to accept them again when the app reloads.
)}
Application Info
Version 1.0.0
Electron 37.2.4
Chrome {navigator.userAgent.match(/Chrome\/(\S+)/)?.[1] || 'Unknown'}
Node.js {process.versions.node}
) }