"use client"; import { useState } from "react"; import type { ToveliEstimate } from "@/lib/estimate"; import { MapView } from "@/components/map-view"; import { EstimateBreakdown } from "@/components/estimate-breakdown"; import { fmtPrice } from "@/lib/format"; import { Notice, Stat } from "@/components/ui"; export function ManualEstimate() { const [pt, setPt] = useState<[number, number]>([46.8139, -71.208]); const [cat, setCat] = useState("maison"); const [area, setArea] = useState(""); const [year, setYear] = useState(""); const [lot, setLot] = useState(""); const [res, setRes] = useState(null); const [err, setErr] = useState(null); const [busy, setBusy] = useState(false); const run = async () => { setBusy(true); setErr(null); setRes(null); const r = await fetch("/api/estimate", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ lat: pt[0], lng: pt[1], category: cat, floorAreaSqft: area ? Number(area) : null, yearBuilt: year ? Number(year) : null, landAreaSqft: lot ? Number(lot) : null, label: "Point choisi sur la carte" }) }); const d = await r.json(); setBusy(false); if (!r.ok) setErr(d.error ?? "Erreur"); else setRes(d); }; return (
setPt([(b[1] + b[3]) / 2, (b[0] + b[2]) / 2])} />📍

Déplacez la carte pour placer le centre sur la propriété. Position : {pt[0].toFixed(5)}, {pt[1].toFixed(5)}

{err && {err}}
{res ? (
{res.method.disclaimer}
) :
Le résultat s'affichera ici, avec la décomposition et les limites de la méthode.
}
); }