import{y as O,u as w,az as S,r as c,j as e,B as l,A as I}from"./index-7T7TTikv.js";import{C as M,a as U,b as T,d as B}from"./card-_ldW-koX.js";import{S as P,a as R,b as F,c as K,d as L}from"./select--i8koVXg.js";import{A as v}from"./AdvancedTable-vWyUWUDX.js";import{u as E}from"./useOrganizations-CPt4mkXS.js";import{c as H,a as V,u as _}from"./useArchived-5V0W60Gf.js";import{A as f}from"./archive-restore-CbEMfc7_.js";import"./table-D_B7hhqb.js";import"./chevron-left-G_a9-f9o.js";import"./utils-N2wtfq7C.js";import"./badge-D4t6Wb1T.js";import"./command-B6S1IvD4.js";import"./search-y8VSu0lZ.js";import"./popover-CSKEA8hg.js";import"./Popover-BSKEfTKH.js";import"./use-uncontrolled-tg0LIUAX.js";import"./separator-BXi_hr72.js";import"./refresh-cw-B7fipPS4.js";import"./organizationsService-DIFVjoLn.js";import"./unitService-DTtkt-Pb.js";import"./positionService-BwPU5sNe.js";/**
 * @license lucide-react v0.513.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const q=[["path",{d:"M10 18v-7",key:"wt116b"}],["path",{d:"M11.12 2.198a2 2 0 0 1 1.76.006l7.866 3.847c.476.233.31.949-.22.949H3.474c-.53 0-.695-.716-.22-.949z",key:"1m329m"}],["path",{d:"M14 18v-7",key:"vav6t3"}],["path",{d:"M18 18v-7",key:"aexdmj"}],["path",{d:"M3 22h18",key:"8prr45"}],["path",{d:"M6 18v-7",key:"1ivflk"}]],G=O("landmark",q),ge=()=>{const{t:a}=w(),m=S(),[t,g]=c.useState("organizations"),{organizationsResponse:d}=E("Org",{take:300,skip:0}),o=(d==null?void 0:d.items)??[],[h,p]=c.useState("");!h&&o.length>0&&p(o[0].id);const{data:s,refetch:j}=H(),{data:n,refetch:z}=V(t==="units"&&h||void 0),u=c.useMemo(()=>(s==null?void 0:s.items)??s??[],[s]),x=c.useMemo(()=>(n==null?void 0:n.items)??n??[],[n]),{restoreUnit:y,isRestoringUnit:k,restoreOrganization:N,isRestoringOrganization:A}=_(),b=[{id:"name",header:a("organization.name","Name"),cell:({row:i})=>{var r;return m((r=i.original)==null?void 0:r.name)||"—"}},{id:"key",header:a("organization.key","Key"),accessorKey:"key"},{id:"actions",header:a("userIncomingretun.Actions","Actions"),cell:({row:i})=>e.jsxs(l,{size:"sm",variant:"outline",disabled:A,onClick:()=>N(i.original.id),className:"flex items-center gap-2 text-primary-700 hover:bg-primary-50",children:[e.jsx(f,{className:"h-4 w-4"}),a("archive.restore","Restore")]})}],C=[{id:"name",header:a("organization.name","Name"),cell:({row:i})=>{var r;return m((r=i.original)==null?void 0:r.name)||"—"}},{id:"key",header:a("organization.key","Key"),accessorKey:"key"},{id:"actions",header:a("userIncomingretun.Actions","Actions"),cell:({row:i})=>e.jsxs(l,{size:"sm",variant:"outline",disabled:k,onClick:()=>y(i.original.id),className:"flex items-center gap-2 text-primary-700 hover:bg-primary-50",children:[e.jsx(f,{className:"h-4 w-4"}),a("archive.restore","Restore")]})}];return e.jsx("div",{className:"p-6 space-y-6",children:e.jsxs(M,{className:"shadow-none border-none bg-transparent px-0",children:[e.jsx(U,{className:"flex flex-row justify-between items-center px-0",children:e.jsx(T,{className:"text-xl font-semibold",children:a("archive.archivedItems","Archived Items")})}),e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsxs(l,{variant:t==="organizations"?"default":"outline",onClick:()=>g("organizations"),className:"flex items-center gap-2",children:[e.jsx(G,{className:"h-4 w-4"}),a("archive.archivedOrganizations","Archived Organizations")]}),e.jsxs(l,{variant:t==="units"?"default":"outline",onClick:()=>g("units"),className:"flex items-center gap-2",children:[e.jsx(I,{className:"h-4 w-4"}),a("archive.archivedUnits","Archived Units")]})]}),t==="units"&&o.length>0&&e.jsxs("div",{className:"mb-4 w-full sm:w-1/2",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-200",children:a("organization.selectOrganization","Select Organization")}),e.jsxs(P,{value:h,onValueChange:i=>p(i),children:[e.jsx(R,{className:"mt-1 block w-full",children:e.jsx(F,{placeholder:a("organization.selectOrganization")})}),e.jsx(K,{children:o.map(i=>e.jsx(L,{value:i.id,children:m(i.name)},i.id))})]})]}),e.jsx(B,{className:"px-0",children:t==="organizations"?e.jsx(v,{columns:b,data:u,tableName:"ArchivedOrganizations",toolBarPosition:"right",itemCount:u.length,pageIndex:0,onPageChange:()=>{},nextFunction:()=>{},prevFunction:()=>{},refresh:j}):e.jsx(v,{columns:C,data:x,tableName:"ArchivedUnits",toolBarPosition:"right",itemCount:x.length,pageIndex:0,onPageChange:()=>{},nextFunction:()=>{},prevFunction:()=>{},refresh:z})})]})})};export{ge as default};
