-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create first project when setup is done + app layout header (#37)
- Loading branch information
1 parent
52101f5
commit 549805f
Showing
75 changed files
with
1,426 additions
and
392 deletions.
There are no files selected for viewing
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
25 changes: 0 additions & 25 deletions
25
apps/web/src/app/(private)/_components/DummyLogoutButton/index.tsx
This file was deleted.
Oops, something went wrong.
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 @@ | ||
import { cache } from 'react' | ||
|
||
import { | ||
findCommit as originalfindCommit, | ||
findProject as originalFindProject, | ||
getFirstProject as originalGetFirstProject, | ||
type FindCommitProps, | ||
type FindProjectProps, | ||
} from '@latitude-data/core' | ||
|
||
export const getFirstProject = cache( | ||
async ({ workspaceId }: { workspaceId: number }) => { | ||
const result = await originalGetFirstProject({ workspaceId }) | ||
const project = result.unwrap() | ||
|
||
return project | ||
}, | ||
) | ||
|
||
export const findProject = cache( | ||
async ({ projectId, workspaceId }: FindProjectProps) => { | ||
const result = await originalFindProject({ projectId, workspaceId }) | ||
const project = result.unwrap() | ||
|
||
return project | ||
}, | ||
) | ||
|
||
export const findCommit = cache( | ||
async ({ uuid, projectId }: FindCommitProps) => { | ||
const result = await originalfindCommit({ uuid, projectId }) | ||
const commit = result.unwrap() | ||
|
||
return commit | ||
}, | ||
) |
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,12 @@ | ||
import { | ||
LATITUDE_CHANGELOG_URL, | ||
LATITUDE_DOCS_URL, | ||
LATITUDE_HELP_URL, | ||
} from '@latitude-data/core/browser' | ||
|
||
export const NAV_LINKS = [ | ||
{ label: 'Feedback', href: '' }, | ||
{ label: 'Docs', href: LATITUDE_DOCS_URL }, | ||
{ label: 'Help', href: LATITUDE_HELP_URL }, | ||
{ label: 'Changelog', href: LATITUDE_CHANGELOG_URL }, | ||
] |
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,34 @@ | ||
'use client' | ||
|
||
import { useEffect } from 'react' | ||
|
||
import { | ||
AppLayout, | ||
ErrorComponent, | ||
useSession, | ||
} from '@latitude-data/web-ui/browser' | ||
import { NAV_LINKS } from '$/app/(private)/_lib/constants' | ||
|
||
export default function Error({ | ||
error, | ||
}: { | ||
error: Error & { digest?: string } | ||
reset: () => void // Re-render of page | ||
}) { | ||
const session = useSession() | ||
useEffect(() => { | ||
console.error(error) | ||
}, [error]) | ||
return ( | ||
<AppLayout | ||
currentUser={session.currentUser} | ||
breadcrumbs={[{ name: session.workspace.name }, { name: 'Error' }]} | ||
navigationLinks={NAV_LINKS} | ||
> | ||
<ErrorComponent | ||
type='red' | ||
message='Something went wrong. Please, try again and if the error persists contact us.' | ||
/> | ||
</AppLayout> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,17 +1,24 @@ | ||
import { ReactNode } from 'react' | ||
|
||
import { SessionProvider } from '@latitude-data/web-ui/browser' | ||
import { getCurrentUser } from '$/services/auth/getCurrentUser' | ||
import { getSession } from '$/services/auth/getSession' | ||
import { ROUTES } from '$/services/routes' | ||
import { redirect } from 'next/navigation' | ||
|
||
export default async function PrivateLayout({ | ||
children, | ||
}: { | ||
children: ReactNode | ||
}) { | ||
}: Readonly<{ children: ReactNode }>) { | ||
const data = await getSession() | ||
|
||
if (!data.session) { | ||
return redirect(ROUTES.auth.login) | ||
} | ||
return children | ||
|
||
const session = await getCurrentUser() | ||
return ( | ||
<SessionProvider currentUser={session.user} workspace={session.workspace}> | ||
{children} | ||
</SessionProvider> | ||
) | ||
} |
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 |
---|---|---|
@@ -1,21 +1,29 @@ | ||
import { FocusHeader, FocusLayout } from '@latitude-data/web-ui' | ||
import DummyLogoutButton from '$/app/(private)/_components/DummyLogoutButton' | ||
import { HEAD_COMMIT, NotFoundError, Project } from '@latitude-data/core' | ||
import { findCommit, getFirstProject } from '$/app/(private)/_data-access' | ||
import { getCurrentUser, SessionData } from '$/services/auth/getCurrentUser' | ||
import { ROUTES } from '$/services/routes' | ||
import { notFound, redirect } from 'next/navigation' | ||
|
||
export const dynamic = 'force-dynamic' | ||
const PROJECT_ROUTE = ROUTES.projects.detail | ||
|
||
export default async function Home() { | ||
return ( | ||
<FocusLayout | ||
header={ | ||
<FocusHeader | ||
title='Inside the APP 💪' | ||
description="Your're in let's kick those random AI's butts!" | ||
/> | ||
} | ||
> | ||
<div className='flex items-center justify-center'> | ||
<DummyLogoutButton /> | ||
</div> | ||
</FocusLayout> | ||
) | ||
export default async function AppRoot() { | ||
let session: SessionData | ||
let project: Project | ||
let url | ||
|
||
try { | ||
session = await getCurrentUser() | ||
project = await getFirstProject({ workspaceId: session.workspace.id }) | ||
await findCommit({ uuid: HEAD_COMMIT, projectId: project.id }) | ||
url = PROJECT_ROUTE({ id: project.id }).commits.latest | ||
} catch (error) { | ||
if (error instanceof NotFoundError) { | ||
return notFound() | ||
} | ||
|
||
throw error | ||
} | ||
|
||
return redirect(url) | ||
} |
28 changes: 0 additions & 28 deletions
28
apps/web/src/app/(private)/projects/[projectId]/commits/[commitUuid]/layout.tsx
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
apps/web/src/app/(private)/projects/[projectId]/layout.tsx
This file was deleted.
Oops, something went wrong.
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,34 @@ | ||
import { HEAD_COMMIT, NotFoundError, Project } from '@latitude-data/core' | ||
import { findCommit, findProject } from '$/app/(private)/_data-access' | ||
import { getCurrentUser, SessionData } from '$/services/auth/getCurrentUser' | ||
import { ROUTES } from '$/services/routes' | ||
import { notFound, redirect } from 'next/navigation' | ||
|
||
export const dynamic = 'force-dynamic' | ||
const PROJECT_ROUTE = ROUTES.projects.detail | ||
|
||
export type ProjectPageParams = { | ||
params: { projectId: string } | ||
} | ||
export default async function ProjectPage({ params }: ProjectPageParams) { | ||
let session: SessionData | ||
let project: Project | ||
let url | ||
|
||
try { | ||
session = await getCurrentUser() | ||
project = await findProject({ | ||
projectId: params.projectId, | ||
workspaceId: session.workspace.id, | ||
}) | ||
await findCommit({ uuid: HEAD_COMMIT, projectId: project.id }) | ||
url = PROJECT_ROUTE({ id: +project.id }).commits.latest | ||
} catch (error) { | ||
if (error instanceof NotFoundError) { | ||
return notFound() | ||
} | ||
throw error | ||
} | ||
|
||
return redirect(url) | ||
} |
78 changes: 78 additions & 0 deletions
78
apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/layout.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,78 @@ | ||
import { ReactNode } from 'react' | ||
|
||
import { | ||
Commit, | ||
HEAD_COMMIT, | ||
NotFoundError, | ||
Project, | ||
} from '@latitude-data/core' | ||
import { CommitProvider, ProjectProvider } from '@latitude-data/web-ui' | ||
import { AppLayout, BreadcrumpBadge } from '@latitude-data/web-ui/browser' | ||
import { findCommit, findProject } from '$/app/(private)/_data-access' | ||
import { NAV_LINKS } from '$/app/(private)/_lib/constants' | ||
import { ProjectPageParams } from '$/app/(private)/projects/[projectId]/page' | ||
import Sidebar from '$/components/Sidebar' | ||
import { getCurrentUser, SessionData } from '$/services/auth/getCurrentUser' | ||
import { notFound } from 'next/navigation' | ||
|
||
export type CommitPageParams = { | ||
children: ReactNode | ||
params: ProjectPageParams['params'] & { commitUuid: string } | ||
} | ||
|
||
export default async function CommitLayout({ | ||
children, | ||
params, | ||
}: CommitPageParams) { | ||
const isHead = params.commitUuid === HEAD_COMMIT | ||
let session: SessionData | ||
let project: Project | ||
let commit: Commit | ||
try { | ||
session = await getCurrentUser() | ||
project = await findProject({ | ||
projectId: params.projectId, | ||
workspaceId: session.workspace.id, | ||
}) | ||
commit = await findCommit({ | ||
uuid: params.commitUuid, | ||
projectId: project.id, | ||
}) | ||
} catch (error) { | ||
if (error instanceof NotFoundError) { | ||
return notFound() | ||
} | ||
throw error | ||
} | ||
|
||
return ( | ||
<ProjectProvider project={project}> | ||
<CommitProvider commit={commit} isHead={isHead}> | ||
<AppLayout | ||
navigationLinks={NAV_LINKS} | ||
currentUser={session.user} | ||
breadcrumbs={[ | ||
{ name: session.workspace.name }, | ||
{ name: project.name }, | ||
{ | ||
name: ( | ||
<BreadcrumpBadge | ||
uuid={commit.uuid} | ||
title={commit.title} | ||
isHead={isHead} | ||
/> | ||
), | ||
}, | ||
]} | ||
> | ||
<main className='flex flex-row w-full'> | ||
<div className='w-[280px]'> | ||
<Sidebar commitUuid={commit.uuid} projectId={project.id} /> | ||
</div> | ||
<div className='flex-1'>{children}</div> | ||
</main> | ||
</AppLayout> | ||
</CommitProvider> | ||
</ProjectProvider> | ||
) | ||
} |
5 changes: 5 additions & 0 deletions
5
apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/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,5 @@ | ||
export const dynamic = 'force-dynamic' | ||
|
||
export default async function CommitRoot() { | ||
return <div>Commits home</div> | ||
} |
5 changes: 5 additions & 0 deletions
5
apps/web/src/app/(private)/projects/[projectId]/versions/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,5 @@ | ||
import ProjectPage from '$/app/(private)/projects/[projectId]/page' | ||
|
||
export const dynamic = 'force-dynamic' | ||
|
||
export default ProjectPage |
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,5 @@ | ||
import AppRoot from '$/app/(private)/page' | ||
|
||
export const dynamic = 'force-dynamic' | ||
|
||
export default AppRoot |
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
Oops, something went wrong.