blob: d2d9efb47f79af9fa77053dd04b44f444dd72dcc (
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
|
"use client"
import * as React from "react"
import { type Table } from "@tanstack/react-table"
import { DeleteCodeGroupsDialog } from "./delete-code-groups-dialog"
import { CodeGroupsAddDialog } from "./code-groups-add-dialog"
import { codeGroups } from "@/db/schema/codeGroups"
interface CodeGroupsTableToolbarActionsProps<TData> {
table: Table<TData>
onSuccess?: () => void
}
export function CodeGroupsTableToolbarActions<TData>({
table,
onSuccess,
}: CodeGroupsTableToolbarActionsProps<TData>) {
const selectedRows = table.getFilteredSelectedRowModel().rows
const selectedCodeGroups = selectedRows.map((row) => row.original as typeof codeGroups.$inferSelect)
return (
<div className="flex items-center gap-2">
{/** 1) 선택된 로우가 있으면 삭제 다이얼로그 */}
{selectedCodeGroups.length > 0 ? (
<DeleteCodeGroupsDialog
codeGroups={selectedCodeGroups}
onSuccess={() => {
table.toggleAllRowsSelected(false)
onSuccess?.()
}}
/>
) : null}
<CodeGroupsAddDialog onSuccess={onSuccess} />
</div>
)
}
|