import Typography from "@/shared/ui/components/Typography/Typography";
import "./AboutUs.scss";
import { Metadata } from "next";
import BreadCrumbs from "@/features/BreadCrumbs/BreadCrumbs";
import { apiInstance } from "@/shared/config/apiConfig";
import { IMetatag } from "@/shared/types/metatag-type";
import { useTranslations } from "next-intl";
export async function generateMetadata(): Promise<Metadata> {
  const data = await apiInstance
    .get<IMetatag[]>("/metatags/")
    .then((res) => res.data)
    .catch((e) => console.log(e));

  if (!data)
    return {
      title: "KG ROAD | О нас",
      description:
        "Transparency International - Кыргызстан - филиал международной организации Transparency International в Кыргызской Республике.",
      openGraph: {
        title: "KG ROAD | О нас",
        description:
          "Transparency International - Кыргызстан - филиал международной организации Transparency International в Кыргызской Республике.",
      },
    };

  const metadata = data.filter((tag) => tag.page === "about-us")[0];
  if (!metadata) {
    return {
      title: "KG ROAD | О нас",
      description:
        "Transparency International - Кыргызстан - филиал международной организации Transparency International в Кыргызской Республике.",
      openGraph: {
        title: "KG ROAD | О нас",
        description:
          "Transparency International - Кыргызстан - филиал международной организации Transparency International в Кыргызской Республике.",
      },
    };
  }

  return {
    title: `KG ROAD | ${metadata.title}`,
    description: metadata.description,
    keywords: metadata.keywords.split(","),
    openGraph: {
      title: `KG ROAD | ${metadata.title}`,
      description: metadata.description,
      type: "website",
    },
  };
}

const AboutUs = () => {
  const t = useTranslations("about_us");
  return (
    <div className="about-us page-padding">
      <BreadCrumbs homeRequired />
      <Typography element="h2">{t("name")}</Typography>

      <div className="about-us__descriptions">
        <h3>
          {t("description1")}
        </h3>
        <h3>{t("description2")}
          {t("description3")}</h3>
        <h3>{t("description4")}</h3>
      </div>
    </div>
  );
};

export default AboutUs;
