correctly assume if assignmen is old, new database fields suggestions
This commit is contained in:
@ -735,7 +735,11 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
|
||||
console.log("dayShifts:", dayShifts);
|
||||
|
||||
const hasAssignment = (shiftId) => {
|
||||
return publisher.assignments.some(ass => ass.shift.id === shiftId);
|
||||
// return publisher.assignments.some(ass => ass.shift.id == shiftId);
|
||||
return publisher.assignments.some(ass => {
|
||||
console.log(`Comparing: ${ass.shift.id} to ${shiftId}: ${ass.shift.id === shiftId}`);
|
||||
return ass.shift.id === shiftId;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@ -780,9 +784,9 @@ export default function CalendarPage({ initialEvents, initialShifts }) {
|
||||
return (
|
||||
<div
|
||||
key={index}
|
||||
className={`text-sm text-white p-2 rounded-md ${isFromPrevMonth ? 'border-l-4 border-yellow-500' : ''} ${assignmentExists ? 'bg-blue-200' : shift.color} h-24 flex flex-col justify-center`}
|
||||
className={`text-sm text-white p-2 rounded-md ${isFromPrevMonth ? 'border-l-6 border-black-500' : ''} ${assignmentExists ? 'bg-blue-200' : shift.color} h-24 flex flex-col justify-center`}
|
||||
>
|
||||
{common.getTimeRange(shift.startTime, shift.endTime)}
|
||||
{common.getTimeRange(shift.startTime, shift.endTime)} {shift.id}
|
||||
|
||||
{!assignmentExists && shift.isAvailable && (
|
||||
<button onClick={() => { addAssignment(publisher, shift.id); onClose() }}
|
||||
|
@ -143,6 +143,8 @@ export default function ImportPage() {
|
||||
//sleep for 300ms to allow the database to process the previous request
|
||||
await new Promise(r => setTimeout(r, 100));
|
||||
|
||||
|
||||
let isOld = false;
|
||||
const row = rawData[i];
|
||||
var email, phone, names, dateOfInput, oldAvDeleted = false, isTrained = false, desiredShiftsPerMonth = 4, isActive = false, publisherType = PublisherType.Publisher;
|
||||
//const date = new Date(row[0]).toISOS{tring().slice(0, 10);
|
||||
@ -162,6 +164,7 @@ export default function ImportPage() {
|
||||
names = row[headerRef.current.nameIndex].normalize('NFC').split(/[ ]+/);
|
||||
dateOfInput = importDate.value || new Date().toISOString();
|
||||
// not empty == true
|
||||
|
||||
isTrained = row[headerRef.current.isTrainedIndex] !== '';
|
||||
isActive = row[headerRef.current.isActiveIndex] == '';
|
||||
desiredShiftsPerMonth = row[headerRef.current.desiredShiftsIndex] !== '' ? row[headerRef.current.desiredShiftsIndex] : 4;
|
||||
@ -174,6 +177,15 @@ export default function ImportPage() {
|
||||
}
|
||||
|
||||
//remove special characters from name
|
||||
const day = new Date();
|
||||
day.setDate(1); // Set to the first day of the month to avoid overflow
|
||||
|
||||
// Calculate the total month difference by considering the year difference
|
||||
let totalMonthDifference = (day.getFullYear() - dateOfInput.getFullYear()) * 12 + (day.getMonth() - dateOfInput.getMonth());
|
||||
// If the total month difference is 2 or more, set isOld to true
|
||||
if (totalMonthDifference >= 0) {
|
||||
isOld = true;
|
||||
}
|
||||
|
||||
// let names = common.removeAccentsAndSpecialCharacters(row[2]).split(/[, ]+/);
|
||||
|
||||
@ -361,6 +373,7 @@ export default function ImportPage() {
|
||||
// Create a new Date object for the start date of the range
|
||||
const day = new Date();
|
||||
day.setDate(1); // Set to the first day of the month to avoid overflow
|
||||
|
||||
//day.setMonth(day.getMonth() + 1); // Add one month to the date, because we assume we are p
|
||||
day.setMonth(common.getMonthIndex(month));
|
||||
day.setDate(parseInt(weekStart) + dayOfWeek);
|
||||
@ -432,13 +445,6 @@ export default function ImportPage() {
|
||||
let minStartTime = parsedIntervals[0].start;
|
||||
let maxEndTime = parsedIntervals[0].end;
|
||||
|
||||
let isOld = false;
|
||||
// Calculate the total month difference by considering the year difference
|
||||
let totalMonthDifference = (day.getFullYear() - dateOfInput.getFullYear()) * 12 + (day.getMonth() - dateOfInput.getMonth());
|
||||
// If the total month difference is 2 or more, set isOld to true
|
||||
if (totalMonthDifference >= 2) {
|
||||
isOld = true;
|
||||
}
|
||||
|
||||
// Iterate over intervals
|
||||
for (let i = 1; i < parsedIntervals.length; i++) {
|
||||
@ -520,7 +526,7 @@ export default function ImportPage() {
|
||||
name,
|
||||
dayofweek: dayOfWeekName,
|
||||
dayOfMonth,
|
||||
weekOfMonth: weekNr, // Add the missing 'weekOfMonth' property
|
||||
weekOfMonth: weekNr, // Add the missing 'weekOfMonth'
|
||||
startTime,
|
||||
endTime,
|
||||
isactive: true,
|
||||
|
@ -133,6 +133,7 @@ model Availability {
|
||||
repeatWeekly Boolean? // New field to indicate weekly repetition
|
||||
repeatFrequency Int? // New field to indicate repetition frequency
|
||||
endDate DateTime? // New field for the end date of repetition
|
||||
//dateOfEntry DateTime
|
||||
|
||||
@@map("Availability")
|
||||
}
|
||||
@ -167,6 +168,7 @@ model Shift {
|
||||
//date DateTime
|
||||
reportId Int? @unique
|
||||
Report Report? @relation(fields: [reportId], references: [id])
|
||||
//isPublished Boolean @default(false)
|
||||
|
||||
@@map("Shift")
|
||||
}
|
||||
|
Reference in New Issue
Block a user