import { useLocation } from "react-router-dom"; import { useQuery } from "@tanstack/react-query"; import { useIntParam, useWant } from "taehui-ts/fe-utility"; import { wwwAXIOS } from "@/Www"; import { GetNoteAPI } from "@/wwwAPI"; import { useNoteStore } from "@/Stores"; import { useIsPath } from "taehui-ts/fe-utility"; export default function useGetNote() { const { viewUnit } = useNoteStore(); const { param: page } = useIntParam("page", 1); const { param: fit } = useIntParam("fit", 0); const { param: src } = useIntParam("src", 0); const { want } = useWant("/note"); const isPath = useIsPath(); return useQuery({ enabled: isPath("/note"), queryKey: ["note", fit, src, want, page, viewUnit], queryFn: async () => { const { data } = await wwwAXIOS.get<GetNoteAPI>("/note", { params: { fit, src, want, page, viewUnit, }, }); return data; }, initialData: { totalCount: 0, highestCount: 0, noteCount: 0, notes: [], }, }); }