Skip to content

Commit 50bcfb9

Browse files
authored
Merge pull request #1818 from kleros/feat/stake-popup-subscribe-notification
feat(web): stake-popup-notification-info
2 parents e7aab2a + aac41a9 commit 50bcfb9

File tree

3 files changed

+45
-30
lines changed

3 files changed

+45
-30
lines changed

web/src/pages/Courts/CourtDetails/StakePanel/Simulator/QuantityToSimulate.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const Container = styled.div`
1717
justify-content: center;
1818
`;
1919

20-
const TextWithTooltipContainer = styled.div`
20+
export const TextWithTooltipContainer = styled.div`
2121
color: ${({ theme }) => theme.secondaryPurple};
2222
font-size: 14px;
2323
@@ -29,7 +29,7 @@ const TextWithTooltipContainer = styled.div`
2929
}
3030
`;
3131

32-
const Quantity = styled.p`
32+
export const Quantity = styled.p`
3333
font-size: 14px;
3434
color: ${({ theme }) => theme.primaryText};
3535
margin: 0;

web/src/pages/Courts/CourtDetails/StakePanel/StakeWithdrawPopup/Header.tsx

+33-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
import React, { useMemo } from "react";
22
import styled from "styled-components";
33

4+
import Skeleton from "react-loading-skeleton";
45
import { useParams } from "react-router-dom";
56
import { formatEther } from "viem";
67
import { useAccount } from "wagmi";
78

89
import Check from "svgs/icons/check-circle-outline.svg";
910

1011
import { useCourtDetails } from "hooks/queries/useCourtDetails";
11-
import { uncommify } from "utils/commify";
12+
import { commify, uncommify } from "utils/commify";
1213

1314
import { useJurorStakeDetailsQuery } from "queries/useJurorStakeDetailsQuery";
1415

15-
import QuantityToSimulate from "../Simulator/QuantityToSimulate";
16+
import { isUndefined } from "src/utils";
17+
18+
import WithHelpTooltip from "components/WithHelpTooltip";
19+
20+
import QuantityToSimulate, { Quantity, TextWithTooltipContainer } from "../Simulator/QuantityToSimulate";
1621
import { ActionType } from "../StakeWithdrawButton";
1722

