Skip to content

Commit cc2e25c

Browse files
committed
feat(web/WIP): adapt for paidFees in the subgraph
1 parent 98f1619 commit cc2e25c

File tree

4 files changed

+39
-18
lines changed

4 files changed

+39
-18
lines changed

web/src/pages/Cases/CaseDetails/Appeal/Classic/Options.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ import {
99
} from "queries/useClassicAppealQuery";
1010
import { useAppealCost } from "queries/useAppealCost";
1111
import { useDisputeKitClassicMultipliers } from "queries/useDisputeKitClassicMultipliers";
12+
import StageExplainer from "./StageExplainer";
1213
import OptionCard from "../OptionCard";
1314

1415
const ONE_BASIS_POINT = BigNumber.from("1000");
1516

16-
const Options: React.FC = () => {
17+
interface IOptions {
18+
selectedOption: undefined | number;
19+
setSelectedOption: (arg0: number) => void;
20+
}
21+
22+
const Options: React.FC<IOptions> = ({ selectedOption, setSelectedOption }) => {
1723
const { id } = useParams();
1824
const { data } = useClassicAppealQuery(id);
1925
const paidFees = getPaidFees(data?.dispute);
@@ -24,6 +30,7 @@ const Options: React.FC = () => {
2430
const { data: multipliers } = useDisputeKitClassicMultipliers();
2531
return (
2632
<Container>
33+
<StageExplainer />
2734
<label> Which option do you want to fund? </label>
2835
<OptionsContainer>
2936
{typeof paidFees !== "undefined" &&
@@ -33,11 +40,12 @@ const Options: React.FC = () => {
3340
<OptionCard
3441
key={answer}
3542
text={answer}
43+
selected={i === selectedOption}
3644
winner={(i + 1).toString() === winningChoice}
3745
funding={
3846
paidFees[i + 1]
39-
? paidFees[i + 1]
40-
: BigNumber.from("30000000000000000")
47+
? BigNumber.from(paidFees[i + 1])
48+
: BigNumber.from(0)
4149
}
4250
required={
4351
(i + 1).toString() === winningChoice
@@ -48,6 +56,7 @@ const Options: React.FC = () => {
4856
.mul(appealCost)
4957
.div(ONE_BASIS_POINT)
5058
}
59+
onClick={() => setSelectedOption(i)}
5160
/>
5261
)
5362
)}

web/src/pages/Cases/CaseDetails/Appeal/Classic/StageExplainer.tsx

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,31 @@ import styled from "styled-components";
33
import { Box } from "@kleros/ui-components-library";
44
import { secondsToDayHourMinute, getTimeLeft } from "utils/date";
55

6-
const StageExplainer: React.FC = () => {
7-
// const timeLeft = secondsToDayHourMinute(
8-
// getTimeLeft(
9-
// parseInt(dispute?.lastPeriodChange, 10),
10-
// parseInt(dispute?.courtID.timesPerPeriod[index], 10)
11-
// )
12-
// );
6+
interface IStageExplainer {
7+
lastPeriodChange: string;
8+
appealPeriodDuration: string;
9+
loserTimeMultiplier: string;
10+
}
11+
12+
const StageExplainer: React.FC<IStageExplainer> = ({
13+
lastPeriodChange,
14+
appealPeriodDuration,
15+
loserTimeMultiplier,
16+
}) => {
17+
const timeLeft = secondsToDayHourMinute(
18+
getTimeLeft(
19+
parseInt(lastPeriodChange, 10),
20+
parseInt(loserTimeMultiplier, 10) * parseInt(appealPeriodDuration, 10)
21+
)
22+
);
1323
return (
1424
<StyledBox>
1525
<StageIndicator />
1626
<div>
17-
<small>One of the losing options must be fully funded.</small>
27+
<small>
28+
In this stage, at least one of the losing options must be fully funded
29+
to proceed.
30+
</small>
1831
<small>
1932
If no option is fully funded in time, the jury decision is maintained.
2033
</small>

web/src/pages/Cases/CaseDetails/Appeal/Classic/index.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
import React from "react";
1+
import React, { useState } from "react";
22
import { useParams } from "react-router-dom";
33
import { useWeb3 } from "hooks/useWeb3";
4-
import StageExplainer from "./StageExplainer";
54
import Options from "./Options";
65
import Fund from "./Fund";
76

87
const Classic: React.FC = () => {
98
const { account } = useWeb3();
109
const { id } = useParams();
10+
const [selectedOption, setSelectedOption] = useState<number | undefined>();
1111
return (
1212
<>
1313
<h1>Appeal crowdfunding</h1>
1414
<label>
15-
The jury decision is appealed when stages 1 and 2 are fully funded
15+
The jury decision is appealed when two options are fully funded.
1616
</label>
17-
<StageExplainer />
18-
<Options />
17+
<Options {...{ selectedOption, setSelectedOption }} />
1918
<Fund />
2019
</>
2120
);

web/src/pages/Cases/CaseDetails/Appeal/OptionCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Card, Radio, LinearProgress } from "@kleros/ui-components-library";
55
import Gavel from "svgs/icons/gavel.svg";
66
import { BigNumber, utils } from "ethers";
77

8-
interface IOptionCard {
8+
interface IOptionCard extends React.HTMLAttributes<HTMLDivElement> {
99
text: string;
1010
funding: BigNumber;
1111
required: BigNumber;
@@ -23,7 +23,7 @@ const OptionCard: React.FC<IOptionCard> = ({
2323
}) => {
2424
const [ref, { width }] = useMeasure();
2525
return (
26-
<StyledCard ref={ref} {...props}>
26+
<StyledCard ref={ref} hover {...props}>
2727
<TopContainer>
2828
<div>
2929
<small className="block">{text}</small>

0 commit comments

Comments
 (0)