Update eventType.ts
parent
f670cc23f2
commit
2ada162c90
|
@ -7,7 +7,7 @@ import prisma from "@lib/prisma";
|
||||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||||
const session = await getSession({ req: req });
|
const session = await getSession({ req: req });
|
||||||
|
|
||||||
if (!session) {
|
if (!session?.user?.id) {
|
||||||
res.status(401).json({ message: "Not authenticated" });
|
res.status(401).json({ message: "Not authenticated" });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||||
|
|
||||||
const user = await prisma.user.findUnique({
|
const user = await prisma.user.findUnique({
|
||||||
where: {
|
where: {
|
||||||
id: session?.user?.id,
|
id: session.user.id,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
|
@ -83,7 +83,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||||
// backwards compatibility, TMP:
|
// backwards compatibility, TMP:
|
||||||
const typesRaw = await prisma.eventType.findMany({
|
const typesRaw = await prisma.eventType.findMany({
|
||||||
where: {
|
where: {
|
||||||
userId: session?.user?.id,
|
userId: session.user.id,
|
||||||
},
|
},
|
||||||
select: eventTypeSelect,
|
select: eventTypeSelect,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue