Skip to content

Commit

Permalink
disconnect the wallet in the mynfts view
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielaDelPilarR committed Apr 26, 2024
1 parent 5c95592 commit d0c7b9a
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { useOutsideClick } from "~~/hooks/scaffold-stark";
import { getTargetNetworks } from "~~/utils/scaffold-stark";
import { Address } from "@starknet-react/chains";
import { useDisconnect } from "@starknet-react/core";
import { usePathname } from "next/navigation";

const allowedNetworks = getTargetNetworks();

Expand All @@ -32,17 +33,25 @@ export const AddressInfoDropdown = ({
blockExplorerAddressLink,
}: AddressInfoDropdownProps) => {
const { disconnect } = useDisconnect();
const location = usePathname();

const [addressCopied, setAddressCopied] = useState(false);

const [selectingNetwork, setSelectingNetwork] = useState(false);
const dropdownRef = useRef<HTMLDetailsElement>(null);

const closeDropdown = () => {
setSelectingNetwork(false);
dropdownRef.current?.removeAttribute("open");
};

useOutsideClick(dropdownRef, closeDropdown);

const handleDisconnect = () => {
if (location === "/myNFTs") {
disconnect();
}
};

return (
<>
<details ref={dropdownRef} className="dropdown dropdown-end leading-3">
Expand Down Expand Up @@ -135,7 +144,7 @@ export const AddressInfoDropdown = ({
<button
className="menu-item text-error btn-sm !rounded-xl flex gap-3 py-3"
type="button"
onClick={() => disconnect()}
onClick={handleDisconnect}
>
<ArrowLeftEndOnRectangleIcon className="h-6 w-4 ml-2 sm:ml-0" />{" "}
<span>Disconnect</span>
Expand Down

0 comments on commit d0c7b9a

Please sign in to comment.