- Add latitude/longitude Float fields to Client model in schema.prisma - Rewrite dashboard controller (remove duplicate const data, use getRecentActivity) - Remove invalid files field from ticket comment create - Add migration for client coordinates
42 lines
1.4 KiB
TypeScript
42 lines
1.4 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) {
|
|
const data = await this.dashboardService.getKpis(user.tenantId);
|
|
return { data };
|
|
}
|
|
|
|
@Get('revenue-chart')
|
|
@Roles('manager')
|
|
async getRevenueChart(@CurrentUser() user: CurrentUserPayload) {
|
|
const data = await this.dashboardService.getRevenueChart(user.tenantId);
|
|
return { data };
|
|
}
|
|
|
|
@Get('activity')
|
|
@Roles('manager')
|
|
async getActivity(@CurrentUser() user: CurrentUserPayload) {
|
|
const data = await this.dashboardService.getRecentActivity(user.tenantId);
|
|
return { data };
|
|
}
|
|
|
|
@Get('financial-summary')
|
|
@Roles('manager')
|
|
async getFinancialSummary(@CurrentUser() user: CurrentUserPayload) {
|
|
const data = await this.dashboardService.getFinancialSummary(user.tenantId);
|
|
return { data };
|
|
}
|
|
}
|