diff --git a/web/src/pages/Cases/CaseDetails/Tabs.tsx b/web/src/pages/Cases/CaseDetails/Tabs.tsx index dff98202b..1321d675e 100644 --- a/web/src/pages/Cases/CaseDetails/Tabs.tsx +++ b/web/src/pages/Cases/CaseDetails/Tabs.tsx @@ -5,6 +5,9 @@ import { Tabs as TabsComponent } from "@kleros/ui-components-library"; import { Periods } from "consts/periods"; import { useVotingHistory } from "hooks/queries/useVotingHistory"; import { useDisputeDetailsQuery } from "hooks/queries/useDisputeDetailsQuery"; +import { useAppealCost } from "queries/useAppealCost"; +import { isLastRound } from "utils/isLastRound"; +import { isUndefined } from "utils/index"; import EyeIcon from "assets/svgs/icons/eye.svg"; import DocIcon from "assets/svgs/icons/doc.svg"; import BalanceIcon from "assets/svgs/icons/law-balance.svg"; @@ -54,6 +57,7 @@ const Tabs: React.FC = () => { const { id } = useParams(); const { data } = useDisputeDetailsQuery(id); const { data: votingHistory } = useVotingHistory(id); + const { data: appealCost } = useAppealCost(id); const rounds = votingHistory?.dispute?.rounds ?? [1]; const dispute = data?.dispute; const currentPeriodIndex = Periods[dispute?.period ?? 0]; @@ -64,8 +68,10 @@ const Tabs: React.FC = () => { }, [currentPathName]); useEffect(() => { - TABS[3].disabled = parseInt(currentPeriodIndex) < 3 && rounds.length === 1; - }, [currentPeriodIndex, id, currentTab, rounds.length]); + TABS[3].disabled = + (parseInt(currentPeriodIndex) < 3 && rounds.length === 1) || + (!isUndefined(appealCost) && isLastRound(appealCost) && parseInt(currentPeriodIndex) === 3); + }, [currentPeriodIndex, id, currentTab, rounds.length, appealCost]); return ( = ({ arbitrable, currentPeriodIndex }) => { const { address } = useAccount(); const { id } = useParams(); const { data: disputeData } = useDisputeDetailsQuery(id); + const { data: appealCost } = useAppealCost(id); const { data: drawData } = useDrawQuery(address?.toLowerCase(), id, disputeData?.dispute?.currentRound.id); const roundId = disputeData?.dispute?.currentRoundIndex; const voteId = drawData?.draws?.[0]?.voteID; @@ -63,6 +66,15 @@ const Voting: React.FC = ({ arbitrable, currentPeriodIndex }) => { return ( <> + {!isUndefined(appealCost) && isLastRound(appealCost) && ( + <> + + + This dispute is on its last round. Vote wisely, It cannot be appealed any further. + +

+ + )} {drawData?.draws.length === 0 && ( <> diff --git a/web/src/utils/isLastRound.ts b/web/src/utils/isLastRound.ts new file mode 100644 index 000000000..6b72cc074 --- /dev/null +++ b/web/src/utils/isLastRound.ts @@ -0,0 +1,8 @@ +import { formatEther } from "viem"; + +export const isLastRound = (appealCost: bigint) => { + if (Number(formatEther(appealCost)) > Number.MAX_SAFE_INTEGER) { + return true; + } + return false; +};