// import axiosInstanceServer from "@/utils/axios";
// import { AxiosError } from "axios";
// import React from "react";
// type Method = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
// interface SingleRequest<T> {
//   method: Method;
//   url: string;
//   children: (data: T) => React.ReactNode;
// }
// interface MultiRequest<T> {
//   requests: Array<{
//     method: Method;
//     url: string;
//     key: keyof T;
//   }>;
//   children: (data: T) => React.ReactNode;
// }
// type GeneralAxiosPageProps<T> =
//   | Omit<SingleRequest<T>, "children">
//   | Omit<MultiRequest<T>, "children">;
// function isMultiRequest<T>(
//   props: GeneralAxiosPageProps<T>
// ): props is Omit<MultiRequest<T>, "children"> {
//   return "requests" in props;
// }
// export default async function GeneralAxiosPage<T>({
//   children,
//   ...props
// }: GeneralAxiosPageProps<T> & { children: (data: T) => React.ReactNode }) {
//   try {
//     if (isMultiRequest(props)) {
//       const responses = await Promise.all(
//         props.requests.map(({ method, url }) =>
//           method.toLocaleUpperCase() === "GET"
//             ? axiosInstanceServer.get<{ data: any }>(url)
//             : method === "POST"
//             ? axiosInstanceServer.post<{ data: any }>(url)
//             : method === "PUT"
//             ? axiosInstanceServer.put<{ data: any }>(url)
//             : method === "DELETE"
//             ? axiosInstanceServer.delete<{ data: any }>(url)
//             : axiosInstanceServer.patch<{ data: any }>(url)
//         )
//       );
//       const data = responses.reduce(
//         (acc, response, index) => ({
//           ...acc,
//           [props.requests[index].key]: response.data.data,
//         }),
//         {} as T
//       );
//       return <>{children(data)}</>;
//     } else {
//       const res = await (props.method === "GET"
//         ? axiosInstanceServer.get<{ data: T }>(props.url)
//         : props.method === "POST"
//         ? axiosInstanceServer.post<{ data: T }>(props.url)
//         : props.method === "PUT"
//         ? axiosInstanceServer.put<{ data: T }>(props.url)
//         : props.method === "DELETE"
//         ? axiosInstanceServer.delete<{ data: T }>(props.url)
//         : axiosInstanceServer.patch<{ data: T }>(props.url));
//       return <>{children(res.data.data)}</>;
//     }
//   } catch (error) {
//     if (error instanceof AxiosError) {
//       return (
//         <div className="error">
//           {error.response?.data?.message || error.message || "An error occurred"}
//         </div>
//       );
//     }
//     return <div className="error">An unexpected error occurred</div>;
//   }
// }
// {
//   /*  <GeneralAxiosPage<HomeData>
//       method="GET"
//       url="/api/home"
//     >
//       {(data) => (
//         <div className="overflow-x-hidden home-page">
//           <HeroSection sliders={data.sliders} />
//           <Offers offers={data.offers} />
//           </div>
//         )}
//       </GeneralAxiosPage>; */
// }
// {
//   /*  <GeneralAxiosPage<HomeData>
//       requests={[
//         { method: "GET", url: "/api/sliders", key: "sliders" },
//         { method: "GET", url: "/api/offers", key: "offers" },
//         { method: "GET", url: "/api/discovers", key: "discovers" }
//       ]}
//     >
//       {(data) => (
//         <div className="overflow-x-hidden home-page">
//           <HeroSection sliders={data.sliders} />
//           <Offers offers={data.offers} />
//           </div>
//         )}
//       </GeneralAxiosPage> */
// }