import { useEffect, useState } from 'react' import { Link } from 'react-router-dom' import { catalog, finance, inventory, partners, production, purchaseOrders, salesOrders, } from '@/api/client' import { PageHeader } from '@/components/PageHeader' import { Loading } from '@/components/Loading' import { ErrorBox } from '@/components/ErrorBox' import { useAuth } from '@/auth/AuthContext' interface DashboardCounts { items: number partners: number locations: number salesOrders: number purchaseOrders: number workOrders: number journalEntries: number inProgressWorkOrders: number } export function DashboardPage() { const { username } = useAuth() const [counts, setCounts] = useState(null) const [error, setError] = useState(null) const [loading, setLoading] = useState(true) useEffect(() => { let active = true setLoading(true) Promise.all([ catalog.listItems(), partners.list(), inventory.listLocations(), salesOrders.list(), purchaseOrders.list(), production.listWorkOrders(), finance.listJournalEntries(), production.shopFloor(), ]) .then(([items, parts, locs, sos, pos, wos, jes, sf]) => { if (!active) return setCounts({ items: items.length, partners: parts.length, locations: locs.length, salesOrders: sos.length, purchaseOrders: pos.length, workOrders: wos.length, journalEntries: jes.length, inProgressWorkOrders: sf.length, }) }) .catch((e: unknown) => { if (active) setError(e instanceof Error ? e : new Error(String(e))) }) .finally(() => active && setLoading(false)) return () => { active = false } }, []) return (
{loading && } {error && } {counts && (
)}

Getting started

The framework's buy-make-sell loop, end to end.

  1. Set up master data — create{' '} items,{' '} partners, and{' '} locations. Then{' '} adjust stock{' '} to set opening balances.
  2. Create a sales order —{' '} new order{' '} with line items. Confirm it — the system auto-generates production work orders and posts an AR journal entry with double-entry lines (DR Accounts Receivable, CR Revenue).
  3. Walk the work order — start it, walk routing operations on the{' '} Shop Floor, then complete it. Materials are consumed, finished goods credited.
  4. Ship the sales order — stock leaves the warehouse, the AR journal entry settles. View the ledger in{' '} Movements{' '} and double-entry lines in{' '} Journal Entries.
  5. Restock via purchase — create a{' '} purchase order, confirm, and receive into a warehouse. AP journal entry posts and settles.
) } function DashboardCard({ label, value, to, highlight = false, }: { label: string value: number to: string highlight?: boolean }) { return (
{label}
{value}
) }