import { LanguageSwitcher } from '../../../components/language-switcher';
import { ResetPasswordCard } from '../../../components/reset-password-card';
import { fetchPasswordResetRequest } from '../../../lib/api';
import { getDictionary, getLocale } from '../../../lib/i18n';

type Props = {
  params: Promise<{ token: string }>;
};

export default async function ResetPasswordPage({ params }: Props) {
  const { token } = await params;
  const locale = await getLocale();
  const dict = await getDictionary();
  const resetRequest = await fetchPasswordResetRequest(token);

  return (
    <ResetPasswordCard
      token={token}
      resetRequest={resetRequest}
      languageSwitcher={
        <LanguageSwitcher
          currentLocale={locale}
          label={dict.common.language}
          englishLabel={dict.common.english}
          indonesianLabel={dict.common.indonesian}
          submitLabel={dict.common.save}
          variant="compact"
        />
      }
    />
  );
}
