From 13e9814e895e8c30b455fd334ee8d5392e89f9ae Mon Sep 17 00:00:00 2001 From: CrisGrud Date: Tue, 12 Mar 2024 17:43:30 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20Code=20refactored?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: #210 --- src/KonvaTimeline/line-scenario.stories.tsx | 8 ++++---- src/tasks/utils/tasks.ts | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/KonvaTimeline/line-scenario.stories.tsx b/src/KonvaTimeline/line-scenario.stories.tsx index 6334852..e66b743 100644 --- a/src/KonvaTimeline/line-scenario.stories.tsx +++ b/src/KonvaTimeline/line-scenario.stories.tsx @@ -78,8 +78,8 @@ export const Line: Story = { label: "Task2", resourceId: "2", time: { - start: 1700434800000, - end: 1700934800000, + start: 1699900000000, + end: 1700048000000, }, relatedTasks: ["5"], }, @@ -88,8 +88,8 @@ export const Line: Story = { label: "Task5", resourceId: "1", time: { - start: 1701505200000, - end: 1702095200000, + start: 1700505200000, + end: 1700805200000, }, }, ], diff --git a/src/tasks/utils/tasks.ts b/src/tasks/utils/tasks.ts index 5363e55..8b852eb 100644 --- a/src/tasks/utils/tasks.ts +++ b/src/tasks/utils/tasks.ts @@ -179,8 +179,8 @@ export const onEndTimeRange = ( const diffTZ = +intervalStartTZ! - +taskStartTZ!; const startOfDay = startDate.startOf("day").toISO()?.slice(-5, -3); //Day start TZ - const nexDay = startDate.startOf("day").plus({ day: 1 }).toISO()?.slice(-5, -3); //Next Day TZ - const diffTZInDay = +nexDay! - +startOfDay!; + const nextDay = startDate.startOf("day").plus({ day: 1 }).toISO()?.slice(-5, -3); //Next Day TZ + const diffTZInDay = +nextDay! - +startOfDay!; let gap = 0; let hrsSpecialCase = 0; @@ -197,11 +197,11 @@ export const onEndTimeRange = ( if (+startOfBeforeDayTz - +intervalStartTZ! !== 0 && +startOfNextDay - +intervalStartTZ! === 0) { const timeOffsett = fromPxToTime(taskDimesion.x - hrsInPx * 23, resolution, columnWidth); - const startTaskMilliss = interval + const startTaskDayBefore = interval .start!.plus({ [resolution.unit]: timeOffsett }) .startOf("hour") .toMillis(); - if (startOfBeforeDay.toMillis() === startTaskMilliss) { + if (startOfBeforeDay.toMillis() === startTaskDayBefore) { hrsSpecialCase = hrs; } } @@ -212,16 +212,16 @@ export const onEndTimeRange = ( gap = hrsInPx * diffTZInDay; } const timeOffsett = fromPxToTime(taskDimesion.x - hrsInPx * 23, resolution, columnWidth); - const startTaskMilliss = interval.start!.plus({ [resolution.unit]: timeOffsett }).startOf("hour"); - if (startOfBeforeDay.toMillis() === startTaskMilliss.toMillis()) { + const startTaskDayBefore = interval.start!.plus({ [resolution.unit]: timeOffsett }).startOf("hour"); + if (startOfBeforeDay.toMillis() === startTaskDayBefore.toMillis()) { if (diffTZInDay !== 0) { gap = 0; hrsSpecialCase = -hrs; } } if ( - startTaskMilliss.toMillis() + hrs * 23 === startDate.startOf("day").toMillis() && - startTaskMilliss.toISO().slice(-5, -3) === intervalStartTZ + startTaskDayBefore.toMillis() + hrs * 23 === startDate.startOf("day").toMillis() && + startTaskDayBefore.toISO().slice(-5, -3) === intervalStartTZ ) { gap = 0; hrsSpecialCase = 0;