vega-frontend-monorepo/apps/trading/components/page-query-container/page-query-container.tsx
Bartłomiej Głownia 25699b6283
feat(#1643): orders table filtering (#2000)
* feat(#1643): add grid set filter, amend filters in orders table

* feat(#1643): strictly type variables in orders data provider

* feat(#1643): add date range param to orders query

* feat(#1643): add date range filter

* feat(#1643): handle data provider updates after variables change in ag-grid infinite row model

* feat(#1643): fix unit tests

* feat(#1643): use DateRangeFilter in positions table instead of agDateColumnFilter

* feat(#1643): add date range filter support to orders data provider

* feat(#1643): fix update functions

* feat(#1643): remove sortable from orders list columns

* chore: remove console.log
2022-11-10 11:08:13 -08:00

31 lines
821 B
TypeScript

import type { OperationVariables, QueryHookOptions } from '@apollo/client';
import { useQuery } from '@apollo/client';
import type { DocumentNode } from 'graphql';
import type { ReactNode } from 'react';
import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
interface PageQueryContainerProps<TData, TVariables> {
query: DocumentNode;
options?: QueryHookOptions<TData, TVariables>;
render: (data: TData) => ReactNode;
}
export const PageQueryContainer = <TData, TVariables = OperationVariables>({
query,
options,
render,
}: PageQueryContainerProps<TData, TVariables>) => {
const { data, loading, error } = useQuery<TData, TVariables>(query, {
...options,
});
return (
<AsyncRenderer<TData>
loading={loading}
error={error}
data={data}
render={render}
/>
);
};