import { useWalkthroughSummary } from '@/business/walkthrough/hooks';
import type { WalkthroughCheckinDto } from '@/shared/types/walkthrough';
import { WalkthroughPresentationView } from '@/components/walkthrough-summary/WalkthroughPresentationView';
import { WalkthroughPrintableReport } from '@/components/walkthrough-summary/WalkthroughPrintableReport';
import { WalkthroughSummaryEmpty } from '@/components/walkthrough-summary/WalkthroughSummaryEmpty';
import { WalkthroughSummaryLoading } from '@/components/walkthrough-summary/WalkthroughSummaryLoading';
import { WalkthroughSummaryMainView } from '@/components/walkthrough-summary/WalkthroughSummaryMainView';

interface WalkThroughSummaryProps {
  readonly checkins: readonly WalkthroughCheckinDto[];
  readonly loading: boolean;
}

export default function WalkThroughSummary({ checkins, loading }: WalkThroughSummaryProps) {
  const summary = useWalkthroughSummary(checkins);

  if (loading) {
    return <WalkthroughSummaryLoading />;
  }

  if (checkins.length === 0) {
    return <WalkthroughSummaryEmpty />;
  }

  if (summary.presentationMode) {
    return <WalkthroughPresentationView summary={summary} />;
  }

  if (summary.showReport) {
    return <WalkthroughPrintableReport summary={summary} />;
  }

  return <WalkthroughSummaryMainView summary={summary} />;
}
