import Router from 'preact-router'
import { route } from 'preact-router'

import { render } from 'preact'
import { useEffect } from 'preact/hooks'
import { DashboardPage, JobsPage } from './pages.jsx'

const Redirect = ({ to }) => {
    useEffect(() => {
        route(to, true)
    }, [])

    return (
        <>
            Redirecting to <pre>{to}</pre>...
        </>
    )
}

const App = () => {
    return (
        <Router>
            <DashboardPage path="/dashboard" />
            <JobsPage path="/jobs" />
            <Redirect default to="/dashboard" />
        </Router>
    )
}

render(<App />, document.body)
