import React from "react";
import LawyerPage from "@comp/LawyerPage/page";
import dataInfo from "../../../../dataLawyers.json";

async function getData(id) {
  const lawyer = dataInfo.find((lawyer) => lawyer.id === id);
  return lawyer;
}

export async function generateMetadata({ params }) {
  const data = await getData(params.slug[0]);

  console.log(data);

  const metadataUrl = new URL(
    `lawyers/${params.slug[0]}/${data?.product?.persianName}`,
    process.env.NEXT_PUBLIC_APP_URL
  );
  return {
    title: data?.name,
    description: `${data?.description}`,
    metadataBase: metadataUrl,
    keywords: [
      "بهترین وکیل تهران",
      "بهترین وکیل چک تهران",
      "بهترین وکیل ساختمان در تهران",
      "وکیل سایبری در تهران",
      "وکیل سایبری در تهران",
    ],

    openGraph: {
      title: data?.name,
      description: `${data?.description}`,
      url: metadataUrl,
      type: "website",
      locale: "fa-IR",
      type: "website",
    },
  };
}

const page = async ({ params }) => {
  const data = await getData(params.slug[0]);

  return <LawyerPage data={data} />;
};

export default page;
