Skip to content

Commit 855bc21

Browse files
Add completed tasks to navbar, create profile route
1 parent 7df512c commit 855bc21

File tree

4 files changed

+62
-15
lines changed

4 files changed

+62
-15
lines changed

next.config.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1-
/**
2-
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
3-
* for Docker builds.
4-
*/
51
await import("./src/env.js");
62

73
/** @type {import("next").NextConfig} */
8-
const config = {};
4+
const config = {
5+
images: {
6+
remotePatterns: [
7+
{
8+
protocol: "https",
9+
hostname: "cdn.discordapp.com",
10+
port: "",
11+
pathname: "/embed/avatars/**",
12+
},
13+
],
14+
},
15+
};
916

1017
export default config;

prisma/schema.prisma

+9-8
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,15 @@ model Session {
5454
}
5555

5656
model User {
57-
id String @id @default(cuid())
58-
name String?
59-
email String? @unique
60-
emailVerified DateTime?
61-
image String?
62-
accounts Account[]
63-
sessions Session[]
64-
tasks Task[]
57+
id String @id @default(cuid())
58+
name String?
59+
email String? @unique
60+
emailVerified DateTime?
61+
image String?
62+
accounts Account[]
63+
sessions Session[]
64+
tasks Task[]
65+
completedTasks Int @default(0)
6566
}
6667

6768
model VerificationToken {

src/app/_components/navbar.tsx

+12-2
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,19 @@ const Navbar = () => {
2929
</div>
3030
<ul
3131
tabIndex={0}
32-
className="menu menu-sm dropdown-content rounded-box z-[1] mt-3 w-52 bg-violet-50 p-2 shadow"
32+
className="menu dropdown-content menu-sm z-[1] mt-3 w-52 rounded-box bg-violet-50 p-2 shadow"
3333
>
3434
<li className="text-2xl text-orange-500">
3535
<Link href="/">Home</Link>
3636
</li>
3737
<li className="text-orange-500">
3838
<Link href="/create-task">Create Task</Link>
3939
</li>
40+
{user !== undefined && (
41+
<li className="text-orange-500">
42+
<Link href="/completed-tasks">Completed</Link>
43+
</li>
44+
)}
4045
{user !== undefined && (
4146
<li className="text-orange-500">
4247
<Link href={`/profiles/${user?.id}`}>Profile</Link>
@@ -61,7 +66,12 @@ const Navbar = () => {
6166
</li>
6267
{user !== undefined && (
6368
<li className="rounded text-lg font-medium text-zinc-950 hover:bg-orange-200">
64-
<Link href={`/profiles/${user?.id}`}>Profile</Link>
69+
<Link href="/completed-tasks">Completed</Link>
70+
</li>
71+
)}
72+
{user !== undefined && (
73+
<li className="rounded text-lg font-medium text-zinc-950 hover:bg-orange-200">
74+
<Link href={`/profile/${user?.id}`}>Profile</Link>
6575
</li>
6676
)}
6777
</ul>

src/app/profile/[id]/page.tsx

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"use client";
2+
3+
import { useSession } from "next-auth/react";
4+
import Image from "next/image";
5+
import React from "react";
6+
7+
const Profile = () => {
8+
const session = useSession();
9+
const user = { ...session.data?.user };
10+
11+
console.log(session.data?.user.name);
12+
13+
return (
14+
<div className="mt-16 flex flex-col items-center">
15+
<Image
16+
src={user.image ?? ""}
17+
alt="user avatar"
18+
width={200}
19+
height={200}
20+
className="rounded-full"
21+
/>
22+
<div>
23+
<h1 className="mt-4 text-4xl">{user.name}</h1>
24+
</div>
25+
</div>
26+
);
27+
};
28+
29+
export default Profile;

0 commit comments

Comments
 (0)