Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable stake button if selected mainnet tab #8

Merged
merged 1 commit into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useEffect, useState } from 'react';
import classNames from 'classnames';

import style from './index.module.css';
Expand All @@ -24,8 +24,9 @@ const ConnectWalletButton = ({ handleAddress }: { handleAddress: (value: boolean
};

const address = accountId?.[0];

handleAddress(!address);
useEffect(() => {
handleAddress(!address);
});

const handleConnect = () => {
setShowPopup(true);
Expand Down
8 changes: 1 addition & 7 deletions apps/ui/src/components/molecules/imageSuspense/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,7 @@ const ImgSuspense = ({
/>
{((!isLoaded && fallback) || !isLoaded || isLoading) && (
<div className={styles.loader} style={loaderStyle ?? { width: '42px', height: '42px' }}>
<Image
src={loader}
alt="preloader"
style={{ width: '42px', height: '32px' }}
width={32}
height={32}
/>
<Image src={loader} alt="preloader" width={32} height={32} />
</div>
)}
</>
Expand Down
4 changes: 2 additions & 2 deletions apps/ui/src/components/organisms/pageHeader/pageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import style from './index.module.css';
import { formatNum } from '../../../comman/helpers';
import { useBalances } from '../../../store/hooks/useBalances';

const PageHeader = () => {
const PageHeader = ({ isStakeAvailable }: { isStakeAvailable: boolean }): JSX.Element => {
const [openStakeModul, setOpenStaekeModul] = useState<boolean>(false);
const [isDisableStakeButton, setIsDisableStakeButton] = useState<boolean>(true);
const { accountId, balance: balanceByWallet } = useWallet();
Expand All @@ -32,7 +32,7 @@ const PageHeader = () => {
text="Stake"
variant={Variant.blue}
onClick={() => setOpenStaekeModul(true)}
disabled={isDisableStakeButton}
disabled={isDisableStakeButton || !isStakeAvailable}
/>
<StakeModalController open={openStakeModul} closeModal={() => setOpenStaekeModul(false)} />
</div>
Expand Down
4 changes: 3 additions & 1 deletion apps/ui/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export default function Home(): JSX.Element {
useObserveBalance();
usePollBlockHeight();

const isStakeAvailable = activTab === tabSwitcherOptions[1];

useEffect(() => {
if (window.localStorage.getItem('isConnectedAuro') === 'true') {
initAccount();
Expand All @@ -45,7 +47,7 @@ export default function Home(): JSX.Element {
<link rel="icon" href="/assets/favicon.ico" />
</Head>
<div className={styles.content}>
<PageHeader />
<PageHeader isStakeAvailable={isStakeAvailable} />
<Header title="Leaderboard" />
<TabSwitcher options={tabSwitcherOptions} onClick={handleTabSwitcher} />
<LeaderboardTables activeTab={activTab} />
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/store/wallet/walletSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const walletSlice = createSlice({
};
},
addPendingTransaction: (state, action: PayloadAction<PendingTransactions>) => {
state.pendingTransactions.push(action.payload);
state.pendingTransactions?.push(action.payload);
},
removePendingTransaction: (state, action: PayloadAction<PendingTransactions>) => {
state.pendingTransactions = state.pendingTransactions.filter((tx) => {
Expand Down
Loading