Skip to content
This repository was archived by the owner on Oct 11, 2024. It is now read-only.

Commit 09312c6

Browse files
committed
repurposing governance error modal (interim) for not enough eth error
1 parent aa3eb5b commit 09312c6

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

ts/pages/account/dashboard.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import styled from 'styled-components';
1010
import { Button } from 'ts/components/button';
1111
import { CallToAction } from 'ts/components/call_to_action';
1212
import { ChangePoolDialog } from 'ts/components/staking/change_pool_dialog';
13+
import { ErrorModal } from 'ts/pages/governance/error_modal';
1314
import { StakingPageLayout } from 'ts/components/staking/layout/staking_page_layout';
1415
import { RemoveStakeDialog } from 'ts/components/staking/remove_stake_dialog';
1516
import { Heading, Paragraph } from 'ts/components/text';
@@ -122,6 +123,8 @@ export const Account: React.FC<AccountProps> = () => {
122123
// NOTE: not yet implemented but left in for future reference
123124
const voteHistory: VoteHistory[] = [];
124125

126+
const [isErrorModalOpen, setErrorModalOpen] = React.useState(false);
127+
const [stakingError, setStakingError] = React.useState<Error | undefined>(undefined);
125128
const [isApplyModalOpen, toggleApplyModal] = React.useState(false);
126129
const [changePoolDetails, setChangePoolDetails] = React.useState<PoolDetails | undefined>(undefined);
127130
const [removeStakePoolDetails, setRemoveStakePoolDetails] = React.useState<PoolDetails | undefined>(undefined);
@@ -147,7 +150,7 @@ export const Account: React.FC<AccountProps> = () => {
147150
const [pendingUnstakePoolSet, setPendingUnstakePoolSet] = React.useState<Set<string>>(new Set());
148151

149152
const apiClient = useAPIClient(networkId);
150-
const { stakingContract, unstake, withdrawStake, withdrawRewards, moveStake, currentEpochRewards } = useStake(
153+
const { stakingContract, unstake, withdrawStake, withdrawRewards, moveStake, currentEpochRewards, error: useStakeError } = useStake(
151154
networkId,
152155
providerState,
153156
);
@@ -389,6 +392,12 @@ export const Account: React.FC<AccountProps> = () => {
389392
);
390393
}, [currentEpochStakeMap, nextEpochStakeMap, delegatorData]);
391394

395+
React.useEffect(() => {
396+
if (useStakeError) {
397+
setStakingError(useStakeError);
398+
}
399+
}, [useStakeError])
400+
392401
const accountLoaded = account && account.address;
393402

394403
if (!accountLoaded) {
@@ -424,7 +433,6 @@ export const Account: React.FC<AccountProps> = () => {
424433
}
425434

426435
const nextEpochStart = nextEpochStats && new Date(nextEpochStats.epochStart.timestamp);
427-
428436
return (
429437
<StakingPageLayout title="0x Staking | Account">
430438
<HeaderWrapper>
@@ -770,6 +778,10 @@ export const Account: React.FC<AccountProps> = () => {
770778
});
771779
}}
772780
/>
781+
<ErrorModal isOpen={Boolean(stakingError)} text={'More ETH is required to complete this transaction. Fund your wallet and try again.'} heading={'Insufficient ETH'} buttonText={'Dismiss'} onClose={() => {
782+
setStakingError(undefined);
783+
}} />
784+
773785
<DialogOverlay
774786
style={{ background: 'rgba(0, 0, 0, 0.75)', zIndex: 30 }}
775787
isOpen={shouldOpenStakeDecisionModal}

ts/pages/governance/error_modal.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ErrorModal.defaultProps = {
4646
};
4747

4848
const Wrapper = styled.div<ErrorModalProps>`
49-
position: absolute;
49+
position: fixed;
5050
background-color: rgba(0, 0, 0, 0.75);
5151
display: flex;
5252
top: 0;
@@ -55,6 +55,7 @@ const Wrapper = styled.div<ErrorModalProps>`
5555
bottom: 0;
5656
opacity: 0;
5757
visibility: hidden;
58+
z-index: 30;
5859
5960
${(props) =>
6061
props.isOpen &&
@@ -69,7 +70,6 @@ const Inner = styled.div`
6970
background-color: #f6f6f6;
7071
padding: 30px 30px;
7172
width: 440px;
72-
height: 440px;
7373
text-align: center;
7474
`;
7575

@@ -79,7 +79,6 @@ const ErrorBox = styled.div`
7979
padding: 18px 30px;
8080
margin-bottom: 30px;
8181
overflow: auto;
82-
max-height: 95px;
8382
`;
8483

8584
const Text = styled(Paragraph).attrs({

0 commit comments

Comments
 (0)