Refactor Filter type to accept Is, Is Not, Contains, Does not Contain (#128)
* Refactor Filter type to accept Is, Is Not, Contains, Does not Contain * Remove any and add tests
This commit is contained in:
@ -1,9 +1,7 @@
|
||||
import { gql, useQuery } from '@apollo/client';
|
||||
import { useMemo, useState } from 'react';
|
||||
import {
|
||||
SearchConfigType,
|
||||
SearchableType,
|
||||
} from '../../../interfaces/search/interface';
|
||||
import { SearchConfigType } from '../../../interfaces/search/interface';
|
||||
import { AnyEntity } from '../../../interfaces/entities/generic.interface';
|
||||
|
||||
export const SEARCH_PEOPLE_QUERY = gql`
|
||||
query SearchQuery($where: people_bool_exp, $limit: Int) {
|
||||
@ -58,7 +56,7 @@ const debounce = <FuncArgs extends any[]>(
|
||||
};
|
||||
};
|
||||
|
||||
export type SearchResultsType<T extends SearchableType> = {
|
||||
export type SearchResultsType<T extends AnyEntity = AnyEntity> = {
|
||||
results: {
|
||||
render: (value: T) => string;
|
||||
value: T;
|
||||
@ -66,7 +64,7 @@ export type SearchResultsType<T extends SearchableType> = {
|
||||
loading: boolean;
|
||||
};
|
||||
|
||||
export const useSearch = <T extends SearchableType>(): [
|
||||
export const useSearch = <T extends AnyEntity = AnyEntity>(): [
|
||||
SearchResultsType<T>,
|
||||
React.Dispatch<React.SetStateAction<string>>,
|
||||
React.Dispatch<React.SetStateAction<SearchConfigType<T> | null>>,
|
||||
|
||||
Reference in New Issue
Block a user