import type { RouterOutputs } from "@openstatus/api"; import { Settings, Delete } from "@openstatus/icons"; export const actions = [ { id: "edit", label: "Settings", icon: Settings, variant: "default" as const, }, { id: "delete", label: "Delete", icon: Delete, variant: "destructive" as const, }, ] as const; export type MaintenanceAction = (typeof actions)[number]; export const getActions = ( props: Partial Promise | void>>, ): (MaintenanceAction & { onClick?: () => Promise | void })[] => { return actions.map((action) => ({ ...action, onClick: props[action.id as keyof typeof props], })); }; type Maintenance = NonNullable; /** `maintenance.update` requires every field: start from the current row. */ export function toUpdateInput(maintenance: Maintenance) { return { id: maintenance.id, title: maintenance.title, startDate: maintenance.from, endDate: maintenance.to, pageComponents: maintenance.pageComponentIds, }; }