This commit is contained in:
PxlLoewe
2025-04-21 15:07:56 -07:00
11 changed files with 513 additions and 75 deletions

View File

@@ -58,6 +58,13 @@ interface MapStore {
aircraftId: string,
tab: MapStore["aircraftTabs"][string],
) => void;
missionTabs: {
[missionId: string]: "home" | "details" | "chat";
};
setMissionTab: (
missionId: string,
tab: MapStore["missionTabs"][string],
) => void;
}
export const useMapStore = create<MapStore>((set, get) => ({
@@ -106,4 +113,12 @@ export const useMapStore = create<MapStore>((set, get) => ({
[aircraftId]: tab,
},
})),
missionTabs: {},
setMissionTab: (missionId, tab) =>
set((state) => ({
missionTabs: {
...state.missionTabs,
[missionId]: tab,
},
})),
}));

View File

@@ -6,6 +6,7 @@ interface MissionStore {
missions: MissionOptionalDefaults[];
setMissions: (missions: MissionOptionalDefaults[]) => void;
getMissions: () => Promise<undefined>;
setMission: (mission: MissionOptionalDefaults) => void;
}
export const useMissionsStore = create<MissionStore>((set) => ({
@@ -47,4 +48,17 @@ export const useMissionsStore = create<MissionStore>((set) => ({
set({ missions: data });
return undefined;
},
setMission: (mission) =>
set((state) => {
const existingMissionIndex = state.missions.findIndex(
(m) => m.id === mission.id,
);
if (existingMissionIndex !== -1) {
const updatedMissions = [...state.missions];
updatedMissions[existingMissionIndex] = mission;
return { missions: updatedMissions };
} else {
return { missions: [...state.missions, mission] };
}
}),
}));

View File

@@ -7,6 +7,6 @@ interface PannelStore {
}
export const usePannelStore = create<PannelStore>((set) => ({
isOpen: false,
isOpen: true, // DEBUG, REMOVE LATER FOR PROD
setOpen: (isOpen) => set({ isOpen }),
}));