import axios from 'axios';
import documentReady from '@assets/js/documentReady';
import googleAnalytics from '@assets/js/googleAnalytics';
import googleTagManager from '@assets/js/googleTagManager';

documentReady(() => {
  const signOutAdmin = document.querySelector('.js-log-in-bar-exit');

  if (signOutAdmin) {
    signOutAdmin.addEventListener('click', async event => {
      event.preventDefault();
      try {
        await axios.post('index.php?route=common/header/logout_admin');
        document.querySelector('.js-log-in-bar').classList.add('hidden');
      } catch (err) {
        console.log(err);
      }
    });
  }

  window.googleAnalytics = googleAnalytics;
  window.googleTagManager = googleTagManager;
});
