diff --git a/src/containers/case.js b/src/containers/case.js index 97ed7bd..09d4635 100644 --- a/src/containers/case.js +++ b/src/containers/case.js @@ -1,5 +1,5 @@ -import React from "react"; -import { Button, Row, Col, Tooltip } from "antd"; +import React, { useMemo } from "react"; +import { Button, Modal, Row, Col, Tooltip } from "antd"; import { useParams } from "react-router-dom"; import { drizzleReactHooks } from "@drizzle/react-plugin"; import CaseDetailsCard from "../components/case-details-card"; @@ -12,6 +12,7 @@ import styled from "styled-components/macro"; import { VIEW_ONLY_ADDRESS } from "../bootstrap/dataloader"; import useChainId from "../hooks/use-chain-id"; import useGetDraws from "../hooks/use-get-draws"; +import { chainIdToNetworkName } from "../helpers/networks"; const { useDrizzle, useDrizzleState } = drizzleReactHooks; @@ -76,66 +77,106 @@ export default function Case() { return disputeData; }); + const isDisputeTooOld = useMemo(() => { + return disputeData.deadline && (new Date().getTime() - disputeData.deadline.getTime() > 30 * 365 * 24 * 60 * 60 * 1000); + }, [disputeData.deadline]); + + async function handleChainSwitchToMainnet() { + try { + await window.ethereum.request({ + method: 'wallet_switchEthereumChain', + params: [{ chainId: '0x1' }], + }); + } catch (error) { + console.error('Error switching chains:', error); + } + } + + const renderContent = () => { + if (isDisputeTooOld && chainId !== 1) { + return ( + + Switch to Mainnet + , + ]} + > + The dispute with ID {ID} does not exist on {chainIdToNetworkName[chainId]}. Please switch to Mainnet. + + ); + } + + return ( + <> + + Case #{ID} | Locked + > + } + extra={ + + {dispute && dispute.ruled ? ( + Resolved + ) : ( + <> + {disputeData.deadline && disputeData.hiddenVotes !== undefined && ( + + {periodToPhase(dispute.period, disputeData.hiddenVotes)} Period Over + + {disputeData.deadline} + + + )} + {disputeData.showPassPeriod ? ( + + {Number(dispute.period) === 4 ? ( + + { + sendExecuteRuling(ID); + }} + > + Execute Ruling + + + ) : ( + + { + sendPassPeriod(ID); + }} + > + Pass Period + + + )} + + ) : ( + "" + )} + > + )} + + } + title="Case Details" + /> + + > + ); + }; + return ( } > - - Case #{ID} | Locked - > - } - extra={ - - {dispute && dispute.ruled ? ( - Resolved - ) : ( - <> - {disputeData.deadline && disputeData.hiddenVotes !== undefined && ( - - {periodToPhase(dispute.period, disputeData.hiddenVotes)} Period Over - - {disputeData.deadline} - - - )} - {disputeData.showPassPeriod ? ( - - {Number(dispute.period) === 4 ? ( - - { - sendExecuteRuling(ID); - }} - > - Execute Ruling - - - ) : ( - - { - sendPassPeriod(ID); - }} - > - Pass Period - - - )} - - ) : ( - "" - )} - > - )} - - } - title="Case Details" - /> - + {renderContent()} ); }
The dispute with ID {ID} does not exist on {chainIdToNetworkName[chainId]}. Please switch to Mainnet.