import { ReturnProcessQuestionKey } from './return-process-question-key';
import { ReturnProcessQuestionType } from './return-process-question-type';
import { ReturnInfo } from './return-info';

export interface ReturnProcessQuestionBase {
  key: ReturnProcessQuestionKey;
  description: string;
  type: ReturnProcessQuestionType;
}

export interface ReturnProcessQuestionOptions {
  label: string;
  value: string;
}

export interface ReturnProcessChecklistQuestion
  extends ReturnProcessQuestionBase {
  type: typeof ReturnProcessQuestionType.Checklist;
  options: ReturnProcessChecklistQuestionOptions[];
  other?: {
    label: string;
    value?: string;
  };
  nextQuestion?: ReturnProcessQuestionKey;
}

export type ReturnProcessChecklistQuestionOptions =
  ReturnProcessQuestionOptions;

export interface ReturnProcessSelectQuestion extends ReturnProcessQuestionBase {
  type: typeof ReturnProcessQuestionType.Select;
  options: ReturnProcessQuestionSelectOptions[];
}

export interface ReturnProcessQuestionSelectOptions
  extends ReturnProcessQuestionOptions {
  label: string;
  value: string;
  returnInfo?: ReturnInfo;
  nextQuestion?: ReturnProcessQuestionKey;
}

export interface ReturnProcessProductQuestion
  extends ReturnProcessQuestionBase {
  type: typeof ReturnProcessQuestionType.Product;
  nextQuestion?: ReturnProcessQuestionKey;
}

export interface ReturnProcessGroupQuestion
  extends Omit<ReturnProcessQuestionBase, 'description'> {
  type: typeof ReturnProcessQuestionType.Group;
  questions: ReturnProcessQuestion[];
}

export interface ReturnProcessInfoQuestion extends ReturnProcessQuestionBase {
  type: typeof ReturnProcessQuestionType.Info;
  content: string[];
  nextQuestion?: ReturnProcessQuestionKey;
}

export type ReturnProcessQuestion =
  | ReturnProcessSelectQuestion
  | ReturnProcessProductQuestion
  | ReturnProcessChecklistQuestion
  | ReturnProcessGroupQuestion
  | ReturnProcessInfoQuestion;
