11import React from 'react'
22import { useCalendarStore } from 'store/calendar'
3- import { Client } from '@notionhq/client'
43import { Footer , Header , withTranslations } from 'pages/index'
54import { client } from '../../tina/__generated__/client'
65import { useTina } from 'tinacms/dist/react'
@@ -14,29 +13,13 @@ import RichText from 'lib/components/tina-cms/RichText'
1413import { CMSButtons } from 'common/components/voxel-button/button'
1514import CalendarLayout from 'lib/components/event-schedule-new/layout'
1615import { Separator } from 'lib/components/ui/separator'
17- import { record } from 'zod'
18- import { makeConsoleLogger } from '@notionhq/client/build/src/logging'
16+ import { apiResultToCalendarFormat } from 'lib/components/event-schedule-new/atproto-to-calendar-format'
1917
2018const Argentina = ( props : any ) => {
2119 const { selectedEvent, selectedDay, setSelectedEvent, setSelectedDay } = useCalendarStore ( )
2220 const { data } : { data : any } = useTina ( props . content )
2321
2422 const events = props . events
25- // const events = props.events.map((event: any) => {
26- // const overrides = {} as any
27-
28- // if (event.id === '1f5638cd-c415-809b-8fbd-ec8c4ba7f5b9') {
29- // overrides.name = 'ETH Day'
30- // overrides.isFairEvent = true
31- // overrides.spanRows = 3
32- // }
33-
34- // return {
35- // ...event,
36- // ...overrides,
37- // onClick: () => {},
38- // }
39- // })
4023
4124 return (
4225 < >
@@ -82,41 +65,11 @@ const Argentina = (props: any) => {
8265 />
8366
8467 < div className = "section mb-8 mt-12" >
85- { /* <div className="text-center text-lg">
86- Stay tuned for details on how to submit your event to the calendar - we will be accepting submissions very
87- soon!
88- </div> */ }
8968 < div className = "grid grid-cols-1 md:grid-cols-2 gap-12 my-4 bg-[rgba(116,172,223,0.1)] p-4 md:p-12" >
9069 < RichText content = { data . pages . calendar_how_to_apply } Buttons = { CMSButtons } />
9170 < RichText content = { data . pages . calendar_community_calendar } Buttons = { CMSButtons } />
9271 </ div >
9372 </ div >
94-
95- { /* <div className="text-sm flex flex-col gap-4">
96- <p>
97- <strong>Disclaimer:</strong> This calendar is a work in progress and may change a lot before Devconnect
98- week. Please check back regularly for updates.
99- </p>
100- <div>
101- <p>
102- <strong>Want to be featured on our calendar?</strong> We encourage event hosts to submit their events to
103- atprotocol adhering to the [devcon.org event record type].{' '}
104- <strong>This is not a guarantee of inclusion as we still curate events,</strong> but is a{' '}
105- <strong>requirement</strong> for community events to be considered on our calendar.
106- </p>
107- <p>
108- <strong>How do I submit my event to atprotocol?</strong> ...
109- </p>
110- </div>
111- <p>
112- <strong>Want to build a community calendar? </strong> For your convenience, we collect all events submitted
113- to atprotocol and expose them via{' '}
114- <Link indicateExternal className="bold" href="https://at-slurper.onrender.com/all-events">
115- https://at-slurper.onrender.com/all-events
116- </Link>
117- . You can also use atprotocol directly, as all data is public.
118- </p>
119- </div> */ }
12073 </ div >
12174
12275 < Footer />
@@ -130,165 +83,14 @@ export async function getStaticProps({ locale }: { locale: string }) {
13083 const translationPath = locale === 'en' ? 'global.json' : locale + '/global.json'
13184 const translations = await client . queries . global_translations ( { relativePath : translationPath } )
13285
133- //www.notion.so/ef-events/1f5638cdc41580be9117f4963f021d8b?v=1f5638cdc415816c9277000ccc6cda85&pvs=4
134-
135- const notion = new Client ( {
136- auth : process . env . NOTION_SECRET ,
137- } )
138-
139- const query = {
140- database_id : '1f5638cdc41580be9117f4963f021d8b' ,
141- sorts : [
142- {
143- property : 'Requested event date' ,
144- direction : 'ascending' ,
145- } ,
146- // {
147- // property: '[WEB] Priority (sort)',
148- // direction: 'descending',
149- // },
150- ] ,
151- filter : {
152- and : [
153- {
154- property : 'Requested event date' ,
155- date : {
156- is_not_empty : true ,
157- } ,
158- } ,
159- {
160- property : 'Live in Website' ,
161- checkbox : {
162- equals : true ,
163- } ,
164- } ,
165- ] ,
166- } ,
167- }
168-
169- let notionEvents : any = { results : [ ] }
170-
171- try {
172- notionEvents = await notion . databases . query ( query as any )
173- } catch ( error ) {
174- console . error ( 'Failed to fetch events from Notion:' , error )
175- // Continue with empty events array if Notion API fails
176- }
177-
178- /*
179- export interface Event {
180- id: string;
181- name: string;
182- isFairEvent?: boolean;
183- isCoreEvent?: boolean;
184- description: string;
185- organizer: string;
186- difficulty: string;
187- amountPeople?: string;
188- location: {
189- url: string;
190- text: string;
191- coordinates?: {
192- lat: number;
193- lng: number;
194- };
195- };
196- timeblocks: {
197- start: string;
198- end: string;
199- name?: string;
200- location?: string;
201- }[];
202- priority: number;
203- categories: string[];
204- }
205-
206- */
207-
208- // console.log(notionEvents)
209-
21086 const atprotoEvents = await fetch (
21187 process . env . NODE_ENV === 'development'
21288 ? 'http://localhost:4000/calendar-events'
21389 : 'https://at-slurper.onrender.com/calendar-events'
21490 )
21591 const atprotoEventsData = await atprotoEvents . json ( )
216- // console.log(atprotoEventsData)
217-
218- const formattedAtprotoEvents = atprotoEventsData . map ( ( event : any ) => {
219- const record = event . record_passed_review
220-
221- const timeblocks = [ ]
222-
223- if ( record . start_utc ) {
224- let startDate = moment . utc ( record . start_utc )
225- let endDate
226-
227- if ( record . end_utc ) {
228- endDate = moment . utc ( record . end_utc ) . format ( 'YYYY-MM-DDTHH:mm:ss[Z]' )
229- } else {
230- endDate = startDate . format ( 'YYYY-MM-DDTHH:mm:ss[Z]' )
231- }
232-
233- timeblocks . push ( {
234- start : startDate . format ( 'YYYY-MM-DDTHH:mm:ss[Z]' ) ,
235- end : endDate ,
236- } )
237- }
238-
239- const manualOverrides = { } as any
240-
241- return {
242- id : event . id ,
243- name : record . title ,
244- description : record . description ,
245- startDate : record . start_utc ,
246- endDate : record . end_utc ,
247- location : record . location . name ,
248- difficulty : record . expertise ,
249- organizer : record . organizer . name ,
250- timeblocks : timeblocks ,
251- eventType : record . event_type ,
252- isCoreEvent : event . is_core_event || false ,
253- eventLink : record . main_url ,
254- ...manualOverrides ,
255- }
256- } )
257-
258- // const events = notionEvents.results.map((event: any) => {
259- // const formattedEvent = formatResult(event)
260-
261- // const timeblocks = []
262-
263- // if (formattedEvent['Requested event date']) {
264- // let startDate = moment.utc(formattedEvent['Requested event date'].startDate)
265- // let endDate
266-
267- // if (formattedEvent['Requested event date'].endDate) {
268- // endDate = moment.utc(formattedEvent['Requested event date'].endDate).format('YYYY-MM-DDTHH:mm:ss[Z]')
269- // } else {
270- // endDate = startDate.format('YYYY-MM-DDTHH:mm:ss[Z]')
271- // }
272-
273- // timeblocks.push({
274- // start: startDate.format('YYYY-MM-DDTHH:mm:ss[Z]'),
275- // end: endDate,
276- // })
277- // }
27892
279- // return {
280- // id: event.id,
281- // name: formattedEvent['Event name'] || '',
282- // description: formattedEvent['Description'] || '',
283- // capacity: formattedEvent['Capacity'] || '',
284- // startDate: formattedEvent['Requested event date'],
285- // // size: formattedEvent['Size'],
286- // location: formattedEvent['Location'] || { text: 'TBD', url: '' },
287- // timeblocks: timeblocks,
288- // difficulty: 'Beginner',
289- // organizer: formattedEvent['Organization'] || '',
290- // }
291- // })
93+ const formattedAtprotoEvents = apiResultToCalendarFormat ( atprotoEventsData )
29294
29395 return {
29496 props : {
0 commit comments