feat: session persistance

This commit is contained in:
TresAbhi committed 2023-09-19 15:52:39 +00:00
1 parent 57f6e928b7
commit 018783bb47
12 files changed
+121 -29

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
import { create } from 'zustand';
import { devtools, persist } from 'zustand/middleware';
import { Region } from '../constants/regions';
import { NormalizedTankStats } from '../types/tanksStats';
type Session =
| {
isTracking: false;
}
| {
isTracking: true;
region: Region;
id: number;
nickname: string;
tankStats: NormalizedTankStats;
};
export const useSession = create<Session>()(
devtools(persist((set) => ({ isTracking: false }), { name: 'session' })),
);