Compare commits

..

No commits in common. "0f744f861b5576018bb9a4676322d2387c2b092b" and "68644842fc002639dfcb0d5d08f60455baff4784" have entirely different histories.

2 changed files with 2916 additions and 3566 deletions

File diff suppressed because it is too large Load Diff

View File

@ -95,17 +95,29 @@ export default function Table({ employees }: { employees: Employee[] }) {
};
const handleSubmit = async () => {
if (selectedIds.length === 0) {
if (!session) {
alert("You must be signed in to update status.");
return;
}
// If no employee is selected and status is not empty
if (selectedIds.length === 0 && employeeStatus.trim() !== '') {
const cur_user = employees.find(employee => employee.name === session.user?.name);
} else {
const cur_user = employees.find(employee => employee.name === session?.user?.name);
if (cur_user) {
setSelectedIds([cur_user.id]);
await fetch('/api/v2/update_status', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.API_KEY}`
},
body: JSON.stringify({ employeeIds: [cur_user.id], newStatus: employeeStatus }),
});
// Optionally refresh data on the client-side after update
const updatedEmployees = await fetchEmployees();
setEmployeeData(updatedEmployees);
setSelectedIds([]);
setStatus('');
}
} else if (employeeStatus.trim() !== '') {
}
} else if (employeeStatus.trim() === '') {
await fetch('/api/v2/update_status', {
method: 'POST',
headers: {
@ -114,7 +126,6 @@ const handleSubmit = async () => {
},
body: JSON.stringify({ employeeIds: selectedIds, newStatus: employeeStatus }),
});
// Optionally refresh data on the client-side after update
const updatedEmployees = await fetchEmployees();
setEmployeeData(updatedEmployees);