import '../styles/globals.css'
import type { AppProps } from 'next/app'
import Head from 'next/head'
import { Amplify } from 'aws-amplify'
import '@aws-amplify/ui-react/styles.css'
import useEnv from '../lib/useEnv'

function MyApp({ Component, pageProps }: AppProps) {
  const { env } = useEnv()
  if (!env) return <>Loading...</>

  Amplify.configure({
    Auth: {
      userPoolId: env.cognitoUserPoolId,
      userPoolWebClientId: env.cognitoUserPoolWebClientId,
    },
  })

  return (
    <>
      <Head>
        <title>Create Next App</title>
        <meta name="description" content="Generated by create next app" />
        <link rel="icon" href="/favicon.ico" />
      </Head>

      <Component {...pageProps} />
    </>
  )
}

export default MyApp
