new fn: delete all availabilities

This commit is contained in:
Dobromir Popov
2024-03-04 00:20:13 +02:00
parent 4dc336bfa2
commit 6043df6ad1
2 changed files with 29 additions and 8 deletions

View File

@ -67,8 +67,8 @@ export default async function handler(req, res) {
await prisma.availability.deleteMany({
where: filter ? {
OR: [
{ firstName: { contains: filter } },
{ lastName: { contains: filter } }
// { name: { contains: filter } },
{ starTime: { lte: date } }
]
} : {}
});
@ -212,7 +212,9 @@ export default async function handler(req, res) {
default:
res.status(200).json({ "message": "no action" });
res.status(200).json({
"message": "no action '" + action + "' found"
});
break;
}
} catch (error) {
@ -455,16 +457,12 @@ export async function filterPublishers(selectFields, searchText, filterDate, fet
OR: [
// Check only by date without considering time ( Assignments on specific days without time)
{
//AND: [{ startTime: { gte: filterDate } }, { startTime: { lte: filterDateEnd } }]
//dayOfMonth: filterDate.getDate(),
startTime: { gte: filterDate },
endTime: { lte: filterDateEnd },
// //dayofweek: dayOfWeekEnum,
}
,
// Check if dayOfMonth is null and match by day of week using the enum (Assigments every week)
// This includes availabilities from previous assignments but not with preference
{
dayOfMonth: null,
dayofweek: dayOfWeekEnum,