-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor out LogoutButton and match style of other header buttons (#2131
- Loading branch information
Showing
5 changed files
with
53 additions
and
22 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,38 @@ | ||
import { Tooltip, useAuth } from '@chia-network/core'; | ||
import { Trans } from '@lingui/macro'; | ||
import { Logout as LogoutIcon } from '@mui/icons-material'; | ||
import { Button } from '@mui/material'; | ||
import React, { useCallback } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
export default function LogoutButton() { | ||
const navigate = useNavigate(); | ||
const { logOut } = useAuth(); | ||
const ButtonStyle = { | ||
minWidth: 0, | ||
width: '40px', | ||
minHeight: '40px', | ||
borderRadius: '8px', | ||
}; | ||
|
||
const handleLogout = useCallback(async () => { | ||
await logOut(); | ||
|
||
navigate('/'); | ||
}, [logOut, navigate]); | ||
|
||
return ( | ||
<Tooltip title={<Trans>Log Out</Trans>}> | ||
<Button | ||
variant="text" | ||
onClick={handleLogout} | ||
color="secondary" | ||
size="small" | ||
data-testid="AppStatusHeader-log-out" | ||
sx={ButtonStyle} | ||
> | ||
<LogoutIcon color="info" /> | ||
</Button> | ||
</Tooltip> | ||
); | ||
} |
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