import { useEffect, useState } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { Trash2 } from 'lucide-react'; import { sessions } from '../api'; import type { Session } from '../api'; import { Badge, Breadcrumbs, Button, Card, DescriptionList, Notification, Timestamp } from '../ui'; import styles from './Page.module.css'; export function SessionDetailPage() { const { t } = useTranslation(); const { id } = useParams<{ id: string }>(); const navigate = useNavigate(); const [session, setSession] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { if (!id) return; sessions .get(Number(id)) .then(setSession) .catch((err: Error) => setError(err.message)) .finally(() => setLoading(false)); }, [id]); const handleDelete = async () => { if (!session) return; await sessions.remove(session.id); navigate('/sessions'); }; return (
navigate('/sessions') }, { label: session?.sessionName ?? `#${id}` }, ]} /> {session && ( )}
{error && ( {error.startsWith('404') ? t('errors.not_found_session', { id }) : error} )} {loading &&

{t('sessions.loading')}

} {session && ( {session.status} ), }, { term: t('sessions.field_token'), detail: {session.token}, }, { term: t('sessions.field_lastUsed'), detail: session.lastUsedAt ? : '—', }, { term: t('sessions.field_created'), detail: , }, { term: t('sessions.field_updated'), detail: , }, ]} /> )}
); }