Merge branch 'main' of git.targo.ca:Targo/targo_backend
This commit is contained in:
commit
58c550103f
|
|
@ -1,4 +1,4 @@
|
||||||
import { Controller, Get, Patch, Param, Body, NotFoundException, Req, Post } from "@nestjs/common";
|
import { Controller, Get, Patch, Param, Body, NotFoundException, Req, Post, Query } from "@nestjs/common";
|
||||||
import { Employees } from "@prisma/client";
|
import { Employees } from "@prisma/client";
|
||||||
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
import { RolesAllowed } from "src/common/decorators/roles.decorators";
|
||||||
import { Result } from "src/common/errors/result-error.factory";
|
import { Result } from "src/common/errors/result-error.factory";
|
||||||
|
|
@ -19,9 +19,12 @@ export class EmployeesController {
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
@Get('profile')
|
@Get('profile')
|
||||||
findOneProfile(@Req() req): Promise<Result<EmployeeProfileItemDto,string>> {
|
findOneProfile(
|
||||||
|
@Req() req,
|
||||||
|
@Query('employee_email') employee_email?: string,
|
||||||
|
): Promise<Result<EmployeeProfileItemDto,string>> {
|
||||||
const email = req.user?.email;
|
const email = req.user?.email;
|
||||||
return this.employeesService.findOneProfile(email);
|
return this.employeesService.findOneProfile(employee_email ?? email);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('employee-list')
|
@Get('employee-list')
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ export class GetTimesheetsOverviewService {
|
||||||
where: { employee_id, start_date: { gte: period_start, lte: period_end } },
|
where: { employee_id, start_date: { gte: period_start, lte: period_end } },
|
||||||
include: {
|
include: {
|
||||||
employee: { include: { user: true } },
|
employee: { include: { user: true } },
|
||||||
shift: { include: { bank_code: true } },
|
shift: { include: { bank_code: true }, orderBy: { start_time: 'asc'} },
|
||||||
expense: { include: { bank_code: true, attachment_record: true } },
|
expense: { include: { bank_code: true, attachment_record: true } },
|
||||||
},
|
},
|
||||||
orderBy: { start_date: 'asc' },
|
orderBy: { start_date: 'asc' },
|
||||||
|
|
@ -109,7 +109,7 @@ export class GetTimesheetsOverviewService {
|
||||||
private async mapOneTimesheet(timesheet: Prisma.TimesheetsGetPayload<{
|
private async mapOneTimesheet(timesheet: Prisma.TimesheetsGetPayload<{
|
||||||
include: {
|
include: {
|
||||||
employee: { include: { user } },
|
employee: { include: { user } },
|
||||||
shift: { include: { bank_code } },
|
shift: { include: { bank_code }, orderBy: { start_time: 'asc'} },
|
||||||
expense: { include: { bank_code, attachment_record } },
|
expense: { include: { bank_code, attachment_record } },
|
||||||
}
|
}
|
||||||
}>): Promise<Timesheet> {
|
}>): Promise<Timesheet> {
|
||||||
|
|
@ -118,7 +118,7 @@ export class GetTimesheetsOverviewService {
|
||||||
const day_dates = sevenDaysFrom(start);
|
const day_dates = sevenDaysFrom(start);
|
||||||
|
|
||||||
//map of shifts by days
|
//map of shifts by days
|
||||||
const shifts_by_date = new Map<string, Prisma.ShiftsGetPayload<{ include: { bank_code } }>[]>();
|
const shifts_by_date = new Map<string, Prisma.ShiftsGetPayload<{ include: { bank_code }, orderBy: { start_time: 'asc'} }>[]>();
|
||||||
for (const shift of timesheet.shift) {
|
for (const shift of timesheet.shift) {
|
||||||
const date_string = toStringFromDate(shift.date);
|
const date_string = toStringFromDate(shift.date);
|
||||||
const arr = shifts_by_date.get(date_string) ?? [];
|
const arr = shifts_by_date.get(date_string) ?? [];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user