1
1
import React , { useMemo } from "react" ;
2
2
import styled from "styled-components" ;
3
3
4
+ import Skeleton from "react-loading-skeleton" ;
4
5
import { useParams } from "react-router-dom" ;
5
6
import { formatEther } from "viem" ;
6
7
import { useAccount } from "wagmi" ;
7
8
8
9
import Check from "svgs/icons/check-circle-outline.svg" ;
9
10
10
11
import { useCourtDetails } from "hooks/queries/useCourtDetails" ;
11
- import { uncommify } from "utils/commify" ;
12
+ import { commify , uncommify } from "utils/commify" ;
12
13
13
14
import { useJurorStakeDetailsQuery } from "queries/useJurorStakeDetailsQuery" ;
14
15
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" ;
16
21
import { ActionType } from "../StakeWithdrawButton" ;
17
22
18
23
const StakingMsgContainer = styled . div `
@@ -43,11 +48,17 @@ const CheckIcon = styled(Check)`
43
48
height: 80px;
44
49
` ;
45
50
46
- const CourtName = styled . label `` ;
51
+ const CourtName = styled . label `
52
+ margin-bottom: 15px;
53
+ ` ;
47
54
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;
50
60
` ;
61
+
51
62
interface IHeader {
52
63
action : ActionType ;
53
64
amount : string ;
@@ -63,6 +74,12 @@ const Header: React.FC<IHeader> = ({ action, amount, isSuccess }) => {
63
74
const jurorCurrentEffectiveStake = address && jurorStakeData ? Number ( formatEther ( jurorStakeData . effectiveStake ) ) : 0 ;
64
75
const jurorCurrentSpecificStake = address && jurorStakeData ? Number ( formatEther ( jurorStakeData . staked ) ) : 0 ;
65
76
77
+ const effectiveStakeDisplay = ! isUndefined ( jurorCurrentEffectiveStake ) ? (
78
+ `${ commify ( jurorCurrentEffectiveStake ) } PNK`
79
+ ) : (
80
+ < Skeleton width = { 50 } />
81
+ ) ;
82
+
66
83
const isWithdraw = action === ActionType . withdraw ;
67
84
const preStakeText = useMemo ( ( ) => ( isWithdraw ? "withdrawing" : "staking" ) , [ isWithdraw ] ) ;
68
85
const postStakeText = useMemo ( ( ) => ( isWithdraw ? "withdrew" : "staked" ) , [ isWithdraw ] ) ;
@@ -73,8 +90,17 @@ const Header: React.FC<IHeader> = ({ action, amount, isSuccess }) => {
73
90
< StakingMsg > { isSuccess ? `You successfully ${ postStakeText } ` : `You are ${ preStakeText } ` } </ StakingMsg >
74
91
< StakingAmount > { amount } PNK</ StakingAmount >
75
92
{ 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
78
104
{ ...{
79
105
jurorCurrentEffectiveStake,
80
106
jurorCurrentSpecificStake,
0 commit comments