const emailInput = document.querySelector('#email');
const passwordInput = document.querySelector('#password');
const loginBtn = document.querySelector('#login');

if(api.getAuthToken()) {
    window.location = '../my-searches/my-searches.html';
}

loginBtn.addEventListener('click', async (e) => {
    e.preventDefault();
    let loadingAnimation = startLoadingAnimation();
    let res = await api.login(emailInput.value,passwordInput.value);
    endLoadingAnimation(loadingAnimation);
    if(!res.success) {
        showPopup('Fehler',res.msg);
        return false;
    }

    window.location = '../my-searches/my-searches.html';
});