/**
 * @ai-summary User profile feature routes
 * @ai-context Registers user profile API endpoints with authentication
 */

import { FastifyPluginAsync } from 'fastify';
import { UserProfileController } from './user-profile.controller';
import { UpdateProfileInput, RequestDeletionInput } from './user-profile.validation';

export const userProfileRoutes: FastifyPluginAsync = async (fastify) => {
  const userProfileController = new UserProfileController();

  // GET /api/user/profile - Get current user's profile
  fastify.get('/user/profile', {
    preHandler: [fastify.authenticate],
    handler: userProfileController.getProfile.bind(userProfileController),
  });

  // PUT /api/user/profile - Update user profile
  fastify.put<{ Body: UpdateProfileInput }>('/user/profile', {
    preHandler: [fastify.authenticate],
    handler: userProfileController.updateProfile.bind(userProfileController),
  });

  // POST /api/user/delete - Request account deletion
  fastify.post<{ Body: RequestDeletionInput }>('/user/delete', {
    preHandler: [fastify.authenticate],
    handler: userProfileController.requestDeletion.bind(userProfileController),
  });

  // POST /api/user/cancel-deletion - Cancel account deletion
  fastify.post('/user/cancel-deletion', {
    preHandler: [fastify.authenticate],
    handler: userProfileController.cancelDeletion.bind(userProfileController),
  });

  // GET /api/user/deletion-status - Get deletion status
  fastify.get('/user/deletion-status', {
    preHandler: [fastify.authenticate],
    handler: userProfileController.getDeletionStatus.bind(userProfileController),
  });
};
