55 AlertTitle ,
66 Box ,
77 Button ,
8+ Divider ,
89 FormControl ,
910 FormLabel ,
1011 Heading ,
@@ -26,19 +27,13 @@ import {
2627 useDisclosure ,
2728} from "@chakra-ui/react" ;
2829import cookie from "js-cookie" ;
30+ import NextLink from "next/link" ;
2931import { useRouter } from "next/router" ;
3032import { useEffect , useRef , useState } from "react" ;
3133import useSWRMutation from "swr/mutation" ;
32- import { ELASTIC_API_KEY_NAME } from "@/utils/tools" ;
34+ import { ELASTIC_API_KEY_NAME , swrPOSTFetch } from "@/utils/tools" ;
3335import { ContentCGU } from "@/pages/legals/cgu" ;
34-
35- export async function auth < T > ( url : string , { arg } : { arg : T } ) {
36- return fetch ( url , {
37- method : "POST" ,
38- body : JSON . stringify ( arg ) ,
39- headers : { "Content-Type" : "application/json" } ,
40- } ) ;
41- }
36+ import { WrapperForm } from "./WrapperForm" ;
4237
4338export const FormLogin = ( ) => {
4439 const router = useRouter ( ) ;
@@ -68,15 +63,15 @@ export const FormLogin = () => {
6863
6964 const { trigger : triggerLogin } = useSWRMutation (
7065 "/api/auth" ,
71- auth < { username : string ; password : string } >
66+ swrPOSTFetch < { username : string ; password : string } >
7267 ) ;
7368 const { trigger : triggerVerify } = useSWRMutation (
7469 "/api/auth/verify-code" ,
75- auth < { username : string ; code : string } >
70+ swrPOSTFetch < { username : string ; code : string } >
7671 ) ;
7772 const { trigger : triggerCreateUser } = useSWRMutation (
7873 "/api/auth/create-user" ,
79- auth < { username : string ; versionCGU : string } >
74+ swrPOSTFetch < { username : string ; versionCGU : string } >
8075 ) ;
8176
8277 const startTimer = ( ) => {
@@ -192,7 +187,7 @@ export const FormLogin = () => {
192187 } }
193188 >
194189 < FormControl mb = { [ 4 , 6 ] } >
195- < FormLabel htmlFor = "code" fontSize = { [ "10px " , "12px " ] } fontWeight = { 500 } >
190+ < FormLabel htmlFor = "code" fontSize = { [ "2xs " , "xs " ] } fontWeight = { 500 } >
196191 Code
197192 </ FormLabel >
198193 < InputGroup mb = { 2 } >
@@ -204,7 +199,7 @@ export const FormLogin = () => {
204199 id = "code"
205200 autoFocus
206201 placeholder = "Saisissez votre code"
207- fontSize = { "12px" }
202+ fontSize = "xs"
208203 bg = { "secondary.500" }
209204 value = { code }
210205 onChange = { handleCodeChange }
@@ -253,12 +248,11 @@ export const FormLogin = () => {
253248 < Button
254249 type = "submit"
255250 isDisabled = { isLoading }
256- bg = "primary.500"
257- _hover = { { } }
251+ colorScheme = "primary"
258252 loadingText = "Connexion en cours..."
259253 color = { "white" }
260254 w = { "full" }
261- fontSize = { [ "14px " , "16px " , "18px " ] }
255+ fontSize = { [ "md " , "lg " , "xl " ] }
262256 fontWeight = { 600 }
263257 >
264258 { isLoading ? < Spinner color = "primary.500" /> : < > Je valide -></ > }
@@ -276,7 +270,7 @@ export const FormLogin = () => {
276270 < FormControl mb = { [ 4 , 6 ] } >
277271 < FormLabel
278272 htmlFor = "username"
279- fontSize = { [ "10px " , "12px " ] }
273+ fontSize = { [ "2xs " , "xs " ] }
280274 fontWeight = { 500 }
281275 >
282276 Identifiant
@@ -290,7 +284,7 @@ export const FormLogin = () => {
290284 id = "username"
291285 autoFocus
292286 placeholder = "Saisissez votre adresse email"
293- fontSize = { "12px" }
287+ fontSize = "xs"
294288 bg = { "secondary.500" }
295289 value = { username }
296290 onChange = { handleUsernameChange }
@@ -301,7 +295,7 @@ export const FormLogin = () => {
301295 < FormControl mb = { [ 4 , 6 ] } >
302296 < FormLabel
303297 htmlFor = "password"
304- fontSize = { [ "10px " , "12px " ] }
298+ fontSize = { [ "2xs " , "xs " ] }
305299 fontWeight = { 500 }
306300 >
307301 Mot de passe
@@ -314,7 +308,7 @@ export const FormLogin = () => {
314308 type = { isOpen ? "text" : "password" }
315309 id = "password"
316310 placeholder = "Saisissez votre mot de passe"
317- fontSize = { "12px" }
311+ fontSize = "xs"
318312 bg = { "secondary.500" }
319313 value = { password }
320314 onChange = { handlePasswordChange }
@@ -369,12 +363,11 @@ export const FormLogin = () => {
369363 < Button
370364 type = "submit"
371365 isDisabled = { isLoading }
372- bg = "primary.500"
373- _hover = { { } }
366+ colorScheme = "primary"
374367 loadingText = "Connexion en cours..."
375368 color = { "white" }
376369 w = { "full" }
377- fontSize = { [ "14px " , "16px " , "18px " ] }
370+ fontSize = { [ "md " , "lg " , "xl " ] }
378371 fontWeight = { 600 }
379372 >
380373 { isLoading ? (
@@ -383,41 +376,30 @@ export const FormLogin = () => {
383376 < > Je me connecte -></ >
384377 ) }
385378 </ Button >
379+ < Divider my = { 4 } />
380+ < Text fontSize = { [ "xs" , "sm" ] } color = "neutral.500" >
381+ < Link as = { NextLink } href = "/login/forgot-password" >
382+ Mot de passe oublié ?
383+ </ Link >
384+ </ Text >
386385 </ form >
387386 ) ;
388387
389388 return (
390389 < >
391- < Box
392- display = "flex"
393- justifyContent = "center"
394- alignItems = "center"
395- mx = { "auto" }
396- mt = { [ 8 , 0 ] }
390+ < WrapperForm title = "Connexion 👋" >
391+ < Text
392+ mb = { 6 }
393+ fontSize = { [ "md" , "lg" ] }
394+ fontWeight = { 400 }
395+ color = { "neutral.500" }
397396 >
398- < Box maxW = "sm" mx = { [ 10 , 20 ] } p = { [ 0 , 2 ] } bgColor = "white" >
399- < Heading
400- as = "h1"
401- size = "lg"
402- mb = { 6 }
403- fontSize = { [ "32px" , "48px" ] }
404- fontWeight = { 700 }
405- >
406- Connexion 👋
407- </ Heading >
408- < Text
409- mb = { 6 }
410- fontSize = { [ "14px" , "16px" ] }
411- fontWeight = { 400 }
412- color = { "neutral.500" }
413- >
414- { showCodeForm
415- ? "Vous avez reçu un code par email, merci de le saisir ci-dessous."
416- : "Veuillez vous connecter pour accéder à votre compte." }
417- </ Text >
418- { showCodeForm ? CodeForm : EmailPasswordForm }
419- </ Box >
420- </ Box >
397+ { showCodeForm
398+ ? "Vous avez reçu un code par email, merci de le saisir ci-dessous."
399+ : "Veuillez vous connecter pour accéder à votre compte." }
400+ </ Text >
401+ { showCodeForm ? CodeForm : EmailPasswordForm }
402+ </ WrapperForm >
421403 < Modal
422404 isOpen = { isOpenTerms }
423405 onClose = { onCloseTerms }
0 commit comments