import{l as i,w as n,b4 as W,a as X,n as a,bq as Y,br as Z}from"./index-7T7TTikv.js";import{f as w,a as ee}from"./organizationService-B_C-b9EH.js";const re=async t=>{try{const{data:r}=await i.get(`units/current/${t}/employees`,{headers:n()});return r}catch(r){throw r}},te=async(t={})=>{try{const{data:r}=await i.get("positions/scoped",{params:{...t},headers:n()});return r}catch(r){throw r}},ae=async(t={})=>{try{const{data:r}=await i.get("positions/scoped",{params:{...t},headers:n()});return r}catch(r){throw r}},F=async(t=null,r={})=>{try{const{data:e}=await i.get(`positions/list/${t}`,{params:{...r},headers:n()});return e}catch(e){throw e}},b=async(t={})=>{try{const{data:r}=await i.get("positions/internal-record-receiving",{params:{...t,take:t.take||3e3},headers:n()});return r}catch(r){throw r}},se=async()=>{try{const{data:t}=await W.get("record-types",{headers:n()});return t}catch(t){throw t}},s=300*1e3,le=t=>{var k,T;const{userDetails:r}=X(),e=((T=(k=r==null?void 0:r.employee)==null?void 0:k[0])==null?void 0:T.unitId)??null,l=300,c=0,{data:y,isLoading:K,error:L}=a({queryKey:["organizations",{take:50,skip:0}],queryFn:w,enabled:!!e,staleTime:s}),{data:A,isLoading:oe,error:ne}=a({queryKey:["organizationsModified",{take:50,skip:0}],queryFn:ee,staleTime:s}),{data:p,isLoading:D,error:I}=a({queryKey:["organizations"],queryFn:w,staleTime:s}),{data:m,isLoading:O,error:M}=a({queryKey:["departments"],queryFn:()=>b(),enabled:!!e,staleTime:s}),{data:u,isLoading:S,error:C}=a({queryKey:["record-types"],queryFn:se,staleTime:s}),{data:g,isLoading:x,error:z}=a({queryKey:["departments"],queryFn:()=>b({take:1e3,skip:0}),staleTime:s,enabled:!!e}),{data:h,isLoading:v,error:V}=a({queryKey:["scoped-departments"],queryFn:()=>te({take:1e3,skip:0}),staleTime:s,enabled:!!e}),{data:q,isLoading:P,error:R}=a({queryKey:["scoped-Employees"],queryFn:()=>ae({take:1e3,skip:0}),staleTime:s,enabled:!!e}),{data:U,isLoading:$,error:H}=a({queryKey:["current-department",e],queryFn:()=>re(e),enabled:!!e,staleTime:s}),{data:d,isLoading:N,error:Q}=a({queryKey:["current-employees",e,l,c],queryFn:()=>Y({take:l,skip:c},e),enabled:!!e,staleTime:s}),{data:_,isLoading:j,error:B}=a({queryKey:["current-employees",e],queryFn:()=>Z({take:l,skip:c},e),enabled:!!e,staleTime:s}),{data:E}=a({queryKey:["all-departments-count",e],queryFn:()=>F(e,{take:1,skip:0}),enabled:!!e,staleTime:s}),f=(E==null?void 0:E.count)??0,{data:o,isLoading:G,error:J}=a({queryKey:["all-departments",e,f],queryFn:()=>F(e,{take:f,skip:0}),enabled:!!e&&f>0,staleTime:s});return{allOrgs:(y==null?void 0:y.items)??[],allModifiedOrgs:A??[],allDepartmentUnits:(m==null?void 0:m.items)??[],listPositionResponse:U,alluser:(d==null?void 0:d.items)??[],listAllDepartmentResponse:(g==null?void 0:g.items)??[],allExternalOrgs:(p==null?void 0:p.items)??[],allScopedDepartments:(h==null?void 0:h.items)??[],allScopedEmployees:(q==null?void 0:q.items)??[],allDepratments:(o==null?void 0:o.items)??[],allDepartmentsCount:o==null?void 0:o.count,recordTypes:(u==null?void 0:u.items)??[],employeesResponse:d,currentEmployeesResponse:_,isLoading:K||O||S||$||N||j||x||D||v||P||G,error:L||M||C||H||Q||B||z||I||V||R||J}};export{le as u};
