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
| Param | Type | Description |
|---|---|---|
entity | Entity | Current entity object |
config | ActionConfig[] | Full action config array |
permissions | string[] | 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.
Related
Last updated on