Files
Epicnabbo-Catalogus-Updated…/src/app/admin/rooms/_lib/load-room.ts
T
Remco e85e4d74ea revert fb8e77bb68
revert style: clean up code with prettier and eslint
2026-07-12 21:02:03 +02:00

21 lines
520 B
TypeScript

import { notFound } from 'next/navigation'
import { prisma } from '@/lib/prisma'
export async function loadRoom(id: string) {
const roomId = parseInt(id, 10)
if (Number.isNaN(roomId)) notFound()
const room = await prisma.rooms.findUnique({
where: { id: roomId },
})
if (!room) notFound()
const owner = room.ownerId > 0
? await prisma.user.findUnique({
where: { id: room.ownerId },
select: { id: true, username: true, look: true },
})
: null
return { ...room, owner }
}