import { Controller, Get, Put, Param, Body } from '@nestjs/common';
import { JobApplicationsService } from './job_applications.service';
import {
  ApiBearerAuth,
  ApiTags,
  ApiBody,
  ApiParam,
  ApiQuery,
  ApiOperation,
} from '@nestjs/swagger';
import { Public } from '../auth/public.decorator';
@ApiTags('jobApplications')
@ApiBearerAuth('access-token')
@Controller('jobApplications')
export class JobApplicationsController {
  constructor(
    private readonly jobApplicationsService: JobApplicationsService,
  ) {}

  @Public()
  @Get()
  @ApiOperation({ summary: 'Get all job applications' })
  findAll() {
    return this.jobApplicationsService.findAll();
  }

  @Public()
  @Put(':id/status')
  @ApiOperation({ summary: 'Update Application Status' })
  @ApiParam({ name: 'id', type: String })
  @ApiBody({
    schema: {
      type: 'object',
      properties: { status: { type: 'string' } },
      required: ['status'],
    },
  })
  async updateStatus(@Param('id') id: string, @Body() body: any) {
    return this.jobApplicationsService.updateStatus(Number(id), body.status);
  }

  @Public()
  @Get('job/:jobPostId')
  @ApiOperation({ summary: 'Find Applications by Job Post' })
  @ApiParam({ name: 'jobPostId', type: String })
  async findByJobPost(@Param('jobPostId') jobPostId: string) {
    return this.jobApplicationsService.findByJobPost(Number(jobPostId));
  }

  @Public()
  @Get('seeker/:seekerId')
  @ApiOperation({ summary: 'Get Applications by Seeker' })
  @ApiParam({ name: 'seekerId', type: String })
  async findBySeeker(@Param('seekerId') seekerId: string) {
    return this.jobApplicationsService.findBySeeker(Number(seekerId));
  }
}
