-
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
Showing
5 changed files
with
69 additions
and
60 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
111 changes: 58 additions & 53 deletions
111
packages/client/src/ui/features/login/ConnectWalletDialog.tsx
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,61 +1,66 @@ | ||
import { braavos, useAccount, useConnect } from "@starknet-react/core"; | ||
import { braavos, argent, useAccount, useConnect } from "@starknet-react/core"; | ||
import { ShowItem, usePersistUIStore, useUIStore } from "../../../store"; | ||
import { GreenButton } from "../../components/GreenButton"; | ||
import { Dialog } from "../../components/Dialog"; | ||
import { useMemo } from "react"; | ||
import { usePlayerProfile } from "../../hooks/usePlayerProfile"; | ||
import { logDebug } from "../../lib/utils"; | ||
|
||
export function ConnectWalletDialog() { | ||
const show = useUIStore((state) => | ||
state.getShow(ShowItem.ConnectWalletDialog) | ||
); | ||
const setShow = useUIStore((state) => state.setShow); | ||
|
||
const setLoggedIn = usePersistUIStore((state) => state.setLoggedIn); | ||
|
||
const { connect } = useConnect(); | ||
const { isConnected } = useAccount(); | ||
const { playerName } = usePlayerProfile(); | ||
|
||
logDebug( | ||
"playerName:", | ||
playerName, | ||
!playerName, | ||
playerName.length, | ||
!!playerName, | ||
"isConnected: ", | ||
isConnected | ||
); | ||
|
||
useMemo(() => { | ||
if (isConnected) { | ||
setLoggedIn(true); | ||
setShow(ShowItem.ConnectWalletDialog, false); | ||
if (!playerName) { | ||
logDebug("show SessionWalletCreate"); | ||
setShow(ShowItem.SessionWalletCreate, true); | ||
} | ||
} | ||
}, [isConnected, setLoggedIn, setShow, playerName]); | ||
|
||
if (!show) return null; | ||
|
||
return ( | ||
<Dialog className="flex flex-col items-center justify-center"> | ||
<div className="text-2xl ml-4">Connect Wallet</div> | ||
<img className="w-32 mt-12" src="/assets/ui/braavos.png" /> | ||
|
||
<div className="flex flex-row items-center justify-center mt-12 w-full"> | ||
<GreenButton | ||
className="w-2/5 h-12 ml-4" | ||
onClick={() => { | ||
connect({ connector: braavos() }); | ||
}} | ||
> | ||
Connect to your braavos Wallet | ||
</GreenButton> | ||
</div> | ||
</Dialog> | ||
); | ||
const show = useUIStore((state) => | ||
state.getShow(ShowItem.ConnectWalletDialog) | ||
); | ||
const setShow = useUIStore((state) => state.setShow); | ||
|
||
const setLoggedIn = usePersistUIStore((state) => state.setLoggedIn); | ||
|
||
const { connect } = useConnect(); | ||
const { isConnected } = useAccount(); | ||
const { playerName } = usePlayerProfile(); | ||
|
||
logDebug( | ||
"playerName:", | ||
playerName, | ||
!playerName, | ||
playerName.length, | ||
!!playerName, | ||
"isConnected: ", | ||
isConnected | ||
); | ||
|
||
useMemo(() => { | ||
if (isConnected) { | ||
setLoggedIn(true); | ||
setShow(ShowItem.ConnectWalletDialog, false); | ||
if (!playerName) { | ||
logDebug("show SessionWalletCreate"); | ||
setShow(ShowItem.SessionWalletCreate, true); | ||
} | ||
} | ||
}, [isConnected, setLoggedIn, setShow, playerName]); | ||
|
||
if (!show) return null; | ||
|
||
return ( | ||
<Dialog className="flex flex-col items-center justify-center"> | ||
<div className="text-2xl ml-4 mb-12">Choose your Wallet</div> | ||
|
||
<div className="flex flex-row items-center justify-center gap-16 h-32"> | ||
<img | ||
onClick={() => { | ||
connect({ connector: braavos() }); | ||
}} | ||
className="w-16 cursor-pointer hover:scale-110 transition-transform" | ||
src="/assets/ui/braavos.png" | ||
/> | ||
|
||
<img | ||
onClick={() => { | ||
connect({ connector: argent() }); | ||
}} | ||
className="w-16 cursor-pointer hover:scale-110 transition-transform" | ||
src="/assets/ui/argent.png" | ||
/> | ||
</div> | ||
</Dialog> | ||
); | ||
} |