"use client";

import { Example } from "@/components/design-system/example";
import { Section } from "@/components/design-system/section";
import { TransactionsList, type MoneyTxn } from "@/components/medora/transactions";
import { toast } from "@/components/ui/toast";

const ROWS: MoneyTxn[] = [
  { ref: "RCP-005214", date: "20 Oct", kind: "Sale", details: "Till sale, Mary Wambui", debit: "1021 M-Pesa till 512330", credit: "4000 Sales", amount: 1589.2, branch: "Westlands Main" },
  { ref: "RCP-005209", date: "20 Oct", kind: "Sale", details: "Till sale, walk-in (cash part)", debit: "1011 Cash drawer, Westlands", credit: "4000 Sales", amount: 1000, branch: "Westlands Main" },
  { ref: "RCP-005209", date: "20 Oct", kind: "Sale", details: "Till sale, walk-in (M-Pesa part)", debit: "1021 M-Pesa till 512330", credit: "4000 Sales", amount: 693.6, branch: "Westlands Main" },
  { ref: "CN-2026-0094", date: "20 Oct", kind: "Credit note", details: "Return on RCP-005209", debit: "4010 Sales returns", credit: "1011 Cash drawer, Westlands", amount: 707.6, branch: "Westlands Main" },
  { ref: "DRP-0318", date: "20 Oct", kind: "Cash drop", details: "Mid-shift drop, Kevin Mutua", debit: "1040 Equity Bank", credit: "1011 Cash drawer, Westlands", amount: 20000, branch: "Westlands Main" },
  { ref: "SP-0127", date: "19 Oct", kind: "Supplier payment", details: "Harleys Ltd, bills to 30 Sep", debit: "2000 Accounts payable", credit: "1040 Equity Bank", amount: 84500, branch: "Westlands Main" },
  { ref: "EXP-0412", date: "19 Oct", kind: "Expense", details: "Electricity, Kenya Power, Sep", debit: "6200 Utilities", credit: "1040 Equity Bank", amount: 12840, branch: "Kilimani" },
  { ref: "PC-0088", date: "18 Oct", kind: "Petty cash", details: "Cleaning supplies", debit: "6300 Cleaning", credit: "1015 Petty cash, Kilimani", amount: 1350, branch: "Kilimani" },
  { ref: "CP-0061", date: "18 Oct", kind: "Customer payment", details: "Aga Khan Hospital, part of INV-2026-00783", debit: "1040 Equity Bank", credit: "1100 Accounts receivable", amount: 2000, branch: "Westlands Main" },
  { ref: "ADV-0019", date: "17 Oct", kind: "Salary advance", details: "Faith Njeri, recovered from October pay", debit: "1300 Staff advances", credit: "1021 M-Pesa till 512330", amount: 5000, branch: "Westlands Main" },
  { ref: "WST-0042", date: "16 Oct", kind: "Waste", details: "Expired Amoxil, batch AMX-2304", debit: "5100 Stock write-offs", credit: "1200 Inventory", amount: 3150, branch: "Nyali" },
];

export function TransactionsSection() {
  return (
    <Section
      id="transactions"
      title="Transactions list"
      description="AC-14: every money movement with its reference, date, details, the account it debits and the account it credits. Search, filter by type or account, export exactly what's shown, and open the document behind any row. Choose an account to see money in, out and net through it."
    >
      <Example title="Transactions, 16–20 Oct 2026" description="All branches. Try the account filter with 1011 Cash drawer, Westlands">
        <TransactionsList rows={ROWS} onOpen={(t) => toast.add({ title: `Opens ${t.ref}`, description: t.kind })} />
      </Example>
    </Section>
  );
}
