Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matched login to high-fidelity mock ups #50

Merged
merged 4 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Logout from './components/Authentication/Logout';
import SignUp from './components/Authentication/SignUp';
import ForgotPassword from './components/Authentication/ForgotPassword';
import EmailAction from './components/Authentication/EmailAction';
import AwaitConfirmation from './components/Authentication/AwaitConfirmation';
import AUTH_ROLES from './utils/auth_config';
import ProtectedRoute from './utils/ProtectedRoute';
import Catalog from './pages/Catalog/Catalog';
Expand Down Expand Up @@ -50,6 +51,7 @@ const App = () => {
<Route exact path="/forgotpassword" element={<ForgotPassword />} />
<Route exact path="/signUp" element={<SignUp />} />
<Route exact path="/emailAction" element={<EmailAction redirectPath="/" />} />
<Route exact path="/awaitConfirmation" element={<AwaitConfirmation redirectPath="/" />} />
<Route
exact
path="/notification-sandbox"
Expand Down
34 changes: 34 additions & 0 deletions src/components/Authentication/AwaitConfirmation.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Box, Heading, Button, Center, Link} from '@chakra-ui/react';

const AwaitConfirmation = () => {


return (
<Center h="90vh">
<Box pt={4}>
<Heading as='h1' size='lg'>Account Pending Approval</Heading>
<Center>
<Link href="/login">
<Button
style={{
borderRadius: '30px',
marginTop: '30px',
paddingLeft: '80px',
paddingRight: '80px',
width: '140px',
height: '38px',
}}
backgroundColor={'#243268'}
color={'#ffffff'}
_hover={{backgroundColor: '#1A2559'}}
>
Return to login
</Button>
</Link>
</Center>
</Box>
</Center>
)
};

export default AwaitConfirmation;
86 changes: 74 additions & 12 deletions src/components/Authentication/ForgotPassword.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useState } from 'react';
import { sendPasswordReset } from '../../utils/auth_utils';
import { FormControl, Input, Button, Center, Link, Box, Heading, Text} from '@chakra-ui/react';


const ForgotPassword = () => {
const [email, setEmail] = useState();
Expand All @@ -21,22 +23,82 @@ const ForgotPassword = () => {
};

return (
<div>
<h2>Send Reset Email</h2>
<Center h="90vh">
<Box
style={{
margin: 'auto',
textAlign: 'center',
width: '598px',
minWidth: '300px',
}}
>
<Heading as='h1' size='lg'>Reset Password</Heading>
<Text as='h2' size='md' mt={2}>Enter email address associated with account</Text>
{errorMessage && <p>{errorMessage}</p>}
<form onSubmit={handleForgotPassword}>
<input
type="text"
value={email}
onChange={({ target }) => setEmail(target.value)}
placeholder="Email"
/>
<br />
<button type="submit">Send Email</button>
<FormControl>
<Box>
<Input
style={{ width: '360px', height: '48px', marginTop: '40px' }}
type="email"
onChange={({ target }) => setEmail(target.value)}
placeholder="Email Address"
borderColor={"#CBD5E0"}
borderRadius= '3px'
/>
</Box>


<Box
style={{
marginTop: '25px',
marginBottom: '25px',
}}
>
<Link href='/login'>
<Button
style={{
borderRadius: '30px',
borderColor: '#155696',
borderWidth: '1.5px',
marginRight: '16px',
paddingLeft: '80px',
paddingRight: '80px',
width: '140px',
height: '38px',
}}
backgroundColor={'#FFFFFF'}
color={'#155696'}
variant='outline'
_hover={{backgroundColor: '#E0E0E0'}}
>
Cancel
</Button>
</Link>


<Button
type="submit"
style={{
borderRadius: '30px',
marginLeft: '16px',
paddingLeft: '80px',
paddingRight: '80px',
width: '140px',
height: '38px',
}}
backgroundColor={'#243268'}
color={'#ffffff'}
_hover={{backgroundColor: '#1A2559'}}
>
Send Instructions
</Button>
</Box>
</FormControl>
</form>
{confirmationMessage && <p>{confirmationMessage}</p>}
<a href="/">Back to Login</a>
</div>
</Box>
</Center>
);
};

Expand Down
205 changes: 114 additions & 91 deletions src/components/Authentication/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,119 +3,142 @@ import { instanceOf } from 'prop-types';
import { Cookies, withCookies } from '../../utils/cookie_utils';
import { logInWithEmailAndPassword, useNavigate } from '../../utils/auth_utils';
// import { logInWithEmailAndPassword , signInWithGoogle, useNavigate } from '../utils/auth_utils';
import { FormControl, Input, Button, Center } from '@chakra-ui/react';
import { Box, Heading, Text, FormControl, Input, Button, Center, Link, Alert, AlertDescription } from '@chakra-ui/react';
// import styles from

