PageSourceSearch

https://maxskills.io/assets/AdminLmsFormateurs-sUqNIZAc.js

js maxskills.io collected 2026-09-24 15:04:20 UTC 9,223 bytes, 1 lines download raw bytes

1import{aa as G,a as U,r as t,c as F,d as q,j as e,H as r,I as X,aF as E,O as N,L as h,b4 as R,b5 as z,b6 as L,B as x,ax as W,aq as Y,Q as T,W as D,Y as M,Z as P,c5 as Z,N as J,X as V,t as u,s as p}from"./index-BJijipAU.js";import{T as ee,a as se,b as j,c as n,d as ae,e as a}from"./table-BiiUHJv2.js";import{S as te}from"./save-DmrMcl30.js";import"./i18n-DlcS6BNz.js";import"./index-paNpr7jU.js";const re=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]],ie=G("user-x",re),le={admin:"bg-primary/20 text-primary border-primary/30",agent:"bg-blue-500/20 text-blue-400 border-blue-500/30",company:"bg-purple-500/20 text-purple-400 border-purple-500/30",formateur:"bg-green-500/20 text-green-400 border-green-500/30",student:"bg-white/10 text-white/50 border-white/10"};function he(){const w=U(),[c,O]=t.useState(""),[f,y]=t.useState(!1),[o,S]=t.useState(""),[d,m]=t.useState(null),[A,C]=t.useState({fr:"",ar:"",en:""}),{data:Q,isLoading:B}=F({queryKey:["admin-formateurs",c],queryFn:()=>p.get("/api/v1/admin/formateurs",{params:c?{search:c}:{}}).then(s=>s.data)}),_=Q?.data??[],{data:H,isFetching:g}=F({queryKey:["admin-formateurs-search-users",o],queryFn:()=>p.get("/api/v1/admin/formateurs/search-users",{params:{search:o}}).then(s=>s.data),enabled:f}),k=H??[],i=q({mutationFn:s=>p.post(`/api/v1/admin/formateurs/${s}/toggle`).then(l=>l.data),onSuccess:s=>{u.success(s.message),w.invalidateQueries({queryKey:["admin-formateurs"]}),w.invalidateQueries({queryKey:["admin-formateurs-search-users"]})},onError:s=>u.error(s?.response?.data?.message??"Erreur lors de la mise à jour")}),b=q({mutationFn:({id:s,specialty:l})=>p.patch(`/api/v1/admin/formateurs/${s}`,{formateur_specialty:l}).then(v=>v.data),onSuccess:()=>{u.success("Spécialité mise à jour"),w.invalidateQueries({queryKey:["admin-formateurs"]}),m(null)},onError:()=>u.error("Erreur lors de la sauvegarde")}),K=s=>{m(s),C({fr:s.formateur_specialty?.fr??"",ar:s.formateur_specialty?.ar??"",en:s.formateur_specialty?.en??""})},I=()=>{d&&b.mutate({id:d.id,specialty:A})},$=t.useCallback(s=>{O(s.target.value)},[]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-white",children:"Formateurs LMS"}),e.jsx("p",{className:"text-white/40 text-sm mt-0.5",children:"Gérez les formateurs — agents, utilisateurs ou rôle dédié"})]}),e.jsxs(r,{onClick:()=>{y(!0),S("")},className:"bg-primary hover:bg-primary/90 text-white font-bold",children:[e.jsx(X,{className:"h-4 w-4 me-2"})," Affecter un formateur"]})]}),e.jsxs("div",{className:"relative w-72",children:[e.jsx(E,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-white/30"}),e.jsx(N,{placeholder:"Rechercher un formateur…",value:c,onChange:$,className:"pl-9 bg-[#1e1f25] border-white/10 text-white"})]}),e.jsx("div",{className:"border border-white/10 rounded-2xl overflow-hidden bg-[#1e1f25]/30",children:e.jsxs(ee,{children:[e.jsx(se,{className:"bg-[#1e1f25]",children:e.jsxs(j,{className:"border-white/10 hover:bg-transparent",children:[e.jsx(n,{className:"text-white/50",children:"Formateur"}),e.jsx(n,{className:"text-white/50",children:"Rôle principal"}),e.jsx(n,{className:"text-white/50",children:"Accès formateur"}),e.jsx(n,{className:"text-white/50",children:"Spécialité (fr)"}),e.jsx(n,{className:"text-white/50 text-end",children:"Actions"})]})}),e.jsx(ae,{children:B?e.jsx(j,{children:e.jsx(a,{colSpan:5,className:"text-center py-12 text-white/30",children:e.jsx(h,{className:"h-5 w-5 animate-spin mx-auto"})})}):_.length===0?e.jsx(j,{children:e.jsx(a,{colSpan:5,className:"text-center py-12 text-white/30",children:"Aucun formateur. Affectez-en un depuis la liste des utilisateurs."})}):_.map(s=>e.jsxs(j,{className:"border-white/5 hover:bg-white/5",children:[e.jsx(a,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(R,{className:"h-8 w-8",children:[e.jsx(z,{src:s.avatar??void 0}),e.jsx(L,{className:"bg-[#1e1f25] text-white text-xs",children:s.name[0]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white font-medium text-sm",children:s.name}),e.jsx("p",{className:"text-white/40 text-xs",children:s.email})]})]})}),e.jsx(a,{children:e.jsx(x,{variant:"outline",className:le[s.role]??"bg-white/10 text-white/50",children:s.role})}),e.jsx(a,{children:s.role==="admin"?e.jsx(x,{variant:"outline",className:"bg-primary/20 text-primary border-primary/30",children:"Admin (toujours)"}):s.role==="formateur"?e.jsx(x,{variant:"outline",className:"bg-green-500/20 text-green-400 border-green-500/30",children:"Rôle formateur"}):e.jsx(x,{variant:"outline",className:s.is_formateur?"bg-green-500/20 text-green-400 border-green-500/30":"bg-white/5 text-white/30 border-white/10",children:s.is_formateur?"Accès activé":"Accès désactivé"})}),e.jsx(a,{className:"text-white/60 text-sm max-w-[200px] truncate",children:s.formateur_specialty?.fr||e.jsx("span",{className:"text-white/20 italic",children:"—"})}),e.jsx(a,{className:"text-end",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(r,{variant:"ghost",size:"icon",className:"h-8 w-8 text-white/30 hover:text-white",onClick:()=>K(s),title:"Modifier la spécialité",children:e.jsx(W,{className:"h-4 w-4"})}),s.role!=="admin"&&e.jsx(r,{variant:"ghost",size:"icon",className:`h-8 w-8 ${s.is_formateur||s.role==="formateur"?"text-red-400 hover:text-red-300":"text-green-400 hover:text-green-300"}`,disabled:i.isPending,onClick:()=>i.mutate(s.id),title:s.is_formateur?"Révoquer l'accès formateur":"Activer l'accès formateur",children:i.isPending?e.jsx(h,{className:"h-4 w-4 animate-spin"}):s.is_formateur?e.jsx(ie,{className:"h-4 w-4"}):e.jsx(Y,{className:"h-4 w-4"})})]})})]},s.id))})]})}),e.jsx(T,{open:f,onOpenChange:y,children:e.jsxs(D,{className:"bg-[#1e1f25] border-white/10 text-white max-w-lg",children:[e.jsx(M,{children:e.jsxs(P,{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"h-5 w-5 text-primary"}),"Affecter un formateur"]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-white/50 text-sm",children:"Recherchez un utilisateur (peu importe son rôle) et activez son accès formateur."}),e.jsxs("div",{className:"relative",children:[e.jsx(E,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-white/30"}),e.jsx(N,{placeholder:"Nom ou email…",value:o,onChange:s=>S(s.target.value),className:"pl-9 bg-[#000216] border-white/10 text-white"})]}),e.jsxs("div",{className:"space-y-1 max-h-72 overflow-y-auto",children:[g&&e.jsx("div",{className:"text-center py-6 text-white/30",children:e.jsx(h,{className:"h-5 w-5 animate-spin mx-auto"})}),!g&&k.map(s=>e.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5 rounded-xl hover:bg-white/5 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(R,{className:"h-8 w-8",children:[e.jsx(z,{src:s.avatar??void 0}),e.jsx(L,{className:"bg-[#000216] text-white text-xs",children:s.name[0]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-white text-sm font-medium",children:s.name}),e.jsxs("p",{className:"text-white/40 text-xs",children:[s.email," · ",e.jsx("span",{className:"text-white/30",children:s.role})]})]})]}),e.jsx(r,{size:"sm",variant:s.is_formateur||s.role==="formateur"||s.role==="admin"?"outline":"default",className:s.is_formateur||s.role==="formateur"||s.role==="admin"?"border-white/10 text-white/40 hover:text-red-400 hover:border-red-500/30 h-7 text-xs":"bg-primary hover:bg-primary/90 text-white h-7 text-xs",disabled:s.role==="admin"||i.isPending,onClick:()=>{s.role!=="admin"&&i.mutate(s.id)},children:s.role==="admin"?"Admin":s.is_formateur||s.role==="formateur"?"Révoquer":"Affecter"})]},s.id)),!g&&o&&k.length===0&&e.jsx("p",{className:"text-center text-white/30 text-sm py-6",children:"Aucun utilisateur trouvé"})]})]})]})}),e.jsx(T,{open:!!d,onOpenChange:s=>{s||m(null)},children:e.jsxs(D,{className:"bg-[#1e1f25] border-white/10 text-white max-w-md",children:[e.jsx(M,{children:e.jsxs(P,{children:["Modifier la spécialité — ",d?.name]})}),e.jsxs("div",{className:"space-y-4",children:[["fr","ar","en"].map(s=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(J,{className:"text-white/60 uppercase text-xs tracking-widest",children:s}),e.jsx(N,{value:A[s],onChange:l=>C(v=>({...v,[s]:l.target.value})),placeholder:`Spécialité en ${s}…`,className:"bg-[#000216] border-white/10 text-white",dir:s==="ar"?"rtl":"ltr"})]},s)),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsxs(r,{variant:"outline",className:"border-white/10 text-white/60 hover:text-white",onClick:()=>m(null),children:[e.jsx(V,{className:"h-4 w-4 me-1"})," Annuler"]}),e.jsxs(r,{onClick:I,disabled:b.isPending,className:"bg-primary hover:bg-primary/90 text-white font-bold",children:[b.isPending?e.jsx(h,{className:"h-4 w-4 me-1 animate-spin"}):e.jsx(te,{className:"h-4 w-4 me-1"}),"Enregistrer"]})]})]})]})})]})}export{he 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.