28 lines
766 B
Plaintext
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');
|
|
}
|
|
}
|