import type { Locale } from "@/i18n/routing";
import { getSiteContent } from "@/lib/site";
import { getTranslations } from "next-intl/server";
import type { SiteContent } from "@prisma/client";

function aboutText(content: SiteContent | null, locale: Locale) {
  if (!content) return "";
  switch (locale) {
    case "ar":
      return content.aboutAr;
    case "ru":
      return content.aboutRu;
    case "it":
      return content.aboutIt;
    default:
      return content.aboutEn;
  }
}

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

export default async function AboutPage({ params }: Props) {
  const { locale } = await params;
  const t = await getTranslations("about");
  const content = await getSiteContent();
  const text = aboutText(content, locale as Locale).trim();

  return (
    <div className="mx-auto max-w-3xl px-4 py-12 md:px-6 md:py-16">
      <h1 className="font-[family-name:var(--font-display)] text-4xl text-foreground">
        {t("title")}
      </h1>
      <div className="mt-8 max-w-none text-base leading-relaxed text-muted">
        {text ? (
          <p className="whitespace-pre-wrap">{text}</p>
        ) : (
          <p>{t("fallback")}</p>
        )}
      </div>
    </div>
  );
}
