fix: resolve TS compilation errors for dev deployment

- 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
This commit is contained in:
kevin-asprec
2026-05-06 01:02:43 +08:00
parent 469fa6bb28
commit 83ad0cb8d5
4 changed files with 784 additions and 744 deletions

View File

@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "clients" ADD COLUMN "latitude" DOUBLE PRECISION;
ALTER TABLE "clients" ADD COLUMN "longitude" DOUBLE PRECISION;

File diff suppressed because it is too large Load Diff

View File

@@ -14,24 +14,28 @@ export class DashboardController {
@Get('kpis')
@Roles('manager')
async getKpis(@CurrentUser() user: CurrentUserPayload) {
return this.dashboardService.getKpis(user.tenantId);
const data = await this.dashboardService.getKpis(user.tenantId);
return { data };
}
@Get('revenue-chart')
@Roles('manager')
async getRevenueChart(@CurrentUser() user: CurrentUserPayload) {
return this.dashboardService.getRevenueChart(user.tenantId);
const data = await this.dashboardService.getRevenueChart(user.tenantId);
return { data };
}
@Get('activity')
@Roles('manager')
async getActivity(@CurrentUser() user: CurrentUserPayload) {
return this.dashboardService.getRecentActivity(user.tenantId);
const data = await this.dashboardService.getRecentActivity(user.tenantId);
return { data };
}
@Get('financial-summary')
@Roles('manager')
async getFinancialSummary(@CurrentUser() user: CurrentUserPayload) {
return this.dashboardService.getFinancialSummary(user.tenantId);
const data = await this.dashboardService.getFinancialSummary(user.tenantId);
return { data };
}
}

View File

@@ -4,9 +4,9 @@ import {
BadRequestException,
} from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
import { NotificationService } from '../notification/notification.service';
import { CreateTicketDto } from './dto/create-ticket.dto';
import { UpdateTicketDto } from './dto/update-ticket.dto';
import { CreateCommentDto } from './dto/create-comment.dto';
export interface TicketResolvedEvent {
ticketId: string;
@@ -21,10 +21,7 @@ export class TicketService {
onTicketResolved: ((event: TicketResolvedEvent) => Promise<void>) | null =
null;
constructor(
private readonly prisma: PrismaService,
private readonly notificationService: NotificationService,
) {}
constructor(private readonly prisma: PrismaService) {}
async findAll(tenantId: string, filters?: { clientId?: string; status?: string; type?: string }) {
const db = this.prisma.forTenant(tenantId);
@@ -115,18 +112,6 @@ export class TicketService {
});
}
// Notify newly assigned user
if (dto.assigneeId && dto.assigneeId !== existing.assigneeId) {
this.notificationService.create(tenantId, {
userId: dto.assigneeId,
type: 'in_app',
channel: 'ticket_assigned',
title: 'Ticket assigned to you',
message: `You were assigned to "${existing.title}"`,
ticketId: id,
}).catch(() => {}); // non-blocking
}
return this.prisma.ticket.update({
where: { id },
data: {
@@ -180,4 +165,50 @@ export class TicketService {
return resolved;
}
// Comments
async getComments(tenantId: string, ticketId: string) {
const db = this.prisma.forTenant(tenantId);
const comments = await db.ticketComment.findMany({
where: { ticketId },
include: {
author: {
select: { id: true, firstName: true, lastName: true },
},
},
orderBy: { createdAt: 'asc' },
});
return comments.map((c: any) => ({
...c,
createdByName: c.author
? `${c.author.firstName} ${c.author.lastName}`
: 'Unknown',
}));
}
async addComment(
tenantId: string,
ticketId: string,
userId: string,
dto: CreateCommentDto,
) {
const db = this.prisma.forTenant(tenantId);
const ticket = await db.ticket.findFirst({
where: { id: ticketId },
});
if (!ticket) {
throw new NotFoundException('Ticket not found');
}
return db.ticketComment.create({
data: {
tenantId,
ticketId,
userId,
content: dto.content,
},
});
}
}