From 0f33ed08ce03e4de22582653f11208fa2788d68c Mon Sep 17 00:00:00 2001 From: jainsujay02 Date: Fri, 1 Sep 2023 13:30:30 +0530 Subject: [PATCH 1/4] Added goat-counter analytics --- pages/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pages/index.js b/pages/index.js index bdd8d9be..ebfb6b2f 100644 --- a/pages/index.js +++ b/pages/index.js @@ -12,6 +12,8 @@ import SocialMedia from '../components/SocialMedia'; import data from '../data'; function Home () { + const { carousel, committees, news } = data; return ( From ce54e5adca44f47af64b5f8c041b71f6531ab3c5 Mon Sep 17 00:00:00 2001 From: jainsujay02 Date: Fri, 1 Sep 2023 13:36:07 +0530 Subject: [PATCH 2/4] Linting fix --- pages/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pages/index.js b/pages/index.js index ebfb6b2f..92589bf5 100644 --- a/pages/index.js +++ b/pages/index.js @@ -1,6 +1,7 @@ import { NextSeo } from 'next-seo'; import Link from 'next/link'; import React from 'react'; +import Head from 'next/head'; import Banner from '../components/Banner'; import Carousel from '../components/Carousel'; @@ -11,12 +12,17 @@ import Article from '../components/NewsArticle'; import SocialMedia from '../components/SocialMedia'; import data from '../data'; + function Home () { - const { carousel, committees, news } = data; return ( + + + Date: Fri, 1 Sep 2023 13:54:08 +0530 Subject: [PATCH 3/4] Added error handling to see if it fixes build pr issues --- pages/events.js | 55 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/pages/events.js b/pages/events.js index 0876043d..177d5803 100644 --- a/pages/events.js +++ b/pages/events.js @@ -31,7 +31,23 @@ const getEventClassByEvent = (event) => { function Events({ events }) { const [activeEvent, setActiveEvent] = useState(null); - const [indexedEvents, setIndexedEvents] = useState(events.map((event, index) => ({...event, id: index}))); + + const [indexedEvents, setIndexedEvents] = useState(() => { + // Check if events exist and have the expected structure + if (!Array.isArray(events)) return []; + return events.map((event, index) => ({...event, id: index})); + }); + + // Handle changes from Filters + const handleFilteredEvents = (newEvents) => { + // Validate newEvents before updating + if (Array.isArray(newEvents)) { + setIndexedEvents(newEvents); + } else { + // Optional: Handle unexpected newEvents format (maybe set to an empty array or log an error) + setIndexedEvents([]); + } + }; return ( @@ -58,7 +74,8 @@ function Events({ events }) {

- setIndexedEvents(newEvents)}/> + + {indexedEvents.length ? ( // Check if we have events to show + ) : ( +

No events available at the moment. Please check back later.

+ )}
@@ -94,19 +114,24 @@ function Events({ events }) { } export const getStaticProps = async () => { - const events = await getAllEvents(); - // Attempt to replace new lines with
, doesnt work - // const processedEvents = events.map((event) => ( - // {...event, description: <>{event.description.replace(/\n/g, '
')}})); - // console.log(processedEvents); - - return { - props: { - events: events, - }, - - revalidate: 3600, - }; + try { + const events = await getAllEvents(); + return { + props: { + events: events, + }, + revalidate: 3600, + }; + } catch (error) { + console.error("Failed to fetch events:", error.message); + return { + props: { + events: [], // Return empty array as fallback + }, + revalidate: 3600, + }; + } }; export default Events; + From fdaeb7176a8f673e4dd084062d138b9c5b799bc7 Mon Sep 17 00:00:00 2001 From: jainsujay02 Date: Fri, 1 Sep 2023 13:57:17 +0530 Subject: [PATCH 4/4] linting fix --- pages/events.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pages/events.js b/pages/events.js index 177d5803..ae91eb13 100644 --- a/pages/events.js +++ b/pages/events.js @@ -123,7 +123,8 @@ export const getStaticProps = async () => { revalidate: 3600, }; } catch (error) { - console.error("Failed to fetch events:", error.message); + // eslint-disable-next-line no-console + console.error('Failed to fetch events:', error.message); return { props: { events: [], // Return empty array as fallback