File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -239,10 +239,14 @@ export default createStore({
239239 const index = state . todos . findIndex (
240240 ( todo : { newId : number } ) => todo . newId === payload
241241 ) ;
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 ) {
242+ let deleteTask ;
243+ if ( ! state . todos [ index ] . completed ) {
244+ //don't ask for confirmation when one-time task is completed
245+ deleteTask = confirm (
246+ `Do you want to delete the task ${ state . todos [ index ] . task } ?\nThis action cannot be undone.`
247+ ) as boolean ; //ask user to confirm task deletion
248+ }
249+ if ( deleteTask || state . todos [ index ] . completed ) {
246250 state . todos . splice ( index , 1 ) ; //delete task item
247251 }
248252 } ,
You can’t perform that action at this time.
0 commit comments