"use client";
import Link from "next/link";
import { useState } from "react";
import classNames from "@calcom/ui/classNames";
import type { BadgeProps } from "../badge";
import { Badge } from "../badge";
import { Button } from "../button";
import { Dropdown, DropdownMenuTrigger, DropdownMenuContent, DropdownItem } from "../dropdown";
import { Input } from "../form/inputs/TextField";
import { Icon } from "../icon";
import type { IconName } from "../icon";
type Action = { check: () => boolean; fn: () => void; color?: "destructive" | "minimal"; disabled?: boolean };
type FormCardActionsProps = {
deleteField?: Action | null;
duplicateField?: Action | null;
};
const FormCardActions = ({ deleteField, duplicateField }: FormCardActionsProps) => {
type ActionItem = {
label: string;
icon: IconName;
onClick: () => void;
color: "destructive" | "minimal";
disabled?: boolean;
};
const actions: ActionItem[] = [
duplicateField?.fn && {
label: "Duplicate",
icon: "copy",
onClick: () => duplicateField.fn(),
},
deleteField?.fn && {
label: "Delete",
icon: "trash",
onClick: () => deleteField.fn(),
color: deleteField.color ?? "minimal",
disabled: deleteField.disabled,
},
].filter((action): action is ActionItem => !!action);
if (actions.length === 0) return null;
// If only one action, show a single icon button
if (actions.length === 1) {
const action = actions[0];
return (
);
}
// If multiple actions, show dropdown
return (