stream/index.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-03-05 12:17:51 +00:00
import { h, render } from 'preact'
2021-10-11 13:50:24 +00:00
import { useState } from 'preact/hooks'
import { BrowserRouter, Route, Switch } from 'react-router-dom'
import Main from './app'
import SeriesPage from './src/pages/SeriesPage'
import { useEventApi, useEventCalendar } from './src/hooks/data'
import { useTimeout } from './src/hooks/timerHooks'
import LoaderLayout from './src/pages/LoaderLayout'
const App = () => {
const { data: calData, calLoading } = useEventCalendar()
const { data: seriesDataArray, loading: eventsLoading } = useEventApi()
const [minLoadTimePassed, setMinTimeUp] = useState(false)
useTimeout(() => {
setMinTimeUp(true)
}, 1500)
const seriesData = Object.values(seriesDataArray)
return calLoading || eventsLoading || !minLoadTimePassed ? (
<LoaderLayout />
) : (
<BrowserRouter>
<Switch>
<Route exact path="/" component={Main} />
{seriesData.length ? seriesData.map(series => (
2021-10-11 17:15:09 +00:00
<Route exact path={`/series/${series.slug}`}>
2021-10-11 13:50:24 +00:00
<SeriesPage data={series} />
</Route>)) : null}
</Switch>
</BrowserRouter>
)
}
2021-03-05 12:17:51 +00:00
const appEl = document.getElementById('app')
2021-03-05 12:17:51 +00:00
render(<App />, appEl)