diff --git a/governance/ui/src/components/CouncilMembers/CouncilMembers.tsx b/governance/ui/src/components/CouncilMembers/CouncilMembers.tsx index 5401814cd..9171d206a 100644 --- a/governance/ui/src/components/CouncilMembers/CouncilMembers.tsx +++ b/governance/ui/src/components/CouncilMembers/CouncilMembers.tsx @@ -130,9 +130,9 @@ export default function CouncilMembers({ activeCouncil }: { activeCouncil: Counc {sortConfig[1] === 'votingPower' && } )} - {/* {councilPeriod === '0' && ( - - )}*/} + {councilPeriod === '0' && ( + + )} diff --git a/governance/ui/src/components/UserTableView/UserTableView.tsx b/governance/ui/src/components/UserTableView/UserTableView.tsx index b7b8dde79..8ee08a2bd 100644 --- a/governance/ui/src/components/UserTableView/UserTableView.tsx +++ b/governance/ui/src/components/UserTableView/UserTableView.tsx @@ -6,7 +6,7 @@ import { useGetCurrentPeriod } from '../../queries/useGetCurrentPeriod'; import { CouncilSlugs } from '../../utils/councils'; import { ProfilePicture } from '../UserProfileCard/ProfilePicture'; import { prettyString } from '@snx-v3/format'; -import { useGetUserBallot } from '../../queries'; +import { useGetEpochIndex, useGetUserBallot } from '../../queries'; import { BigNumber, utils } from 'ethers'; import { formatNumber } from '@snx-v3/formatters'; import { renderCorrectBorder } from '../../utils/table-border'; @@ -28,7 +28,8 @@ export default function UserTableView({ }) { const navigate = useNavigate(); const [searchParams] = useSearchParams(); - const { data: ballot } = useGetUserBallot(activeCouncil); + const { data: epochIndex } = useGetEpochIndex(activeCouncil); + const { data: ballot } = useGetUserBallot(activeCouncil, (epochIndex?.toNumber() || 1) - 1); const { data: councilPeriod } = useGetCurrentPeriod(activeCouncil); const isSelected = searchParams.get('view') === user.address; const councilIsInAdminOrVotinOrEval = @@ -129,7 +130,7 @@ export default function UserTableView({ )} - {councilPeriod === '2' && ( + {(councilPeriod === '2' || councilPeriod === '0') && ( (council: T) { +export function useGetUserBallot( + council: T, + epochIndex?: number +) { const { network } = useNetwork(); const signer = useSigner(); @@ -13,11 +16,11 @@ export function useGetUserBallot(counci queryFn: async () => { if (signer && network?.id) { const address = await signer.getAddress(); - return await getBallot(council, address, network.id); + return await getBallot(council, address, network.id, epochIndex); } }, enabled: !!signer, - queryKey: ['userBallot', council.toString(), network?.id], + queryKey: ['userBallot', council.toString(), network?.id, epochIndex], staleTime: 900000, }); } @@ -25,7 +28,8 @@ export function useGetUserBallot(counci async function getBallot( council: T, address: string, - chainId: number + chainId: number, + epochIndex?: number ): Promise< T extends CouncilSlugs ? { @@ -47,14 +51,14 @@ async function getBallot( ballot = (await Promise.all( council.map(async (c) => { const electionModule = getCouncilContract(c).connect(provider); - const electionId = await electionModule.getEpochIndex(); + const electionId = epochIndex ?? (await electionModule.getEpochIndex()); const temp = await electionModule.getBallot(address, chainId, electionId); return { ...temp, council: c }; }) )) as { votingPower: BigNumber; votedCandidates: string[]; amounts: BigNumber[] }[]; } else { const electionModule = getCouncilContract(council).connect(provider); - const electionId = electionModule.getEpochIndex(); + const electionId = epochIndex ?? (await electionModule.getEpochIndex()); const temp = (await electionModule.getBallot(address, chainId, electionId)) as { votingPower: BigNumber; votedCandidates: string[];