Skip to content

Commit

Permalink
temporal type fix
Browse files Browse the repository at this point in the history
  • Loading branch information
velascoandres committed Mar 9, 2024
1 parent 9d2acf7 commit 4211c5e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/app/view-whiteboard/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -15,15 +16,15 @@ const getWhiteboard = async (id: number) => {
redirect('/not-found')
}

return whiteboard
return whiteboard as unknown as WitheboardType & {content: undefined | Content}
}



const WhitebardViewPage = async ({ params }: {params: {id: string}}) => {
const whiteboardId = Number(params.id)

const whiteboard = await getWhiteboard(whiteboardId)
const whiteboard: WitheboardType = await getWhiteboard(whiteboardId)

return (
<main className="h-screen w-screen">
Expand Down
4 changes: 2 additions & 2 deletions src/server/api/whiteboard/usecases/find-public-whiteboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import { NotFound } from '@/server/exceptions/not-found'
type Options = z.infer<typeof SearchByIdDto> & {omitContent?: boolean}

const findPublicWhiteboardById = async (db: PostgresJsDatabase<typeof schema>, 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)),
columns: {
id: true,
name: true,
description: true,
content: omitContent ? false : true,
content: !omitContent ? true : false,
createdAt: true,
updatedAt: true,
}
Expand Down

0 comments on commit 4211c5e

Please sign in to comment.