diff --git a/components/Venue/venue.js b/components/Venue/venue.js index e3586677..bc24eb5d 100644 --- a/components/Venue/venue.js +++ b/components/Venue/venue.js @@ -3,19 +3,28 @@ import React from 'react'; import Link from 'next/link'; import Image from 'next/image'; -export function isEventEnded(date){ - const eventDate = date.split(" "); - const month = eventDate[0]; - const year = eventDate[eventDate.length-1]; - const startDay = eventDate[1].split("-")[0]; - return new Date(`${startDay} ${month} ${year}`) < Date.now() +export function getEventStatus(date){ + const today = new Date(); + const event = new Date(date); + + if (event.toDateString() === today.toDateString()) { + return "Ongoing"; + } else if (event > today) { + return "Upcoming"; + } else { + return "Ended"; + } } +export function isEventEnded(date){ + return getEventStatus(date) === "Ended"; +} function Venue({ className, city }) { const eventEnded = isEventEnded(city.date); const textColor = eventEnded ? "text-white": "text-white"; + const eventStatus = getEventStatus(city.date); return ( @@ -37,8 +46,8 @@ function Venue({ className, city }) { {city.name=='Online'?{city.name} {city.country}:{city.country}, {city.name}}
-
{city.date}
- {eventEnded ? "ENDED" : ""} +
{city.date}
+ {eventStatus}