<div class="swm-toast-notify">
<div class="toast-notify__icon">
<img class="width-full toast-notify__icon-success" src="{{ asset('bundles/shopwithmeui/assets/icons/toastNoti/success.svg') }}"/>
<img class="width-full toast-notify__icon-error" src="{{ asset('bundles/shopwithmeui/assets/icons/toastNoti/error.svg') }}"/>
</div>
<div class="toast-notify__content">
</div>
<div class="toast-notify__close">
<img src="{{ asset('bundles/shopwithmeui/assets/icons/toastNoti-close.svg') }}"/>
</div>
</div>
<script>
function showToastNotify(message, options = {}) {
const { type } = options || {};
const notify = document.querySelector('.swm-toast-notify');
const notiClose = document.querySelector('.toast-notify__close');
const notiCloseIcon = document.querySelector('.toast-notify__close img');
const notiSuccess = document.querySelector('.toast-notify__icon-success');
const notiError = document.querySelector('.toast-notify__icon-error');
if (notify) {
notify.classList.add('show');
notify.classList.add(type);
if (type == 'success') {
if (notiError) {
notiError.classList.add('d-none-important');
}
if (notiSuccess) {
notiSuccess.classList.remove('d-none-important');
}
}
else {
console.log('check error')
if (notiError) {
notiError.classList.remove('d-none-important');
}
if (notiSuccess) {
notiSuccess.classList.add('d-none-important');
}
}
notiCloseIcon.classList.add(type);
const content = notify.querySelector('.toast-notify__content');
content.innerHTML = message;
setTimeout(() => {
notify.classList.remove('show');
notify.classList.remove(type);
notiCloseIcon.classList.remove(type);
}, 4000);
}
notiClose.addEventListener('click', () => {
notify.classList.remove('show');
notify.classList.remove(type);
notiCloseIcon.classList.remove(type);
})
}
</script>