Files
blitzkit/packages/website/src/components/Tankopedia/CalloutsSection.tsx
T

57 lines
1.8 KiB
TypeScript
Raw Normal View History

2024-11-22 10:50:35 -06:00
import { assertSecret } from '@blitzkit/core';
2024-08-28 18:08:23 -05:00
import { MinusCircledIcon } from '@radix-ui/react-icons';
import { Callout, Flex } from '@radix-ui/themes';
2024-11-12 21:53:22 -06:00
import { uniq } from 'lodash-es';
import { useEffect } from 'react';
2024-09-22 22:04:03 -05:00
import { Duel } from '../../stores/duel';
2024-11-12 21:53:22 -06:00
import { TankopediaPersistent } from '../../stores/tankopediaPersistent';
2024-11-22 10:50:35 -06:00
import { AesonPlug } from '../AesonPlug';
2024-09-22 22:04:03 -05:00
import { ExperimentIcon } from '../ExperimentIcon';
2024-11-12 21:53:22 -06:00
import { MAX_RECENTLY_VIEWED } from '../TankSearch/constants';
2024-08-28 18:08:23 -05:00
export function CalloutsSection() {
const tank = Duel.use((state) => state.protagonist.tank);
2024-11-12 21:53:22 -06:00
const mutateTankopediaPersistent = TankopediaPersistent.useMutation();
2024-11-22 10:50:35 -06:00
const promoteAeson =
assertSecret(import.meta.env.PUBLIC_ASSET_BRANCH) === 'preview';
2024-11-12 21:53:22 -06:00
useEffect(() => {
mutateTankopediaPersistent((draft) => {
draft.recentlyViewed = uniq([tank.id, ...draft.recentlyViewed]).slice(
0,
MAX_RECENTLY_VIEWED,
);
});
}, [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 (
<Flex direction="column" align="center" gap="2" mb="4">
2024-11-22 10:50:35 -06:00
<AesonPlug />
2024-08-28 18:08:23 -05:00
{tank.deprecated && (
<Callout.Root color="red">
<Callout.Icon>
<MinusCircledIcon />
</Callout.Icon>
<Callout.Text>
This tank is deprecated and may display undefined behavior.
</Callout.Text>
</Callout.Root>
)}
{tank.testing && (
<Callout.Root color="red">
<Callout.Icon>
<ExperimentIcon style={{ width: '1em', height: '1em' }} />
</Callout.Icon>
<Callout.Text>
Tanks in testing are subject to change and may not represent the
final product.
</Callout.Text>
</Callout.Root>
)}
</Flex>
);
}