Openstatus www.openstatus.dev
at main 27 lines 637 B view raw
1import { Pencil, Trash2 } from "lucide-react"; 2 3export const actions = [ 4 { 5 id: "edit", 6 label: "Edit", 7 icon: Pencil, 8 variant: "default" as const, 9 }, 10 { 11 id: "delete", 12 label: "Delete", 13 icon: Trash2, 14 variant: "destructive" as const, 15 }, 16] as const; 17 18export type MaintenanceAction = (typeof actions)[number]; 19 20export const getActions = ( 21 props: Partial<Record<MaintenanceAction["id"], () => Promise<void> | void>>, 22): (MaintenanceAction & { onClick?: () => Promise<void> | void })[] => { 23 return actions.map((action) => ({ 24 ...action, 25 onClick: props[action.id as keyof typeof props], 26 })); 27};