// @Note: This is an effort to mimic basic functions like react-query // import { useState } from "react"; // interface MutationResult { // isLoading: boolean; // isSuccess: boolean; // isError: boolean; // data: Data | null; // error: ErrorType | null; // mutate: (props?: any) => Promise; // } // const useCustomMutation = ( // mutationFunction: (props?: any) => Promise, // options?: { // onSuccess?: (data: Data) => void; // onError?: (error: ErrorType) => void; // } // ): MutationResult => { // 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 mutate = async (props?: any) => { // setIsLoading(true); // setIsSuccess(false); // setIsError(false); // setError(null); // setData(null); // try { // const result = await mutationFunction(props); // setData(result); // setIsSuccess(true); // if (options?.onSuccess) { // options.onSuccess(result); // } // } catch (error) { // setError(error as ErrorType); // setIsError(true); // if (options?.onError) { // options.onError(error as ErrorType); // } // } finally { // setIsLoading(false); // } // }; // return { // isLoading, // isSuccess, // isError, // data, // error, // mutate, // }; // }; // export default useCustomMutation;