import{u as N,j as e,g as y,M as c,q as x,b as f}from"./index-C8aoN8t4.js";import{r as g}from"./vendor-ChGFRQAq.js";import{D,m as E,z as j,F as h,n as _}from"./ui-wfmc48pO.js";import"./pdf-DdgWE7Gk.js";const w=({isOpen:u,onClose:i,payment:o,onSave:b})=>{const{t:n}=N(),[t,m]=g.useState({});if(g.useEffect(()=>{o&&m({...o,date:new Date(o.date)})},[o]),!u||!o)return null;const d=l=>{const{name:a,value:s}=l.target;m(a==="date"?r=>({...r,date:new Date(s+"T00:00:00")}):r=>({...r,[a]:a==="amount"?parseFloat(s):s}))},p=l=>{l.preventDefault();const{id:a,...s}=t;a&&b(a,s),i()},v=[{value:"bank_transfer",label:n("accounting.payment_methods.bank_transfer")},{value:"card",label:n("accounting.payment_methods.card")},{value:"cash",label:n("accounting.payment_methods.cash")},{value:"cheque",label:n("accounting.payment_methods.cheque")}];return e.jsxDEV(y,{isOpen:u,onClose:i,title:n("accounting_modals.payment_form.title_edit"),maxWidth:"max-w-lg",children:e.jsxDEV("form",{onSubmit:p,className:"p-6 space-y-6",children:[e.jsxDEV(c,{label:n("accounting_modals.payment_form.amount"),name:"amount",type:"number",value:t.amount||"",onChange:d,required:!0,min:"0.01",step:"0.01",icon:e.jsxDEV(D,{size:18},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/components/accounting/AddEditPaymentModal.tsx",lineNumber:76,columnNumber:17},void 0)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/components/accounting/AddEditPaymentModal.tsx",lineNumber:67,columnNumber:9},void 0),e.jsxDEV(c,{label:n("accounting_modals.payment_form.date"),name:"date",type:"date",value:t.date?new Date(t.date).toISOString().split("T")[0]:"",onChange:d,required:!0,icon:e.jsxDEV(E,{size:18},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/components/accounting/AddEditPaymentModal.tsx",lineNumber:86,columnNumber:17},void 0)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/components/accounting/AddEditPaymentModal.tsx",lineNumber:79,columnNumber:9},void 0),e.jsxDEV(x,{label:n("accounting_modals.payment_form.method"),name:"method",value:t.method||"bank_transfer",onChange:d,options:v,required:!0,icon:e.jsxDEV(j,{size:18},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/components/accounting/AddEditPaymentModal.tsx",lineNumber:96,columnNumber:17},void 0)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/components/accounting/AddEditPaymentModal.tsx",lineNumber:89,columnNumber:9},void 0),e.jsxDEV(c,{label:n("accounting_modals.payment_form.reference"),name:"reference",value:t.reference||"",onChange:d,placeholder:n("accounting_modals.payment_form.ref_placeholder"),icon:e.jsxDEV(h,{size:18},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/components/accounting/AddEditPaymentModal.tsx",lineNumber:105,columnNumber:17},void 0)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/components/accounting/AddEditPaymentModal.tsx",lineNumber:99,columnNumber:9},void 0),e.jsxDEV("div",{className:"flex flex-col sm:flex-row justify-end gap-3 pt-6 border-t border-slate-200 dark:border-slate-700",children:[e.jsxDEV(f,{variant:"secondary",onClick:i,className:"w-full sm:w-auto",children:n("accounting_modals.common.cancel")},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/components/accounting/AddEditPaymentModal.tsx",lineNumber:109,columnNumber:11},void 0),e.jsxDEV(f,{variant:"primary",onClick:()=>p(new Event("submit")),icon:_,className:"w-full sm:w-[150px]",children:n("accounting_modals.payment_form.save_btn")},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/components/accounting/AddEditPaymentModal.tsx",lineNumber:116,columnNumber:11},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/components/accounting/AddEditPaymentModal.tsx",lineNumber:108,columnNumber:9},void 0)]},void 0,!0,{fileName:"D:/devlop/projects/printing system/src/components/accounting/AddEditPaymentModal.tsx",lineNumber:66,columnNumber:7},void 0)},void 0,!1,{fileName:"D:/devlop/projects/printing system/src/components/accounting/AddEditPaymentModal.tsx",lineNumber:60,columnNumber:5},void 0)};export{w as default};
