Skip to content

Commit

Permalink
chore: add current pool on pool selector
Browse files Browse the repository at this point in the history
  • Loading branch information
yvesfracari committed Nov 21, 2024
1 parent a9f83de commit 0ed6f52
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions apps/deposit-pool/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 ||
Expand Down Expand Up @@ -142,7 +154,7 @@ export default function Page() {
<PoolsDropdownMenu
onSelect={(pool: IPool) => setValue("poolId", pool.id)}
PoolItemInfo={PoolItemInfo}
pools={pools || []}
pools={allPools}
selectedPool={selectedPool}
isCheckDetailsCentered={false}
/>
Expand Down

0 comments on commit 0ed6f52

Please sign in to comment.