import React, { FC } from "react"; import Button from "@calcom/ui/Button"; import Dropdown, { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@calcom/ui/Dropdown"; import { Icon } from "@calcom/ui/Icon"; import { SVGComponent } from "@lib/types/SVGComponent"; export type ActionType = { id: string; icon?: SVGComponent; iconClassName?: string; label: string; disabled?: boolean; color?: "primary" | "secondary"; } & ( | { href: string; onClick?: never; actions?: never } | { href?: never; onClick: (e: React.MouseEvent) => void; actions?: never } | { actions?: ActionType[]; href?: never; onClick?: never } ); interface Props { actions: ActionType[]; } const defaultAction = (e: React.MouseEvent) => { e.stopPropagation(); }; const DropdownActions = ({ actions, actionTrigger, }: { actions: ActionType[]; actionTrigger?: React.ReactNode; }) => { return ( {!actionTrigger ? ( ))} ); }; const TableActions: FC = ({ actions }) => { const mobileActions = actions.flatMap((action) => { if (action.actions) { return action.actions; } return action; }); return ( <>
{actions.map((action) => { const button = ( ); if (!action.actions) { return button; } return ; })}
); }; export default TableActions;