blob: 5044d90dabc02322a4af2eb348a56f98e2d85b47 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
"use client"
import * as React from "react"
import { type Table } from "@tanstack/react-table"
import { DocumentClassOptionAddDialog } from "./document-class-option-add-dialog"
import { DeleteDocumentClassOptionDialog } from "./delete-document-class-option-dialog"
import { documentClasses, documentClassOptions } from "@/db/schema/documentClasses"
interface DocumentClassOptionsTableToolbarActionsProps<TData> {
table: Table<TData>
selectedDocumentClass: typeof documentClasses.$inferSelect | null
onSuccess?: () => void
}
export function DocumentClassOptionsTableToolbarActions<TData>({
table,
selectedDocumentClass,
onSuccess,
}: DocumentClassOptionsTableToolbarActionsProps<TData>) {
const selectedRows = table.getFilteredSelectedRowModel().rows
const selectedOptions = selectedRows.map((row) => row.original as typeof documentClassOptions.$inferSelect)
return (
<div className="flex items-center gap-2">
{/** 선택된 로우가 있으면 삭제 다이얼로그 */}
{selectedOptions.length > 0 ? (
<DeleteDocumentClassOptionDialog
options={selectedOptions}
onSuccess={() => {
table.toggleAllRowsSelected(false)
onSuccess?.()
}}
/>
) : null}
<DocumentClassOptionAddDialog
selectedDocumentClass={selectedDocumentClass}
onSuccess={onSuccess}
/>
</div>
)
}
|