"use client";

import { Trash2 } from "lucide-react";
import { Button } from "@/components/ui/button";

interface DeleteButtonProps {
  action: () => Promise<void>;
  label?: string;
}

export function DeleteButton({ action, label = "刪除" }: DeleteButtonProps) {
  return (
    <form
      action={async () => {
        if (confirm("確定要刪除嗎？此操作無法復原。")) {
          await action();
        }
      }}
    >
      <Button type="submit" variant="destructive" size="sm">
        <Trash2 className="size-3.5" />
        {label}
      </Button>
    </form>
  );
}