11import { useTranslation } from "react-i18next"
2+ import { useNavigate } from "react-router-dom"
23import QrCodeIcon from "@mui/icons-material/QrCode"
34import PasswordIcon from "@mui/icons-material/Password"
45import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline"
56import FactCheckOutlinedIcon from "@mui/icons-material/FactCheckOutlined"
67import LogoutIcon from "@mui/icons-material/Logout"
8+ import LockOutlinedIcon from "@mui/icons-material/LockOutlined"
79import { Col , Page } from "components/layout"
810import is from "../../scripts/is"
911import useAuth from "../../hooks/useAuth"
@@ -12,7 +14,8 @@ import ConnectedWallet from "./ConnectedWallet"
1214
1315export const useManageWallet = ( ) => {
1416 const { t } = useTranslation ( )
15- const { wallet } = useAuth ( )
17+ const navigate = useNavigate ( )
18+ const { wallet, disconnect, lock } = useAuth ( )
1619
1720 const toExport = {
1821 to : "/auth/export" ,
@@ -44,19 +47,31 @@ export const useManageWallet = () => {
4447 icon : < FactCheckOutlinedIcon /> ,
4548 }
4649
47- const toDisconnect = {
48- to : "/auth/disconnect" ,
50+ const disconnectWallet = {
51+ onClick : ( ) => {
52+ disconnect ( )
53+ navigate ( "/" , { replace : true } )
54+ } ,
4955 children : t ( "Disconnect" ) ,
5056 icon : < LogoutIcon /> ,
5157 }
5258
59+ const lockWallet = {
60+ onClick : ( ) => {
61+ lock ( )
62+ navigate ( "/" , { replace : true } )
63+ } ,
64+ children : t ( "Lock" ) ,
65+ icon : < LockOutlinedIcon /> ,
66+ }
67+
5368 if ( ! wallet ) return
5469
55- return is . ledger ( wallet )
56- ? [ toSignMultisig , toDisconnect ]
57- : is . multisig ( wallet )
58- ? [ toPostMultisig , toDelete , toDisconnect ]
59- : [ toExport , toPassword , toDelete , toSignMultisig , toDisconnect ]
70+ return is . multisig ( wallet )
71+ ? [ toPostMultisig , toDelete , disconnectWallet ]
72+ : is . ledger ( wallet )
73+ ? [ toSignMultisig , disconnectWallet ]
74+ : [ toExport , toPassword , toDelete , toSignMultisig , lockWallet ]
6075}
6176
6277const ManageWallets = ( ) => {
0 commit comments