import{r as s,j as a}from"./vendor-react-wBh_31cN.js";import{L as x}from"./vendor-router-D1GqFWiT.js";import{C as g,a as j,b as P,c as N}from"./card-BeQtvmcJ.js";import{S as C}from"./search-input-BWz7f2O1.js";import{A as v}from"./avatar-DDfx1nOU.js";import{V as d}from"./value-7N0Keti9.js";import{m as L,aA as b,aq as E,G as S,g as y,r as M}from"./index-dNe6i2rS.js";import{D as w}from"./data-table-Mt0DWBPO.js";import{P as D}from"./pagination-D1zFozYl.js";import{u as A}from"./useTitle-DQo_L6Ox.js";import{u as T}from"./index-DIs5Kizm.js";import{a as z}from"./any-BVxDk2A0.js";import{i as G}from"./includes-ucXR_9jq.js";import{f as I}from"./formatDistance-B6o-SXVU.js";import{ah as k}from"./vendor-icons-BUUmD6ht.js";import"./input-group-gxy3DSmS.js";import"./vendor-utils-OeoE2qq_.js";import"./input-DFI7JniT.js";import"./label-gPWmc6ow.js";import"./vendor-radix-BRyWS4bQ.js";import"./textarea-BJVuSob1.js";import"./tooltip-DFFgUYh6.js";import"./vendor-redux-CJZrIb6x.js";import"./vendor-grid-CeFlDWv4.js";import"./checkbox-BlA4MwH9.js";import"./skeleton-C7BaXix8.js";import"./BlinkingDots-CJK9OJE3.js";import"./LoadMore-Bg-Y-iGB.js";import"./table-a0YeQrHM.js";const c=10,H=[{header:"name",accessorKey:"name",meta:{primary:!0},cell:({getValue:e})=>a.jsx(d,{className:"block truncate",children:e()})},{header:"owner",id:"owner",accessorFn:e=>`${e.creator.firstname} ${e.creator.lastname}`,cell:({row:e})=>a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(v,{firstName:e.original.creator.firstname,lastName:e.original.creator.lastname,size:"sm"}),a.jsxs("span",{className:"text-sm",children:[e.original.creator.firstname," ",e.original.creator.lastname]})]})},{header:"last updated",accessorKey:"lastQuotaUpdate",cell:({getValue:e})=>a.jsxs(d,{children:[I(new Date(e()),new Date)," ago"]})},{id:"actions",header:"",enableSorting:!1,cell:({row:e})=>a.jsx(S,{asChild:!0,variant:"outline",size:"sm",children:a.jsxs(x,{to:y(M.settings.projects.edit,"",{pId:e.original.id}),children:[a.jsx(k,{className:"size-3.5"}),"Edit configuration"]})})}],fe=()=>{A("Projects");const[e,p]=s.useState(""),[t,m]=s.useState(1),{data:r,isLoading:f}=T(),n=s.useMemo(()=>(r==null?void 0:r.filter(({name:i,creator:{firstname:l,lastname:h}})=>z(G(e.toLowerCase()),L(b,[i,l,h]))).sort((i,l)=>i.name.localeCompare(l.name)))??[],[r,e]),o=Math.max(1,Math.ceil(n.length/c));s.useEffect(()=>{m(1)},[e]),s.useEffect(()=>{t>o&&m(o)},[t,o]);const u=s.useMemo(()=>n.slice((t-1)*c,t*c),[n,t]);return f?a.jsx(E,{}):a.jsxs(g,{className:"flex max-h-[calc(100vh-215px)] flex-col overflow-hidden",children:[a.jsx(j,{children:a.jsx(P,{children:"Projects"})}),a.jsxs(N,{className:"flex min-h-0 flex-1 flex-col",children:[a.jsx(C,{className:"w-full",disabled:!(r!=null&&r.length),value:e,placeholder:"search project by name or owner...",onChange:i=>p(i.target.value)}),a.jsx("div",{className:"mt-4 min-h-0 flex-1 overflow-auto",children:a.jsx(w,{columns:H,data:u,enableSorting:!0,emptyMessage:"No projects found"})}),o>1&&a.jsx(D,{className:"mt-4",currentPage:t,totalPages:o,onChange:m})]})]})};export{fe as ProjectsManagementList};
