import { PortfolioProjectStatus } from '@prisma/client';
import { ActionButton } from '@/src/types/common';
import { FaCheck, FaTimes, FaEdit, FaTrashAlt, FaRedo, FaEye, FaCommentDots } from 'react-icons/fa';
import { GetPortfolioProjectActionsProps } from '@/types/project';

export const getPortfolioProjectActions = ({
  project,
  isAuthor,
  approveProject,
  rejectProject,
  editProject,
  deleteProject,
  resubmitProject,
  viewFeedback,
  onViewDetails,
}: GetPortfolioProjectActionsProps): ActionButton[] => {
  const actions: ActionButton[] = [];

  if (isAuthor && project.status === PortfolioProjectStatus.PENDING) {
    actions.push({
      icon: <FaEye />,
      text: 'View Details',
      onClick: () => onViewDetails(project),
    });
    actions.push({
      icon: <FaCheck />,
      text: 'Approve',
      onClick: () => approveProject(project.id),
    });
    actions.push({
      icon: <FaTimes />,
      text: 'Reject',
      onClick: () => rejectProject(project),
    });
  }

  if (project.status === PortfolioProjectStatus.REJECTED && project.isOwner && project.message) {
    actions.push({
      icon: <FaCommentDots />,
      text: 'View Feedback',
      onClick: () => viewFeedback(project),
    });
  }

  if (project.status === PortfolioProjectStatus.REJECTED && project.isOwner) {
    actions.push({
      icon: <FaRedo />,
      text: 'Resubmit',
      onClick: () => resubmitProject(project.id),
    });
  }

  if (project.isOwner) {
    actions.push({
      icon: <FaEdit />,
      text: 'Edit',
      onClick: () => editProject(project),
    });
  }

  if (project.isOwner || project.status === PortfolioProjectStatus.APPROVED) {
    actions.push({
      icon: <FaTrashAlt />,
      text: 'Delete',
      onClick: () => deleteProject(project),
    });
  }

  return actions;
};
