import { Body, Controller, Param, Post } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { CurrentUser } from '../common/decorators/current-user.decorator';
import type { JwtUserPayload } from '../auth/jwt.types';
import { PunchesService } from './punches.service';
import {
  ArrivalPunchDto,
  DeparturePunchDto,
  MeetingEndPunchDto,
  MeetingStartPunchDto,
} from './dto/punch.dto';

@ApiTags('punches')
@ApiBearerAuth('access-token')
@Controller('trips/:tripId/punches')
export class PunchesController {
  constructor(private readonly punches: PunchesService) {}

  @Post('departure')
  departure(
    @Param('tripId') tripId: string,
    @CurrentUser() actor: JwtUserPayload,
    @Body() dto: DeparturePunchDto,
  ) {
    return this.punches.recordDeparture(tripId, actor, dto);
  }

  @Post('arrival')
  arrival(
    @Param('tripId') tripId: string,
    @CurrentUser() actor: JwtUserPayload,
    @Body() dto: ArrivalPunchDto,
  ) {
    return this.punches.recordArrival(tripId, actor, dto);
  }

  @Post('meeting-start')
  meetingStart(
    @Param('tripId') tripId: string,
    @CurrentUser() actor: JwtUserPayload,
    @Body() dto: MeetingStartPunchDto,
  ) {
    return this.punches.recordMeetingStart(tripId, actor, dto);
  }

  @Post('meeting-end')
  meetingEnd(
    @Param('tripId') tripId: string,
    @CurrentUser() actor: JwtUserPayload,
    @Body() dto: MeetingEndPunchDto,
  ) {
    return this.punches.recordMeetingEnd(tripId, actor, dto);
  }
}
