From de8be84c835d2d6659ad16c1bdbcc460797670e4 Mon Sep 17 00:00:00 2001 From: Monu Date: Sat, 23 Mar 2024 23:54:16 +0530 Subject: [PATCH 1/4] feat: Handle past events --- components/Venue/venue.js | 23 ++++++++++++++++++----- pages/venue/[id].js | 16 +++++++++++----- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/components/Venue/venue.js b/components/Venue/venue.js index 5fdd5b8e..5d344be6 100644 --- a/components/Venue/venue.js +++ b/components/Venue/venue.js @@ -1,26 +1,38 @@ /* eslint-disable react/no-unescaped-entities */ import React from 'react'; + 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() +} + + function Venue({ className, city }) { + + const eventEnded = isEventEnded(city.date); + const textColor = eventEnded ? "text-gray-300": "text-white"; + return (
-
cfp is open
+
cfp is open
-
+
{city.country}, {city.name}
-
-
{city.date}
-
+
{city.date}
+ - {eventEnded ? "ENDED" : "UPCOMING"}
@@ -29,3 +41,4 @@ function Venue({ className, city }) { } export default Venue; +export {isEventEnded} diff --git a/pages/venue/[id].js b/pages/venue/[id].js index 92be3609..d9eecf21 100644 --- a/pages/venue/[id].js +++ b/pages/venue/[id].js @@ -6,6 +6,7 @@ import Heading from '../../components/Typography/heading'; import Paragraph from '../../components/Typography/paragraph'; import speakers from '../../config/speakers.json'; import Sponsors from '../../components/Sponsors/sponsors'; +import { isEventEnded } from '../../components/Venue/venue'; export async function getStaticProps({ params }) { let res = {}; @@ -32,29 +33,34 @@ export async function getStaticPaths() { } function Venue({ city }) { + + const eventEnded = isEventEnded(city.date); + const textColor = eventEnded ? "text-gray-400": "text-white"; + return (
- + {city.name}, {city.country} - {city.description} + {eventEnded &&

ENDED

} + {city.description} - + {city.address} - + {city.date} {city.ended ? "" : } From 5119efa5323a6986c58f7ed96d9bfed95fe3abcc Mon Sep 17 00:00:00 2001 From: Monu <142221687+monoMonu@users.noreply.github.com> Date: Sun, 24 Mar 2024 10:03:25 +0530 Subject: [PATCH 2/4] Update venue.js remove explicit export from Venue/venue.js --- components/Venue/venue.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/Venue/venue.js b/components/Venue/venue.js index 5d344be6..a577d259 100644 --- a/components/Venue/venue.js +++ b/components/Venue/venue.js @@ -1,7 +1,7 @@ /* eslint-disable react/no-unescaped-entities */ import React from 'react'; - function isEventEnded(date){ +export function isEventEnded(date){ const eventDate = date.split(" "); const month = eventDate[0]; const year = eventDate[eventDate.length-1]; @@ -41,4 +41,3 @@ function Venue({ className, city }) { } export default Venue; -export {isEventEnded} From f5eb45c3f83c76e3f5e00ff77724f05310551556 Mon Sep 17 00:00:00 2001 From: Monu <142221687+monoMonu@users.noreply.github.com> Date: Tue, 9 Jul 2024 00:03:46 +0530 Subject: [PATCH 3/4] remove "upcoming" tag --- components/Venue/venue.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Venue/venue.js b/components/Venue/venue.js index c96f2394..f686e812 100644 --- a/components/Venue/venue.js +++ b/components/Venue/venue.js @@ -34,7 +34,7 @@ function Venue({ className, city }) { {city.country}, {city.name}
{city.date}
- - {eventEnded ? "ENDED" : "UPCOMING"} + - {eventEnded ? "ENDED" : ""}
From 8f1d6a409b7fe92557e797ed1e5b2c499485156d Mon Sep 17 00:00:00 2001 From: Monu Date: Wed, 28 Aug 2024 23:41:11 +0530 Subject: [PATCH 4/4] fix event text visibility issue --- components/Venue/venue.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/Venue/venue.js b/components/Venue/venue.js index f686e812..ff21997a 100644 --- a/components/Venue/venue.js +++ b/components/Venue/venue.js @@ -15,11 +15,11 @@ export function isEventEnded(date){ function Venue({ className, city }) { const eventEnded = isEventEnded(city.date); - const textColor = eventEnded ? "text-gray-300": "text-white"; + const textColor = eventEnded ? "text-white": "text-white"; return ( -
@@ -33,8 +33,10 @@ function Venue({ className, city }) {
{city.country}, {city.name}
-
{city.date}
- - {eventEnded ? "ENDED" : ""} +
+
{city.date}
+ {eventEnded ? "ENDED" : ""} +