export async function fetchPageContent() {
  try {
    const response = await fetch("http://bpms-back.sepehrdata.com/api/select", {
      method: "POST",
      headers: {
        "Content-Type": "application/json;charset=UTF-8",
      },
      body: JSON.stringify({
        ProcessName: "sepehrdata",
        OutputFields: [
          "company_name",
          "company_latin_name",
          "company_introduction",
          "address",
          "mobile1",
          "mobile2",
          "email1",
          "logo",
          "product_introduction",
          "product_introduction_image",
          "location_company",
          "link_social_title1",
          "logo_socail1",
          "link_social_title2",
          "logo_socail2",
          "link_social_title3",
          "logo_socail3",
          "copy_right",
          { slider: ["*"] },
          { service: ["*"] },
          { customer: ["*"] },
        ],
      }),
    });

    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`);
    }

    const data = await response.json();
    console.log("Data received:", data);
    const convertData = JSON.parse(data.data)[0];

    return {
      props: {
        data: convertData,
      },
    };
  } catch (error) {
    console.error("❌ Error fetching data:", error);

    return {
      props: {
        data: null,
        error: "خطا در دریافت داده‌ها",
      },
    };
  }
}
