'use client'

import { usePathname, useRouter } from 'next/navigation'
import { useEffect } from 'react'

export function AccountAuthPrompt(props: { message?: string }) {
  const router = useRouter()
  const pathname = usePathname()

  useEffect(() => {
    router.replace(`/login?redirect=${encodeURIComponent(pathname || '/account')}`)
  }, [pathname, router])

  return (
    <section className="grid min-h-[calc(100vh-160px)] place-items-center bg-bg px-6">
      <div className="text-center">
        {props.message && <div className="mb-2 text-sm font-extrabold text-ink">{props.message}</div>}
        <div className="text-sm font-extrabold text-muted">正在跳转登录...</div>
      </div>
    </section>
  )
}
