import{l as t,n as c,o as i,p as o,q as p,t as u}from"./index-Cc987VYg.js";import{t as d}from"./api-utils-SNhvzubv.js";const y="/ar/payer-master",n={getPayers:async e=>{const{data:a}=await t.get(`${y}/`,{params:d(e)});return a},getPayer:async e=>{const{data:a}=await t.get(`${y}/${e}/`);return a},createPayer:async e=>{const{data:a}=await t.post(`${y}/`,e);return a},updatePayer:async(e,a)=>{const{data:r}=await t.put(`${y}/${e}/`,a);return r},deletePayer:async e=>{await t.delete(`${y}/${e}/`)},getActivePayers:async()=>{const{data:e}=await t.get(`${y}/active/`);return e.data||e},getPayersByType:async e=>{const{data:a}=await t.get(`${y}/by_type/`,{params:{payer_type:e}});return a.data||a}},s={payers:["payers"],payer:e=>["payers",e],activePayers:["payers","active"],payersByType:e=>["payers","by-type",e]},q=e=>c({queryKey:[...s.payers,e],queryFn:()=>n.getPayers(e)}),v=e=>c({queryKey:s.payer(e),queryFn:()=>n.getPayer(e),enabled:!!e}),g=()=>c({queryKey:s.activePayers,queryFn:()=>n.getActivePayers()}),m=e=>c({queryKey:s.payersByType(e),queryFn:()=>n.getPayersByType(e),enabled:!!e}),K=()=>{const e=i();return o({mutationFn:a=>n.createPayer(a),onSuccess:()=>{e.invalidateQueries({queryKey:s.payers}),e.invalidateQueries({queryKey:s.activePayers}),u.success("Payer created successfully")},onError:a=>{const r=p(a);u.error(r,{duration:5e3})}})},Q=()=>{const e=i();return o({mutationFn:({id:a,data:r})=>n.updatePayer(a,r),onSuccess:(a,r)=>{e.invalidateQueries({queryKey:s.payers}),e.invalidateQueries({queryKey:s.payer(r.id)}),e.invalidateQueries({queryKey:s.activePayers}),u.success("Payer updated successfully")},onError:a=>{const r=p(a);u.error(r,{duration:5e3})}})},$=()=>{const e=i();return o({mutationFn:a=>n.deletePayer(a),onSuccess:()=>{e.invalidateQueries({queryKey:s.payers}),e.invalidateQueries({queryKey:s.activePayers}),u.success("Payer deleted successfully")},onError:a=>{const r=p(a);u.error(r,{duration:5e3})}})};export{K as a,$ as b,v as c,q as d,m as e,Q as f,n as p,g as u};
