Merge pull request #99 from calcom/fix/event-types-user-centric-query
fix: moves event-types to find user including it's event-typespull/9078/head
commit
10e8677894
|
@ -29,15 +29,17 @@ async function createOrlistAllEventTypes(
|
||||||
* 404:
|
* 404:
|
||||||
* description: No event types were found
|
* description: No event types were found
|
||||||
*/
|
*/
|
||||||
const data = await prisma.eventType
|
const data = await prisma.user
|
||||||
.findMany({ where: { userId } })
|
.findUnique({
|
||||||
|
where: { id: userId },
|
||||||
|
rejectOnNotFound: true,
|
||||||
|
select: { eventTypes: true },
|
||||||
|
})
|
||||||
.catch((error) => res.status(404).json({ message: "No event types were found", error }));
|
.catch((error) => res.status(404).json({ message: "No event types were found", error }));
|
||||||
console.log("eventTypes:", data);
|
|
||||||
console.log("userId:", userId);
|
|
||||||
// const event_types = data.map(
|
// const event_types = data.map(
|
||||||
// async (eventType) => await schemaEventTypeReadPublic.safeParseAsync(eventType)
|
// async (eventType) => await schemaEventTypeReadPublic.safeParseAsync(eventType)
|
||||||
// );
|
// );
|
||||||
if (data) res.status(200).json({ event_types: data });
|
if (data) res.status(200).json({ event_types: data.eventTypes });
|
||||||
else
|
else
|
||||||
(error: Error) =>
|
(error: Error) =>
|
||||||
res.status(404).json({
|
res.status(404).json({
|
||||||
|
|
Loading…
Reference in New Issue