"use client"; import { useEffect, useState } from "react"; export default function DashboardPage() { const [salesAccountCode, setSalesAccountCode] = useState(""); const [stripeClearingAccountCode, setStripeClearingAccountCode] = useState(""); const [loading, setLoading] = useState(true); const [saved, setSaved] = useState(false); useEffect(() => { fetch("/api/dashboard/xero-settings") .then((res) => res.json()) .then((data) => { setSalesAccountCode(data.salesAccountCode ?? ""); setStripeClearingAccountCode(data.stripeClearingAccountCode ?? ""); setLoading(false); }); }, []); async function save() { setSaved(false); await fetch("/api/dashboard/xero-settings", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ salesAccountCode, stripeClearingAccountCode, }), }); setSaved(true); } if (loading) return
Loading…
; return (Used on invoice line items
Receives Stripe payments
Saved
)}