import{l as r,n as d,o,p as i,q as l,t as n}from"./index-C9vqJYWU.js";const c="/exchange-rates",y=async e=>(await r.get(`${c}/`,{params:e})).data,g=async e=>(await r.get(`${c}/current/`,{params:e})).data.data,p=async e=>{const t=await r.get(`${c}/${e}/`);return t.data.data||t.data},E=async e=>(await r.post(`${c}/convert/`,e)).data.data,x=async e=>(await r.post(`${c}/`,e)).data.data,q=async(e,t)=>(await r.put(`${c}/${e}/`,t)).data.data,h=async e=>{await r.delete(`${c}/${e}/`)},s={all:["exchange-rates"],lists:()=>[...s.all,"list"],list:e=>[...s.lists(),e],current:()=>[...s.all,"current"],details:()=>[...s.all,"detail"],detail:e=>[...s.details(),e]},u={all:["conversion-logs"],lists:()=>[...u.all,"list"],list:e=>[...u.lists(),e],details:()=>[...u.all,"detail"],detail:e=>[...u.details(),e]},R=e=>d({queryKey:s.list(e),queryFn:()=>y(e),staleTime:300*1e3}),K=e=>d({queryKey:[...s.current(),e],queryFn:()=>g(e),staleTime:300*1e3}),m=(e,t=!0)=>d({queryKey:s.detail(e),queryFn:()=>p(e),enabled:t&&!!e}),C=()=>{const e=o();return i({mutationFn:t=>E(t),onSuccess:()=>{e.invalidateQueries({queryKey:u.lists()})},onError:t=>{const a=l(t);n.error(a,{duration:5e3})}})},Q=()=>{const e=o();return i({mutationFn:t=>x(t),onSuccess:()=>{e.invalidateQueries({queryKey:s.lists()}),e.invalidateQueries({queryKey:s.current()}),n.success("Exchange rate created successfully")},onError:t=>{const a=l(t);n.error(a,{duration:5e3})}})},$=()=>{const e=o();return i({mutationFn:({id:t,data:a})=>q(t,a),onSuccess:(t,a)=>{e.invalidateQueries({queryKey:s.lists()}),e.invalidateQueries({queryKey:s.current()}),e.invalidateQueries({queryKey:s.detail(a.id)}),n.success("Exchange rate updated successfully")},onError:t=>{const a=l(t);n.error(a,{duration:5e3})}})},w=()=>{const e=o();return i({mutationFn:t=>h(t),onSuccess:()=>{e.invalidateQueries({queryKey:s.lists()}),e.invalidateQueries({queryKey:s.current()}),n.success("Exchange rate deactivated successfully")},onError:t=>{const a=l(t);n.error(a,{duration:5e3})}})};export{C as a,w as b,Q as c,$ as d,K as e,m as f,y as g,R as u};
