import axios from "axios";
import { generateSlug } from "./slug";

export async function generateStaticParams() {
  try {
    await axios.get("https://admin.promtechno.uz/api/products/").then((res) => {
      console.log("all data: ", res?.data);
      const allData = res?.data || [];
      return allData.map((product: any) => ({
        slug: generateSlug(product.name_uz),
      }));
    });
  } catch (error) {
    console.error("Error in generateStaticParams:", error);
    return []; // Xato bo'lsa bo'sh array qaytarish
  }
}
