/**
 * @ai-summary Fastify routes for onboarding API
 * @ai-context Route definitions for user onboarding workflow
 */

import { FastifyInstance, FastifyPluginOptions, FastifyPluginAsync } from 'fastify';
import { OnboardingController } from './onboarding.controller';
import { SavePreferencesInput } from './onboarding.validation';

export const onboardingRoutes: FastifyPluginAsync = async (
  fastify: FastifyInstance,
  _opts: FastifyPluginOptions
) => {
  const onboardingController = new OnboardingController();

  // POST /api/onboarding/preferences - Save user preferences
  fastify.post<{ Body: SavePreferencesInput }>('/onboarding/preferences', {
    preHandler: [fastify.authenticate],
    handler: onboardingController.savePreferences.bind(onboardingController),
  });

  // POST /api/onboarding/complete - Mark onboarding as complete
  fastify.post('/onboarding/complete', {
    preHandler: [fastify.authenticate],
    handler: onboardingController.completeOnboarding.bind(onboardingController),
  });

  // GET /api/onboarding/status - Get onboarding status
  fastify.get('/onboarding/status', {
    preHandler: [fastify.authenticate],
    handler: onboardingController.getStatus.bind(onboardingController),
  });
};
