"use strict";

exports.__esModule = true;
exports.default = void 0;

var _react = require("react");

var _api = require("subfirelib/api");

var _hooks = require("subfirelib/hooks");

var _notistack = require("notistack");

function useLoginSnacker() {
  const {
    loginState
  } = (0, _hooks.useSubsonic)();
  const {
    enqueueSnackbar,
    closeSnackbar
  } = (0, _notistack.useSnackbar)();
  const snackRef = (0, _react.useRef)();
  (0, _react.useEffect)(() => {
    if (snackRef.current) {
      closeSnackbar(snackRef.current);
      snackRef.current = null;
    }

    if (loginState === _api.loginStates.notLoggedIn) {
      snackRef.current = enqueueSnackbar('Logged Out', {
        variant: 'error'
      });
    }

    if (loginState === _api.loginStates.partiallyLoggedIn) {
      snackRef.current = enqueueSnackbar('Login Partialy Successful', {
        variant: 'warning'
      });
    } else if (loginState === _api.loginStates.fullyLoggedIn) {
      snackRef.current = enqueueSnackbar('Login Successful', {
        variant: 'success'
      });
    }
  }, [enqueueSnackbar, closeSnackbar, loginState]);
}

var _default = useLoginSnacker;
exports.default = _default;