1
0
mirror of https://gitlab.com/ceda_ei/sonzai.git synced 2025-11-04 09:00:05 +01:00

Add ADD_SUBJECT and REMOVE_SUBJECT action creators and reducer.

This commit is contained in:
2020-03-16 20:20:48 +05:30
parent 4ddcabb62a
commit 0508970fa0
4 changed files with 57 additions and 4 deletions

View File

@@ -1,5 +1,14 @@
export default function subjects(state) {
import { v4 } from "react-native-uuid";
export default function subjects(state, action) {
if (typeof state === "undefined")
return [];
return state;
switch(action.type) {
case "ADD_SUBJECT":
return [ ...state, { name: action.subject, id: v4() } ];
case "REMOVE_SUBJECT":
return state.filter(item => item.id != action.id);
default:
return state;
}
}