-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8406c86
commit 168a3da
Showing
7 changed files
with
83 additions
and
23 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
src/app/(protected)/(dashboard)/@modal/(...)view-whiteboard/[id]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { IntercepModal } from '@/app/_shared/components/modal/intercep-modal' | ||
import { getPublicWhiteboard } from '@/app/_whiteboards/actions/public-whiteboard' | ||
import { WhiterboardFromCompressed } from '@/app/_whiteboards/components/whiteboard' | ||
|
||
export default async function Page({ params }: {params: {id: string}}) { | ||
const whiteboardId = Number(params.id) | ||
|
||
const whiteboard = await getPublicWhiteboard(whiteboardId) | ||
|
||
return ( | ||
<IntercepModal title={whiteboard.name}> | ||
<section className="h-[calc(100dvh-300px)] w-full"> | ||
<WhiterboardFromCompressed | ||
viewModeEnabled | ||
id={whiteboard?.id} | ||
initialRawCompressed={whiteboard.compressedRawContent} | ||
/> | ||
</section> | ||
</IntercepModal> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Default() { | ||
return null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use client' | ||
|
||
import React, { useState } from 'react' | ||
import { useRouter } from 'next/navigation' | ||
|
||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/app/_shared/components/ui/dialog' | ||
|
||
interface Props { | ||
title: string | ||
children: React.ReactNode | ||
} | ||
|
||
export const IntercepModal = ({ title, children }: Props) => { | ||
const router = useRouter() | ||
const [isOpen, setIsOpen] = useState(true) | ||
|
||
const onOpenChangeHandler = (value: boolean) => { | ||
if (!value) { | ||
setIsOpen(false) | ||
router.back() | ||
|
||
return | ||
} | ||
} | ||
|
||
return ( | ||
<Dialog open={isOpen} onOpenChange={onOpenChangeHandler}> | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle>{title}</DialogTitle> | ||
</DialogHeader> | ||
{children} | ||
</DialogContent> | ||
</Dialog> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { redirect } from 'next/navigation' | ||
|
||
import findWhiteboardContent from '@/server/api/whiteboard/usecases/find-whiteboard-content' | ||
import { db } from '@/server/db' | ||
|
||
export const getPublicWhiteboard = async (id: number) => { | ||
'use server' | ||
const whiteboard = await findWhiteboardContent(db, { id, isPublic: true }) | ||
|
||
if (!whiteboard){ | ||
redirect('/not-found') | ||
} | ||
|
||
return whiteboard | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters