import {useChangePasswordMutation, useUpdateUserMutation} from "../../../Api/usersApi.js";
import {useGetRolesQuery} from "../../../Api/rolesApi.js";


const useUpdateUserModalForm = () => {
    const {
        data: roles = [],
        isLoading: isLoadingRoles,
        isError: isErrorRoles,
    } = useGetRolesQuery(undefined, {
        pollingInterval: 60000,
    });

    const [updateUser, {isLoading: isUserUpdating}] = useUpdateUserMutation();
    const [updatePassword, {isLoading: isPasswordUpdating}] = useChangePasswordMutation();

    return {
        roles,
        isLoadingRoles,
        isErrorRoles,
        updateUser,
        updatePassword,
        isUserUpdating,
        isPasswordUpdating,
    };
};

export default useUpdateUserModalForm;