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);
|
console.log("dayShifts:", dayShifts);
|
||||||
|
|
||||||
const hasAssignment = (shiftId) => {
|
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 (
|
return (
|
||||||
<div
|
<div
|
||||||
key={index}
|
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 && (
|
{!assignmentExists && shift.isAvailable && (
|
||||||
<button onClick={() => { addAssignment(publisher, shift.id); onClose() }}
|
<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
|
//sleep for 300ms to allow the database to process the previous request
|
||||||
await new Promise(r => setTimeout(r, 100));
|
await new Promise(r => setTimeout(r, 100));
|
||||||
|
|
||||||
|
|
||||||
|
let isOld = false;
|
||||||
const row = rawData[i];
|
const row = rawData[i];
|
||||||
var email, phone, names, dateOfInput, oldAvDeleted = false, isTrained = false, desiredShiftsPerMonth = 4, isActive = false, publisherType = PublisherType.Publisher;
|
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);
|
//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(/[ ]+/);
|
names = row[headerRef.current.nameIndex].normalize('NFC').split(/[ ]+/);
|
||||||
dateOfInput = importDate.value || new Date().toISOString();
|
dateOfInput = importDate.value || new Date().toISOString();
|
||||||
// not empty == true
|
// not empty == true
|
||||||
|
|
||||||
isTrained = row[headerRef.current.isTrainedIndex] !== '';
|
isTrained = row[headerRef.current.isTrainedIndex] !== '';
|
||||||
isActive = row[headerRef.current.isActiveIndex] == '';
|
isActive = row[headerRef.current.isActiveIndex] == '';
|
||||||
desiredShiftsPerMonth = row[headerRef.current.desiredShiftsIndex] !== '' ? row[headerRef.current.desiredShiftsIndex] : 4;
|
desiredShiftsPerMonth = row[headerRef.current.desiredShiftsIndex] !== '' ? row[headerRef.current.desiredShiftsIndex] : 4;
|
||||||
@ -174,6 +177,15 @@ export default function ImportPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//remove special characters from name
|
//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(/[, ]+/);
|
// 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
|
// Create a new Date object for the start date of the range
|
||||||
const day = new Date();
|
const day = new Date();
|
||||||
day.setDate(1); // Set to the first day of the month to avoid overflow
|
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(day.getMonth() + 1); // Add one month to the date, because we assume we are p
|
||||||
day.setMonth(common.getMonthIndex(month));
|
day.setMonth(common.getMonthIndex(month));
|
||||||
day.setDate(parseInt(weekStart) + dayOfWeek);
|
day.setDate(parseInt(weekStart) + dayOfWeek);
|
||||||
@ -432,13 +445,6 @@ export default function ImportPage() {
|
|||||||
let minStartTime = parsedIntervals[0].start;
|
let minStartTime = parsedIntervals[0].start;
|
||||||
let maxEndTime = parsedIntervals[0].end;
|
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
|
// Iterate over intervals
|
||||||
for (let i = 1; i < parsedIntervals.length; i++) {
|
for (let i = 1; i < parsedIntervals.length; i++) {
|
||||||
@ -520,7 +526,7 @@ export default function ImportPage() {
|
|||||||
name,
|
name,
|
||||||
dayofweek: dayOfWeekName,
|
dayofweek: dayOfWeekName,
|
||||||
dayOfMonth,
|
dayOfMonth,
|
||||||
weekOfMonth: weekNr, // Add the missing 'weekOfMonth' property
|
weekOfMonth: weekNr, // Add the missing 'weekOfMonth'
|
||||||
startTime,
|
startTime,
|
||||||
endTime,
|
endTime,
|
||||||
isactive: true,
|
isactive: true,
|
||||||
|
@ -133,6 +133,7 @@ model Availability {
|
|||||||
repeatWeekly Boolean? // New field to indicate weekly repetition
|
repeatWeekly Boolean? // New field to indicate weekly repetition
|
||||||
repeatFrequency Int? // New field to indicate repetition frequency
|
repeatFrequency Int? // New field to indicate repetition frequency
|
||||||
endDate DateTime? // New field for the end date of repetition
|
endDate DateTime? // New field for the end date of repetition
|
||||||
|
//dateOfEntry DateTime
|
||||||
|
|
||||||
@@map("Availability")
|
@@map("Availability")
|
||||||
}
|
}
|
||||||
@ -167,6 +168,7 @@ model Shift {
|
|||||||
//date DateTime
|
//date DateTime
|
||||||
reportId Int? @unique
|
reportId Int? @unique
|
||||||
Report Report? @relation(fields: [reportId], references: [id])
|
Report Report? @relation(fields: [reportId], references: [id])
|
||||||
|
//isPublished Boolean @default(false)
|
||||||
|
|
||||||
@@map("Shift")
|
@@map("Shift")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user