Merge branch 'production'

This commit is contained in:
Dobromir Popov
2024-05-29 01:51:00 +03:00
3 changed files with 8 additions and 8 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);
@ -784,10 +786,11 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
return (
<li key={index}
className={`flex justify-between items-center p-4 sm:py-2 rounded-lg shadow-sm mb-2
${bgAndBorderColorClass} ${selectedBorderClass} ${activeOpacityClass}`}
${bgAndBorderColorClass} ${selectedBorderClass} ${activeOpacityClass}
${pub.currentMonthAssignments >= pub.desiredShiftsPerMonth ? 'text-gray-400' : 'text-gray-800'}`}
onDoubleClick={(handlePublisherModalOpen.bind(this, pub))}
>
<span className={`text-gray-700 ${pub.isAvailableForShift ? 'font-bold' : 'font-medium'} `}>
<span className={`${pub.isAvailableForShift ? 'font-bold' : 'font-medium'} `}>
{pub.firstName} {pub.lastName}
{pub.canTransport && (<LocalShippingIcon className="mx-2 text-gray-500" />)}
</span>
@ -940,7 +943,7 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
{common.getTimeRange(shift.startTime, shift.endTime)} {shift.id}
{!assignmentExists && shift.isAvailable && (
<button onClick={() => { addAssignment(publisher, shift.id); onClose() }}
<button onClick={() => { addAssignment(publisher, shift.id); }}
className="mt-2 bg-green-500 text-white p-1 rounded hover:bg-green-600 active:bg-green-700 focus:outline-none"
>
добави

View File

@ -331,7 +331,7 @@ async function filterPublishersNew(selectFields, filterDate, isExactTime = false
{ dayOfMonth: null },
//{ dayofweek: dayOfWeekEnum }, // we want all days of the week for now
// moved down to conditional filters
// { startTime: { lte: filterTimeTo } }, // we ignore startTime as it will be filtered later only by the time and not by date.
{ startTime: { lte: filterTimeTo } }, // we ignore startTime as it will be filtered later only by the time and not by date. ! but we need it to filter future repeating availabilities that are not yet started on the request date
{
OR: [ // OR condition for repeatUntil to handle events that either end after filterDate or repeat forever
{ endDate: { gte: filterTimeFrom } }, // endDate included