generated from 202306-NEA-DZ-FEW/capstone-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(index.jsx): change link on sign up or reset password
- Loading branch information
1 parent
dd8b246
commit 5782eeb
Showing
2 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import React, { useState } from "react"; | ||
import { useAuth } from "@/context/AuthContext"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
export default function LoginForm() { | ||
const [email, setEmail] = useState(""); | ||
const [password, setPassword] = useState(""); | ||
const { login, currentUser } = useAuth(); | ||
const navigate = useNavigate(); | ||
|
||
function handleLogin(e) { | ||
e.preventDefault(); | ||
console.log("whatever"); | ||
login(email, password) | ||
.then(() => { | ||
navigate("/account"); | ||
}) | ||
.catch((error) => { | ||
console.log("error"); | ||
}); | ||
} | ||
console.log(currentUser); | ||
|
||
return ( | ||
<div className='flex justify-center items-center h-screen'> | ||
<div className='w-full max-w-md'> | ||
<h1 className='text-3xl font-semibold text-center mb-4'> | ||
Log in | ||
</h1> | ||
<form className='bg-white rounded px-8 pt-6 pb-8 mb-4'> | ||
<div className='mb-4'> | ||
<label | ||
className='block text-gray-700 text-sm font-bold mb-2' | ||
htmlFor='email' | ||
> | ||
</label> | ||
<input | ||
className='border-emerald-600 border-2 appearance-none border rounded-2xl w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline' | ||
id='email' | ||
type='email' | ||
placeholder='[email protected]' | ||
value={email} | ||
onChange={(e) => setEmail(e.target.value)} | ||
required | ||
/> | ||
</div> | ||
<div className='mb-6'> | ||
<label | ||
className='block text-gray-700 text-sm font-bold mb-2' | ||
htmlFor='password' | ||
> | ||
Password | ||
</label> | ||
<input | ||
className='border-emerald-600 border-2 appearance-none border rounded-2xl w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline' | ||
id='password' | ||
type='password' | ||
placeholder='********' | ||
value={password} | ||
onChange={(e) => setPassword(e.target.value)} | ||
required | ||
/> | ||
</div> | ||
<div className='mb-6'> | ||
<label className='block text-gray-700 text-sm font-light mb-2 cursor-pointer'> | ||
<input | ||
type='checkbox' | ||
className='mr-2 leading-tight' | ||
/> | ||
Keep me logged in | ||
</label> | ||
</div> | ||
<button | ||
className='bg-[#16a34a] hover:bg-[#16a32a] active:bg-violet-700 focus:outline-none focus:ring focus:ring-violet-300 w-full rounded-2xl py-2 px-4' | ||
type='submit' | ||
onClick={(e) => handleLogin(e)} | ||
> | ||
Log in | ||
</button> | ||
</form> | ||
<div className='text-center'> | ||
Don't have an account?{" "} | ||
<a className='underline' href='/sign-up'> | ||
Sign up | ||
</a> | ||
<a | ||
className='block text-centertext-sm mt-2 underline' | ||
href='/reset-password' | ||
> | ||
Forgot Password? | ||
</a> | ||
</div> | ||
<div className='my-4 text-center'> | ||
<p className='font-bold'>Log in with:</p> | ||
<div className='flex justify-center'> | ||
<button className='bg-blue-700 hover:bg-blue-800 text-white font-bold py-2 px-4 rounded mx-2'> | ||
</button> | ||
<button className='bg-blue-700 hover:bg-blue-800 text-white font-bold py-2 px-4 rounded mx-2'> | ||
</button> | ||
<button className='bg-blue-700 hover:bg-blue-800 text-white font-bold py-2 px-4 rounded mx-2'> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import Footer from "@/components/footer/Footer"; | ||
import Navbar from "@/components/navbar/Navbar"; | ||
import LoginForm from "@/components/loginform"; | ||
import { BrowserRouter as Router } from "react-router-dom"; // Import Router | ||
import React from "react"; | ||
|
||
export default function Login() { | ||
return ( | ||
<Router> | ||
{" "} | ||
{/* Wrap your components with the Router */} | ||
<div> | ||
<Navbar /> | ||
<div> | ||
<div> | ||
<LoginForm /> | ||
</div> | ||
<div></div> | ||
</div> | ||
<Footer /> | ||
</div> | ||
</Router> | ||
); | ||
} |