🐛 Fixed login page & delete forgot + register page
This commit is contained in:
@@ -1,48 +0,0 @@
|
|||||||
// ---------------------------------------------------------------------------------------------------------------------
|
|
||||||
//! Imports
|
|
||||||
// ---------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// --------------------------------------------------- Components ------------------------------------------------------
|
|
||||||
import Image from 'next/image';
|
|
||||||
// ---------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// ------------------------------------------------- Assets & Styles ---------------------------------------------------
|
|
||||||
import '../styles.scss';
|
|
||||||
// ---------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
const Forgot = () => {
|
|
||||||
return (
|
|
||||||
<div className='authContainer'>
|
|
||||||
<Image
|
|
||||||
src={'/logo-transparent.png'}
|
|
||||||
className='appLogo'
|
|
||||||
alt='appLogo'
|
|
||||||
width={1024}
|
|
||||||
height={1024}
|
|
||||||
/>
|
|
||||||
<div className='formContainer'>
|
|
||||||
<h1 className='formTitle'>Connexion</h1>
|
|
||||||
|
|
||||||
<div
|
|
||||||
role='form'
|
|
||||||
className='form'
|
|
||||||
>
|
|
||||||
<div className='inputContainer'>
|
|
||||||
<input
|
|
||||||
type='password'
|
|
||||||
name='password'
|
|
||||||
className='input'
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
<label className='inputLabel'>Mot de passe</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className='buttonsContainer'>
|
|
||||||
<button className='submitButton'>Se connecter</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Forgot;
|
|
||||||
@@ -58,13 +58,6 @@ const Login = () => {
|
|||||||
/>
|
/>
|
||||||
<label className='inputLabel'>Mot de passe</label>
|
<label className='inputLabel'>Mot de passe</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Link
|
|
||||||
href={'/auth/forgot'}
|
|
||||||
className='forgetLink'
|
|
||||||
>
|
|
||||||
Mot de passe oublié ?
|
|
||||||
</Link>
|
|
||||||
</div>
|
</div>
|
||||||
<div className='buttonsContainer'>
|
<div className='buttonsContainer'>
|
||||||
<button
|
<button
|
||||||
@@ -73,12 +66,6 @@ const Login = () => {
|
|||||||
>
|
>
|
||||||
Se connecter
|
Se connecter
|
||||||
</button>
|
</button>
|
||||||
<Link
|
|
||||||
href={'/auth/register'}
|
|
||||||
className='submitButton secondary'
|
|
||||||
>
|
|
||||||
S'inscrire
|
|
||||||
</Link>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
export const useActions = ({
|
|
||||||
usernameRef,
|
|
||||||
emailRef,
|
|
||||||
passwordRef,
|
|
||||||
confpasswordRef,
|
|
||||||
}) => {
|
|
||||||
const handleSubmit = () => {};
|
|
||||||
|
|
||||||
return {
|
|
||||||
handleSubmit,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
import { useRef } from 'react';
|
|
||||||
|
|
||||||
export const useData = () => {
|
|
||||||
const usernameRef = useRef(null);
|
|
||||||
const emailRef = useRef(null);
|
|
||||||
const passwordRef = useRef(null);
|
|
||||||
const confpasswordRef = useRef(null);
|
|
||||||
|
|
||||||
return {
|
|
||||||
usernameRef,
|
|
||||||
emailRef,
|
|
||||||
passwordRef,
|
|
||||||
confpasswordRef,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
'use client';
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------------------------------------------
|
|
||||||
//! Imports
|
|
||||||
// ---------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// --------------------------------------------------- Components ------------------------------------------------------
|
|
||||||
import Image from 'next/image';
|
|
||||||
import Link from 'next/link';
|
|
||||||
// ---------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// -------------------------------------------------- Hooks & Utils ----------------------------------------------------
|
|
||||||
import { useData } from './hooks/useData';
|
|
||||||
import { useActions } from './hooks/useActions';
|
|
||||||
// ---------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// ------------------------------------------------- Assets & Styles ---------------------------------------------------
|
|
||||||
import '../styles.scss';
|
|
||||||
// ---------------------------------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
const Register = () => {
|
|
||||||
const { usernameRef, emailRef, passwordRef, confpasswordRef } = useData();
|
|
||||||
const { handleSubmit } = useActions({
|
|
||||||
usernameRef,
|
|
||||||
emailRef,
|
|
||||||
passwordRef,
|
|
||||||
confpasswordRef,
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='authContainer'>
|
|
||||||
<Image
|
|
||||||
src={'/logo-transparent.png'}
|
|
||||||
className='appLogo'
|
|
||||||
alt='appLogo'
|
|
||||||
width={1024}
|
|
||||||
height={1024}
|
|
||||||
/>
|
|
||||||
<div className='formContainer'>
|
|
||||||
<h1 className='formTitle'>Inscription</h1>
|
|
||||||
|
|
||||||
<div
|
|
||||||
role='form'
|
|
||||||
className='form'
|
|
||||||
>
|
|
||||||
<div className='inputContainer'>
|
|
||||||
<input
|
|
||||||
ref={usernameRef}
|
|
||||||
type='text'
|
|
||||||
name='name'
|
|
||||||
className='input'
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
<label className='inputLabel'>
|
|
||||||
Nom d'utilisateur
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div className='inputContainer'>
|
|
||||||
<input
|
|
||||||
ref={emailRef}
|
|
||||||
type='email'
|
|
||||||
name='email'
|
|
||||||
className='input'
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
<label className='inputLabel'>Adresse e-mail</label>
|
|
||||||
</div>
|
|
||||||
<div className='inputContainer'>
|
|
||||||
<input
|
|
||||||
ref={passwordRef}
|
|
||||||
type='password'
|
|
||||||
name='password'
|
|
||||||
className='input'
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
<label className='inputLabel'>Mot de passe</label>
|
|
||||||
</div>
|
|
||||||
<div className='inputContainer'>
|
|
||||||
<input
|
|
||||||
ref={confpasswordRef}
|
|
||||||
type='password'
|
|
||||||
name='confpassword'
|
|
||||||
className='input'
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
<label className='inputLabel'>
|
|
||||||
Confirmer le mot de passe
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className='buttonsContainer'>
|
|
||||||
<button
|
|
||||||
className='submitButton'
|
|
||||||
onClick={handleSubmit}
|
|
||||||
>
|
|
||||||
S'inscrire
|
|
||||||
</button>
|
|
||||||
<Link
|
|
||||||
href={'/auth/login'}
|
|
||||||
className='submitButton secondary'
|
|
||||||
>
|
|
||||||
Se connecter
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Register;
|
|
||||||
+11
-10
@@ -2,15 +2,16 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
gap: 50px;
|
||||||
|
padding: 15svh;
|
||||||
width: 100svw;
|
width: 100svw;
|
||||||
height: 100svh;
|
height: 100svh;
|
||||||
|
|
||||||
& > .appLogo {
|
& > .appLogo {
|
||||||
position: absolute;
|
margin-top: -50px;
|
||||||
top: 5svh;
|
|
||||||
width: 30svw;
|
width: 30svw;
|
||||||
|
max-width: 150px;
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,10 +20,10 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
padding: 30px 60px;
|
padding: 20px 30px;
|
||||||
width: 95svw;
|
width: 95svw;
|
||||||
max-width: 450px;
|
max-width: 450px;
|
||||||
border: 3px solid #fefefa;
|
border: 2px solid #fefefa;
|
||||||
border-radius: 7px;
|
border-radius: 7px;
|
||||||
background-color: #d94253;
|
background-color: #d94253;
|
||||||
|
|
||||||
@@ -60,7 +61,7 @@
|
|||||||
|
|
||||||
& > .input {
|
& > .input {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border: 2px solid #fefefa;
|
border: 1px solid #fefefa;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
background-color: #d94253;
|
background-color: #d94253;
|
||||||
outline: none;
|
outline: none;
|
||||||
@@ -102,8 +103,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
& > .buttonsContainer {
|
& > .buttonsContainer {
|
||||||
display: grid;
|
display: flex;
|
||||||
grid-template-columns: repeat(2, 1fr);
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 30px;
|
gap: 30px;
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
@@ -113,8 +114,8 @@
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 5px;
|
gap: 5px;
|
||||||
padding: 7px 21px;
|
padding: 7px 35px;
|
||||||
border: 2px solid #fefefa;
|
border: 1px solid #fefefa;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
background-color: #fefefa;
|
background-color: #fefefa;
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
|
|||||||
+2
-3
@@ -1,6 +1,6 @@
|
|||||||
import { Inter } from 'next/font/google';
|
import { Inter } from 'next/font/google';
|
||||||
|
import Provider from './provider';
|
||||||
import './globals.scss';
|
import './globals.scss';
|
||||||
import Navbar from '@/components/Navbar/Navbar';
|
|
||||||
|
|
||||||
const inter = Inter({ subsets: ['latin'] });
|
const inter = Inter({ subsets: ['latin'] });
|
||||||
|
|
||||||
@@ -12,8 +12,7 @@ const RootLayout = ({ children }) => {
|
|||||||
return (
|
return (
|
||||||
<html lang='fr'>
|
<html lang='fr'>
|
||||||
<body className={inter.className}>
|
<body className={inter.className}>
|
||||||
{children}
|
<Provider>{children}</Provider>
|
||||||
<Navbar />
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------------------------------------------------
|
||||||
|
//! Imports
|
||||||
|
// ---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// -------------------------------------------------- React & Next -----------------------------------------------------
|
||||||
|
import { useEffect, useState } from 'react';
|
||||||
|
import { redirect, usePathname } from 'next/navigation';
|
||||||
|
import Navbar from '@/components/Navbar/Navbar';
|
||||||
|
// ---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
const Provider = ({ children }) => {
|
||||||
|
const pathname = usePathname();
|
||||||
|
const [isSuccess, setIsSuccess] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (pathname.startsWith('/auth')) {
|
||||||
|
setIsSuccess(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const token = localStorage.getItem('token');
|
||||||
|
|
||||||
|
if (!token) {
|
||||||
|
redirect('/auth/login');
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsSuccess(true);
|
||||||
|
}, [pathname]);
|
||||||
|
|
||||||
|
if (!isSuccess) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathname.startsWith('/auth')) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{children}
|
||||||
|
<Navbar />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Provider;
|
||||||
@@ -4,6 +4,9 @@ const nextConfig = {
|
|||||||
env: {
|
env: {
|
||||||
MAPBOX_TOKEN: process.env.MAPBOX_TOKEN,
|
MAPBOX_TOKEN: process.env.MAPBOX_TOKEN,
|
||||||
},
|
},
|
||||||
|
images: {
|
||||||
|
unoptimized: true,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default nextConfig;
|
||||||
|
|||||||
Reference in New Issue
Block a user