import {
  Body,
  Controller,
  Get,
  Post,
  UseGuards,
  ValidationPipe,
} from '@nestjs/common';
import { ApiTags } from '@nestjs/swagger';
import { VcElementsService } from '../services/elements.service';
import { VISA_PRODUCTS } from 'src/constants/visa/visa-commission';
import { handleServiceRequest } from 'src/utils/response/response-handler';
import { SessionGuard } from 'src/config/guards/session.guard';
import { SearchProductCountriesDto } from '../dto/search-product-countries-dto';
import { SearchAssociatesDto } from '../dto/search-associates-dto';
import { SearchCollegeCampusDto } from '../dto/search-college-campus-dto';
import { CountriesDetailsByIdsDto } from '../dto/countries-details-by-ids.dto';
import { FetchByAssociationTypesDto } from '../dto/fetch-by-association-typs.dto';
import { FetchByUsersDto } from '../dto/fetch-by-users.dto';
import { SearchCollegeCampusCoursesDto } from '../dto/search-college-campus-courses-dto';

@ApiTags('Visa Commission')
@Controller('')
@UseGuards(SessionGuard)
export class VcElementsController {
  constructor(private readonly visaCommissionService: VcElementsService) {}

  @Get('visa-products-list')
  getVisaProductList() {
    return VISA_PRODUCTS.filter((item) => item.id === 8);
  }

  @Post('visa-service-countries')
  async getVisaServiceCountries(
    @Body(new ValidationPipe()) params: SearchProductCountriesDto,
  ) {
    return await handleServiceRequest(
      this.visaCommissionService.getVisaCountryList(params.product_id),
    );
  }

  @Post('associate-list')
  async getAssociates(@Body(new ValidationPipe()) params: SearchAssociatesDto) {
    return await handleServiceRequest(
      this.visaCommissionService.getAssociateList(params),
    );
  }

  @Get('client-countries')
  async getClientCountries() {
    return await handleServiceRequest(
      this.visaCommissionService.getClientCountryList(),
    );
  }

  @Post('college-campus-list')
  async getCollegeCampus(
    @Body(new ValidationPipe()) params: SearchCollegeCampusDto,
  ) {
    return await handleServiceRequest(
      this.visaCommissionService.getInstituteCampusList(params),
    );
  }

  @Get('study-level-list')
  async getStudyLevels() {
    return await handleServiceRequest(
      this.visaCommissionService.getStudyLevelList(),
    );
  }

  @Post('c-d-b-ids')
  async getCountriesDetailsByIds(
    @Body(new ValidationPipe()) params: CountriesDetailsByIdsDto,
  ) {
    return await handleServiceRequest(
      this.visaCommissionService.getCountriesByIds(params.countries),
    );
  }

  @Post('fetch-client-countries')
  async getClientCountriesByList(
    @Body(new ValidationPipe()) params: FetchByAssociationTypesDto,
  ) {
    return await handleServiceRequest(
      this.visaCommissionService.fetchClientCountriesByList(params.type),
    );
  }

  @Post('fetch-associates')
  async getAssociatesByList(
    @Body(new ValidationPipe()) params: FetchByAssociationTypesDto,
  ) {
    return await handleServiceRequest(
      this.visaCommissionService.fetchAssociatesByList(params.type),
    );
  }

  @Post('fetch-users')
  async getCreatedByOrUpdatedByUsers(
    @Body(new ValidationPipe()) params: FetchByUsersDto,
  ) {
    return await handleServiceRequest(
      this.visaCommissionService.fetchCreatedByOrUpdatedByUsers(
        params.by,
        params.type,
      ),
    );
  }

  @Post('fetch-courses-by-campus-study-levels')
  async getCoursesByInstituteCampusStudyLevels(
    @Body() searchCoursesDto: SearchCollegeCampusCoursesDto,
  ): Promise<any> {
    return await handleServiceRequest(
      this.visaCommissionService.getCoursesByInstituteCampusStudyLevels(
        searchCoursesDto,
      ),
    );
  }
}
