Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wellsousaaa
GitHub Repository: wellsousaaa/Five-Nights-at-Freddys-Web
Path: blob/main/src/reducers/officeReducer.js
270 views
1
const originalState = {
2
leftDoor: false,
3
rightDoor: false,
4
leftLight: false,
5
rightLight: false,
6
};
7
8
export default function office(state = originalState, action) {
9
switch (action.type) {
10
case "CHANGE_OFFICE_CONFIG":
11
if (action.obj === "leftLight" && state.leftDoor) return state;
12
if (action.obj === "rightLight" && state.rightDoor) return state;
13
14
if (action.obj === "leftDoor" && !state.leftDoor && state.leftLight)
15
return { ...state, leftLight: false, leftDoor: true };
16
if (
17
action.obj === "rightDoor" &&
18
!state.rightDoor &&
19
state.rightLight
20
)
21
return { ...state, rightLight: false, rightDoor: true };
22
state[action.obj] = !state[action.obj];
23
return state;
24
25
case "CLEAR_DATA":
26
return { ...originalState };
27
28
default:
29
return state;
30
}
31
}
32
33