Skip to content

Commit 464fd49

Browse files
authored
Merge pull request #1184 from kleros/fix(web)/disable-appeal-tab-on-last-round
feat(web): disable appeal tab on last round and add info message
2 parents 9b97263 + d3ebfe8 commit 464fd49

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

web/src/pages/Cases/CaseDetails/Tabs.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import { Tabs as TabsComponent } from "@kleros/ui-components-library";
55
import { Periods } from "consts/periods";
66
import { useVotingHistory } from "hooks/queries/useVotingHistory";
77
import { useDisputeDetailsQuery } from "hooks/queries/useDisputeDetailsQuery";
8+
import { useAppealCost } from "queries/useAppealCost";
9+
import { isLastRound } from "utils/isLastRound";
10+
import { isUndefined } from "utils/index";
811
import EyeIcon from "assets/svgs/icons/eye.svg";
912
import DocIcon from "assets/svgs/icons/doc.svg";
1013
import BalanceIcon from "assets/svgs/icons/law-balance.svg";
@@ -54,6 +57,7 @@ const Tabs: React.FC = () => {
5457
const { id } = useParams();
5558
const { data } = useDisputeDetailsQuery(id);
5659
const { data: votingHistory } = useVotingHistory(id);
60+
const { data: appealCost } = useAppealCost(id);
5761
const rounds = votingHistory?.dispute?.rounds ?? [1];
5862
const dispute = data?.dispute;
5963
const currentPeriodIndex = Periods[dispute?.period ?? 0];
@@ -64,8 +68,10 @@ const Tabs: React.FC = () => {
6468
}, [currentPathName]);
6569

6670
useEffect(() => {
67-
TABS[3].disabled = parseInt(currentPeriodIndex) < 3 && rounds.length === 1;
68-
}, [currentPeriodIndex, id, currentTab, rounds.length]);
71+
TABS[3].disabled =
72+
(parseInt(currentPeriodIndex) < 3 && rounds.length === 1) ||
73+
(!isUndefined(appealCost) && isLastRound(appealCost) && parseInt(currentPeriodIndex) === 3);
74+
}, [currentPeriodIndex, id, currentTab, rounds.length, appealCost]);
6975

7076
return (
7177
<StyledTabs

web/src/pages/Cases/CaseDetails/Voting/index.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import { useAccount } from "wagmi";
55
import { useLockOverlayScroll } from "hooks/useLockOverlayScroll";
66
import { useDisputeDetailsQuery } from "queries/useDisputeDetailsQuery";
77
import { useDrawQuery } from "queries/useDrawQuery";
8+
import { useAppealCost } from "queries/useAppealCost";
89
import Classic from "./Classic";
910
import VotingHistory from "./VotingHistory";
1011
import Popup, { PopupType } from "components/Popup";
1112
import { Periods } from "consts/periods";
1213
import { isUndefined } from "utils/index";
14+
import { isLastRound } from "utils/isLastRound";
1315
import { getPeriodEndTimestamp } from "components/DisputeCard";
1416
import { useDisputeKitClassicIsVoteActive } from "hooks/contracts/generated";
1517
import VoteIcon from "assets/svgs/icons/voted.svg";
@@ -44,6 +46,7 @@ const Voting: React.FC<IVoting> = ({ arbitrable, currentPeriodIndex }) => {
4446
const { address } = useAccount();
4547
const { id } = useParams();
4648
const { data: disputeData } = useDisputeDetailsQuery(id);
49+
const { data: appealCost } = useAppealCost(id);
4750
const { data: drawData } = useDrawQuery(address?.toLowerCase(), id, disputeData?.dispute?.currentRound.id);
4851
const roundId = disputeData?.dispute?.currentRoundIndex;
4952
const voteId = drawData?.draws?.[0]?.voteID;
@@ -63,6 +66,15 @@ const Voting: React.FC<IVoting> = ({ arbitrable, currentPeriodIndex }) => {
6366

6467
return (
6568
<>
69+
{!isUndefined(appealCost) && isLastRound(appealCost) && (
70+
<>
71+
<InfoContainer>
72+
<InfoCircle />
73+
This dispute is on its last round. Vote wisely, It cannot be appealed any further.
74+
</InfoContainer>
75+
<br></br>
76+
</>
77+
)}
6678
{drawData?.draws.length === 0 && (
6779
<>
6880
<InfoContainer>

web/src/utils/isLastRound.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { formatEther } from "viem";
2+
3+
export const isLastRound = (appealCost: bigint) => {
4+
if (Number(formatEther(appealCost)) > Number.MAX_SAFE_INTEGER) {
5+
return true;
6+
}
7+
return false;
8+
};

0 commit comments

Comments
 (0)