// Auteur : Simon-Pierre Boucher — contact@spboucher.ai import { NextRequest, NextResponse } from "next/server"; import { estimateByUnitId, estimateManual } from "@/lib/estimator"; export function GET(req: NextRequest) { const id = req.nextUrl.searchParams.get("id"); if (!id) return NextResponse.json({ error: "id requis" }, { status: 400 }); const r = estimateByUnitId(id); if (!r) return NextResponse.json({ error: "unité introuvable" }, { status: 404 }); return NextResponse.json(r); } export async function POST(req: NextRequest) { const body = (await req.json()) as { municipality?: string; typeProp?: string; floorArea?: number; yearBuilt?: number; landArea?: number; }; if (!body.municipality || !body.typeProp) { return NextResponse.json( { error: "municipality et typeProp requis" }, { status: 400 } ); } const r = estimateManual({ municipality: body.municipality, typeProp: body.typeProp, floorArea: body.floorArea, yearBuilt: body.yearBuilt, landArea: body.landArea, }); if (!r) return NextResponse.json( { error: "municipalité introuvable ou marché insuffisant" }, { status: 404 } ); return NextResponse.json(r); }