Compare commits

..

2 Commits

Author SHA1 Message Date
0f744f861b kill me 2024-07-21 19:45:17 -05:00
52320227d2 idk server crap 2024-07-21 19:23:39 -05:00
2 changed files with 3566 additions and 2916 deletions

6231
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -94,30 +94,18 @@ export default function Table({ employees }: { employees: Employee[] }) {
setStatus(e.target.value);
};
const handleSubmit = async () => {
if (selectedIds.length === 0) {
const handleSubmit = async () => {
if (!session) {
alert("You must be signed in to update status.");
return;
} else {
const cur_user = employees.find(employee => employee.name === session?.user?.name);
}
// 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);
if (cur_user) {
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('');
setSelectedIds([cur_user.id]);
}
}
} else if (employeeStatus.trim() === '') {
} else if (employeeStatus.trim() !== '') {
await fetch('/api/v2/update_status', {
method: 'POST',
headers: {
@ -126,13 +114,14 @@ export default function Table({ employees }: { employees: Employee[] }) {
},
body: JSON.stringify({ employeeIds: selectedIds, newStatus: employeeStatus }),
});
// Optionally refresh data on the client-side after update
const updatedEmployees = await fetchEmployees();
setEmployeeData(updatedEmployees);
setSelectedIds([]);
setStatus('');
}
};
};
const handleKeyPress = async (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.key === 'Enter') {