fix: moves event-types to find user including it's event-types
parent
ed2f42fb01
commit
8f9a970fb6
|
@ -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