import{u as g,j as e,d as b,M as c,e as _}from"./index-D9pJRAs5.js";import{r as p}from"./vendor-D6aTFYy9.js";import{D as j,m as v,u as y,F as D,n as k}from"./ui-CtYVlq7P.js";import"./pdf-Bz_mU5mG.js";const q=({isOpen:u,onClose:l,payment:o,onSave:x})=>{const{t:a}=g(),[t,d]=p.useState({});if(p.useEffect(()=>{o&&d({...o,date:new Date(o.date)})},[o]),!u||!o)return null;const r=i=>{const{name:n,value:s}=i.target;d(n==="date"?m=>({...m,date:new Date(s+"T00:00:00")}):m=>({...m,[n]:n==="amount"?parseFloat(s):s}))},h=i=>{i.preventDefault();const{id:n,...s}=t;n&&x(n,s),l()},f=[{value:"bank_transfer",label:a("accounting.payment_methods.bank_transfer")},{value:"card",label:a("accounting.payment_methods.card")},{value:"cash",label:a("accounting.payment_methods.cash")},{value:"cheque",label:a("accounting.payment_methods.cheque")}];return e.jsx(b,{isOpen:u,onClose:l,title:a("accounting_modals.payment_form.title_edit"),maxWidth:"max-w-lg",children:e.jsxs("form",{onSubmit:h,className:"p-6 space-y-6",children:[e.jsx(c,{label:a("accounting_modals.payment_form.amount"),name:"amount",type:"number",value:t.amount||"",onChange:r,required:!0,min:"0.01",step:"0.01",icon:e.jsx(j,{size:18})}),e.jsx(c,{label:a("accounting_modals.payment_form.date"),name:"date",type:"date",value:t.date?new Date(t.date).toISOString().split("T")[0]:"",onChange:r,required:!0,icon:e.jsx(v,{size:18})}),e.jsx(_,{label:a("accounting_modals.payment_form.method"),name:"method",value:t.method||"bank_transfer",onChange:r,options:f,required:!0,icon:e.jsx(y,{size:18})}),e.jsx(c,{label:a("accounting_modals.payment_form.reference"),name:"reference",value:t.reference||"",onChange:r,placeholder:a("accounting_modals.payment_form.ref_placeholder"),icon:e.jsx(D,{size:18})}),e.jsxs("div",{className:"flex justify-end space-x-3 pt-6 border-t border-slate-200 dark:border-slate-700",children:[e.jsx("button",{type:"button",onClick:l,className:"px-6 py-2.5 text-sm font-medium text-slate-700 dark:text-slate-300 bg-slate-100 dark:bg-slate-800 hover:bg-slate-200 dark:hover:bg-slate-700 rounded-xl transition-colors",children:a("accounting_modals.common.cancel")}),e.jsxs("button",{type:"submit",className:"px-6 py-2.5 text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 rounded-xl shadow-lg shadow-indigo-500/30 transition-all active:scale-95 flex items-center space-x-2",children:[e.jsx(k,{size:18}),e.jsx("span",{children:a("accounting_modals.payment_form.save_btn")})]})]})]})})};export{q as default};
