-
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
1 parent
4a1a44a
commit 53528d7
Showing
6 changed files
with
143 additions
and
30 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
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,85 @@ | ||
import React, { useState } from 'react'; | ||
import { Box, Typography, TextField, Button } from '@mui/material'; | ||
import { useTheme } from '@mui/material/styles'; | ||
import authService from '../services/auth'; | ||
import {toast} from "react-toastify"; | ||
import CircularProgress from "@mui/material/CircularProgress"; | ||
|
||
const ForgotPasswordPage = () => { | ||
const [email, setEmail] = useState(''); | ||
const [isLoading, setIsLoading] = useState(false) | ||
const theme = useTheme(); | ||
|
||
const handleEmailChange = (event) => { | ||
setEmail(event.target.value); | ||
}; | ||
|
||
const handleSubmit = async (event) => { | ||
setIsLoading(true) | ||
event.preventDefault(); | ||
const data = {email}; | ||
try{ | ||
const response = await authService.forgotPassword(data) | ||
console.log('response: ', response) | ||
if (response.status===200) { | ||
toast.info('An email has been sent to your email address with instructions to reset your password') | ||
} | ||
} catch (error){ | ||
console.log('error sending forgot password request: ', error) | ||
toast.error('Error sending forgot password request') | ||
} finally { | ||
setIsLoading(false) | ||
} | ||
}; | ||
|
||
return ( | ||
<Box | ||
component="form" | ||
onSubmit={handleSubmit} | ||
sx={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
width: '300px', | ||
margin: '0 auto', | ||
gap: '20px', | ||
marginTop: '100px', | ||
backgroundColor: '#FFFFFF', | ||
padding: '20px', | ||
borderRadius: '10px', | ||
boxShadow: `0 0 10px ${theme.palette.grey[200]}`, // Example box shadow | ||
}} | ||
> | ||
<Typography variant="h4" component="h2" align='center'> | ||
Forgot Password | ||
</Typography> | ||
<Typography variant="body1" align='center'> | ||
Please enter your registered email address | ||
</Typography> | ||
<TextField | ||
label="Email" | ||
variant="outlined" | ||
name="email" | ||
type="email" | ||
value={email} | ||
onChange={handleEmailChange} | ||
required | ||
/> | ||
<Button | ||
variant="contained" | ||
type="submit" | ||
sx={{ | ||
backgroundColor: theme.palette.primary.main, | ||
color: '#FFFFFF', | ||
padding: '10px 20px', | ||
borderRadius: '10px', | ||
alignSelf: 'center', | ||
}} | ||
disabled={isLoading} | ||
> | ||
{isLoading ? <CircularProgress size={24} /> : 'Submit'} | ||
</Button> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default ForgotPasswordPage; |
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,5 @@ | ||
const ResetPasswordPage = () => { | ||
|
||
} | ||
|
||
export default ResetPasswordPage; |