2024-06-20 14:18:00 -05:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import { TrashIcon } from '@radix-ui/react-icons';
|
|
|
|
|
import { Box, Button, Flex, IconButton, Text } from '@radix-ui/themes';
|
|
|
|
|
import { produce } from 'immer';
|
|
|
|
|
import { times } from 'lodash';
|
|
|
|
|
import { use, useState } from 'react';
|
2024-06-18 14:28:20 -05:00
|
|
|
import { classIcons } from '../../../components/ClassIcon';
|
2024-06-20 13:31:42 -05:00
|
|
|
import { ExperimentIcon } from '../../../components/ExperimentIcon';
|
2023-11-30 12:21:20 -06:00
|
|
|
import PageWrapper from '../../../components/PageWrapper';
|
2024-06-20 13:20:03 -05:00
|
|
|
import { ResearchedIcon } from '../../../components/ResearchedIcon';
|
2024-06-20 13:31:42 -05:00
|
|
|
import { ScienceIcon } from '../../../components/ScienceIcon';
|
|
|
|
|
import { ScienceOffIcon } from '../../../components/ScienceOffIcon';
|
2024-06-20 14:18:00 -05:00
|
|
|
import { TankClass, TreeType } from '../../../components/Tanks';
|
2024-06-18 14:28:20 -05:00
|
|
|
import { TANK_CLASSES } from '../../../components/Tanks/components/Item/constants';
|
|
|
|
|
import { asset } from '../../../core/blitzkit/asset';
|
2024-06-19 20:53:59 -05:00
|
|
|
import { gameDefinitions } from '../../../core/blitzkit/gameDefinitions';
|
2024-06-20 14:18:00 -05:00
|
|
|
import { Tier } from '../../../core/blitzkit/tankDefinitions';
|
2024-06-18 14:28:20 -05:00
|
|
|
import { TIER_ROMAN_NUMERALS } from '../../../core/blitzkit/tankDefinitions/constants';
|
2024-06-20 14:18:00 -05:00
|
|
|
import { Results } from './components/Results';
|
|
|
|
|
|
|
|
|
|
export interface TankopediaSearchPageFilters {
|
|
|
|
|
tier?: Tier;
|
|
|
|
|
nation?: string;
|
|
|
|
|
class?: TankClass;
|
|
|
|
|
type?: TreeType;
|
|
|
|
|
testing: 'include' | 'exclude' | 'only';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const defaultTankopediaSearchPageFilters: TankopediaSearchPageFilters = {
|
|
|
|
|
testing: 'include',
|
|
|
|
|
};
|
2023-11-30 12:21:20 -06:00
|
|
|
|
2023-11-30 18:00:48 -06:00
|
|
|
export default function Page() {
|
2024-06-19 20:53:59 -05:00
|
|
|
const awaitedGameDefinitions = use(gameDefinitions);
|
2024-06-20 14:18:00 -05:00
|
|
|
const [filters, setFilters] = useState<TankopediaSearchPageFilters>(
|
|
|
|
|
defaultTankopediaSearchPageFilters,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
function mutateFilters(recipe: (draft: TankopediaSearchPageFilters) => void) {
|
|
|
|
|
setFilters(produce(recipe));
|
|
|
|
|
}
|
2023-12-03 19:45:43 -06:00
|
|
|
|
2023-11-30 12:21:20 -06:00
|
|
|
return (
|
2024-06-19 13:58:37 -05:00
|
|
|
<PageWrapper color="purple" size={1028 + 256}>
|
2024-06-20 13:20:03 -05:00
|
|
|
<Flex
|
|
|
|
|
gap="8"
|
|
|
|
|
direction={{
|
|
|
|
|
initial: 'column',
|
|
|
|
|
sm: 'row',
|
|
|
|
|
}}
|
|
|
|
|
pt={{
|
|
|
|
|
initial: '0',
|
|
|
|
|
sm: '6',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<Flex
|
|
|
|
|
direction={{
|
|
|
|
|
initial: 'row',
|
|
|
|
|
sm: 'column',
|
|
|
|
|
}}
|
2024-06-20 13:31:42 -05:00
|
|
|
gap="2"
|
|
|
|
|
align={{
|
|
|
|
|
initial: 'start',
|
|
|
|
|
sm: 'start',
|
|
|
|
|
}}
|
|
|
|
|
justify={{
|
|
|
|
|
initial: 'center',
|
|
|
|
|
sm: 'start',
|
|
|
|
|
}}
|
2024-06-20 13:20:03 -05:00
|
|
|
>
|
2024-06-19 13:58:37 -05:00
|
|
|
<Flex
|
2024-06-20 13:20:03 -05:00
|
|
|
direction={{
|
|
|
|
|
initial: 'row',
|
|
|
|
|
sm: 'column',
|
|
|
|
|
}}
|
2024-06-19 13:58:37 -05:00
|
|
|
overflow="hidden"
|
|
|
|
|
style={{
|
|
|
|
|
borderRadius: 'var(--radius-4)',
|
|
|
|
|
}}
|
|
|
|
|
>
|
2024-06-20 13:20:03 -05:00
|
|
|
<Flex
|
|
|
|
|
direction={{
|
|
|
|
|
sm: 'row',
|
|
|
|
|
initial: 'column',
|
|
|
|
|
}}
|
|
|
|
|
>
|
2024-06-19 13:58:37 -05:00
|
|
|
{times(5, (index) => {
|
|
|
|
|
const tier = (index + 1) as Tier;
|
2024-06-20 14:18:00 -05:00
|
|
|
const selected = filters.tier === tier;
|
2024-04-19 09:26:53 -05:00
|
|
|
|
2024-06-19 13:58:37 -05:00
|
|
|
return (
|
2024-06-20 14:18:00 -05:00
|
|
|
<IconButton
|
2024-06-19 20:23:44 -05:00
|
|
|
key={tier}
|
2024-06-20 14:18:00 -05:00
|
|
|
variant={selected ? 'solid' : 'soft'}
|
2024-06-19 13:58:37 -05:00
|
|
|
radius="none"
|
2024-06-20 14:18:00 -05:00
|
|
|
color={selected ? undefined : 'gray'}
|
2024-06-19 13:58:37 -05:00
|
|
|
highContrast
|
2024-06-20 14:18:00 -05:00
|
|
|
onClick={() =>
|
|
|
|
|
mutateFilters((draft) => {
|
|
|
|
|
draft.tier = draft.tier === tier ? undefined : tier;
|
|
|
|
|
})
|
|
|
|
|
}
|
2024-06-19 13:58:37 -05:00
|
|
|
>
|
2024-06-20 14:18:00 -05:00
|
|
|
<Text size="2">{TIER_ROMAN_NUMERALS[tier]}</Text>
|
|
|
|
|
</IconButton>
|
2024-06-19 13:58:37 -05:00
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</Flex>
|
2024-06-20 13:20:03 -05:00
|
|
|
<Flex
|
|
|
|
|
direction={{
|
|
|
|
|
sm: 'row',
|
|
|
|
|
initial: 'column',
|
|
|
|
|
}}
|
|
|
|
|
>
|
2024-06-19 13:58:37 -05:00
|
|
|
{times(5, (index) => {
|
|
|
|
|
const tier = (index + 6) as Tier;
|
2024-06-20 14:18:00 -05:00
|
|
|
const selected = filters.tier === tier;
|
2024-06-18 14:28:20 -05:00
|
|
|
|
2024-06-19 13:58:37 -05:00
|
|
|
return (
|
2024-06-20 14:18:00 -05:00
|
|
|
<IconButton
|
2024-06-19 20:23:44 -05:00
|
|
|
key={tier}
|
2024-06-20 14:18:00 -05:00
|
|
|
variant={selected ? 'solid' : 'soft'}
|
2024-06-19 13:58:37 -05:00
|
|
|
radius="none"
|
2024-06-20 14:18:00 -05:00
|
|
|
color={selected ? undefined : 'gray'}
|
2024-06-19 13:58:37 -05:00
|
|
|
highContrast
|
2024-06-20 14:18:00 -05:00
|
|
|
onClick={() =>
|
|
|
|
|
mutateFilters((draft) => {
|
|
|
|
|
draft.tier = draft.tier === tier ? undefined : tier;
|
|
|
|
|
})
|
|
|
|
|
}
|
2024-06-19 13:58:37 -05:00
|
|
|
>
|
2024-06-20 14:18:00 -05:00
|
|
|
<Text size="2">{TIER_ROMAN_NUMERALS[tier]}</Text>
|
|
|
|
|
</IconButton>
|
2024-06-19 13:58:37 -05:00
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</Flex>
|
|
|
|
|
</Flex>
|
2024-06-18 14:28:20 -05:00
|
|
|
|
2024-06-19 13:58:37 -05:00
|
|
|
<Flex
|
2024-06-20 13:20:03 -05:00
|
|
|
direction={{
|
|
|
|
|
initial: 'row',
|
|
|
|
|
sm: 'column',
|
2024-06-19 13:58:37 -05:00
|
|
|
}}
|
2024-06-19 20:53:59 -05:00
|
|
|
overflow="hidden"
|
|
|
|
|
style={{
|
|
|
|
|
borderRadius: 'var(--radius-4)',
|
|
|
|
|
}}
|
|
|
|
|
>
|
2024-06-20 13:20:03 -05:00
|
|
|
<Flex
|
|
|
|
|
direction={{
|
|
|
|
|
sm: 'row',
|
|
|
|
|
initial: 'column',
|
|
|
|
|
}}
|
|
|
|
|
>
|
2024-06-19 20:53:59 -05:00
|
|
|
{awaitedGameDefinitions.nations
|
|
|
|
|
.slice(0, Math.ceil(awaitedGameDefinitions.nations.length / 2))
|
2024-06-20 14:18:00 -05:00
|
|
|
.map((nation) => {
|
|
|
|
|
const selected = filters.nation === nation;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<IconButton
|
|
|
|
|
variant={selected ? 'solid' : 'soft'}
|
|
|
|
|
color={selected ? undefined : 'gray'}
|
|
|
|
|
highContrast
|
|
|
|
|
radius="none"
|
|
|
|
|
onClick={() =>
|
|
|
|
|
mutateFilters((draft) => {
|
|
|
|
|
draft.nation =
|
|
|
|
|
draft.nation === nation ? undefined : nation;
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
style={{ width: '1em', height: '1em' }}
|
|
|
|
|
src={asset(`flags/circle/${nation}.webp`)}
|
|
|
|
|
/>
|
|
|
|
|
</IconButton>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2024-06-19 20:53:59 -05:00
|
|
|
</Flex>
|
2024-06-20 13:20:03 -05:00
|
|
|
<Flex
|
|
|
|
|
direction={{
|
|
|
|
|
sm: 'row',
|
|
|
|
|
initial: 'column',
|
|
|
|
|
}}
|
|
|
|
|
>
|
2024-06-19 20:53:59 -05:00
|
|
|
{awaitedGameDefinitions.nations
|
|
|
|
|
.slice(Math.ceil(awaitedGameDefinitions.nations.length / 2))
|
2024-06-20 14:18:00 -05:00
|
|
|
.map((nation) => {
|
|
|
|
|
const selected = filters.nation === nation;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<IconButton
|
|
|
|
|
style={{ flex: 1 }}
|
|
|
|
|
variant={selected ? 'solid' : 'soft'}
|
|
|
|
|
color={selected ? undefined : 'gray'}
|
|
|
|
|
highContrast
|
|
|
|
|
radius="none"
|
|
|
|
|
onClick={() =>
|
|
|
|
|
mutateFilters((draft) => {
|
|
|
|
|
draft.nation =
|
|
|
|
|
draft.nation === nation ? undefined : nation;
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
style={{ width: '1em', height: '1em' }}
|
|
|
|
|
src={asset(`flags/circle/${nation}.webp`)}
|
|
|
|
|
/>
|
|
|
|
|
</IconButton>
|
|
|
|
|
);
|
|
|
|
|
})}
|
2024-06-19 20:53:59 -05:00
|
|
|
</Flex>
|
2024-06-19 13:58:37 -05:00
|
|
|
</Flex>
|
2024-06-18 14:28:20 -05:00
|
|
|
|
2024-06-20 13:20:03 -05:00
|
|
|
<Flex
|
|
|
|
|
overflow="hidden"
|
|
|
|
|
style={{
|
|
|
|
|
borderRadius: 'var(--radius-full)',
|
|
|
|
|
}}
|
|
|
|
|
direction={{
|
|
|
|
|
sm: 'row',
|
|
|
|
|
initial: 'column',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{TANK_CLASSES.map((tankClass) => {
|
|
|
|
|
const Icon = classIcons[tankClass];
|
2024-06-20 14:18:00 -05:00
|
|
|
const selected = filters.class === tankClass;
|
2024-06-20 13:20:03 -05:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<IconButton
|
|
|
|
|
key={tankClass}
|
2024-06-20 14:18:00 -05:00
|
|
|
variant={selected ? 'solid' : 'soft'}
|
2024-06-20 13:20:03 -05:00
|
|
|
radius="none"
|
2024-06-20 14:18:00 -05:00
|
|
|
color={selected ? undefined : 'gray'}
|
2024-06-20 13:20:03 -05:00
|
|
|
highContrast
|
2024-06-20 14:18:00 -05:00
|
|
|
onClick={() =>
|
|
|
|
|
mutateFilters((draft) => {
|
|
|
|
|
draft.class =
|
|
|
|
|
draft.class === tankClass ? undefined : tankClass;
|
|
|
|
|
})
|
|
|
|
|
}
|
2024-06-20 13:20:03 -05:00
|
|
|
>
|
|
|
|
|
<Icon style={{ width: '1em', height: '1em' }} />
|
|
|
|
|
</IconButton>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</Flex>
|
|
|
|
|
|
|
|
|
|
<Flex
|
|
|
|
|
overflow="hidden"
|
|
|
|
|
style={{
|
|
|
|
|
borderRadius: 'var(--radius-full)',
|
|
|
|
|
}}
|
|
|
|
|
direction={{
|
|
|
|
|
sm: 'row',
|
|
|
|
|
initial: 'column',
|
|
|
|
|
}}
|
|
|
|
|
>
|
2024-06-20 14:18:00 -05:00
|
|
|
<IconButton
|
|
|
|
|
variant={filters.type === 'researchable' ? 'solid' : 'soft'}
|
|
|
|
|
radius="none"
|
|
|
|
|
color={filters.type === 'researchable' ? undefined : 'gray'}
|
|
|
|
|
highContrast
|
|
|
|
|
onClick={() =>
|
|
|
|
|
mutateFilters((draft) => {
|
|
|
|
|
draft.type =
|
|
|
|
|
draft.type === 'researchable' ? undefined : 'researchable';
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
>
|
2024-06-20 13:20:03 -05:00
|
|
|
<ResearchedIcon style={{ width: '1em', height: '1em' }} />
|
|
|
|
|
</IconButton>
|
2024-06-20 14:18:00 -05:00
|
|
|
<IconButton
|
|
|
|
|
variant={filters.type === 'premium' ? 'solid' : 'soft'}
|
|
|
|
|
radius="none"
|
|
|
|
|
color={filters.type === 'premium' ? 'amber' : 'gray'}
|
|
|
|
|
highContrast
|
|
|
|
|
onClick={() =>
|
|
|
|
|
mutateFilters((draft) => {
|
|
|
|
|
draft.type = draft.type === 'premium' ? undefined : 'premium';
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
>
|
2024-06-20 13:20:03 -05:00
|
|
|
<Text
|
2024-06-20 14:18:00 -05:00
|
|
|
color={filters.type === 'premium' ? undefined : 'amber'}
|
2024-06-20 13:20:03 -05:00
|
|
|
style={{ display: 'flex', justifyContent: 'center' }}
|
|
|
|
|
>
|
|
|
|
|
<ResearchedIcon style={{ width: '1em', height: '1em' }} />
|
|
|
|
|
</Text>
|
|
|
|
|
</IconButton>
|
2024-06-20 14:18:00 -05:00
|
|
|
<IconButton
|
|
|
|
|
variant={filters.type === 'collector' ? 'solid' : 'soft'}
|
|
|
|
|
radius="none"
|
|
|
|
|
color={filters.type === 'collector' ? 'blue' : 'gray'}
|
|
|
|
|
highContrast
|
|
|
|
|
onClick={() =>
|
|
|
|
|
mutateFilters((draft) => {
|
|
|
|
|
draft.type =
|
|
|
|
|
draft.type === 'collector' ? undefined : 'collector';
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
>
|
2024-06-20 13:20:03 -05:00
|
|
|
<Text
|
2024-06-20 14:18:00 -05:00
|
|
|
color={filters.type === 'premium' ? undefined : 'blue'}
|
2024-06-20 13:20:03 -05:00
|
|
|
style={{ display: 'flex', justifyContent: 'center' }}
|
|
|
|
|
>
|
|
|
|
|
<ResearchedIcon style={{ width: '1em', height: '1em' }} />
|
|
|
|
|
</Text>
|
|
|
|
|
</IconButton>
|
|
|
|
|
</Flex>
|
|
|
|
|
|
2024-06-20 13:31:42 -05:00
|
|
|
<Flex
|
|
|
|
|
overflow="hidden"
|
|
|
|
|
style={{
|
|
|
|
|
borderRadius: 'var(--radius-full)',
|
|
|
|
|
}}
|
|
|
|
|
direction={{
|
|
|
|
|
sm: 'row',
|
|
|
|
|
initial: 'column',
|
|
|
|
|
}}
|
|
|
|
|
>
|
2024-06-20 14:18:00 -05:00
|
|
|
<IconButton
|
|
|
|
|
variant={filters.testing === 'include' ? 'solid' : 'soft'}
|
|
|
|
|
radius="none"
|
|
|
|
|
color={filters.testing === 'include' ? undefined : 'gray'}
|
|
|
|
|
highContrast
|
|
|
|
|
onClick={() =>
|
|
|
|
|
mutateFilters((draft) => {
|
|
|
|
|
draft.testing = 'include';
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
>
|
2024-06-20 13:31:42 -05:00
|
|
|
<ExperimentIcon
|
|
|
|
|
style={{ width: '1em', height: '1em', color: 'currentColor' }}
|
|
|
|
|
/>
|
|
|
|
|
</IconButton>
|
2024-06-20 14:18:00 -05:00
|
|
|
<IconButton
|
|
|
|
|
variant={filters.testing === 'exclude' ? 'solid' : 'soft'}
|
|
|
|
|
radius="none"
|
|
|
|
|
color={filters.testing === 'exclude' ? undefined : 'gray'}
|
|
|
|
|
highContrast
|
|
|
|
|
onClick={() =>
|
|
|
|
|
mutateFilters((draft) => {
|
|
|
|
|
draft.testing = 'exclude';
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
>
|
2024-06-20 13:31:42 -05:00
|
|
|
<ScienceOffIcon
|
|
|
|
|
style={{ width: '1em', height: '1em', color: 'currentColor' }}
|
|
|
|
|
/>
|
|
|
|
|
</IconButton>
|
2024-06-20 14:18:00 -05:00
|
|
|
<IconButton
|
|
|
|
|
variant={filters.testing === 'only' ? 'solid' : 'soft'}
|
|
|
|
|
radius="none"
|
|
|
|
|
color={filters.testing === 'only' ? undefined : 'gray'}
|
|
|
|
|
highContrast
|
|
|
|
|
onClick={() =>
|
|
|
|
|
mutateFilters((draft) => {
|
|
|
|
|
draft.testing = 'only';
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<ScienceIcon
|
|
|
|
|
style={{ width: '1em', height: '1em', color: 'currentColor' }}
|
|
|
|
|
/>
|
|
|
|
|
</IconButton>
|
2024-06-20 13:20:03 -05:00
|
|
|
</Flex>
|
2024-06-20 14:18:00 -05:00
|
|
|
|
|
|
|
|
<Box display={{ initial: 'block', sm: 'none' }}>
|
|
|
|
|
<IconButton
|
|
|
|
|
color="red"
|
|
|
|
|
ml="2"
|
|
|
|
|
onClick={() => setFilters(defaultTankopediaSearchPageFilters)}
|
|
|
|
|
>
|
|
|
|
|
<TrashIcon />
|
|
|
|
|
</IconButton>
|
|
|
|
|
</Box>
|
|
|
|
|
<Box display={{ initial: 'none', sm: 'block' }}>
|
|
|
|
|
<Button
|
|
|
|
|
color="red"
|
|
|
|
|
mt="2"
|
|
|
|
|
onClick={() => setFilters(defaultTankopediaSearchPageFilters)}
|
|
|
|
|
>
|
|
|
|
|
<TrashIcon /> Clear
|
|
|
|
|
</Button>
|
|
|
|
|
</Box>
|
2024-06-19 13:58:37 -05:00
|
|
|
</Flex>
|
2024-06-18 14:28:20 -05:00
|
|
|
|
2024-06-20 14:18:00 -05:00
|
|
|
<Results filters={filters} />
|
2024-06-18 14:28:20 -05:00
|
|
|
</Flex>
|
2023-11-30 12:21:20 -06:00
|
|
|
</PageWrapper>
|
|
|
|
|
);
|
|
|
|
|
}
|