import {
  type ReviewCycle,
  ReviewDirection,
} from 'src/pages/dashboard/performance/types';

export type FinalSelectionUser = {
  id: number;
  firstName: string;
  lastName: string;
  profilePicture?: string | null;
  userId: number;
  isExternal?: boolean;
};

export const hasSelectReviewType = (
  cycle: ReviewCycle | undefined,
  type: ReviewDirection,
) => {
  if (!cycle) return false;

  const hasFormTemplate = cycle.formTemplates?.some(
    f => f?.evaluationType === type,
  );

  if (!hasFormTemplate) return false;

  switch (type) {
    case ReviewDirection.PEER_REVIEW:
      return cycle?.peerReviewReviewerSelectionVisibleForBosses;
    case ReviewDirection.PEER_EXTERNAL_REVIEW:
      return cycle?.peerReviewExternalReviewerSelectionVisibleForBosses;
    case ReviewDirection.OTHERS_REVIEW:
      return cycle?.othersReviewReviewerSelectionVisibleForBosses;
    default:
      return false;
  }
};
