chore(build): refactor codebase for production

This commit is contained in:
shafin-r
2026-03-12 02:39:34 +06:00
parent 121cc2bf71
commit bd35f6a852
123 changed files with 3501 additions and 3254 deletions

View File

@ -16,6 +16,7 @@ interface AuthState {
registrationMessage: string | null;
login: (credentials: LoginRequest) => Promise<boolean>;
register: (credentials: RegistrationRequest) => Promise<boolean>;
fetchUser: () => Promise<void>;
logout: () => void;
clearError: () => void;
}
@ -85,6 +86,18 @@ export const useAuthStore = create<AuthState>()(
}
},
fetchUser: async () => {
const token = useAuthStore.getState().token;
if (!token) return;
try {
const user = await api.fetchUser(token);
set({ user });
} catch (error) {
console.error("Failed to refresh user:", error);
}
},
logout: () => {
set({
user: null,

View File

@ -54,7 +54,7 @@ export const useInventoryStore = create<InventoryStore>()(
lastActivatedId: itemId,
}),
activateItemError: (itemId, error) => set({ activatingId: null, error }),
activateItemError: (error) => set({ activatingId: null, error }),
clearLastActivated: () => set({ lastActivatedId: null }),

View File

@ -2,7 +2,6 @@ import { create } from "zustand";
import { persist, createJSONStorage } from "zustand/middleware";
import type { QuestArc, QuestNode } from "../types/quest";
import { CREW_RANKS } from "../types/quest";
import { QUEST_ARCS } from "../data/questData";
// ─── Types ────────────────────────────────────────────────────────────────────
@ -58,8 +57,8 @@ interface QuestStore {
export const useQuestStore = create<QuestStore>()(
persist(
(set) => ({
arcs: QUEST_ARCS,
activeArcId: QUEST_ARCS[0].id,
arcs: [],
activeArcId: "",
earnedXP: 0,
earnedTitles: [],

View File

@ -81,7 +81,7 @@ export const useSatExam = create<SatExamState>()(
startBreak: () => {
const endTime = Date.now() + BREAK_DURATION * 1000;
set((state) => ({
set(() => ({
phase: "BREAK",
endTime,
questionIndex: 0, // optional: reset question index for next module UX