From 36db3ad6ebe72ac28e6874b6ffd2e1c2104dae0e Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Thu, 3 Dec 2026 21:42:26 -0600 Subject: [PATCH] add portals to tank flters --- .../components/TankSearchFilters/index.tsx | 1003 +++++++++-------- 1 file changed, 514 insertions(+), 489 deletions(-) diff --git a/packages/website/src/components/TankSearchFilters/index.tsx b/packages/website/src/components/TankSearchFilters/index.tsx index 028874cc8..89849deb7 100644 --- a/packages/website/src/components/TankSearchFilters/index.tsx +++ b/packages/website/src/components/TankSearchFilters/index.tsx @@ -214,53 +214,57 @@ function TiersFilter() { - - {TIERS.map((tier) => { - const selected = tiersRaw.includes(tier); + + + {TIERS.map((tier) => { + const selected = tiersRaw.includes(tier); - return ( - { - event.preventDefault(); + return ( + { + event.preventDefault(); - TankFilters.mutate((draft) => { - if (selected) { - draft.tiers = draft.tiers.filter((t) => t !== tier); - } else { - draft.tiers = [...draft.tiers, tier].sort((a, b) => b - a); - } - }); - }} - checked={selected} - key={tier} - > - - - + TankFilters.mutate((draft) => { + if (selected) { + draft.tiers = draft.tiers.filter((t) => t !== tier); + } else { + draft.tiers = [...draft.tiers, tier].sort( + (a, b) => b - a, + ); + } + }); + }} + checked={selected} + key={tier} + > + + + - {literals(strings.website.common.tank_search.tier, { - tier: romanize(tier), - })} - - ); - })} + {literals(strings.website.common.tank_search.tier, { + tier: romanize(tier), + })} + + ); + })} - + - { - event.preventDefault(); + { + event.preventDefault(); - TankFilters.mutate((draft) => { - draft.tiers = []; - }); - }} - > - {strings.website.common.tank_search.clear} - - - + TankFilters.mutate((draft) => { + draft.tiers = []; + }); + }} + > + {strings.website.common.tank_search.clear} + + + + ); } @@ -285,67 +289,69 @@ function NationsFilter() { - - {gameDefinitions.nations.map((nation) => { - const selected = rawNations.includes(nation); + + + {gameDefinitions.nations.map((nation) => { + const selected = rawNations.includes(nation); - return ( - { - event.preventDefault(); + return ( + { + event.preventDefault(); - TankFilters.mutate((draft) => { - if (selected) { - draft.nations = draft.nations.filter((n) => n !== nation); - } else { - draft.nations = [...draft.nations, nation]; - } - }); - }} - checked={selected} - key={nation} - > - - - - -
{ + if (selected) { + draft.nations = draft.nations.filter((n) => n !== nation); + } else { + draft.nations = [...draft.nations, nation]; + } + }); }} - /> + checked={selected} + key={nation} + > + + + - { - strings.common.nations[ - nation as keyof typeof strings.common.nations - ] - } - - ); - })} +
- + { + strings.common.nations[ + nation as keyof typeof strings.common.nations + ] + } + + ); + })} - { - event.preventDefault(); + - TankFilters.mutate((draft) => { - draft.nations = []; - }); - }} - > - {strings.website.common.tank_search.clear} + { + event.preventDefault(); - - - + TankFilters.mutate((draft) => { + draft.nations = []; + }); + }} + > + {strings.website.common.tank_search.clear} + + + + + ); } @@ -371,56 +377,58 @@ function ClassFilter() { - - {tankClassOrder.map((tankClass) => { - const selected = rawClasses.includes(tankClass); + + + {tankClassOrder.map((tankClass) => { + const selected = rawClasses.includes(tankClass); - return ( - { - event.preventDefault(); + return ( + { + event.preventDefault(); - TankFilters.mutate((draft) => { - if (selected) { - draft.classes = draft.classes.filter( - (c) => c !== tankClass, - ); - } else { - draft.classes = [...draft.classes, tankClass]; - } - }); - }} - checked={selected} - > - - - + TankFilters.mutate((draft) => { + if (selected) { + draft.classes = draft.classes.filter( + (c) => c !== tankClass, + ); + } else { + draft.classes = [...draft.classes, tankClass]; + } + }); + }} + checked={selected} + > + + + - {strings.common.tank_class_medium[tankClass]} + {strings.common.tank_class_medium[tankClass]} - - - ); - })} + + + ); + })} - + - { - event.preventDefault(); + { + event.preventDefault(); - TankFilters.mutate((draft) => { - draft.classes = []; - }); - }} - > - {strings.website.common.tank_search.clear} + TankFilters.mutate((draft) => { + draft.classes = []; + }); + }} + > + {strings.website.common.tank_search.clear} - - - + + + + ); } @@ -447,54 +455,58 @@ function GunTypeFilter() { - - {gunTypeOrder.map((gunType) => { - const selected = rawGunTypes.includes(gunType); + + + {gunTypeOrder.map((gunType) => { + const selected = rawGunTypes.includes(gunType); - return ( - { - event.preventDefault(); + return ( + { + event.preventDefault(); - TankFilters.mutate((draft) => { - if (selected) { - draft.gunType = draft.gunType.filter((c) => c !== gunType); - } else { - draft.gunType = [...draft.gunType, gunType]; - } - }); - }} - checked={selected} - key={gunType} - > - - - + TankFilters.mutate((draft) => { + if (selected) { + draft.gunType = draft.gunType.filter( + (c) => c !== gunType, + ); + } else { + draft.gunType = [...draft.gunType, gunType]; + } + }); + }} + checked={selected} + key={gunType} + > + + + - {strings.common.gun_types[gunType]} + {strings.common.gun_types[gunType]} - - - ); - })} + + + ); + })} - + - { - event.preventDefault(); + { + event.preventDefault(); - TankFilters.mutate((draft) => { - draft.gunType = []; - }); - }} - > - {strings.website.common.tank_search.clear} + TankFilters.mutate((draft) => { + draft.gunType = []; + }); + }} + > + {strings.website.common.tank_search.clear} - - - + + + + ); } @@ -525,60 +537,62 @@ function TypeFilter() { - - {treeTypeOrder.map((tankType) => { - const selected = rawTypes.includes(tankType); + + + {treeTypeOrder.map((tankType) => { + const selected = rawTypes.includes(tankType); - return ( - { - event.preventDefault(); + return ( + { + event.preventDefault(); - TankFilters.mutate((draft) => { - if (selected) { - draft.types = draft.types.filter((c) => c !== tankType); - } else { - draft.types = [...draft.types, tankType]; - } - }); - }} - checked={selected} - key={tankType} - > - - - - - {strings.common.tree_type[tankType]} - - { + if (selected) { + draft.types = draft.types.filter((c) => c !== tankType); + } else { + draft.types = [...draft.types, tankType]; + } + }); }} - /> - - ); - })} + checked={selected} + key={tankType} + > + + + - + {strings.common.tree_type[tankType]} - { - event.preventDefault(); + + + ); + })} - TankFilters.mutate((draft) => { - draft.types = []; - }); - }} - > - {strings.website.common.tank_search.clear} + - - - + { + event.preventDefault(); + + TankFilters.mutate((draft) => { + draft.types = []; + }); + }} + > + {strings.website.common.tank_search.clear} + + + + + ); } @@ -624,76 +638,78 @@ function IndividualShellFilter({ - - - {Object.values(ShellType).map((shellType) => { - if (typeof shellType === "string") return null; + + + + {Object.values(ShellType).map((shellType) => { + if (typeof shellType === "string") return null; - const selected = shells[index] === shellType; + const selected = shells[index] === shellType; - return ( - { - event.preventDefault(); + return ( + { + event.preventDefault(); - const mutated = [...shells] as TankFilters["shells"]; + const mutated = [...shells] as TankFilters["shells"]; - mutated[index] = selected ? null : shellType; + mutated[index] = selected ? null : shellType; - TankFilters.mutate((draft) => { - draft.shells = mutated; - }); - }} - color={selected ? undefined : "gray"} - > - - - + TankFilters.mutate((draft) => { + draft.shells = mutated; + }); + }} + color={selected ? undefined : "gray"} + > + + + - { - strings.common.shells[ - shellTypeIcons[ - shellType - ] as keyof typeof strings.common.shells - ] - } + { + strings.common.shells[ + shellTypeIcons[ + shellType + ] as keyof typeof strings.common.shells + ] + } - - - ); - })} + + + ); + })} - + - { - event.preventDefault(); + { + event.preventDefault(); - const mutated = [...shells] as TankFilters["shells"]; + const mutated = [...shells] as TankFilters["shells"]; - mutated[index] = null; + mutated[index] = null; - TankFilters.mutate((draft) => { - draft.shells = mutated; - }); - }} - > - {strings.website.common.tank_search.clear} + TankFilters.mutate((draft) => { + draft.shells = mutated; + }); + }} + > + {strings.website.common.tank_search.clear} - - - - + + + + + ); } @@ -825,60 +841,62 @@ function ConsumablesFilter() { - - {consumablesArray.map((consumable) => { - const selected = rawConsumables.includes(consumable); - const consumableDefinition = - consumableDefinitions.consumables[consumable]; + + + {consumablesArray.map((consumable) => { + const selected = rawConsumables.includes(consumable); + const consumableDefinition = + consumableDefinitions.consumables[consumable]; - return ( - { - event.preventDefault(); + return ( + { + event.preventDefault(); - TankFilters.mutate((draft) => { - if (selected) { - draft.consumables = draft.consumables.filter( - (n) => n !== consumable, - ); - } else { - draft.consumables = [...draft.consumables, consumable]; - } - }); - }} - checked={selected} - key={consumable} - > - - - + TankFilters.mutate((draft) => { + if (selected) { + draft.consumables = draft.consumables.filter( + (n) => n !== consumable, + ); + } else { + draft.consumables = [...draft.consumables, consumable]; + } + }); + }} + checked={selected} + key={consumable} + > + + + - {unwrap(consumableDefinition.name!)} + {unwrap(consumableDefinition.name!)} - - - ); - })} + + + ); + })} - + - { - event.preventDefault(); + { + event.preventDefault(); - TankFilters.mutate((draft) => { - draft.consumables = []; - }); - }} - > - {strings.website.common.tank_search.clear} + TankFilters.mutate((draft) => { + draft.consumables = []; + }); + }} + > + {strings.website.common.tank_search.clear} - - - + + + + ); } @@ -912,60 +930,62 @@ function ProvisionsFilter() { - - {provisionsArray.map((provision) => { - const selected = rawProvisions.includes(provision); - const provisionDefinition = - provisionDefinitions.provisions[provision]; + + + {provisionsArray.map((provision) => { + const selected = rawProvisions.includes(provision); + const provisionDefinition = + provisionDefinitions.provisions[provision]; - return ( - { - event.preventDefault(); + return ( + { + event.preventDefault(); - TankFilters.mutate((draft) => { - if (selected) { - draft.provisions = draft.provisions.filter( - (n) => n !== provision, - ); - } else { - draft.provisions = [...draft.provisions, provision]; - } - }); - }} - checked={selected} - key={provision} - > - - - + TankFilters.mutate((draft) => { + if (selected) { + draft.provisions = draft.provisions.filter( + (n) => n !== provision, + ); + } else { + draft.provisions = [...draft.provisions, provision]; + } + }); + }} + checked={selected} + key={provision} + > + + + - {unwrap(provisionDefinition.name!)} + {unwrap(provisionDefinition.name!)} - - - ); - })} + + + ); + })} - + - { - event.preventDefault(); + { + event.preventDefault(); - TankFilters.mutate((draft) => { - draft.provisions = []; - }); - }} - > - {strings.website.common.tank_search.clear} + TankFilters.mutate((draft) => { + draft.provisions = []; + }); + }} + > + {strings.website.common.tank_search.clear} - - - + + + + ); } @@ -1010,141 +1030,146 @@ function GameModeAbilitiesFilter() { - - {gameModeRoles.map(({ gameModeId, consumables, provisions }) => { - const gameMode = gameDefinitions.gameModes[gameModeId]; - const hasNeither = - consumables.length === 0 && provisions.length === 0; + + + {gameModeRoles.map(({ gameModeId, consumables, provisions }) => { + const gameMode = gameDefinitions.gameModes[gameModeId]; + const hasNeither = + consumables.length === 0 && provisions.length === 0; - if (hasNeither) return null; + if (hasNeither) return null; - const hasBoth = consumables.length > 0 && provisions.length > 0; + const hasBoth = consumables.length > 0 && provisions.length > 0; - return ( - - {consumables.length > 0 && ( - - {hasBoth - ? literals(strings.website.common.tank_search.active, { - name: unwrap(gameMode.name!), - }) - : unwrap(gameMode.name!)} - - )} + return ( + + {consumables.length > 0 && ( + + {hasBoth + ? literals(strings.website.common.tank_search.active, { + name: unwrap(gameMode.name!), + }) + : unwrap(gameMode.name!)} + + )} - {consumables.map((consumable) => { - { - const selected = rawAbilities.includes(consumable); - const abilityDefinition = - consumableDefinitions.consumables[consumable]; + {consumables.map((consumable) => { + { + const selected = rawAbilities.includes(consumable); + const abilityDefinition = + consumableDefinitions.consumables[consumable]; - return ( - { - event.preventDefault(); + return ( + { + event.preventDefault(); - TankFilters.mutate((draft) => { - if (selected) { - draft.abilities = draft.abilities.filter( - (n) => n !== consumable, - ); - } else { - draft.abilities = [...draft.abilities, consumable]; - } - }); - }} - checked={selected} - key={consumable} - > - - - + TankFilters.mutate((draft) => { + if (selected) { + draft.abilities = draft.abilities.filter( + (n) => n !== consumable, + ); + } else { + draft.abilities = [ + ...draft.abilities, + consumable, + ]; + } + }); + }} + checked={selected} + key={consumable} + > + + + - {unwrap(abilityDefinition.name!)} + {unwrap(abilityDefinition.name!)} - - - ); - } - })} + + + ); + } + })} - {provisions.length > 0 && ( - - {hasBoth - ? literals(strings.website.common.tank_search.passive, { - name: unwrap(gameMode.name!), - }) - : unwrap(gameMode.name!)} - - )} + {provisions.length > 0 && ( + + {hasBoth + ? literals(strings.website.common.tank_search.passive, { + name: unwrap(gameMode.name!), + }) + : unwrap(gameMode.name!)} + + )} - {provisions.map((provision) => { - { - const selected = rawPowers.includes(provision); - const powerDefinition = - provisionDefinitions.provisions[provision]; + {provisions.map((provision) => { + { + const selected = rawPowers.includes(provision); + const powerDefinition = + provisionDefinitions.provisions[provision]; - return ( - { - event.preventDefault(); + return ( + { + event.preventDefault(); - TankFilters.mutate((draft) => { - if (selected) { - draft.powers = draft.powers.filter( - (n) => n !== provision, - ); - } else { - draft.powers = [...draft.powers, provision]; - } - }); - }} - checked={selected} - key={provision} - > - - - + TankFilters.mutate((draft) => { + if (selected) { + draft.powers = draft.powers.filter( + (n) => n !== provision, + ); + } else { + draft.powers = [...draft.powers, provision]; + } + }); + }} + checked={selected} + key={provision} + > + + + - {unwrap(powerDefinition.name!)} + {unwrap(powerDefinition.name!)} - - - ); - } - })} - - ); - })} + + + ); + } + })} + + ); + })} - + - { - event.preventDefault(); + { + event.preventDefault(); - TankFilters.mutate((draft) => { - draft.abilities = []; - draft.powers = []; - }); - }} - > - {strings.website.common.tank_search.clear} + TankFilters.mutate((draft) => { + draft.abilities = []; + draft.powers = []; + }); + }} + > + {strings.website.common.tank_search.clear} - - - + + + + ); }