Skip to content

Commit

Permalink
Merge pull request #1292 from IntersectMBO/fix/1119-bug-wallet-discon…
Browse files Browse the repository at this point in the history
…nect-unexpected-redirection-to-dashboard-from-governancedrep-pages

fix/1119-bug-wallet-disconnect-unexpected-redirection-to-dashboard-from-governancedrep-pages
  • Loading branch information
Sworzen1 authored Jun 14, 2024
2 parents 8a184d4 + e2e368b commit 5af9a31
Show file tree
Hide file tree
Showing 3 changed files with 2,413 additions and 6,943 deletions.
9 changes: 7 additions & 2 deletions govtool/frontend/src/components/molecules/WalletInfoCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useNavigate } from "react-router-dom";
import { useLocation, useNavigate } from "react-router-dom";
import { Box, Button, Typography } from "@mui/material";

import { PATHS, gray } from "@consts";
Expand All @@ -9,11 +9,16 @@ import { Card } from "./Card";
export const WalletInfoCard = () => {
const { address, disconnectWallet } = useCardano();
const navigate = useNavigate();
const { pathname, hash } = useLocation();
const { t } = useTranslation();

const onClickDisconnect = async () => {
await disconnectWallet();
navigate(PATHS.home);
navigate(
pathname.includes("/connected")
? `${pathname.replace("/connected", "")}${hash}`
: PATHS.home,
);
window.location.reload();
};

Expand Down
9 changes: 7 additions & 2 deletions govtool/frontend/src/components/molecules/WalletOption.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC, useCallback } from "react";
import { To, useNavigate } from "react-router-dom";
import { To, useNavigate, useLocation } from "react-router-dom";
import { Box, CircularProgress, Typography } from "@mui/material";

import { PATHS } from "@consts";
Expand All @@ -23,6 +23,7 @@ export const WalletOptionButton: FC<WalletOption> = ({
cip95Available,
pathToNavigate,
}) => {
const { pathname, hash } = useLocation();
const { enable, isEnableLoading } = useCardano();
const {
palette: { lightBlue },
Expand All @@ -33,7 +34,11 @@ export const WalletOptionButton: FC<WalletOption> = ({
if (isEnableLoading) return;
const result = await enable(name);
if (result?.stakeKey) {
navigate(pathToNavigate ?? PATHS.dashboard);
navigate(
pathToNavigate ?? pathname === "/"
? "/dashboard"
: `connected${pathname}${hash}`,
);
return;
}
navigate(PATHS.stakeKeys);
Expand Down
Loading

0 comments on commit 5af9a31

Please sign in to comment.