import { Archive, Copy, Flag, Pencil, Star } from "lucide-react";

import { RowMenu, type RowMenuItem } from "../../pages/manage/_shared";
import type { Project } from "../../types";

interface ProjectRowMenuProps {
  project: Project;
  onEditDetails: () => void;
  onMilestones: () => void;
  onToggleTentative: () => void;
  onArchive: () => void;
  onRestore?: () => void;
}

export function ProjectRowMenu({
  project,
  onEditDetails,
  onMilestones,
  onToggleTentative,
  onArchive,
  onRestore,
}: ProjectRowMenuProps) {
  const items: RowMenuItem[] = [
    { label: "Edit Details", icon: Pencil, onClick: onEditDetails },
    { label: "Milestones", icon: Flag, onClick: onMilestones },
    {
      label: project.is_tentative ? "Set Confirmed" : "Set Tentative",
      icon: Star,
      onClick: onToggleTentative,
    },
    {
      label: "Duplicate",
      icon: Copy,
      onClick: () => window.alert("Duplicate is not available yet."),
    },
    project.is_active
      ? { label: "Archive", icon: Archive, danger: true, onClick: onArchive }
      : { label: "Restore", icon: Archive, onClick: onRestore ?? (() => undefined) },
  ];

  return <RowMenu items={items} />;
}
