import Auth from '../components/auth'

// This is the HOC
function withAuth(WrappedComponent: React.FunctionComponent) {
  // Return a new component
  function withAuth(pageProps) {
    // Render the WrappedComponent with additional props
    return (
      <Auth>
        <WrappedComponent {...pageProps} />
      </Auth>
    )
  }

  withAuth.displayName = `withAuth(${WrappedComponent.displayName}`

  return withAuth
}

export default withAuth
