diff --git a/site/src/app/bills/[year]/[billNoOfYear]/page.tsx b/site/src/app/bills/[year]/[billNoOfYear]/page.tsx
index cec97cb..96ca6fb 100644
--- a/site/src/app/bills/[year]/[billNoOfYear]/page.tsx
+++ b/site/src/app/bills/[year]/[billNoOfYear]/page.tsx
@@ -38,7 +38,7 @@ async function getBill(billNo: string) {
const { error, data } = await supabase
.from("bill")
.select(
- "bill_no, name, summary, pdf_url, date_introduced, second_reading_date_type, second_reading_date, is_passed, passed_date",
+ "id, bill_no, name, summary, pdf_url, date_introduced, second_reading_date_type, second_reading_date, is_passed, passed_date",
)
.eq("bill_no", billNo)
.single();
@@ -49,7 +49,7 @@ async function getBill(billNo: string) {
export default async function FullBill({
params,
}: {
- params: { year: string; billNoOfYear: string };
+ params: { id: number; year: string; billNoOfYear: string };
}) {
const bill = await getBill(
buildBillNoFromBillPath(params.year, params.billNoOfYear),
diff --git a/site/src/app/bills/page.tsx b/site/src/app/bills/page.tsx
index c9e87fc..0762346 100644
--- a/site/src/app/bills/page.tsx
+++ b/site/src/app/bills/page.tsx
@@ -37,7 +37,7 @@ async function getRecentBills(page: number) {
const { error, data } = await supabase
.from("bill")
.select(
- "bill_no, name, second_reading_date_type, second_reading_date, is_passed, passed_date, summary, pdf_url",
+ "id, bill_no, name, second_reading_date_type, second_reading_date, is_passed, passed_date, summary, pdf_url",
)
.order("date_introduced", { ascending: false })
.order("bill_no", { ascending: false })
diff --git a/site/src/app/components/BillDebateButton.tsx b/site/src/app/components/BillDebateButton.tsx
new file mode 100644
index 0000000..c15145c
--- /dev/null
+++ b/site/src/app/components/BillDebateButton.tsx
@@ -0,0 +1,38 @@
+import StandardButton from "@/app/components/StandardButton";
+import { createClient } from "@/utils/supabase/server";
+
+async function getSecondDebate(billId: number) {
+ const supabase = createClient();
+ const { data, error } = await supabase
+ .from("debate_bill_match_view")
+ .select("debate_id")
+ .eq("bill_id", billId)
+ .eq("is_second_reading", true)
+ // If there's multiple second readings detected, just ignore it for now...
+ .limit(1)
+ .maybeSingle();
+ if (error) throw error;
+ return data ? data.debate_id : null;
+}
+
+async function getSecondDebateUrl(billId: number) {
+ const debateId = await getSecondDebate(billId);
+ return debateId ? `/debates/${debateId}` : null;
+}
+
+export default async function BillDebateButton({
+ bill,
+}: {
+ bill: { id: number };
+}) {
+ const secondDebateUrl = await getSecondDebateUrl(bill.id);
+ return secondDebateUrl ? (
+
+ Debate
+
+ ) : (
+
+ Debate
+
+ );
+}
diff --git a/site/src/app/components/BillSummary.tsx b/site/src/app/components/BillSummary.tsx
index 9a374c8..051656e 100644
--- a/site/src/app/components/BillSummary.tsx
+++ b/site/src/app/components/BillSummary.tsx
@@ -7,11 +7,12 @@ import SummaryAiDisclaimer from "@/app/components/SummaryAiDisclaimer";
import BillOriginalPdfButton from "@/app/components/BillOriginalPdfButton";
import SummaryNotAvailableApology from "@/app/components/SummaryNotAvailableApology";
import React from "react";
+import BillDebateButton from "@/app/components/BillDebateButton";
export default function BillSummary({
bill,
}: {
- bill: { summary: string | null; pdf_url: string };
+ bill: { id: number; summary: string | null; pdf_url: string };
}) {
return (
@@ -23,13 +24,17 @@ export default function BillSummary({
{bill.summary}
-
+
+
+
+
) : (
+
)}
diff --git a/site/src/app/components/ShortBill.tsx b/site/src/app/components/ShortBill.tsx
index bc22765..3ef87fb 100644
--- a/site/src/app/components/ShortBill.tsx
+++ b/site/src/app/components/ShortBill.tsx
@@ -8,6 +8,7 @@ import SummaryNotAvailableApology from "@/app/components/SummaryNotAvailableApol
import StandardButton from "@/app/components/StandardButton";
import BillOriginalPdfButton from "@/app/components/BillOriginalPdfButton";
import StandardMarkdown from "./StandardMarkdown";
+import BillDebateButton from "@/app/components/BillDebateButton";
function flipBillNo(billNo: string) {
const [billOfYear, year] = billNo.split("/");
@@ -17,6 +18,7 @@ export default async function ShortBill({
bill,
}: {
bill: {
+ id: number;
bill_no: string;
name: string;
second_reading_date_type: string;
@@ -69,6 +71,7 @@ export default async function ShortBill({
Overview
+
);
diff --git a/site/src/app/components/StandardButton.tsx b/site/src/app/components/StandardButton.tsx
index be9b8b3..f87f7f0 100644
--- a/site/src/app/components/StandardButton.tsx
+++ b/site/src/app/components/StandardButton.tsx
@@ -6,13 +6,21 @@ export default function StandardButton({
colour,
href,
children,
+ disabled = false,
}: {
colour: string;
href: string;
children: React.ReactNode;
+ disabled?: boolean;
}) {
return (
-