import{l as o,m as u,o as d,a as l,p as i,t as r,q as y,R as V,n as E}from"./index-Cc987VYg.js";import{q as n}from"./query-keys-DGBjVswC.js";const c={getVendors:async e=>{const{data:s}=await o.get(u.VENDORS,{params:e});return s},getVendor:async e=>{const{data:s}=await o.get(u.VENDOR_DETAIL(e));return s},createVendor:async e=>{const{data:s}=await o.post(u.VENDORS,e);return s},updateVendor:async(e,s)=>{const{data:a}=await o.put(u.VENDOR_DETAIL(e),s);return a},deleteVendor:async e=>{await o.delete(u.VENDOR_DETAIL(e))}},g=e=>E({queryKey:n.accountsPayable.vendors.list(JSON.stringify(e)),queryFn:()=>c.getVendors(e),staleTime:300*1e3}),p=e=>E({queryKey:n.accountsPayable.vendors.detail(e),queryFn:()=>c.getVendor(e),enabled:!!e,staleTime:300*1e3}),D=e=>{const s=d(),a=l();return i({mutationFn:c.createVendor,onSuccess:t=>{s.invalidateQueries({queryKey:n.accountsPayable.vendors.lists()}),r.success("Vendor created successfully"),e?.onSuccess?.(t),e?.navigateOnSuccess!==!1&&a(`${V.VENDORS}/`)},onError:t=>{r.error(y(t))}})},S=()=>{const e=d(),s=l();return i({mutationFn:({id:a,data:t})=>c.updateVendor(a,t),onSuccess:(a,t)=>{e.invalidateQueries({queryKey:n.accountsPayable.vendors.lists()}),e.invalidateQueries({queryKey:n.accountsPayable.vendors.detail(t.id)}),r.success("Vendor updated successfully"),s(`${V.VENDORS}/${t.id}`)},onError:a=>{r.error(y(a))}})},m=()=>{const e=d();return i({mutationFn:c.deleteVendor,onSuccess:()=>{e.invalidateQueries({queryKey:n.accountsPayable.vendors.lists()}),r.success("Vendor deleted successfully")},onError:s=>{r.error(y(s))}})};export{p as a,D as b,m as c,S as d,g as u,c as v};
