shift replcement works
This commit is contained in:
@ -210,6 +210,12 @@ export default async function handler(req, res) {
|
||||
res.status(200).json(shiftsForDate);
|
||||
break;
|
||||
|
||||
case "replaceInAssignment":
|
||||
const { oldPublisherId, newPublisherId, shiftId } = req.method === "POST" ? req.body : req.query;
|
||||
const prisma = common.getPrismaClient();
|
||||
const result = await replaceInAssignment(oldPublisherId, newPublisherId, shiftId);
|
||||
res.status(200).json(result);
|
||||
break;
|
||||
|
||||
default:
|
||||
res.status(200).json({
|
||||
@ -224,6 +230,7 @@ export default async function handler(req, res) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
export async function getMonthlyStatistics(selectFields, filterDate) {
|
||||
|
||||
let publishers = [];
|
||||
@ -670,4 +677,22 @@ async function getCalendarEvents(publisherId, date, availabilities = true, assig
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
async function replaceInAssignment(oldPublisherId, newPublisherId, shiftId) {
|
||||
const prisma = common.getPrismaClient();
|
||||
const result = await prisma.assignment.updateMany({
|
||||
where: {
|
||||
publisherId: oldPublisherId,
|
||||
shiftId: shiftId
|
||||
},
|
||||
data: {
|
||||
publisherId: newPublisherId,
|
||||
isConfirmed: false,
|
||||
isTentative: true,
|
||||
isMailSent: false
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
Reference in New Issue
Block a user