Phase 3 completion — Personal Workflow feature set is now complete.
Collections / Watchlists:
- New tables: collections (UUID share_token, slug, public/private) and
collection_bills (unique bill-per-collection constraint)
- Full CRUD API at /api/collections with bill add/remove endpoints
- Public share endpoint /api/collections/share/{token} (no auth)
- /collections list page with inline create form and delete
- /collections/[id] detail page: inline rename, public toggle,
copy-share-link, bill search/add/remove
- CollectionPicker bookmark-icon popover on bill detail pages
- Collections nav link in sidebar (auth-required)
Shareable Brief Links:
- share_token UUID column on bill_briefs (backfilled on migration)
- Unified public share router at /api/share (brief + collection)
- /share/brief/[token] — minimal layout, full AIBriefCard, CTAs
- /share/collection/[token] — minimal layout, bill list, CTA
- Share2 button in BriefPanel header row, "Link copied!" flash
AuthGuard: /collections → AUTH_REQUIRED; /share prefix → NO_SHELL_PATHS
Authored-By: Jack Levy
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
95 lines
3.4 KiB
TypeScript
95 lines
3.4 KiB
TypeScript
"use client";
|
|
|
|
import { use } from "react";
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import Link from "next/link";
|
|
import { Landmark } from "lucide-react";
|
|
import { shareAPI } from "@/lib/api";
|
|
import type { Bill } from "@/lib/types";
|
|
import { billLabel, formatDate } from "@/lib/utils";
|
|
|
|
export default function SharedCollectionPage({ params }: { params: Promise<{ token: string }> }) {
|
|
const { token } = use(params);
|
|
|
|
const { data: collection, isLoading, isError } = useQuery({
|
|
queryKey: ["share-collection", token],
|
|
queryFn: () => shareAPI.getCollection(token),
|
|
retry: false,
|
|
});
|
|
|
|
return (
|
|
<div className="min-h-screen bg-background">
|
|
{/* Minimal header */}
|
|
<header className="border-b border-border bg-card px-6 py-3 flex items-center gap-2">
|
|
<Landmark className="w-5 h-5 text-primary" />
|
|
<Link href="/" className="font-semibold text-sm hover:opacity-70 transition-opacity">
|
|
PocketVeto
|
|
</Link>
|
|
</header>
|
|
|
|
<div className="max-w-2xl mx-auto px-4 py-8 space-y-6">
|
|
{isLoading && (
|
|
<div className="text-center py-20 text-muted-foreground text-sm">Loading…</div>
|
|
)}
|
|
|
|
{isError && (
|
|
<div className="text-center py-20">
|
|
<p className="text-muted-foreground">Collection not found or link is invalid.</p>
|
|
</div>
|
|
)}
|
|
|
|
{collection && (
|
|
<>
|
|
{/* Header */}
|
|
<div>
|
|
<h1 className="text-xl font-bold">{collection.name}</h1>
|
|
<p className="text-sm text-muted-foreground mt-1">
|
|
{collection.bill_count} {collection.bill_count === 1 ? "bill" : "bills"}
|
|
</p>
|
|
</div>
|
|
|
|
{/* Bill list */}
|
|
{collection.bills.length === 0 ? (
|
|
<p className="text-sm text-muted-foreground">No bills in this collection.</p>
|
|
) : (
|
|
<div className="space-y-2">
|
|
{collection.bills.map((bill: Bill) => (
|
|
<Link
|
|
key={bill.bill_id}
|
|
href={`/bills/${bill.bill_id}`}
|
|
className="block bg-card border border-border rounded-lg px-4 py-3 hover:bg-accent/50 transition-colors"
|
|
>
|
|
<div className="flex items-center gap-2">
|
|
<span className="font-mono text-xs text-muted-foreground shrink-0">
|
|
{billLabel(bill.bill_type, bill.bill_number)}
|
|
</span>
|
|
<span className="text-sm font-medium truncate">
|
|
{bill.short_title || bill.title || "Untitled"}
|
|
</span>
|
|
</div>
|
|
{bill.latest_action_date && (
|
|
<p className="text-xs text-muted-foreground mt-0.5">
|
|
Latest action: {formatDate(bill.latest_action_date)}
|
|
</p>
|
|
)}
|
|
</Link>
|
|
))}
|
|
</div>
|
|
)}
|
|
|
|
{/* CTA */}
|
|
<div className="pt-2">
|
|
<Link
|
|
href="/register"
|
|
className="inline-flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 transition-colors"
|
|
>
|
|
Follow these bills on PocketVeto →
|
|
</Link>
|
|
</div>
|
|
</>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|