Skip to content

Commit 7c584c6

Browse files
author
Jez
committed
Merge PR ifindev#22: Replace alert() with toast in toggle-complete
2 parents dd5e7a6 + f355e68 commit 7c584c6

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)