import { CanActivate, ExecutionContext, ForbiddenException, Injectable } from "@nestjs/common";
import { OnboardingService } from "./onboarding.service";

@Injectable()
export class OnboardingGuard implements CanActivate {
  constructor(private readonly onboardingService: OnboardingService) {}

  async canActivate(_context: ExecutionContext): Promise<boolean> {
    const completed = await this.onboardingService.isCompleted();

    if (completed) {
      throw new ForbiddenException("Onboarding already completed");
    }

    return true;
  }
}
