Up to date CRA Started by Patrick Fic

This commit is contained in:
Patrick Fic
2020-09-29 14:06:16 -07:00
commit cc82bcc810
34 changed files with 13681 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
import ApplicationActionTypes from "./application.types";
import _ from "lodash";
const INITIAL_STATE = {
rooms: [],
images: {
id: [],
},
};
const applicationReducer = (state = INITIAL_STATE, action) => {
switch (action.type) {
case ApplicationActionTypes.SET_ROOMS:
return {
...state,
rooms: _.unionBy(state.rooms, action.payload, "id"),
};
case ApplicationActionTypes.ADD_ROOM:
return {
...state,
rooms: _.unionBy(state.rooms, [action.payload], "id"),
};
case ApplicationActionTypes.ADD_IMAGES_TO_ROOM:
return {
...state,
images: {
...state.images,
[action.payload.roomId]: _.unionBy(
state.images[action.payload.roomId] || [],
action.payload.images,
"filename"
),
},
};
case ApplicationActionTypes.REMOVE_ROOM:
return {
...state,
rooms: state.rooms.filter((r) => r.id !== action.payload),
};
case ApplicationActionTypes.MARK_ROOM_NA:
return {
...state,
rooms: state.rooms.map((room) =>
room.id === action.payload ? { ...room, na: true } : room
),
};
default:
return state;
}
};
export default applicationReducer;