Skip to content

Commit

Permalink
fix: owned pail only if wallet connected
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveVodrazka committed Nov 19, 2024
1 parent 5d660f5 commit 7b6ff3c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/components/ConnectWallet/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,18 @@ export const WalletButton = () => {
</button>
);
};

export const OpenWalletDialogButton = () => {
const { address } = useAccount();
const { openWalletConnectModal } = useConnectWallet();

if (address) {
return null;
}

return (
<button onClick={openWalletConnectModal} className="main primary active">
Connect Wallet
</button>
);
};
26 changes: 25 additions & 1 deletion src/components/PAIL/Owned.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,38 @@
import { LoadingAnimation } from "../Loading/Loading";
import { usePailTokenIds } from "../../hooks/usePailTokenIds";
import { useProvider, useSendTransaction } from "@starknet-react/core";
import {
useAccount,
useProvider,
useSendTransaction,
} from "@starknet-react/core";
import { PAIL_ADDRESS, PAIL_NFT_ADDRESS } from "../../constants/amm";
import toast from "react-hot-toast";
import { OpenWalletDialogButton } from "../ConnectWallet/Button";

export const Owned = () => {
const { address } = useAccount();
const { isLoading, isError, error, data } = usePailTokenIds();
const { sendAsync } = useSendTransaction({});
const { provider } = useProvider();

if (!address) {
return (
<div style={{ width: "fit-content" }}>
<div
style={{
display: "flex",
flexFlow: "column",
alignItems: "center",
gap: "10px",
}}
>
<p>Connect wallet to see your positions</p>
<OpenWalletDialogButton />
</div>
</div>
);
}

if (isLoading) {
return <LoadingAnimation />;
}
Expand Down

0 comments on commit 7b6ff3c

Please sign in to comment.