import { Head } from '@inertiajs/react';
import AccountingNav from '@/components/accounting-nav';
import MemberPage from '@/components/member/member-page';
import { formatDate } from '@/lib/format';
import { trialBalance } from '@/routes/admin/accounting';
import { LedgerTable } from './general-ledger';
import type { LedgerProps } from './general-ledger';

export default function Cashbook(props: LedgerProps) {
    return (
        <>
            <Head title="Cashbook" />

            <MemberPage
                title="Cashbook"
                description={`Money received and paid out, ${formatDate(props.from)} – ${formatDate(props.to)}.`}
            >
                <AccountingNav
                    current="cashbook"
                    dates={{ from: props.from, to: props.to }}
                />

                <LedgerTable
                    props={props}
                    debitLabel="Received"
                    creditLabel="Paid out"
                />
            </MemberPage>
        </>
    );
}

Cashbook.layout = {
    breadcrumbs: [{ title: 'Accounting', href: trialBalance() }],
};
