Skip to content

Commit

Permalink
Create the action: LeaveMission to change the reserved status to fals…
Browse files Browse the repository at this point in the history
…e on a mission item
  • Loading branch information
Kidd254 committed Jul 25, 2023
1 parent 08abfed commit 81ad66c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/redux/missions/missionsSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ const missionsSlice = createSlice({
});
state.missions = newMissionState;
},
LeaveMission: (state, action) => {
const newMissionState = state.missions.map((mission) => {
if (mission.mission_id === action.payload) {
return { ...mission, reserved: false };
}
return mission;
});
state.missions = newMissionState;
},
},
extraReducers: (builder) => {
builder
Expand Down Expand Up @@ -60,5 +69,5 @@ const missionsSlice = createSlice({
},
});

export const { addReservedMission } = missionsSlice.actions;
export const { addReservedMission, LeaveMission } = missionsSlice.actions;
export default missionsSlice.reducer;

0 comments on commit 81ad66c

Please sign in to comment.