Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Templates + Fixing Route Architecture #151

Merged
merged 6 commits into from
Aug 21, 2023
Merged
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
2 changes: 1 addition & 1 deletion app/(dashboard)/dashboard/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default async function DashboardLayout({
</div>
</header>

<div className="grid flex-1 gap-12 md:grid-cols-[200px_1fr] px-10">
<div className="grid flex-1 gap-4 md:grid-cols-[200px_1fr] px-10">
<aside className="hidden w-[200px] flex-col md:flex">
<DashboardNav items={dashboardConfig.sidebarNav} />
</aside>
Expand Down
16 changes: 8 additions & 8 deletions app/(dashboard)/dashboard/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { DashboardHeader } from "@/components/header"
import { JotCreateButton } from "@/components/jot-create-button"
import { JotItem } from "@/components/jot-item"
import { DashboardShell } from "@/components/shell"
import { PageHeader } from "@/components/page-header"
import { JotCreateButton } from "@/components/jots/jot-create-button"
import { JotItem } from "@/components/jots/jot-item"
import { PageShell } from "@/components/page-shell"

export default function DashboardLoading() {
return (
<DashboardShell>
<DashboardHeader
<PageShell>
<PageHeader
heading="Jots"
text="Create and manage jots."
>
<JotCreateButton />
</DashboardHeader>
</PageHeader>
<div className="divide-border-200 divide-y rounded-md border">
<JotItem.Skeleton />
<JotItem.Skeleton />
<JotItem.Skeleton />
<JotItem.Skeleton />
<JotItem.Skeleton />
</div>
</DashboardShell>
</PageShell>
)
}
16 changes: 8 additions & 8 deletions app/(dashboard)/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { authOptions } from "@/lib/auth"
import { db } from "@/lib/db"
import { getCurrentUser } from "@/lib/session"
import { EmptyPlaceholder } from "@/components/empty-placeholder"
import { DashboardHeader } from "@/components/header"
import { JotCreateButton } from "@/components/jot-create-button"
import { JotItem } from "@/components/jot-item"
import { DashboardShell } from "@/components/shell"
import { PageHeader } from "@/components/page-header"
import { JotCreateButton } from "@/components/jots/jot-create-button"
import { JotItem } from "@/components/jots/jot-item"
import { PageShell } from "@/components/page-shell"

export const metadata = {
title: "Dashboard",
Expand Down Expand Up @@ -36,13 +36,13 @@ export default async function DashboardPage() {
})

return (
<DashboardShell>
<DashboardHeader
<PageShell>
<PageHeader
heading="Jots"
text="Create and manage jots."
>
<JotCreateButton />
</DashboardHeader>
</PageHeader>
<div>
{jots?.length ? (
<div className="divide-y divide-border rounded-md border">
Expand All @@ -61,6 +61,6 @@ export default async function DashboardPage() {
</EmptyPlaceholder>
)}
</div>
</DashboardShell>
</PageShell>
)
}
11 changes: 0 additions & 11 deletions app/(editor)/editor/layout.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Link from "next/link"

import { buttonVariants } from "@/components/ui/button"
import { EmptyPlaceholder } from "@/components/empty-placeholder"

Expand All @@ -9,9 +8,12 @@ export default function NotFound() {
<EmptyPlaceholder.Icon name="warning" />
<EmptyPlaceholder.Title>Uh oh! Not Found</EmptyPlaceholder.Title>
<EmptyPlaceholder.Description>
This jot could not be found. Please try again.
This Jot could not be found. Please try again.
</EmptyPlaceholder.Description>
<Link href="/dashboard" className={buttonVariants({ variant: "ghost" })}>
<Link
href="/jots"
className={buttonVariants({ variant: "ghost" })}
>
Go to Dashboard
</Link>
</EmptyPlaceholder>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Jot, User } from "@prisma/client"
import { authOptions } from "@/lib/auth"
import { db } from "@/lib/db"
import { getCurrentUser } from "@/lib/session"
import DocumentEditor from "@/components/document-editor"
import { MyValue } from "@/types/plate-types"
import JotDetails from "@/components/jots/jot-details"

async function getJotForUser(jotId: Jot["id"], userId: User["id"]) {
return await db.jot.findFirst({
Expand All @@ -21,7 +21,6 @@ interface EditorPageProps {

export default async function EditorPage({ params }: EditorPageProps) {
const user = await getCurrentUser()

if (!user) {
redirect(authOptions?.pages?.signIn || "/login")
}
Expand All @@ -32,14 +31,16 @@ export default async function EditorPage({ params }: EditorPageProps) {
}

return (
<DocumentEditor
jot={{
id: jot.id,
title: jot.title,
content: jot.content as MyValue,
createdAt: jot.createdAt,
published: jot.published,
}}
/>
<div>
<JotDetails
jot={{
id: jot.id,
title: jot.title,
content: jot.content as MyValue,
createdAt: jot.createdAt,
published: jot.published,
}}
/>
</div>
)
}
2 changes: 1 addition & 1 deletion app/(jots)/jots/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default async function JotsLayout({
</div>
</header>

<div className="grid flex-1 gap-12 md:grid-cols-[200px_1fr] px-10">
<div className="grid flex-1 gap-4 md:grid-cols-[200px_1fr] px-10">
<aside className="hidden w-[200px] flex-col md:flex">
<DashboardNav items={dashboardConfig.sidebarNav} />
</aside>
Expand Down
16 changes: 8 additions & 8 deletions app/(jots)/jots/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { DashboardHeader } from "@/components/header"
import { JotCreateButton } from "@/components/jot-create-button"
import { JotItem } from "@/components/jot-item"
import { DashboardShell } from "@/components/shell"
import { PageHeader } from "@/components/page-header"
import { JotCreateButton } from "@/components/jots/jot-create-button"
import { JotItem } from "@/components/jots/jot-item"
import { PageShell } from "@/components/page-shell"

export default function JotsLanding() {
return (
<DashboardShell>
<DashboardHeader
<PageShell>
<PageHeader
heading="Jots"
text="Create and manage jots."
>
<JotCreateButton />
</DashboardHeader>
</PageHeader>
<div className="divide-border-200 divide-y rounded-md border">
<JotItem.Skeleton />
<JotItem.Skeleton />
<JotItem.Skeleton />
<JotItem.Skeleton />
<JotItem.Skeleton />
</div>
</DashboardShell>
</PageShell>
)
}
17 changes: 8 additions & 9 deletions app/(jots)/jots/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { authOptions } from "@/lib/auth"
import { db } from "@/lib/db"
import { getCurrentUser } from "@/lib/session"
import { EmptyPlaceholder } from "@/components/empty-placeholder"
import { DashboardHeader } from "@/components/header"
import { JotCreateButton } from "@/components/jot-create-button"
import { JotItem } from "@/components/jot-item"
import { DashboardShell } from "@/components/shell"
import { PageHeader } from "@/components/page-header"
import { JotCreateButton } from "@/components/jots/jot-create-button"
import { JotItem } from "@/components/jots/jot-item"
import { PageShell } from "@/components/page-shell"

export const metadata = {
title: "Jots",
Expand All @@ -16,7 +16,6 @@ export const metadata = {

export default async function JotsPage() {
const user = await getCurrentUser()

if (!user) {
redirect(authOptions?.pages?.signIn || "/login")
}
Expand All @@ -37,13 +36,13 @@ export default async function JotsPage() {
})

return (
<DashboardShell>
<DashboardHeader
<PageShell>
<PageHeader
heading="Jots"
text="Create and manage Jots."
>
<JotCreateButton />
</DashboardHeader>
</PageHeader>
<div>
{jots?.length ? (
<div className="divide-y divide-border rounded-md border">
Expand All @@ -62,6 +61,6 @@ export default async function JotsPage() {
</EmptyPlaceholder>
)}
</div>
</DashboardShell>
</PageShell>
)
}
2 changes: 1 addition & 1 deletion app/(projects)/projects/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default async function ProjectsLayout({
</div>
</header>

<div className="grid flex-1 gap-12 md:grid-cols-[200px_1fr] px-10">
<div className="grid flex-1 gap-4 md:grid-cols-[200px_1fr] px-10">
<aside className="hidden w-[200px] flex-col md:flex">
<DashboardNav items={dashboardConfig.sidebarNav} />
</aside>
Expand Down
16 changes: 8 additions & 8 deletions app/(projects)/projects/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { DashboardHeader } from "@/components/header"
import { JotCreateButton } from "@/components/jot-create-button"
import { JotItem } from "@/components/jot-item"
import { DashboardShell } from "@/components/shell"
import { PageHeader } from "@/components/page-header"
import { JotCreateButton } from "@/components/jots/jot-create-button"
import { JotItem } from "@/components/jots/jot-item"
import { PageShell } from "@/components/page-shell"

export default function ProjectsLanding() {
return (
<DashboardShell>
<DashboardHeader
<PageShell>
<PageHeader
heading="Projects"
text="Create and manage projects."
>
<JotCreateButton />
</DashboardHeader>
</PageHeader>
<div className="divide-border-200 divide-y rounded-md border">
<JotItem.Skeleton />
<JotItem.Skeleton />
<JotItem.Skeleton />
<JotItem.Skeleton />
<JotItem.Skeleton />
</div>
</DashboardShell>
</PageShell>
)
}
18 changes: 9 additions & 9 deletions app/(projects)/projects/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import { authOptions } from "@/lib/auth"
import { db } from "@/lib/db"
import { getCurrentUser } from "@/lib/session"
import { EmptyPlaceholder } from "@/components/empty-placeholder"
import { DashboardHeader } from "@/components/header"
import { JotCreateButton } from "@/components/jot-create-button"
import { JotItem } from "@/components/jot-item"
import { DashboardShell } from "@/components/shell"
import { PageHeader } from "@/components/page-header"
import { JotCreateButton } from "@/components/jots/jot-create-button"
import { JotItem } from "@/components/jots/jot-item"
import { PageShell } from "@/components/page-shell"

export const metadata = {
title: "Projects",
description: "Create and manage Projects.",
}

export default async function TasksPage() {
export default async function ProjectsPage() {
const user = await getCurrentUser()

if (!user) {
Expand All @@ -37,13 +37,13 @@ export default async function TasksPage() {
})

return (
<DashboardShell>
<DashboardHeader
<PageShell>
<PageHeader
heading="Projects"
text="Create and manage Projects."
>
<JotCreateButton />
</DashboardHeader>
</PageHeader>
<div>
{jots?.length ? (
<div className="divide-y divide-border rounded-md border">
Expand All @@ -62,6 +62,6 @@ export default async function TasksPage() {
</EmptyPlaceholder>
)}
</div>
</DashboardShell>
</PageShell>
)
}
2 changes: 1 addition & 1 deletion app/(settings)/settings/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default async function SettingLayout({
</div>
</header>

<div className="grid flex-1 gap-12 md:grid-cols-[200px_1fr] px-10">
<div className="grid flex-1 gap-4 md:grid-cols-[200px_1fr] px-10">
<aside className="hidden w-[200px] flex-col md:flex">
<DashboardNav items={dashboardConfig.sidebarNav} />
</aside>
Expand Down
10 changes: 5 additions & 5 deletions app/(settings)/settings/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { CardSkeleton } from "@/components/card-skeleton"
import { DashboardHeader } from "@/components/header"
import { DashboardShell } from "@/components/shell"
import { PageHeader } from "@/components/page-header"
import { PageShell } from "@/components/page-shell"

export default function SettingsLoading() {
return (
<DashboardShell>
<DashboardHeader
<PageShell>
<PageHeader
heading="Settings"
text="Manage account and website settings."
/>
<div className="grid gap-10">
<CardSkeleton />
</div>
</DashboardShell>
</PageShell>
)
}
10 changes: 5 additions & 5 deletions app/(settings)/settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { redirect } from "next/navigation"

import { authOptions } from "@/lib/auth"
import { getCurrentUser } from "@/lib/session"
import { DashboardHeader } from "@/components/header"
import { DashboardShell } from "@/components/shell"
import { PageHeader } from "@/components/page-header"
import { PageShell } from "@/components/page-shell"
import { UserNameForm } from "@/components/user-name-form"

export const metadata = {
Expand All @@ -19,14 +19,14 @@ export default async function SettingsPage() {
}

return (
<DashboardShell>
<DashboardHeader
<PageShell>
<PageHeader
heading="Settings"
text="Manage account and website settings."
/>
<div className="grid gap-10">
<UserNameForm user={{ id: user.id, name: user.name || "" }} />
</div>
</DashboardShell>
</PageShell>
)
}
Loading