import { useQuery } from "@pinia/colada";
import { useApi } from "~/composables/useApi";
import type { AxiosResponse } from "axios";

export function useServicesQuery() {
  const { get } = useApi();
  const { locale } = useI18n();

  return useQuery({
    staleTime: 1000 * 60 * 60,
    key: computed(() => ["services", locale.value]),
    query: async () => {
      try {
        const response = (await get("services")) as AxiosResponse;
        return response.data.data;
      } catch (error: any) {
        console.error(error.message);
      }
    },
  });
}
