diff --git a/src/components/court-cascader-modal.js b/src/components/court-cascader-modal.js index 34cac8b..c0b96b0 100644 --- a/src/components/court-cascader-modal.js +++ b/src/components/court-cascader-modal.js @@ -195,7 +195,7 @@ const CourtCascaderModal = ({ onClick }) => { } onCancel={useCallback(() => onClick(), [onClick])} - title={Join Court} + title="Join Court" visible > { - const { useCacheCall, useCacheEvents } = useDrizzle() - const drizzleState = useDrizzleState(drizzleState => ({ - account: drizzleState.accounts[0] || VIEW_ONLY_ADDRESS - })) - const [filter, setFilter] = useState(0) +export default function Cases() { + const { useCacheCall, useCacheEvents } = useDrizzle(); + const drizzleState = useDrizzleState((drizzleState) => ({ + account: drizzleState.accounts[0] || VIEW_ONLY_ADDRESS, + })); + const [filter, setFilter] = useState(0); const draws = useCacheEvents( - 'KlerosLiquid', - 'Draw', + "KlerosLiquid", + "Draw", useMemo( () => ({ filter: { _address: drizzleState.account }, - fromBlock: process.env.REACT_APP_KLEROS_LIQUID_BLOCK_NUMBER + fromBlock: process.env.REACT_APP_KLEROS_LIQUID_BLOCK_NUMBER, }), [drizzleState.account] ) - ) - const disputes = useCacheCall(['KlerosLiquid'], call => + ); + const disputes = useCacheCall(["KlerosLiquid"], (call) => draws ? Object.values( draws.reduce((acc, d) => { - acc[d.returnValues._disputeID] = d - return acc + acc[d.returnValues._disputeID] = d; + return acc; }, {}) ).reduce( (acc, d) => { - const dispute = call( - 'KlerosLiquid', - 'disputes', - d.returnValues._disputeID - ) - const numberOfVotes = draws.filter( - _draw => - _draw.returnValues._disputeID === d.returnValues._disputeID - ) + const dispute = call("KlerosLiquid", "disputes", d.returnValues._disputeID); + const numberOfVotes = draws.filter((_draw) => _draw.returnValues._disputeID === d.returnValues._disputeID); if (dispute) - if (dispute.period === '1' || dispute.period === '2') { - const dispute2 = call( - 'KlerosLiquid', - 'getDispute', - d.returnValues._disputeID - ) + if (dispute.period === "1" || dispute.period === "2") { + const dispute2 = call("KlerosLiquid", "getDispute", d.returnValues._disputeID); if (dispute2) - if ( - Number(d.returnValues._appeal) === - dispute2.votesLengths.length - 1 - ) { + if (Number(d.returnValues._appeal) === dispute2.votesLengths.length - 1) { const vote = call( - 'KlerosLiquid', - 'getVote', + "KlerosLiquid", + "getVote", d.returnValues._disputeID, d.returnValues._appeal, d.returnValues._voteID - ) + ); if (vote) - acc[vote.voted ? 'active' : 'votePending'].push({ + acc[vote.voted ? "active" : "votePending"].push({ ID: d.returnValues._disputeID, - draws: numberOfVotes - }) - else acc.loading = true + draws: numberOfVotes, + }); + else acc.loading = true; } else acc.active.push({ ID: d.returnValues._disputeID, - draws: numberOfVotes - }) - else acc.loading = true + draws: numberOfVotes, + }); + else acc.loading = true; } else - acc[dispute.period === '4' ? 'executed' : 'active'].push({ + acc[dispute.period === "4" ? "executed" : "active"].push({ ID: d.returnValues._disputeID, - draws: numberOfVotes - }) - else acc.loading = true - return acc + draws: numberOfVotes, + }); + else acc.loading = true; + return acc; }, { active: [], executed: [], loading: false, votePending: [] } ) : { active: [], executed: [], loading: true, votePending: [] } - ) - const filteredDisputes = - disputes[['votePending', 'active', 'executed'][filter]] + ); + + const filteredDisputes = disputes[["votePending", "active", "executed"][filter]]; + return ( <> { setFilter(e.target.value), [])} + onChange={useCallback((e) => setFilter(e.target.value), [])} value={filter} > Vote Pending @@ -141,19 +91,15 @@ export default () => { Closed } - extraLong title="My Cases" /> {filteredDisputes.length === 0 ? ( - - You don't have any {['pending', 'active', 'closed'][filter]}{' '} - cases. - + You don’t have any {["pending", "active", "closed"][filter]} cases. ) : ( - filteredDisputes.map(dispute => ( + filteredDisputes.map((dispute) => ( @@ -162,5 +108,54 @@ export default () => { - ) + ); } + +const StyledRadioGroup = styled(Radio.Group)` + display: flex; + gap: 10px; + + @media (max-width: 575.98px) { + flex-wrap: wrap; + } + + .ant-radio-button-wrapper { + border: 1px solid #4d00b4 !important; + border-radius: 300px; + color: #4d00b4; + + &:before { + background-color: transparent; + } + + &-checked { + background: #4d00b4 !important; + } + } + + .ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled) { + box-shadow: none; + + :focus-within { + outline: none; + } + + ::before { + display: none; + } + } +`; + +const StyledRadioButton = styled(Radio.Button)` + @media (max-width: 575.98px) { + text-align: center; + } +`; + +const StyledCol = styled(Col)` + color: #d09cff; + font-size: 24px; + font-weight: 500; + line-height: 28px; + text-align: center; +`;