From 970d93e7e0b09eef69b94329b1858cc2050a7227 Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:46:06 -0600 Subject: [PATCH] fix: hot tanks context --- .../src/components/HomePageHotTanks.tsx | 50 +++++++++++++++++++ packages/website/src/pages/index.astro | 37 +------------- 2 files changed, 52 insertions(+), 35 deletions(-) create mode 100644 packages/website/src/components/HomePageHotTanks.tsx diff --git a/packages/website/src/components/HomePageHotTanks.tsx b/packages/website/src/components/HomePageHotTanks.tsx new file mode 100644 index 000000000..2334f4b5b --- /dev/null +++ b/packages/website/src/components/HomePageHotTanks.tsx @@ -0,0 +1,50 @@ +import { fetchAverageDefinitions, fetchTankDefinitions } from '@blitzkit/core'; +import { Box, Flex, Heading } from '@radix-ui/themes'; +import { TankopediaPersistent } from '../stores/tankopediaPersistent'; +import { TankCard } from './TankSearch/components/TankCard'; + +const tankDefinitions = await fetchTankDefinitions(); +const averageDefinitions = await fetchAverageDefinitions(); +const tanks = Object.values(tankDefinitions.tanks); +const tankAverages = Object.entries(averageDefinitions.averages).map( + ([id, average]) => ({ + id: Number(id), + ...average, + }), +); + +// lol don't ask questions +const testTanks = tanks + .filter((tank) => tank.testing && tank.tier >= 8) + .sort((a, b) => b.tier - a.tier); +const mostPlayedTanks = tankAverages + .sort((a, b) => b.samples.d_1 - a.samples.d_1) + .map(({ id }) => tankDefinitions.tanks[id]) + .filter((tank) => tank !== undefined && !tank.testing); +const popularTanks = [...testTanks, ...mostPlayedTanks].slice(0, 8); + +export function HomePageHotTanks() { + return ( + + + + ); +} + +function Content() { + return ( + + + Popular tanks + + + + {popularTanks.map((tank) => ( + + + + ))} + + + ); +} diff --git a/packages/website/src/pages/index.astro b/packages/website/src/pages/index.astro index ae1a31e75..a1f0679a7 100644 --- a/packages/website/src/pages/index.astro +++ b/packages/website/src/pages/index.astro @@ -1,9 +1,8 @@ --- -import { fetchAverageDefinitions, fetchTankDefinitions } from '@blitzkit/core'; import { Box, Flex, Heading } from '@radix-ui/themes'; import HomeHero from '../components/HomeHero.astro'; +import { HomePageHotTanks } from '../components/HomePageHotTanks'; import { Plugs } from '../components/Plugs.tsx'; -import { TankCard } from '../components/TankSearch/components/TankCard'; import ToolCard from '../components/ToolCard.astro'; import { compareTool, @@ -16,26 +15,6 @@ import { tankopediaTool, } from '../constants/tools'; import BaseLayout from '../layouts/BaseLayout.astro'; - -const tankDefinitions = await fetchTankDefinitions(); -const averageDefinitions = await fetchAverageDefinitions(); -const tanks = Object.values(tankDefinitions.tanks); -const tankAverages = Object.entries(averageDefinitions.averages).map( - ([id, average]) => ({ - id: Number(id), - ...average, - }), -); - -// lol don't ask questions -const testTanks = tanks - .filter((tank) => tank.testing && tank.tier >= 8) - .sort((a, b) => b.tier - a.tier); -const mostPlayedTanks = tankAverages - .sort((a, b) => b.samples.d_1 - a.samples.d_1) - .map(({ id }) => tankDefinitions.tanks[id]) - .filter((tank) => tank !== undefined && !tank.testing); -const popularTanks = [...testTanks, ...mostPlayedTanks].slice(0, 8); --- @@ -47,19 +26,7 @@ const popularTanks = [...testTanks, ...mostPlayedTanks].slice(0, 8); - - Popular tanks - - - { - popularTanks.map((tank) => ( - - - - )) - } - - + {/* */}