"use client"; import { useTransition } from "react"; import { Loader2, BellRing } from "lucide-react"; import { toast } from "sonner"; import { Button } from "@/components/ui/button"; import { triggerAlertAction } from "./actions"; export function AlertButton({ assignmentId, }: { assignmentId: string; }) { const [isPending, startTransition] = useTransition(); const handleAlert = () => { if (!confirm("Bist du sicher? Dies löst den Notdienst-Alarm aus.")) return; startTransition(async () => { const result = await triggerAlertAction(assignmentId); if ("error" in result && result.error) { toast.error(result.error); } else { toast.success("Alarm erfolgreich ausgelöst. E-Mail wurde versendet."); } }); }; return ( ); }