import{m as P,u as m,k as q,o as a,t as p,n as i}from"./index-7T7TTikv.js";import{c as E,u as K,d as h,m as F,a as H,g as Q,b as f,e as k,f as M}from"./positionService-BwPU5sNe.js";const _=o=>{const n=P(),{t:r}=m(),{handleError:t}=q(r),u=()=>i({queryKey:["positions",o],queryFn:()=>H(o),select:e=>({count:e.data.count,items:e.data.items}),staleTime:300*1e3,enabled:!!o}),b=e=>i({queryKey:["position",e],queryFn:()=>Q(e),enabled:!!e,select:s=>s.data}),g=(e="root")=>i({queryKey:["positionHierarchy",e],queryFn:()=>f(e),enabled:!!e,select:s=>s.data}),v=e=>i({queryKey:["positionEmployees",e],queryFn:()=>k(e),enabled:!!(e||o)}),C=(e,s)=>i({queryKey:["positionList",e,s],queryFn:()=>M(e,s),enabled:!!e,select:d=>d.data}),c=a({mutationFn:({payload:e,successCallback:s})=>E(e),onSuccess:(e,s)=>{n.invalidateQueries({queryKey:["positionHierarchy"]}),s.successCallback()},onError:e=>{t(e)}}),l=a({mutationFn:({id:e,payload:s,successCallback:d})=>K(e,s),onSuccess:(e,s)=>{n.invalidateQueries({queryKey:["positionHierarchy"]}),s.successCallback()},onError:e=>{t(e)}}),y=a({mutationFn:({id:e,successCallback:s})=>h(e),onSuccess:(e,s)=>{n.invalidateQueries({queryKey:["positionHierarchy"]}),p.success("Department removed successfully."),s.successCallback()},onError:e=>{t(e)}});return{usePositionsQuery:u,usePositionById:b,usePositionHierarchy:g,useEmployeesUnderPosition:v,usePositionListByUnitId:C,createPosition:c.mutateAsync,isCreating:c.isPending,updatePosition:l.mutateAsync,isUpdating:l.isPending,deletePosition:y.mutateAsync,isDeleting:y.isPending}},A=()=>{const o=P(),{t:n}=m(),{handleError:r}=q(n);return a({mutationFn:t=>F(t),onSuccess:(t,u)=>{o.invalidateQueries({queryKey:["positions"]}),o.invalidateQueries({queryKey:["positionHierarchy"]}),p.success("Department moved successfully.")},onError:t=>{r(t)}})};export{A as a,_ as u};
