diff --git a/src/app/view-whiteboard/[id]/page.tsx b/src/app/view-whiteboard/[id]/page.tsx index 475d5de..70f00f8 100644 --- a/src/app/view-whiteboard/[id]/page.tsx +++ b/src/app/view-whiteboard/[id]/page.tsx @@ -3,7 +3,8 @@ import React from 'react' import { redirect } from 'next/navigation' -import { type Content, Whiteboard } from '@/app/_whiteboards/components/whiteboard' +import { type Content,Whiteboard } from '@/app/_whiteboards/components/whiteboard' +import { type Whiteboard as WitheboardType } from '@/app/_whiteboards/interfaces/whiteboard' import findPublicWhiteboardById from '@/server/api/whiteboard/usecases/find-public-whiteboard' import { db } from '@/server/db' @@ -15,7 +16,7 @@ const getWhiteboard = async (id: number) => { redirect('/not-found') } - return whiteboard + return whiteboard as unknown as WitheboardType & {content: undefined | Content} } @@ -23,7 +24,7 @@ const getWhiteboard = async (id: number) => { const WhitebardViewPage = async ({ params }: {params: {id: string}}) => { const whiteboardId = Number(params.id) - const whiteboard = await getWhiteboard(whiteboardId) + const whiteboard: WitheboardType = await getWhiteboard(whiteboardId) return (
diff --git a/src/server/api/whiteboard/usecases/find-public-whiteboard.ts b/src/server/api/whiteboard/usecases/find-public-whiteboard.ts index 8dee928..4ced723 100644 --- a/src/server/api/whiteboard/usecases/find-public-whiteboard.ts +++ b/src/server/api/whiteboard/usecases/find-public-whiteboard.ts @@ -9,7 +9,7 @@ import { NotFound } from '@/server/exceptions/not-found' type Options = z.infer & {omitContent?: boolean} const findPublicWhiteboardById = async (db: PostgresJsDatabase, options: Options) => { - const { id, omitContent } = options + const { id, omitContent = false } = options const currentWhiteboard = await db.query.whiteboards.findFirst({ where: (whiteboards, { eq, and }) => and(eq(whiteboards.id, id), eq(whiteboards.isPublic, true)), @@ -17,7 +17,7 @@ const findPublicWhiteboardById = async (db: PostgresJsDatabase, o id: true, name: true, description: true, - content: omitContent ? false : true, + content: !omitContent ? true : false, createdAt: true, updatedAt: true, }