From 36574b4643e9bb40cdab69679c93a25f2999b9c2 Mon Sep 17 00:00:00 2001 From: wslyvh Date: Thu, 31 Oct 2024 16:54:03 +0100 Subject: [PATCH] session redirect --- devcon/src/pages/sea/schedule/[code].tsx | 53 ++++-------------------- 1 file changed, 8 insertions(+), 45 deletions(-) diff --git a/devcon/src/pages/sea/schedule/[code].tsx b/devcon/src/pages/sea/schedule/[code].tsx index 6d90f8a00..52f4392fa 100644 --- a/devcon/src/pages/sea/schedule/[code].tsx +++ b/devcon/src/pages/sea/schedule/[code].tsx @@ -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 + useEffect(() => { + router.push(`https://app.devcon.org/schedule/${props.params.code}`) + }, [router, props.params.code]) + + return <> } export async function getStaticPaths() { @@ -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 } )), - }, }, } }