Merge branch 'main' of https://github.com/VAR-Virtual-Air-Rescue/var-monorepo
This commit is contained in:
@@ -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,
|
||||
},
|
||||
})),
|
||||
}));
|
||||
|
||||
@@ -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] };
|
||||
}
|
||||
}),
|
||||
}));
|
||||
|
||||
@@ -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 }),
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user