Skip to content

Commit 665a091

Browse files
authored
Merge pull request #1742 from kleros/fix/stake-error-display
fix(web): display-stake-button-error
2 parents 54bcb9f + 0c6447e commit 665a091

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

web/src/pages/Courts/CourtDetails/StakePanel/StakeWithdrawButton.tsx

+28-14
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,24 @@ import { isUndefined } from "utils/index";
2222
import { wrapWithToast } from "utils/wrapWithToast";
2323

2424
import { EnsureChain } from "components/EnsureChain";
25+
import styled from "styled-components";
2526

2627
export enum ActionType {
2728
allowance = "allowance",
2829
stake = "stake",
2930
withdraw = "withdraw",
3031
}
3132

33+
const Container = styled.div`
34+
display: flex;
35+
gap: 8px;
36+
flex-direction: column;
37+
`;
38+
39+
const ErrorLabel = styled.label`
40+
color: ${({ theme }) => theme.error};
41+
`;
42+
3243
interface IActionButton {
3344
isSending: boolean;
3445
parsedAmount: bigint;
@@ -142,20 +153,23 @@ const StakeWithdrawButton: React.FC<IActionButton> = ({
142153
const { text, checkDisabled, onClick } = buttonProps[isAllowance ? ActionType.allowance : action];
143154
return (
144155
<EnsureChain>
145-
<Button
146-
text={text}
147-
isLoading={isSending}
148-
disabled={
149-
isSending ||
150-
parsedAmount == 0n ||
151-
isUndefined(targetStake) ||
152-
isUndefined(courtDetails) ||
153-
checkDisabled() ||
154-
(targetStake !== 0n && targetStake < BigInt(courtDetails.court?.minStake)) ||
155-
(isStaking && !isAllowance && isUndefined(setStakeConfig))
156-
}
157-
onClick={onClick}
158-
/>
156+
<Container>
157+
<Button
158+
text={text}
159+
isLoading={isSending}
160+
disabled={
161+
isSending ||
162+
parsedAmount == 0n ||
163+
isUndefined(targetStake) ||
164+
isUndefined(courtDetails) ||
165+
checkDisabled() ||
166+
(targetStake !== 0n && targetStake < BigInt(courtDetails.court?.minStake)) ||
167+
(isStaking && !isAllowance && isUndefined(setStakeConfig))
168+
}
169+
onClick={onClick}
170+
/>
171+
{setStakeError && <ErrorLabel> {setStakeError.message}</ErrorLabel>}
172+
</Container>
159173
</EnsureChain>
160174
);
161175
};

0 commit comments

Comments
 (0)