-
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 : Add OpenClassrooms-Student-Center#2 US (Login) + Add Login and…
… Profile pages, update main.css and FeatureItem.jsx, and update NavBar.jsx and Home.jsx
- Loading branch information
Showing
7 changed files
with
173 additions
and
53 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
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 |
---|---|---|
|
@@ -8,6 +8,9 @@ html { | |
|
||
body { | ||
margin: 0; | ||
} | ||
|
||
#root { | ||
display: flex; | ||
flex-direction: column; | ||
min-height: 100vh; | ||
|
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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
import PropTypes from 'prop-types'; | ||
|
||
FeatureItem.propTypes = { | ||
icon: PropTypes.string.isRequired, | ||
title: PropTypes.string.isRequired, | ||
children: PropTypes.string.isRequired | ||
} | ||
const FeatureItem = ({ icon, title, children }) => { | ||
return ( | ||
<div className='feature-item'> | ||
<img src={icon} alt='Feature Icon' className='feature-icon' /> | ||
<h3 className='feature-item-title'>{title}</h3> | ||
<p>{children}</p> | ||
</div> | ||
); | ||
}; | ||
|
||
const FeatureItem = ({icon, title, children}) => { | ||
return ( | ||
<div className='feature-item'> | ||
<img src={icon} alt='Feature Icon' className='feature-icon' /> | ||
<h3 className='feature-item-title'>{title}</h3> | ||
<p>{children}</p> | ||
</div> | ||
); | ||
} | ||
FeatureItem.propTypes = { | ||
icon: PropTypes.string.isRequired, | ||
title: PropTypes.string.isRequired, | ||
children: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default FeatureItem; | ||
export default FeatureItem; |
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
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
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,66 @@ | ||
import { useState } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
const Login = () => { | ||
const [email, setEmail] = useState(''); | ||
const [password, setPassword] = useState(''); | ||
const navigate = useNavigate(); | ||
|
||
const handleSubmit = async (e) => { | ||
e.preventDefault(); | ||
|
||
const response = await fetch('http://localhost:3001/api/v1/user/login', { | ||
method: 'POST', | ||
headers: { 'Content-Type': 'application/json' }, | ||
body: JSON.stringify({ email, password }), | ||
}); | ||
|
||
const data = await response.json(); | ||
|
||
if (response.ok) { | ||
localStorage.setItem('token', data.body.token); | ||
console.log(data.message); | ||
navigate('/profile'); | ||
} else { | ||
window.alert(data.message); | ||
} | ||
}; | ||
|
||
return ( | ||
<main className='main bg-dark'> | ||
<section className='sign-in-content'> | ||
<i className='fa fa-user-circle sign-in-icon'></i> | ||
<h1>Sign In</h1> | ||
<form onSubmit={handleSubmit}> | ||
<div className='input-wrapper'> | ||
<label htmlFor='username'>Username</label> | ||
<input | ||
type='email' | ||
id='username' | ||
placeholder='Email' | ||
value={email} | ||
onChange={(e) => setEmail(e.target.value)} | ||
/> | ||
</div> | ||
<div className='input-wrapper'> | ||
<label htmlFor='password'>Password</label> | ||
<input | ||
type='password' | ||
id='password' | ||
placeholder='Password' | ||
value={password} | ||
onChange={(e) => setPassword(e.target.value)} | ||
/> | ||
</div> | ||
<div className='input-remember'> | ||
<input type='checkbox' id='remember-me' /> | ||
<label htmlFor='remember-me'>Remember me</label> | ||
</div> | ||
<button className='sign-in-button'>Sign In</button> | ||
</form> | ||
</section> | ||
</main> | ||
); | ||
}; | ||
|
||
export default Login; |
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,48 @@ | ||
const Profile = () => { | ||
// const { user } = useAuth(); | ||
return ( | ||
<main className='main bg-dark'> | ||
<div className='header'> | ||
<h1> | ||
Welcome back | ||
<br /> | ||
Tony Jarvis! | ||
</h1> | ||
<button className='edit-button'>Edit Name</button> | ||
</div> | ||
<h2 className='sr-only'>Accounts</h2> | ||
<section className='account'> | ||
<div className='account-content-wrapper'> | ||
<h3 className='account-title'>Argent Bank Checking (x8349)</h3> | ||
<p className='account-amount'>$2,082.79</p> | ||
<p className='account-amount-description'>Available Balance</p> | ||
</div> | ||
<div className='account-content-wrapper cta'> | ||
<button className='transaction-button'>View transactions</button> | ||
</div> | ||
</section> | ||
<section className='account'> | ||
<div className='account-content-wrapper'> | ||
<h3 className='account-title'>Argent Bank Savings (x6712)</h3> | ||
<p className='account-amount'>$10,928.42</p> | ||
<p className='account-amount-description'>Available Balance</p> | ||
</div> | ||
<div className='account-content-wrapper cta'> | ||
<button className='transaction-button'>View transactions</button> | ||
</div> | ||
</section> | ||
<section className='account'> | ||
<div className='account-content-wrapper'> | ||
<h3 className='account-title'>Argent Bank Credit Card (x8349)</h3> | ||
<p className='account-amount'>$184.30</p> | ||
<p className='account-amount-description'>Current Balance</p> | ||
</div> | ||
<div className='account-content-wrapper cta'> | ||
<button className='transaction-button'>View transactions</button> | ||
</div> | ||
</section> | ||
</main> | ||
); | ||
}; | ||
|
||
export default Profile; |