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

51 lines
1.6 KiB
TypeScript
Raw Normal View History

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-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();
useEffect(() => {
mutateTankopediaPersistent((draft) => {
draft.recentlyViewed = uniq([tank.id, ...draft.recentlyViewed]).slice(
0,
MAX_RECENTLY_VIEWED,
);
});
}, [tank]);
2024-08-28 18:08:23 -05:00
if (!tank.testing && !tank.deprecated) return null;
return (
<Flex direction="column" align="center" gap="2" mb="4">
{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>
);
}