assignment - search for replacement works

This commit is contained in:
Dobromir Popov
2024-03-03 04:21:14 +02:00
parent bd9d345386
commit 87836fab0a
2 changed files with 18 additions and 4 deletions

View File

@ -270,7 +270,8 @@ const AvCalendar = ({ publisherId, events, selectedDate }) => {
let bgColorClass = 'bg-gray-500'; // Default color for inactive events
var bgColor = event.isactive ? "" : "bg-gray-500";
if (event.type === "assignment") {
bgColor = event.isConfirmed ? "bg-green-500" : "bg-yellow-500";
bgColor = event.isTentative ? "bg-red-500" : (event.isConfirmed ? "bg-green-500" : "bg-yellow-500");
//event.title = event.publisher.name; //ToDo: add other publishers names
//event.title = common.getTimeFomatted(event.startTime) + " - " + common.getTimeFomatted(event.endTime);
} else {
@ -313,12 +314,24 @@ const AvCalendar = ({ publisherId, events, selectedDate }) => {
toast.info("Потвърдено!", { autoClose: 2000 });
// Update the event data
event.isConfirmed = true;
event.isactive = false;
event.isTentative = false;
// Update the events array by first removing the old event and then adding the updated one
setEvents(currentEvents => {
const filteredEvents = currentEvents.filter(e => e.id !== event.id);
return [...filteredEvents, event];
});
//store the updated event in the database
var assignment = {
isConfirmed: true,
isTentative: false
};
axiosInstance.put('/api/data/assignments/' + event.id, assignment)
.then((response) => {
console.log(response);
})
.catch((error) => {
console.log(error);
});
};
return (
<div style={eventStyle} className={bgColor + " relative"}