mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 22:27:16 +01:00
Refactored useQuery functions.
This commit is contained in:
parent
be550cc440
commit
b578162cb6
33 changed files with 179 additions and 151 deletions
|
|
@ -1,29 +1,16 @@
|
|||
import { ReactNode, Dispatch, SetStateAction } from 'react';
|
||||
import { ReactNode } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { Banner, Loading, SearchField } from 'react-basics';
|
||||
import { useMessages } from 'components/hooks';
|
||||
import Empty from 'components/common/Empty';
|
||||
import Pager from 'components/common/Pager';
|
||||
import styles from './DataTable.module.css';
|
||||
import { FilterQueryResult } from 'components/hooks/useFilterQuery';
|
||||
|
||||
const DEFAULT_SEARCH_DELAY = 600;
|
||||
|
||||
export interface DataTableProps {
|
||||
queryResult: {
|
||||
result: {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
count: number;
|
||||
data: any[];
|
||||
};
|
||||
params: {
|
||||
query: string;
|
||||
page: number;
|
||||
};
|
||||
setParams: Dispatch<SetStateAction<{ query: string; page: number }>>;
|
||||
isLoading: boolean;
|
||||
error: unknown;
|
||||
};
|
||||
queryResult: FilterQueryResult<any>;
|
||||
searchDelay?: number;
|
||||
allowSearch?: boolean;
|
||||
allowPaging?: boolean;
|
||||
|
|
@ -38,7 +25,12 @@ export function DataTable({
|
|||
children,
|
||||
}: DataTableProps) {
|
||||
const { formatMessage, labels, messages } = useMessages();
|
||||
const { result, error, isLoading, params, setParams } = queryResult || {};
|
||||
const {
|
||||
result,
|
||||
params,
|
||||
setParams,
|
||||
query: { error, isLoading },
|
||||
} = queryResult || {};
|
||||
const { page, pageSize, count, data } = result || {};
|
||||
const { query } = params || {};
|
||||
const hasData = Boolean(!isLoading && data?.length);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ export interface FilterLinkProps {
|
|||
label?: string;
|
||||
externalUrl?: string;
|
||||
className?: string;
|
||||
children: ReactNode;
|
||||
children?: ReactNode;
|
||||
}
|
||||
|
||||
export function FilterLink({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue