From a0fce4c7b7a3590838999afe53dc3d07b68707c2 Mon Sep 17 00:00:00 2001 From: Joey Date: Mon, 27 May 2024 12:01:35 +1000 Subject: [PATCH] Make sure admin panel passes in network id --- frontend/components/Admin/AdminPanel/index.js | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/frontend/components/Admin/AdminPanel/index.js b/frontend/components/Admin/AdminPanel/index.js index ca1b511..8d195af 100644 --- a/frontend/components/Admin/AdminPanel/index.js +++ b/frontend/components/Admin/AdminPanel/index.js @@ -1,28 +1,36 @@ -import { useState, useEffect } from 'react' -import { Spinner } from '@chakra-ui/react' -import Grants from './Grants' -import TokenBalance from './TokenBalance' -import RecentActivity from '../../shared/RecentActivity' -import { useRecoilState } from 'recoil' -import { getGrants, fetchGrants } from '../../../lib/store/grants' -import { eventsState, fetchEvents } from '../../../lib/store/events' +import { useState, useEffect } from "react"; +import { Spinner } from "@chakra-ui/react"; +import Grants from "./Grants"; +import TokenBalance from "./TokenBalance"; +import RecentActivity from "../../shared/RecentActivity"; +import { useRecoilState } from "recoil"; +import { getGrants, fetchGrants } from "../../../lib/store/grants"; +import { eventsState, fetchEvents } from "../../../lib/store/events"; export default function AdminPanel() { const [grants, setGrant] = useRecoilState(getGrants()); const [events, setEvents] = useRecoilState(eventsState); const [loadingData, setLoadingData] = useState(true); + const { chain } = useNetwork(); + const networkId = chain.id; useEffect(() => { - Promise.all([fetchEvents(setEvents), fetchGrants(setGrant)]).finally(() => { - setLoadingData(false) - }) - }, []) - - return loadingData ? : <> - - - - - + if (!networkId) return; + Promise.all([ + fetchEvents(setEvents, networkId), + fetchGrants(setGrant, networkId), + ]).finally(() => { + setLoadingData(false); + }); + }, [networkId]); + return loadingData ? ( + + ) : ( + <> + + + + + ); }