import {
  Controller,
  Post,
  Get,
  Body,
  Param,
  ParseIntPipe,
} from '@nestjs/common';
import { SeekerPreferencesService } from './seeker_preferences.service';
import { Public } from '../auth/public.decorator';
import {
  ApiBearerAuth,
  ApiTags,
  ApiBody,
  ApiParam,
  ApiQuery,
  ApiOperation,
} from '@nestjs/swagger';

@ApiTags('seeker/preferences')
@ApiBearerAuth('access-token')
@Controller('seeker/preferences')
export class SeekerPreferencesController {
  constructor(
    private readonly seekerPreferencesService: SeekerPreferencesService,
  ) {}
  @Public()
  @Post()
  @ApiOperation({ summary: 'Save Seeker Preferences' })
  @ApiBody({
    schema: {
      type: 'object',
      properties: {
        user_id: { type: 'number' },
        roles: { type: 'array', items: { type: 'number' } },
        skills: { type: 'array', items: { type: 'number' } },
      },
      required: ['user_id'],
    },
  })
  async savePreferences(
    @Body() data: { user_id: number; roles?: number[]; skills?: number[] },
  ) {
    const result =
      await this.seekerPreferencesService.saveSeekerPreferences(data);
    return {
      success: true,
      ...result,
    };
  }
  @Public()
  @Get(':userId')
  @ApiOperation({ summary: 'Get Seeker Preferences' })
  @ApiParam({ name: 'userId', type: Number })
  async getPreferences(@Param('userId', ParseIntPipe) userId: number) {
    const result =
      await this.seekerPreferencesService.getSeekerPreferences(userId);
    return {
      success: true,
      ...result,
    };
  }
}
