diff --git a/app/src/app/page.tsx b/app/src/app/page.tsx index 176fbd4..ec1518d 100644 --- a/app/src/app/page.tsx +++ b/app/src/app/page.tsx @@ -8,7 +8,6 @@ import LeagueSection from '@/components/league-section' import GameCard from '@/components/game-card' import { leaguesData, currentSeason } from '@/config/api' import { Sport, Game } from '@/types' -import { setLeaguesIds } from '@/lib/server-context' export default async function Home({ searchParams, @@ -16,7 +15,6 @@ export default async function Home({ searchParams: { [key: string]: string | string[] | undefined } }) { const currentLeagues = await fetchCurrentLeagues(Sport.Rugby) - setLeaguesIds(currentLeagues.map((l) => l.id)) const data = await Promise.all( currentLeagues.map(async (league) => { let allGames: Game[] = await fetchCurrentGames(Sport.Rugby, league.id) diff --git a/app/src/components/bet-slip.tsx b/app/src/components/bet-slip.tsx index a967ded..5ea6ae9 100644 --- a/app/src/components/bet-slip.tsx +++ b/app/src/components/bet-slip.tsx @@ -1,11 +1,10 @@ -import { fetchGames } from '@/lib/fetch-data' +import { fetchCurrentLeagues, fetchGames } from '@/lib/fetch-data' import BetSlipList from '@/components/bet-slip-list' import { currentSeason } from '@/config/api' import { Sport } from '@/types' -import { getLeaguesIds } from '@/lib/server-context' const BetSlip = async () => { - const leagueIds = getLeaguesIds() + const leagueIds = (await fetchCurrentLeagues(Sport.Rugby)).map((l) => l.id) const games = ( await Promise.all( leagueIds.map(async (leagueId) => { diff --git a/app/src/lib/server-context.ts b/app/src/lib/server-context.ts deleted file mode 100644 index 34d893b..0000000 --- a/app/src/lib/server-context.ts +++ /dev/null @@ -1,17 +0,0 @@ -import 'server-only' -// @ts-ignore -import { cache } from 'react' - -const serverContext = (defaultValue: T): [() => T, (v: T) => void] => { - const getRef = cache(() => ({ current: defaultValue })) - - const getValue = (): T => getRef().current - - const setValue = (value: T) => { - getRef().current = value - } - - return [getValue, setValue] -} - -export const [getLeaguesIds, setLeaguesIds] = serverContext([])