import { WALKTHROUGH_FORM_CATEGORIES } from '@/shared/constants/walkthrough';
import type { WalkthroughRatingDraft } from '@/business/walkthrough/mappers';

interface WalkthroughFormValidationInput {
  readonly teacherName: string;
  readonly classroom: string;
  readonly directorName: string;
  readonly ratings: WalkthroughRatingDraft;
}

export function hasAllWalkthroughRatings(ratings: WalkthroughRatingDraft): boolean {
  return WALKTHROUGH_FORM_CATEGORIES.every((category) => ratings[category.key] !== undefined);
}

export function canSubmitWalkthroughForm(input: WalkthroughFormValidationInput): boolean {
  return Boolean(
    input.teacherName.trim()
    && input.classroom.trim()
    && input.directorName.trim()
    && hasAllWalkthroughRatings(input.ratings),
  );
}
