Files
2024-10-29 14:07:31 +00:00

28 lines
766 B
Plaintext

// js/services/NotificationService.js
export class NotificationService {
constructor() {
this.toastElement = document.getElementById('toast');
}
showMessage(message, type = 'info') {
this.toastElement.textContent = message;
this.toastElement.className = `fixed bottom-4 right-4 px-6 py-3 rounded shadow-lg ${
type === 'error' ? 'bg-red-500' : 'bg-green-500'
} text-white`;
this.toastElement.classList.remove('hidden');
setTimeout(() => {
this.toastElement.classList.add('hidden');
}, 3000);
}
showError(message) {
this.showMessage(message, 'error');
}
showSuccess(message) {
this.showMessage(message, 'success');
}
}