Add credit score pull UI
This commit is contained in:
parent
28dee336c9
commit
10d386bc7d
6
app/api/credit-score/pull/route.ts
Normal file
6
app/api/credit-score/pull/route.ts
Normal 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");
|
||||||
|
}
|
||||||
@ -108,6 +108,26 @@ export default function CreditScorePage() {
|
|||||||
await load();
|
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 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";
|
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" />
|
<input value={form.negativeFactors} onChange={(event) => setForm((prev) => ({ ...prev, negativeFactors: event.target.value }))} className={inputCls} placeholder="hard inquiry, high balance" />
|
||||||
</div>
|
</div>
|
||||||
</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">
|
<div className="mt-4 flex flex-wrap gap-3">
|
||||||
Add Score
|
<button onClick={addEntry} className="rounded-lg bg-primary px-4 py-2.5 text-sm font-bold text-primary-foreground hover:bg-primary/90">
|
||||||
</button>
|
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>}
|
{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>
|
</section>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user