import useSWR from "swr";
import RoleService from "../services/RoleService";
import UserService from "../services/UserService";

export function useRoles() {
    const { data, error, isLoading } = useSWR(`/auth/roles`, RoleService.getRoles)

    return {
        roles: data?.data,
        isLoading,
        isError: error
    }
}

export function useUsers() {
    const { data, error, isLoading } = useSWR(`/auth/user`, UserService.getUsers)

    return {
        users: data?.data,
        isLoading,
        isError: error
    }
}