Files
edr-platform/apps/edr-freight-web/backoffice/public/_um/assets/useEmployees-CygwM5u6.js
2026-06-13 14:32:26 +03:00

2 lines
1.4 KiB
JavaScript

import{l as s,w as r,n as i,o as w}from"./index-Db-xuq0b.js";const o={getEmployee:e=>s.get(`/employees/${e}`,{headers:r()}),getEmployeesListById:e=>s.get(`/employees/list/${e}`,{headers:r()}),getEmployeesWithUnitById:(e,t)=>s.get(`/employees/${e}/with-unit`,{headers:r(),params:t}),getUsersWithUnitById:(e,t)=>s.get(`/employees/${e}/active-with-unit`,{headers:r(),params:t}),getEmployeesWithOrganizationById:(e,t)=>s.get(`/employees/${e}/by-organization`,{headers:r(),params:t}),createEmployee:e=>s.post("/employees",e,{headers:r()}),updateEmployee:(e,t)=>s.put(`/employees/${e}`,t,{headers:r()}),deleteEmployee:e=>s.delete(`/employees/${e}`,{headers:r()})},f=({unitId:e,organizationId:t,params:y})=>{const{data:l,isLoading:n,isError:p,refetch:m}=i({queryKey:["employees",e],queryFn:async()=>{const{data:a}=await o.getUsersWithUnitById(e,{take:3e3});return a},enabled:!!e,staleTime:3e5,retry:!1}),{data:d,isLoading:g,isError:u,refetch:h}=i({queryKey:["employees",t,y],queryFn:async()=>{const{data:a}=await o.getEmployeesWithOrganizationById(t,y);return a},enabled:!!t,staleTime:300*1e3,retry:!1}),{mutate:c,isPending:E}=w({mutationFn:async a=>{const{data:B}=await o.getEmployee(a);return B}});return{employeesResponse:l,isLoading:n,isError:p,refetch:m,getEmployeeByDetails:c,isFetchingEmployee:E,refetchEmployeesByOrg:h,isErrorEmployeesByOrg:u,isLoadingEmployeesByOrg:g,employeesResponseByOrg:d}};export{o as e,f as u};