import {useSnackbar} from "notistack";

export function useAlert() {
    // variant could be success, error, warning, info, or default
    const {enqueueSnackbar} = useSnackbar();

    function createAlert(message, variant) {
        const options = {
            ...variant,
            anchorOrigin: {vertical: 'top', horizontal: 'right'},
        }
        enqueueSnackbar(message, options);
    }

    function notImplement() {
        createAlert("Данный функционал пока не реализован", {variant: 'warning'});
    }

    function createError(message) {
        createAlert(message, {variant: "error"});
    }

    function getError() {
        createAlert("Ошибка получения данных", {variant: "error"});
    }

    function createSuccess(message) {
        createAlert(message, {variant: "success"});
    }

    return {createAlert, notImplement, createError, getError, createSuccess}
}