diff --git a/components/calendar/ShiftComponent.tsx b/components/calendar/ShiftComponent.tsx index 3e0de26..9ce66a5 100644 --- a/components/calendar/ShiftComponent.tsx +++ b/components/calendar/ShiftComponent.tsx @@ -151,49 +151,45 @@ function ShiftComponent({ shift, onShiftSelect, isSelected, onPublisherSelect, a let borderStyles = ''; let canTransport = false; if (selectedPublisher && selectedPublisher.id === ass.publisher.id) { - borderStyles += 'border-2 border-blue-300'; // Bottom border for selected publishers + borderStyles += 'bg-blue-200 font-bold '; // Bottom border for selected publishers } - else { - if (publisherInfo.availabilityCount == 0) //user has never the form - { - borderStyles = 'border-2 border-orange-300 '; + + if (publisherInfo.availabilityCount == 0 || !publisherInfo.availabilities || publisherInfo.availabilities.length == 0) + //user has never the filled the avalabilities form or if there is no publisherInfo - draw red border - publisher is no longer available for the day! + { + borderStyles += 'border-2 border-red-500 '; + } else { + + // checkig if the publisher is available for this assignment + //ToDo: verify if that check is correct + const av = publisherInfo.availabilities?.find(av => + av.startTime <= shift.startTime && av.endTime >= shift.endTime + ); + if (av) { + borderStyles += 'border-b-2 border-blue-500 '; // Left border for specific availability conditions + ass.canTransport = av.isWithTransportIn || av.isWithTransportOut; + // console.log(publisherInfo.firstName, "available for shift", shift.id, "at", common.getDateFormattedShort(new Date(shift.startTime)), "av-" + av.id, ": a." + common.getTimeFormatted(av.startTime), "<=", common.getTimeFormatted(shift.startTime), "; a." + common.getTimeFormatted(av.endTime), ">=", common.getTimeFormatted(shift.endTime)); + } + else { + borderStyles += 'border-l-4 border-red-500 '; } - else - //if there is no publisherInfo - draw red border - publisher is no longer available for the day! - if (!publisherInfo.availabilities || publisherInfo.availabilities.length == 0) { - borderStyles = 'border-2 border-red-500 '; - } - else { - // checkig if the publisher is available for this assignment - const av = publisherInfo.availabilities?.find(av => - av.startTime <= shift.startTime && av.endTime >= shift.endTime - ); - if (av) { - borderStyles += 'border-l-2 border-blue-500 '; // Left border for specific availability conditions - ass.canTransport = av.isWithTransportIn || av.isWithTransportOut; - } - else { - borderStyles += 'border-l-4 border-red-500 '; - } + if (publisherInfo.hasUpToDateAvailabilities) { + //add green right border + borderStyles += 'border-r-2 border-green-300'; + } - if (publisherInfo.hasUpToDateAvailabilities) { - //add green right border - borderStyles += 'border-r-2 border-green-300'; - } - - //the pub is the same time as last month - // if (publisherInfo.availabilities?.some(av => - // (!av.dayOfMonth || av.isFromPreviousMonth) && - // av.startTime <= ass.startTime && - // av.endTime >= ass.endTime)) { - // borderStyles += 'border-t-2 border-yellow-500 '; // Left border for specific availability conditions - // } - - } + //the pub is the same time as last month + // if (publisherInfo.availabilities?.some(av => + // (!av.dayOfMonth || av.isFromPreviousMonth) && + // av.startTime <= ass.startTime && + // av.endTime >= ass.endTime)) { + // borderStyles += 'border-t-2 border-yellow-500 '; // Left border for specific availability conditions + // } } + return (