Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions src/app/doc/[uuid]/DocPageClient.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
"use client";

import TopNavigationBar from "@/components/layout/NotePage/TopNavigationBar";
import { useCallback, useEffect, useState } from "react";

import ChatMenu from "@/components/chat/ChatMenu";
import NoteExplorer from "@/components/layout/NotePage/NoteExplorer";
import NoteUI from "@/components/layout/NotePage/NoteUI";
import ChatMenu from "@/components/chat/ChatMenu";
import TopNavigationBar from "@/components/layout/NotePage/TopNavigationBar";

export default function DocPageClient({
user,
Expand All @@ -12,12 +14,35 @@ export default function DocPageClient({
user: User;
selectedNoteId: string;
}) {
const [activeNoteId, setActiveNoteId] = useState<string>(selectedNoteId);

useEffect(() => {
setActiveNoteId(selectedNoteId);
}, [selectedNoteId]);

const handleSelectNote = useCallback((noteId: string) => {
setActiveNoteId(noteId);

if (typeof window !== "undefined") {
const nextUrl = `/doc/${noteId}`;
if (window.location.pathname !== nextUrl) {
window.history.replaceState(null, "", nextUrl);
}
}
}, []);

const resolvedNoteId = activeNoteId || selectedNoteId;

return (
<div className="flex flex-col justify-start w-full relative gap-[59px] bg-[#f0f8fe]">
<TopNavigationBar user={user} selectedNoteId={selectedNoteId} />
<TopNavigationBar user={user} selectedNoteId={resolvedNoteId} />
<div className="flex flex-row w-full pt-24">
<NoteExplorer user={user} selectedNoteId={selectedNoteId} />
<NoteUI user={user} noteId={selectedNoteId} />
<NoteExplorer
user={user}
selectedNoteId={resolvedNoteId}
onSelectNote={handleSelectNote}
/>
<NoteUI user={user} noteId={resolvedNoteId} />
</div>
<ChatMenu uuid={"1234"} user={user} />
</div>
Expand Down
Loading