Openstatus
www.openstatus.dev
1import { Trash2 } from "lucide-react";
2
3export const actions = [
4 {
5 id: "delete",
6 label: "Delete",
7 icon: Trash2,
8 variant: "destructive" as const,
9 },
10] as const;
11
12export type PageComponentAction = (typeof actions)[number];
13
14export const getActions = (
15 props: Partial<Record<PageComponentAction["id"], () => Promise<void> | void>>,
16): (PageComponentAction & { onClick?: () => Promise<void> | void })[] => {
17 return actions.map((action) => ({
18 ...action,
19 onClick: props[action.id as keyof typeof props],
20 }));
21};