feat: Add Ledger Accounts table to DashboardPage
- Add ledgerAccounts state with LedgerAccount type - Fetch accounts from ledgerApi.accounts() - Add table with Code, Name, Type, Balance columns - Color-code positive/negative balances - Build passes successfully
This commit is contained in:
+79
-79
File diff suppressed because one or more lines are too long
Vendored
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
||||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet" />
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet" />
|
||||||
<script type="module" crossorigin src="/assets/index-BtifZyOD.js"></script>
|
<script type="module" crossorigin src="/assets/index-DkrQA2Vo.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-oHhMI01Z.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-oHhMI01Z.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
} from '@/components/ui/Table'
|
} from '@/components/ui/Table'
|
||||||
import { Badge } from '@/components/ui/Badge'
|
import { Badge } from '@/components/ui/Badge'
|
||||||
import { formatCurrency, formatDate } from '@/lib/utils'
|
import { formatCurrency, formatDate } from '@/lib/utils'
|
||||||
import { financeApi, salesApi, crmApi, ledgerApi } from '@/lib/api'
|
import { financeApi, salesApi, crmApi, ledgerApi, type LedgerAccount } from '@/lib/api'
|
||||||
import {
|
import {
|
||||||
DollarSign,
|
DollarSign,
|
||||||
Users,
|
Users,
|
||||||
@@ -66,6 +66,7 @@ export function DashboardPage() {
|
|||||||
const [ledgerLiabilities, setLedgerLiabilities] = useState(0)
|
const [ledgerLiabilities, setLedgerLiabilities] = useState(0)
|
||||||
const [ledgerEquity, setLedgerEquity] = useState(0)
|
const [ledgerEquity, setLedgerEquity] = useState(0)
|
||||||
const [netIncome, setNetIncome] = useState(0)
|
const [netIncome, setNetIncome] = useState(0)
|
||||||
|
const [ledgerAccounts, setLedgerAccounts] = useState<LedgerAccount[]>([])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchData() {
|
async function fetchData() {
|
||||||
@@ -102,6 +103,12 @@ export function DashboardPage() {
|
|||||||
if (ledgerIs) {
|
if (ledgerIs) {
|
||||||
setNetIncome(ledgerIs.net_income || 0)
|
setNetIncome(ledgerIs.net_income || 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch all accounts
|
||||||
|
const accountsRes = await ledgerApi.accounts().catch(() => null)
|
||||||
|
if (accountsRes) {
|
||||||
|
setLedgerAccounts(accountsRes.accounts || [])
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : 'Failed to load dashboard data')
|
setError(err instanceof Error ? err.message : 'Failed to load dashboard data')
|
||||||
} finally {
|
} finally {
|
||||||
@@ -270,6 +277,50 @@ export function DashboardPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Ledger Accounts Table */}
|
||||||
|
<Card>
|
||||||
|
<CardHeader
|
||||||
|
title="Ledger Accounts"
|
||||||
|
subtitle="All BAS accounts with balances"
|
||||||
|
/>
|
||||||
|
<div className="overflow-x-auto">
|
||||||
|
<Table>
|
||||||
|
<TableHeader>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead>Code</TableHead>
|
||||||
|
<TableHead>Name</TableHead>
|
||||||
|
<TableHead>Type</TableHead>
|
||||||
|
<TableHead className="text-right">Balance</TableHead>
|
||||||
|
</TableRow>
|
||||||
|
</TableHeader>
|
||||||
|
<TableBody>
|
||||||
|
{ledgerAccounts.length === 0 ? (
|
||||||
|
<TableRow>
|
||||||
|
<TableCell colSpan={4} className="text-center text-muted">
|
||||||
|
No accounts found
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
) : (
|
||||||
|
ledgerAccounts.map((account) => (
|
||||||
|
<TableRow key={account.code}>
|
||||||
|
<TableCell className="font-medium">{account.code}</TableCell>
|
||||||
|
<TableCell>{account.name}</TableCell>
|
||||||
|
<TableCell>
|
||||||
|
<Badge>{account.account_type}</Badge>
|
||||||
|
</TableCell>
|
||||||
|
<TableCell className="text-right">
|
||||||
|
<span className={account.balance >= 0 ? 'text-success' : 'text-danger'}>
|
||||||
|
{formatCurrency(account.balance)}
|
||||||
|
</span>
|
||||||
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
{/* Recent Deals */}
|
{/* Recent Deals */}
|
||||||
<Card>
|
<Card>
|
||||||
<CardHeader
|
<CardHeader
|
||||||
|
|||||||
Reference in New Issue
Block a user