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:
@@ -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
@@ -14,24 +14,28 @@ export class DashboardController {
|
|||||||
@Get('kpis')
|
@Get('kpis')
|
||||||
@Roles('manager')
|
@Roles('manager')
|
||||||
async getKpis(@CurrentUser() user: CurrentUserPayload) {
|
async getKpis(@CurrentUser() user: CurrentUserPayload) {
|
||||||
return this.dashboardService.getKpis(user.tenantId);
|
const data = await this.dashboardService.getKpis(user.tenantId);
|
||||||
|
return { data };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('revenue-chart')
|
@Get('revenue-chart')
|
||||||
@Roles('manager')
|
@Roles('manager')
|
||||||
async getRevenueChart(@CurrentUser() user: CurrentUserPayload) {
|
async getRevenueChart(@CurrentUser() user: CurrentUserPayload) {
|
||||||
return this.dashboardService.getRevenueChart(user.tenantId);
|
const data = await this.dashboardService.getRevenueChart(user.tenantId);
|
||||||
|
return { data };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('activity')
|
@Get('activity')
|
||||||
@Roles('manager')
|
@Roles('manager')
|
||||||
async getActivity(@CurrentUser() user: CurrentUserPayload) {
|
async getActivity(@CurrentUser() user: CurrentUserPayload) {
|
||||||
return this.dashboardService.getRecentActivity(user.tenantId);
|
const data = await this.dashboardService.getRecentActivity(user.tenantId);
|
||||||
|
return { data };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('financial-summary')
|
@Get('financial-summary')
|
||||||
@Roles('manager')
|
@Roles('manager')
|
||||||
async getFinancialSummary(@CurrentUser() user: CurrentUserPayload) {
|
async getFinancialSummary(@CurrentUser() user: CurrentUserPayload) {
|
||||||
return this.dashboardService.getFinancialSummary(user.tenantId);
|
const data = await this.dashboardService.getFinancialSummary(user.tenantId);
|
||||||
|
return { data };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import {
|
|||||||
BadRequestException,
|
BadRequestException,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { PrismaService } from '../prisma/prisma.service';
|
import { PrismaService } from '../prisma/prisma.service';
|
||||||
import { NotificationService } from '../notification/notification.service';
|
|
||||||
import { CreateTicketDto } from './dto/create-ticket.dto';
|
import { CreateTicketDto } from './dto/create-ticket.dto';
|
||||||
import { UpdateTicketDto } from './dto/update-ticket.dto';
|
import { UpdateTicketDto } from './dto/update-ticket.dto';
|
||||||
|
import { CreateCommentDto } from './dto/create-comment.dto';
|
||||||
|
|
||||||
export interface TicketResolvedEvent {
|
export interface TicketResolvedEvent {
|
||||||
ticketId: string;
|
ticketId: string;
|
||||||
@@ -21,10 +21,7 @@ export class TicketService {
|
|||||||
onTicketResolved: ((event: TicketResolvedEvent) => Promise<void>) | null =
|
onTicketResolved: ((event: TicketResolvedEvent) => Promise<void>) | null =
|
||||||
null;
|
null;
|
||||||
|
|
||||||
constructor(
|
constructor(private readonly prisma: PrismaService) {}
|
||||||
private readonly prisma: PrismaService,
|
|
||||||
private readonly notificationService: NotificationService,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async findAll(tenantId: string, filters?: { clientId?: string; status?: string; type?: string }) {
|
async findAll(tenantId: string, filters?: { clientId?: string; status?: string; type?: string }) {
|
||||||
const db = this.prisma.forTenant(tenantId);
|
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({
|
return this.prisma.ticket.update({
|
||||||
where: { id },
|
where: { id },
|
||||||
data: {
|
data: {
|
||||||
@@ -180,4 +165,50 @@ export class TicketService {
|
|||||||
|
|
||||||
return resolved;
|
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,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user