import { Body, Controller, Get, Post, Patch, Delete, Param, UseGuards } from '@nestjs/common';
import { LegalHoldsService } from './legal-holds.service';
import { JwtAuthGuard } from '../../common/guards/jwt.guard';
import { CurrentUser } from '../../common/decorators/current-user.decorator';
import { Workspace } from '../../common/decorators/workspace.decorator';

@Controller('legal-holds')
@UseGuards(JwtAuthGuard)
export class LegalHoldsController {
  constructor(private readonly legalHoldsService: LegalHoldsService) {}

  @Get()
  async list(@Workspace('id') wsId: string, @CurrentUser('userId') userId: string) {
    return this.legalHoldsService.list(wsId, userId);
  }

  @Post()
  async create(
    @Workspace('id') wsId: string,
    @CurrentUser('userId') userId: string,
    @Body() dto: any,
  ) {
    return this.legalHoldsService.create(wsId, userId, dto);
  }

  @Patch(':id')
  async update(
    @Param('id') id: string,
    @Workspace('id') wsId: string,
    @CurrentUser('userId') userId: string,
    @Body() dto: any,
  ) {
    return this.legalHoldsService.update(id, wsId, userId, dto);
  }

  @Post(':id/release')
  async release(
    @Param('id') id: string,
    @Workspace('id') wsId: string,
    @CurrentUser('userId') userId: string,
  ) {
    return this.legalHoldsService.release(id, wsId, userId);
  }

  @Delete(':id')
  async delete(
    @Param('id') id: string,
    @Workspace('id') wsId: string,
    @CurrentUser('userId') userId: string,
  ) {
    return this.legalHoldsService.delete(id, wsId, userId);
  }
}