//import initialData from '../../initial-data'
import { Timer } from '../../src/timer'
import { useRouter } from 'next/router'
import { useTrainingQuery } from '../../src/gql'
import { Page } from '../../src/app'

const TimerPage = () => {
  const router = useRouter()
  const { id } = router.query

  const { data, error, loading } = useTrainingQuery({
    variables: { id: typeof id === 'string' ? id : id && id[0] },
  })

  if (loading) return <p>Loading data...</p>
  if (error) return <p>Error loading training.</p>

  if (!data?.training) return <p>Training not found.</p>
  else return <Timer training={data.training} />
}

export default TimerPage
