Skip to content

Commit cfcf620

Browse files
committed
Add confirmation if user attempts to delete the task
1 parent 6bd191a commit cfcf620

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/store/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,12 @@ export default createStore({
239239
const index = state.todos.findIndex(
240240
(todo: { newId: number }) => todo.newId === payload
241241
);
242-
state.todos.splice(index, 1); //delete task item
242+
const deleteTask: boolean = confirm(
243+
`Do you want to delete the task ${state.todos[index].task}?\nThis action cannot be undone.`
244+
);
245+
if (deleteTask) {
246+
state.todos.splice(index, 1); //delete task item
247+
}
243248
},
244249
setUser: (state, user) => {
245250
state.user = user; //set user data

0 commit comments

Comments
 (0)