Add credit score pull UI

This commit is contained in:
MOHAN 2026-07-17 23:36:31 +05:30
parent 28dee336c9
commit 10d386bc7d
2 changed files with 34 additions and 3 deletions

View File

@ -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");
}

View File

@ -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<CreditScoreEntry>("/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() {
<input value={form.negativeFactors} onChange={(event) => setForm((prev) => ({ ...prev, negativeFactors: event.target.value }))} className={inputCls} placeholder="hard inquiry, high balance" />
</div>
</div>
<button onClick={addEntry} className="mt-4 rounded-lg bg-primary px-4 py-2.5 text-sm font-bold text-primary-foreground hover:bg-primary/90">
Add Score
</button>
<div className="mt-4 flex flex-wrap gap-3">
<button onClick={addEntry} className="rounded-lg bg-primary px-4 py-2.5 text-sm font-bold text-primary-foreground hover:bg-primary/90">
Add Score
</button>
<button onClick={pullScore} className="rounded-lg border border-primary/30 px-4 py-2.5 text-sm font-bold text-primary hover:bg-primary/10">
Pull From Provider
</button>
</div>
{status && <p className="mt-4 rounded-lg border border-border bg-background/60 px-4 py-3 text-sm text-muted-foreground">{status}</p>}
</section>