Files
blitzkit/packages/website/src/stores/tierList.ts
T

28 lines
748 B
TypeScript
Raw Normal View History

2024-11-25 14:20:10 -06:00
import { enableMapSet } from 'immer';
2024-11-17 16:34:18 -06:00
import { create } from 'zustand';
import { subscribeWithSelector } from 'zustand/middleware';
import { tierListRows } from '../components/TierList/Table/constants';
import { createContextualStore } from '../core/zustand/createContextualStore';
export interface TierList {
dragging: boolean;
2024-11-26 20:44:44 -06:00
rows: { name: string; tanks: number[] }[];
2024-11-25 14:20:10 -06:00
placedTanks: Set<number>;
2024-11-17 16:34:18 -06:00
}
2024-11-25 14:20:10 -06:00
enableMapSet();
2024-11-26 20:44:44 -06:00
export const tierListInitialState: TierList = {
dragging: false,
rows: tierListRows.map((row) => ({
name: row.name,
tanks: [],
})),
placedTanks: new Set(),
};
2024-11-17 16:34:18 -06:00
export const TierList = createContextualStore(() =>
create<TierList>()(
2024-11-26 20:44:44 -06:00
subscribeWithSelector<TierList>(() => tierListInitialState),
2024-11-17 16:34:18 -06:00
),
);