Skip to content

Commit

Permalink
init new branch
Browse files Browse the repository at this point in the history
  • Loading branch information
nikos-koukis committed Oct 12, 2023
1 parent d87f1d6 commit f757127
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 51 deletions.
66 changes: 66 additions & 0 deletions src/views/Home/Home copy.tsx
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;

54 changes: 3 additions & 51 deletions src/views/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,10 @@ 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>
<>
Work
</>
)
};

Expand Down

0 comments on commit f757127

Please sign in to comment.