PageSourceSearch

https://thestreamlinefactory.com/assets/AdminUsers-C-jv5QST.js

js thestreamlinefactory.com collected 2026-09-24 14:20:11 UTC 4,794 bytes, 1 lines download raw bytes

1import{r as t,j as e}from"./react-vendor-C-_weJGF.js";import{b as p,u as g,c}from"./query-DA-B5yju.js";import{g as f,B as b,s as d,a}from"./index-DiEum5Ju.js";import{A as m}from"./AdminLayout-Byts1X3Z.js";import{C as j}from"./ConfirmDialog-D19QEs3y.js";import{y as u,w as N,a5 as y}from"./icons-BZJMmL1V.js";import"./radix-CMA3xQgM.js";import"./supabase-BppBjPB2.js";import"./motion-CfmjrLVm.js";import"./logo-BWhOaj1e.js";function U(){const n=p(),{role:o}=f();t.useState(!1),t.useState(""),t.useState(""),t.useState("editor");const{data:i=[]}=g({queryKey:["admin-users"],queryFn:async()=>{const{data:s}=await d.from("user_roles").select("*");return s||[]},enabled:o==="super_admin"}),x=c({mutationFn:async({id:s,newRole:r})=>{const{error:l}=await d.from("user_roles").update({role:r}).eq("id",s);if(l)throw l},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-users"]}),a.success("Role updated!")},onError:()=>a.error("Failed to update role")}),h=c({mutationFn:async s=>{const{error:r}=await d.from("user_roles").delete().eq("id",s);if(r)throw r},onSuccess:()=>{n.invalidateQueries({queryKey:["admin-users"]}),a.success("User role removed")},onError:()=>a.error("Failed to remove")});return o!=="super_admin"?e.jsxs(m,{children:[e.jsx("h1",{className:"font-display text-2xl font-bold mb-4",children:"Users"}),e.jsxs("div",{className:"bg-card border border-border rounded-lg p-6 text-muted-foreground",children:[e.jsx(u,{className:"w-8 h-8 mx-auto mb-3 opacity-30"}),e.jsx("p",{className:"text-center font-medium",children:"Access Restricted"}),e.jsx("p",{className:"text-center text-sm mt-1",children:"Only Super Admins can manage user accounts and roles."})]})]}):e.jsxs(m,{children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-2xl font-bold",children:"Users & Roles"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Manage who has access to the admin panel and their permission level."})]})}),e.jsxs("div",{className:"bg-card border border-border rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-display font-medium text-xs text-muted-foreground uppercase tracking-wide mb-2",children:"Role Permissions"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{className:"bg-secondary rounded-md p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(N,{className:"w-4 h-4 text-primary"}),e.jsx("span",{className:"font-medium text-foreground",children:"Super Admin"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Full access to everything including user management, settings, and all content."})]}),e.jsxs("div",{className:"bg-secondary rounded-md p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(u,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium text-foreground",children:"Editor"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Can edit pages, blog posts, media, and SEO. Cannot manage users or critical settings."})]})]})]}),e.jsx("div",{className:"bg-muted/50 border border-border rounded-lg p-4 mb-6 text-sm text-muted-foreground",children:e.jsxs("p",{children:["💡 ",e.jsx("strong",{children:"To add a new admin user:"})," Have them sign up via the login page first, then add their User ID below with the desired role. You can find their User ID in the backend authentication panel."]})}),i.length===0?e.jsx("div",{className:"text-center py-12 text-muted-foreground bg-card border border-border rounded-lg",children:e.jsx("p",{className:"font-medium",children:"No admin users configured yet"})}):e.jsx("div",{className:"space-y-2",children:i.map(s=>e.jsxs("div",{className:"bg-card border border-border rounded-lg p-4 flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-mono text-foreground truncate",children:s.user_id}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Added ",new Date(s.created_at).toLocaleDateString()]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("select",{value:s.role,onChange:r=>x.mutate({id:s.id,newRole:r.target.value}),className:"bg-secondary border border-border rounded-md px-2 py-1 text-xs",children:[e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"super_admin",children:"Super Admin"})]}),e.jsx(j,{title:"Remove this user's admin access?",description:"They will no longer be able to log into the admin panel.",onConfirm:()=>h.mutate(s.id),trigger:e.jsx(b,{variant:"ghost",size:"sm",children:e.jsx(y,{className:"w-4 h-4 text-destructive"})})})]})]},s.id))})]})}export{U 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.