Skip to content

Commit

Permalink
navigate back from token selection when clicking outside
Browse files Browse the repository at this point in the history
  • Loading branch information
eli-d committed Aug 19, 2024
1 parent fe2fbf3 commit 411071c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions web/src/app/stake/pool/create/select-prime-asset/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { Hash } from "viem";
import { usdFormat } from "@/lib/usdFormat";
import { graphql, useFragment } from "@/gql";
import { useFeatureFlag } from "@/hooks/useFeatureFlag";
import { useDetectClickOutside } from "react-detect-click-outside";

const SelectPrimeAssetFragment = graphql(`
fragment SelectPrimeAssetFragment on SeawaterPool {
Expand All @@ -43,6 +44,10 @@ const SelectPrimeAssetFragment = graphql(`
const SelectPrimeAsset = () => {
const router = useRouter();

const ref = useDetectClickOutside({
onTriggered: () => router.back(),
});

const [boostedPools, setBoostedPools] = useState(false);
const [myAssets, setMyAssets] = useState(false);

Expand Down Expand Up @@ -116,6 +121,7 @@ const SelectPrimeAsset = () => {
<motion.div
layoutId={"modal"}
className="flex h-[514px] w-[318px] flex-col rounded-lg bg-black px-[12px] pb-[12px] pt-[9px] text-white md:h-[547px] md:w-[393px]"
ref={ref}
>
<div className={"flex flex-row items-center justify-between"}>
<div className={"text-[10px]"}>Select Prime Asset</div>
Expand Down
6 changes: 6 additions & 0 deletions web/src/app/swap/explore/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { useAccount } from "wagmi";
import { config } from "@/config";
import { getFormattedStringFromTokenAmount } from "@/lib/amounts";
import { SwapExploreFragmentFragment } from "@/gql/graphql";
import { useDetectClickOutside } from "react-detect-click-outside";

const SwapExploreFragment = graphql(`
fragment SwapExploreFragment on SeawaterPool {
Expand All @@ -45,6 +46,10 @@ const ExplorePage = () => {

const searchParams = useSearchParams();

const ref = useDetectClickOutside({
onTriggered: () => router.back(),
});

const token = searchParams.get("token") as "0" | "1";

const { data, isLoading } = useGraphqlGlobal();
Expand Down Expand Up @@ -120,6 +125,7 @@ const ExplorePage = () => {
<div className={"flex flex-col items-center overflow-y-auto"}>
<motion.div
layoutId={"modal"}
ref={ref}
className={
"h-[509px] w-[325px] rounded-lg bg-black p-[10px] text-white md:h-[559px] md:w-[393px]"
}
Expand Down

0 comments on commit 411071c

Please sign in to comment.