-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
44bdfb7
commit 2c5f911
Showing
13 changed files
with
346 additions
and
188 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import Image from "next/image"; | ||
import classNames from "classnames"; | ||
|
||
import { getServerAuthSession } from "@/server/auth" | ||
import { db } from "@/server/db"; | ||
import { Label } from "@/components/ui/label"; | ||
|
||
|
||
export default async function UserProfileWidget() { | ||
const session = await getServerAuthSession(); | ||
|
||
const userDetails = session?.user; | ||
const userId = String(userDetails?.id); | ||
const userName = String(userDetails?.name); | ||
const userImage = String(userDetails?.image) | ||
const userEmail = String(userDetails?.email) | ||
|
||
|
||
const getAccountProvider = await db.account.findFirst({ | ||
where: { | ||
userId: userId | ||
}, | ||
select: { | ||
provider: true, | ||
} | ||
}) | ||
|
||
const provider = String(getAccountProvider?.provider); | ||
|
||
const providerFormatted = provider.charAt(0).toUpperCase() + provider.slice(1); | ||
|
||
|
||
|
||
return ( | ||
<> | ||
<div className="flex flex-row items-center justify-center gap-40"> | ||
<Image | ||
alt="PROFILE PIC OF USER" | ||
src={userImage} | ||
blurDataURL={userImage} | ||
height={400} | ||
width={400} | ||
className="rounded-2xl" | ||
priority | ||
/> | ||
|
||
|
||
<div className="space-y-8"> | ||
<div> | ||
<Label className="text-lg text-muted-foreground underline">Your Name</Label> | ||
<h1 className={classNames({ | ||
"font-bold text-3xl text-gray-600": true, | ||
})}> | ||
{userName} | ||
</h1> | ||
</div> | ||
|
||
<div> | ||
<Label className="text-lg text-muted-foreground underline">Email</Label> | ||
<h1 className={classNames({ | ||
"font-bold text-3xl text-gray-600": true, | ||
})}> | ||
{userEmail} | ||
</h1> | ||
</div> | ||
|
||
<div> | ||
<Label className="text-lg text-muted-foreground underline">OAuth Provider</Label> | ||
<h1 className={classNames({ | ||
"font-bold text-3xl text-gray-600": true, | ||
})}> | ||
{providerFormatted} | ||
</h1> | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { getServerAuthSession } from '@/server/auth' | ||
import { type Metadata } from 'next' | ||
|
||
import type { ILayout } from 'types' | ||
|
||
|
||
export async function generateMetadata(): Promise<Metadata> { | ||
const sessionDetails = await getServerAuthSession(); | ||
|
||
const userDetails = sessionDetails?.user; | ||
|
||
const userProfilePic = userDetails?.image; | ||
const userName = userDetails?.name; | ||
|
||
|
||
return { | ||
title: "Profile || " + userName, | ||
icons: [`${userProfilePic}`] | ||
} | ||
} | ||
|
||
|
||
|
||
export default function ProfileLayout( | ||
{ children }: ILayout | ||
) { | ||
return ( | ||
<> | ||
{children} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
export default function UsersProfilePage() { | ||
import { getServerAuthSession } from "@/server/auth" | ||
import { redirect } from "next/navigation"; | ||
|
||
import UserProfileWidget from "./_components/UserProfileWidget"; | ||
import classNames from "classnames"; | ||
|
||
|
||
export default async function UsersProfilePage() { | ||
const session = await getServerAuthSession(); | ||
|
||
!session && redirect("/api/auth/signin?callbackUrl=%2Fprofile") | ||
|
||
|
||
return ( | ||
<div>UsersProfilePage</div> | ||
<section className={classNames({ | ||
"py-12 px-20 my-2": true, | ||
})}> | ||
<UserProfileWidget /> | ||
</section> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.