import{r as m,j as e,H as p,L as g,b as h}from"./app-CAqQVdqj.js";import{A as u}from"./AuthenticatedLayout-CQEcc2iz.js";import{f as r}from"./utils-f31lc4sE.js";const n={paid:{label:"Paid ✓",bg:"bg-green-50",text:"text-green-800",badge:"bg-green-100 text-green-800"},pending:{label:"Pending ⏳",bg:"bg-yellow-50",text:"text-yellow-800",badge:"bg-yellow-100 text-yellow-800"},overdue:{label:"Overdue ✗",bg:"bg-red-50",text:"text-red-800",badge:"bg-red-100 text-red-800"},no_invoice:{label:"No Invoice",bg:"bg-gray-50",text:"text-gray-500",badge:"bg-gray-100 text-gray-500"}};function j({shops:l,month:x}){const[i,d]=m.useState(x||new Date().toISOString().slice(0,7)),c=t=>{d(t),h.get(route("reports.payment-tracker"),{month:t},{preserveState:!0,replace:!0})};return e.jsxs(u,{header:e.jsx("h2",{className:"text-xl font-semibold leading-tight text-gray-800",children:"Payment Tracker"}),children:[e.jsx(p,{title:"Payment Tracker"}),e.jsx("div",{className:"py-12",children:e.jsxs("div",{className:"mx-auto max-w-7xl sm:px-6 lg:px-8 space-y-6",children:[e.jsx("div",{className:"bg-white shadow-sm sm:rounded-lg p-6",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("label",{className:"text-sm font-medium text-gray-700",children:"Month:"}),e.jsx("input",{type:"month",value:i,onChange:t=>c(t.target.value),className:"rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"})]}),e.jsx(g,{href:route("reports.index"),className:"inline-flex items-center rounded-md bg-gray-200 px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-300",children:"Back to Reports"})]})}),e.jsx("div",{className:"flex flex-wrap gap-4 px-2",children:Object.entries(n).map(([t,a])=>e.jsx("div",{className:"flex items-center gap-1.5",children:e.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${a.badge}`,children:a.label})},t))}),e.jsx("div",{className:"bg-white shadow-sm sm:rounded-lg overflow-hidden",children:e.jsx("div",{className:"p-6 text-gray-900",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500",children:"Shop#"}),e.jsx("th",{className:"px-4 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500",children:"Tenant"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium uppercase tracking-wider text-gray-500",children:"Total Amount"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium uppercase tracking-wider text-gray-500",children:"Paid"}),e.jsx("th",{className:"px-4 py-3 text-right text-xs font-medium uppercase tracking-wider text-gray-500",children:"Balance"}),e.jsx("th",{className:"px-4 py-3 text-center text-xs font-medium uppercase tracking-wider text-gray-500",children:"Status"})]})}),e.jsxs("tbody",{className:"divide-y divide-gray-200",children:[l.map((t,a)=>{const s=n[t.status]||n.no_invoice,o=(parseFloat(t.invoice?.total_amount)||0)-(parseFloat(t.total_paid)||0);return e.jsxs("tr",{className:s.bg,children:[e.jsx("td",{className:"whitespace-nowrap px-4 py-4 text-sm font-medium text-gray-900",children:t.shop?.shop_number||"—"}),e.jsx("td",{className:"whitespace-nowrap px-4 py-4 text-sm text-gray-900",children:t.shop?.active_lease?.tenant?.name||"—"}),e.jsx("td",{className:"whitespace-nowrap px-4 py-4 text-sm text-right text-gray-900",children:t.invoice?r(t.invoice.total_amount):"—"}),e.jsx("td",{className:"whitespace-nowrap px-4 py-4 text-sm text-right text-gray-900",children:r(t.total_paid)}),e.jsx("td",{className:"whitespace-nowrap px-4 py-4 text-sm text-right font-medium text-gray-900",children:t.invoice?r(o):"—"}),e.jsx("td",{className:"whitespace-nowrap px-4 py-4 text-sm text-center",children:e.jsx("span",{className:`inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium ${s.badge}`,children:s.label})})]},a)}),l.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:"6",className:"px-4 py-4 text-center text-sm text-gray-500",children:"No shops found."})})]})]})})})})]})})]})}export{j as default};
