-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create new events page (#1014)
* feat: create new events page * chore: add params for pagination
- Loading branch information
1 parent
3a03290
commit ac96a26
Showing
5 changed files
with
68 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ComponentWrapperPage } from '@/components/near-org/ComponentWrapperPage'; | ||
import { useBosComponents } from '@/hooks/useBosComponents'; | ||
import { useDefaultLayout } from '@/hooks/useLayout'; | ||
import type { NextPageWithLayout } from '@/utils/types'; | ||
|
||
import { fetchEventsList } from '@/utils/events'; | ||
|
||
const EventsPage: NextPageWithLayout = () => { | ||
const components = useBosComponents(); | ||
return ( | ||
<ComponentWrapperPage | ||
src={components.eventsPage} | ||
meta={{ | ||
title: 'NEAR | Events', | ||
description: 'Join NEAR for one of our upcoming in-person, virtual, or hybrid events.', | ||
}} | ||
componentProps={{ | ||
fetchEventsList, | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
EventsPage.getLayout = useDefaultLayout; | ||
|
||
export default EventsPage; |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { eventsApiUrl, eventsApiKey } from './config'; | ||
|
||
type EventData = { | ||
api_id: string; | ||
event: { | ||
api_id: string; | ||
name: string; | ||
start_at: string; | ||
cover_url: string; | ||
url: string; | ||
}; | ||
}; | ||
|
||
type EventsListData = { | ||
entries: EventData[]; | ||
hasMore: boolean; | ||
}; | ||
|
||
export const fetchEventsList = async (limit: number, offset: number): Promise<EventsListData> => { | ||
const queryLimit = `pagination_limit=${limit ?? 10}`; | ||
const queryOffset = offset ? `pagination_offset=${offset}` : ''; | ||
const queryParams = `${queryLimit}${queryOffset ? `&${queryOffset}` : ''}`; | ||
const res = await fetch(`${eventsApiUrl}/calendar/list-events?${queryParams}`, { | ||
method: 'GET', | ||
headers: { | ||
accept: 'application/json', | ||
'x-luma-api-key': eventsApiKey as string, | ||
}, | ||
}); | ||
|
||
if (!res.ok) { | ||
throw new Error('Failed to fetch data'); | ||
} | ||
|
||
const data = (await res.json()) as { entries: EventData[]; has_more: boolean }; | ||
return { entries: data.entries, hasMore: data.has_more }; | ||
}; |