// @Note: This is an effort to mimic basic functions like react-query // import { useState, useEffect } from "react"; // interface FetchResult { // isLoading: boolean; // isSuccess: boolean; // isError: boolean; // data: Data | null; // error: ErrorType | null; // refetch: () => void; // } // interface FetchQueryOptions { // enabled?: boolean; // onSuccess?: (data: Data) => void; // onError?: (error: ErrorType) => void; // } // const useCustomFetchQuery = ( // apiFunction: () => Promise, // options: FetchQueryOptions = {} // ): FetchResult => { // const { enabled = true, onSuccess, onError } = options; // const [isLoading, setIsLoading] = useState(false); // const [isSuccess, setIsSuccess] = useState(false); // const [isError, setIsError] = useState(false); // const [data, setData] = useState(null); // const [error, setError] = useState(null); // const fetchData = async () => { // setIsLoading(true); // setIsSuccess(false); // setIsError(false); // setError(null); // try { // const result = await apiFunction(); // setData(result); // setIsSuccess(true); // if (onSuccess) { // onSuccess(result); // } // } catch (error) { // setError(error as ErrorType); // setIsError(true); // if (onError) { // onError(error as ErrorType); // } // } finally { // setIsLoading(false); // } // }; // const refetch = () => { // fetchData(); // }; // useEffect(() => { // if (enabled) { // fetchData(); // } // }, [enabled]); // return { // isLoading, // isSuccess, // isError, // data, // error, // refetch, // }; // }; // export default useCustomFetchQuery;