// trip-fund.controller.ts
import {
  Controller,
  Post,
  Body,
  Param,
  Get,
  Delete,
  UseGuards,
} from '@nestjs/common';
import { TripFundService } from './trip-fund.service';
import { CreateMultipleTripFundDto } from './dto/create-multiple-trip-fund.dto';
import { TripMember, TripAdmin } from '@/auth/decorator/permission.decorator';
import { JwtAuthGuard } from '@/auth/guards/jwt-auth/jwt-auth.guard';

@UseGuards(JwtAuthGuard)
@Controller('trips/:tripId/funds')
export class TripFundController {
  constructor(private readonly fundService: TripFundService) {}

  @Post()
  @TripAdmin()
  upsertMultiple(
    @Param('tripId') tripId: string,
    @Body() dto: CreateMultipleTripFundDto,
  ) {
    return this.fundService.upsertMultiple(tripId, dto);
  }

  @Get()
  @TripMember()
  findByTrip(@Param('tripId') tripId: string) {
    return this.fundService.findByTrip(tripId);
  }

  @Delete(':userId')
  @TripAdmin()
  remove(
    @Param('tripId') tripId: string,
    @Param('userId') userId: string,
  ) {
    return this.fundService.remove(tripId, userId);
  }
}