Skip to content

Commit 01b82e4

Browse files
committed
feat: refactor dashboard structure to module
1 parent 86273d1 commit 01b82e4

File tree

5 files changed

+138
-118
lines changed

5 files changed

+138
-118
lines changed

src/app/dashboard/layout.tsx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
1-
import { redirect } from "next/navigation";
2-
import { Navigation } from "@/components/navigation";
3-
import { getSession } from "@/modules/auth/utils/auth-utils";
1+
import DashboardLayout from "@/modules/dashboard/dashboard.layout";
42

5-
export default async function DashboardLayout({
3+
export default async function Layout({
64
children,
75
}: {
86
children: React.ReactNode;
97
}) {
10-
const session = await getSession();
11-
12-
if (!session) {
13-
redirect("/login");
14-
}
15-
16-
return (
17-
<div className="flex flex-col min-h-screen">
18-
<Navigation />
19-
20-
<div className="w-full md:w-xl mx-auto py-8 px-4">{children}</div>
21-
</div>
22-
);
8+
return <DashboardLayout>{children}</DashboardLayout>;
239
}

src/app/dashboard/page.tsx

Lines changed: 3 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,5 @@
1-
import { CheckSquare, List, Plus } from "lucide-react";
2-
import Link from "next/link";
3-
import { Button } from "@/components/ui/button";
4-
import {
5-
Card,
6-
CardContent,
7-
CardDescription,
8-
CardHeader,
9-
CardTitle,
10-
} from "@/components/ui/card";
1+
import Dashboard from "@/modules/dashboard/dashboard.page";
112

12-
export default async function Dashboard() {
13-
return (
14-
<div className="container mx-auto py-12 px-4">
15-
<div className="text-center mb-12">
16-
<h1 className="text-4xl font-bold text-gray-900 mb-4">
17-
Welcome to TodoApp
18-
</h1>
19-
<p className="text-xl text-gray-600 max-w-2xl mx-auto">
20-
A simple and elegant todo application built with Next.js 15,
21-
TailwindCSS, and shadcn/ui components.
22-
</p>
23-
</div>
24-
25-
<div className="grid md:grid-cols-2 gap-8 max-w-4xl mx-auto">
26-
<Card className="hover:shadow-lg transition-shadow">
27-
<CardHeader>
28-
<CardTitle className="flex items-center">
29-
<List className="mr-2 h-5 w-5" />
30-
View Todos
31-
</CardTitle>
32-
<CardDescription>
33-
Browse and manage all your todos in one place
34-
</CardDescription>
35-
</CardHeader>
36-
<CardContent>
37-
<Link href="/dashboard/todos">
38-
<Button className="w-full">
39-
<CheckSquare className="mr-2 h-4 w-4" />
40-
Go to Todos
41-
</Button>
42-
</Link>
43-
</CardContent>
44-
</Card>
45-
46-
<Card className="hover:shadow-lg transition-shadow">
47-
<CardHeader>
48-
<CardTitle className="flex items-center">
49-
<Plus className="mr-2 h-5 w-5" />
50-
Create Todo
51-
</CardTitle>
52-
<CardDescription>
53-
Add a new task to your todo list
54-
</CardDescription>
55-
</CardHeader>
56-
<CardContent>
57-
<Link href="/dashboard/todos/new">
58-
<Button className="w-full" variant="outline">
59-
<Plus className="mr-2 h-4 w-4" />
60-
Create New Todo
61-
</Button>
62-
</Link>
63-
</CardContent>
64-
</Card>
65-
</div>
66-
67-
<div className="mt-16 text-center">
68-
<h2 className="text-2xl font-semibold text-gray-900 mb-4">
69-
Features
70-
</h2>
71-
<div className="grid md:grid-cols-3 gap-6 max-w-3xl mx-auto">
72-
<div className="text-center">
73-
<div className="bg-blue-100 rounded-full w-12 h-12 flex items-center justify-center mx-auto mb-3">
74-
<CheckSquare className="h-6 w-6 text-blue-600" />
75-
</div>
76-
<h3 className="font-semibold mb-2">Task Management</h3>
77-
<p className="text-gray-600 text-sm">
78-
Create, edit, and delete todos with ease
79-
</p>
80-
</div>
81-
<div className="text-center">
82-
<div className="bg-green-100 rounded-full w-12 h-12 flex items-center justify-center mx-auto mb-3">
83-
<List className="h-6 w-6 text-green-600" />
84-
</div>
85-
<h3 className="font-semibold mb-2">Categories</h3>
86-
<p className="text-gray-600 text-sm">
87-
Organize your todos with custom categories
88-
</p>
89-
</div>
90-
<div className="text-center">
91-
<div className="bg-purple-100 rounded-full w-12 h-12 flex items-center justify-center mx-auto mb-3">
92-
<Plus className="h-6 w-6 text-purple-600" />
93-
</div>
94-
<h3 className="font-semibold mb-2">Rich Features</h3>
95-
<p className="text-gray-600 text-sm">
96-
Priorities, due dates, images, and more
97-
</p>
98-
</div>
99-
</div>
100-
</div>
101-
</div>
102-
);
3+
export default async function Page() {
4+
return <Dashboard />;
1035
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { redirect } from "next/navigation";
2+
import { Navigation } from "@/components/navigation";
3+
import { getSession } from "@/modules/auth/utils/auth-utils";
4+
import authRoutes from "../auth/auth.route";
5+
6+
export default async function DashboardLayout({
7+
children,
8+
}: {
9+
children: React.ReactNode;
10+
}) {
11+
const session = await getSession();
12+
13+
if (!session) {
14+
redirect(authRoutes.login);
15+
}
16+
17+
return (
18+
<div className="flex flex-col min-h-screen">
19+
<Navigation />
20+
21+
<div className="w-full md:w-xl mx-auto py-8 px-4">{children}</div>
22+
</div>
23+
);
24+
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import { CheckSquare, List, Plus } from "lucide-react";
2+
import Link from "next/link";
3+
import { Button } from "@/components/ui/button";
4+
import {
5+
Card,
6+
CardContent,
7+
CardDescription,
8+
CardHeader,
9+
CardTitle,
10+
} from "@/components/ui/card";
11+
12+
export default async function Dashboard() {
13+
return (
14+
<div className="container mx-auto py-12 px-4">
15+
<div className="text-center mb-12">
16+
<h1 className="text-4xl font-bold text-gray-900 mb-4">
17+
Welcome to TodoApp
18+
</h1>
19+
<p className="text-xl text-gray-600 max-w-2xl mx-auto">
20+
A simple and elegant todo application built with Next.js 15,
21+
TailwindCSS, and shadcn/ui components.
22+
</p>
23+
</div>
24+
25+
<div className="grid md:grid-cols-2 gap-8 max-w-4xl mx-auto">
26+
<Card className="hover:shadow-lg transition-shadow">
27+
<CardHeader>
28+
<CardTitle className="flex items-center">
29+
<List className="mr-2 h-5 w-5" />
30+
View Todos
31+
</CardTitle>
32+
<CardDescription>
33+
Browse and manage all your todos in one place
34+
</CardDescription>
35+
</CardHeader>
36+
<CardContent>
37+
<Link href="/dashboard/todos">
38+
<Button className="w-full">
39+
<CheckSquare className="mr-2 h-4 w-4" />
40+
Go to Todos
41+
</Button>
42+
</Link>
43+
</CardContent>
44+
</Card>
45+
46+
<Card className="hover:shadow-lg transition-shadow">
47+
<CardHeader>
48+
<CardTitle className="flex items-center">
49+
<Plus className="mr-2 h-5 w-5" />
50+
Create Todo
51+
</CardTitle>
52+
<CardDescription>
53+
Add a new task to your todo list
54+
</CardDescription>
55+
</CardHeader>
56+
<CardContent>
57+
<Link href="/dashboard/todos/new">
58+
<Button className="w-full" variant="outline">
59+
<Plus className="mr-2 h-4 w-4" />
60+
Create New Todo
61+
</Button>
62+
</Link>
63+
</CardContent>
64+
</Card>
65+
</div>
66+
67+
<div className="mt-16 text-center">
68+
<h2 className="text-2xl font-semibold text-gray-900 mb-4">
69+
Features
70+
</h2>
71+
<div className="grid md:grid-cols-3 gap-6 max-w-3xl mx-auto">
72+
<div className="text-center">
73+
<div className="bg-blue-100 rounded-full w-12 h-12 flex items-center justify-center mx-auto mb-3">
74+
<CheckSquare className="h-6 w-6 text-blue-600" />
75+
</div>
76+
<h3 className="font-semibold mb-2">Task Management</h3>
77+
<p className="text-gray-600 text-sm">
78+
Create, edit, and delete todos with ease
79+
</p>
80+
</div>
81+
<div className="text-center">
82+
<div className="bg-green-100 rounded-full w-12 h-12 flex items-center justify-center mx-auto mb-3">
83+
<List className="h-6 w-6 text-green-600" />
84+
</div>
85+
<h3 className="font-semibold mb-2">Categories</h3>
86+
<p className="text-gray-600 text-sm">
87+
Organize your todos with custom categories
88+
</p>
89+
</div>
90+
<div className="text-center">
91+
<div className="bg-purple-100 rounded-full w-12 h-12 flex items-center justify-center mx-auto mb-3">
92+
<Plus className="h-6 w-6 text-purple-600" />
93+
</div>
94+
<h3 className="font-semibold mb-2">Rich Features</h3>
95+
<p className="text-gray-600 text-sm">
96+
Priorities, due dates, images, and more
97+
</p>
98+
</div>
99+
</div>
100+
</div>
101+
</div>
102+
);
103+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const dashboardRoutes = {
2+
dashboard: "/dashboard",
3+
} as const;
4+
5+
export default dashboardRoutes;

0 commit comments

Comments
 (0)