PageSourceSearch

https://glcacademy.fr/assets/LesCompetences-c3LSIzOK.js

js glcacademy.fr collected 2026-10-08 05:51:59 UTC 4,512 bytes, 1 lines download raw bytes

1import{r as t,s as l,h as i,j as e,B as o,C as g,e as C,q as v,v as D,L as N,I as B}from"./index-DuNqvBbR.js";import{A as q}from"./AppLayout-CznbCnew.js";import{D as P,a as T,b as _,c as z,e as F}from"./dialog-Bu91GZLk.js";import{A as I,a as H,b as G,c as K,d as M,e as R,f as J,g as Q}from"./alert-dialog-DJt-qi7w.js";import{P as U}from"./plus-DcF3CRiB.js";import{B as V}from"./briefcase-afYgDgOP.js";import{P as W}from"./pencil-akClkjHa.js";import{T as X}from"./trash-2-mlUX4Wgh.js";import"./AppSidebar-CHRnQteG.js";import"./skeleton-DIkGymNE.js";import"./collapsible-CnfUx8rI.js";import"./calendar-check-BQ5uL-Es.js";import"./target-8Cihj_F2.js";import"./book-open-BULitv2_.js";import"./lock-BTmQBVMX.js";import"./monitor-D_-ZkWde.js";import"./search-CYNmd2Km.js";import"./tag-CUQeD3im.js";import"./history-D8deafKD.js";const fe=()=>{const[u,y]=t.useState([]),[A,w]=t.useState(!0),[E,n]=t.useState(!1),[c,h]=t.useState(null),[r,m]=t.useState(""),[b,d]=t.useState(!1),[a,x]=t.useState(null);t.useEffect(()=>{p()},[]);const p=async()=>{try{const{data:s,error:j}=await l.from("ref_competences").select("*").order("intitule");if(j)throw j;y(s||[])}catch(s){i.error("Erreur lors du chargement des compétences"),console.error(s)}finally{w(!1)}},S=()=>{h(null),m(""),n(!0)},L=s=>{h(s),m(s.intitule),n(!0)},f=async()=>{if(!r.trim()){i.error("Le nom de la compétence est requis");return}try{if(c){const{error:s}=await l.from("ref_competences").update({intitule:r.trim()}).eq("id",c.id);if(s)throw s;i.success("Compétence modifiée")}else{const{error:s}=await l.from("ref_competences").insert({intitule:r.trim()});if(s)throw s;i.success("Compétence ajoutée")}n(!1),p()}catch(s){i.error(s.message||"Erreur lors de l'enregistrement")}},O=async()=>{if(a)try{const{error:s}=await l.from("ref_competences").delete().eq("id",a.id);if(s)throw s;i.success("Compétence supprimée"),d(!1),x(null),p()}catch(s){i.error(s.message||"Erreur lors de la suppression")}},k=s=>{x(s),d(!0)};return e.jsxs(q,{title:"Les Compétences",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("p",{className:"text-muted-foreground",children:"Gérez les compétences associées à vos formations"}),e.jsxs(o,{onClick:S,children:[e.jsx(U,{className:"h-4 w-4 mr-2"}),"Ajouter une compétence"]})]}),A?e.jsx("p",{className:"text-muted-foreground",children:"Chargement..."}):u.length===0?e.jsx(g,{children:e.jsxs(C,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(V,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Aucune compétence configurée"})]})}):e.jsx("div",{className:"grid gap-3",children:u.map(s=>e.jsx(g,{children:e.jsxs(C,{className:"flex items-center justify-between py-4 px-5",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(v,{className:D(s.intitule),children:s.intitule})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(o,{variant:"ghost",size:"icon",onClick:()=>L(s),children:e.jsx(W,{className:"h-4 w-4"})}),e.jsx(o,{variant:"ghost",size:"icon",className:"text-destructive hover:text-destructive",onClick:()=>k(s),children:e.jsx(X,{className:"h-4 w-4"})})]})]})},s.id))})]}),e.jsx(P,{open:E,onOpenChange:n,children:e.jsxs(T,{children:[e.jsx(_,{children:e.jsx(z,{children:c?"Modifier la compétence":"Ajouter une compétence"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"intitule",children:"Nom de la compétence"}),e.jsx(B,{id:"intitule",value:r,onChange:s=>m(s.target.value),placeholder:"Ex: Climatisation, Électricité...",onKeyDown:s=>s.key==="Enter"&&f()})]}),r.trim()&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Aperçu"}),e.jsx(v,{className:D(r.trim()),children:r.trim()})]})]}),e.jsxs(F,{children:[e.jsx(o,{variant:"outline",onClick:()=>n(!1),children:"Annuler"}),e.jsx(o,{onClick:f,children:c?"Enregistrer":"Ajouter"})]})]})}),e.jsx(I,{open:b,onOpenChange:d,children:e.jsxs(H,{children:[e.jsxs(G,{children:[e.jsx(K,{children:"Supprimer cette c
1ompétence ?"}),e.jsxs(M,{children:["La compétence « ",a==null?void 0:a.intitule," » sera supprimée définitivement. Cette action est irréversible."]})]}),e.jsxs(R,{children:[e.jsx(J,{children:"Annuler"}),e.jsx(Q,{onClick:O,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Supprimer"})]})]})})]})};export{fe 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.