import useRequest from "@/lib/app/hooks/useRequest";
import useSWR from "swr";
import {GET_PERMISSIONS_LIST} from "@/core/data/apiRoutes";

const usePermissions = () => {
    const requestServer = useRequest({auth: true, notification: false})
    const fetcher = (...args) => {
        return requestServer(args, 'get').then((response) => {
            return response.data.data;
        }).catch(() => {
        })
    };

    const {data, isLoading} = useSWR(GET_PERMISSIONS_LIST, fetcher, {
        revalidateIfStale: false,
        revalidateOnFocus: false,
        revalidateOnReconnect: false,
        keepPreviousData : true
    })
    const permissions_list = data
    //swr config

    // render data
    return {permissions_list, isLoading}
}
export default usePermissions;