fix: availability creation and expand/collapse settings (#882)

* fix: availability creation and expand/collapse settings

* additional fixes

* Update pages/api/availability/eventtype.ts

Co-authored-by: Alex Johansson <[email protected]>

* update branch

* fix: more fixes

Co-authored-by: Alex Johansson <[email protected]>
Co-authored-by: Bailey Pumfleet <[email protected]>
Co-authored-by: Mihai Colceriu <[email protected]>
This commit is contained in:
authored and GitHub committed 2021-10-12 08:17:25 +00:00
1 parent 683713e73f
commit f27b0b3cad
6 files changed
+45 -17

No files matched your search

+9
View File
@@ -144,6 +144,15 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const openingHours = req.body.availability.openingHours || [];
// const overrides = req.body.availability.dateOverrides || [];
const eventTypeId = +req.body.id;
if (eventTypeId) {
await prisma.availability.deleteMany({
where: {
eventTypeId,
},
});
}
Promise.all(
openingHours.map((schedule) =>
prisma.availability.create({