import { Link, useParams } from 'react-router-dom'; import { useAuth } from '../auth/AuthContext'; import { useCampaign, useCampaignCharacters } from '../api/queries'; import { useCampaignSocket } from '../hooks/useCampaignSocket'; import { Spinner, ErrorBanner } from '../components/Spinner'; import { usePagination, Pagination } from '../components/Paginated'; import { InfoTip } from '../components/InfoTip'; import { CLASS_LABELS, SPECIES_LABELS, formatPurse } from '../lib/format'; import { HpBar } from '../components/HpBar'; import { LifeBadge } from '../components/DeathSaves'; import { speciesIcon } from '../lib/speciesIcons'; // A DM's one-screen view of every character's stats at a glance; a player // sees the same table, scoped to their own character(s) plus a read-only // view of the rest of the party — same visibility split as the character // list on the campaign home page. export function PartyOverviewPage() { const { campaignId = '' } = useParams(); const { user } = useAuth(); useCampaignSocket(campaignId); const { data, isLoading: campaignLoading, error: campaignError } = useCampaign(campaignId); const { data: characters, isLoading: charsLoading, error: charsError } = useCampaignCharacters(campaignId); const { pageItems, page, pageCount, prevPage, nextPage } = usePagination(characters, 12); if (campaignLoading || charsLoading) return ; if (campaignError || charsError || !data) return ; const isDM = data.campaign.role === 'DM'; return (

Party Overview

{isDM ? 'Every character in this campaign, at a glance.' : 'Your party.'}

← Back to Campaign
{characters?.length === 0 &&
No characters yet.
} {characters && characters.length > 0 && (
{pageItems.map((c) => { const inProgress = c.buildStage !== 'COMPLETE'; const isMine = c.userId === user?.id; return ( ); })}
Character Species Class Level HP AC Coins Location
{c.name} {isMine && you} {c.species ? SPECIES_LABELS[c.species] : '—'} {c.characterClass ? CLASS_LABELS[c.characterClass] : inProgress ? 'Building…' : '—'} {c.level} {c.maxHp != null ? (
{c.currentHp}/{c.maxHp} {c.tempHp > 0 && ` +${c.tempHp}`} {' '}
) : ( '—' )}
{c.armorClass ?? '—'} {c.gold == null ? '—' : formatPurse(c)} {c.currentLocationName ? `📍 ${c.currentLocationName}` : '—'}
)}
); }