Initial commit

This commit is contained in:
Jack Levy
2026-02-28 21:08:19 -05:00
commit e418dd9ae0
85 changed files with 5261 additions and 0 deletions

View File

@@ -0,0 +1,105 @@
"use client";
import { AlertTriangle, CheckCircle, Clock, Cpu, Tag } from "lucide-react";
import { BriefSchema } from "@/lib/types";
import { formatDate } from "@/lib/utils";
interface AIBriefCardProps {
brief?: BriefSchema | null;
}
export function AIBriefCard({ brief }: AIBriefCardProps) {
if (!brief) {
return (
<div className="bg-card border border-border rounded-lg p-6">
<div className="flex items-center gap-2 mb-3">
<Cpu className="w-4 h-4 text-muted-foreground" />
<h2 className="font-semibold">AI Analysis</h2>
</div>
<p className="text-sm text-muted-foreground italic">
Analysis not yet generated. It will appear once the bill text has been processed.
</p>
</div>
);
}
return (
<div className="bg-card border border-border rounded-lg p-6 space-y-5">
<div className="flex items-center justify-between">
<div className="flex items-center gap-2">
<Cpu className="w-4 h-4 text-primary" />
<h2 className="font-semibold">AI Analysis</h2>
</div>
<span className="text-xs text-muted-foreground">
{brief.llm_provider}/{brief.llm_model} · {formatDate(brief.created_at)}
</span>
</div>
{brief.summary && (
<div>
<h3 className="text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-2">Summary</h3>
<p className="text-sm leading-relaxed whitespace-pre-line">{brief.summary}</p>
</div>
)}
{brief.key_points && brief.key_points.length > 0 && (
<div>
<h3 className="text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-2">Key Points</h3>
<ul className="space-y-1.5">
{brief.key_points.map((point, i) => (
<li key={i} className="flex items-start gap-2 text-sm">
<CheckCircle className="w-3.5 h-3.5 mt-0.5 text-green-500 shrink-0" />
<span>{point}</span>
</li>
))}
</ul>
</div>
)}
{brief.risks && brief.risks.length > 0 && (
<div>
<h3 className="text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-2">Risks & Concerns</h3>
<ul className="space-y-1.5">
{brief.risks.map((risk, i) => (
<li key={i} className="flex items-start gap-2 text-sm">
<AlertTriangle className="w-3.5 h-3.5 mt-0.5 text-yellow-500 shrink-0" />
<span>{risk}</span>
</li>
))}
</ul>
</div>
)}
{brief.deadlines && brief.deadlines.length > 0 && (
<div>
<h3 className="text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-2">Deadlines</h3>
<ul className="space-y-1.5">
{brief.deadlines.map((d, i) => (
<li key={i} className="flex items-start gap-2 text-sm">
<Clock className="w-3.5 h-3.5 mt-0.5 text-blue-500 shrink-0" />
<span>
{d.date ? <strong>{formatDate(d.date)}: </strong> : ""}
{d.description}
</span>
</li>
))}
</ul>
</div>
)}
{brief.topic_tags && brief.topic_tags.length > 0 && (
<div className="flex items-center gap-2 pt-1 border-t border-border flex-wrap">
<Tag className="w-3.5 h-3.5 text-muted-foreground shrink-0" />
{brief.topic_tags.map((tag) => (
<span
key={tag}
className="text-xs px-2 py-1 bg-accent text-accent-foreground rounded-full"
>
{tag}
</span>
))}
</div>
)}
</div>
);
}

View File

@@ -0,0 +1,47 @@
import { Clock } from "lucide-react";
import { BillAction } from "@/lib/types";
import { formatDate } from "@/lib/utils";
interface ActionTimelineProps {
actions: BillAction[];
}
export function ActionTimeline({ actions }: ActionTimelineProps) {
if (!actions || actions.length === 0) {
return (
<div className="bg-card border border-border rounded-lg p-6">
<h2 className="font-semibold mb-3 flex items-center gap-2">
<Clock className="w-4 h-4" />
Action History
</h2>
<p className="text-sm text-muted-foreground italic">No actions recorded yet.</p>
</div>
);
}
return (
<div className="bg-card border border-border rounded-lg p-6">
<h2 className="font-semibold mb-4 flex items-center gap-2">
<Clock className="w-4 h-4" />
Action History
<span className="text-xs text-muted-foreground font-normal">({actions.length})</span>
</h2>
<div className="relative">
<div className="absolute left-2 top-0 bottom-0 w-px bg-border" />
<ul className="space-y-4 pl-7">
{actions.map((action, i) => (
<li key={action.id} className="relative">
<div className="absolute -left-5 top-1.5 w-2 h-2 rounded-full bg-primary/60 border-2 border-background" />
<div className="text-xs text-muted-foreground mb-0.5">
{formatDate(action.action_date)}
{action.chamber && ` · ${action.chamber}`}
</div>
<p className="text-sm leading-snug">{action.action_text}</p>
</li>
))}
</ul>
</div>
</div>
);
}

