import { GET_PERMISSIONS_ROUTE } from "@/core/utils/routes";
import useSWR from "swr";
import useRequest from "./useRequest";

export const usePermissions = () => {
    const request = useRequest();

    const fetcher = async (url) => {
        try {
            const response = await request(url);
            return response.data.data;
        } catch (error) {
            throw new Error();
        }
    };

    return useSWR(GET_PERMISSIONS_ROUTE, fetcher, { keepPreviousData: true });
};
