From 0b66e964fe021dc65159e66e811bde04b1515737 Mon Sep 17 00:00:00 2001 From: Agusti Fernandez Pardo Date: Fri, 27 May 2022 21:51:40 +0200 Subject: [PATCH 1/5] fix: some logggingeventtypeid --- pages/api/event-types/[id].ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pages/api/event-types/[id].ts b/pages/api/event-types/[id].ts index 12cee4433c..8654585786 100644 --- a/pages/api/event-types/[id].ts +++ b/pages/api/event-types/[id].ts @@ -25,6 +25,8 @@ export async function eventTypeById( select: { eventTypes: true }, }); const userEventTypes = data.eventTypes.map((eventType) => eventType.id); + console.log(userEventTypes); + console.log(userId); if (!userEventTypes.includes(safeQuery.data.id)) res.status(401).json({ message: "Unauthorized" }); else { switch (method) { From b9a2e0f4c6ca1f8f617c57a319cb67b22f8482ae Mon Sep 17 00:00:00 2001 From: Agusti Fernandez Pardo Date: Fri, 27 May 2022 21:58:38 +0200 Subject: [PATCH 2/5] fix: event types validations recurring event and locations nullable: --- lib/validations/event-type.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/validations/event-type.ts b/lib/validations/event-type.ts index bd2ba68728..b67f13fa6a 100644 --- a/lib/validations/event-type.ts +++ b/lib/validations/event-type.ts @@ -102,15 +102,18 @@ export const schemaEventTypeReadPublic = EventType.pick({ until: z.date().optional(), tzid: timeZone.optional(), }) - .optional(), - locations: z.array( - z.object({ - link: z.string().optional(), - address: z.string().optional(), - hostPhoneNumber: z.string().optional(), - type: z.nativeEnum(DefaultLocationType).or(z.nativeEnum(AppStoreLocationType)), - }) - ), + .optional() + .nullable(), + locations: z + .array( + z.object({ + link: z.string().optional(), + address: z.string().optional(), + hostPhoneNumber: z.string().optional(), + type: z.nativeEnum(DefaultLocationType).or(z.nativeEnum(AppStoreLocationType)), + }) + ) + .nullable(), metadata: jsonSchema.nullable(), }) ); From 2cd548bdb202f61331049184f14d4da0590b7a71 Mon Sep 17 00:00:00 2001 From: Agusti Fernandez Pardo Date: Fri, 27 May 2022 22:04:08 +0200 Subject: [PATCH 3/5] fix: or z nul --- lib/validations/event-type.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/validations/event-type.ts b/lib/validations/event-type.ts index b67f13fa6a..4d4c2446fd 100644 --- a/lib/validations/event-type.ts +++ b/lib/validations/event-type.ts @@ -103,7 +103,8 @@ export const schemaEventTypeReadPublic = EventType.pick({ tzid: timeZone.optional(), }) .optional() - .nullable(), + .nullable() + .or(z.null()), locations: z .array( z.object({ From eea7c1148801920cc85f0afb76aa293db2f4d43c Mon Sep 17 00:00:00 2001 From: Agusti Fernandez Pardo Date: Sat, 28 May 2022 01:50:28 +0200 Subject: [PATCH 4/5] fix event type valdiations --- lib/types.ts | 16 +++++++++------- lib/validations/event-type.ts | 3 +-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/types.ts b/lib/types.ts index 257568d551..b5d9ac4663 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -142,13 +142,15 @@ interface EventTypeExtended extends Omit Date: Sat, 28 May 2022 01:51:25 +0200 Subject: [PATCH 5/5] fix: remove console logs --- pages/api/event-types/[id].ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pages/api/event-types/[id].ts b/pages/api/event-types/[id].ts index 8654585786..20ad84d776 100644 --- a/pages/api/event-types/[id].ts +++ b/pages/api/event-types/[id].ts @@ -25,8 +25,7 @@ export async function eventTypeById( select: { eventTypes: true }, }); const userEventTypes = data.eventTypes.map((eventType) => eventType.id); - console.log(userEventTypes); - console.log(userId); + if (!userEventTypes.includes(safeQuery.data.id)) res.status(401).json({ message: "Unauthorized" }); else { switch (method) {