import { Controller, Get, Query } from '@nestjs/common'; import { ApiBearerAuth, ApiOkResponse, ApiOperation, ApiTags, } from '@nestjs/swagger'; import { BookingView } from '../../common/booking-guards'; import { OverviewQueryDto } from './dto/overview-query.dto'; import { OverviewResponseDto } from './dto/overview-response.dto'; import { OverviewBillingTabDto, OverviewBookingsTabDto, OverviewCustomersTabDto, OverviewOperationsTabDto, OverviewStaffTabDto, } from './dto/overview-tab-response.dto'; import { OverviewService } from './overview.service'; @ApiTags('Overview') @ApiBearerAuth() @Controller('overview') export class OverviewController { constructor(private readonly overviewService: OverviewService) {} @Get() @BookingView() @ApiOperation({ summary: 'Aggregated dashboard summary for backoffice overview' }) @ApiOkResponse({ type: OverviewResponseDto }) getDashboard(@Query() query: OverviewQueryDto): Promise { return this.overviewService.getDashboard(query.range ?? '30d'); } @Get('bookings') @BookingView() @ApiOperation({ summary: 'Bookings tab metrics and charts' }) @ApiOkResponse({ type: OverviewBookingsTabDto }) getBookingsTab(@Query() query: OverviewQueryDto): Promise { return this.overviewService.getBookingsTab(query.range ?? '30d'); } @Get('billing') @BookingView() @ApiOperation({ summary: 'Billing tab metrics and charts' }) @ApiOkResponse({ type: OverviewBillingTabDto }) getBillingTab(@Query() query: OverviewQueryDto): Promise { return this.overviewService.getBillingTab(query.range ?? '30d'); } @Get('operations') @BookingView() @ApiOperation({ summary: 'Operations tab metrics and charts' }) @ApiOkResponse({ type: OverviewOperationsTabDto }) getOperationsTab(): Promise { return this.overviewService.getOperationsTab(); } @Get('customers') @BookingView() @ApiOperation({ summary: 'Customers tab metrics and charts' }) @ApiOkResponse({ type: OverviewCustomersTabDto }) getCustomersTab(@Query() query: OverviewQueryDto): Promise { return this.overviewService.getCustomersTab(query.range ?? '30d'); } @Get('staff') @BookingView() @ApiOperation({ summary: 'Staff tab metrics and charts' }) @ApiOkResponse({ type: OverviewStaffTabDto }) getStaffTab(@Query() query: OverviewQueryDto): Promise { return this.overviewService.getStaffTab(query.range ?? '30d'); } }