Skip to content

Commit 62c26a6

Browse files
committed
showing time
1 parent 0e5e136 commit 62c26a6

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

src/components/molecules/EventDisplay/EventDisplay.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from "react";
1+
import React, { useState, useMemo } from "react";
22
import { format } from "date-fns";
33

44
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
@@ -9,7 +9,7 @@ import classNames from "classnames";
99

1010
import { AnyVenue, VenueEvent } from "types/venues";
1111

12-
import { getCurrentTimeInUTCSeconds, formatHour } from "utils/time";
12+
import { getCurrentTimeInUTCSeconds, formatHour, getMinutes } from "utils/time";
1313
import { WithId } from "utils/id";
1414

1515
import "./EventDisplay.scss";
@@ -32,18 +32,29 @@ export const EventDisplay: React.FC<EventDisplayProps> = ({ event, venue }) => {
3232
});
3333

3434
const starHour = formatHour(event.start_utc_seconds);
35+
3536
const oneHourBehind = format(
3637
new Date().setHours(new Date().getHours() - 1),
3738
"HH"
3839
);
3940
const duration = Math.floor(event.duration_minutes / 60);
4041
const beginnigToShow = Number(starHour) - Number(oneHourBehind);
4142

43+
const currentMinutes = getMinutes(getCurrentTimeInUTCSeconds());
44+
45+
const timeToShow = useMemo(() => {
46+
const minutesShowing =
47+
currentMinutes >= 1020 ? 1020 : (new Date().getHours() - 1) * 60;
48+
const startTime = getMinutes(event.start_utc_seconds);
49+
50+
return startTime - minutesShowing;
51+
}, [currentMinutes, event.start_utc_seconds]);
52+
4253
return (
4354
<div
4455
className={containerClasses}
4556
style={{
46-
marginLeft: `${beginnigToShow * 200 + 52}px`,
57+
marginLeft: `${timeToShow * 3.33 + 90}px`,
4758
width: `${
4859
beginnigToShow * 200 + 100 + duration * 200 > 4800
4960
? 4800 - (Number(beginnigToShow) * 200 + 100)

src/components/organisms/SchedulePageModal/SchedulePageModal.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,25 @@ export const SchedulePageModal: FC<SchedulePageModalProps> = ({
160160
const descriptionText = hasParentVenue
161161
? parentVenue?.config?.landingPageConfig.description
162162
: currentVenue?.config?.landingPageConfig.description;
163-
const currentMinutes = getMinutes(getCurrentTimeInUTCSeconds()) - 60;
163+
164+
const currentMinutes = getMinutes(getCurrentTimeInUTCSeconds());
164165

165166
const hours = hoursOfTheDay(
166167
eachHourOfInterval({
167-
start: new Date().setHours(new Date().getHours() - 1),
168+
start: new Date().setHours(
169+
currentMinutes >= 1020 ? 17 : new Date().getHours() - 1
170+
),
168171
end: endOfDay(new Date()),
169172
})
170173
);
174+
175+
const timeToShow = useMemo(() => {
176+
const minutesShowing =
177+
currentMinutes >= 1020 ? 1020 : (new Date().getHours() - 1) * 60;
178+
179+
return currentMinutes - minutesShowing;
180+
}, [currentMinutes]);
181+
171182
const dailyHours = useMemo(() => {
172183
return hours.map((date, index) => (
173184
<EventTimeSchedule key={`${index}-${date}`} time={date} />
@@ -211,7 +222,7 @@ export const SchedulePageModal: FC<SchedulePageModalProps> = ({
211222
<div
212223
className="current-time-line"
213224
style={{
214-
left: `${currentMinutes * 0.3 + 390}px`,
225+
left: `${timeToShow * 3.33 + 300}px`,
215226
height: `${roomsWithEvents * 160 - 40}px`,
216227
}}
217228
></div>

0 commit comments

Comments
 (0)