From 089b696719e32bb5b0a649adf8b037fafb623904 Mon Sep 17 00:00:00 2001 From: Kevin Lie Date: Tue, 26 Mar 2024 18:15:19 -0400 Subject: [PATCH] Minor code formatting --- src/hooks/useCalendar.js | 6 ++--- src/hooks/useEvents.js | 54 ++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/hooks/useCalendar.js b/src/hooks/useCalendar.js index 41d984c..d16d39f 100644 --- a/src/hooks/useCalendar.js +++ b/src/hooks/useCalendar.js @@ -75,7 +75,7 @@ const useCalendar = (events) => { [eventsByDateString] ); - return {selectedDate, setSelectedDate, displayedEvents, tileClassName} -} + return { selectedDate, setSelectedDate, displayedEvents, tileClassName }; +}; -export default useCalendar; \ No newline at end of file +export default useCalendar; diff --git a/src/hooks/useEvents.js b/src/hooks/useEvents.js index 27f6b09..ed2c7d5 100644 --- a/src/hooks/useEvents.js +++ b/src/hooks/useEvents.js @@ -2,37 +2,37 @@ import { useState, useEffect } from 'react'; import ical from 'cal-parser'; const useEvents = () => { - const [events, setEvents] = useState([]); + const [events, setEvents] = useState([]); - const fetchData = async () => { - try { - const response = await fetch( - 'https://docs.google.com/document/d/1OcnWWt1qHaJWE-8v_FPtNO8DKviRQ7DMaqylupuvPXE/export?format=txt' - ); - - const content = await response.text(); - return content; - } catch (error) { - return null; - } -}; - -useEffect(() => { - const eventsData = async () => { + const fetchData = async () => { try { - const fetchedData = await fetchData(); - const parsedData = ical.parseString(fetchedData); - return parsedData.events; + const response = await fetch( + 'https://docs.google.com/document/d/1OcnWWt1qHaJWE-8v_FPtNO8DKviRQ7DMaqylupuvPXE/export?format=txt' + ); + + const content = await response.text(); + return content; } catch (error) { - return []; + return null; } }; - eventsData().then((data) => { - setEvents(data); - }); -}, []); - return {events} -} + useEffect(() => { + const eventsData = async () => { + try { + const fetchedData = await fetchData(); + const parsedData = ical.parseString(fetchedData); + return parsedData.events; + } catch (error) { + return []; + } + }; + eventsData().then((data) => { + setEvents(data); + }); + }, []); + + return { events }; +}; -export default useEvents; \ No newline at end of file +export default useEvents;