Skip to content
This repository was archived by the owner on Dec 23, 2025. It is now read-only.

Commit f355e68

Browse files
author
Jez
committed
fix: replace alert() with toast in toggle-complete component
- Import react-hot-toast for consistent error feedback - Replace alert() with toast.error() on line 35 - Simplify error message to match other components - Consistent with PR ifindev#14 (delete-todo.tsx) Provides professional, non-blocking error notifications when toggling todo completion fails.
1 parent a44687a commit f355e68

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/modules/todos/components/toggle-complete.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { useState, useTransition } from "react";
4+
import toast from "react-hot-toast";
45
import { Checkbox } from "@/components/ui/checkbox";
56
import { updateTodoFieldAction } from "../actions/update-todo.action";
67

@@ -31,8 +32,8 @@ export function ToggleComplete({ todoId, completed }: ToggleCompleteProps) {
3132
console.error("Error updating todo:", error);
3233
// Revert the optimistic update
3334
setIsCompleted(!checked);
34-
alert(
35-
`Error updating todo: ${error instanceof Error ? error.message : "Unknown error"}`,
35+
toast.error(
36+
error instanceof Error ? error.message : "Failed to update todo",
3637
);
3738
}
3839
});

0 commit comments

Comments
 (0)