import type { Row } from "@tanstack/react-table" import { ActionMenu, type ActionMenuItem, type ActionMenuProps, } from "@/components/actions/action-menu" export type DataTableRowAction = Omit & { onSelect?: (row: Row, original: TData) => void | Promise } export type DataTableRowActionsProps = Omit & { row: Row actions?: DataTableRowAction[] getActions?: (row: Row, original: TData) => DataTableRowAction[] } function resolveRowActions( row: Row, actions?: DataTableRowAction[], getActions?: (row: Row, original: TData) => DataTableRowAction[] ): ActionMenuItem[] { const resolvedActions = getActions?.(row, row.original) ?? actions ?? [] return resolvedActions.map((action) => ({ ...action, onSelect: action.onSelect ? () => action.onSelect?.(row, row.original) : undefined, })) } function DataTableRowActions({ row, actions, getActions, ...props }: DataTableRowActionsProps) { return ( ) } export { DataTableRowActions, resolveRowActions }