From 0ed6f5217974dd321fe20ce1537c2ec290bfa6bd Mon Sep 17 00:00:00 2001 From: Pedro Yves Fracari Date: Thu, 21 Nov 2024 14:20:58 -0300 Subject: [PATCH] chore: add current pool on pool selector --- apps/deposit-pool/src/app/page.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/deposit-pool/src/app/page.tsx b/apps/deposit-pool/src/app/page.tsx index 1dc7916..0d91e26 100644 --- a/apps/deposit-pool/src/app/page.tsx +++ b/apps/deposit-pool/src/app/page.tsx @@ -8,7 +8,7 @@ import { } from "@bleu/cow-hooks-ui"; import { COW_NATIVE_TOKEN_ADDRESS } from "@bleu/utils"; import { ALL_SUPPORTED_CHAIN_IDS, type Address } from "@cowprotocol/cow-sdk"; -import { useCallback, useState } from "react"; +import { useCallback, useMemo, useState } from "react"; import { useFormContext, useWatch } from "react-hook-form"; import { PoolForm } from "#/components/PoolForm"; import { PoolItemInfo } from "#/components/PoolItemInfo"; @@ -34,6 +34,18 @@ export default function Page() { const selectedPool = useSelectedPool(); + const allPools = useMemo(() => { + if (!pools && !selectedPool) return []; + if (!selectedPool) return pools || []; + if (!pools) return [selectedPool]; + return [...pools, selectedPool].filter((item, index, array) => { + return ( + index === + array.findIndex((obj) => obj.id.toLowerCase() === item.id.toLowerCase()) + ); + }); + }, [pools, selectedPool]); + const loadHookInfo = useCallback(async () => { if ( !context?.hookToEdit?.hook.callData || @@ -142,7 +154,7 @@ export default function Page() { setValue("poolId", pool.id)} PoolItemInfo={PoolItemInfo} - pools={pools || []} + pools={allPools} selectedPool={selectedPool} isCheckDetailsCentered={false} />