-
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.
Merge pull request #32 from AAISS/feat/add-log-out
feat: add logout
- Loading branch information
Showing
4 changed files
with
179 additions
and
130 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import { Dialog, DialogTitle, DialogContent, DialogContentText, DialogActions, Button } from '@mui/material'; | ||
import PropTypes from 'prop-types'; | ||
import ROUTES from '../../providers/config-provider/ROUTES'; | ||
|
||
const LogoutModal = ({ visibility, onVisibilityChange }) => { | ||
const handleLogout = () => { | ||
localStorage.removeItem('user'); | ||
onVisibilityChange(); | ||
|
||
window.location.reload(); | ||
window.location.replace(ROUTES.signup.path); | ||
}; | ||
|
||
return ( | ||
<Dialog | ||
onClose={onVisibilityChange} | ||
open={visibility} | ||
PaperProps={{ | ||
style: { | ||
backgroundColor: 'var(--background-color-lighter-20)', | ||
}, | ||
}} | ||
> | ||
<DialogTitle variant="h5">Logout</DialogTitle> | ||
<DialogContent> | ||
<DialogContentText>Are you sure you want to logout?</DialogContentText> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={onVisibilityChange}>Cancel</Button> | ||
<Button onClick={handleLogout} color="error" variant="contained"> | ||
Logout | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
LogoutModal.propTypes = { | ||
visibility: PropTypes.bool, | ||
onVisibilityChange: PropTypes.func, | ||
}; | ||
|
||
export default LogoutModal; |
Oops, something went wrong.