Skip to content

Commit

Permalink
refactor: 💡 Code refactored
Browse files Browse the repository at this point in the history
✅ Closes: #210
  • Loading branch information
CrisGrud committed Mar 12, 2024
1 parent 10fa9a6 commit 13e9814
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/KonvaTimeline/line-scenario.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export const Line: Story = {
label: "Task2",
resourceId: "2",
time: {
start: 1700434800000,
end: 1700934800000,
start: 1699900000000,
end: 1700048000000,
},
relatedTasks: ["5"],
},
Expand All @@ -88,8 +88,8 @@ export const Line: Story = {
label: "Task5",
resourceId: "1",
time: {
start: 1701505200000,
end: 1702095200000,
start: 1700505200000,
end: 1700805200000,
},
},
],
Expand Down
16 changes: 8 additions & 8 deletions src/tasks/utils/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}
Expand All @@ -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;
Expand Down

0 comments on commit 13e9814

Please sign in to comment.