diff --git a/app/(auth)/login/page.tsx b/app/(auth)/login/page.tsx index f3ceae7afd354a8b1b1fc9301c5b6f25e2eca343..f499915ecddbb268410432807a0eb8c2c9dcca56 100644 --- a/app/(auth)/login/page.tsx +++ b/app/(auth)/login/page.tsx @@ -4,7 +4,7 @@ import Link from 'next/link' export default function LoginPage() { return ( <div className="h-screen w-screen flex justify-center items-center bg-slate-100"> - <div className="sm:shadow-xl px-8 pb-8 pt-12 sm:bg-white rounded-xl space-y-12"> + <div className="sm:shadow-xl px-8 pb-8 pt-12 sm:bg-black rounded-xl space-y-12"> <h1 className="font-semibold text-2xl">Login</h1> <LoginForm /> <p className="text-center"> diff --git a/app/(auth)/signup/page.tsx b/app/(auth)/signup/page.tsx index 8f2d6d9dffb89f50281a46d4e4ac89bbcd05654f..ea1b9f6903ff3760516c72353c6c14f392819529 100644 --- a/app/(auth)/signup/page.tsx +++ b/app/(auth)/signup/page.tsx @@ -4,7 +4,7 @@ import Link from 'next/link' export default function SignupPage() { return ( <div className="h-screen w-screen flex justify-center items-center bg-slate-100"> - <div className="sm:shadow-xl px-8 pb-8 pt-12 sm:bg-white rounded-xl space-y-12"> + <div className="sm:shadow-xl px-8 pb-8 pt-12 sm:bg-black rounded-xl space-y-12"> <h1 className="font-semibold text-2xl">Create your Account</h1> <SignupForm /> <p className="text-center"> diff --git a/app/(content)/(user)/[userid]/page.tsx b/app/(content)/(user)/[userid]/page.tsx index 69fa2065f2ba3c79cce8dd9d19db4264ecadb2f6..86ddc8ad3eadfa841f8e89e7d82f93ea50456d1a 100644 --- a/app/(content)/(user)/[userid]/page.tsx +++ b/app/(content)/(user)/[userid]/page.tsx @@ -1,8 +1,40 @@ +'use client' +import { useSession } from "next-auth/react"; + + export default function User({ params }: { params: { userid: string } }) { + const { data: session } = useSession(); return ( - <> - <h1>User Profile Page WIP</h1> - <p>Unique Page Params: {params.userid}</p> - </> + <div className="mt-8 px-4"> + <div className="flex-shrink-0"> + <title>{`GameUnity User`}</title> + <div className="h-10 w-10 rounded-full bg-gray-300"></div> {/* Profile picture */} + </div> + <div className="flex flex-col"> + <p className="text-white text-2xl font-semibold"> + {session?.user.name} + </p> + <div + className=" + flex + flex-row + items-center + gap-2 + mt-4 + text-neutral-500 + "> + </div> + </div> + <div className="flex flex-row items-center mt-4 gap-6"> + <div className="flex flex-row items-center gap-1"> + <p className="text-neutral-500">Following</p> + </div> + <div className="flex flex-row items-center gap-1"> + <p className="text-white">{}</p> + <p className="text-neutral-500">Followers</p> + </div> + </div> + </div> + ) } \ No newline at end of file diff --git a/app/(content)/(user)/[userid]/followers/page.tsx b/app/(content)/followers/page.tsx similarity index 55% rename from app/(content)/(user)/[userid]/followers/page.tsx rename to app/(content)/followers/page.tsx index a024dd2d33ce785d357b497bb47fde72553d5230..7d8778f1536ea8bccdf82875f3b1ccb301ed563b 100644 --- a/app/(content)/(user)/[userid]/followers/page.tsx +++ b/app/(content)/followers/page.tsx @@ -1,8 +1,9 @@ +import { authOptions } from "@/app/api/auth/[...nextauth]/route"; import FollowersList from "@/components/following-users"; -import { useSession } from "next-auth/react"; +import { getServerSession } from "next-auth"; -export default function Followers() { - const { data: session } = useSession(); +export default async function Followers() { + const session = await getServerSession(authOptions); if (!session) { return <div>Loading...</div>; diff --git a/app/(content)/layout.tsx b/app/(content)/layout.tsx index 0e27a5e2484fc79b7061b26b072adb93f36cda51..b960adc16735c90def990ddce4d44f07074b8255 100644 --- a/app/(content)/layout.tsx +++ b/app/(content)/layout.tsx @@ -15,6 +15,7 @@ export default async function ContentLayout({ <aside className="hidden w-[200px] flex-col md:flex"> <div className="sticky top-0"> <DashboardNav items={dashboardConfig.sidebarNav} /> + <button>Logout</button> </div> </aside> <main className="flex w-full flex-1 flex-col overflow-hidden"> diff --git a/app/(content)/(user)/[userid]/notifications/page.tsx b/app/(content)/notifications/page.tsx similarity index 100% rename from app/(content)/(user)/[userid]/notifications/page.tsx rename to app/(content)/notifications/page.tsx diff --git a/app/api/user/[userid].ts b/app/api/user/[userid].ts new file mode 100644 index 0000000000000000000000000000000000000000..5fa1e7c6303bfcd9b8181eaf1680cdb213aa549d --- /dev/null +++ b/app/api/user/[userid].ts @@ -0,0 +1,28 @@ +import { NextApiRequest, NextApiResponse } from "next"; + +import { prisma } from "@/lib/db"; + +export default async function handler(req: NextApiRequest, res: NextApiResponse) { + if (req.method !== 'GET') { + return res.status(405).end(); + } + + try { + const { userId } = req.query; + + if (!userId || typeof userId !== 'string') { + throw new Error('Invalid ID'); + } + + const existingUser = await prisma.user.findUnique({ + where: { + id : +userId + } + }); + + return res.status(200).json({ ...existingUser}); + } catch (error) { + console.log(error); + return res.status(400).end(); + } +}; \ No newline at end of file diff --git a/app/api/user/index.ts b/app/api/user/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..abb35ff5646110d1595419851254f320385d9175 --- /dev/null +++ b/app/api/user/index.ts @@ -0,0 +1,22 @@ +import { NextApiRequest, NextApiResponse } from "next"; + +import { prisma } from "@/lib/db"; + +export default async function handler(req: NextApiRequest, res: NextApiResponse) { + if (req.method !== 'GET') { + return res.status(405).end(); + } + + try { + const users = await prisma.user.findMany({ + orderBy: { + createdAt: 'desc' + } + }); + + return res.status(200).json(users); + } catch(error) { + console.log(error); + return res.status(400).end(); + } +} \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 46c6b9977670490988f4a0930f68e937f4cbd2de..dbf586aff3bf9942c1708cfcf403b99eb71a2001 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -12,12 +12,13 @@ datasource db { model User { id Int @id @default(autoincrement()) - userName String? @unique - name String? + userName String? @unique + name String? @default("u ${id}") email String? @unique password String emailVerified DateTime? - image String? + image String? + createdAt DateTime @default(now()) Post Post[] Comment Comment[]