From a32d636b6edddf3bff90c000fcb73477031bff4f Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Fri, 20 Feb 2026 05:29:22 -0500 Subject: [PATCH] feat(tickets): added a service function to get tickets according to email or session email and ticket status --- src/customer-support/tickets/dtos/note.ts | 45 ------------------- .../tickets/ticket.controller.ts | 12 +++-- .../domains/services/sick-leave.service.ts | 4 +- 3 files changed, 11 insertions(+), 50 deletions(-) delete mode 100644 src/customer-support/tickets/dtos/note.ts diff --git a/src/customer-support/tickets/dtos/note.ts b/src/customer-support/tickets/dtos/note.ts deleted file mode 100644 index bff4586..0000000 --- a/src/customer-support/tickets/dtos/note.ts +++ /dev/null @@ -1,45 +0,0 @@ - -/* -To allow me to get all infos needed to display in the ticket list page i need to access these informations and how to get it : - - -> ticket_id: - - ticket table: - using the account ids and delivery ids, i can : - i need first name and last name for contacts, i will use the account_ids to query the account table - i need to find the service_id, i need the product_id to query the service table. - - -> status: - -ticket table : the status is here. - - -> assign_to: - - ticket table : - displays a staff_id: - I need to query the staff table, using the email to get the id of the employee, its email, its first and last name, - - -> deliveryAddress: - - ticket table: the account_id is here. - - delivery table: i can get the address here, using the account_id. - - -> product_type: - - ticket table : using the account_id : - i can query the delivery table: - -delivery table: - get delivery id linked to the account id - i can query the service table - - service table: - delivery_id to get the product_id and device_id - - product table: - using the product_id, i can get the type here - -> department: - - ticket table: - i can get the dept_id here - - ticket_dept : - using the dept_id from the ticket table, i can get the name here. - -> parentTicketId: - - ticket table: - i can get the parent here. - -> dueDate, updatedAt, completedAt: - - ticket table: - i can get the due_date, last_update, Date_closed here. - -*/ \ No newline at end of file diff --git a/src/customer-support/tickets/ticket.controller.ts b/src/customer-support/tickets/ticket.controller.ts index 187d293..dea7a28 100644 --- a/src/customer-support/tickets/ticket.controller.ts +++ b/src/customer-support/tickets/ticket.controller.ts @@ -1,4 +1,5 @@ import { Controller, Get, Param } from "@nestjs/common"; +import { Access } from "src/common/decorators/module-access.decorators"; import { ModuleAccessAllowed } from "src/common/decorators/modules-guard.decorators"; import { Result } from "src/common/errors/result-error.factory"; import { TicketListItem } from "src/customer-support/tickets/dtos/ticket-list.dto"; @@ -9,13 +10,18 @@ export class TicketController { constructor(private readonly getService: TicketService) { } - @Get(':email/:status') + @Get(':status/:email') @ModuleAccessAllowed() async findTicketByFilters( + @Access('email') email: string, @Param('status') status: string, - @Param('email') email?: string, + @Param('email') filter_email?: string, ): Promise> { - return await this.getService.getListOfAllTicketByFilters(status, email); + if (!filter_email) { + return await this.getService.getListOfAllTicketByFilters(status, email) + } else { + return await this.getService.getListOfAllTicketByFilters(status, filter_email); + } } } \ No newline at end of file diff --git a/src/time-and-attendance/domains/services/sick-leave.service.ts b/src/time-and-attendance/domains/services/sick-leave.service.ts index 19684b7..5bd9c82 100644 --- a/src/time-and-attendance/domains/services/sick-leave.service.ts +++ b/src/time-and-attendance/domains/services/sick-leave.service.ts @@ -113,7 +113,7 @@ export class SickLeaveService { takeSickLeaveHours = async (employee_id: number, asked_hours: number): Promise> => { if (asked_hours <= 0) return { success: false, error: 'INVALID_BANKING_HOURS' }; - + try { const result = await this.prisma.$transaction(async (tx) => { const employee = await this.prisma.employees.findUnique({ @@ -147,7 +147,7 @@ export class SickLeaveService { last_updated: new Date(), }, }); - + return { success: true, data: asked_hours } as Result; } });