import{c as N,u as b,r as o,m as P,a as T,n as v,j as e,P as C,o as R,U as A,M as L,i as S}from"./index-e867d936.js";import{f as y,T as n}from"./_utils-98e246cc.js";const k=()=>{const r=N(),{t:i}=b(),[c,u]=o.useState(1),t=P(),l=T("users"),{data:s,isLoading:f,isError:x,refetch:p}=v("users",{params:{page:c}}),d=o.useMemo(()=>{if(!s)return!1;const{data:a,...w}=s;return w},[s]),g=o.useMemo(()=>s!=null&&s.data?s.data.filter(a=>a.id!==(t==null?void 0:t.id)):[],[s,t]),m=t==null?void 0:t.can({action:"update",targetModel:"users"}),j=()=>r("/users/invite"),h=m?a=>r(`/users/${a}`):void 0,E=m?async a=>{confirm(i(L.ON_DELETE_REQUEST_PROMPT))&&(await S.entries.delete("users",a),p())}:void 0,M=o.useMemo(()=>{if(l)return y(l)},[l]);return e.jsx(e.Fragment,{children:e.jsxs(C,{children:[e.jsxs("div",{className:"flex w-full flex-col justify-between gap-5 py-10 md:flex-row",children:[e.jsx("h1",{className:"text-3xl font-semibold capitalize",children:i("Users")}),e.jsx("div",{className:"flex items-center gap-5",children:e.jsxs(R,{color:"green",className:" items-center font-semibold uppercase",size:"md",onClick:j,children:[e.jsx("span",{className:"hidden md:block",children:i("Add new user")}),e.jsx(A,{className:"inline-block h-5 w-5 md:ml-3"})," "]})})]}),e.jsx(n,{isLoading:f||x,items:g,columns:M||[],onEditAction:h,onDeleteAction:E}),e.jsxs(n.Footer,{children:[d&&e.jsx(n.Metadata,{...d}),e.jsx(n.Pagination,{className:"ml-auto",total:(s==null?void 0:s.last_page)||1,page:c,onChange:u})]})]})})};export{k as default};
