fixed placement of note fuction

This commit is contained in:
chris 2025-08-02 09:43:55 -04:00
parent 5e506e5ab6
commit 74b0cb4cbb

View File

@ -341,7 +341,19 @@
const username = selected.options[selected.selectedIndex].dataset.username; const username = selected.options[selected.selectedIndex].dataset.username;
const punchInTime = new Date(e.target.elements['add-punch-in'].value).toISOString(); const punchInTime = new Date(e.target.elements['add-punch-in'].value).toISOString();
async function handleAddNote(e) {
// Handle the optional punch-out time
const punchOutValue = e.target.elements['add-punch-out'].value;
const punchOutTime = punchOutValue ? new Date(punchOutValue).toISOString() : null;
const res = await apiCall('/admin/add-punch', 'POST', { userId, username, punchInTime, punchOutTime });
if (res.success) {
showMessage(res.data.message, 'success');
e.target.reset();
renderAdminDashboard();
}
}
async function handleAddNote(e) {
e.preventDefault(); e.preventDefault();
const userId = e.target.elements['note-user-select'].value; const userId = e.target.elements['note-user-select'].value;
const noteText = e.target.elements['note-text'].value; const noteText = e.target.elements['note-text'].value;
@ -356,17 +368,7 @@
e.target.reset(); e.target.reset();
} }
} }
// Handle the optional punch-out time async function handleTimeOffRequest(e) { e.preventDefault(); const startDate = e.target.elements['start-date'].value; const endDate = e.target.elements['end-date'].value; const reason = e.target.elements['reason'].value; if (new Date(endDate) < new Date(startDate)) { return showMessage('End date cannot be before start date.', 'error'); } const res = await apiCall('/user/request-time-off', 'POST', { startDate, endDate, reason }); if (res.success) { showMessage(res.data.message, 'success'); e.target.reset(); renderEmployeeDashboard(); } }
const punchOutValue = e.target.elements['add-punch-out'].value;
const punchOutTime = punchOutValue ? new Date(punchOutValue).toISOString() : null;
const res = await apiCall('/admin/add-punch', 'POST', { userId, username, punchInTime, punchOutTime });
if (res.success) {
showMessage(res.data.message, 'success');
e.target.reset();
renderAdminDashboard();
}
} async function handleTimeOffRequest(e) { e.preventDefault(); const startDate = e.target.elements['start-date'].value; const endDate = e.target.elements['end-date'].value; const reason = e.target.elements['reason'].value; if (new Date(endDate) < new Date(startDate)) { return showMessage('End date cannot be before start date.', 'error'); } const res = await apiCall('/user/request-time-off', 'POST', { startDate, endDate, reason }); if (res.success) { showMessage(res.data.message, 'success'); e.target.reset(); renderEmployeeDashboard(); } }
// --- Initializer --- // --- Initializer ---
signOutBtn.addEventListener('click', () => handleSignOut('You have been signed out.')); signOutBtn.addEventListener('click', () => handleSignOut('You have been signed out.'));