1 line
31 KiB
JavaScript
1 line
31 KiB
JavaScript
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8389],{5623:(e,a,t)=>{t.d(a,{A:()=>r});let r=(0,t(19946).A)("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]])},12318:(e,a,t)=>{t.d(a,{A:()=>r});let r=(0,t(19946).A)("UserPlus",[["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:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]])},13717:(e,a,t)=>{t.d(a,{A:()=>r});let r=(0,t(19946).A)("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]])},14503:(e,a,t)=>{t.d(a,{dj:()=>u,oR:()=>m});var r=t(12115);let s=0,l=new Map,i=e=>{if(l.has(e))return;let a=setTimeout(()=>{l.delete(e),c({type:"REMOVE_TOAST",toastId:e})},1e6);l.set(e,a)},n=(e,a)=>{switch(a.type){case"ADD_TOAST":return{...e,toasts:[a.toast,...e.toasts].slice(0,1)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(e=>e.id===a.toast.id?{...e,...a.toast}:e)};case"DISMISS_TOAST":{let{toastId:t}=a;return t?i(t):e.toasts.forEach(e=>{i(e.id)}),{...e,toasts:e.toasts.map(e=>e.id===t||void 0===t?{...e,open:!1}:e)}}case"REMOVE_TOAST":if(void 0===a.toastId)return{...e,toasts:[]};return{...e,toasts:e.toasts.filter(e=>e.id!==a.toastId)}}},o=[],d={toasts:[]};function c(e){d=n(d,e),o.forEach(e=>{e(d)})}function m(e){let{...a}=e,t=(s=(s+1)%Number.MAX_SAFE_INTEGER).toString(),r=()=>c({type:"DISMISS_TOAST",toastId:t});return c({type:"ADD_TOAST",toast:{...a,id:t,open:!0,onOpenChange:e=>{e||r()}}}),{id:t,dismiss:r,update:e=>c({type:"UPDATE_TOAST",toast:{...e,id:t}})}}function u(){let[e,a]=r.useState(d);return r.useEffect(()=>(o.push(a),()=>{let e=o.indexOf(a);e>-1&&o.splice(e,1)}),[e]),{...e,toast:m,dismiss:e=>c({type:"DISMISS_TOAST",toastId:e})}}},15630:(e,a,t)=>{t.d(a,{C1:()=>E,bL:()=>C});var r=t(12115),s=t(6101),l=t(46081),i=t(85185),n=t(5845),o=t(45503),d=t(11275),c=t(28905);t(47650);var m=t(99708),u=t(95155),f=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((e,a)=>{let t=r.forwardRef((e,t)=>{let{asChild:r,...s}=e,l=r?m.DX:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,u.jsx)(l,{...s,ref:t})});return t.displayName=`Primitive.${a}`,{...e,[a]:t}},{}),p="Checkbox",[h,x]=(0,l.A)(p),[g,y]=h(p),b=r.forwardRef((e,a)=>{let{__scopeCheckbox:t,name:l,checked:o,defaultChecked:d,required:c,disabled:m,value:p="on",onCheckedChange:h,form:x,...y}=e,[b,N]=r.useState(null),v=(0,s.s)(a,e=>N(e)),C=r.useRef(!1),E=!b||x||!!b.closest("form"),[S=!1,A]=(0,n.i)({prop:o,defaultProp:d,onChange:h}),R=r.useRef(S);return r.useEffect(()=>{let e=null==b?void 0:b.form;if(e){let a=()=>A(R.current);return e.addEventListener("reset",a),()=>e.removeEventListener("reset",a)}},[b,A]),(0,u.jsxs)(g,{scope:t,state:S,disabled:m,children:[(0,u.jsx)(f.button,{type:"button",role:"checkbox","aria-checked":w(S)?"mixed":S,"aria-required":c,"data-state":k(S),"data-disabled":m?"":void 0,disabled:m,value:p,...y,ref:v,onKeyDown:(0,i.m)(e.onKeyDown,e=>{"Enter"===e.key&&e.preventDefault()}),onClick:(0,i.m)(e.onClick,e=>{A(e=>!!w(e)||!e),E&&(C.current=e.isPropagationStopped(),C.current||e.stopPropagation())})}),E&&(0,u.jsx)(j,{control:b,bubbles:!C.current,name:l,value:p,checked:S,required:c,disabled:m,form:x,style:{transform:"translateX(-100%)"},defaultChecked:!w(d)&&d})]})});b.displayName=p;var N="CheckboxIndicator",v=r.forwardRef((e,a)=>{let{__scopeCheckbox:t,forceMount:r,...s}=e,l=y(N,t);return(0,u.jsx)(c.C,{present:r||w(l.state)||!0===l.state,children:(0,u.jsx)(f.span,{"data-state":k(l.state),"data-disabled":l.disabled?"":void 0,...s,ref:a,style:{pointerEvents:"none",...e.style}})})});v.displayName=N;var j=e=>{let{control:a,checked:t,bubbles:s=!0,defaultChecked:l,...i}=e,n=r.useRef(null),c=(0,o.Z)(t),m=(0,d.X)(a);r.useEffect(()=>{let e=n.current,a=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,"checked").set;if(c!==t&&a){let r=new Event("click",{bubbles:s});e.indeterminate=w(t),a.call(e,!w(t)&&t),e.dispatchEvent(r)}},[c,t,s]);let f=r.useRef(!w(t)&&t);return(0,u.jsx)("input",{type:"checkbox","aria-hidden":!0,defaultChecked:null!=l?l:f.current,...i,tabIndex:-1,ref:n,style:{...e.style,...m,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})};function w(e){return"indeterminate"===e}function k(e){return w(e)?"indeterminate":e?"checked":"unchecked"}var C=b,E=v},53999:(e,a,t)=>{t.d(a,{cn:()=>l});var r=t(52596),s=t(39688);function l(){for(var e=arguments.length,a=Array(e),t=0;t<e;t++)a[t]=arguments[t];return(0,s.QP)((0,r.$)(a))}},58389:(e,a,t)=>{t.d(a,{UsersTable:()=>w});var r=t(95155),s=t(12115),l=t(88524),i=t(97168),n=t(12108),o=t(89852),d=t(5623),c=t(13717),m=t(12318),u=t(19946);let f=(0,u.A)("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]),p=(0,u.A)("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]),h=(0,u.A)("LockOpen",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);var x=t(74126),g=t(67133),y=t(14503),b=t(99840),N=t(82714),v=t(95139);function j(e){let{open:a,onOpenChange:t,onAfterClose:l,triggerComponent:i,children:n,className:o}=e,d=(0,s.useCallback)(e=>{t(e),!e&&l&&setTimeout(l,300)},[t,l]);return(0,r.jsxs)(b.lG,{open:a,onOpenChange:d,children:[i&&(0,r.jsx)(b.zM,{asChild:!0,children:i}),(0,r.jsx)(b.Cf,{className:o,children:n})]})}function w(e){let{userRole:a=[]}=e,{data:t,status:u}=(0,n.useSession)(),[w,k]=(0,s.useState)([]),[C,E]=(0,s.useState)([]),[S,A]=(0,s.useState)(!0),[R,T]=(0,s.useState)(1),[L,_]=(0,s.useState)(""),[O,D]=(0,s.useState)(!1),[M,F]=(0,s.useState)(!1),[J,U]=(0,s.useState)(!1),[z,P]=(0,s.useState)(null),[I,H]=(0,s.useState)({username:"",lastName:"",firstName:"",email:"",password:"",roles:[],enabled:!0});(0,s.useEffect)(()=>{V(),q()},[]);let q=async()=>{try{let e=await fetch("/api/roles");if(!e.ok)throw Error("Failed to fetch roles");let a=await e.json();E(a)}catch(e){console.error("Error fetching roles:",e),(0,y.oR)({title:"Erreur",description:"Erreur lors de la r\xe9cup\xe9ration des r\xf4les",variant:"destructive"})}},V=async()=>{try{A(!0);let e=await fetch("/api/users"),a=await e.json();k(a)}catch(e){console.error("Error fetching users:",e),(0,y.oR)({title:"Erreur",description:"Erreur lors de la r\xe9cup\xe9ration des utilisateurs",variant:"destructive"})}finally{A(!1)}},$=async e=>{e.preventDefault();try{let e=await fetch("/api/users",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...I,firstName:I.firstName,lastName:I.lastName})}),a=await e.json();if(!e.ok)throw Error(a.error||"Erreur lors de la cr\xe9ation de l'utilisateur");k(e=>[...e,a.user]),D(!1),H({username:"",firstName:"",lastName:"",email:"",password:"",roles:[],enabled:!0}),(0,y.oR)({title:"Succ\xe8s",description:"L'utilisateur a \xe9t\xe9 cr\xe9\xe9 avec succ\xe8s"})}catch(e){(0,y.oR)({title:"Erreur",description:e instanceof Error?e.message:"Une erreur est survenue",variant:"destructive"})}},X=async e=>{let a=w.find(a=>a.id===e);a&&(P(a),H({username:a.username,firstName:a.firstName||"",lastName:a.lastName||"",email:a.email||"",password:"",roles:[],enabled:a.enabled}),F(!0))},G=async e=>{let a=w.find(a=>a.id===e);a&&(P(a),H(e=>({...e,roles:a.roles||[],username:a.username,firstName:a.firstName||"",lastName:a.lastName||"",email:a.email||""})),U(!0))},Z=async()=>{if(z)try{if(!(await fetch("/api/users/".concat(z.id,"/roles"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({roles:I.roles})})).ok)throw Error("Erreur lors de la mise \xe0 jour des r\xf4les");await V(),U(!1),P(null),H(e=>({...e,roles:[]})),(0,y.oR)({title:"Succ\xe8s",description:"Les r\xf4les ont \xe9t\xe9 mis \xe0 jour avec succ\xe8s"})}catch(e){(0,y.oR)({title:"Erreur",description:e instanceof Error?e.message:"Une erreur est survenue",variant:"destructive"})}},B=async e=>{if(e.preventDefault(),z)try{if(!(await fetch("/api/users/".concat(z.id),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({firstName:I.firstName,lastName:I.lastName,email:I.email})})).ok)throw Error("Erreur lors de la modification de l'utilisateur");await V(),H({username:"",lastName:"",firstName:"",email:"",password:"",roles:[],enabled:!0}),F(!1),P(null),(0,y.oR)({title:"Succ\xe8s",description:"L'utilisateur a \xe9t\xe9 modifi\xe9 avec succ\xe8s"})}catch(e){(0,y.oR)({title:"Erreur",description:e instanceof Error?e.message:"Une erreur est survenue",variant:"destructive"})}},K=async(e,a)=>{try{let t=await fetch("/api/users?id=".concat(e,"&email=").concat(encodeURIComponent(a)),{method:"DELETE"}),r=await t.json();if(!t.ok)throw Error(r.error||"Erreur lors de la suppression de l'utilisateur");k(a=>a.filter(a=>a.id!==e)),(0,y.oR)({title:"Succ\xe8s",description:"L'utilisateur a \xe9t\xe9 supprim\xe9 avec succ\xe8s"})}catch(e){(0,y.oR)({title:"Erreur",description:e instanceof Error?e.message:"Une erreur est survenue",variant:"destructive"})}},Q=async e=>{let a=prompt("Entrez le nouveau mot de passe temporaire:");if(a)try{if(!(await fetch("/api/users/".concat(e,"/password"),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:a,temporary:!0})})).ok)throw Error("Erreur lors du changement de mot de passe");(0,y.oR)({title:"Succ\xe8s",description:"Le mot de passe temporaire a \xe9t\xe9 d\xe9fini avec succ\xe8s. L'utilisateur devra le changer \xe0 sa premi\xe8re connexion."})}catch(e){(0,y.oR)({title:"Erreur",description:e instanceof Error?e.message:"Une erreur est survenue",variant:"destructive"})}},Y=async(e,a)=>{try{if(!(await fetch("/api/users/".concat(e),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!a})})).ok)throw Error("Erreur lors de la modification du statut de l'utilisateur");k(t=>t.map(t=>t.id===e?{...t,enabled:!a}:t)),(0,y.oR)({title:"Succ\xe8s",description:"L'utilisateur a \xe9t\xe9 ".concat(a?"d\xe9sactiv\xe9":"activ\xe9"," avec succ\xe8s")})}catch(e){(0,y.oR)({title:"Erreur",description:e instanceof Error?e.message:"Une erreur est survenue",variant:"destructive"})}},W=(0,s.useMemo)(()=>{let e=w;return L&&(e=e.filter(e=>{var a,t,r;return e.username.toLowerCase().includes(L.toLowerCase())||(null==(a=e.email)?void 0:a.toLowerCase().includes(L.toLowerCase()))||(null==(t=e.firstName)?void 0:t.toLowerCase().includes(L.toLowerCase()))||(null==(r=e.lastName)?void 0:r.toLowerCase().includes(L.toLowerCase()))})),e},[w,L]);W.length;let ee=W.slice((R-1)*10,10*R),ea=(0,s.useCallback)(()=>{H({username:"",lastName:"",firstName:"",email:"",password:"",roles:[],enabled:!0})},[]),et=(0,s.useCallback)(()=>{H({username:"",lastName:"",firstName:"",email:"",password:"",roles:[],enabled:!0}),P(null)},[]),er=(0,s.useCallback)(()=>{H(e=>({...e,roles:[]})),P(null)},[]);return t?S?(0,r.jsx)("div",{className:"text-center p-4",children:"Loading..."}):(0,r.jsxs)("div",{className:"space-y-4 p-6 bg-gray-100 rounded-lg",children:[(0,r.jsxs)("div",{className:"flex justify-between items-center",children:[(0,r.jsx)(o.p,{type:"text",placeholder:"Rechercher un utilisateur...",value:L,onChange:e=>_(e.target.value),className:"max-w-sm bg-white text-gray-900 border-gray-300"}),(0,r.jsxs)(j,{open:O,onOpenChange:D,onAfterClose:ea,triggerComponent:(0,r.jsx)(i.$,{className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Ajouter un utilisateur"}),className:"max-h-[85vh] overflow-y-auto bg-white text-black border border-gray-300",children:[(0,r.jsx)(b.c7,{children:(0,r.jsx)(b.L3,{className:"text-gray-900",children:"Nouvel Utilisateur"})}),(0,r.jsxs)("form",{onSubmit:$,className:"space-y-3",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(N.J,{htmlFor:"username",className:"text-gray-900",children:"Nom d'utilisateur"}),(0,r.jsx)(o.p,{id:"username",value:I.username,onChange:e=>H(a=>({...a,username:e.target.value.trim()})),required:!0,className:"bg-white text-gray-900 border-gray-300"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(N.J,{htmlFor:"email",className:"text-gray-900",children:"Email"}),(0,r.jsx)(o.p,{id:"email",type:"email",value:I.email,onChange:e=>H(a=>({...a,email:e.target.value.trim()})),required:!0,className:"bg-white text-gray-900 border-gray-300"})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(N.J,{htmlFor:"firstName",className:"text-gray-900",children:"Pr\xe9nom"}),(0,r.jsx)(o.p,{id:"firstName",value:I.firstName,onChange:e=>H(a=>({...a,firstName:e.target.value.trim()})),required:!0,className:"bg-white text-gray-900 border-gray-300"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(N.J,{htmlFor:"lastName",className:"text-gray-900",children:"Nom"}),(0,r.jsx)(o.p,{id:"lastName",value:I.lastName,onChange:e=>H(a=>({...a,lastName:e.target.value.trim()})),required:!0,className:"bg-white text-gray-900 border-gray-300"})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(N.J,{htmlFor:"password",className:"text-gray-900",children:"Mot de passe"}),(0,r.jsx)(o.p,{id:"password",type:"password",value:I.password,onChange:e=>H(a=>({...a,password:e.target.value})),required:!0,className:"bg-white text-gray-900 border-gray-300"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(N.J,{className:"text-gray-900",children:"R\xf4les"}),(0,r.jsx)("div",{className:"grid grid-cols-2 gap-2 max-h-[120px] overflow-y-auto border border-gray-300 rounded-md p-2 bg-white",children:C.map(e=>(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)(v.S,{id:"role-".concat(e.id),checked:I.roles.includes(e.name),onCheckedChange:a=>{H(t=>({...t,roles:a?[...t.roles,e.name]:t.roles.filter(a=>a!==e.name)}))},className:"border-gray-500"}),(0,r.jsx)(N.J,{htmlFor:"role-".concat(e.id),className:"text-sm text-gray-900",children:e.name})]},e.id))})]}),(0,r.jsx)(i.$,{type:"submit",className:"w-full bg-blue-600 hover:bg-blue-700 text-white",children:"Cr\xe9er Utilisateur"})]})]})]}),(0,r.jsxs)(l.XI,{className:"bg-white border border-gray-300 rounded-md",children:[(0,r.jsx)(l.A0,{className:"bg-gray-50",children:(0,r.jsxs)(l.Hj,{children:[(0,r.jsx)(l.nd,{className:"text-gray-900",children:"Username"}),(0,r.jsx)(l.nd,{className:"text-gray-900",children:"First Name"}),(0,r.jsx)(l.nd,{className:"text-gray-900",children:"Last Name"}),(0,r.jsx)(l.nd,{className:"text-gray-900",children:"Email"}),(0,r.jsx)(l.nd,{className:"text-gray-900",children:"Created At"}),(0,r.jsx)(l.nd,{className:"text-gray-900",children:"Roles"}),(0,r.jsx)(l.nd,{className:"text-gray-900 text-right",children:"Actions"})]})}),(0,r.jsx)(l.BF,{children:ee.map(e=>(0,r.jsxs)(l.Hj,{className:"hover:bg-gray-50 border-t border-gray-200",children:[(0,r.jsx)(l.nA,{className:"text-gray-900",children:e.username}),(0,r.jsx)(l.nA,{className:"text-gray-900",children:e.firstName||"-"}),(0,r.jsx)(l.nA,{className:"text-gray-900",children:e.lastName||"-"}),(0,r.jsx)(l.nA,{className:"text-gray-900",children:e.email||"-"}),(0,r.jsx)(l.nA,{className:"text-gray-900",children:new Date(e.createdTimestamp).toLocaleDateString()}),(0,r.jsx)(l.nA,{className:"text-gray-900",children:(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:(e.roles||[]).map(e=>(0,r.jsx)("span",{className:"inline-flex items-center rounded-full bg-blue-50 px-2 py-1 text-xs font-medium text-blue-700 ring-1 ring-inset ring-blue-700/10",children:e},e))})}),(0,r.jsx)(l.nA,{className:"text-gray-900 text-right",children:(0,r.jsxs)(g.rI,{children:[(0,r.jsx)(g.ty,{asChild:!0,children:(0,r.jsxs)(i.$,{variant:"ghost",className:"h-8 w-8 p-0",children:[(0,r.jsx)("span",{className:"sr-only",children:"Open menu"}),(0,r.jsx)(d.A,{className:"h-4 w-4"})]})}),(0,r.jsxs)(g.SQ,{align:"end",className:"bg-white border border-gray-300",children:[(0,r.jsx)(g.lp,{className:"text-gray-900",children:"Actions"}),(0,r.jsxs)(g._2,{onClick:()=>X(e.id),className:"text-gray-900 hover:bg-gray-100",children:[(0,r.jsx)(c.A,{className:"mr-2 h-4 w-4"}),"Modifier"]}),(0,r.jsxs)(g._2,{onClick:()=>G(e.id),className:"text-gray-900 hover:bg-gray-100",children:[(0,r.jsx)(m.A,{className:"mr-2 h-4 w-4"}),"G\xe9rer les r\xf4les"]}),(0,r.jsxs)(g._2,{onClick:()=>Q(e.id),className:"text-gray-900 hover:bg-gray-100",children:[(0,r.jsx)(f,{className:"mr-2 h-4 w-4"}),"Changer le mot de passe"]}),(0,r.jsx)(g._2,{onClick:()=>Y(e.id,e.enabled),className:"text-gray-900 hover:bg-gray-100",children:e.enabled?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(p,{className:"mr-2 h-4 w-4"}),"D\xe9sactiver"]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(h,{className:"mr-2 h-4 w-4"}),"Activer"]})}),(0,r.jsx)(g.mB,{}),(0,r.jsxs)(g._2,{className:"text-red-600 hover:bg-red-50 hover:text-red-700",onClick:()=>K(e.id,e.email),children:[(0,r.jsx)(x.A,{className:"mr-2 h-4 w-4"}),"Supprimer"]})]})]})})]},e.id))})]}),(0,r.jsxs)(j,{open:M,onOpenChange:F,onAfterClose:et,className:"bg-white text-black border border-gray-300",children:[(0,r.jsx)(b.c7,{children:(0,r.jsx)(b.L3,{className:"text-gray-900",children:"Modifier l'utilisateur"})}),(0,r.jsxs)("form",{onSubmit:B,className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(N.J,{htmlFor:"edit-firstName",className:"text-gray-900",children:"Pr\xe9nom"}),(0,r.jsx)(o.p,{id:"edit-firstName",value:I.firstName,onChange:e=>H(a=>({...a,firstName:e.target.value})),className:"bg-white text-gray-900 border-gray-300",autoFocus:!0})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(N.J,{htmlFor:"edit-lastName",className:"text-gray-900",children:"Nom"}),(0,r.jsx)(o.p,{id:"edit-lastName",value:I.lastName,onChange:e=>H(a=>({...a,lastName:e.target.value})),className:"bg-white text-gray-900 border-gray-300"})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(N.J,{htmlFor:"edit-email",className:"text-gray-900",children:"Email"}),(0,r.jsx)(o.p,{id:"edit-email",type:"email",value:I.email,onChange:e=>H(a=>({...a,email:e.target.value})),className:"bg-white text-gray-900 border-gray-300"})]}),(0,r.jsxs)("div",{className:"flex justify-end space-x-2",children:[(0,r.jsx)(i.$,{type:"button",variant:"outline",onClick:()=>{F(!1),P(null),H({username:"",lastName:"",firstName:"",email:"",password:"",roles:[],enabled:!0})},className:"border-gray-300 text-gray-800 hover:bg-gray-100",children:"Annuler"}),(0,r.jsx)(i.$,{type:"submit",className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Modifier"})]})]})]}),(0,r.jsxs)(j,{open:J,onOpenChange:U,onAfterClose:er,className:"bg-white text-black border border-gray-300",children:[(0,r.jsx)(b.c7,{children:(0,r.jsxs)(b.L3,{className:"text-gray-900",children:["G\xe9rer les r\xf4les pour ",null==z?void 0:z.username]})}),(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(N.J,{className:"text-gray-900",children:"R\xf4les disponibles"}),(0,r.jsx)("div",{className:"grid grid-cols-2 gap-2 max-h-[200px] overflow-y-auto border border-gray-300 rounded-md p-2 bg-white",children:C.map(e=>(0,r.jsxs)("div",{className:"flex items-center space-x-2 p-2 rounded-md hover:bg-gray-100",children:[(0,r.jsx)(v.S,{id:"manage-role-".concat(e.id),checked:I.roles.includes(e.name),onCheckedChange:a=>{H(t=>({...t,roles:a?[...t.roles,e.name]:t.roles.filter(a=>a!==e.name)}))},className:"border-gray-500"}),(0,r.jsx)(N.J,{htmlFor:"manage-role-".concat(e.id),className:"text-sm text-gray-900",children:e.name})]},e.id))})]}),(0,r.jsxs)("div",{className:"flex justify-end space-x-2",children:[(0,r.jsx)(i.$,{variant:"outline",onClick:()=>{U(!1),P(null),H(e=>({...e,roles:[]}))},className:"border-gray-300 text-gray-800 hover:bg-gray-100",children:"Annuler"}),(0,r.jsx)(i.$,{onClick:Z,className:"bg-blue-600 hover:bg-blue-700 text-white",children:"Mettre \xe0 jour les r\xf4les"})]})]})]})]}):null}},67133:(e,a,t)=>{t.d(a,{SQ:()=>u,_2:()=>f,lp:()=>p,mB:()=>h,rI:()=>c,ty:()=>m});var r=t(95155),s=t(12115),l=t(73447),i=t(13052),n=t(5196),o=t(9428),d=t(53999);let c=l.bL,m=l.l9;l.YJ,l.ZL,l.Pb,l.z6,s.forwardRef((e,a)=>{let{className:t,inset:s,children:n,...o}=e;return(0,r.jsxs)(l.ZP,{ref:a,className:(0,d.cn)("flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",s&&"pl-8",t),...o,children:[n,(0,r.jsx)(i.A,{className:"ml-auto"})]})}).displayName=l.ZP.displayName,s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,r.jsx)(l.G5,{ref:a,className:(0,d.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...s})}).displayName=l.G5.displayName;let u=s.forwardRef((e,a)=>{let{className:t,sideOffset:s=4,...i}=e;return(0,r.jsx)(l.ZL,{children:(0,r.jsx)(l.UC,{ref:a,sideOffset:s,className:(0,d.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...i})})});u.displayName=l.UC.displayName;let f=s.forwardRef((e,a)=>{let{className:t,inset:s,...i}=e;return(0,r.jsx)(l.q7,{ref:a,className:(0,d.cn)("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",s&&"pl-8",t),...i})});f.displayName=l.q7.displayName,s.forwardRef((e,a)=>{let{className:t,children:s,checked:i,...o}=e;return(0,r.jsxs)(l.H_,{ref:a,className:(0,d.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:i,...o,children:[(0,r.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,r.jsx)(l.VF,{children:(0,r.jsx)(n.A,{className:"h-4 w-4"})})}),s]})}).displayName=l.H_.displayName,s.forwardRef((e,a)=>{let{className:t,children:s,...i}=e;return(0,r.jsxs)(l.hN,{ref:a,className:(0,d.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...i,children:[(0,r.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,r.jsx)(l.VF,{children:(0,r.jsx)(o.A,{className:"h-2 w-2 fill-current"})})}),s]})}).displayName=l.hN.displayName;let p=s.forwardRef((e,a)=>{let{className:t,inset:s,...i}=e;return(0,r.jsx)(l.JU,{ref:a,className:(0,d.cn)("px-2 py-1.5 text-sm font-semibold",s&&"pl-8",t),...i})});p.displayName=l.JU.displayName;let h=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,r.jsx)(l.wv,{ref:a,className:(0,d.cn)("-mx-1 my-1 h-px bg-muted",t),...s})});h.displayName=l.wv.displayName},72797:(e,a,t)=>{t.d(a,{b:()=>o});var r=t(12115);t(47650);var s=t(99708),l=t(95155),i=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((e,a)=>{let t=r.forwardRef((e,t)=>{let{asChild:r,...i}=e,n=r?s.DX:a;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,l.jsx)(n,{...i,ref:t})});return t.displayName=`Primitive.${a}`,{...e,[a]:t}},{}),n=r.forwardRef((e,a)=>(0,l.jsx)(i.label,{...e,ref:a,onMouseDown:a=>{var t;a.target.closest("button, input, select, textarea")||(null==(t=e.onMouseDown)||t.call(e,a),!a.defaultPrevented&&a.detail>1&&a.preventDefault())}}));n.displayName="Label";var o=n},74126:(e,a,t)=>{t.d(a,{A:()=>r});let r=(0,t(19946).A)("Trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]])},82714:(e,a,t)=>{t.d(a,{J:()=>d});var r=t(95155),s=t(12115),l=t(72797),i=t(74466),n=t(53999);let o=(0,i.F)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),d=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,r.jsx)(l.b,{ref:a,className:(0,n.cn)(o(),t),...s})});d.displayName=l.b.displayName},88524:(e,a,t)=>{t.d(a,{A0:()=>n,BF:()=>o,Hj:()=>d,XI:()=>i,nA:()=>m,nd:()=>c});var r=t(95155),s=t(12115),l=t(53999);let i=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,r.jsx)("div",{className:"relative w-full overflow-auto",children:(0,r.jsx)("table",{ref:a,className:(0,l.cn)("w-full caption-bottom text-sm",t),...s})})});i.displayName="Table";let n=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,r.jsx)("thead",{ref:a,className:(0,l.cn)("[&_tr]:border-b",t),...s})});n.displayName="TableHeader";let o=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,r.jsx)("tbody",{ref:a,className:(0,l.cn)("[&_tr:last-child]:border-0",t),...s})});o.displayName="TableBody",s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,r.jsx)("tfoot",{ref:a,className:(0,l.cn)("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",t),...s})}).displayName="TableFooter";let d=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,r.jsx)("tr",{ref:a,className:(0,l.cn)("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",t),...s})});d.displayName="TableRow";let c=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,r.jsx)("th",{ref:a,className:(0,l.cn)("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0",t),...s})});c.displayName="TableHead";let m=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,r.jsx)("td",{ref:a,className:(0,l.cn)("p-4 align-middle [&:has([role=checkbox])]:pr-0",t),...s})});m.displayName="TableCell",s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,r.jsx)("caption",{ref:a,className:(0,l.cn)("mt-4 text-sm text-muted-foreground",t),...s})}).displayName="TableCaption"},89852:(e,a,t)=>{t.d(a,{p:()=>i});var r=t(95155),s=t(12115),l=t(53999);let i=s.forwardRef((e,a)=>{let{className:t,type:s,...i}=e;return(0,r.jsx)("input",{type:s,className:(0,l.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:a,...i})});i.displayName="Input"},95139:(e,a,t)=>{t.d(a,{S:()=>o});var r=t(95155),s=t(12115),l=t(15630),i=t(5196),n=t(53999);let o=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,r.jsx)(l.bL,{ref:a,className:(0,n.cn)("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...s,children:(0,r.jsx)(l.C1,{className:(0,n.cn)("flex items-center justify-center text-current"),children:(0,r.jsx)(i.A,{className:"h-4 w-4"})})})});o.displayName=l.bL.displayName},97168:(e,a,t)=>{t.d(a,{$:()=>d,r:()=>o});var r=t(95155),s=t(12115),l=t(99708),i=t(74466),n=t(53999);let o=(0,i.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),d=s.forwardRef((e,a)=>{let{className:t,variant:s,size:i,asChild:d=!1,...c}=e,m=d?l.DX:"button";return(0,r.jsx)(m,{className:(0,n.cn)(o({variant:s,size:i,className:t})),ref:a,...c})});d.displayName="Button"},99840:(e,a,t)=>{t.d(a,{Cf:()=>u,Es:()=>p,L3:()=>h,ZJ:()=>c,c7:()=>f,lG:()=>o,rr:()=>x,zM:()=>d});var r=t(95155),s=t(12115),l=t(45821),i=t(54416),n=t(53999);let o=l.bL,d=l.l9,c=l.ZL;l.bm;let m=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,r.jsx)(l.hJ,{ref:a,className:(0,n.cn)("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...s})});m.displayName=l.hJ.displayName;let u=s.forwardRef((e,a)=>{let{className:t,children:s,...o}=e;return(0,r.jsxs)(c,{children:[(0,r.jsx)(m,{}),(0,r.jsxs)(l.UC,{ref:a,className:(0,n.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-white p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...o,children:[s,(0,r.jsxs)(l.bm,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,r.jsx)(i.A,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});u.displayName=l.UC.displayName;let f=e=>{let{className:a,...t}=e;return(0,r.jsx)("div",{className:(0,n.cn)("flex flex-col space-y-1.5 text-center sm:text-left",a),...t})};f.displayName="DialogHeader";let p=e=>{let{className:a,...t}=e;return(0,r.jsx)("div",{className:(0,n.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",a),...t})};p.displayName="DialogFooter";let h=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,r.jsx)(l.hE,{ref:a,className:(0,n.cn)("text-lg font-semibold leading-none tracking-tight",t),...s})});h.displayName=l.hE.displayName;let x=s.forwardRef((e,a)=>{let{className:t,...s}=e;return(0,r.jsx)(l.VY,{ref:a,className:(0,n.cn)("text-sm text-muted-foreground",t),...s})});x.displayName=l.VY.displayName}}]); |