"use client"; import { Button } from "@azmr/ui/button"; import { toast } from "@azmr/ui/toast"; import { useState } from "react"; export default function ToastActions() { const [items, setItems] = useState(["Quarterly report", "Team photo"]); function remove(name: string) { setItems((all) => all.filter((n) => n !== name)); toast(`Deleted “${name}”`, { // The same id replaces the toast instead of stacking another. id: `deleted-${name}`, action: { label: "Undo", onClick: () => setItems((all) => (all.includes(name) ? all : [...all, name])), }, }); } return (
); }