import{j as e,H as o,L as c}from"./app-BQEFzdw6.js";import{A as x}from"./AppLayout-kozc03ce.js";import{P as m}from"./PageHeader-Bj1OQnqr.js";import{f as i}from"./formatters-ClI693-F.js";import"./useThemeColor-qPCpc713.js";import"./dayjs.min-BDUBcDj6.js";function d({label:t,value:a,icon:l,delta:s,color:r="primary"}){const n={primary:"bg-primary-50 text-primary-600",green:"bg-green-50 text-green-600",amber:"bg-amber-50 text-amber-600",red:"bg-red-50 text-red-600",blue:"bg-blue-50 text-blue-600"};return e.jsx("div",{className:"card p-5",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-gray-500",children:t}),e.jsx("p",{className:"text-2xl font-bold text-gray-900 mt-1",children:a}),s!==void 0&&e.jsxs("p",{className:`text-xs mt-1 ${s>=0?"text-green-600":"text-red-600"}`,children:[s>=0?"+":"",s,"% from last month"]})]}),l&&e.jsx("div",{className:`w-12 h-12 rounded-xl flex items-center justify-center ${n[r]}`,children:e.jsx(l,{className:"h-6 w-6"})})]})})}function g({stats:t,recentInvoices:a,overdueInvoices:l}){return e.jsxs(x,{children:[e.jsx(o,{title:"Accounts Dashboard"}),e.jsx(m,{title:"Accounts",subtitle:"Financial overview"}),e.jsxs("div",{className:"p-4 sm:p-6 space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[e.jsx(d,{title:"Total Receivables",value:i((t==null?void 0:t.total_receivables)??0),subtitle:"Outstanding invoices",color:"blue"}),e.jsx(d,{title:"Total Payables",value:i((t==null?void 0:t.total_payables)??0),subtitle:"Outstanding payments",color:"red"}),e.jsx(d,{title:"This Month Revenue",value:i((t==null?void 0:t.month_revenue)??0),subtitle:"Receipts this month",color:"green"}),e.jsx(d,{title:"This Month Expenses",value:i((t==null?void 0:t.month_expenses)??0),subtitle:"Expenses this month",color:"orange"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-semibold text-sm",children:"Recent Invoices"}),e.jsx(c,{href:route("accounts.invoices.index"),className:"text-xs text-primary-600 hover:underline",children:"View all"})]}),e.jsx("table",{className:"min-w-full text-sm divide-y divide-gray-100",children:e.jsxs("tbody",{className:"divide-y divide-gray-50",children:[(a??[]).map(s=>{var r;return e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 font-mono text-primary-600",children:e.jsx(c,{href:route("accounts.invoices.show",s.id),children:s.code})}),e.jsx("td",{className:"py-2 text-gray-600",children:(r=s.client)==null?void 0:r.name}),e.jsx("td",{className:"py-2 text-right font-medium",children:i(s.grand_total)})]},s.id)}),(a??[]).length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:3,className:"py-4 text-center text-gray-400",children:"No invoices yet."})})]})})]}),e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"font-semibold text-sm text-red-600",children:"Overdue Invoices"}),e.jsx(c,{href:route("accounts.reports.receivables"),className:"text-xs text-primary-600 hover:underline",children:"View all"})]}),e.jsx("table",{className:"min-w-full text-sm divide-y divide-gray-100",children:e.jsxs("tbody",{className:"divide-y divide-gray-50",children:[(l??[]).map(s=>{var r;return e.jsxs("tr",{children:[e.jsx("td",{className:"py-2 font-mono text-primary-600",children:e.jsx(c,{href:route("accounts.invoices.show",s.id),children:s.code})}),e.jsx("td",{className:"py-2 text-gray-600",children:(r=s.client)==null?void 0:r.name}),e.jsx("td",{className:"py-2 text-right font-semibold text-red-600",children:i(s.balance_due)})]},s.id)}),(l??[]).length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:3,className:"py-4 text-center text-gray-400",children:"No overdue invoices."})})]})})]})]})]})]})}export{g as default};
