Skip to content

Commit

Permalink
Fixed the suggesions
Browse files Browse the repository at this point in the history
  • Loading branch information
MamounE1 committed Oct 8, 2024
1 parent 846c57d commit 0fa39ba
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/components/events/EventTimeAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
differenceInMinutes,
} from 'date-fns';
import { type ReactNode } from 'react';
import {useState, useEffect} from 'react';

type EventTimeAlertProps = {
event: SelectEvent;
Expand All @@ -24,16 +25,16 @@ const Base = ({ children, className }: BaseProps) => {
);
};

import React, {useState, useEffect} from 'react';


const EventTimeAlert = ({ event }: EventTimeAlertProps) =>
{
const [now, setNow] = useState(new Date());
const [now, setNow] = useState(Date.now());

useEffect(() => {
const intervalId = setInterval(() =>
{
setNow (new Date());
setNow (Date.now());
}, 1000);

return () => clearInterval(intervalId);
Expand All @@ -43,9 +44,9 @@ const EventTimeAlert = ({ event }: EventTimeAlertProps) =>
const start = event.startTime;
const hourDiff = differenceInHours(start, now);

if (event.startTime.getTime() < Date.now())
if (event.startTime.getTime() < now)
{
if (event.endTime.getTime() < Date.now())
if (event.endTime.getTime() < now)
{
return <Base className="bg-red-600">over :(</Base>;
}
Expand Down

0 comments on commit 0fa39ba

Please sign in to comment.