import { getLocale } from "next-intl/server";
import { permanentRedirect } from "next/navigation";

import { getSiteSettings } from "@/lib/app-config";
import { getLocalizedPath, resolveLocale } from "@/lib/locale";

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

export default async function PortfolioCategoryIndexPage({
  params,
}: PortfolioCategoryIndexPageProps) {
  await params;
  const siteSettings = await getSiteSettings();
  const localeKey = resolveLocale(await getLocale().catch(() => siteSettings.defaultLocale), siteSettings.defaultLocale);

  permanentRedirect(getLocalizedPath(localeKey, "/portfolio", siteSettings.defaultLocale));
}
