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

@Controller('reminders')
@UseGuards(JwtAuthGuard)
export class RemindersController {
  constructor(private readonly remindersService: RemindersService) {}

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

  @Post()
  async create(
    @CurrentUser('userId') userId: string,
    @Workspace('id') wsId: string,
    @Body() dto: { text: string; remind_at: string; channel_id?: string },
  ) {
    return this.remindersService.create(userId, wsId, dto);
  }

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

  @Post(':id/complete')
  async complete(
    @Param('id') id: string,
    @CurrentUser('userId') userId: string,
  ) {
    return this.remindersService.complete(id, userId);
  }
}