2026-08-04 14:02:52 -05:00
|
|
|
import { assertSecret } from "@blitzkit/core";
|
2025-09-02 16:24:13 -05:00
|
|
|
import { MinusCircledIcon } from "@radix-ui/react-icons";
|
|
|
|
|
import { Callout, Flex } from "@radix-ui/themes";
|
|
|
|
|
import { uniq } from "lodash-es";
|
|
|
|
|
import { useEffect } from "react";
|
2026-08-30 15:02:01 -05:00
|
|
|
import { api } from "../../blitzkit/api";
|
2025-09-02 16:24:13 -05:00
|
|
|
import { Duel } from "../../stores/duel";
|
|
|
|
|
import { TankopediaPersistent } from "../../stores/tankopediaPersistent";
|
|
|
|
|
import { AesonPlug } from "../AesonPlug";
|
|
|
|
|
import { ExperimentIcon } from "../ExperimentIcon";
|
|
|
|
|
import { MAX_RECENTLY_VIEWED } from "../TankSearch/constants";
|
2024-08-28 18:08:23 -05:00
|
|
|
|
2026-08-30 14:26:08 -05:00
|
|
|
const tankDefinitions = await api.tanks();
|
2025-01-17 20:29:33 -06:00
|
|
|
|
2024-08-28 18:08:23 -05:00
|
|
|
export function CalloutsSection() {
|
|
|
|
|
const tank = Duel.use((state) => state.protagonist.tank);
|
2024-11-22 10:50:35 -06:00
|
|
|
const promoteAeson =
|
2026-08-08 20:56:45 -05:00
|
|
|
assertSecret(import.meta.env.PUBLIC_ENVIRONMENT) === "preview";
|
2024-11-12 21:53:22 -06:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
2025-09-02 16:24:13 -05:00
|
|
|
TankopediaPersistent.mutate((draft) => {
|
2025-01-17 20:29:33 -06:00
|
|
|
draft.recentlyViewed = uniq([tank.id, ...draft.recentlyViewed])
|
|
|
|
|
.filter((id) => id in tankDefinitions.tanks)
|
|
|
|
|
.slice(0, MAX_RECENTLY_VIEWED);
|
2024-11-12 21:53:22 -06:00
|
|
|
});
|
|
|
|
|
}, [tank]);
|
2024-08-28 18:08:23 -05:00
|
|
|
|
2024-11-22 10:50:35 -06:00
|
|
|
if (!tank.testing && !tank.deprecated && !promoteAeson) return null;
|
2024-08-28 18:08:23 -05:00
|
|
|
|
|
|
|
|
return (
|
2024-11-29 13:29:22 -06:00
|
|
|
<Flex direction="column" align="center" gap="2" mb="4" px="4">
|
2024-11-24 20:39:21 -06:00
|
|
|
{promoteAeson && <AesonPlug />}
|
2024-11-22 10:50:35 -06:00
|
|
|
|
2024-08-28 18:08:23 -05:00
|
|
|
{tank.deprecated && (
|
|
|
|
|
<Callout.Root color="red">
|
|
|
|
|
<Callout.Icon>
|
|
|
|
|
<MinusCircledIcon />
|
|
|
|
|
</Callout.Icon>
|
|
|
|
|
<Callout.Text>
|
2024-11-29 13:29:22 -06:00
|
|
|
Deprecated tanks may display undefined behavior.
|
2024-08-28 18:08:23 -05:00
|
|
|
</Callout.Text>
|
|
|
|
|
</Callout.Root>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{tank.testing && (
|
|
|
|
|
<Callout.Root color="red">
|
|
|
|
|
<Callout.Icon>
|
2025-09-02 16:24:13 -05:00
|
|
|
<ExperimentIcon style={{ width: "1em", height: "1em" }} />
|
2024-08-28 18:08:23 -05:00
|
|
|
</Callout.Icon>
|
|
|
|
|
<Callout.Text>
|
|
|
|
|
Tanks in testing are subject to change and may not represent the
|
|
|
|
|
final product.
|
|
|
|
|
</Callout.Text>
|
|
|
|
|
</Callout.Root>
|
|
|
|
|
)}
|
|
|
|
|
</Flex>
|
|
|
|
|
);
|
|
|
|
|
}
|