const Login = ({ cookies }) => {
const navigate = useNavigate();
const [email, setEmail] = useState();
const [password, setPassword] = useState();
const [hasError, setHasError] = useState(false);
const [errorMessage, setErrorMessage] = useState();

const handleStdLogin = async e => {
try {
console.log('logging in...');
e.preventDefault();
await logInWithEmailAndPassword(email, password, '/publishedSchedule', navigate, cookies);
window.location.reload(true);
} catch (err) {
setHasError(true);
setErrorMessage(err.message);
}
};

return (
<Center h="100vh">
<div
style={{
margin: 'auto',
textAlign: 'center',
width: '598px',
minWidth: '300px',
padding: '50px, 40px, 40px, 37px',
gap: '25px',
}}
>
<h2>Welcome. Please enter login information.</h2>
{errorMessage && <p>{errorMessage}</p>}
<form onSubmit={handleStdLogin}>
<FormControl>
<div>
<Input
style={{ width: '350px', height: '81px', margin: '20px' }}
type="email"
onChange={({ target }) => setEmail(target.value)}
placeholder="Email"
/>
<Input
style={{ width: '350px', height: '81px', margin: '20px' }}
type="password"
onChange={({ target }) => setPassword(target.value)}
placeholder="Password"
/>
</div>
<Box>
<Box>
{ hasError &&
<Alert
status='warning'
alignItems='center'
justifyContent='center'
height='80px'
position='absolute'
backgroundColor="#F69052"
color="black"
>
<AlertDescription>{ errorMessage }</AlertDescription>
</Alert>
}
</Box>
<Center h="90vh">
<Box
style={{
margin: 'auto',
textAlign: 'center',
width: '598px',
minWidth: '300px',
padding: '50px, 40px, 40px, 37px',
gap: '25px',
}}
>
<Heading as='h1' size='lg'>Sign In</Heading>
<Text as='h2' size='md' mt={2}>Please enter login information.</Text>
<form onSubmit={handleStdLogin}>
<FormControl>
<Box pt={4}>
<Input
style={{ width: '360px', height: '48px', marginTop: '20px' }}
type="email"
onChange={({ target }) => setEmail(target.value)}
placeholder="Email"
borderColor={"#CBD5E0"}
borderRadius= '3px'
/>
<Input
style={{ width: '360px', height: '48px', margin: '20px' }}
type="password"
onChange={({ target }) => setPassword(target.value)}
placeholder="Password"
borderColor={"#CBD5E0"}
borderRadius= '3px'
/>
</Box>

<div
style={{
marginTop: '25px',
marginBottom: '25px',
}}
>
<Button
type="submit"
style={{
borderRadius: '30px',
marginRight: '24px',
width: '130px',
height: '38px',
}}
backgroundColor={'#3182CE'}
color={'white'}
>
Login
</Button>
<Button
<Box
style={{
borderRadius: '30px',
marginLeft: '24px',
width: '130px',
height: '38px',
marginTop: '25px',
marginBottom: '25px',
}}
backgroundColor={'#A0AEC0'}
color={'white'}
>
Create Account
</Button>
</div>

<div>
<a href="/forgotpassword" style={{ fontWeight: 'bold' }}>
Forgot Password
</a>
</div>
</FormControl>
</form>

{/* <h2>Welcome. Please enter login information.</h2>
{errorMessage && <p>{errorMessage}</p>} */}
{/* <form onSubmit={handleStdLogin}>
<input type="text" onChange={({ target }) => setEmail(target.value)} placeholder="Email" />
<br />
<input
type="password"
onChange={({ target }) => setPassword(target.value)}
placeholder="Password"
/>
<br />
<a href="/forgotpassword">Forgot Password</a>
<br />
<button type="submit">Login</button>
</form> */}
<Link href='/signup'>
<Button
style={{
borderRadius: '30px',
borderColor: '#155696',
borderWidth: '1.5px',
marginRight: '16px',
paddingLeft: '80px',
paddingRight: '80px',
width: '140px',
height: '38px',
}}
backgroundColor={'#FFFFFF'}
color={'#155696'}
variant='outline'
onMouseOver={(e) => {
e.target.style.backgroundColor = '#E0E0E0';
}}
onMouseOut={(e) => {
e.target.style.backgroundColor = '#FFFFFF';
}}
>
Create Account
</Button>
</Link>
<Button
type="submit"
style={{
borderRadius: '30px',
marginLeft: '16px',
paddingLeft: '80px',
paddingRight: '80px',
width: '140px',
height: '38px',
}}
backgroundColor={'#243268'}
color={'#ffffff'}
onMouseOver={(e) => {
e.target.style.backgroundColor = '#1A2559';
}}
onMouseOut={(e) => {
e.target.style.backgroundColor = '#243268';
}}
>
Login
</Button>
</Box>

{/* <br />
<form onSubmit={handleGoogleLogin}>
<button type="submit">Sign In with Google</button>
</form>
<br /> */}
</div>
</Center>
<Box>
<a href="/forgotpassword" style={{ textDecoration: "underline"}}>
Forgot Password
</a>
</Box>
</FormControl>
</form>
</Box>
</Center>
</Box>
);
};

Expand Down
Loading
Loading