-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
661 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { db } from '@/lib/db'; | ||
import { bills } from '@/lib/db/schema/bills'; | ||
import { eq } from 'drizzle-orm'; | ||
import { notFound } from 'next/navigation'; | ||
import ReactMarkdown from 'react-markdown' | ||
|
||
export default async function BillPage({ params }: { params: { id: string } }) { | ||
const [bill] = await db | ||
.select() | ||
.from(bills) | ||
.where(eq(bills.id, params.id)); | ||
|
||
if (!bill) { | ||
notFound(); | ||
} | ||
|
||
return ( | ||
<div className="container py-8"> | ||
<h1 className="text-3xl font-bold mb-6">{bill.title}</h1> | ||
|
||
<div className="bg-white rounded-lg shadow p-6"> | ||
<div className="grid grid-cols-2 gap-4 mb-6"> | ||
{/* <div> | ||
<p className="text-sm text-gray-600">Bill Number</p> | ||
<p className="font-medium">{bill.billNumber}</p> | ||
</div> | ||
<div> | ||
<p className="text-sm text-gray-600">Session Number</p> | ||
<p className="font-medium">{bill.sessionNumber}</p> | ||
</div> */} | ||
<div> | ||
<p className="text-sm text-gray-600">Status</p> | ||
<p className={` | ||
inline-block px-2 py-1 rounded-full text-sm | ||
${bill.status === 'passed' ? 'bg-green-100 text-green-800' : | ||
bill.status === 'rejected' ? 'bg-red-100 text-red-800' : | ||
'bg-yellow-100 text-yellow-800'} | ||
`}> | ||
{bill.status.charAt(0).toUpperCase() + bill.status.slice(1)} | ||
</p> | ||
</div> | ||
{bill.passageDate && ( | ||
<div> | ||
<p className="text-sm text-gray-600">Passage Date</p> | ||
<p className="font-medium"> | ||
{new Date(bill.passageDate).toLocaleDateString()} | ||
</p> | ||
</div> | ||
)} | ||
</div> | ||
|
||
<div className="prose max-w-none"> | ||
<h2 className="text-xl font-semibold mb-4">Summary</h2> | ||
<div className="whitespace-pre-wrap"><ReactMarkdown>{bill.summary}</ReactMarkdown></div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { db } from '@/lib/db'; | ||
import { bills } from '@/lib/db/schema/bills'; | ||
import Link from 'next/link'; | ||
import { desc } from 'drizzle-orm'; | ||
|
||
export default async function BillsPage() { | ||
const allBills = await db.query.bills.findMany({ | ||
orderBy: [desc(bills.createdAt)], | ||
}); | ||
|
||
return ( | ||
<div className="container py-8"> | ||
<h1 className="mb-8 text-3xl font-bold">National Assembly Bills</h1> | ||
|
||
<div className="grid gap-4"> | ||
{allBills.map((bill) => ( | ||
<Link | ||
key={bill.id} | ||
href={`/bills/${bill.id}`} | ||
className="block p-6 rounded-lg shadow transition-shadow" | ||
> | ||
<h2 className="text-xl font-semibold mb-2">{bill.title}</h2> | ||
<div className="flex gap-4 text-sm text-gray-600"> | ||
{/* <span>Bill #{bill.billNumber}</span> */} | ||
{/* <span>Session #{bill.sessionNumber}</span> */} | ||
<span className={` | ||
px-2 py-1 rounded-full text-xs | ||
${bill.status === 'passed' ? 'bg-green-100 text-green-800' : | ||
bill.status === 'rejected' ? 'bg-red-100 text-red-800' : | ||
'bg-yellow-100 text-yellow-800'} | ||
`}> | ||
{bill.status.charAt(0).toUpperCase() + bill.status.slice(1)} | ||
</span> | ||
</div> | ||
</Link> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
import { drizzle } from "drizzle-orm/postgres-js"; | ||
import postgres from "postgres"; | ||
import * as documents from './schema/documents'; | ||
import * as embeddings from './schema/embeddings'; | ||
import * as bills from './schema/bills'; | ||
import * as chatThreads from './schema/chat-threads'; | ||
import { env } from "@/lib/env.mjs"; | ||
|
||
const client = postgres(env.DATABASE_URL); | ||
export const db = drizzle(client); | ||
export const db = drizzle(client, { | ||
schema: { | ||
...documents, | ||
...embeddings, | ||
...bills, | ||
...chatThreads, | ||
}, | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
CREATE TABLE IF NOT EXISTS "bills" ( | ||
"id" varchar(191) PRIMARY KEY NOT NULL, | ||
"title" text NOT NULL, | ||
"status" varchar(50) NOT NULL, | ||
"summary" text NOT NULL, | ||
"original_text" text NOT NULL, | ||
"passage_date" timestamp, | ||
"session_number" text, | ||
"bill_number" text, | ||
"created_at" timestamp DEFAULT now() NOT NULL, | ||
"updated_at" timestamp DEFAULT now() NOT NULL | ||
); |
Oops, something went wrong.