import { getTranslations, setRequestLocale } from 'next-intl/server'
import { PageShell } from '@/components/PageShell'
import { RecoverForm } from './RecoverForm'

export default async function RecoverPage({ params }: { params: Promise<{ locale: string }> }) {
  const { locale } = await params
  setRequestLocale(locale)
  const t = await getTranslations('Recover')
  const sections = t.raw('infoSections') as { h: string; lines: string[] }[]

  return (
    <PageShell title={t('title')}>
      <div className="box-content">
        <div className="title-box-content">
          <h2>{t('infoTitle')}</h2>
        </div>
        <div className="body-box-content justified">
          {sections.map((s, i) => (
            <div key={i}>
              <span>{s.h}</span>
              {s.lines.map((l, j) => (
                <p key={j}>{l}</p>
              ))}
              {i < sections.length - 1 && <br />}
            </div>
          ))}
        </div>
      </div>

      <div className="box-content">
        <div className="title-box-content">
          <h2>{t('reqTitle')}</h2>
        </div>
        <div className="body-box-content centered">
          <RecoverForm />
        </div>
      </div>
    </PageShell>
  )
}
