-
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.
create change password functionality
- Loading branch information
1 parent
b706c2d
commit f73284d
Showing
9 changed files
with
289 additions
and
116 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
This file was deleted.
Oops, something went wrong.
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,88 @@ | ||
import React, { useState } from 'react'; | ||
import { Alert, Box, Button, Grid, Paper, Snackbar, TextField, Typography } from '@mui/material'; | ||
|
||
const ChangePassword = ({ handleChangePassword, errorMessage, successMessage }) => { | ||
const [oldPassword, setOldPassword] = useState(''); | ||
const [newPassword, setNewPassword] = useState(''); | ||
const [confirmPassword, setConfirmPassword] = useState(''); | ||
|
||
const handleSubmit = async (event) => { | ||
event.preventDefault(); | ||
const success = await handleChangePassword(oldPassword, newPassword, confirmPassword); | ||
if (success) { | ||
setOldPassword(''); | ||
setNewPassword(''); | ||
setConfirmPassword(''); | ||
} | ||
}; | ||
|
||
return ( | ||
<Grid item xs={12}> | ||
<Paper elevation={3}> | ||
<Box p={3}> | ||
<Typography variant="h6">Change Password</Typography> | ||
<TextField | ||
variant="outlined" | ||
margin="normal" | ||
required | ||
fullWidth | ||
name="oldPassword" | ||
label="Old Password" | ||
type="password" | ||
id="oldPassword" | ||
autoComplete="current-password" | ||
value={oldPassword} | ||
onChange={(e) => setOldPassword(e.target.value)} | ||
/> | ||
<TextField | ||
variant="outlined" | ||
margin="normal" | ||
required | ||
fullWidth | ||
name="newPassword" | ||
label="New Password" | ||
type="password" | ||
id="newPassword" | ||
autoComplete="current-password" | ||
value={newPassword} | ||
onChange={(e) => setNewPassword(e.target.value)} | ||
/> | ||
<TextField | ||
variant="outlined" | ||
margin="normal" | ||
required | ||
fullWidth | ||
name="confirmPassword" | ||
label="Confirm New Password" | ||
type="password" | ||
id="confirmPassword" | ||
autoComplete="current-password" | ||
value={confirmPassword} | ||
onChange={(e) => setConfirmPassword(e.target.value)} | ||
/> | ||
{successMessage && | ||
<Box mt={2} mb={2}> | ||
<Alert severity="success">{successMessage}</Alert> | ||
</Box> | ||
} | ||
{errorMessage && | ||
<Box mt={2} mb={2}> | ||
<Alert severity="error">{errorMessage}</Alert> | ||
</Box> | ||
} | ||
<Button | ||
type="submit" | ||
fullWidth | ||
variant="contained" | ||
color="primary" | ||
onClick={handleSubmit} | ||
> | ||
Change Password | ||
</Button> | ||
</Box> | ||
</Paper> | ||
</Grid> | ||
); | ||
}; | ||
|
||
export default ChangePassword; |
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,19 @@ | ||
import React from 'react'; | ||
import Card from '@mui/material/Card'; | ||
import CardContent from '@mui/material/CardContent'; | ||
import Grid from '@mui/material/Grid'; | ||
import Typography from '@mui/material/Typography'; | ||
|
||
const InfoCard = ({ Icon, title, content }) => ( | ||
<Grid item xs={12} sm={6} md={4}> | ||
<Card> | ||
<CardContent> | ||
<Icon /> | ||
<Typography variant="h6">{title}</Typography> | ||
<Typography variant="body1">{content}</Typography> | ||
</CardContent> | ||
</Card> | ||
</Grid> | ||
); | ||
|
||
export default InfoCard; |
Oops, something went wrong.