fix(leaderboard): fix leaderboard scheme for questions and streaks
This commit is contained in:
@ -3,9 +3,15 @@ import { create } from "zustand";
|
||||
import { persist } from "zustand/middleware";
|
||||
import type { StartExamPayload, ExamMode } from "../types/test";
|
||||
|
||||
type UserMetrics = {
|
||||
xp: number;
|
||||
questions: number;
|
||||
streak: number;
|
||||
};
|
||||
|
||||
interface ExamConfigState {
|
||||
payload: StartExamPayload | null;
|
||||
userXp: number;
|
||||
userMetrics: UserMetrics;
|
||||
|
||||
setSheetId: (id: string) => void;
|
||||
storeTopics: (ids: string[]) => void;
|
||||
@ -15,7 +21,7 @@ interface ExamConfigState {
|
||||
storeDuration: (minutes: number) => void;
|
||||
setMode: (mode: ExamMode) => void;
|
||||
setSection: (section: string) => void;
|
||||
setUserXp: (section: number) => void;
|
||||
setUserMetrics: (userMetrics: UserMetrics) => void;
|
||||
|
||||
clearPayload: () => void;
|
||||
}
|
||||
@ -24,7 +30,11 @@ export const useExamConfigStore = create<ExamConfigState>()(
|
||||
persist(
|
||||
(set, get) => ({
|
||||
payload: null,
|
||||
userXp: 0,
|
||||
userMetrics: {
|
||||
xp: 0,
|
||||
questions: 0,
|
||||
streak: 0,
|
||||
},
|
||||
|
||||
setSheetId: (sheet_id) =>
|
||||
set({
|
||||
@ -48,9 +58,9 @@ export const useExamConfigStore = create<ExamConfigState>()(
|
||||
section,
|
||||
} as StartExamPayload,
|
||||
}),
|
||||
setUserXp: (userXp) =>
|
||||
setUserMetrics: (userMetrics) =>
|
||||
set({
|
||||
userXp: userXp,
|
||||
userMetrics: userMetrics,
|
||||
}),
|
||||
|
||||
setDifficulty: (difficulty) =>
|
||||
|
||||
Reference in New Issue
Block a user