destinguish between pubs without availabilities (orange) and with changed availabilities (red) in calendar dash

This commit is contained in:
Dobromir Popov
2024-03-02 19:10:29 +02:00
parent 27a0c2cbb4
commit 6c6f8f41d0
6 changed files with 122 additions and 45 deletions

View File

@ -156,37 +156,43 @@ function ShiftComponent({ shift, onShiftSelect, isSelected, onPublisherSelect, a
// Determine border styles
let borderStyles = '';
//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 ';
if (selectedPublisher && selectedPublisher.id === ass.publisher.id) {
borderStyles += 'border-2 border-blue-300'; // Bottom border for selected publishers
}
else {
//pub is not available for that shift assignment.
if (publisherInfo.availabilities?.length === 0 ||
publisherInfo.availabilities?.every(avail => avail.isFromPreviousAssignment)) {
borderStyles += 'border-l-3 border-r-3 border-orange-500 '; // Top border for manual publishers
}
// checkig if the publisher is available for this assignment
if (publisherInfo.availabilities?.some(av =>
av.startTime <= ass.startTime &&
av.endTime >= ass.endTime)) {
borderStyles += 'border-t-2 border-red-500 '; // Left border for specific availability conditions
if (publisherInfo.availabilityCount == 0) //user has never the form
{
borderStyles = 'border-2 border-orange-300 ';
}
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
if (publisherInfo.availabilities?.some(av =>
av.startTime <= shift.startTime &&
av.endTime >= shift.endTime)) {
borderStyles += 'border-l-2 border-blue-500 '; // Left border for specific availability conditions
}
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
// }
if (selectedPublisher && selectedPublisher.id === ass.publisher.id) {
borderStyles += 'border-2 border-blue-300'; // Bottom border for selected publishers
}
if (publisherInfo.hasUpToDateAvailabilities) {
//add green right border
borderStyles += 'border-r-2 border-green-300';
}
}
return (
<div key={index}