// Root — URL `/`. The auth app has no landing of its own; send visitors to
// /login (preserving any `?next=`/`?token=` query so a deep link survives).
import type { ReactNode } from 'react'
import { useEffect } from 'react'
import type { PageMeta } from '@voltro/web'
import { T } from '@voltro/i18n'
import { AuthShell } from '../components/AuthShell'
import { getCatalog } from '../locales'

export const renderMode = 'static' as const

export const meta = ({ locale }: { readonly locale: string }): PageMeta => ({
  title: getCatalog(locale)['meta.login.title'],
})

export default function Index(): ReactNode {
  useEffect(() => {
    const search = window.location.search
    window.location.replace(`/login${search}`)
  }, [])
  return (
    <AuthShell titleId="login.title">
      <p className="muted"><a href="/login"><T id="login.submit" /></a></p>
    </AuthShell>
  )
}
