import { Controller, Get, Patch, Param, UseGuards } from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { NotificationsService } from './notifications.service';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
import { CurrentTenant } from '../../common/decorators/tenant.decorator';

@ApiTags('Notifications')
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Controller('notifications')
export class NotificationsController {
  constructor(private service: NotificationsService) {}

  @Get()
  findAll(@CurrentTenant() tenantId: string) { return this.service.findAll(tenantId); }

  @Get('unread-count')
  count(@CurrentTenant() tenantId: string) { return this.service.countUnread(tenantId); }

  @Patch(':id/read')
  read(@CurrentTenant() tenantId: string, @Param('id') id: string) {
    return this.service.markRead(tenantId, id);
  }

  @Patch('read-all')
  readAll(@CurrentTenant() tenantId: string) { return this.service.markAllRead(tenantId); }
}
