(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[495],{75511:function(e,s,r){(window.__NEXT_P=window.__NEXT_P||[]).push(["/register",function(){return r(91931)}])},91931:function(e,s,r){"use strict";r.r(s),r.d(s,{default:function(){return c}});var a=r(85893),t=r(67294),n=r(87536),o=r(90748),l=r(11163),d=r(41664),i=r.n(d);function c(){let{register:e,handleSubmit:s,formState:{errors:r}}=(0,n.cI)(),[d,c]=(0,t.useState)(""),u=(0,l.useRouter)(),m=async e=>{let{email:s,password:r,genre:t,poids:n,taille:o,dateNaissance:l}=e;if(r.length<6||r.length>128){c("Password must be between 6 and 128 characters");return}try{let e=await fetch("/api/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:s,password:r,genre:t,poids:n,taille:o,dateNaissance:l})});if(e.ok)u.push("/go-confirm-email");else{let s=await e.json();c(s.error),"User already exists"===s.error&&c((0,a.jsxs)(a.Fragment,{children:["Vous avez d\xe9j\xe0 un compte chez nous."," ",(0,a.jsx)(i(),{href:"/login",children:(0,a.jsx)("span",{className:"text-blue-500 cursor-pointer",children:"Acc\xe9dez \xe0 la page login ici"})}),"."]}))}}catch(e){console.error(e),c(e.message)}};return(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8",children:(0,a.jsxs)("div",{className:"max-w-md w-full space-y-8",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("a",{href:"/login",className:"text-[#E63A76] hover:text-[#F4B6CD] absolute top-4 left-4",children:(0,a.jsx)(o.O8Q,{size:24})}),(0,a.jsx)("h2",{className:"mt-6 text-center text-3xl font-extrabold",style:{color:"#215152"},children:"Inscription"})]}),(0,a.jsxs)("form",{className:"mt-8 space-y-6",onSubmit:s(m),children:[(0,a.jsx)("input",{type:"hidden",name:"remember",defaultValue:"true"}),(0,a.jsxs)("div",{className:"rounded-md shadow-sm -space-y-px",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{htmlFor:"email-address",className:"sr-only",children:"Adresse Email"}),(0,a.jsx)("input",{...e("email",{required:"L'email est requis"}),id:"email-address",name:"email",type:"email",autoComplete:"email",required:!0,className:"appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-t-md focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm ".concat(r.email?"border-red-500":""),placeholder:"Adresse Email"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{htmlFor:"password",className:"sr-only",children:"Password"}),(0,a.jsx)("input",{...e("password",{required:"Le mot de passe est requis"}),id:"password",name:"password",type:"password",autoComplete:"current-password",required:!0,className:"appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm ".concat(r.password?"border-red-500":""),placeholder:"Mot de passe"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{htmlFor:"genre",className:"sr-only",children:"genre"}),(0,a.jsxs)("select",{...e("genre",{required:"Le genre est n\xe9cessaire pour estimer vos apports"}),id:"genre",name:"genre",required:!0,className:"appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm ".concat(r.genre?"border-red-500":""),children:[(0,a.jsx)("option",{value:"",children:"Selectionner votre genre"}),(0,a.jsx)("option",{value:"homme",children:"Homme"}),(0,a.jsx)("option",{value:"femme",children:"Femme"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{htmlFor:"poids",className:"sr-only",children:"poids"}),(0,a.jsx)("input",{...e("poids",{required:"Le poids est n\xe9cessaire pour estimer vos apports"}),id:"poids",name:"poids",type:"number",required:!0,className:"appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm ".concat(r.poids?"border-red-500":""),placeholder:"poids (en kg)"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{htmlFor:"taille",className:"sr-only",children:"taille"}),(0,a.jsx)("input",{...e("taille",{required:"La taille est n\xe9cessaire pour estimer vos apports"}),id:"taille",name:"taille",type:"number",required:!0,className:"appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm ".concat(r.taille?"border-red-500":""),placeholder:"taille (en cm)"})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("label",{htmlFor:"dateNaissance",className:"mr-3 block text-sm font-medium",style:{color:"#215152"},children:"Date de naissance"}),(0,a.jsx)("div",{className:"mt-1",children:(0,a.jsx)("input",{...e("dateNaissance",{required:"La date de naissance est n\xe9cessaire pour estimer vos apports"}),id:"dateNaissance",name:"dateNaissance",type:"date",required:!0,className:"appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-blue-500 focus:border-blue-500 focus:z-10 sm:text-sm ".concat(r.dateNaissance?"border-red-500":"")})})]})]}),r.email&&(0,a.jsx)("p",{className:"text-red-500 text-xs mt-2",children:r.email.message}),r.password&&(0,a.jsx)("p",{className:"text-red-500 text-xs mt-2",children:r.password.message}),r.genre&&(0,a.jsx)("p",{className:"text-red-500 text-xs mt-2",children:r.genre.message}),r.poids&&(0,a.jsx)("p",{className:"text-red-500 text-xs mt-2",children:r.poids.message}),r.taille&&(0,a.jsx)("p",{className:"text-red-500 text-xs mt-2",children:r.taille.message}),r.dataNaissance&&(0,a.jsx)("p",{className:"text-red-500 text-xs mt-2",children:r.dataNaissance.message}),(0,a.jsx)("div",{children:(0,a.jsx)("button",{type:"submit",className:"group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-[#E63A76] hover:bg-[#F4B6CD] focus:outline-none focus:ring-2 focus:ring-offset-2 focus:bg-[#E63A76]",children:"Inscrivez-vous maintenant !"})}),d&&(0,a.jsx)("p",{className:"text-center text-red-500 mt-2",children:d})]})]})})}},11163:function(e,s,r){e.exports=r(26036)}},function(e){e.O(0,[260,664,536,888,774,179],function(){return e(e.s=75511)}),_N_E=e.O()}]);