PageSourceSearch

https://tresda.institute/assets/AdminUsers-CXwIU4Ap.js

js tresda.institute collected 2026-10-02 01:57:54 UTC 4,264 bytes, 1 lines download raw bytes

1import{u as g,r as h,b as f,a as b,j as e,I as j,m as o,q as N,g as v,h as w}from"./index-u0HMC9Vb.js";const y=["pending","student","mentor","team","admin"],R={pending:"bg-amber-100 text-amber-700",student:"bg-blue-100 text-blue-700",mentor:"bg-purple-100 text-purple-700",team:"bg-teal-100 text-teal-700",admin:"bg-stone-800 text-white"};function _(){const r=g(),[l,n]=h.useState(""),{data:c=[],isLoading:d}=f({queryKey:["all-users"],queryFn:()=>o.entities.User.list("-created_date",200)}),m=()=>`TR-00${Math.floor(1e3+Math.random()*9e3)}`,i=b({mutationFn:async({id:t,role:a,user:C})=>{await o.entities.User.update(t,{role:a}),(a==="student"||a==="mentor"||a==="team")&&(await o.entities.TRESDAProfile.filter({user_id:t})).length===0&&await o.entities.TRESDAProfile.create({user_id:t,student_id:m()})},onSuccess:()=>r.invalidateQueries({queryKey:["all-users"]})}),s=c.filter(t=>l?`${t.first_name||""} ${t.last_name||""} ${t.email||""}`.toLowerCase().includes(l.toLowerCase()):!0),x=s.filter(t=>!t.role||t.role==="pending"),u=s.filter(t=>t.role&&t.role!=="pending");return e.jsxs("div",{className:"bg-background min-h-screen",children:[e.jsx("header",{className:"border-b border-border px-5 lg:px-10 pt-8 pb-6",children:e.jsxs("div",{className:"max-w-3xl mx-auto",children:[e.jsx("p",{className:"text-[9px] font-meta uppercase tracking-[0.35em] text-muted-foreground",children:"Admin"}),e.jsx("h1",{className:"text-2xl font-display uppercase text-foreground mt-0.5",children:"User Access"}),e.jsx("p",{className:"text-[10px] font-meta text-muted-foreground mt-1",children:"Manually approve and assign roles to users."})]})}),e.jsxs("div",{className:"p-5 lg:px-10 max-w-3xl mx-auto pt-8",children:[e.jsx(j,{placeholder:"Search by name or email...",value:l,onChange:t=>n(t.target.value),className:"mb-6 bg-muted border-border h-9 text-sm"}),d?e.jsx("p",{className:"text-sm text-stone-400",children:"Loading..."}):e.jsxs(e.Fragment,{children:[x.length>0&&e.jsxs("div",{className:"mb-8",children:[e.jsxs("p",{className:"text-[9px] font-meta uppercase tracking-widest text-muted-foreground mb-3",children:["Awaiting Approval (",x.length,")"]}),e.jsx("div",{className:"space-y-2",children:x.map(t=>e.jsx(p,{user:t,onRoleChange:a=>i.mutate({id:t.id,role:a,user:t}),isPending:!0},t.id))})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-[9px] font-meta uppercase tracking-widest text-muted-foreground mb-3",children:["All Users (",u.length,")"]}),u.length===0?e.jsx("div",{className:"bg-muted p-8 text-center",children:e.jsx("p",{className:"text-[10px] font-meta uppercase tracking-widest text-muted-foreground",children:"No approved users yet."})}):e.jsx("div",{className:"space-y-2",children:u.map(t=>e.jsx(p,{user:t,onRoleChange:a=>i.mutate({id:t.id,role:a,user:t})},t.id))})]})]})]})]})}function p({user:r,onRoleChange:l,isPending:n}){const[c,d]=h.useState(!1),m=[r.first_name,r.last_name].filter(Boolean).join(" ")||r.full_name||r.email,i=r.role||"pending";return e.jsx("div",{className:`p-4 border ${n?"bg-amber-50/50 border-amber-200":"bg-card border-border"}`,children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(N,{className:"w-4 h-4 text-muted-foreground",strokeWidth:1.5})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground truncate",children:m}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:r.email})]}),e.jsxs("div",{className:"relative flex items-center gap-2",children:[e.jsx("span",{className:`text-[9px] font-meta uppercase tracking-widest px-2 py-0.5 ${R[i]||"bg-muted text-muted-foreground"}`,children:i}),e.jsx(v,{size:"sm",variant:n?"default":"outline",className:"text-xs h-7 ",onClick:()=>d(s=>!s),children:n?e.jsxs(e.Fragment,{children:[e.jsx(w,{className:"w-3 h-3 mr-1"})," Approve"]}):"Change Role"}),c&&e.jsx("div",{className:"absolute right-0 top-8 z-20 bg-card border border-border shadow-lg py-1 min-w-[120px]",children:y.filter(s=>s!==i).map(s=>e.jsx("button",{onClick:()=>{l(s),d(!1)},className:"w-full text-left px-4 py-2 text-xs text-foreground hover:bg-muted capitalize",children:s},s))})]})]})})}export{_ as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.