ui fix for shift UI
This commit is contained in:
@ -81,13 +81,10 @@ function ShiftComponent({ shift, onShiftSelect, isSelected, onPublisherSelect, a
|
|||||||
const { data } = await axiosInstance.post("/api/data/assignments", newAssignment);
|
const { data } = await axiosInstance.post("/api/data/assignments", newAssignment);
|
||||||
// Update the 'publisher' property of the returned data with the full publisher object
|
// Update the 'publisher' property of the returned data with the full publisher object
|
||||||
data.publisher = publisher;
|
data.publisher = publisher;
|
||||||
//ToDo: see if we need to update in state
|
setAssignments(prevAssignments => [...prevAssignments, data]);
|
||||||
// publisher.currentWeekAssignments += 1;
|
|
||||||
// publisher.currentMonthAssignments += 1;
|
|
||||||
if (onAssignmentChange) {
|
if (onAssignmentChange) {
|
||||||
onAssignmentChange(data.publisher.id, 'add')
|
onAssignmentChange(data.publisher.id, 'add')
|
||||||
}
|
}
|
||||||
setAssignments(prevAssignments => [...prevAssignments, data]);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error adding assignment:", error);
|
console.error("Error adding assignment:", error);
|
||||||
}
|
}
|
||||||
|
@ -367,6 +367,8 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
|
|||||||
const { data } = await axiosInstance.post("/api/data/assignments", newAssignment);
|
const { data } = await axiosInstance.post("/api/data/assignments", newAssignment);
|
||||||
// Update the 'publisher' property of the returned data with the full publisher object
|
// Update the 'publisher' property of the returned data with the full publisher object
|
||||||
data.publisher = publisher;
|
data.publisher = publisher;
|
||||||
|
data.shift = shifts.find(shift => shift.id === shiftId);
|
||||||
|
publisher.assignments = [...publisher.assignments, data];
|
||||||
handleAssignmentChange(publisher.id, 'add');
|
handleAssignmentChange(publisher.id, 'add');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error adding assignment:", error);
|
console.error("Error adding assignment:", error);
|
||||||
|
Reference in New Issue
Block a user