PageSourceSearch

https://thechedet.com/_assets/admin.users-Bo4CrKGq.js

js thechedet.com collected 2026-09-25 07:44:01 UTC 4,783 bytes, 1 lines download raw bytes

1import{r as f,j as e,aX as S,aY as v,o as C,W as u,G as F,_ as w,aK as _}from"./vendor-BuFaoZ7W.js";import{s as U,B as j,t as V}from"./index-7cjzHoP-.js";import{I as g}from"./Input-BHizAjS-.js";import{S as E,a as A,b as D,c as P,d as T}from"./Select-Cqm0SRcN.js";import{D as k,a as B,b as I,c as R,e as q,f as L}from"./Dialog-JSWLgpD_.js";import{u as M,F as z,a as m,b as h,c as p,d as x}from"./Form-CWTH6NWS.js";import{B as O}from"./Badge-BTtDNiG_.js";import{U as y}from"./schema-C6OxlYY4.js";import"./Input.module-Dmb6Vdaa.js";import"./index-BiiqRTmU.js";const G="_container_f6ga5_1",H="_header_f6ga5_7",K="_title_f6ga5_13",W="_tableContainer_f6ga5_21",X="_table_f6ga5_21",Y="_th_f6ga5_34",J="_tr_f6ga5_43",Q="_td_f6ga5_51",Z="_actions_f6ga5_63",$="_emptyState_f6ga5_68",ee="_formFields_f6ga5_74",s={container:G,header:H,title:K,tableContainer:W,table:X,th:Y,tr:J,td:Q,actions:Z,emptyState:$,formFields:ee},N={super_admin:"Super Admin",editor:"Editor",publisher:"Publisher",media_manager:"Media Manager"},se=C({id:w().optional(),displayName:u().min(1,"Name is required"),email:u().email("Valid email required"),role:F(y),password:u().optional()}).refine(a=>!(!a.id&&(!a.password||a.password.trim()==="")),{message:"Password is required for new users",path:["password"]});function ae({user:a,onClose:o}){const{mutateAsync:d,isPending:n}=V(),l=M({schema:se,defaultValues:{id:a?.id,displayName:a?.displayName??"",email:a?.email??"",role:a?.role??"editor",password:""}}),c=async r=>{try{const t={...r};a&&(!t.password||t.password.trim()==="")&&delete t.password,await d(t),_.success(a?"User updated":"User added"),o()}catch(t){_.error(t.message||"Failed to save user")}};return e.jsx(z,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(c),children:[e.jsx(I,{children:e.jsx(R,{children:a?"Edit User":"Add User"})}),e.jsxs("div",{className:s.formFields,children:[e.jsxs(m,{name:"displayName",children:[e.jsx(h,{children:"Display Name"}),e.jsx(p,{children:e.jsx(g,{value:l.values.displayName,onChange:r=>l.setValues(t=>({...t,displayName:r.target.value})),placeholder:"Full Name"})}),e.jsx(x,{})]}),e.jsxs(m,{name:"email",children:[e.jsx(h,{children:"Email"}),e.jsx(p,{children:e.jsx(g,{type:"email",value:l.values.email,onChange:r=>l.setValues(t=>({...t,email:r.target.value})),placeholder:"[email protected]"})}),e.jsx(x,{})]}),e.jsxs(m,{name:"role",children:[e.jsx(h,{children:"Role"}),e.jsx(p,{children:e.jsxs(E,{value:l.values.role,onValueChange:r=>l.setValues(t=>({...t,role:r})),children:[e.jsx(A,{children:e.jsx(D,{placeholder:"Select role"})}),e.jsx(P,{children:y.map(r=>e.jsx(T,{value:r,children:N[r]},r))})]})}),e.jsx(x,{})]}),e.jsxs(m,{name:"password",children:[e.jsxs(h,{children:["Password ",a?"(Leave blank to keep unchanged)":"*"]}),e.jsx(p,{children:e.jsx(g,{type:"password",value:l.values.password??"",onChange:r=>l.setValues(t=>({...t,password:r.target.value})),placeholder:"Secure password"})}),e.jsx(x,{})]})]}),e.jsxs(q,{children:[e.jsx(L,{asChild:!0,children:e.jsx(j,{variant:"outline",type:"button",onClick:o,children:"Cancel"})}),e.jsx(j,{type:"submit",disabled:n,children:n?"Saving...":"Save User"})]})]})})}function pe(){const{data:a,isFetching:o}=U(),[d,n]=f.useState(!1),[l,c]=f.useState(),r=()=>{c(void 0),n(!0)},t=i=>{c(i),n(!0)},b=i=>{switch(i){case"super_admin":return"primary";case"publisher":return"secondary";case"editor":return"outline";default:return"outline"}};return e.jsxs("div",{className:s.container,children:[e.jsxs("div",{className:s.header,children:[e.jsx("h1",{className:s.title,children:"User Management"}),e.jsxs(j,{onClick:r,children:[e.jsx(S,{size:16})," Add User"]})]}),e.jsx("div",{className:s.tableContainer,children:e.jsxs("table",{className:s.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:s.th,children:"Name"}),e.jsx("th",{className:s.th,children:"Email"}),e.jsx("th",{className:s.th,children:"Role"}),e.jsx("th",{className:s.th,children:"Actions"})]})}),e.jsx("tbody",{children:o&&!a?e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:s.emptyState,children:"Loading..."})}):a?.items.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:s.emptyState,children:"No users found."})}):a?.items.map(i=>e.jsxs("tr",{className:s.tr,children:[e.jsx("td",{className:s.td,children:e.jsx("strong",{children:i.displayName})}),e.jsx("td",{className:s.td,children:i.email}),e.jsx("td",{className:s.td,children:e.jsx(O,{variant:b(i.role),children:N[i.role]||i.role})}),e.jsx("td",{className:s.td,children:e.jsx("div",{className:s.actions,children:e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>t(i),children:[e.jsx(v,{size:14})," Edit"]})})})]},i.id))})]})}),e.jsx(k,{open:d,onOpenChange:n,children:e.jsx(B,{children:d&&e.jsx(ae,{user:l,onClose:()=>n(!1)})})})]})}export{pe 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.