import api from "@/service/api";
import { CmsResponse } from "@/types/TCms";
import { useQuery } from "@tanstack/react-query";
import { useMemo } from "react";
export const cmsService = {
  getCms: async (id: string): Promise<CmsResponse> => {
    try {
      return (await api.get(`cms/${id}`)).data;
    } catch (error) {
      console.log("Error fetching CMS data:", error);
      throw error;
    }
  },
};
export const useGetCms = (pageId: string) => {
  const queryKey = useMemo(() => ["cms", pageId], [pageId]);
  return useQuery({
    queryKey,
    queryFn: () => cmsService.getCms(pageId),
  });
};
