diff --git a/public/index.html b/public/index.html
index 6cfe1c8..01939df 100644
--- a/public/index.html
+++ b/public/index.html
@@ -341,7 +341,19 @@
const username = selected.options[selected.selectedIndex].dataset.username;
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();
const userId = e.target.elements['note-user-select'].value;
const noteText = e.target.elements['note-text'].value;
@@ -356,17 +368,7 @@
e.target.reset();
}
}
- // 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 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(); } }
+ 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 ---
signOutBtn.addEventListener('click', () => handleSignOut('You have been signed out.'));