import './bootstrap';
import { AjaxTable } from './AjaxTable';
window.AjaxTable = AjaxTable;
document.addEventListener('DOMContentLoaded', () => {
if (document.getElementById('filterForm') && document.querySelector('.bg-white.shadow-sm')) {
new AjaxTable();
}
});
window.openDeleteModal = function(msnv, url) {
const messageEl = document.getElementById('deleteModal-message');
if (messageEl) {
messageEl.innerHTML = `Bạn có chắc chắn muốn đánh dấu nhân viên đã nghỉ việc?
Thao tác này sẽ ngăn user đăng nhập vào hệ thống, nhưng dữ liệu lịch sử vẫn được giữ lại.`;
}
const formEl = document.getElementById('deleteModal-form');
if (formEl) {
formEl.action = url;
}
if (typeof window.openModal === 'function') {
window.openModal('deleteModal');
}
};
window.togglePasswordVisibility = function(inputId, button) {
const input = document.getElementById(inputId);
if (!input) return;
const eyeOpen = button.querySelector('.eye-icon-open');
const eyeClosed = button.querySelector('.eye-icon-closed');
if (input.type === 'password') {
input.type = 'text';
button.setAttribute('aria-label', 'Hide password');
if (eyeOpen) eyeOpen.classList.remove('hidden');
if (eyeClosed) eyeClosed.classList.add('hidden');
} else {
input.type = 'password';
button.setAttribute('aria-label', 'Show password');
if (eyeOpen) eyeOpen.classList.add('hidden');
if (eyeClosed) eyeClosed.classList.remove('hidden');
}
};
document.addEventListener('DOMContentLoaded', () => {
const loginForm = document.querySelector('form[action$="/login"]');
if (loginForm) {
loginForm.addEventListener('submit', (e) => {
const submitBtn = loginForm.querySelector('button[type="submit"]');
if (submitBtn) {
if (submitBtn.disabled) {
e.preventDefault();
return;
}
submitBtn.disabled = true;
const originalText = submitBtn.textContent.trim();
submitBtn.dataset.originalText = originalText;
submitBtn.innerHTML = `
${originalText}
`;
}
});
}
});