Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solving issue #1082 #1084

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions frontend/src/reducers/taskReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,20 @@ export const task = (state = {
return { ...state, completed: true, error: action.error }

case UPDATE_TASK_REQUESTED:
return { ...state, completed: false }
return { ...state, completed: false };
case UPDATE_TASK_SUCCESS:
return { ...state, completed: true }
// Assuming the updated task data is provided in the action payload as 'task'
const updatedTaskData = action.task;
// Find the index of the task to be updated
const taskIndex = state.data.findIndex(t => t.id === updatedTaskData.id);
// Create a new array for tasks with the updated task data
Comment on lines +105 to +107
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're trying to find a task in a list of tasks, but this is a single task reducer, so it should have from the back-end the task updated, and I fixed for now on the back-end.

const newData = [...state.data];
if (taskIndex !== -1) {
newData[taskIndex] = { ...newData[taskIndex], ...updatedTaskData };
}
return { ...state, completed: true, data: newData };
case UPDATE_TASK_ERROR:
return { ...state, completed: true, error: action.error }
return { ...state, completed: true, error: action.error };
case CHANGE_TASK_TAB:
return { ...state, tab: action.tab }

Expand Down