import React from 'react'; 
import type { ReviewQuestionElement } from '@/types/curriculum.type';
import ReviewQuestionRadio from './review-question-radio';
import ReviewQuestionText from './review-question-text';
import ReviewQuestionSatisfactionOption from './review-question-satisfaction-option';
import ReviewQuestionSatisfactionText from './review-question-satisfaction-text';

interface ReviewQuestionBodyProps {
  question: ReviewQuestionElement;
  answer: string;
  error?: string;
  onChange: (value: string) => void;
}

function ReviewQuestionBody(props: ReviewQuestionBodyProps): React.ReactNode {
  const { question, answer, error, onChange } = props;
  
  if (question.type === 'question_radio') {
    return (
      <ReviewQuestionRadio
        answer={answer}
        error={error}
        onChange={onChange}
        question={question}
      />
    );
  }
  if (question.type === 'question_text') {
    return (
      <ReviewQuestionText
        answer={answer}
        error={error}
        onChange={onChange}
        question={question}
      />
    );
  }
  if (question.type === 'question_satisfaction_option') {
    return (
      <ReviewQuestionSatisfactionOption
        answer={answer}
        error={error}
        onChange={onChange}
        question={question}
      />
    );
  }

  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- 그 외의 타입이 있을 경우 있음
  if (question.type === 'question_satisfaction_text') {
    return (
      <ReviewQuestionSatisfactionText
        answer={answer}
        error={error}
        onChange={onChange}
        question={question}
      />
    );
  }

  return null;
}
export default ReviewQuestionBody;
