2023-12-03 19:45:43 -06:00
|
|
|
import { produce } from 'immer';
|
|
|
|
|
import { create } from 'zustand';
|
|
|
|
|
import { devtools, persist } from 'zustand/middleware';
|
|
|
|
|
|
2023-12-04 10:25:54 -06:00
|
|
|
export type TankopediaSortBy = 'tier' | 'name';
|
2023-12-03 19:45:43 -06:00
|
|
|
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));
|
|
|
|
|
}
|