fix copy availabilities button functionality. when editing manually, the flag is set back to false;
This commit is contained in:
@ -212,7 +212,7 @@ export default function AvailabilityForm({ publisherId, existingItems, inline, o
|
||||
availability.dayOfMonth = startTime.getDate();
|
||||
availability.endDate = null;
|
||||
}
|
||||
|
||||
availability.isFromPreviousMonth = false;
|
||||
availability.dateOfEntry = new Date();
|
||||
}
|
||||
|
||||
|
@ -402,6 +402,10 @@ const AvCalendar = ({ publisherId, events, selectedDate }) => {
|
||||
// orange-500 from Tailwind CSS
|
||||
backgroundColor = '#f56565';
|
||||
}
|
||||
if (event.isFromPreviousMonth) {
|
||||
//gray
|
||||
backgroundColor = '#a0aec0';
|
||||
}
|
||||
if (event.isActive) {
|
||||
switch (event.type) {
|
||||
case 'assignment':
|
||||
|
@ -30,7 +30,7 @@ export default async function handler(req, res) {
|
||||
|
||||
var action = req.query.action;
|
||||
var filter = req.query.filter;
|
||||
let day: Date, monthInfo: any;
|
||||
let day: Date;
|
||||
let isExactTime;
|
||||
if (req.query.date) {
|
||||
day = new Date(req.query.date);
|
||||
@ -42,6 +42,7 @@ export default async function handler(req, res) {
|
||||
isExactTime = true;
|
||||
}
|
||||
|
||||
let monthInfo = common.getMonthDatesInfo(day);
|
||||
const searchText = req.query.searchText?.normalize('NFC');
|
||||
|
||||
try {
|
||||
@ -220,6 +221,7 @@ export default async function handler(req, res) {
|
||||
|
||||
res.status(200).json(shiftsForDate);
|
||||
break;
|
||||
|
||||
case "copyOldAvailabilities":
|
||||
//get all publishers that don't have availabilities for the current month
|
||||
monthInfo = common.getMonthDatesInfo(day);
|
||||
@ -283,12 +285,12 @@ export default async function handler(req, res) {
|
||||
type: AvailabilityType.Monthly,
|
||||
isFromPreviousMonth: true,
|
||||
name: avail.name || "старо предпочитание",
|
||||
// parentAvailabilityId: avail.id
|
||||
parentAvailability: {
|
||||
connect: {
|
||||
id: avail.id
|
||||
}
|
||||
}
|
||||
parentAvailabilityId: avail.id,
|
||||
// parentAvailability: {
|
||||
// connect: {
|
||||
// id: avail.id
|
||||
// }
|
||||
// },
|
||||
}
|
||||
await prisma.availability.create({ data: data });
|
||||
|
||||
@ -331,7 +333,6 @@ export default async function handler(req, res) {
|
||||
|
||||
case "updateShifts":
|
||||
//get all shifts for the month and publish them (we pass date )
|
||||
let monthInfo = common.getMonthDatesInfo(day);
|
||||
let isPublished = common.parseBool(req.query.isPublished);
|
||||
let updated = await prisma.shift.updateMany({
|
||||
where: {
|
||||
|
@ -88,6 +88,7 @@ async function getAvailabilities(userId) {
|
||||
name: true,
|
||||
isActive: true,
|
||||
isFromPreviousAssignment: true,
|
||||
isFromPreviousMonth: true,
|
||||
dayofweek: true,
|
||||
dayOfMonth: true,
|
||||
startTime: true,
|
||||
|
Reference in New Issue
Block a user