mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-15 21:56:10 +01:00
27 lines
660 B
TypeScript
27 lines
660 B
TypeScript
import { produce } from 'immer';
|
|||
|
|
import { create } from 'zustand';
|
||
|
|
import { devtools, persist } from 'zustand/middleware';
|
||
|
|
|
||
|
|
export type TankopediaSortBy = 'tier';
|
||
|
|
export type TankopediaSortDirection = 'ascending' | 'descending';
|
||
|
|
|
||
|
|
type Tankopedia = {
|
||
|
|
sortBy: TankopediaSortBy;
|
||
|
|
sortDirection: TankopediaSortDirection;
|
||
|
|
};
|
||
|
|
|
||
|
|
export const useTankopedia = create<Tankopedia>()(
|
||
|
|
devtools(
|
||
|
|
persist(
|
||
|
|
(set) => ({
|
||
|
|
sortBy: 'tier',
|
||
|
|
sortDirection: 'descending',
|
||
|
|
}),
|
||
|
|
{ name: 'tankopedia' },
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
|
||
|
|
export default function mutateTankopedia(recipe: (draft: Tankopedia) => void) {
|
||
|
|
useTankopedia.setState(produce(recipe));
|
||
|
|
}
|