1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[603],{3349:(e,s,t)=>{"use strict";t.d(s,{MM:()=>l,VE:()=>i,ke:()=>o,lN:()=>n,y9:()=>r});var a=t(4734);let r=async e=>{let s=await fetch("/api/admin/access/invitation?token=".concat(encodeURIComponent(e)));if(!s.ok)throw Error(await (0,a.V)(s,"Impossible de v\xe9rifier ce lien d'activation."));return s.json()},i=async e=>{let s=await fetch("/api/admin/access/invitation",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!s.ok)throw Error(await (0,a.V)(s,"Impossible d'activer ce compte."));return s.json()},o=async e=>{let s=await fetch("/api/admin/access/password-reset/request",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(!s.ok)throw Error(await (0,a.V)(s,"Impossible d'envoyer le lien de r\xe9initialisation."))},n=async e=>{let s=await fetch("/api/admin/access/password-reset?token=".concat(encodeURIComponent(e)));if(!s.ok)throw Error(await (0,a.V)(s,"Impossible de v\xe9rifier ce lien de r\xe9initialisation."));return s.json()},l=async e=>{let s=await fetch("/api/admin/access/password-reset",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!s.ok)throw Error(await (0,a.V)(s,"Impossible de mettre \xe0 jour le mot de passe."));return s.json()}},4734:(e,s,t)=>{"use strict";t.d(s,{V:()=>a});let a=async(e,s)=>{if((e.headers.get("content-type")||"").includes("application/json")){let s=await e.json().catch(()=>null);if(s&&"string"==typeof s.error&&s.error.trim().length>0)return s.error}return await e.text().catch(()=>"")||s}},6315:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>u});var a=t(7876),r=t(9003),i=t(4232),o=t(9099),n=t(3349),l=t(254);let d="Ce lien d'activation est invalide ou a expir\xe9.";var c=t(3117);let m=()=>{let{email:e,role:s,roles:t,isLoading:m,isSubmitting:u,errorMessage:p,isValid:h,isSuccess:x,handleActivate:f}=(()=>{let e=(0,o.useRouter)(),[s,t]=(0,i.useState)({email:"",role:"",roles:[],isLoading:!0,isSubmitting:!1,errorMessage:"",isValid:!1,isSuccess:!1});(0,i.useEffect)(()=>{if(!e.isReady)return;let s="string"==typeof e.query.token?e.query.token:"";if(!s)return void t(e=>({...e,isLoading:!1,isValid:!1,errorMessage:d}));let a=!0;return t(e=>({...e,isLoading:!0,errorMessage:"",isValid:!1})),(0,n.y9)(s).then(e=>{a&&t(s=>({...s,email:e.email,role:e.role,roles:Array.isArray(e.roles)?e.roles:e.role?[e.role]:[],isLoading:!1,isValid:!0}))}).catch(e=>{a&&t(s=>({...s,isLoading:!1,isValid:!1,errorMessage:e instanceof Error?e.message:d}))}),()=>{a=!1}},[e.isReady,e.query.token]);let a=(0,i.useCallback)(async a=>{let{password:r,confirmPassword:i}=a,o="string"==typeof e.query.token?e.query.token:"";if(o&&!s.isSubmitting){if(!r||r!==i)return void t(e=>({...e,errorMessage:"Les mots de passe ne correspondent pas."}));if(r.length<8)return void t(e=>({...e,errorMessage:"Le mot de passe doit contenir au moins ".concat(8," caract\xe8res.")}));t(e=>({...e,isSubmitting:!0,errorMessage:"",isSuccess:!1}));try{let{email:s}=await (0,n.VE)({token:o,password:r}),a=null;try{let{error:e}=await (0,l.M)({email:s,password:r});a=e}catch(e){throw e instanceof Error&&"auth_revoked"===e.kind||(0,l.A_)(),e}if(a)return void e.replace("/admin/login?activated=1");t(e=>({...e,isSubmitting:!1,isSuccess:!0})),e.replace("/admin/dashboard")}catch(e){t(s=>({...s,isSubmitting:!1,errorMessage:e instanceof Error?e.message:"Impossible d'activer ce compte pour le moment."}))}}},[e,s.isSubmitting]);return{email:s.email,role:s.role,roles:s.roles,isLoading:s.isLoading,isSubmitting:s.isSubmitting,errorMessage:s.errorMessage,isValid:s.isValid,isSuccess:s.isSuccess,handleActivate:a}})(),b=(0,c.X1)(t,s).join(", ")||(0,c.sp)(s);return(0,a.jsx)("main",{className:"flex min-h-screen items-center justify-center bg-slate-50 px-6 py-12",children:(0,a.jsxs)("div",{className:"w-full max-w-md rounded-2xl bg-white p-6 shadow-lg",children:[(0,a.jsx)("h1",{className:"text-2xl font-semibold text-slate-900",children:"Activer votre acces back-office"}),(0,a.jsx)("p",{className:"mt-2 text-sm text-slate-600",children:"Definissez votre mot de passe pour acceder aux modules qui vous ont ete attribues."}),m?(0,a.jsx)("p",{className:"mt-6 text-sm text-slate-600",children:"Verification du lien en cours..."}):null,m||h?null:(0,a.jsxs)("div",{className:"mt-6 rounded-xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-800",children:[(0,a.jsx)("p",{children:p}),(0,a.jsx)("p",{className:"mt-2",children:"Demandez une nouvelle invitation a un administrateur ou utilisez un lien recu recemment."})]}),!m&&h?(0,a.jsxs)("div",{className:"mt-6 space-y-4",children:[(0,a.jsxs)("div",{className:"rounded-xl border border-slate-200 bg-slate-50 p-4 text-sm text-slate-700",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("span",{className:"font-semibold text-slate-900",children:"Email :"})," ",e]}),(0,a.jsxs)("p",{className:"mt-1",children:[(0,a.jsx)("span",{className:"font-semibold text-slate-900",children:"Acces metier :"})," ",b]})]}),(0,a.jsx)(r.A,{onSubmit:f,isLoading:u,errorMessage:p,isSuccess:x})]}):null]})})},u=()=>(0,a.jsx)(m,{})},8224:(e,s,t)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/activate",function(){return t(6315)}])},9003:(e,s,t)=>{"use strict";t.d(s,{A:()=>i});var a=t(7876),r=t(4232);let i=e=>{let{onSubmit:s,isLoading:t,errorMessage:i,isSuccess:o}=e,[n,l]=(0,r.useState)(""),[d,c]=(0,r.useState)("");return(0,a.jsxs)("form",{className:"space-y-4",onSubmit:e=>{e.preventDefault(),s({password:n,confirmPassword:d})},children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{htmlFor:"admin-new-password",className:"block text-sm font-medium text-slate-700",children:"Nouveau mot de passe"}),(0,a.jsx)("input",{id:"admin-new-password",name:"password",type:"password",autoComplete:"new-password",required:!0,value:n,onChange:e=>l(e.target.value),className:"w-full rounded-lg border border-slate-300 px-3 py-2 text-slate-900 focus:border-slate-500 focus:outline-none"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("label",{htmlFor:"admin-confirm-password",className:"block text-sm font-medium text-slate-700",children:"Confirmer le mot de passe"}),(0,a.jsx)("input",{id:"admin-confirm-password",name:"confirmPassword",type:"password",autoComplete:"new-password",required:!0,value:d,onChange:e=>c(e.target.value),className:"w-full rounded-lg border border-slate-300 px-3 py-2 text-slate-900 focus:border-slate-500 focus:outline-none"})]}),i?(0,a.jsx)("p",{className:"text-sm text-red-600",children:i}):null,o?(0,a.jsx)("p",{className:"text-sm text-emerald-600",children:"Mot de passe mis \xe0 jour. Vous \xeates connect\xe9."}):null,(0,a.jsx)("button",{type:"submit",disabled:t,className:"w-full rounded-lg bg-slate-900 px-4 py-2 text-sm font-semibold text-white transition hover:bg-slate-800 disabled:cursor-not-allowed disabled:opacity-60",children:t?"Mise \xe0 jour...":"Mettre \xe0 j
1our"})]})}}},e=>{e.O(0,[636,593,792],()=>e(e.s=8224)),_N_E=e.O()}]);
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.