2023-10-09 14:59:00 +00:00
|
|
|
import { useVegaWallet } from '@vegaprotocol/wallet';
|
|
|
|
import { FundingPaymentsManager } from '@vegaprotocol/funding-payments';
|
|
|
|
import { create } from 'zustand';
|
|
|
|
import { persist } from 'zustand/middleware';
|
|
|
|
import { useDataGridEvents } from '@vegaprotocol/datagrid';
|
|
|
|
import { Splash } from '@vegaprotocol/ui-toolkit';
|
|
|
|
import type { DataGridSlice } from '../../stores/datagrid-store-slice';
|
|
|
|
import { createDataGridSlice } from '../../stores/datagrid-store-slice';
|
|
|
|
import { useMarketClickHandler } from '../../lib/hooks/use-market-click-handler';
|
2023-11-16 03:10:39 +00:00
|
|
|
import { useT } from '../../lib/use-t';
|
2023-10-09 14:59:00 +00:00
|
|
|
|
2023-10-16 09:19:08 +00:00
|
|
|
export const FundingPaymentsContainer = ({
|
|
|
|
marketId,
|
|
|
|
}: {
|
|
|
|
marketId?: string;
|
|
|
|
}) => {
|
2023-11-16 03:10:39 +00:00
|
|
|
const t = useT();
|
2023-10-09 14:59:00 +00:00
|
|
|
const onMarketClick = useMarketClickHandler(true);
|
|
|
|
const { pubKey } = useVegaWallet();
|
|
|
|
|
|
|
|
const gridStore = useFundingPaymentsStore((store) => store.gridStore);
|
|
|
|
const updateGridStore = useFundingPaymentsStore(
|
|
|
|
(store) => store.updateGridStore
|
|
|
|
);
|
|
|
|
|
|
|
|
const gridStoreCallbacks = useDataGridEvents(gridStore, (colState) => {
|
|
|
|
updateGridStore(colState);
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!pubKey) {
|
|
|
|
return (
|
|
|
|
<Splash>
|
|
|
|
<p>{t('Please connect Vega wallet')}</p>
|
|
|
|
</Splash>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<FundingPaymentsManager
|
|
|
|
partyId={pubKey}
|
2023-10-16 09:19:08 +00:00
|
|
|
marketId={marketId}
|
2023-10-09 14:59:00 +00:00
|
|
|
onMarketClick={onMarketClick}
|
|
|
|
gridProps={gridStoreCallbacks}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-12-28 12:33:18 +00:00
|
|
|
export const useFundingPaymentsStore = create<DataGridSlice>()(
|
2023-10-09 14:59:00 +00:00
|
|
|
persist(createDataGridSlice, {
|
|
|
|
name: 'vega_funding_payments_store',
|
|
|
|
})
|
|
|
|
);
|