"use client"; import { useEffect, useState } from "react"; export default function DashboardPage() { const [salesAccountCode, setSalesAccountCode] = useState(""); const [stripeClearingAccountCode, setStripeClearingAccountCode] = useState(""); const [stripeAccountId, setStripeAccountId] = useState(""); const [xeroTenantId, setXeroTenantId] = useState(""); const [loading, setLoading] = useState(true); const [saved, setSaved] = useState(false); const [error, setError] = useState(null); useEffect(() => { Promise.all([ fetch("/api/dashboard/xero-settings").then((res) => res.json()), fetch("/api/dashboard/connections").then((res) => res.json()), ]).then(([settings, connections]) => { setSalesAccountCode(settings.salesAccountCode ?? ""); setStripeClearingAccountCode(settings.stripeClearingAccountCode ?? ""); setStripeAccountId(connections.stripeAccountId ?? ""); setXeroTenantId(connections.xeroTenantId ?? ""); setLoading(false); }); }, []); async function save() { setSaved(false); setError(null); try { await fetch("/api/dashboard/xero-settings", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ salesAccountCode, stripeClearingAccountCode, }), }); setSaved(true); setTimeout(() => setSaved(false), 3000); } catch (err) { setError("Failed to save settings. Please try again."); } } if (loading) { return (

Loading your settings…

); } return (
{/* Navigation */}
{/* Header */}

Dashboard

Configure your Xero account codes and manage your automation settings.

{/* Main Content */}
{/* Connected Accounts */}

Connected Accounts

Stripe Account

{stripeAccountId || Not connected}

Xero Organisation

{xeroTenantId || Not connected}

{/* Account Configuration */}

Xero Account Codes

{/* Sales Account Code */}
setSalesAccountCode(e.target.value)} />

The Xero account code used for sales invoice line items. This is typically your revenue/sales account.

{/* Stripe Clearing Account Code */}
setStripeClearingAccountCode(e.target.value)} />

The Xero account code that receives Stripe payments. This is typically a bank or clearing account.

{/* Save Button and Feedback */}
{saved && (
Settings saved successfully
)} {error && (
{error}
)}
{/* Sidebar */}
{/* Info Card */}

ℹ️ How it works

When a Stripe payment is received, we automatically create an invoice in Xero using:

  • Sales Account: Invoice line items
  • Clearing Account: Payment received
{/* Help Card */}

🚀 Getting started

  1. 1. Set the account codes above
  2. 2. Make a test payment in Stripe
  3. 3. Check Xero for the invoice
  4. 4. You're ready to go!
{/* Status Card */}

✓ Status

Connected & Active

Your automation is ready. New Stripe payments will create invoices in Xero automatically.

); }