compile tank search page

This commit is contained in:
tresabhi committed 2026-09-27 13:22:34 -05:00
1 parent d8f6a55ee4
commit 558a02b6ae
17 files changed
+54 -48

No files matched your search

@@ -1,4 +1,4 @@
import { MapDefinitions } from "@blitzkit/core"; import { MapDefinitions } from "@blitzkit/protos";
import { Cache } from "./0_base"; import { Cache } from "./0_base";
import { ServerBlitzKitAPI3 } from "./3_models"; import { ServerBlitzKitAPI3 } from "./3_models";
+2 -2
View File
@@ -1,5 +1,5 @@
import { emptyAllStats } from '..'; import { emptyAllStats } from "../types";
import { BlitzStats } from './compositeStats/constants'; import { BlitzStats } from "./compositeStats/constants";
export function sumAllStats(allStatsCollection: BlitzStats[]) { export function sumAllStats(allStatsCollection: BlitzStats[]) {
return allStatsCollection.reduce((accumulated, current) => { return allStatsCollection.reduce((accumulated, current) => {
+21 -2
View File
@@ -1,5 +1,24 @@
import { emptyAllStats } from '../blitz'; import type { BlitzStats } from "../statistics";
import type { BlitzStats } from '../statistics';
export const emptyAllStats: BlitzStats = {
battles: 0,
capture_points: 0,
damage_dealt: 0,
damage_received: 0,
dropped_capture_points: 0,
frags: 0,
frags8p: 0,
hits: 0,
losses: 0,
max_frags: 0,
max_xp: 0,
shots: 0,
spotted: 0,
survived_battles: 0,
win_and_survived: 0,
wins: 0,
xp: 0,
};
export interface IndividualTankStats { export interface IndividualTankStats {
all: BlitzStats; all: BlitzStats;
-1
View File
@@ -1,4 +1,3 @@
export * from "./literals"; export * from "./literals";
export * from "./strings"; export * from "./strings";
export * from "./unwrapper"; export * from "./unwrapper";
export * from "./wrapper";
-15
View File
@@ -1,15 +0,0 @@
import locales from "../locales.json";
import { type BlitzKitStrings, STRINGS } from "./strings";
export function wrapper(slicer: (strings: BlitzKitStrings) => string) {
const defaultString = slicer(STRINGS[locales.default] as BlitzKitStrings);
const object = { [locales.default]: defaultString };
for (const { locale } of locales.supported) {
const string = slicer(STRINGS[locale] as BlitzKitStrings);
if (string !== defaultString) object[locale] = string;
}
return object;
}
@@ -1,7 +1,7 @@
import { isEqual } from "lodash-es"; import { isEqual } from "lodash-es";
import { useMemo } from "react"; import { useMemo } from "react";
import { api } from "../../api/dynamic"; import { api } from "../../api/dynamic";
import { useLocale } from "../../hooks/useLocale"; import { useStrings } from "../../hooks/useStrings";
import { TankFilters } from "../../stores/tankFilters"; import { TankFilters } from "../../stores/tankFilters";
import { TankopediaPersistent } from "../../stores/tankopediaPersistent"; import { TankopediaPersistent } from "../../stores/tankopediaPersistent";
import { TankSort } from "../../stores/tankopediaSort"; import { TankSort } from "../../stores/tankopediaSort";
@@ -29,7 +29,8 @@ export function RecentlyViewedTanks() {
}), }),
[filters], [filters],
); );
const { strings } = useLocale();
const strings = useStrings();
const by = TankSort.use((state) => state.by); const by = TankSort.use((state) => state.by);
if (recentlyViewed.length === 0 || by !== "meta.none" || hasFilters) { if (recentlyViewed.length === 0 || by !== "meta.none" || hasFilters) {
@@ -1,11 +1,13 @@
import { alias, TankType, type TankDefinition } from "@blitzkit/core"; import { alias } from "@blitzkit/core";
import { TankType, type TankDefinition } from "@blitzkit/protos";
import { uniq } from "lodash-es"; import { uniq } from "lodash-es";
import { type ReactNode } from "react"; import { type ReactNode } from "react";
import { api } from "../../api/dynamic"; import { api } from "../../api/dynamic";
import { useLocale } from "../../hooks/useLocale"; import { useLocale } from "../../hooks/useLocale";
import { useUnwrapper } from "../../hooks/useUnwrapper";
import { TankopediaPersistent } from "../../stores/tankopediaPersistent"; import { TankopediaPersistent } from "../../stores/tankopediaPersistent";
import type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps"; import type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps";
import { classIcons } from "../ClassIcon"; import { ClassIcon } from "../ClassIcon";
import { Flex } from "../Flex"; import { Flex } from "../Flex";
import { LinkI18nWrapper } from "../LinkI18nWrapper"; import { LinkI18nWrapper } from "../LinkI18nWrapper";
import { TankCardSkeleton } from "../TankCardSkeleton"; import { TankCardSkeleton } from "../TankCardSkeleton";
@@ -28,7 +30,8 @@ export const TankCard = (props: MaybeSkeletonComponentProps<TankCardProps>) => {
return <TankCardSkeleton />; return <TankCardSkeleton />;
} }
const { unwrap, locale } = useLocale(); const unwrap = useUnwrapper();
const locale = useLocale();
const provideLink = !props.noLink && props.onTankSelect === undefined; const provideLink = !props.noLink && props.onTankSelect === undefined;
const name = unwrap(props.tank.name!); const name = unwrap(props.tank.name!);
@@ -41,8 +44,6 @@ export const TankCard = (props: MaybeSkeletonComponentProps<TankCardProps>) => {
: "gray"; : "gray";
const lowContrast = props.tank.type !== TankType.TANK_TYPE_RESEARCHABLE; const lowContrast = props.tank.type !== TankType.TANK_TYPE_RESEARCHABLE;
const Icon = classIcons[props.tank.class];
const content = ( const content = (
<Flex <Flex
className={styles.wrapper} className={styles.wrapper}
@@ -75,7 +76,7 @@ export const TankCard = (props: MaybeSkeletonComponentProps<TankCardProps>) => {
</Flex> </Flex>
<Text className={styles.name} color={color} lowContrast={lowContrast}> <Text className={styles.name} color={color} lowContrast={lowContrast}>
<Icon className={styles.icon} /> <ClassIcon class={props.tank.class} className={styles.icon} />
<span className={styles.text}>{name}</span> <span className={styles.text}>{name}</span>
</Text> </Text>
@@ -1,5 +1,5 @@
import { CaretDownIcon } from "@radix-ui/react-icons"; import { CaretDownIcon } from "@radix-ui/react-icons";
import { useLocale } from "../../../hooks/useLocale"; import { useStrings } from "../../../hooks/useStrings";
import type { import type {
TankopediaSortBy, TankopediaSortBy,
TankopediaSortDirection, TankopediaSortDirection,
@@ -17,7 +17,7 @@ interface ItemProps {
} }
function Item({ by }: ItemProps) { function Item({ by }: ItemProps) {
const { strings } = useLocale(); const strings = useStrings();
const _by = TankSort.use((state) => state.by); const _by = TankSort.use((state) => state.by);
return ( return (
@@ -36,7 +36,7 @@ function Item({ by }: ItemProps) {
export function Sort() { export function Sort() {
const direction = TankSort.use((state) => state.direction); const direction = TankSort.use((state) => state.direction);
const { strings } = useLocale(); const strings = useStrings();
return ( return (
<DropdownMenu.Root> <DropdownMenu.Root>
@@ -1,12 +1,12 @@
import type { TankDefinition } from "@blitzkit/core"; import type { TankDefinition } from "@blitzkit/protos";
import { MagnifyingGlassIcon } from "@radix-ui/react-icons"; import { MagnifyingGlassIcon } from "@radix-ui/react-icons";
import { import {
type KeyboardEventHandler, type KeyboardEventHandler,
useCallback, useCallback,
useEffect, useEffect,
useRef, useRef,
} from "react"; } from "react";
import { useLocale } from "../../hooks/useLocale"; import { useStrings } from "../../hooks/useStrings";
import { TankFilters } from "../../stores/tankFilters"; import { TankFilters } from "../../stores/tankFilters";
import type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps"; import type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps";
import { Flex } from "../Flex"; import { Flex } from "../Flex";
@@ -23,7 +23,7 @@ export function TankSearchBar({
skeleton, skeleton,
onSelect, onSelect,
}: SearchBarProps) { }: SearchBarProps) {
const { strings } = useLocale(); const strings = useStrings();
const search = TankFilters.use((state) => state.search); const search = TankFilters.use((state) => state.search);
@@ -1,7 +1,7 @@
import { isTankCompatible } from "@blitzkit/core";
import type { TankDefinition } from "@blitzkit/protos"; import type { TankDefinition } from "@blitzkit/protos";
import { times } from "lodash-es"; import { times } from "lodash-es";
import { api } from "../../api/dynamic"; import { api } from "../../api/dynamic";
import { isTankCompatible } from "../../hooks/useTankCompatibility";
import type { TankFilters } from "../../stores/tankFilters"; import type { TankFilters } from "../../stores/tankFilters";
const SHELLS = times(3, (index) => index); const SHELLS = times(3, (index) => index);
@@ -1,11 +1,12 @@
import { getTankStats, idToRegion, TankDefinition } from "@blitzkit/core"; import { getTankStats, idToRegion } from "@blitzkit/core";
import type { TankDefinition } from "@blitzkit/protos";
import { TankFilters } from "../../stores/tankFilters"; import { TankFilters } from "../../stores/tankFilters";
import { filterTank } from "./filterTank"; import { filterTank } from "./filterTank";
export async function filterTanks( export async function filterTanks(
filters: TankFilters, filters: TankFilters,
tanks: TankDefinition[], tanks: TankDefinition[],
player?: number player?: number,
) { ) {
const filtered: TankDefinition[] = []; const filtered: TankDefinition[] = [];
let owned: number[] | undefined; let owned: number[] | undefined;
@@ -1,4 +1,4 @@
import { CamouflageDefinitions } from "@blitzkit/core"; import { CamouflageDefinitions } from "@blitzkit/protos";
import { api } from "../../../api/dynamic"; import { api } from "../../../api/dynamic";
export { getStaticPaths } from "../_index"; export { getStaticPaths } from "../_index";
@@ -1,4 +1,4 @@
import { ConsumableDefinitions } from "@blitzkit/core"; import { ConsumableDefinitions } from "@blitzkit/protos";
import { api } from "../../../api/dynamic"; import { api } from "../../../api/dynamic";
export { getStaticPaths } from "../_index"; export { getStaticPaths } from "../_index";
@@ -1,4 +1,4 @@
import { GameDefinitions } from "@blitzkit/core"; import { GameDefinitions } from "@blitzkit/protos";
import { api } from "../../../api/dynamic"; import { api } from "../../../api/dynamic";
export { getStaticPaths } from "../_index"; export { getStaticPaths } from "../_index";
@@ -1,4 +1,4 @@
import { ModelDefinitions } from "@blitzkit/core"; import { ModelDefinitions } from "@blitzkit/protos";
import { api } from "../../../api/dynamic"; import { api } from "../../../api/dynamic";
export { getStaticPaths } from "../_index"; export { getStaticPaths } from "../_index";
@@ -1,4 +1,4 @@
import { ProvisionDefinitions } from "@blitzkit/core"; import { ProvisionDefinitions } from "@blitzkit/protos";
import { api } from "../../../api/dynamic"; import { api } from "../../../api/dynamic";
export { getStaticPaths } from "../_index"; export { getStaticPaths } from "../_index";
@@ -1,4 +1,4 @@
import { TankDefinitions } from "@blitzkit/core"; import { TankDefinitions } from "@blitzkit/protos";
import { api } from "../../../api/dynamic"; import { api } from "../../../api/dynamic";
export { getStaticPaths } from "../_index"; export { getStaticPaths } from "../_index";