ui fix for shift UI

This commit is contained in:
Dobromir Popov
2024-05-29 00:12:42 +03:00
parent 4f8d72c162
commit c8367026dd
2 changed files with 3 additions and 4 deletions

View File

@ -81,13 +81,10 @@ function ShiftComponent({ shift, onShiftSelect, isSelected, onPublisherSelect, a
const { data } = await axiosInstance.post("/api/data/assignments", newAssignment);
// Update the 'publisher' property of the returned data with the full publisher object
data.publisher = publisher;
//ToDo: see if we need to update in state
// publisher.currentWeekAssignments += 1;
// publisher.currentMonthAssignments += 1;
setAssignments(prevAssignments => [...prevAssignments, data]);
if (onAssignmentChange) {
onAssignmentChange(data.publisher.id, 'add')
}
setAssignments(prevAssignments => [...prevAssignments, data]);
} catch (error) {
console.error("Error adding assignment:", error);
}

View File

@ -367,6 +367,8 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
const { data } = await axiosInstance.post("/api/data/assignments", newAssignment);
// Update the 'publisher' property of the returned data with the full publisher object
data.publisher = publisher;
data.shift = shifts.find(shift => shift.id === shiftId);
publisher.assignments = [...publisher.assignments, data];
handleAssignmentChange(publisher.id, 'add');
} catch (error) {
console.error("Error adding assignment:", error);