This commit is contained in:
Tom Chien (IQ-AS)
2026-09-08 17:46:28 +08:00
commit e25c995560
55 changed files with 6928 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
import { NextRequest, NextResponse } from "next/server";
import { getDashboardRows } from "@/lib/calc";
// GET /api/dashboard?region&costItem&year -> aggregated table rows.
export async function GET(req: NextRequest) {
const { searchParams } = new URL(req.url);
const region = searchParams.get("region") ?? "All";
const costItem = searchParams.get("costItem") ?? "All";
const yearParam = searchParams.get("year");
const year = yearParam ? parseInt(yearParam, 10) : NaN;
if (Number.isNaN(year)) {
return NextResponse.json({ error: "year is required" }, { status: 400 });
}
const rows = await getDashboardRows({ region, costItem, year });
return NextResponse.json({ rows });
}