Files
kooltab-backoffice/apps/api/src/reminders/reminders.controller.ts
T
brammie15 314717ba3a
CI / build-and-test (push) Canceled after 0s
feat: move to V2
2026-10-29 11:21:52 +01:00

29 lines
1.1 KiB
TypeScript

import { Body, Controller, Get, Param, Post, Query } from '@nestjs/common';
import { z } from 'zod';
import { Reminder, ReminderCandidate, SendRemindersResult, sendRemindersSchema } from '@kooltap/shared';
import { zod } from '../common/zod.pipe';
import { Authorized, Roles } from '../common/auth';
import { RemindersService } from './reminders.service';
@Controller('venues/:venueId/reminders')
@Authorized()
export class RemindersController {
constructor(private reminders: RemindersService) {}
@Get('candidates')
candidates(@Param('venueId') venueId: string): Promise<{ candidates: ReminderCandidate[]; cooldownDays: number }> {
return this.reminders.candidates(venueId);
}
@Post('send')
@Roles('admin', 'manager')
send(@Param('venueId') venueId: string, @Body(zod(sendRemindersSchema)) dto: z.output<typeof sendRemindersSchema>): Promise<SendRemindersResult> {
return this.reminders.send(venueId, dto.tabIds);
}
@Get()
history(@Param('venueId') venueId: string, @Query('customerName') customerName?: string): Promise<Reminder[]> {
return this.reminders.history(venueId, customerName);
}
}