Skip to content

Commit 10939c6

Browse files
committed
fix(web): improve onClick functionality
1 parent 02eed64 commit 10939c6

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

web/src/layout/Header/DesktopHeader.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ import styled, { css } from "styled-components";
33

44
import { useLocation } from "react-router-dom";
55
import { useToggle } from "react-use";
6+
import { useAccount, useChainId } from "wagmi";
67

78
import KlerosSolutionsIcon from "svgs/menu-icons/kleros-solutions.svg";
89

910
import { useLockOverlayScroll } from "hooks/useLockOverlayScroll";
1011

12+
import { DEFAULT_CHAIN } from "consts/chains";
13+
1114
import { landscapeStyle } from "styles/landscapeStyle";
1215
import { responsiveSize } from "styles/responsiveSize";
1316

@@ -21,7 +24,6 @@ import Explore from "./navbar/Explore";
2124
import Menu from "./navbar/Menu";
2225
import Help from "./navbar/Menu/Help";
2326
import Settings from "./navbar/Menu/Settings";
24-
import { useAccount } from "wagmi";
2527

2628
const Container = styled.div`
2729
display: none;
@@ -73,13 +75,14 @@ const StyledKlerosSolutionsIcon = styled(KlerosSolutionsIcon)`
7375
fill: ${({ theme }) => theme.white} !important;
7476
`;
7577

76-
const ConnectWalletContainer = styled.div<{ isConnected: boolean }>`
78+
const ConnectWalletContainer = styled.div<{ isConnected: boolean; isCorrectChain: boolean }>`
7779
label {
7880
color: ${({ theme }) => theme.white};
7981
}
8082
81-
${({ isConnected }) =>
83+
${({ isConnected, isCorrectChain }) =>
8284
isConnected &&
85+
isCorrectChain &&
8386
css`
8487
cursor: pointer;
8588
& > * {
@@ -105,7 +108,9 @@ const DesktopHeader: React.FC = () => {
105108
const [isOnboardingMiniGuidesOpen, toggleIsOnboardingMiniGuidesOpen] = useToggle(false);
106109
const [initialTab, setInitialTab] = useState<number>(0);
107110
const location = useLocation();
111+
const chainId = useChainId();
108112
const { isConnected } = useAccount();
113+
const isCorrectChain = chainId === DEFAULT_CHAIN;
109114

110115
const initializeFragmentURL = useCallback(() => {
111116
const hash = location.hash;
@@ -141,7 +146,10 @@ const DesktopHeader: React.FC = () => {
141146
</MiddleSide>
142147

143148
<RightSide>
144-
<ConnectWalletContainer {...{ isConnected }} onClick={isConnected ? toggleIsSettingsOpen : undefined}>
149+
<ConnectWalletContainer
150+
{...{ isConnected, isCorrectChain }}
151+
onClick={isConnected && isCorrectChain ? toggleIsSettingsOpen : undefined}
152+
>
145153
<ConnectWallet />
146154
</ConnectWalletContainer>
147155
<Menu {...{ toggleIsHelpOpen, toggleIsSettingsOpen }} />

0 commit comments

Comments
 (0)