"use client" import * as React from "react" import type { Table } from "@tanstack/react-table" import { Plus, Trash2 } from "lucide-react" import { toast } from "sonner" import { Button } from "@/components/ui/button" import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip" import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@/components/ui/alert-dialog" import type { TechVendorPossibleItem } from "../validations" import { deleteTechVendorPossibleItemsNew } from "../service" interface PossibleItemsTableToolbarActionsProps { table: Table vendorId: number onAdd: () => void // 주석처리 } export function PossibleItemsTableToolbarActions({ table, vendorId, onAdd, // 주석처리 }: PossibleItemsTableToolbarActionsProps) { const [showDeleteAlert, setShowDeleteAlert] = React.useState(false) const [isDeleting, setIsDeleting] = React.useState(false) const selectedRows = table.getFilteredSelectedRowModel().rows async function handleDelete() { setIsDeleting(true) try { const ids = selectedRows.map((row) => row.original.id) const { error } = await deleteTechVendorPossibleItemsNew(ids, vendorId) if (error) { throw new Error(error) } toast.success(`${ids.length}개의 아이템이 삭제되었습니다`) table.resetRowSelection() setShowDeleteAlert(false) } catch { toast.error("아이템 삭제 중 오류가 발생했습니다") } finally { setIsDeleting(false) } } return ( <>
{/* 아이템 추가 버튼 주석처리 */} {selectedRows.length > 0 && ( <> 선택된 {selectedRows.length}개 아이템을 삭제합니다 )}
아이템 삭제 선택된 {selectedRows.length}개의 아이템을 삭제하시겠습니까? 이 작업은 되돌릴 수 없습니다. 취소 {isDeleting ? "삭제 중..." : "삭제"} ) }