View File

@@ -0,0 +1,46 @@
import { ExternalLink, Newspaper } from "lucide-react";
import { NewsArticle } from "@/lib/types";
import { formatDate } from "@/lib/utils";
interface NewsPanelProps {
articles?: NewsArticle[];
}
export function NewsPanel({ articles }: NewsPanelProps) {
return (
<div className="bg-card border border-border rounded-lg p-4">
<h3 className="font-semibold text-sm flex items-center gap-2 mb-3">
<Newspaper className="w-4 h-4" />
Related News
{articles && articles.length > 0 && (
<span className="text-xs text-muted-foreground font-normal">({articles.length})</span>
)}
</h3>
{!articles || articles.length === 0 ? (
<p className="text-xs text-muted-foreground italic">No news articles found yet.</p>
) : (
<ul className="space-y-3">
{articles.slice(0, 8).map((article) => (
<li key={article.id} className="group">
<a
href={article.url}
target="_blank"
rel="noopener noreferrer"
className="block hover:text-primary transition-colors"
>
<p className="text-xs font-medium line-clamp-2 leading-snug group-hover:underline">
{article.headline}
<ExternalLink className="w-3 h-3 inline ml-1 opacity-50" />
</p>
<p className="text-xs text-muted-foreground mt-0.5">
{article.source} · {formatDate(article.published_at)}
</p>
</a>
</li>
))}
</ul>
)}
</div>
);
}

View File

@@ -0,0 +1,86 @@
"use client";
import { TrendingUp } from "lucide-react";
import {
LineChart,
Line,
XAxis,
YAxis,
Tooltip,
ResponsiveContainer,
CartesianGrid,
} from "recharts";
import { TrendScore } from "@/lib/types";
import { formatDate } from "@/lib/utils";
interface TrendChartProps {
data?: TrendScore[];
}
export function TrendChart({ data }: TrendChartProps) {
const chartData = data?.map((d) => ({
date: new Date(d.score_date).toLocaleDateString("en-US", { month: "short", day: "numeric" }),
score: Math.round(d.composite_score),
news: d.newsapi_count,
gnews: d.gnews_count,
})) ?? [];
const latest = data?.[data.length - 1]?.composite_score;
return (
<div className="bg-card border border-border rounded-lg p-4">
<div className="flex items-center justify-between mb-4">
<h3 className="font-semibold text-sm flex items-center gap-2">
<TrendingUp className="w-4 h-4" />
Public Interest
</h3>
{latest !== undefined && (
<span className="text-2xl font-bold tabular-nums">{Math.round(latest)}</span>
)}
</div>
{chartData.length === 0 ? (
<p className="text-xs text-muted-foreground italic text-center py-8">
Trend data not yet available.
</p>
) : (
<ResponsiveContainer width="100%" height={180}>
<LineChart data={chartData} margin={{ top: 4, right: 4, left: -20, bottom: 0 }}>
<CartesianGrid strokeDasharray="3 3" stroke="hsl(var(--border))" />
<XAxis
dataKey="date"
tick={{ fontSize: 10, fill: "hsl(var(--muted-foreground))" }}
tickLine={false}
/>
<YAxis
domain={[0, 100]}
tick={{ fontSize: 10, fill: "hsl(var(--muted-foreground))" }}
tickLine={false}
/>
<Tooltip
contentStyle={{
backgroundColor: "hsl(var(--card))",
border: "1px solid hsl(var(--border))",
borderRadius: "6px",
fontSize: "12px",
}}
/>
<Line
type="monotone"
dataKey="score"
stroke="hsl(var(--primary))"
strokeWidth={2}
dot={false}
name="Zeitgeist Score"
/>
</LineChart>
</ResponsiveContainer>
)}
<div className="mt-3 flex gap-4 text-xs text-muted-foreground">
<span>Score: 0100 composite</span>
<span>NewsAPI + Google News + Trends</span>
</div>
</div>
);
}