2025-09-02 16:24:13 -05:00
|
|
|
import { literals } from "@blitzkit/i18n/src/literals";
|
|
|
|
|
import { EyeOpenIcon } from "@radix-ui/react-icons";
|
|
|
|
|
import { Box, Flex, Heading, Text } from "@radix-ui/themes";
|
|
|
|
|
import { awaitablePopularTanks } from "../core/awaitables/popularTanks";
|
|
|
|
|
import { awaitableTankDefinitions } from "../core/awaitables/tankDefinitions";
|
2025-01-06 20:31:21 -06:00
|
|
|
import {
|
|
|
|
|
LocaleProvider,
|
|
|
|
|
useLocale,
|
|
|
|
|
type LocaleAcceptorProps,
|
2025-09-02 16:24:13 -05:00
|
|
|
} from "../hooks/useLocale";
|
|
|
|
|
import { TankCard } from "./TankCard";
|
2024-11-11 12:46:06 -06:00
|
|
|
|
2025-04-18 23:57:04 -05:00
|
|
|
const [tankDefinitions, popularTanks] = await Promise.all([
|
|
|
|
|
awaitableTankDefinitions,
|
|
|
|
|
awaitablePopularTanks,
|
|
|
|
|
]);
|
2024-11-11 12:46:06 -06:00
|
|
|
|
2025-01-06 20:31:21 -06:00
|
|
|
export function HomePageHotTanks({ locale }: LocaleAcceptorProps) {
|
2024-11-11 12:46:06 -06:00
|
|
|
return (
|
2024-12-27 14:01:59 -06:00
|
|
|
<LocaleProvider locale={locale}>
|
2025-09-02 16:24:13 -05:00
|
|
|
<Content />
|
2024-12-27 14:01:59 -06:00
|
|
|
</LocaleProvider>
|
2024-11-11 12:46:06 -06:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Content() {
|
2025-01-06 20:09:11 -06:00
|
|
|
const { locale, strings } = useLocale();
|
|
|
|
|
|
2024-11-11 12:46:06 -06:00
|
|
|
return (
|
2025-04-03 12:15:08 -05:00
|
|
|
<Flex direction="column" pt="4" pb="6">
|
2024-11-11 12:46:06 -06:00
|
|
|
<Heading align="center" size="5">
|
2025-01-06 20:09:11 -06:00
|
|
|
{strings.website.home.hot_tanks.title}
|
2024-11-11 12:46:06 -06:00
|
|
|
</Heading>
|
2024-12-12 15:03:51 -06:00
|
|
|
<Text color="gray" align="center" mb="5" size="2">
|
2025-09-02 16:24:13 -05:00
|
|
|
{literals(strings.website.home.hot_tanks.subtitle, ["7"])}
|
2024-12-12 15:03:51 -06:00
|
|
|
</Text>
|
2024-11-11 12:46:06 -06:00
|
|
|
|
|
|
|
|
<Flex justify="center" gap="4" wrap="wrap">
|
2025-04-18 23:57:04 -05:00
|
|
|
{popularTanks.tanks.map(({ id, views }) => {
|
|
|
|
|
const tank = tankDefinitions.tanks[id];
|
|
|
|
|
|
|
|
|
|
if (tank === undefined) return null;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Box width="7rem" key={tank.id}>
|
|
|
|
|
<TankCard
|
|
|
|
|
tank={tank}
|
|
|
|
|
discriminator={
|
|
|
|
|
<Flex align="center" gap="1" justify="center">
|
|
|
|
|
<EyeOpenIcon />
|
|
|
|
|
{Math.round(views * (30 / 7)).toLocaleString(locale)}
|
|
|
|
|
</Flex>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2024-11-11 12:46:06 -06:00
|
|
|
</Flex>
|
|
|
|
|
</Flex>
|
|
|
|
|
);
|
|
|
|
|
}
|