"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 };
type FormCardActionsProps = {
deleteField?: Action | null;
duplicateField?: Action | null;
};
const FormCardActions = ({ deleteField, duplicateField }: FormCardActionsProps) => {
type ActionItem = {
label: string;
icon: IconName;
onClick: () => void;
color?: "destructive" | "minimal";
};
const actions: ActionItem[] = [
duplicateField?.fn && {
label: "Duplicate",
icon: "copy",
onClick: () => duplicateField.fn(),
},
deleteField?.fn && {
label: "Delete",
icon: "trash",
color: "minimal",
onClick: () => deleteField.fn(),
},
].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 (