import {
  ManagerSurvey,
  QuestionTemplateType,
  Topic,
} from '../../../../../../types';

export const SELECT_QUESTION_TYPE = 'SELECT' as const;
export type SelectQuestionType = typeof SELECT_QUESTION_TYPE;

export type QuestionsTableProps = {
  surveyId: ManagerSurvey['id'];
  onScrollToTop: () => void;
  dimensionId?: Topic['id'];
};

type ParsedQuestionStatsBase = {
  id: number;
  statement: string;
  topicLabel: string;
  answersLabel: string;
  answersAmount: number;
  commentsAmount: number;
  hasThresholdPassed: boolean;
  commentsLabel: string;
  typeLabel: string;
  scoreDifference: number | null;
  baseScore: number | null;
};

export type ParsedLikertQuestionStats = ParsedQuestionStatsBase & {
  score: number;
  type: QuestionTemplateType.LIKERT;
  promoters: number;
  detractors: number;
  neutrals: number;
};

export type ParsedTextQuestionStats = ParsedQuestionStatsBase & {
  score: null;
  type: QuestionTemplateType.TEXT;
};

export type ParsedSelectQuestionStats = ParsedQuestionStatsBase & {
  score: null;
  type: SelectQuestionType;
  answer: string;
  scorePercentage: number;
};

export type ParsedQuestionStats =
  | ParsedLikertQuestionStats
  | ParsedTextQuestionStats
  | ParsedSelectQuestionStats;
