schedule is for monthinfo periods

This commit is contained in:
Dobromir Popov
2024-04-20 12:09:30 +03:00
parent 2c062be8a1
commit b535d0853a
6 changed files with 24 additions and 11 deletions

View File

@ -73,17 +73,20 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
if (req.method === 'GET') {
// const { year, month } = req.query;
const { year, month } = req.query;
// let monthIndex = parseInt(month as string) - 1;
// const monthInfo = common.getMonthDatesInfo(new Date(year, month, 1));
// let fromDate = monthInfo.firstMonday;
// const toDate = monthInfo.lastSunday;
//ToDo: maybe we don't need that anymore as we are publishing the shifts and show all published shifts
let fromDate = new Date();
fromDate.setDate(fromDate.getDate() - 1);
fromDate.setHours(0, 0, 0, 0);
let toDate = new Date(fromDate);
toDate.setDate(toDate.getDate() + 40);
if (year && month) {
fromDate = new Date(parseInt(year as string), parseInt(month as string) - 1, 1);
}
const monthInfo = common.getMonthDatesInfo(fromDate);
//let toDate = new Date(monthInfo.lastSunday);
if (year && month) {
fromDate = monthInfo.firstMonday;
}
try {
@ -93,7 +96,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
isPublished: true,
startTime: {
gte: fromDate,
lt: toDate,
//lt: toDate,
},
},
orderBy: {