import{u as o,j as e,H as m,L as d}from"./app-CAqQVdqj.js";import{A as h}from"./AuthenticatedLayout-CQEcc2iz.js";function g({leases:n}){const{data:a,setData:r,post:i,processing:l,errors:t}=o({lease_id:"",month:"",due_date:"",other_charges:"",other_charges_description:""}),c=s=>{s.preventDefault(),i(route("invoices.store"))};return e.jsxs(h,{header:e.jsx("h2",{className:"text-xl font-semibold leading-tight text-gray-800",children:"Generate Invoice"}),children:[e.jsx(m,{title:"Generate Invoice"}),e.jsx("div",{className:"py-12",children:e.jsx("div",{className:"mx-auto max-w-2xl sm:px-6 lg:px-8",children:e.jsx("div",{className:"overflow-hidden bg-white shadow-sm sm:rounded-lg",children:e.jsxs("div",{className:"p-6 text-gray-900",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h3",{className:"text-lg font-medium",children:"Generate New Invoice"}),e.jsx(d,{href:route("invoices.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"})]}),e.jsx("div",{className:"mb-6 rounded-lg border border-blue-200 bg-blue-50 p-4",children:e.jsx("p",{className:"text-sm text-blue-700",children:"Rent, electricity and maintenance will be calculated automatically based on lease agreement and meter readings."})}),e.jsxs("form",{onSubmit:c,className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700",children:["Lease ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("select",{value:a.lease_id,onChange:s=>r("lease_id",s.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500",children:[e.jsx("option",{value:"",children:"Select a lease..."}),n.map(s=>e.jsxs("option",{value:s.id,children:["Shop ",s.shop?.shop_number," - ",s.tenant?.name]},s.id))]}),t.lease_id&&e.jsx("p",{className:"mt-1 text-sm text-red-600",children:t.lease_id})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700",children:["Month ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"month",value:a.month,onChange:s=>r("month",s.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"}),t.month&&e.jsx("p",{className:"mt-1 text-sm text-red-600",children:t.month})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700",children:["Due Date ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"date",value:a.due_date,onChange:s=>r("due_date",s.target.value),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"}),t.due_date&&e.jsx("p",{className:"mt-1 text-sm text-red-600",children:t.due_date})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Other Charges"}),e.jsx("input",{type:"number",step:"0.01",min:"0",value:a.other_charges,onChange:s=>r("other_charges",s.target.value),placeholder:"0",className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"}),t.other_charges&&e.jsx("p",{className:"mt-1 text-sm text-red-600",children:t.other_charges})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700",children:"Other Charges Description"}),e.jsx("input",{type:"text",value:a.other_charges_description,onChange:s=>r("other_charges_description",s.target.value),placeholder:"e.g. Repair charges, late fee...",className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-blue-500 focus:ring-blue-500"}),t.other_charges_description&&e.jsx("p",{className:"mt-1 text-sm text-red-600",children:t.other_charges_description})]}),e.jsxs("div",{className:"flex items-center justify-end gap-4",children:[e.jsx(d,{href:route("invoices.index"),className:"text-sm text-gray-600 hover:text-gray-900",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:l,className:"inline-flex items-center rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:opacity-50",children:l?"Generating...":"Generate Invoice"})]})]})]})})})})]})}export{g as default};
