Skip to content

Commit

Permalink
fixed edit tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
sandygudie committed Dec 18, 2023
1 parent 5d0f01c commit d63a393
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/components/Board/AddTask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default function AddTask({ handleClose, tasks }: Props) {
const active: IBoard = data.active;
const toast = useToast();


const [selectedColumn, setSelectedColumn] = useState<string | any>(
tasks
? active.columns.find((item: IColumn) =>
Expand All @@ -45,7 +46,6 @@ export default function AddTask({ handleClose, tasks }: Props) {

const addTaskHandler = (values: ITask) => {
values.status = selectedColumn;

const foundDuplicate = checkDuplicatedTask(values, active);
if (foundDuplicate === false) {
dispatch(addTask({ updatedTasks: values, position: 0 }));
Expand Down
1 change: 0 additions & 1 deletion src/components/Board/TaskDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export default function TaskDetails({
const updatedCheckedState = checkedState.map((item, index) =>
index === id ? !item : item
);

setCheckedState(updatedCheckedState);
dispatch(isCompletedToggle({ updatedCheckedState, id, tasks }));
}
Expand Down
8 changes: 4 additions & 4 deletions src/redux/boardSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const boardSlice = createSlice({
? item.columns.find((o: IColumn) =>
o.name === action.payload.status
? (o.tasks = o.tasks.filter(
(s: any) => s.title !== action.payload.title
(s: any) => s.id !== action.payload.id
))
: null
)
Expand All @@ -89,8 +89,8 @@ const boardSlice = createSlice({
item.name === state.active.name
? item.columns.find((o: IColumn) =>
o.name === action.payload.values.status
? o.tasks.find((s: ITask) =>
s.title === action.payload.tasks.title
? o.tasks.map((s: ITask) =>
s.id === action.payload.values.id
? ((s.title = action.payload.values.title),
(s.description = action.payload.values.description),
(s.status = action.payload.values.status),
Expand All @@ -111,7 +111,7 @@ const boardSlice = createSlice({
? item.columns.find((o: IColumn) =>
o.name === action.payload.tasks.status
? o.tasks.map((s: ITask) =>
s.title === action.payload.tasks.title
s.id === action.payload.tasks.id
? s.subtasks.map((t: ISubTask, i: number) =>
i === action.payload.id
? (t.isCompleted =
Expand Down

0 comments on commit d63a393

Please sign in to comment.