feat: tier filters

This commit is contained in:
TrèsAbhi committed 2023-12-04 11:47:33 -06:00
1 parent 5b4601b671
commit 7020e5641f
4 files changed
+127 -70

No files matched your search

+15 -4
View File
@@ -1,21 +1,32 @@
import { produce } from 'immer';
import { create } from 'zustand';
import { devtools, persist } from 'zustand/middleware';
import { TIERS, Tier } from '../core/blitzkrieg/tankopedia';
export type TankopediaSortBy = 'tier' | 'name';
export type TankopediaSortDirection = 'ascending' | 'descending';
type Tankopedia = {
sortBy: TankopediaSortBy;
sortDirection: TankopediaSortDirection;
sort: {
by: TankopediaSortBy;
direction: TankopediaSortDirection;
};
filters: {
tiers: Tier[];
};
};
export const useTankopedia = create<Tankopedia>()(
devtools(
persist(
(set) => ({
sortBy: 'tier',
sortDirection: 'descending',
sort: {
by: 'tier',
direction: 'descending',
},
filters: {
tiers: [...TIERS],
},
}),
{ name: 'tankopedia' },
),