-
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
d87f1d6
commit f757127
Showing
2 changed files
with
69 additions
and
51 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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { useSession, signIn, signOut } from "next-auth/react" | ||
import { Button, Box } from "@chakra-ui/react"; | ||
import { useGetUserInfo } from "@/views/Home/hooks/hooks"; | ||
import NewUserForm from "./components/NewUserForm/NewUserForm"; | ||
import withDappProvider from "@/hoc/withDappProvider"; | ||
import ExistingUser from "./components/ExistingUser/ExistingUser"; | ||
|
||
|
||
const Home = () => { | ||
|
||
const { data: session } = useSession() | ||
console.log("⚠️ ~ file: Home.tsx:12 ~ Home ~ session::::", session) | ||
|
||
const email = session?.user?.email || ""; | ||
const platform = "google"; | ||
|
||
const {userInfo, isLoadingUserInfo, errorUserInfo} = useGetUserInfo(email, platform); | ||
console.log("⚠️ ~ file: Home.tsx:18 ~ Home ~ userInfo::::", userInfo) | ||
|
||
let userExists = false; | ||
if (!isLoadingUserInfo && session && userInfo?.address != "") { | ||
userExists = true; | ||
} | ||
|
||
if (session) { | ||
return ( | ||
<Box> | ||
Signed in as {session?.user?.email} <br /> | ||
ID: {session?.user?.sub} <br /> | ||
<Button | ||
w={'fit'} | ||
_hover={{ | ||
opacity: 1, | ||
boxShadow: 'lg' | ||
}} | ||
onClick={() => signOut()} | ||
> | ||
Sign Out | ||
</Button> | ||
{userExists ? | ||
<ExistingUser email={session?.user?.email} address={userInfo?.address || ""} secretWords={userInfo?.secretWords || []}/> | ||
: | ||
<NewUserForm email={email} platform={platform}/> | ||
} | ||
</Box> | ||
) | ||
} | ||
return ( | ||
<Box> | ||
Not signed in <br /> | ||
<Button | ||
w={'fit'} | ||
_hover={{ | ||
opacity: 1, | ||
boxShadow: 'lg' | ||
}} | ||
onClick={() => signIn()} | ||
> | ||
Sign in | ||
</Button> | ||
</Box> | ||
) | ||
}; | ||
|
||
export default Home; | ||
|
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