diff --git a/src/app/profile/[slug]/page.tsx b/src/app/profile/[slug]/page.tsx index e024d48..d6b94e0 100644 --- a/src/app/profile/[slug]/page.tsx +++ b/src/app/profile/[slug]/page.tsx @@ -1,7 +1,12 @@ -import Image from "next/image"; import { redirect } from "next/navigation"; +import Image from "next/image"; +import Link from "next/link"; +import { Icon } from "@iconify/react"; + +import { auth } from "@/lib/auth"; import { prisma } from "@/lib/prisma"; + import MiiList from "@/app/components/mii-list"; interface Props { @@ -10,6 +15,7 @@ interface Props { } export default async function ProfilePage({ params, searchParams }: Props) { + const session = await auth(); const { slug } = await params; const user = await prisma.user.findFirst({ @@ -33,7 +39,7 @@ export default async function ProfilePage({ params, searchParams }: Props) { className="aspect-square rounded-full border-2 border-amber-500 shadow" /> -
+

{user?.name}

@{user?.username}

@@ -43,6 +49,13 @@ export default async function ProfilePage({ params, searchParams }: Props) {

Created: {user?.createdAt.toLocaleDateString("en-GB", { month: "long", day: "2-digit", year: "numeric" })}

+ + {session?.user.id == slug && ( + + + Settings + + )}
diff --git a/src/app/profile/settings/page.tsx b/src/app/profile/settings/page.tsx new file mode 100644 index 0000000..ffc5ca3 --- /dev/null +++ b/src/app/profile/settings/page.tsx @@ -0,0 +1,116 @@ +import { redirect } from "next/navigation"; +import Image from "next/image"; + +import { auth } from "@/lib/auth"; +import { prisma } from "@/lib/prisma"; +import { Icon } from "@iconify/react"; +import Link from "next/link"; + +export default async function ProfileSettingsPage() { + const session = await auth(); + + if (!session) redirect("/login"); + + const userExtra = await prisma.user.findUnique({ where: { id: Number(session.user.id) } }); + const likedMiis = await prisma.like.count({ where: { userId: Number(session.user.id) } }); + + return ( +
+
+ profile picture + +
+

{session.user.name}

+

@{session.user.username}

+ +

+ Liked {likedMiis} Miis +

+

+ Created: {userExtra!.createdAt.toLocaleDateString("en-GB", { month: "long", day: "2-digit", year: "numeric" })} +

+ + + + Back + +
+
+ +
+
+

Profile Settings

+

Update your account info, username, and preferences.

+
+ + {/* Separator */} +
+
+ Account Info +
+
+ + {/* Change Name */} +
+
+ +

This is the name shown on your profile — feel free to change it anytime

+
+ +
+ + +
+
+ + {/* Change Username */} +
+
+ +

Your unique tag on the site. Can only be changed once every 90 days

+
+ +
+ + +
+
+ + {/* Separator */} +
+
+ Danger Zone +
+
+ + {/* Delete Account */} +
+
+ +

This will permanently remove your account and all uploaded Miis. This action cannot be undone

+
+ + +
+
+
+ ); +}