Skip to Content
FrontendBundlesCRUDHooksuseActionButtons

useActionButtons

useActionButtons computes the final list of action buttons to render, applying permission checks, showWhen conditions, and entity state rules.


Import

import { useActionButtons } from "@phpcreation/frontend-crud-react-nextjs-bundle/hooks/useActionButtons";

Usage

import { useActionButtons } from "..."; function EntityActions({ entity, actionConfig }) { const actions = useActionButtons({ entity, config: actionConfig, }); return ( <div> {actions.map((action) => ( <Button key={action.key} onClick={action.onClick}> {action.label} </Button> ))} </div> ); }

Parameters

ParamTypeDescription
entityEntityCurrent entity object
configActionConfig[]Full action config array
permissionsstring[]User permissions (auto-read from AuthContext)

Returns

A filtered, ordered array of resolved actions with computed onClick, disabled, and visible states.

DetailActions and ListingTable row actions both use this hook internally. Use it directly only when building custom action UIs.


Last updated on