diff --git a/apps/web/src/app/(private)/layout.tsx b/apps/web/src/app/(private)/layout.tsx
index 709e988ba..63e0f847d 100644
--- a/apps/web/src/app/(private)/layout.tsx
+++ b/apps/web/src/app/(private)/layout.tsx
@@ -1,6 +1,5 @@
import { ReactNode } from 'react'
-import Sidebar from '$/components/Sidebar'
import { getSession } from '$/services/auth/getSession'
import { ROUTES } from '$/services/routes'
import { redirect } from 'next/navigation'
@@ -14,12 +13,5 @@ export default async function PrivateLayout({
if (!data.session) {
return redirect(ROUTES.auth.login)
}
- return (
-
-
-
-
- {children}
-
- )
+ return children
}
diff --git a/apps/web/src/app/(private)/projects/[projectId]/commits/[commitUuid]/document/[documentId]/page.tsx b/apps/web/src/app/(private)/projects/[projectId]/commits/[commitUuid]/document/[documentId]/page.tsx
new file mode 100644
index 000000000..37b88c0ff
--- /dev/null
+++ b/apps/web/src/app/(private)/projects/[projectId]/commits/[commitUuid]/document/[documentId]/page.tsx
@@ -0,0 +1,23 @@
+import { DocumentEditor } from '@latitude-data/web-ui'
+import { getDocument } from '$core/data-access'
+
+export const dynamic = 'force-dynamic'
+
+export default async function Editor({
+ params,
+}: {
+ params: { projectId: number; commitUuid: string; documentId: number }
+}) {
+ const result = await getDocument({
+ projectId: params.projectId,
+ commitUuid: params.commitUuid,
+ documentId: params.documentId,
+ })
+ const { content } = result.unwrap()
+
+ return (
+
+
+
+ )
+}
diff --git a/apps/web/src/app/(private)/projects/[projectId]/commits/[commitUuid]/layout.tsx b/apps/web/src/app/(private)/projects/[projectId]/commits/[commitUuid]/layout.tsx
new file mode 100644
index 000000000..17ee3b1d0
--- /dev/null
+++ b/apps/web/src/app/(private)/projects/[projectId]/commits/[commitUuid]/layout.tsx
@@ -0,0 +1,28 @@
+import { ReactNode } from 'react'
+
+import { CommitProvider } from '@latitude-data/web-ui'
+import Sidebar from '$/components/Sidebar'
+import { getCommitMergedAt } from '$core/data-access'
+
+export default async function PrivateLayout({
+ children,
+ params,
+}: {
+ children: ReactNode
+ params: { commitUuid: string; projectId: number }
+}) {
+ const { commitUuid, projectId } = params
+ const commitMergeTime = await getCommitMergedAt({ projectId, commitUuid })
+ const isDraft = commitMergeTime.unwrap() === null
+
+ return (
+
+
+
+
+
+ {children}
+
+
+ )
+}
diff --git a/apps/web/src/app/(private)/projects/[projectId]/layout.tsx b/apps/web/src/app/(private)/projects/[projectId]/layout.tsx
new file mode 100644
index 000000000..b0b841869
--- /dev/null
+++ b/apps/web/src/app/(private)/projects/[projectId]/layout.tsx
@@ -0,0 +1,15 @@
+import { ReactNode } from 'react'
+
+import { ProjectProvider } from '@latitude-data/web-ui'
+
+export default async function PrivateLayout({
+ children,
+ params,
+}: {
+ children: ReactNode
+ params: { projectId: number }
+}) {
+ const { projectId } = params
+
+ return {children}
+}
diff --git a/apps/web/src/app/api/commits/[commitUuid]/documents/route.ts b/apps/web/src/app/api/projects/[projectId]/commits/[commitUuid]/documents/route.ts
similarity index 60%
rename from apps/web/src/app/api/commits/[commitUuid]/documents/route.ts
rename to apps/web/src/app/api/projects/[projectId]/commits/[commitUuid]/documents/route.ts
index 41a125cf1..9f152dd40 100644
--- a/apps/web/src/app/api/commits/[commitUuid]/documents/route.ts
+++ b/apps/web/src/app/api/projects/[projectId]/commits/[commitUuid]/documents/route.ts
@@ -2,12 +2,14 @@ import { materializeDocumentsAtCommit } from '@latitude-data/core'
import { NextRequest, NextResponse } from 'next/server'
export async function GET(
- req: NextRequest,
- { commitUuid }: { commitUuid: string },
+ _: NextRequest,
+ { commitUuid, projectId }: { commitUuid: string; projectId: number },
) {
try {
- const staged = Boolean(req.nextUrl.searchParams.get('staged') || false)
- const documents = await materializeDocumentsAtCommit({ commitUuid, staged })
+ const documents = await materializeDocumentsAtCommit({
+ commitUuid,
+ projectId,
+ })
return NextResponse.json(documents)
} catch (err: unknown) {
diff --git a/apps/web/src/components/Sidebar/DocumentTree/index.tsx b/apps/web/src/components/Sidebar/DocumentTree/index.tsx
index 3f2f1d2cf..69f1bf477 100644
--- a/apps/web/src/components/Sidebar/DocumentTree/index.tsx
+++ b/apps/web/src/components/Sidebar/DocumentTree/index.tsx
@@ -2,6 +2,7 @@
import { faker } from '@faker-js/faker'
import type { DocumentType, DocumentVersion } from '@latitude-data/core'
+import { useCurrentCommit, useCurrentProject } from '@latitude-data/web-ui'
import useDocumentVersions from '$/stores/documentVersions'
import { Node, useTree } from '../toTree'
@@ -20,16 +21,20 @@ export function CreateNode({ parentId }: { parentId?: number }) {
}
function CreateFolder({ parentId }: { parentId?: number }) {
- const { create } = useDocumentVersions({ staged: true })
+ const { commitUuid, isDraft } = useCurrentCommit()
+ const { projectId } = useCurrentProject()
+ const { create } = useDocumentVersions({ projectId, commitUuid })
return (
@@ -37,9 +42,17 @@ function CreateFolder({ parentId }: { parentId?: number }) {
}
function CreateDocument({ parentId }: { parentId?: number }) {
- const { create } = useDocumentVersions({ staged: true })
+ const { commitUuid, isDraft } = useCurrentCommit()
+ const { projectId } = useCurrentProject()
+ const { create } = useDocumentVersions({ projectId, commitUuid })
return (
-