Skip to content

Commit 1e9a8e0

Browse files
committed
✨ feat: Add login page
1 parent 7f2c1c0 commit 1e9a8e0

File tree

3 files changed

+128
-0
lines changed

3 files changed

+128
-0
lines changed

src/app/login/SubmitBox.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use client';
2+
import { FormEvent } from 'react';
3+
import { Box } from '@mui/material';
4+
5+
// This file holds the handling logic for the login form submission.
6+
export default function LoginSubmitBox({
7+
children,
8+
}: {
9+
children: React.ReactNode;
10+
}) {
11+
const handleSubmit = (event: FormEvent<HTMLFormElement>) => {
12+
event.preventDefault();
13+
const data = new FormData(event.currentTarget);
14+
console.log({
15+
email: data.get('email'),
16+
password: data.get('password'),
17+
});
18+
};
19+
20+
return (
21+
<Box component='form' onSubmit={handleSubmit} noValidate sx={{ mt: 1 }}>
22+
{children}
23+
</Box>
24+
);
25+
}

src/app/login/page.tsx

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import {
2+
Avatar,
3+
Box,
4+
Button,
5+
Checkbox,
6+
FormControlLabel,
7+
Grid,
8+
TextField,
9+
Typography,
10+
} from '@mui/material';
11+
import { LockOutlined } from '@mui/icons-material';
12+
import Copyright from '@/components/Copyright';
13+
import CustomLink from '@/components/CustomLink';
14+
import LoginSubmitBox from './SubmitBox';
15+
16+
export default function Login() {
17+
return (
18+
<>
19+
<Box
20+
sx={{
21+
mt: 8,
22+
display: 'flex',
23+
flexDirection: 'column',
24+
alignItems: 'center',
25+
}}
26+
>
27+
<Avatar sx={{ m: 1, bgcolor: 'secondary.main' }}>
28+
<LockOutlined />
29+
</Avatar>
30+
<Typography component='h1' variant='h5'>
31+
Login
32+
</Typography>
33+
<LoginSubmitBox>
34+
<TextField
35+
margin='normal'
36+
required
37+
fullWidth
38+
id='email'
39+
label='Email Address'
40+
name='email'
41+
autoComplete='email'
42+
autoFocus
43+
/>
44+
<TextField
45+
margin='normal'
46+
required
47+
fullWidth
48+
name='password'
49+
label='Password'
50+
type='password'
51+
id='password'
52+
autoComplete='current-password'
53+
/>
54+
<FormControlLabel
55+
control={<Checkbox value='remember' color='primary' />}
56+
label='Remember me'
57+
/>
58+
<Button
59+
type='submit'
60+
fullWidth
61+
variant='contained'
62+
sx={{ mt: 3, mb: 2 }}
63+
>
64+
Login
65+
</Button>
66+
<Grid container>
67+
<Grid item xs>
68+
<CustomLink href='#' variant='body2'>
69+
Forgot password?
70+
</CustomLink>
71+
</Grid>
72+
<Grid item>
73+
<CustomLink href='/register' variant='body2'>
74+
{"Don't have an account? Sign Up"}
75+
</CustomLink>
76+
</Grid>
77+
</Grid>
78+
</LoginSubmitBox>
79+
</Box>
80+
<Copyright sx={{ mt: 8, mb: 4 }} />
81+
</>
82+
);
83+
}

src/components/Copyright.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Typography } from '@mui/material';
2+
import CustomLink from '@/components/CustomLink';
3+
4+
export default function Copyright(props: any) {
5+
return (
6+
<Typography
7+
variant='body2'
8+
color='text.secondary'
9+
align='center'
10+
{...props}
11+
>
12+
{'Copyright © '}
13+
<CustomLink color='inherit' href='https://mui.com/'>
14+
Bibimbap
15+
</CustomLink>{' '}
16+
{new Date().getFullYear()}
17+
{'.'}
18+
</Typography>
19+
);
20+
}

0 commit comments

Comments
 (0)