Sammy/t 190 aau i see other filters city on people (#101)

* feature: add email filter

* feature: add city filter

* test: fix company search tests

* test: use the right value in test

* refactor: test all the filters in a loop
This commit is contained in:
Sammy Teillet
2023-05-05 12:16:25 +02:00
committed by GitHub
parent 55eff2b7a2
commit f022bf8335
4 changed files with 189 additions and 79 deletions

View File

@ -5,6 +5,12 @@ import {
People_Bool_Exp,
Users_Bool_Exp,
} from '../../../generated/graphql';
import { GraphqlQueryCompany } from '../../../interfaces/company.interface';
import {
SEARCH_COMPANY_QUERY,
SEARCH_PEOPLE_QUERY,
} from '../../../services/search/search';
import { GraphqlQueryPerson } from '../../../interfaces/person.interface';
export type SortType<SortKey = string> = {
label: string;
@ -46,3 +52,25 @@ export type SelectedFilterType<WhereTemplate> = FilterType<WhereTemplate> & {
operand: FilterOperandType;
where: WhereTemplate;
};
export function assertFilterUseCompanySearch<FilterValue>(
filter: FilterType<People_Bool_Exp>,
): filter is FilterType<People_Bool_Exp> & {
searchResultMapper: (data: GraphqlQueryCompany) => {
displayValue: string;
value: FilterValue;
};
} {
return filter.searchQuery === SEARCH_COMPANY_QUERY;
}
export function assertFilterUsePeopleSearch<FilterValue>(
filter: FilterType<People_Bool_Exp>,
): filter is FilterType<People_Bool_Exp> & {
searchResultMapper: (data: GraphqlQueryPerson) => {
displayValue: string;
value: FilterValue;
};
} {
return filter.searchQuery === SEARCH_PEOPLE_QUERY;
}