schedule is now published to be visible to the public
This commit is contained in:
@ -7,6 +7,7 @@ const subq = require('../../prisma/bl/subqueries');
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { all } from "axios";
|
||||
|
||||
/**
|
||||
*
|
||||
@ -29,7 +30,7 @@ export default async function handler(req, res) {
|
||||
|
||||
var action = req.query.action;
|
||||
var filter = req.query.filter;
|
||||
let date: Date;
|
||||
let date: Date, monthInfo: any;
|
||||
if (req.query.date) {
|
||||
date = new Date(req.query.date);
|
||||
//date.setDate(date.getDate()); // Subtract one day to get the correct date, as calendar sends wrong date (one day ahead)
|
||||
@ -77,7 +78,7 @@ export default async function handler(req, res) {
|
||||
//gets publisher by names with availabilities and assignments
|
||||
case "deleteAvailabilityForPublisher":
|
||||
let publisherId = req.query.publisherId;
|
||||
let dateFor, monthInfo;
|
||||
let dateFor;
|
||||
if (req.query.date) {
|
||||
dateFor = new Date(req.query.date);
|
||||
//get month info from date
|
||||
@ -212,11 +213,31 @@ export default async function handler(req, res) {
|
||||
|
||||
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;
|
||||
|
||||
case "updateShifts":
|
||||
//get all shifts for the month and publish them (we pass date )
|
||||
let monthInfo = common.getMonthDatesInfo(date);
|
||||
let isPublished = common.parseBool(req.query.isPublished);
|
||||
let updated = await prisma.shift.updateMany({
|
||||
where: {
|
||||
startTime: {
|
||||
gte: new Date(monthInfo.firstMonday.getFullYear(), monthInfo.firstMonday.getMonth(), 1),
|
||||
lt: new Date(monthInfo.lastSunday.getFullYear(), monthInfo.lastSunday.getMonth() + 1, 1),
|
||||
}
|
||||
},
|
||||
data: {
|
||||
isPublished: isPublished
|
||||
}
|
||||
});
|
||||
console.log("Updated shifts: " + updated.count);
|
||||
res.status(200).json({ "message": "ok" });
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
res.status(200).json({
|
||||
"message": "no action '" + action + "' found"
|
||||
|
Reference in New Issue
Block a user