add shortcut on login
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import styles from "./RegisterPage.module.css";
|
||||
import Background from "../../components/Background/Background.jsx";
|
||||
import Background from "../../components/Background/Background";
|
||||
import Input from "../../components/ui/Input/Input";
|
||||
import Button from "../../components/ui/Button/Button";
|
||||
import {useContext, useEffect, useState} from "react";
|
||||
import register from "../../utils/register.js";
|
||||
import { useNavigate } from "react-router";
|
||||
import { AuthContext } from "../../contexts/Auth/AuthContext.js";
|
||||
import { AuthContext } from "../../contexts/Auth/AuthContext";
|
||||
import Modal from "../../components/ui/Modal/Modal";
|
||||
import {AuthContextType } from "../../../src/contexts/Auth/AuthContext";
|
||||
|
||||
|
||||
function RegisterPage() {
|
||||
@@ -22,8 +23,7 @@ function RegisterPage() {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [title, setTitle] = useState("");
|
||||
const [message, setMessage] = useState("");
|
||||
|
||||
const { user, loading } = useContext(AuthContext)
|
||||
const { user, loading } = useContext(AuthContext) as AuthContextType
|
||||
|
||||
useEffect(() => {
|
||||
if (!loading && user) {
|
||||
@@ -31,15 +31,21 @@ function RegisterPage() {
|
||||
}
|
||||
}, [loading, user]);
|
||||
|
||||
const handleModal = (t, m) => {
|
||||
const handleModal = (t: string, m: string) => {
|
||||
setTitle(t)
|
||||
setMessage(m)
|
||||
setOpen(true);
|
||||
}
|
||||
|
||||
async function handleSubmit(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||
if (e.key === 'Enter') {
|
||||
handleSubmit();
|
||||
}
|
||||
};
|
||||
|
||||
async function handleSubmit():Promise<void>
|
||||
{
|
||||
|
||||
if(!(password === confirmPassword)) handleModal("Mot de passe invalide", "Les mots de passes ne conrrespondent pas");
|
||||
else if(password.length < 8) handleModal("Mot de passe invalide", "Le mot de passe doit faire plus de 8 charactères");
|
||||
else {
|
||||
@@ -54,7 +60,7 @@ function RegisterPage() {
|
||||
}
|
||||
}
|
||||
|
||||
const handlePhone = (e) => {
|
||||
const handlePhone = (e:React.ChangeEvent<HTMLInputElement>) => {
|
||||
const value = e.target.value;
|
||||
if (value === "" || /^[0-9 +]+$/.test(value)) {
|
||||
setPhone(value);
|
||||
@@ -62,13 +68,13 @@ function RegisterPage() {
|
||||
};
|
||||
|
||||
|
||||
return <Background>
|
||||
return <Background className="">
|
||||
|
||||
<div className={styles.container}>
|
||||
|
||||
<h1 className={styles.title}>Créer un compte</h1>
|
||||
|
||||
<div className={`glassCard ${styles.inputContainer}`}>
|
||||
<div className={`glassCard ${styles.inputContainer}`} onKeyDown={handleKeyDown}>
|
||||
|
||||
<div className={styles.formGroup}>
|
||||
<Input
|
||||
Reference in New Issue
Block a user