import { useQuery } from "@tanstack/react-query";
import { useLocation } from "react-router-dom";

import { wwwAXIOS } from "src/Www";
import { GetEtcAPI } from "src/wwwAPI";

export default function useGetEtc() {
  const { pathname } = useLocation();

  return useQuery({
    enabled: pathname.startsWith("/qwilight/etc"),
    queryKey: ["etc"],
    queryFn: async () => {
      const { data } = await wwwAXIOS.get<GetEtcAPI>("/etc");
      return data;
    },
    initialData: {
      totalDateSet: [],
      totalDateValues: [],
      signUpDateSet: [],
      signUpDateValues: [],
      avatarDateSet: [],
      avatarDateValues: [],
      totalNoteFiles: [],
      totalTitles: [],
      totalEdges: [],
      favorites: [],
      favoritesAt: [],
      inputModes: [],
      autoModes: [],
      noteSaltModes: [],
      faintNoteModes: [],
      judgmentModes: [],
      hitPointsModes: [],
      noteMobilityModes: [],
      longNoteModes: [],
      inputFavorModes: [],
      noteModifyModes: [],
      lowestJudgmentConditionModes: [],
    },
  });
}
