mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
2 lines
2.7 KiB
JavaScript
2 lines
2.7 KiB
JavaScript
import{r as n,az as g,u as y,n as v,j as i}from"./index-Db-xuq0b.js";import{A as j}from"./AdvancedTable-CC9ioMU-.js";import{C as A,a as C,b,d as N}from"./card-BBWyxDss.js";import{u as S,A as U}from"./ArchivedUserColumnDefn-DQXeUrrA.js";import{f as I}from"./organizationService-DPKKJMFw.js";import{S as z}from"./FormFields-BA7SVWfi.js";import"./table-D3n3VABd.js";import"./select-BoQxM42A.js";import"./chevron-left-DCpEaNzo.js";import"./utils-BncSPdK1.js";import"./badge-D7JvaQeJ.js";import"./command-Cr0tMDDu.js";import"./search-CM5F2ZRy.js";import"./popover-X-j_SRnG.js";import"./Popover-CzANYrEa.js";import"./use-uncontrolled-C3HRHW6t.js";import"./separator-BaOOgzZX.js";import"./refresh-cw-JB7N413f.js";import"./organizationsService-BEVk8qa1.js";import"./alert-dialog-B5Y0wlSz.js";import"./useEmployeePostions-CMraotEg.js";import"./employeePositionsService-CkHoE9xG.js";import"./ellipsis-vertical-Cs1B3vez.js";import"./square-pen-B91TPB19.js";import"./user-plus-CBq7Z0dQ.js";import"./form-BeLK5rTt.js";import"./index.esm-BG4gweZJ.js";import"./label-CsFy6wpo.js";import"./multi-select-C9K8HXhI.js";import"./single-select-D9ZG1edj.js";const ne=()=>{const[o,c]=n.useState(0),p=g(),{t:m}=y(),{data:t,isLoading:u,error:E}=v({queryKey:["organizations"],queryFn:I,staleTime:300*1e3}),[s,d]=n.useState(null),f=e=>{d(e)},h=n.useMemo(()=>(t==null?void 0:t.items?.map(e=>({id:e.id,name:e.name,hierarchyType:"organization",value:e.units.length===1?e.units[0].id:"",children:Array.isArray(e.units)&&e.units.length>0?e.units?.map(r=>({id:r.id,name:r.name,hierarchyType:"unit",value:r.id,children:[]})):[]})))||[],[t,p]);n.useEffect(()=>{if(!s&&(t!=null&&t.items)){const e=t.items.flatMap(r=>r.units).find(r=>r.id);e&&d(e.id)}},[t,s]),n.useEffect(()=>{s&&sessionStorage.setItem("selectedArchiveUnitId",s)},[s]),n.useEffect(()=>{const e=sessionStorage.getItem("selectedArchiveUnitId");e&&d(e)},[]);const{data:a,refetch:x}=S(s??""),l=e=>{c(e)};return u?i.jsx("div",{className:"text-gray-900 dark:text-gray-100",children:m("loading")}):i.jsx("div",{className:"p-6 space-y-6",children:i.jsxs(A,{className:"col-span-2 shadow-none border-none bg-transparent px-0",children:[i.jsx(C,{className:"flex flex-row justify-between items-center px-0",children:i.jsx(b,{className:"text-xl font-semibold",children:m("setting.archivedUsers")})}),i.jsx("div",{className:"mb-4",children:i.jsx(z,{label:m("selectUnit"),options:h,value:s,onChange:f,collapsible:!0})}),i.jsx(N,{className:"px-0",children:i.jsx(j,{columns:U,data:(a==null?void 0:a.items)||[],tableName:"Archived Users",toolBarPosition:"right",itemCount:(a==null?void 0:a.count)||0,pageIndex:o,onPageChange:l,nextFunction:()=>l(o+1),prevFunction:()=>l(Math.max(o-1,0)),refresh:x})})]})})};export{ne as default};
|