diff --git a/app/api/credit-score/pull/route.ts b/app/api/credit-score/pull/route.ts new file mode 100644 index 0000000..932ac3a --- /dev/null +++ b/app/api/credit-score/pull/route.ts @@ -0,0 +1,6 @@ +import { NextRequest } from "next/server"; +import { proxyRequest } from "@/lib/backend"; + +export async function POST(req: NextRequest) { + return proxyRequest(req, "credit-score/pull"); +} diff --git a/app/credit-score/page.tsx b/app/credit-score/page.tsx index 55f60ff..87c7128 100644 --- a/app/credit-score/page.tsx +++ b/app/credit-score/page.tsx @@ -108,6 +108,26 @@ export default function CreditScorePage() { await load(); }; + const pullScore = async () => { + const bureau = ["experian", "equifax", "transunion"].includes(form.bureau) ? form.bureau : "experian"; + const res = await apiFetch("/api/credit-score/pull", { + method: "POST", + body: JSON.stringify({ + bureau, + consent: { + acceptedAt: new Date().toISOString(), + purpose: "credit_score_monitoring", + }, + }), + }); + if (res.error) { + setStatus(res.error.message ?? "Unable to pull credit score."); + return; + } + setStatus(`${bureau} score pulled: ${res.data.score}.`); + await load(); + }; + const inputCls = "mt-2 w-full rounded-xl border border-border bg-background/50 px-4 py-2 text-sm text-foreground focus:border-primary focus:ring-primary focus:outline-none"; const labelCls = "text-xs text-muted-foreground font-semibold uppercase tracking-wider"; @@ -175,9 +195,14 @@ export default function CreditScorePage() { setForm((prev) => ({ ...prev, negativeFactors: event.target.value }))} className={inputCls} placeholder="hard inquiry, high balance" /> - +
+ + +
{status &&

{status}

}