ultisuite-client/out/_next/static/chunks/1242.0334ddc294165077.js
R3D347HR4Y d6d18f911b
Some checks failed
E2E / Playwright e2e (push) Has been cancelled
Lots of stuff and mobile app
2026-06-17 00:13:28 +02:00

1 line
33 KiB
JavaScript

"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1242],{2336:(e,s,t)=>{t.d(s,{BQ:()=>d,QL:()=>l,v8:()=>o});var a=t(98306),n=t(39927),i=t(17745),r=t(94927);function l(e="org"){return(0,a.I)({queryKey:["admin","ai","usage",e],queryFn:()=>r.uE.get(`/admin/ai/usage?scope=${e}`),staleTime:3e4})}function d(){return(0,a.I)({queryKey:["admin","ai","pricing"],queryFn:async()=>(await r.uE.get("/admin/ai/pricing")).prices??[],staleTime:6e4})}function o(e){let s=(0,n.jE)();return(0,i.n)({mutationFn:s=>r.uE.put(`/admin/users/${e}/ai-policy`,s),onSuccess:()=>{s.invalidateQueries({queryKey:["admin","ai"]})}})}},5251:(e,s,t)=>{t.d(s,{Fm:()=>m,Qs:()=>h,cj:()=>l,h:()=>u,kN:()=>d,qp:()=>x});var a=t(4208);t(91356);var n=t(79531),i=t(12551),r=t(58113);function l({...e}){return(0,a.jsx)(n.bL,{"data-slot":"sheet",...e})}function d({...e}){return(0,a.jsx)(n.bm,{"data-slot":"sheet-close",...e})}function o({...e}){return(0,a.jsx)(n.ZL,{"data-slot":"sheet-portal",...e})}function c({className:e,...s}){return(0,a.jsx)(n.hJ,{"data-slot":"sheet-overlay",className:(0,r.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...s})}function u({className:e,children:s,side:t="right",overlayClassName:l,hideClose:d=!1,...m}){return(0,a.jsxs)(o,{children:[(0,a.jsx)(c,{className:l}),(0,a.jsxs)(n.UC,{"data-slot":"sheet-content",className:(0,r.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500","right"===t&&"data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm","left"===t&&"data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm","top"===t&&"data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b","bottom"===t&&"data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",e),...m,children:[s,d?null:(0,a.jsxs)(n.bm,{className:"ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none",children:[(0,a.jsx)(i.A,{className:"size-4"}),(0,a.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function m({className:e,...s}){return(0,a.jsx)("div",{"data-slot":"sheet-header",className:(0,r.cn)("flex flex-col gap-1.5 p-4",e),...s})}function x({className:e,...s}){return(0,a.jsx)(n.hE,{"data-slot":"sheet-title",className:(0,r.cn)("text-foreground font-semibold",e),...s})}function h({className:e,...s}){return(0,a.jsx)(n.VY,{"data-slot":"sheet-description",className:(0,r.cn)("text-muted-foreground text-sm",e),...s})}},11242:(e,s,t)=>{t.r(s),t.d(s,{UsersSection:()=>Y});var a=t(4208),n=t(91356),i=t(70374),r=t(12325),l=t(56706),d=t(7),o=t(6078),c=t(92394),u=t(12551),m=t(14410),x=t(81596),h=t(37928),p=t(78606),g=t(89032),j=t(57648),f=t(4433),v=t(86466),b=t(80691),N=t(35691),y=t(20911);let C={admin:"Administrateur",user:"Utilisateur",guest:"Invit\xe9",suspended:"Suspendu"},_={admin:f.A,user:v.A,guest:b.A,suspended:N.A},k=y.A;function w(e){return e.role?e.role:"disabled"===e.status?"suspended":"invited"===e.status?"guest":e.platform_admin?"admin":"user"}let z={admin:"Acc\xe8s complet \xe0 l'administration et \xe0 toutes les applications.",user:"Acc\xe8s standard \xe0 la suite (mail, drive, contacts, etc.).",guest:"Acc\xe8s limit\xe9 au drive : fichiers partag\xe9s et contenus envoy\xe9s uniquement.",suspended:"Compte bloqu\xe9, aucun acc\xe8s aux services."};var A=t(61554),S=t(51551),$=t(89342),q=t(18166),E=t(19096);let M=["admin","user","guest","suspended"];function G({selectedIds:e,groups:s,onClear:t}){let r=(0,j.Tl)(),[l,d]=(0,n.useState)(!1),[o,c]=(0,n.useState)(!1),[f,v]=(0,n.useState)("add_to_group"),[b,N]=(0,n.useState)("user"),[y,k]=(0,n.useState)(""),w=e.length;if(0===w)return null;async function z(s,a){try{let n=await r.mutateAsync({user_ids:e,action:s,...a});n.failed?.length?g.oR.warning(`${n.success_count} r\xe9ussi(s), ${n.failed.length} \xe9chec(s)`):g.oR.success(`${n.success_count} utilisateur(s) mis \xe0 jour`),t()}catch{g.oR.error("Action de masse impossible")}}return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"mb-3 flex flex-wrap items-center gap-2 rounded-lg border bg-muted/30 px-3 py-2",children:[(0,a.jsx)(A.$,{variant:"ghost",size:"icon",className:"size-8",onClick:t,children:(0,a.jsx)(u.A,{className:"size-4"})}),(0,a.jsxs)("span",{className:"text-sm font-medium",children:[w," s\xe9lectionn\xe9",w>1?"s":""]}),(0,a.jsxs)("div",{className:"ml-auto flex flex-wrap gap-1",children:[(0,a.jsxs)(A.$,{variant:"outline",size:"sm",disabled:r.isPending,onClick:()=>void z("disable"),children:[(0,a.jsx)(m.A,{className:"mr-2 size-4"}),"Suspendre"]}),(0,a.jsxs)(A.$,{variant:"outline",size:"sm",disabled:r.isPending,onClick:()=>void z("reactivate"),children:[(0,a.jsx)(x.A,{className:"mr-2 size-4"}),"R\xe9activer"]}),(0,a.jsxs)(A.$,{variant:"outline",size:"sm",disabled:r.isPending,onClick:()=>d(!0),children:[(0,a.jsx)(h.A,{className:"mr-2 size-4"}),"Changer le type"]}),(0,a.jsxs)(S.rI,{children:[(0,a.jsx)(S.ty,{asChild:!0,children:(0,a.jsxs)(A.$,{variant:"outline",size:"sm",disabled:r.isPending||0===s.length,children:[(0,a.jsx)(i.A,{className:"mr-2 size-4"}),"Groupes"]})}),(0,a.jsxs)(S.SQ,{align:"end",children:[(0,a.jsx)(S._2,{onClick:()=>{v("add_to_group"),k(s[0]?.id??""),c(!0)},children:"Ajouter \xe0 un groupe"}),(0,a.jsx)(S._2,{onClick:()=>{v("remove_from_group"),k(s[0]?.id??""),c(!0)},children:"Retirer d'un groupe"})]})]}),(0,a.jsxs)(A.$,{variant:"outline",size:"sm",className:"text-destructive",disabled:r.isPending,onClick:()=>{confirm(`Supprimer ${w} utilisateur(s) ?`)&&z("delete")},children:[(0,a.jsx)(p.A,{className:"mr-2 size-4"}),"Supprimer"]})]})]}),(0,a.jsx)(q.lG,{open:l,onOpenChange:d,children:(0,a.jsxs)(q.Cf,{children:[(0,a.jsx)(q.c7,{children:(0,a.jsx)(q.L3,{children:"Changer le type"})}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(E.J,{children:"Type d'utilisateur"}),(0,a.jsxs)($.l6,{value:b,onValueChange:e=>N(e),children:[(0,a.jsx)($.bq,{children:(0,a.jsx)($.yv,{})}),(0,a.jsx)($.gC,{children:M.map(e=>{let s=_[e];return(0,a.jsx)($.eb,{value:e,children:(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)(s,{className:"size-4"}),C[e]]})},e)})})]})]}),(0,a.jsxs)(q.Es,{children:[(0,a.jsx)(A.$,{variant:"outline",onClick:()=>d(!1),children:"Annuler"}),(0,a.jsx)(A.$,{onClick:()=>{z("set_role",{role:b}),d(!1)},children:"Appliquer"})]})]})}),(0,a.jsx)(q.lG,{open:o,onOpenChange:c,children:(0,a.jsxs)(q.Cf,{children:[(0,a.jsx)(q.c7,{children:(0,a.jsx)(q.L3,{children:"add_to_group"===f?"Ajouter au groupe":"Retirer du groupe"})}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(E.J,{children:"Groupe"}),(0,a.jsxs)($.l6,{value:y,onValueChange:k,children:[(0,a.jsx)($.bq,{children:(0,a.jsx)($.yv,{placeholder:"Choisir un groupe"})}),(0,a.jsx)($.gC,{children:s.map(e=>(0,a.jsx)($.eb,{value:e.id,children:e.name},e.id))})]})]}),(0,a.jsxs)(q.Es,{children:[(0,a.jsx)(A.$,{variant:"outline",onClick:()=>c(!1),children:"Annuler"}),(0,a.jsx)(A.$,{disabled:!y,onClick:()=>{z(f,{group_id:y}),c(!1)},children:"Appliquer"})]})]})})]})}var P=t(93497),J=t(5312),F=t(26708),L=t(13746),I=t(84956);function T({open:e,onOpenChange:s}){let[t,i]=(0,n.useState)(""),[r,l]=(0,n.useState)(!1),[d,o]=(0,n.useState)(null),c=(0,n.useMemo)(()=>({page:1,page_size:100,q:t.trim()||void 0}),[t]),{data:u,isFetching:m}=(0,F._E)(c),x=u?.groups??[];return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(q.lG,{open:e,onOpenChange:s,children:(0,a.jsxs)(q.Cf,{className:"max-w-lg",children:[(0,a.jsx)(q.c7,{children:(0,a.jsx)(q.L3,{children:"Groupes d'utilisateurs"})}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(L.p,{value:t,onChange:e=>i(e.target.value),placeholder:"Rechercher un groupe",className:"h-9"}),(0,a.jsxs)(A.$,{className:"h-9 shrink-0",onClick:function(){o(null),l(!0)},children:[(0,a.jsx)(P.A,{className:"mr-2 size-4"}),"Cr\xe9er"]})]}),(0,a.jsx)("div",{className:"max-h-80 space-y-2 overflow-y-auto rounded-lg border p-2",children:m?(0,a.jsx)("p",{className:"px-2 py-4 text-sm text-muted-foreground",children:"Chargement…"}):0===x.length?(0,a.jsx)("p",{className:"px-2 py-4 text-sm text-muted-foreground",children:"Aucun groupe."}):x.map(e=>(0,a.jsx)(O,{group:e,onEdit:()=>{o(e),l(!0)}},e.id))})]})]})}),(0,a.jsx)(Z,{open:r,onOpenChange:l,group:d})]})}function O({group:e,onEdit:s}){let t=(0,j.Gu)();return(0,a.jsxs)("div",{className:"flex items-start gap-3 rounded-md px-2 py-2 hover:bg-muted/50",children:[(0,a.jsx)(i.A,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,a.jsx)("div",{className:"font-medium",children:e.name}),e.description?(0,a.jsx)("div",{className:"text-xs text-muted-foreground",children:e.description}):null,(0,a.jsxs)("div",{className:"mt-1 text-xs text-muted-foreground",children:[e.member_count.toLocaleString("fr-FR")," membre(s)"]})]}),(0,a.jsxs)("div",{className:"flex shrink-0 gap-1",children:[(0,a.jsx)(A.$,{variant:"ghost",size:"icon",className:"size-8",onClick:s,children:(0,a.jsx)(J.A,{className:"size-4"})}),(0,a.jsx)(A.$,{variant:"ghost",size:"icon",className:"size-8 text-destructive",onClick:()=>{confirm(`Supprimer le groupe \xab ${e.name} \xbb ?`)&&t.mutateAsync(e.id)},children:(0,a.jsx)(p.A,{className:"size-4"})})]})]})}function Z({open:e,onOpenChange:s,group:t}){let i=(0,j.dB)(),r=(0,j.er)(t?.id??""),[l,d]=(0,n.useState)(""),[o,c]=(0,n.useState)(""),u=!!t;async function m(){let e=l.trim();e&&(u&&t?await r.mutateAsync({name:e,description:o.trim()}):await i.mutateAsync({name:e,description:o.trim()||void 0}),s(!1))}return(0,n.useEffect)(()=>{e&&(d(t?.name??""),c(t?.description??""))},[e,t]),(0,a.jsx)(q.lG,{open:e,onOpenChange:s,children:(0,a.jsxs)(q.Cf,{children:[(0,a.jsx)(q.c7,{children:(0,a.jsx)(q.L3,{children:u?"Modifier le groupe":"Nouveau groupe"})}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(E.J,{children:"Nom"}),(0,a.jsx)(L.p,{className:"mt-1",value:l,onChange:e=>d(e.target.value)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(E.J,{children:"Description (optionnel)"}),(0,a.jsx)(I.T,{className:"mt-1 min-h-20",value:o,onChange:e=>c(e.target.value)})]})]}),(0,a.jsxs)(q.Es,{children:[(0,a.jsx)(A.$,{variant:"outline",onClick:()=>s(!1),children:"Annuler"}),(0,a.jsx)(A.$,{disabled:!l.trim()||i.isPending||r.isPending,onClick:()=>void m(),children:u?"Enregistrer":"Cr\xe9er"})]})]})})}var R=t(2336),Q=t(92309),V=t(58113),D=t(30925),H=t(51355),U=t(5251),B=t(51618);let K=["admin","user","guest","suspended"],X=[{value:"-created_at",label:"Cr\xe9ation (r\xe9cent)"},{value:"created_at",label:"Cr\xe9ation (ancien)"},{value:"name",label:"Nom (A→Z)"},{value:"-name",label:"Nom (Z→A)"},{value:"email",label:"E-mail (A→Z)"},{value:"-email",label:"E-mail (Z→A)"},{value:"-updated_at",label:"Mise \xe0 jour (r\xe9cent)"},{value:"updated_at",label:"Mise \xe0 jour (ancien)"}];function Y(){let[e,s]=(0,n.useState)(""),[t,l]=(0,n.useState)("all"),[u,m]=(0,n.useState)("all"),[x,h]=(0,n.useState)(1),[p,g]=(0,n.useState)(25),[j,f]=(0,n.useState)("-created_at"),[v,b]=(0,n.useState)(!1),[N,y]=(0,n.useState)(!1),[C,_]=(0,n.useState)(null),[k,w]=(0,n.useState)([]),z=(0,n.useMemo)(()=>({page:x,page_size:p,sort:j,q:e.trim()||void 0,role:"all"===t?void 0:t,group_id:"all"===u?void 0:u}),[x,p,j,e,t,u]),{data:S}=(0,F._E)({page:1,page_size:200}),q=S?.groups??[],{data:M,isFetching:P,isError:J,refetch:I}=(0,F.F2)(z),O=M?.users,Z=M?.pagination.total??0,R=M?.pagination.page_size??p,Q=Math.max(1,Math.ceil(Z/R)),V=(0,n.useMemo)(()=>(O??[]).map(e=>e.id),[O]),H=V.join(","),U=V.length>0&&V.every(e=>k.includes(e)),Y=V.some(e=>k.includes(e))&&!U;return(0,n.useEffect)(()=>{let e=H.length>0?H.split(","):[];w(s=>{let t=s.filter(s=>e.includes(s));return t.length===s.length&&t.every((e,t)=>e===s[t])?s:t})},[H]),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.y,{title:"Utilisateurs",description:"Comptes, groupes, types d'utilisateur, invitations et quotas."}),(0,a.jsx)(o.v,{isFetching:P,isError:J,onRetry:()=>I()}),(0,a.jsxs)("div",{className:"mb-4 flex flex-wrap items-end gap-3",children:[(0,a.jsxs)("div",{className:"min-w-[200px] flex-1",children:[(0,a.jsx)(E.J,{className:"text-xs",children:"Recherche"}),(0,a.jsx)(L.p,{className:"mt-1 h-9",value:e,onChange:e=>{s(e.target.value),h(1)},placeholder:"E-mail, nom ou ID externe"})]}),(0,a.jsxs)("div",{className:"w-52",children:[(0,a.jsx)(E.J,{className:"text-xs",children:"Type d'utilisateur"}),(0,a.jsxs)($.l6,{value:t,onValueChange:e=>{l(e),h(1)},children:[(0,a.jsx)($.bq,{className:"mt-1 h-9",children:(0,a.jsx)($.yv,{placeholder:"Type d'utilisateur"})}),(0,a.jsxs)($.gC,{children:[(0,a.jsx)($.eb,{value:"all",children:(0,a.jsx)(es,{role:"all"})}),K.map(e=>(0,a.jsx)($.eb,{value:e,children:(0,a.jsx)(es,{role:e})},e))]})]})]}),(0,a.jsxs)("div",{className:"w-52",children:[(0,a.jsx)(E.J,{className:"text-xs",children:"Groupe"}),(0,a.jsxs)($.l6,{value:u,onValueChange:e=>{m(e),h(1)},children:[(0,a.jsx)($.bq,{className:"mt-1 h-9",children:(0,a.jsx)($.yv,{placeholder:"Groupe"})}),(0,a.jsxs)($.gC,{children:[(0,a.jsx)($.eb,{value:"all",children:(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)(i.A,{className:"size-4 opacity-80"}),"Tous les groupes"]})}),q.map(e=>(0,a.jsx)($.eb,{value:e.id,children:e.name},e.id))]})]})]}),(0,a.jsxs)(A.$,{variant:"outline",className:"h-9",onClick:()=>y(!0),children:[(0,a.jsx)(i.A,{className:"mr-2 size-4"}),"Groupes"]}),(0,a.jsxs)(A.$,{className:"h-9",onClick:()=>b(!0),children:[(0,a.jsx)(r.A,{className:"mr-2 size-4"}),"Inviter"]})]}),(0,a.jsx)(G,{selectedIds:k,groups:q,onClear:()=>w([])}),(0,a.jsx)(c.Q,{page:x,pageSize:R,total:Z,totalPages:Q,sort:j,sortOptions:X,onPageChange:h,onPageSizeChange:e=>{g(e),h(1)},onSortChange:e=>{f(e),h(1)},itemLabel:"utilisateur(s)"}),(0,a.jsx)("div",{className:"overflow-x-auto rounded-lg border",children:(0,a.jsxs)(B.XI,{children:[(0,a.jsx)(B.A0,{children:(0,a.jsxs)(B.Hj,{children:[(0,a.jsx)(B.nd,{className:"w-10",children:(0,a.jsx)(D.S,{checked:!!U||!!Y&&"indeterminate",onCheckedChange:e=>{!0===e?w(e=>Array.from(new Set([...e,...V]))):w(e=>e.filter(e=>!V.includes(e)))},"aria-label":"S\xe9lectionner la page"})}),(0,a.jsx)(B.nd,{children:"Utilisateur"}),(0,a.jsx)(B.nd,{children:"Type"}),(0,a.jsx)(B.nd,{className:"hidden xl:table-cell",children:"Groupes"}),(0,a.jsx)(B.nd,{className:"hidden lg:table-cell",children:"Mail"}),(0,a.jsx)(B.nd,{className:"hidden lg:table-cell",children:"Drive"}),(0,a.jsx)(B.nd,{className:"hidden md:table-cell",children:"ID externe"}),(0,a.jsx)(B.nd,{className:"w-12"})]})}),(0,a.jsx)(B.BF,{children:0===(O??[]).length?(0,a.jsx)(B.Hj,{children:(0,a.jsx)(B.nA,{colSpan:8,className:"text-center text-muted-foreground",children:"Aucun utilisateur trouv\xe9."})}):(O??[]).map(e=>(0,a.jsx)(W,{user:e,selected:k.includes(e.id),onToggleSelect:s=>{var t;return t=e.id,void w(e=>s?Array.from(new Set([...e,t])):e.filter(e=>e!==t))},onOpen:()=>_(e.id)},e.id))})]})}),(0,a.jsx)(ea,{open:v,onOpenChange:b}),(0,a.jsx)(T,{open:N,onOpenChange:y}),(0,a.jsx)(en,{userId:C,onClose:()=>_(null)})]})}function W({user:e,selected:s,onToggleSelect:t,onOpen:n}){let i=(0,j.gb)(),r=(0,j.qA)(),d=(0,j.le)();return(0,a.jsxs)(B.Hj,{className:"cursor-pointer",children:[(0,a.jsx)(B.nA,{onClick:e=>e.stopPropagation(),children:(0,a.jsx)(D.S,{checked:s,onCheckedChange:e=>t(!0===e),"aria-label":`S\xe9lectionner ${e.email}`})}),(0,a.jsxs)(B.nA,{onClick:n,children:[(0,a.jsx)("div",{className:"font-medium",children:e.name||"—"}),(0,a.jsx)("div",{className:"text-xs text-muted-foreground",children:e.email})]}),(0,a.jsx)(B.nA,{onClick:n,children:(0,a.jsx)(et,{role:w(e)})}),(0,a.jsx)(B.nA,{className:"hidden xl:table-cell",onClick:n,children:(0,a.jsx)(ee,{groups:e.groups??[]})}),(0,a.jsx)(B.nA,{className:"hidden text-xs text-muted-foreground lg:table-cell",onClick:n,children:(0,Q.z3)(e.storage?.mail_used_bytes??0)}),(0,a.jsx)(B.nA,{className:"hidden text-xs text-muted-foreground lg:table-cell",onClick:n,children:(0,Q.z3)(e.storage?.drive_used_bytes??0)}),(0,a.jsx)(B.nA,{className:"hidden max-w-[200px] truncate font-mono text-xs md:table-cell",onClick:n,children:e.external_id}),(0,a.jsx)(B.nA,{onClick:e=>e.stopPropagation(),children:(0,a.jsxs)(S.rI,{children:[(0,a.jsx)(S.ty,{asChild:!0,children:(0,a.jsx)(A.$,{variant:"ghost",size:"icon",className:"size-8",children:(0,a.jsx)(l.A,{className:"size-4"})})}),(0,a.jsxs)(S.SQ,{align:"end",children:[(0,a.jsx)(S._2,{onClick:n,children:"D\xe9tails et quotas"}),"suspended"!==w(e)?(0,a.jsx)(S._2,{onClick:()=>void i.mutateAsync(e.id),children:"Suspendre"}):(0,a.jsx)(S._2,{onClick:()=>void r.mutateAsync(e.id),children:"R\xe9activer"}),(0,a.jsx)(S.mB,{}),(0,a.jsx)(S._2,{className:"text-destructive",onClick:()=>{confirm(`Supprimer d\xe9finitivement ${e.email} ?`)&&d.mutateAsync(e.id)},children:"Supprimer"})]})]})})]})}function ee({groups:e}){if(!e?.length)return(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:"—"});let s=e.slice(0,2),t=e.length-s.length;return(0,a.jsxs)("div",{className:"flex flex-wrap gap-1",children:[s.map(e=>(0,a.jsx)(H.E,{variant:"outline",className:"text-xs font-normal",children:e.name},e.id)),t>0?(0,a.jsxs)(H.E,{variant:"secondary",className:"text-xs font-normal",children:["+",t]}):null]})}function es({role:e,className:s}){let t="all"===e?k:_[e],n="all"===e?"Tous les types":C[e];return(0,a.jsxs)("span",{className:(0,V.cn)("flex items-center gap-2",s),children:[(0,a.jsx)(t,{className:"size-4 shrink-0 opacity-80","aria-hidden":!0}),(0,a.jsx)("span",{children:n})]})}function et({role:e}){let s=_[e];return(0,a.jsxs)(H.E,{variant:"admin"===e?"default":"user"===e?"secondary":"guest"===e?"outline":"destructive",className:"gap-1.5 pr-2.5",children:[(0,a.jsx)(s,{className:"size-3.5","aria-hidden":!0}),C[e]??e]})}function ea({open:e,onOpenChange:s}){let t=(0,j.Ti)(),[i,r]=(0,n.useState)(""),[l,d]=(0,n.useState)("");async function o(){await t.mutateAsync({email:i,name:l||void 0}),r(""),d(""),s(!1)}return(0,a.jsx)(q.lG,{open:e,onOpenChange:s,children:(0,a.jsxs)(q.Cf,{children:[(0,a.jsx)(q.c7,{children:(0,a.jsx)(q.L3,{children:"Inviter un utilisateur"})}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(E.J,{children:"E-mail"}),(0,a.jsx)(L.p,{className:"mt-1",type:"email",value:i,onChange:e=>r(e.target.value)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(E.J,{children:"Nom (optionnel)"}),(0,a.jsx)(L.p,{className:"mt-1",value:l,onChange:e=>d(e.target.value)})]})]}),(0,a.jsxs)(q.Es,{children:[(0,a.jsx)(A.$,{variant:"outline",onClick:()=>s(!1),children:"Annuler"}),(0,a.jsx)(A.$,{disabled:!i||t.isPending,onClick:()=>void o(),children:"Envoyer l'invitation"})]})]})})}function en({userId:e,onClose:s}){let{data:t,isFetching:i}=(0,F.Wu)(e),r=(0,j.XM)(e??""),l=(0,j.AH)(e??""),d=(0,j.Ck)(e??""),o=(0,R.v8)(e??""),[c,u]=(0,n.useState)(""),[m,x]=(0,n.useState)(""),[h,p]=(0,n.useState)("user"),[g,f]=(0,n.useState)("5"),[v,b]=(0,n.useState)("5"),[N,y]=(0,n.useState)("5"),[C,_]=(0,n.useState)(""),[k,S]=(0,n.useState)(""),q=!!e;async function M(){e&&await r.mutateAsync({name:c,email:m})}async function G(){e&&t&&h!==w(t)&&await l.mutateAsync({role:h})}async function P(){e&&await d.mutateAsync({mail_max_storage_bytes:(0,Q.Zp)(Number(g)),drive_max_storage_bytes:(0,Q.Zp)(Number(v)),photos_max_storage_bytes:(0,Q.Zp)(Number(N))})}async function J(){e&&await o.mutateAsync({daily_limit_eur:""===C.trim()?null:Number(C),monthly_limit_eur:""===k.trim()?null:Number(k)})}return(0,n.useEffect)(()=>{t&&(u(t.name??""),x(t.email??""),p(w(t)),t.quota&&(f(String((0,Q.$p)(t.quota.mail.max_storage_bytes).toFixed(1))),b(String((0,Q.$p)(t.quota.drive.max_storage_bytes).toFixed(1))),y(String((0,Q.$p)(t.quota.photos.max_storage_bytes).toFixed(1)))))},[t]),(0,a.jsx)(U.cj,{open:q,onOpenChange:e=>!e&&s(),children:(0,a.jsxs)(U.h,{className:"flex flex-col gap-0 overflow-y-auto p-0 sm:max-w-lg",children:[(0,a.jsx)(U.Fm,{className:"border-b px-6 py-5",children:(0,a.jsx)(U.qp,{children:"D\xe9tails utilisateur"})}),i||!t?(0,a.jsx)("p",{className:"px-6 py-5 text-sm text-muted-foreground",children:"Chargement…"}):(0,a.jsxs)("div",{className:"space-y-8 px-6 py-6",children:[(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)(et,{role:w(t)}),t.groups?.length?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(E.J,{children:"Groupes"}),(0,a.jsx)(ee,{groups:t.groups})]}):null,(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(E.J,{children:"Type d'utilisateur"}),(0,a.jsxs)($.l6,{value:h,onValueChange:e=>p(e),children:[(0,a.jsx)($.bq,{children:(0,a.jsx)($.yv,{placeholder:"Type d'utilisateur"})}),(0,a.jsx)($.gC,{children:K.map(e=>(0,a.jsx)($.eb,{value:e,children:(0,a.jsx)(es,{role:e})},e))})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:z[h]}),(0,a.jsx)(A.$,{size:"sm",variant:"secondary",onClick:()=>void G(),disabled:l.isPending||h===w(t),children:"Enregistrer le type"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(E.J,{children:"Nom"}),(0,a.jsx)(L.p,{value:c,onChange:e=>u(e.target.value)})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(E.J,{children:"E-mail"}),(0,a.jsx)(L.p,{value:m,onChange:e=>x(e.target.value)})]}),(0,a.jsx)(A.$,{size:"sm",onClick:()=>void M(),disabled:r.isPending,children:"Mettre \xe0 jour le profil"})]}),t.quota?(0,a.jsxs)("div",{className:"space-y-5 rounded-lg border bg-muted/20 p-5",children:[(0,a.jsx)("h3",{className:"text-sm font-medium",children:"Quotas stockage"}),(0,a.jsx)(er,{label:"Mail",used:ei(t.quota.mail.used_storage_bytes),max:ei(t.quota.mail.max_storage_bytes),gib:g,onGibChange:f,count:t.quota.mail.count}),(0,a.jsx)(er,{label:"Drive",used:ei(t.quota.drive.used_storage_bytes),max:ei(t.quota.drive.max_storage_bytes),gib:v,onGibChange:b}),(0,a.jsx)(er,{label:"Photos",used:ei(t.quota.photos.used_storage_bytes),max:ei(t.quota.photos.max_storage_bytes),gib:N,onGibChange:y}),(0,a.jsx)(A.$,{size:"sm",onClick:()=>void P(),disabled:d.isPending,children:"Enregistrer les quotas"})]}):null,(0,a.jsxs)("div",{className:"space-y-4 rounded-lg border bg-muted/20 p-5",children:[(0,a.jsx)("h3",{className:"text-sm font-medium",children:"Plafond IA (cl\xe9 org)"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Override utilisateur. Laissez vide pour h\xe9riter des plafonds org/groupe."}),(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(E.J,{children:"Journalier (€)"}),(0,a.jsx)(L.p,{type:"number",min:0,step:.5,placeholder:"H\xe9rit\xe9",value:C,onChange:e=>_(e.target.value)})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(E.J,{children:"Mensuel (€)"}),(0,a.jsx)(L.p,{type:"number",min:0,step:1,placeholder:"H\xe9rit\xe9",value:k,onChange:e=>S(e.target.value)})]})]}),(0,a.jsx)(A.$,{size:"sm",variant:"secondary",onClick:()=>void J(),disabled:o.isPending,children:"Enregistrer le plafond IA"})]}),(0,a.jsxs)("p",{className:"font-mono text-xs text-muted-foreground",children:["ID : ",t.id]})]})]})})}function ei(e){let s="number"==typeof e?e:Number(e);return Number.isFinite(s)&&s>=0?s:0}function er({label:e,used:s,max:t,gib:n,onGibChange:i,count:r}){let l=t>0?t:(0,Q.Zp)(Number(n)||0),d=l>0?Math.min(100,Math.round(s/l*100)):0;return(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 text-xs",children:[(0,a.jsx)("span",{className:"font-medium text-foreground",children:e}),(0,a.jsxs)("span",{className:"text-right text-muted-foreground",children:[(0,Q.z3)(s)," / ",(0,Q.z3)(l),void 0!==r?` \xb7 ${r} messages`:""]})]}),(0,a.jsx)("div",{className:"h-1.5 overflow-hidden rounded-full bg-muted",children:(0,a.jsx)("div",{className:"h-full rounded-full bg-primary transition-all",style:{width:`${d}%`}})}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(E.J,{className:"sr-only",children:["Quota ",e]}),(0,a.jsx)(L.p,{type:"number",min:0,step:.5,className:"h-9",value:n,onChange:e=>i(e.target.value)}),(0,a.jsx)("span",{className:"shrink-0 text-sm text-muted-foreground",children:"Go max"})]})]})}},18166:(e,s,t)=>{t.d(s,{Cf:()=>u,Es:()=>x,HM:()=>o,L3:()=>h,c7:()=>m,lG:()=>l,rr:()=>p});var a=t(4208);t(91356);var n=t(79531),i=t(12551),r=t(58113);function l({...e}){return(0,a.jsx)(n.bL,{"data-slot":"dialog",...e})}function d({...e}){return(0,a.jsx)(n.ZL,{"data-slot":"dialog-portal",...e})}function o({...e}){return(0,a.jsx)(n.bm,{"data-slot":"dialog-close",...e})}function c({className:e,...s}){return(0,a.jsx)(n.hJ,{"data-slot":"dialog-overlay",className:(0,r.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...s})}function u({className:e,overlayClassName:s,children:t,showCloseButton:l=!0,...o}){return(0,a.jsxs)(d,{"data-slot":"dialog-portal",children:[(0,a.jsx)(c,{className:s}),(0,a.jsxs)(n.UC,{"data-slot":"dialog-content",className:(0,r.cn)("bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...o,children:[t,l&&(0,a.jsxs)(n.bm,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[(0,a.jsx)(i.A,{}),(0,a.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})}function m({className:e,...s}){return(0,a.jsx)("div",{"data-slot":"dialog-header",className:(0,r.cn)("flex flex-col gap-2 text-center sm:text-left",e),...s})}function x({className:e,...s}){return(0,a.jsx)("div",{"data-slot":"dialog-footer",className:(0,r.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...s})}function h({className:e,...s}){return(0,a.jsx)(n.hE,{"data-slot":"dialog-title",className:(0,r.cn)("text-lg leading-none font-semibold",e),...s})}function p({className:e,...s}){return(0,a.jsx)(n.VY,{"data-slot":"dialog-description",className:(0,r.cn)("text-muted-foreground text-sm",e),...s})}},30925:(e,s,t)=>{t.d(s,{S:()=>d});var a=t(4208);t(91356);var n=t(28879),i=t(68183),r=t(35019),l=t(58113);function d({className:e,checked:s,...t}){return(0,a.jsx)(n.bL,{"data-slot":"checkbox",className:(0,l.cn)("peer border-[1.5px] border-mail-row-checkbox-border bg-background dark:bg-mail-surface-muted data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-primary-foreground data-[state=indeterminate]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 cursor-pointer rounded-[4px] shadow-xs transition-all outline-none hover:border-foreground/60 hover:shadow-sm focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",e),...t,checked:s,children:(0,a.jsx)(n.C1,{"data-slot":"checkbox-indicator",className:"flex items-center justify-center text-current transition-none",children:"indeterminate"===s?(0,a.jsx)(i.A,{className:"size-3 stroke-[2.5] text-inherit"}):(0,a.jsx)(r.A,{className:"size-3.5 text-inherit stroke-[2.5]"})})})}},51551:(e,s,t)=>{t.d(s,{M5:()=>f,SQ:()=>c,V0:()=>p,_2:()=>u,hO:()=>m,lp:()=>x,lv:()=>g,mB:()=>h,nV:()=>j,rI:()=>d,ty:()=>o});var a=t(4208);t(91356);var n=t(12805),i=t(35019),r=t(26159),l=t(58113);function d({...e}){return(0,a.jsx)(n.bL,{"data-slot":"dropdown-menu",...e})}function o({...e}){return(0,a.jsx)(n.l9,{"data-slot":"dropdown-menu-trigger",...e})}function c({className:e,sideOffset:s=4,...t}){return(0,a.jsx)(n.ZL,{children:(0,a.jsx)(n.UC,{"data-slot":"dropdown-menu-content",sideOffset:s,className:(0,l.cn)("bg-popover text-popover-foreground 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 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md",e),...t})})}function u({className:e,inset:s,variant:t="default",...i}){return(0,a.jsx)(n.q7,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":t,className:(0,l.cn)("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:!text-destructive [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...i})}function m({className:e,children:s,checked:t,...r}){return(0,a.jsxs)(n.H_,{"data-slot":"dropdown-menu-checkbox-item",className:(0,l.cn)("focus:bg-accent focus:text-accent-foreground relative flex cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:t,...r,children:[(0,a.jsx)("span",{className:"pointer-events-none absolute left-2 flex size-3.5 items-center justify-center",children:(0,a.jsx)(n.VF,{children:(0,a.jsx)(i.A,{className:"size-4"})})}),s]})}function x({className:e,inset:s,...t}){return(0,a.jsx)(n.JU,{"data-slot":"dropdown-menu-label","data-inset":s,className:(0,l.cn)("px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",e),...t})}function h({className:e,...s}){return(0,a.jsx)(n.wv,{"data-slot":"dropdown-menu-separator",className:(0,l.cn)("bg-border -mx-1 my-1 h-px",e),...s})}function p({className:e,...s}){return(0,a.jsx)("span",{"data-slot":"dropdown-menu-shortcut",className:(0,l.cn)("text-muted-foreground ml-auto text-xs tracking-widest",e),...s})}function g({...e}){return(0,a.jsx)(n.Pb,{"data-slot":"dropdown-menu-sub",...e})}function j({className:e,inset:s,children:t,...i}){return(0,a.jsxs)(n.ZP,{"data-slot":"dropdown-menu-sub-trigger","data-inset":s,className:(0,l.cn)("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...i,children:[t,(0,a.jsx)(r.A,{className:"ml-auto size-4"})]})}function f({className:e,...s}){return(0,a.jsx)(n.ZL,{children:(0,a.jsx)(n.G5,{"data-slot":"dropdown-menu-sub-content",className:(0,l.cn)("bg-popover text-popover-foreground 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 z-[100] min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border p-1 shadow-lg",e),...s})})}},84956:(e,s,t)=>{t.d(s,{T:()=>i});var a=t(4208);t(91356);var n=t(58113);function i({className:e,...s}){return(0,a.jsx)("textarea",{"data-slot":"textarea",className:(0,n.cn)("border-input placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...s})}},92309:(e,s,t)=>{t.d(s,{$p:()=>r,Zp:()=>i,z3:()=>n});let a=["o","Ko","Mo","Go","To"];function n(e,s=1){if(!Number.isFinite(e)||e<0)return"—";if(0===e)return"0 o";let t=Math.min(Math.floor(Math.log(e)/Math.log(1024)),a.length-1),i=e/Math.pow(1024,t);return`${i.toFixed(s)} ${a[t]}`}function i(e){return Math.round(1024*e*1048576)}function r(e){return e/0x40000000}}}]);