mirror of
https://github.com/bendtherules/demo-trello-app.git
synced 2026-08-18 13:42:40 +00:00
Redux - Add editTask and editList
This commit is contained in:
@@ -50,6 +50,14 @@ export const slice = createSlice({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
editList: (state, action) => {
|
||||||
|
const { name, listID } = action.payload;
|
||||||
|
|
||||||
|
const existingList = state.lists.find(({ id }) => id === listID);
|
||||||
|
|
||||||
|
existingList.name = name;
|
||||||
|
},
|
||||||
|
|
||||||
createTask: (state, action) => {
|
createTask: (state, action) => {
|
||||||
const { text: cardText, listID: parentListID } = action.payload;
|
const { text: cardText, listID: parentListID } = action.payload;
|
||||||
|
|
||||||
@@ -58,10 +66,19 @@ export const slice = createSlice({
|
|||||||
id: `Card #${generateID()}`,
|
id: `Card #${generateID()}`,
|
||||||
text: cardText
|
text: cardText
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
editTask: (state, action) => {
|
||||||
|
const { text: cardText, cardID, listID: parentListID } = action.payload;
|
||||||
|
|
||||||
|
const parentList = state.lists.find(({ id }) => id === parentListID);
|
||||||
|
const existingCard = parentList.find(({ id }) => id === cardID);
|
||||||
|
|
||||||
|
existingCard.text = cardText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const { createList, createTask } = slice.actions;
|
export const { createList, createTask, editList, editTask } = slice.actions;
|
||||||
|
|
||||||
export default slice.reducer;
|
export default slice.reducer;
|
||||||
|
|||||||
Reference in New Issue
Block a user