-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03926ce
commit 5708bdd
Showing
7 changed files
with
50 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,37 @@ | ||
import { useEffect, useState } from "react"; | ||
import { useAppDispatch } from "../hooks/hooks"; | ||
import { useAppDispatch, useAppSelector } from "../hooks/hooks"; | ||
import { SetCurrentPage } from "../slices/pageSlice"; | ||
import Events from "./Events"; | ||
import { fetchEventsAsync } from "../thunks/EventThunks"; | ||
import { AppDispatch } from "../stores/store"; | ||
import { CalendarEvent } from "../slices/eventSlice"; | ||
import { CalendarEvent, SetCalendarEvents, selectEvents } from "../slices/eventSlice"; | ||
|
||
export default function EventsPage() | ||
{ | ||
const mainDispatch = useAppDispatch(); | ||
|
||
mainDispatch(SetCurrentPage("/events")); | ||
const events = useAppSelector(selectEvents); | ||
|
||
const [events, setEvents] = useState(new Array<CalendarEvent>()); | ||
mainDispatch(SetCurrentPage("/events")); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
setEvents((await mainDispatch(fetchEventsAsync() as AppDispatch)) as unknown as CalendarEvent[]); | ||
if (events.length < 1) | ||
{ | ||
const fetchedEvents: CalendarEvent[] = (await mainDispatch(fetchEventsAsync() as AppDispatch)) as unknown as CalendarEvent[]; | ||
|
||
mainDispatch(SetCalendarEvents(fetchedEvents)); | ||
} | ||
})(); | ||
}); | ||
}); | ||
|
||
return (<> | ||
<div className={"flex flex-col bg-body-gray items-center grow"}> | ||
<div className="flex flex-col mt-10"> | ||
<div className={"text-[36px] font-bold"}>EVENTS</div> | ||
</div> | ||
<div className="mt-10"><Events Events={events}/></div> | ||
<div className="mt-10"><Events Events={[...events]}/></div> | ||
</div> | ||
</>); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters