Mission Popup WIP

This commit is contained in:
nocnico
2025-04-21 23:57:18 +02:00
parent 391d216374
commit 1329e6b5e9
4 changed files with 154 additions and 22 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

@@ -4,6 +4,7 @@ import { create } from "zustand";
interface MissionStore {
missions: MissionOptionalDefaults[];
setMissions: (missions: MissionOptionalDefaults[]) => void;
setMission: (mission: MissionOptionalDefaults) => void;
}
export const useMissionsStore = create<MissionStore>((set) => ({
@@ -24,4 +25,17 @@ export const useMissionsStore = create<MissionStore>((set) => ({
},
],
setMissions: (missions) => set({ missions }),
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] };
}
}),
}));