38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { Controller, Get, UseGuards } from '@nestjs/common';
|
|
import { AuthGuard } from '@nestjs/passport';
|
|
import { DashboardService } from './dashboard.service';
|
|
import { Roles } from '../common/decorators/roles.decorator';
|
|
import { RolesGuard } from '../common/guards/roles.guard';
|
|
import { TenantGuard } from '../common/guards/tenant.guard';
|
|
import { CurrentUser, CurrentUserPayload } from '../common/decorators/current-user.decorator';
|
|
|
|
@Controller('dashboard')
|
|
@UseGuards(AuthGuard('jwt'), TenantGuard, RolesGuard)
|
|
export class DashboardController {
|
|
constructor(private readonly dashboardService: DashboardService) {}
|
|
|
|
@Get('kpis')
|
|
@Roles('manager')
|
|
async getKpis(@CurrentUser() user: CurrentUserPayload) {
|
|
return this.dashboardService.getKpis(user.tenantId);
|
|
}
|
|
|
|
@Get('revenue-chart')
|
|
@Roles('manager')
|
|
async getRevenueChart(@CurrentUser() user: CurrentUserPayload) {
|
|
return this.dashboardService.getRevenueChart(user.tenantId);
|
|
}
|
|
|
|
@Get('activity')
|
|
@Roles('manager')
|
|
async getActivity(@CurrentUser() user: CurrentUserPayload) {
|
|
return this.dashboardService.getRecentActivity(user.tenantId);
|
|
}
|
|
|
|
@Get('financial-summary')
|
|
@Roles('manager')
|
|
async getFinancialSummary(@CurrentUser() user: CurrentUserPayload) {
|
|
return this.dashboardService.getFinancialSummary(user.tenantId);
|
|
}
|
|
}
|