import type { Metadata } from 'next';
import { LoginForm } from '@/components/auth/AuthForms';
import { safeNext } from '@/lib/auth/roles';
import { getMessages } from '@/i18n/server';

export async function generateMetadata(): Promise<Metadata> {
  return { title: (await getMessages()).auth.login.meta };
}

export default async function LoginPage({ searchParams }: PageProps<'/masuk'>) {
  const t = (await getMessages()).auth.login;
  const next = safeNext((await searchParams).next) ?? undefined;
  return (
    <>
      <h1 className="text-[28px] font-semibold tracking-[-0.02em] text-ink">{t.title}</h1>
      <p className="mt-2 mb-8 text-[15px] text-muted">{t.text}</p>
      <LoginForm next={next} />
    </>
  );
}
