import React, { FC } from "react"; import { SVGComponent } from "@calcom/types/SVGComponent"; import { Icon } from "@calcom/ui/Icon"; import Button from "@calcom/ui/v2/core/Button"; import { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, DropdownMenuPortal, } from "@calcom/ui/v2/core/Dropdown"; import Dropdown from "@calcom/ui/v2/core/Dropdown"; 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;