schedule is for monthinfo periods
This commit is contained in:
@ -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: {
|
||||
|
Reference in New Issue
Block a user