import { useQuery } from '@tanstack/react-query' import { Link, Outlet, useLocation, useNavigate, useParams } from 'react-router' import { Badge } from '@/components/ui/badge' import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs' import { api } from '@/lib/api' const tabs = ['settings', 'members', 'held', 'archive', 'sent'] as const export function ListPage() { const params = useParams() const id = /^\d+$/.test(params.id ?? '') ? Number(params.id) : null const navigate = useNavigate() const { pathname } = useLocation() const list = useQuery({ queryKey: ['list', id], queryFn: () => api.lists.get(id!), enabled: id !== null }) const held = useQuery({ queryKey: ['held', id], queryFn: () => api.held.list(id!), enabled: id !== null }) if (id === null || (list.isError && list.error.message === 'not found')) { return } if (list.isPending) return

Loading…

if (list.isError) return

{list.error.message}

const current = tabs.find((t) => pathname.endsWith(`/${t}`)) ?? 'settings' const heldCount = held.data?.length ?? 0 return (
All lists

{list.data.address}

{list.data.title}

navigate(t === 'settings' ? `/lists/${id}` : `/lists/${id}/${t}`)}> Settings Members Held {heldCount > 0 && {heldCount}} Archive Sent
) } function NotFound() { return (

List not found

Back to lists
) }