Skip to content

Commit

Permalink
session redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
wslyvh committed Oct 31, 2024
1 parent 5dc7edb commit 36574b4
Showing 1 changed file with 8 additions and 45 deletions.
53 changes: 8 additions & 45 deletions devcon/src/pages/sea/schedule/[code].tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from 'react'
import { GetPage } from 'services/page'
import { getGlobalData } from 'services/global'
import { Hero } from 'components/domain/index/hero'
import { APP_CONFIG } from 'utils/config'
import React, { useEffect } from 'react'
import { useRouter } from 'next/router'

const Speaker = (props: any) => {
if (!props.params) return null
const router = useRouter()

return <Hero talk={props.talk} speakerMode></Hero>
useEffect(() => {
router.push(`https://app.devcon.org/schedule/${props.params.code}`)
}, [router, props.params.code])

return <></>
}

export async function getStaticPaths() {
Expand All @@ -18,47 +19,9 @@ export async function getStaticPaths() {
}

export async function getStaticProps(context: any) {
const globalData = await getGlobalData(context)
const page = await GetPage('/404')
const res = await fetch(`https://cfp.ticketh.xyz/api/events/devcon7-sea/talks/${context.params.code}`, {
headers: {
Authorization: `Token ${process.env.PRETALX_API_KEY}`,
},
})

const data = await res.json()
if (!data) {
return {
notFound: true
}
}

let type = 'talk'
if (data.submission_type_id === 36) type = 'lightning Talk'
if (data.submission_type_id === 32) type = 'talk'
if (data.submission_type_id === 41) type = 'panel'
if (data.submission_type_id === 33 || data.submission_type_id === 34 || data.submission_type_id === 40)
type = 'workshop'

console.log('Schedule', context.params.code, data?.title, data?.state)
if (APP_CONFIG.NODE_ENV === 'production' && (data.state !== 'accepted' && data.state !== 'confirmed')) {
return {
notFound: true
}
}

return {
props: {
...globalData,
params: context.params,
page,
talk: {
id: context.params.code,
title: data.title,
type: type,
track: data.track.en,
speakers: data.speakers.map((i: any) => ({ name: i.name, avatar: i.avatar } )),
},
},
}
}
Expand Down

0 comments on commit 36574b4

Please sign in to comment.