Skip to content

Scheduling infrastructure for absolutely everyone.

fix: build removing extra spaces

Agusti Fernandez Pardo9078ee2f3f4d
diff --git a/pages/api/attendees/[id].ts b/pages/api/attendees/[id].ts
index 03133bf5262..6931c5d6dfd 100644
--- a/pages/api/attendees/[id].ts
+++ b/pages/api/attendees/[id].ts
@@ -100,7 +100,7 @@ export async function attendeeById(req: NextApiRequest, res: NextApiResponse<Att
const attendees = userBookings.map((booking) => booking.attendees).flat();
const attendeeIds = attendees.map((attendee) => attendee.id);
// Here we make sure to only return attendee's of the user's own bookings.
- if (!attendeeIds.includes(safeQuery.data.id)) res.status(401).json({ message: "Unauthorized" });
+ if (!attendeeIds.includes(safeQuery.data.id)) res.status(401).json({ message: "Unauthorized" });
else {
switch (method) {
case "GET":
diff --git a/pages/api/schedules/[id].ts b/pages/api/schedules/[id].ts
index a8fa5014120..9a6f67d8268 100644
--- a/pages/api/schedules/[id].ts
+++ b/pages/api/schedules/[id].ts
@@ -126,6 +126,20 @@ export async function scheduleById(req: NextApiRequest, res: NextApiResponse<Sch
break;
case "DELETE":
+ // Look for user to check if schedule is user's default
+ const user = await prisma.user.findUnique({ where: { id: userId } });
+ if (!user) throw new Error("User not found");
+ if (user.defaultScheduleId === safeQuery.data.id) {
+ // unset default
+ await prisma.user.update({
+ where: {
+ id: userId,
+ },
+ data: {
+ defaultScheduleId: undefined,
+ },
+ });
+ }
await prisma.schedule
.delete({ where: { id: safeQuery.data.id } })
.then(() =>
diff --git a/pages/api/users/[id].ts b/pages/api/users/[id].ts
index e1a11b30045..58fb8265214 100644
--- a/pages/api/users/[id].ts
+++ b/pages/api/users/[id].ts
@@ -91,7 +91,7 @@ export async function userById(req: NextApiRequest, res: NextApiResponse<UserRes
const safeBody = schemaUserBodyParams.safeParse(body);
if (!safeQuery.success) throw new Error("Invalid request query", safeQuery.error);
const userId = req.userId;
- if (safeQuery.data.id !== userId) res.status(401).json({ message: "Unauthorized" });
+ if (safeQuery.data.id !== userId) res.status(401).json({ message: "Unauthorized" });
else {
switch (method) {
case "GET":