Skip to content

Commit

Permalink
Fix queryOptions type
Browse files Browse the repository at this point in the history
  • Loading branch information
slax57 authored and bendenoz committed Jun 27, 2024
1 parent 72f9067 commit 1d1dde1
Showing 1 changed file with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { useCallback, useMemo } from 'react';
import { useFormContext, useWatch } from 'react-hook-form';

import { FilterPayload, RaRecord, SortPayload } from '../../types';
import {
FilterPayload,
GetListResult,
RaRecord,
SortPayload,
} from '../../types';
import { useGetList, useGetManyAggregate } from '../../dataProvider';
import { useReferenceParams } from './useReferenceParams';
import { ChoicesContextValue } from '../../form';
Expand Down Expand Up @@ -68,7 +73,9 @@ export const useReferenceArrayInputController = <
},
{
enabled: value != null && value.length > 0,
...otherQueryOptions,
...(otherQueryOptions as UseQueryOptions<
GetManyAggregateResult<RecordType>
>),
}
);

Expand Down Expand Up @@ -113,7 +120,9 @@ export const useReferenceArrayInputController = <
retry: false,
enabled: isGetMatchingEnabled,
keepPreviousData: true,
...otherQueryOptions,
...(otherQueryOptions as UseQueryOptions<
GetListResult<RecordType>
>),
}
);

Expand Down Expand Up @@ -189,19 +198,16 @@ const mergeReferences = <RecordType extends RaRecord = any>(
return res;
};

type GetManyAggregateResult<RecordType extends RaRecord = any> = RecordType[];

export interface UseReferenceArrayInputParams<
RecordType extends RaRecord = any
> {
debounce?: number;
filter?: FilterPayload;
queryOptions?: UseQueryOptions<{
data: RecordType[];
total?: number;
pageInfo?: {
hasNextPage?: boolean;
hasPreviousPage?: boolean;
};
}> & { meta?: any };
queryOptions?: UseQueryOptions<
GetListResult<RecordType> | GetManyAggregateResult<RecordType>
> & { meta?: any };
page?: number;
perPage?: number;
record?: RecordType;
Expand Down

0 comments on commit 1d1dde1

Please sign in to comment.