import { usePersonalityQuizWorkflow } from '@/business/personality/quizWorkflowHooks';
import { PersonalityQuizView } from '@/components/personality-quiz/PersonalityQuizView';
import type { QuizQuestion } from '@/shared/constants/personalityCatalog';

interface PersonalityQuizProps {
  readonly onViewDirectory: () => void;
  readonly onResult?: (code: string, answers: Record<number, string>) => void | Promise<void>;
  readonly savedType?: string | null;
  readonly savedAnswers?: Record<number, string> | null;
  readonly savedDate?: string | null;
  readonly isSaving?: boolean;
  readonly canPersistResult?: boolean;
  readonly questions?: readonly QuizQuestion[];
}

export default function PersonalityQuiz({
  onViewDirectory,
  onResult,
  savedType,
  savedAnswers,
  savedDate,
  isSaving = false,
  canPersistResult = true,
  questions,
}: PersonalityQuizProps) {
  const workflow = usePersonalityQuizWorkflow({
    onResult,
    savedType,
    savedAnswers,
    questions,
  });

  return (
    <PersonalityQuizView
      workflow={workflow}
      onViewDirectory={onViewDirectory}
      savedDate={savedDate}
      isSaving={isSaving}
      canPersistResult={canPersistResult}
    />
  );
}
