import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query' import toast from 'react-hot-toast' import client from '../api/client' import useAuthStore from '../store/authStore' function formatUptime(seconds) { const h = Math.floor(seconds / 3600) const m = Math.floor((seconds % 3600) / 60) const s = seconds % 60 return `${h}ω ${m}λ ${s}δ` } export default function SettingsPage() { const user = useAuthStore(s => s.user) const qc = useQueryClient() const { data: status, isLoading } = useQuery({ queryKey: ['system-status'], queryFn: () => client.get('/api/system/status').then(r => r.data), refetchInterval: 30_000, }) const testPrint = useMutation({ mutationFn: (id) => client.post(`/api/system/printers/test?printer_id=${id}`), onSuccess: (res) => { const d = res.data d.success ? toast.success('Test print στάλθηκε!') : toast.error(`Σφάλμα: ${d.error}`) }, onError: () => toast.error('Σφάλμα επικοινωνίας'), }) if (isLoading) return
Φόρτωση…
return (

Ρυθμίσεις

{/* System info */}

Σύστημα

Uptime
{formatUptime(status?.uptime_seconds ?? 0)}
Άδεια χρήσης
{status?.licensed ? 'Ενεργή' : 'Ανενεργή'}
Κατάσταση
{status?.locked ? 'Κλειδωμένο' : 'Λειτουργικό'}
{status?.expires_at && ( <>
Λήξη άδειας
{new Date(status.expires_at).toLocaleDateString('el-GR')}
)}
{/* Printers */}

Εκτυπωτές

{(!status?.printers || status.printers.length === 0) && (

Δεν βρέθηκαν εκτυπωτές.

)} {status?.printers?.map(p => (

{p.name}

{p.reachable ? 'Προσβάσιμος' : 'Μη προσβάσιμος'}
))}
{/* Sysadmin-only section */} {user?.role === 'sysadmin' && (

Sysadmin

Έλεγχος κλειδώματος συστήματος.

)}
) }