feat: safe sort

This commit is contained in:
TrèsAbhi committed 2024-07-08 19:59:15 -05:00
1 parent 4d99e61bfb
commit f0fc23712a
13 files changed
+73 -65

No files matched your search

@@ -0,0 +1,21 @@
import { TankPerformanceSortType } from '.';
export const tankPerformanceSortTypeNames = {
winrate: 'Winrate',
players: 'Players (30d)',
battles: 'Battles (career)',
damage: 'Damage',
survival: 'Survival',
xp: 'XP',
kills: 'Kills',
spots: 'Spots',
accuracy: 'Accuracy',
shots: 'Shots',
hits: 'Hits',
damageRatio: 'Dmg. ratio',
damageTaken: 'Dmg. taken',
capturePoints: 'Cap points',
} as const;
export const tankPerformanceSortTypeNamesArray = Object.keys(
tankPerformanceSortTypeNames,
) as TankPerformanceSortType[];
+17
View File
@@ -0,0 +1,17 @@
'use client';
import { createNextSafeStore } from '../../core/zustand/createNextSafeStore';
import { tankPerformanceSortTypeNames } from './constants';
export type TankPerformanceSortType = keyof typeof tankPerformanceSortTypeNames;
export interface TankPerformanceSort {
type: TankPerformanceSortType;
direction: -1 | 1;
}
export const { Provider, use, useMutation, useStore } =
createNextSafeStore<TankPerformanceSort>({
type: 'winrate',
direction: -1,
});