Merge branch 'main' of git.targo.ca:Targo/targo_backend
This commit is contained in:
commit
e72b63116c
|
|
@ -62,6 +62,7 @@ export class ShiftsUpdateDeleteService {
|
|||
if (!timesheet.success) return { success: false, error: timesheet.error }
|
||||
|
||||
//finds original shift
|
||||
console.log('timesheet id found: ', timesheet.data.id);
|
||||
const original = await this.prisma.shifts.findFirst({
|
||||
where: { id: dto.id, timesheet_id: timesheet.data.id },
|
||||
select: shift_select,
|
||||
|
|
@ -162,9 +163,14 @@ export class ShiftsUpdateDeleteService {
|
|||
for (let j = i + 1; j < shifts.length; j++) {
|
||||
const shift_a = shifts[i];
|
||||
const shift_b = shifts[j];
|
||||
<<<<<<< HEAD
|
||||
|
||||
if (shift_a.date !== shift_b.date) continue;
|
||||
if (shift_a.id === shift_b.id) continue;
|
||||
=======
|
||||
|
||||
if (shift_a.date !== shift_b.date || shift_a.id === shift_b.id) continue;
|
||||
>>>>>>> 37b150d87c98746a3cb23bbe36ee9e364c6a613d
|
||||
const has_overlap = overlaps(
|
||||
{ start: toHHmmFromString(shift_a.start_time), end: toHHmmFromString(shift_a.end_time) },
|
||||
{ start: toHHmmFromString(shift_b.start_time), end: toHHmmFromString(shift_b.end_time) },
|
||||
|
|
|
|||
|
|
@ -3,11 +3,9 @@ import { ANCHOR_ISO, MS_PER_DAY, PERIODS_PER_YEAR, PERIOD_DAYS } from "src/time-
|
|||
|
||||
//ensures the week starts from sunday
|
||||
export function weekStartSunday(date_local: Date): Date {
|
||||
const start = new Date(Date.UTC(date_local.getFullYear(), date_local.getMonth(), date_local.getDate()));
|
||||
const dow = start.getDay(); // 0 = dimanche
|
||||
start.setDate(start.getDate() - dow);
|
||||
start.setHours(0, 0, 0, 0);
|
||||
return start;
|
||||
const start_date = new Date();
|
||||
start_date.setDate(date_local.getDate() - date_local.getDay());
|
||||
return start_date;
|
||||
}
|
||||
|
||||
//converts string to HHmm format
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ export class EmployeeTimesheetResolver {
|
|||
const employee_id = await this.emailResolver.findIdByEmail(email);
|
||||
if(!employee_id.success) return { success: false, error: employee_id.error}
|
||||
const start_date = weekStartSunday(date);
|
||||
console.log('start date: ', start_date);
|
||||
const timesheet = await db.timesheets.findFirst({
|
||||
where: { employee_id : employee_id.data, start_date: start_date },
|
||||
select: { id: true },
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user