import { Project } from "@/app/main/planning/projects/types/project";
import { ProjectCardProps } from "@/app/main/planning/projects/projectCard/projectCard";

/* Backend enum (API contract) */
type BackendProjectStatus =
  | "ACTIVE"
  | "COMPLETED"
  | "ON_HOLD"
  | "AT_RISK";

/* Optional: convert backend enum to readable label */
const statusLabelMap: Record<BackendProjectStatus, string> = {
  ACTIVE: "Ongoing",
  COMPLETED: "Completed",
  ON_HOLD: "On Hold",
  AT_RISK: "At Risk",
};

export function mapProjectToCard(
  project: Omit<Project, "projectStatus"> & {
    projectStatus: BackendProjectStatus;
  }
): ProjectCardProps {

  return {
    projectIdentifier: project.projectIdentifier,
    projectName: project.projectName,
    projectDescription: project.projectDescription ?? "",
    projectStatus: statusLabelMap[project.projectStatus] ?? "Ongoing",
    productType: project.productType ?? "N/A",
    contractedStartDate: project.contractedStartDate ,
    contractedEndDate: project.contractedEndDate,
    projectClient:project.projectClient,
    projectManager:project.projectManager
  };
}
