{"size": 1330, "ext": "js", "max_stars_repo_path": "pages/index.js", "max_stars_repo_name": "DavidJones418/swr-spotify-example", "max_stars_repo_stars_event_min_datetime": "2021-02-11T23:27:17.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-27T12:02:26.000Z", "max_issues_repo_path": "pages/index.js", "max_issues_repo_name": "kitibyte/swr-spotify-example", "max_issues_repo_issues_event_min_datetime": "2020-08-19T14:13:54.000Z", "max_issues_repo_issues_event_max_datetime": "2020-10-08T22:29:06.000Z", "max_forks_repo_path": "pages/index.js", "max_forks_repo_name": "DavidJones418/swr-spotify-example", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 8, "max_issues_count": 28, "max_forks_count": null, "avg_line_length": 27.1428571429, "max_line_length": 168, "alphanum_fraction": 0.5789473684}
import { beginLogin } from 'auth/spotify'
import useUser from 'auth/use-user'
import Nav from 'components/nav'
import Router from 'next/router'
import { useEffect } from 'react'
import Head from 'next/head'

export default function Home() {
  const { user } = useUser()

  // if logged in, redirect to the dashboard
  useEffect(() => {
    if (user) {
      Router.replace('/dashboard')
    }
  }, [user])

  return (
    <div className="homepage">
      <Head>
        <title>Please Login</title>
      </Head>

      <Nav title="SWR Spotify Example" />

      <main className="p-2 flex flex-col max-w-xs mx-auto my-4 text-center space-y-4">
        <h1 className="text-4xl">Do something cool with your Spotify data.</h1>
        <br />
        <button
          className="px-4 py-2 rounded-full bg-gradient-to-tr from-pink-600 to-purple-600 text-white font-bold hover:opacity-75 focus:outline-none focus:shadow-outline"
          onClick={async () => {
            await beginLogin()
          }}
        >
          Login with Spotify to continue
        </button>
        <p>
          <a
            className="px-4 py-2 text-blue-600 font-bold hover:underline"
            href="https://github.com/DavidJones418/swr-spotify-example"
          >
            source
          </a>
        </p>
      </main>
    </div>
  )
}
