-
Notifications
You must be signed in to change notification settings - Fork 0
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
1159b42
commit cc44db4
Showing
4 changed files
with
55 additions
and
16 deletions.
There are no files selected for viewing
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,21 +1,10 @@ | ||
import { getServerSession } from "next-auth"; | ||
import { Balancer } from "react-wrap-balancer"; | ||
import { authOptions } from "~/app/api/auth/[...nextauth]/route"; | ||
import getUser from "~/applications/Authentication/Api/getUser"; | ||
import UnsignedHome from "~/views/Home/UnsignedHome"; | ||
|
||
const HomePage = async () => { | ||
return ( | ||
<> | ||
<Balancer | ||
as="h1" | ||
className="bg-gradient-to-br from-black to-stone-500 bg-clip-text text-center font-display text-4xl font-bold tracking-[-0.02em] drop-shadow-sm md:text-7xl md:leading-[5rem]" | ||
> | ||
PComparator Compare prices of many products | ||
</Balancer> | ||
<Balancer as="p" className="mt-6 text-center text-gray-500 md:text-xl"> | ||
PriceComparator is the price comparator for foods, cosmetic and more | ||
</Balancer> | ||
</> | ||
); | ||
const user = await getUser(); | ||
|
||
return user.exist ? <h1>Hello {user.user?.name}</h1> : <UnsignedHome />; | ||
}; | ||
|
||
export default HomePage; |
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,12 @@ | ||
import { getServerSession } from "next-auth"; | ||
import { authOptions } from "~/app/api/auth/[...nextauth]/route"; | ||
import { User } from "~/applications/Authentication/Domain/User"; | ||
|
||
const getUser = async () => { | ||
const session = await getServerSession(authOptions); | ||
const user = new User(session?.user); | ||
|
||
return user; | ||
}; | ||
|
||
export default getUser; |
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,19 @@ | ||
import { Session } from "next-auth"; | ||
|
||
type UserProfile = { | ||
email?: string | null | undefined; | ||
name?: string | null | undefined; | ||
image?: string | null | undefined; | ||
}; | ||
|
||
export class User { | ||
public readonly user: UserProfile | undefined; | ||
|
||
constructor(user: Session["user"]) { | ||
this.user = user; | ||
} | ||
|
||
get exist(): boolean { | ||
return !!this.user ?? false; | ||
} | ||
} |
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,19 @@ | ||
import { Balancer } from "react-wrap-balancer"; | ||
|
||
const UnsignedHome = () => { | ||
return ( | ||
<> | ||
<Balancer | ||
as="h1" | ||
className="bg-gradient-to-br from-black to-stone-500 bg-clip-text text-center font-display text-4xl font-bold tracking-[-0.02em] drop-shadow-sm md:text-7xl md:leading-[5rem]" | ||
> | ||
PComparator Compare prices of many products | ||
</Balancer> | ||
<Balancer as="p" className="mt-6 text-center text-gray-500 md:text-xl"> | ||
PriceComparator is the price comparator for foods, cosmetic and more | ||
</Balancer> | ||
</> | ||
); | ||
}; | ||
|
||
export default UnsignedHome; |