import{r as u,u as p,j as t,H as m}from"./app-BQEFzdw6.js";import{A as h}from"./AppLayout-kozc03ce.js";import{P as x}from"./PageHeader-Bj1OQnqr.js";import{F as s}from"./FormField-HY4WrCzQ.js";import"./dayjs.min-BDUBcDj6.js";import"./useThemeColor-qPCpc713.js";const j=["cash","bank_transfer","cheque","bkash","nagad","rocket","other"];function y({clients:c,accountHeads:o}){const[v,_]=u.useState([]),{data:a,setData:r,post:l,processing:i,errors:n}=p({client_id:"",invoice_id:"",project_id:"",amount:"",receipt_date:new Date().toISOString().substring(0,10),payment_method:"bank_transfer",reference:"",account_head_id:"",notes:""});function d(e){e.preventDefault(),l(route("accounts.receipts.store"))}return t.jsxs(h,{children:[t.jsx(m,{title:"Record Receipt"}),t.jsx(x,{title:"Record Client Receipt",back:route("accounts.receipts.index")}),t.jsx("div",{className:"p-4 sm:p-6 max-w-2xl mx-auto",children:t.jsxs("form",{onSubmit:d,className:"card p-6 space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[t.jsx(s,{label:"Client",error:n.client_id,required:!0,children:t.jsxs("select",{className:"form-input",value:a.client_id,onChange:e=>r("client_id",e.target.value),children:[t.jsx("option",{value:"",children:"Select client…"}),c.map(e=>t.jsxs("option",{value:e.id,children:[e.name," (",e.code,")"]},e.id))]})}),t.jsx(s,{label:"Amount (৳)",error:n.amount,required:!0,children:t.jsx("input",{type:"number",step:"0.01",min:"0.01",className:"form-input",value:a.amount,onChange:e=>r("amount",e.target.value)})}),t.jsx(s,{label:"Receipt Date",error:n.receipt_date,required:!0,children:t.jsx("input",{type:"date",className:"form-input",value:a.receipt_date,onChange:e=>r("receipt_date",e.target.value)})}),t.jsx(s,{label:"Payment Method",error:n.payment_method,required:!0,children:t.jsx("select",{className:"form-input",value:a.payment_method,onChange:e=>r("payment_method",e.target.value),children:j.map(e=>t.jsx("option",{value:e,className:"capitalize",children:e.replace(/_/g," ")},e))})}),t.jsx(s,{label:"Received Into (Account)",error:n.account_head_id,required:!0,children:t.jsxs("select",{className:"form-input",value:a.account_head_id,onChange:e=>r("account_head_id",e.target.value),children:[t.jsx("option",{value:"",children:"Select account…"}),o.map(e=>t.jsxs("option",{value:e.id,children:[e.code," — ",e.name]},e.id))]})}),t.jsx(s,{label:"Reference (Cheque/TxID)",error:n.reference,children:t.jsx("input",{className:"form-input",value:a.reference,onChange:e=>r("reference",e.target.value),placeholder:"Optional"})})]}),t.jsx(s,{label:"Notes",error:n.notes,children:t.jsx("textarea",{className:"form-input",rows:2,value:a.notes,onChange:e=>r("notes",e.target.value)})}),t.jsxs("div",{className:"flex gap-3 pt-2",children:[t.jsx("button",{type:"submit",disabled:i,className:"btn btn-primary",children:i?"Recording…":"Record Receipt"}),t.jsx("a",{href:route("accounts.receipts.index"),className:"btn",children:"Cancel"})]})]})})]})}export{y as default};
