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
Δεν βρέθηκαν εκτυπωτές.
)} {status?.printers?.map(p => ({p.name}
Έλεγχος κλειδώματος συστήματος.