1
0
Fork 0

feat(campaigns): hide completed campaigns by default

Default the campaigns list "Show completed" toggle to off, so only
ongoing campaigns show until the user opts in. Renamed the toggle from
"Hide completed" to "Show completed" and flipped the empty-state link to
turn completion visibility on.
This commit is contained in:
Jason Fraley 2026-10-09 13:13:09 -04:00
parent 6f3d1a4147
commit c019e642a3

View file

@ -8,7 +8,7 @@ export interface CampaignListEntry {
readonly id: number; readonly id: number;
readonly name: string; readonly name: string;
readonly summary: string; readonly summary: string;
readonly status: "concept" | "inProgress" | "completed"; readonly status: "concept" | "inProgress" | "onHold" | "completed";
readonly campaignMode: "official" | "custom"; readonly campaignMode: "official" | "custom";
readonly startDate?: string | null; readonly startDate?: string | null;
readonly endDate?: string | null; readonly endDate?: string | null;
@ -25,11 +25,11 @@ interface CampaignsListProps {
} }
export function CampaignsList({ campaigns }: CampaignsListProps) { export function CampaignsList({ campaigns }: CampaignsListProps) {
const [hideCompleted, setHideCompleted] = useState(false); const [showCompleted, setShowCompleted] = useState(false);
const visible = hideCompleted const visible = showCompleted
? campaigns.filter((campaign) => campaign.status !== "completed") ? campaigns
: campaigns; : campaigns.filter((campaign) => campaign.status !== "completed");
const officialCampaigns = visible.filter( const officialCampaigns = visible.filter(
(campaign) => campaign.campaignMode === "official", (campaign) => campaign.campaignMode === "official",
); );
@ -41,16 +41,16 @@ export function CampaignsList({ campaigns }: CampaignsListProps) {
<> <>
<div className="flex items-center justify-end gap-2"> <div className="flex items-center justify-end gap-2">
<Switch <Switch
id="hide-completed-campaigns" id="show-completed-campaigns"
checked={hideCompleted} checked={showCompleted}
onCheckedChange={setHideCompleted} onCheckedChange={setShowCompleted}
aria-label="Hide completed campaigns" aria-label="Show completed campaigns"
/> />
<label <label
htmlFor="hide-completed-campaigns" htmlFor="show-completed-campaigns"
className="cursor-pointer select-none text-sm text-muted-foreground" className="cursor-pointer select-none text-sm text-muted-foreground"
> >
Hide completed Show completed
</label> </label>
</div> </div>
{visible.length > 0 ? ( {visible.length > 0 ? (
@ -101,7 +101,7 @@ export function CampaignsList({ campaigns }: CampaignsListProps) {
<div className="flex flex-col items-center justify-center gap-2 py-12 text-muted-foreground"> <div className="flex flex-col items-center justify-center gap-2 py-12 text-muted-foreground">
<p className="text-sm">No campaigns match the current filter.</p> <p className="text-sm">No campaigns match the current filter.</p>
<button <button
onClick={() => setHideCompleted(false)} onClick={() => setShowCompleted(true)}
className="text-sm text-primary hover:underline" className="text-sm text-primary hover:underline"
> >
Show completed Show completed