Scheduling Employees is Painful
Make Scheduling Employees Fast and Easy
Scheduling Employees Takes Too Much Time!
const form = document.getElementById('scheduling-tool-form'); const filenameInput = document.getElementById('filename'); const csvFileInput = document.getElementById('csv-file'); const submitButton = document.getElementById('submit-button');const manualEntryForm = document.getElementById('manual-entry-form'); const numEmployeesInput = document.getElementById('num-employees'); const numShiftsInput = document.getElementById('num-shifts'); const shiftLengthInput = document.getElementById('shift-length'); const employeeNamesInput = document.getElementById('employee-names'); const shiftStartTimesInput = document.getElementById('shift-start-times'); const submitButtonManual = document.getElementById('submit-button-manual');submitButton.addEventListener('click', (e) => { e.preventDefault(); const filename = filenameInput.value; const csvFile = csvFileInput.files[0]; // Use the filename and csvFile variables to generate the schedule // ... });submitButtonManual.addEventListener('click', (e) => { e.preventDefault(); const numEmployees = parseInt(numEmployeesInput.value); const numShifts = parseInt(numShiftsInput.value); const shiftLength = parseInt(shiftLengthInput.value); const employeeNames = employeeNamesInput.value.split(','); const shiftStartTimes = shiftStartTimesInput.value.split(',');// Validate user input if (isNaN(numEmployees) || numEmployees <= 0) { alert('Please enter a valid number of employees'); return; }if (isNaN(numShifts) || numShifts <= 0) { alert('Please enter a valid number of shifts'); return; }if (isNaN(shiftLength) || shiftLength <= 0) { alert('Please enter a valid shift length'); return; }if (employeeNames.length === 0) { alert('Please enter at least one employee name'); return; }if (shiftStartTimes.length === 0) { alert('Please enter at least one shift start time'); return; }// Use regular expressions to validate employee names and shift start times const employeeNameRegex = /^[a-zA-Z\s]+$/; const shiftStartTimeRegex = /^\d{1,2}:\d{2}$/;for (const employeeName of employeeNames) { if (!employeeNameRegex.test(employeeName.trim())) { alert(`Invalid employee name: ${employeeName}`); return; } }for (const shiftStartTime of shiftStartTimes) { if (!shiftStartTimeRegex.test(shiftStartTime.trim())) { alert(`Invalid shift start time: ${shiftStartTime}`); return; } }// If all input is valid, generate the schedule // ... });