Skip to content

Commit 6084ef0

Browse files
committed
add dashboard paths
1 parent e0c5116 commit 6084ef0

4 files changed

Lines changed: 38 additions & 9 deletions

File tree

app/dashboard/[[...path]]/page.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@ import DashboardClient from "@/components/dashboard/dashboard-client";
22

33
export function generateStaticParams() {
44
// This satisfies the static export requirement
5-
return [{ path: [] }];
5+
// Include common dashboard paths to pre-render them
6+
return [
7+
{ path: [] },
8+
{ path: ["profile"] },
9+
{ path: ["profile", "new"] },
10+
{ path: ["posts"] },
11+
{ path: ["posts", "new"] },
12+
];
613
}
714

815
export default function DashboardPage() {

app/dashboard/layout.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import type React from "react";
2+
export default function DashboardLayout({ children }: { children: React.ReactNode }) {
3+
return <div className="container mx-auto px-4 py-8">{children}</div>;
4+
}

app/dashboard/not-found.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Link from "next/link";
2+
import { Button } from "@/components/ui/button";
3+
4+
export default function DashboardNotFound() {
5+
return (
6+
<div className="flex flex-col items-center justify-center py-12">
7+
<h1 className="text-2xl font-bold mb-4">Page not found</h1>
8+
<p className="text-muted-foreground mb-6">The dashboard page you are looking for does not exist.</p>
9+
<Link href="/dashboard">
10+
<Button>Back to Dashboard</Button>
11+
</Link>
12+
</div>
13+
);
14+
}

components/dashboard/dashboard-client.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,31 +63,35 @@ export default function DashboardClient() {
6363
return null;
6464
}
6565

66+
console.log("Current pathname:", pathname); // Add this for debugging
67+
6668
// Extract the path parts after /dashboard/
6769
const pathParts = pathname.split("/").slice(2);
6870
const section = pathParts[0] || "";
6971
const action = pathParts[1] || "";
7072
const id = pathParts[2] || "";
7173

74+
console.log("Path parts:", { section, action, id }); // Add this for debugging
75+
7276
// Render the appropriate component based on the path
73-
if (section === "posts") {
77+
if (section === "profile") {
7478
if (action === "new") {
75-
return <NewPost user={user} />;
79+
return <NewProfile user={user} />;
7680
}
7781
if (action === "edit" && id) {
78-
return <PostEditor user={user} postId={id} />;
82+
return <ProfileEditor user={user} profileId={id} />;
7983
}
80-
return <PostsList user={user} />;
84+
return <ProfileView user={user} />;
8185
}
8286

83-
if (section === "profile") {
87+
if (section === "posts") {
8488
if (action === "new") {
85-
return <NewProfile user={user} />;
89+
return <NewPost user={user} />;
8690
}
8791
if (action === "edit" && id) {
88-
return <ProfileEditor user={user} profileId={id} />;
92+
return <PostEditor user={user} postId={id} />;
8993
}
90-
return <ProfileView user={user} />;
94+
return <PostsList user={user} />;
9195
}
9296

9397
// Default to dashboard home

0 commit comments

Comments
 (0)