-
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
d3856e2
commit a1b1d79
Showing
8 changed files
with
2,949 additions
and
14 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
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,16 +1,16 @@ | ||
import { CalendarEvent } from "../slices/eventSlice"; | ||
import EventInstance from "./Event"; | ||
|
||
interface EventsProps | ||
{ | ||
Events: CalendarEvent[]; | ||
} | ||
|
||
export default function Events() | ||
export default function Events({Events} : EventsProps) | ||
{ | ||
return (<div className={"flex flex-col w-full max-[600px]:flex-col flex-wrap items-center gap-5"}> | ||
<EventInstance Event={{ | ||
Title: "Board Games Social", | ||
Start: new Date(), | ||
End: new Date(Date.now() + 100000000), | ||
Description: "Event description", | ||
Location: "T001", | ||
Image: "https://langaracpsc.github.io/assets/social.png" | ||
}}/> | ||
{ | ||
Events.map(event => <EventInstance Event={event}/>) | ||
} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,32 @@ | ||
import { useEffect, useState } from "react"; | ||
import { useAppDispatch } 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"; | ||
|
||
export default function EventsPage() | ||
{ | ||
const mainDispatch = useAppDispatch(); | ||
|
||
mainDispatch(SetCurrentPage("/events")); | ||
|
||
const [events, setEvents] = useState(new Array<CalendarEvent>()); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
setEvents((await mainDispatch(fetchEventsAsync() as AppDispatch)) as unknown as CalendarEvent[]); | ||
console.log(events); | ||
})(); | ||
}); | ||
|
||
return (<> | ||
<div className={"flex flex-col h-[100vh] max-[600px]: h-[90vh] 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/></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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { CalendarEvent } from "../slices/eventSlice"; | ||
import { AppDispatch, RootState } from "../stores/store"; | ||
|
||
export const fetchEventsAsync = () => async (state: RootState, dispatch: AppDispatch) => { | ||
const response = await (await (fetch(`https://${process.env.CALENDAR_BASE_URL}/calendars/${process.env.CALENDER_ID}&key=${process.env.CALENDAR_API_KEY}`, | ||
{ | ||
method: "GET", | ||
headers: { | ||
"Authorization": `Bearer ${process.env.CALENDAR_OAUTH_TOKEN}` | ||
} | ||
}))).json(); | ||
|
||
console.log(response); | ||
|
||
return response["items"].map((item: any) => { | ||
return { | ||
Title: item.summary, | ||
Start: new Date(item.start.dateTime), | ||
End: new Date(item.end.dateTime), | ||
Description: item.summary, | ||
Location: "T001", | ||
Image: "https://langaracpsc.github.io/assets/social.png" | ||
} as CalendarEvent; | ||
}); | ||
}; |
Oops, something went wrong.