import { matchFilter, lpAggregatedDataProvider } from '@vegaprotocol/liquidity'; import { useDataProvider } from '@vegaprotocol/data-provider'; import { Tab, Tabs } from '@vegaprotocol/ui-toolkit'; import { useVegaWallet } from '@vegaprotocol/wallet-react'; import { useEffect, useState } from 'react'; import { useParams } from 'react-router-dom'; import { LiquidityContainer } from '../../components/liquidity-container'; import { useT } from '../../lib/use-t'; import { ErrorBoundary } from '../../components/error-boundary'; const enum LiquidityTabs { Active = 'active', Inactive = 'inactive', MyLiquidityProvision = 'myLP', } export const Liquidity = () => { const params = useParams(); const marketId = params.marketId; return ; }; export const LiquidityViewContainer = ({ marketId, }: { marketId: string | undefined; }) => { const t = useT(); const [tab, setTab] = useState(undefined); const { pubKey } = useVegaWallet(); const { data } = useDataProvider({ dataProvider: lpAggregatedDataProvider, skipUpdates: true, variables: { marketId: marketId || '' }, skip: !marketId, }); useEffect(() => { if (data) { if (pubKey && data.some((lp) => matchFilter({ partyId: pubKey }, lp))) { setTab(LiquidityTabs.MyLiquidityProvision); return; } if (data.some((lp) => matchFilter({ active: true }, lp))) { setTab(LiquidityTabs.Active); return; } setTab(LiquidityTabs.Inactive); } }, [data, pubKey]); return (
); };