1823
const StakingMsgContainer = styled.div`
@@ -43,11 +48,17 @@ const CheckIcon = styled(Check)`
4348
height: 80px;
4449
`;
4550

46-
const CourtName = styled.label``;
51+
const CourtName = styled.label`
52+
margin-bottom: 15px;
53+
`;
4754

48-
const StyledQuantityToSimulate = styled(QuantityToSimulate)`
49-
margin-top: 15px;
55+
const QuantityContainer = styled.div`
56+
display: flex;
57+
align-items: center;
58+
justify-content: center;
59+
gap: 8px;
5060
`;
61+
5162
interface IHeader {
5263
action: ActionType;
5364
amount: string;
@@ -63,6 +74,12 @@ const Header: React.FC<IHeader> = ({ action, amount, isSuccess }) => {
6374
const jurorCurrentEffectiveStake = address && jurorStakeData ? Number(formatEther(jurorStakeData.effectiveStake)) : 0;
6475
const jurorCurrentSpecificStake = address && jurorStakeData ? Number(formatEther(jurorStakeData.staked)) : 0;
6576

77+
const effectiveStakeDisplay = !isUndefined(jurorCurrentEffectiveStake) ? (
78+
`${commify(jurorCurrentEffectiveStake)} PNK`
79+
) : (
80+
<Skeleton width={50} />
81+
);
82+
6683
const isWithdraw = action === ActionType.withdraw;
6784
const preStakeText = useMemo(() => (isWithdraw ? "withdrawing" : "staking"), [isWithdraw]);
6885
const postStakeText = useMemo(() => (isWithdraw ? "withdrew" : "staked"), [isWithdraw]);
@@ -73,8 +90,17 @@ const Header: React.FC<IHeader> = ({ action, amount, isSuccess }) => {
7390
<StakingMsg>{isSuccess ? `You successfully ${postStakeText}` : `You are ${preStakeText}`}</StakingMsg>
7491
<StakingAmount>{amount} PNK</StakingAmount>
7592
{courtDetails?.court?.name ? <CourtName>on {courtDetails.court.name}</CourtName> : null}
76-
{isSuccess ? null : (
77-
<StyledQuantityToSimulate
93+
{isSuccess ? (
94+
<QuantityContainer>
95+
<Quantity>{effectiveStakeDisplay}</Quantity>
96+
<TextWithTooltipContainer>
97+
<WithHelpTooltip tooltipMsg="The stake is confirmed! It is standard procedure to delay the execution of a change in stakes if the phase of the arbitrator is not currently Staking. It'll be updated shortly.">
98+
Current Stake
99+
</WithHelpTooltip>
100+
</TextWithTooltipContainer>{" "}
101+
</QuantityContainer>
102+
) : (
103+
<QuantityToSimulate
78104
{...{
79105
jurorCurrentEffectiveStake,
80106
jurorCurrentSpecificStake,

web/src/pages/Courts/CourtDetails/StakePanel/StakeWithdrawPopup/index.tsx

+10-21
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
import React from "react";
22
import styled, { css, keyframes } from "styled-components";
33

4-
import { _TimelineItem1, CustomTimeline } from "@kleros/ui-components-library";
4+
import { _TimelineItem1, AlertMessage, CustomTimeline } from "@kleros/ui-components-library";
55

66
import Close from "svgs/icons/close.svg";
77

8-
import { useSortitionModulePhase } from "hooks/useSortitionModule";
9-
108
import { landscapeStyle } from "styles/landscapeStyle";
119
import { responsiveSize } from "styles/responsiveSize";
1210

1311
import { Divider } from "components/Divider";
14-
import InfoCard from "components/InfoCard";
1512
import LightButton from "components/LightButton";
1613
import { Overlay } from "components/Overlay";
17-
import { Phases } from "components/Phase";
1814

1915
import { ActionType } from "../StakeWithdrawButton";
2016

@@ -92,16 +88,10 @@ const StyledButton = styled(LightButton)`
9288
}
9389
`;
9490

95-
const InfoContainer = styled.div`
96-
display: flex;
97-
flex-direction: column;
98-
gap: 24px;
99-
margin-top: 8px;
91+
const AlertContainer = styled.div`
92+
margin-top: 24px;
10093
`;
10194

102-
const StyledInfoCard = styled(InfoCard)`
103-
font-size: 14px;
104-
`;
10595
interface IStakeWithdrawPopup {
10696
action: ActionType;
10797
amount: string;
@@ -111,8 +101,6 @@ interface IStakeWithdrawPopup {
111101
}
112102

113103
const StakeWithdrawPopup: React.FC<IStakeWithdrawPopup> = ({ amount, closePopup, steps, isSuccess, action }) => {
114-
const { data: phase, isLoading } = useSortitionModulePhase();
115-
116104
return (
117105
<Overlay onClick={closePopup}>
118106
<Container onClick={(e) => e.stopPropagation()}>
@@ -121,13 +109,14 @@ const StakeWithdrawPopup: React.FC<IStakeWithdrawPopup> = ({ amount, closePopup,
121109
<Header {...{ amount, isSuccess, action }} />
122110
<Divider />
123111
{steps && <CustomTimeline items={steps} />}
124-
{phase !== Phases.staking && !isLoading ? (
125-
<InfoContainer>
126-
<Divider />
127-
<StyledInfoCard
128-
msg={`The ${action === ActionType.stake ? "stake" : "withdraw"} might be delayed by ~1 hr.`}
112+
{isSuccess && action === ActionType.stake ? (
113+
<AlertContainer>
114+
<AlertMessage
115+
title="Hey there! Avoid missing a case"
116+
msg="Make sure to subscribe to notifications on Settings > Notifications"
117+
variant="info"
129118
/>
130-
</InfoContainer>
119+
</AlertContainer>
131120
) : null}
132121
</InnerContainer>
133122
</Container>

0 commit comments

Comments
 (0)