-
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.
- Loading branch information
Showing
8 changed files
with
575 additions
and
10 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 |
---|---|---|
@@ -1,7 +1,18 @@ | ||
import React from 'react'; | ||
import { Routes, Route } from 'react-router-dom'; | ||
import Signup from '../components/signup/signup'; | ||
import Login from '../components/login/login'; | ||
|
||
function App() { | ||
return <>App</>; | ||
return ( | ||
<div> | ||
<Routes> | ||
<Route path="/" element={<Login />} /> | ||
<Route path="/signup" element={<Signup />} /> | ||
<Route path="/login" element={<Login />} /> | ||
</Routes> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
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,117 @@ | ||
import * as React from 'react'; | ||
import Avatar from '@mui/material/Avatar'; | ||
import Button from '@mui/material/Button'; | ||
import CssBaseline from '@mui/material/CssBaseline'; | ||
import TextField from '@mui/material/TextField'; | ||
import Link from '@mui/material/Link'; | ||
import Paper from '@mui/material/Paper'; | ||
import Box from '@mui/material/Box'; | ||
import Grid from '@mui/material/Grid'; | ||
import LockOutlinedIcon from '@mui/icons-material/LockOutlined'; | ||
import Typography from '@mui/material/Typography'; | ||
import { createTheme, ThemeProvider } from '@mui/material/styles'; | ||
|
||
const theme = createTheme(); | ||
|
||
function Login() { | ||
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => { | ||
event.preventDefault(); | ||
const data = new FormData(event.currentTarget); | ||
console.log({ | ||
email: data.get('email'), | ||
password: data.get('password'), | ||
}); | ||
}; | ||
|
||
return ( | ||
<ThemeProvider theme={theme}> | ||
<Grid container component="main" sx={{ height: '100vh' }}> | ||
<CssBaseline /> | ||
<Grid | ||
item | ||
xs={false} | ||
sm={4} | ||
md={7} | ||
sx={{ | ||
backgroundImage: 'url(https://source.unsplash.com/random)', | ||
backgroundRepeat: 'no-repeat', | ||
backgroundColor: (t) => | ||
t.palette.mode === 'light' | ||
? t.palette.grey[50] | ||
: t.palette.grey[900], | ||
backgroundSize: 'cover', | ||
backgroundPosition: 'center', | ||
}} | ||
/> | ||
<Grid item xs={12} sm={8} md={5} component={Paper} elevation={6} square> | ||
<Box | ||
sx={{ | ||
my: 8, | ||
mx: 4, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<Avatar sx={{ m: 1, bgcolor: 'secondary.main' }}> | ||
<LockOutlinedIcon /> | ||
</Avatar> | ||
<Typography component="h1" variant="h5"> | ||
Login | ||
</Typography> | ||
<Box | ||
component="form" | ||
noValidate | ||
onSubmit={handleSubmit} | ||
sx={{ mt: 1 }} | ||
> | ||
<TextField | ||
margin="normal" | ||
required | ||
fullWidth | ||
id="email" | ||
label="Email Address" | ||
name="email" | ||
autoComplete="email" | ||
autoFocus | ||
/> | ||
<TextField | ||
margin="normal" | ||
required | ||
fullWidth | ||
name="password" | ||
label="Password" | ||
type="password" | ||
id="password" | ||
autoComplete="current-password" | ||
/> | ||
<Button | ||
type="submit" | ||
fullWidth | ||
variant="contained" | ||
sx={{ mt: 3, mb: 2 }} | ||
> | ||
Sign In | ||
</Button> | ||
<Grid container> | ||
<Grid item xs> | ||
<Link href="#" variant="body2"> | ||
Forgot password? | ||
</Link> | ||
</Grid> | ||
<Grid item> | ||
<Link href="#" variant="body2"> | ||
{"Don't have an account? Sign Up"} | ||
</Link> | ||
</Grid> | ||
</Grid> | ||
Created By Donald Wu | ||
</Box> | ||
</Box> | ||
</Grid> | ||
</Grid> | ||
</ThemeProvider> | ||
); | ||
} | ||
|
||
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,117 @@ | ||
import * as React from 'react'; | ||
import Avatar from '@mui/material/Avatar'; | ||
import Button from '@mui/material/Button'; | ||
import CssBaseline from '@mui/material/CssBaseline'; | ||
import TextField from '@mui/material/TextField'; | ||
import Link from '@mui/material/Link'; | ||
import Paper from '@mui/material/Paper'; | ||
import Box from '@mui/material/Box'; | ||
import Grid from '@mui/material/Grid'; | ||
import LockOutlinedIcon from '@mui/icons-material/LockOutlined'; | ||
import Typography from '@mui/material/Typography'; | ||
import { createTheme, ThemeProvider } from '@mui/material/styles'; | ||
|
||
const theme = createTheme(); | ||
|
||
function Signup() { | ||
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => { | ||
event.preventDefault(); | ||
const data = new FormData(event.currentTarget); | ||
console.log({ | ||
email: data.get('email'), | ||
password: data.get('password'), | ||
}); | ||
}; | ||
|
||
return ( | ||
<ThemeProvider theme={theme}> | ||
<Grid container component="main" sx={{ height: '100vh' }}> | ||
<CssBaseline /> | ||
<Grid | ||
item | ||
xs={false} | ||
sm={4} | ||
md={7} | ||
sx={{ | ||
backgroundImage: 'url(https://source.unsplash.com/random)', | ||
backgroundRepeat: 'no-repeat', | ||
backgroundColor: (t) => | ||
t.palette.mode === 'light' | ||
? t.palette.grey[50] | ||
: t.palette.grey[900], | ||
backgroundSize: 'cover', | ||
backgroundPosition: 'center', | ||
}} | ||
/> | ||
<Grid item xs={12} sm={8} md={5} component={Paper} elevation={6} square> | ||
<Box | ||
sx={{ | ||
my: 8, | ||
mx: 4, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<Avatar sx={{ m: 1, bgcolor: 'secondary.main' }}> | ||
<LockOutlinedIcon /> | ||
</Avatar> | ||
<Typography component="h1" variant="h5"> | ||
Login | ||
</Typography> | ||
<Box | ||
component="form" | ||
noValidate | ||
onSubmit={handleSubmit} | ||
sx={{ mt: 1 }} | ||
> | ||
<TextField | ||
margin="normal" | ||
required | ||
fullWidth | ||
id="email" | ||
label="Email Address" | ||
name="email" | ||
autoComplete="email" | ||
autoFocus | ||
/> | ||
<TextField | ||
margin="normal" | ||
required | ||
fullWidth | ||
name="password" | ||
label="Password" | ||
type="password" | ||
id="password" | ||
autoComplete="current-password" | ||
/> | ||
<Button | ||
type="submit" | ||
fullWidth | ||
variant="contained" | ||
sx={{ mt: 3, mb: 2 }} | ||
> | ||
Sign In | ||
</Button> | ||
<Grid container> | ||
<Grid item xs> | ||
<Link href="#" variant="body2"> | ||
Forgot password? | ||
</Link> | ||
</Grid> | ||
<Grid item> | ||
<Link href="#" variant="body2"> | ||
{"Don't have an account? Sign Up"} | ||
</Link> | ||
</Grid> | ||
</Grid> | ||
Created By Donald Wu | ||
</Box> | ||
</Box> | ||
</Grid> | ||
</Grid> | ||
</ThemeProvider> | ||
); | ||
} | ||
|
||
export default Signup; |
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,4 @@ | ||
export const getRootUrl = () => { | ||
const rootUrl = `localhost:3333/api`; | ||
return rootUrl; | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,30 @@ | ||
import axios from 'axios'; | ||
import { UserRole } from '@prisma/client'; | ||
import { getRootUrl } from '../helper/helper'; | ||
|
||
const rootUrl = getRootUrl(); | ||
|
||
export const signup = async ( | ||
email: string, | ||
password: string, | ||
userRoles: UserRole[] | ||
) => { | ||
const data = { | ||
email: email, | ||
password: password, | ||
userRoles: userRoles, | ||
}; | ||
|
||
const response = await axios.post(`${rootUrl}/user/signup`, data); | ||
return response; | ||
}; | ||
|
||
export const login = async (email: string, password: string) => { | ||
const data = { | ||
email: email, | ||
password: password, | ||
}; | ||
|
||
const response = await axios.post(`${rootUrl}/user/login`, data); | ||
return response; | ||
}; |
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
Oops, something went wrong.