19 lines
816 B
JavaScript
19 lines
816 B
JavaScript
|
// Alert Box
|
||
|
// Function to show the custom alert with a message and type
|
||
|
export function showAlert(message, type = 'error') {
|
||
|
const alertBox = document.getElementById('custom-alert');
|
||
|
const alertMessage = document.getElementById('alert-message');
|
||
|
const closeButton = document.getElementById('close-alert');
|
||
|
|
||
|
alertMessage.textContent = message; // Set the message to display
|
||
|
alertBox.style.display = 'block'; // Show the alert box
|
||
|
|
||
|
// Reset previous styles
|
||
|
alertBox.classList.remove('success', 'error');
|
||
|
alertBox.classList.add(type); // Add the appropriate class (success/error)
|
||
|
|
||
|
// Add event listener to close the alert box
|
||
|
closeButton.addEventListener('click', () => {
|
||
|
alertBox.style.display = 'none'; // Hide the alert box when the button is clicked
|
||
|
});
|
||
|
}
|