Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontend/app/api/populace/compare/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export async function GET(request: Request) {
let a = url.searchParams.get("a");
let b = url.searchParams.get("b");
const country = parseCountry(url.searchParams.get("country"));
const scope = url.searchParams.get("scope") === "healthcare" ? "healthcare" : null;
try {
// Default b to the latest release; a is required for a real diff.
if (!b) b = (await loadPointerReleaseId(revalidate, country)).release_id;
Expand All @@ -25,7 +26,7 @@ export async function GET(request: Request) {
{ status: 400 },
);
}
const comparison = await loadComparison(a, b, revalidate, country);
const comparison = await loadComparison(a, b, revalidate, country, scope);
return NextResponse.json(scrub(comparison));
} catch (error) {
return NextResponse.json(
Expand Down
19 changes: 17 additions & 2 deletions frontend/app/populace/compare/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
import { AppShell } from "@/components/layout/app-shell";
import { PopulaceCompareView } from "@/components/populace/populace-compare-view";

export default function PopulaceComparePage() {
interface PopulaceComparePageProps {
searchParams?: Promise<Record<string, string | string[] | undefined>>;
}

export default async function PopulaceComparePage({
searchParams,
}: PopulaceComparePageProps) {
const params = await searchParams;
const rawScope = Array.isArray(params?.scope) ? params.scope[0] : params?.scope;
const rawA = Array.isArray(params?.a) ? params.a[0] : params?.a;
const rawB = Array.isArray(params?.b) ? params.b[0] : params?.b;

return (
<AppShell>
<PopulaceCompareView />
<PopulaceCompareView
initialA={rawA ?? ""}
initialB={rawB ?? ""}
initialScope={rawScope === "healthcare" ? "healthcare" : "all"}
/>
</AppShell>
);
}
Loading