import{l as r,n as l,o as i,p as o,q as c,t as u}from"./index-Cc987VYg.js";const n={getUnitsOfMeasure:async s=>{const{data:e}=await r.get("/units-of-measure/",{params:s});return e},getUnitOfMeasure:async s=>{const{data:e}=await r.get(`/units-of-measure/${s}/`);return e},createUnitOfMeasure:async s=>{const{data:e}=await r.post("/units-of-measure/",s);return e},updateUnitOfMeasure:async(s,e)=>{const{data:t}=await r.put(`/units-of-measure/${s}/`,e);return t},deleteUnitOfMeasure:async s=>{await r.delete(`/units-of-measure/${s}/`)}},a={all:["units-of-measure"],lists:()=>[...a.all,"list"],details:()=>[...a.all,"detail"],detail:s=>[...a.details(),s]};function d(s){return l({queryKey:[...a.lists(),s],queryFn:()=>n.getUnitsOfMeasure(s)})}function y(s,e=!0){return l({queryKey:a.detail(s),queryFn:()=>n.getUnitOfMeasure(s),enabled:e&&!!s})}function M(){const s=i();return o({mutationFn:e=>n.createUnitOfMeasure(e),onSuccess:e=>{s.invalidateQueries({queryKey:a.lists()}),u.success(`Unit of Measure "${e.name}" created successfully`)},onError:e=>{const t=c(e);u.error(t,{duration:5e3})}})}function U(){const s=i();return o({mutationFn:({id:e,data:t})=>n.updateUnitOfMeasure(e,t),onSuccess:e=>{s.invalidateQueries({queryKey:a.lists()}),s.invalidateQueries({queryKey:a.detail(e.id.toString())}),u.success(`Unit of Measure "${e.name}" updated successfully`)},onError:e=>{const t=c(e);u.error(t,{duration:5e3})}})}function O(){const s=i();return o({mutationFn:e=>n.deleteUnitOfMeasure(e),onSuccess:()=>{s.invalidateQueries({queryKey:a.lists()}),u.success("Unit of Measure deleted successfully")},onError:e=>{const t=c(e);u.error(t,{duration:5e3})}})}export{O as a,M as b,U as c,y as d,n as e,d as u};
