mirror of
https://github.com/pawelmalak/flame.git
synced 2025-08-07 03:35:18 +02:00
Updating categories using form
This commit is contained in:
parent
0f2125e720
commit
216c12a33c
11 changed files with 176 additions and 30 deletions
|
@ -78,6 +78,20 @@ const deleteCategory = (state: State, action: Action): State => {
|
|||
}
|
||||
}
|
||||
|
||||
const updateCategory = (state: State, action: Action): State => {
|
||||
const tmpCategories = [...state.categories];
|
||||
const categoryInUpdate = tmpCategories.find((category: Category) => category.id === action.payload.id);
|
||||
|
||||
if (categoryInUpdate) {
|
||||
categoryInUpdate.name = action.payload.name;
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
categories: tmpCategories
|
||||
}
|
||||
}
|
||||
|
||||
const bookmarkReducer = (state = initialState, action: Action) => {
|
||||
switch (action.type) {
|
||||
case ActionTypes.getCategories: return getCategories(state, action);
|
||||
|
@ -86,6 +100,7 @@ const bookmarkReducer = (state = initialState, action: Action) => {
|
|||
case ActionTypes.addBookmark: return addBookmark(state, action);
|
||||
case ActionTypes.pinCategory: return pinCategory(state, action);
|
||||
case ActionTypes.deleteCategory: return deleteCategory(state, action);
|
||||
case ActionTypes.updateCategory: return updateCategory(state, action);
|
||||
default: return state;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue