diff --git a/packages/twenty-front/src/modules/object-record/graphql/types/RecordGqlOperationFilter.ts b/packages/twenty-front/src/modules/object-record/graphql/types/RecordGqlOperationFilter.ts index 1d4fb29bc991..c973e687c55b 100644 --- a/packages/twenty-front/src/modules/object-record/graphql/types/RecordGqlOperationFilter.ts +++ b/packages/twenty-front/src/modules/object-record/graphql/types/RecordGqlOperationFilter.ts @@ -103,7 +103,6 @@ export type EmailsFilter = { export type PhonesFilter = { primaryPhoneNumber?: StringFilter; - primaryPhoneCountryCode?: StringFilter; }; export type SelectFilter = { diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/constants/NumberFilterTypes.ts b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/constants/NumberFilterTypes.ts index 5f36ae347fd8..c17732c2dd94 100644 --- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/constants/NumberFilterTypes.ts +++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/constants/NumberFilterTypes.ts @@ -1 +1 @@ -export const NUMBER_FILTER_TYPES = ['NUMBER', 'CURRENCY']; +export const NUMBER_FILTER_TYPES = ['NUMBER', 'CURRENCY', 'PHONES']; diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/constants/TextFilterTypes.ts b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/constants/TextFilterTypes.ts index 9ff7456c42f4..0c702e01cf0a 100644 --- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/constants/TextFilterTypes.ts +++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/constants/TextFilterTypes.ts @@ -2,7 +2,6 @@ export const TEXT_FILTER_TYPES = [ 'TEXT', 'EMAIL', 'EMAILS', - 'PHONE', 'FULL_NAME', 'LINK', 'LINKS', @@ -10,5 +9,4 @@ export const TEXT_FILTER_TYPES = [ 'ACTOR', 'ARRAY', 'RAW_JSON', - 'PHONES', ]; diff --git a/packages/twenty-front/src/modules/object-record/record-filter/utils/__tests__/computeViewRecordGqlOperationFilter.test.ts b/packages/twenty-front/src/modules/object-record/record-filter/utils/__tests__/computeViewRecordGqlOperationFilter.test.ts index 694107ae3c12..9542d5e4280c 100644 --- a/packages/twenty-front/src/modules/object-record/record-filter/utils/__tests__/computeViewRecordGqlOperationFilter.test.ts +++ b/packages/twenty-front/src/modules/object-record/record-filter/utils/__tests__/computeViewRecordGqlOperationFilter.test.ts @@ -588,36 +588,16 @@ describe('should work as expected for the different field types', () => { }, }, }, - { - phones: { - primaryPhoneCountryCode: { - ilike: '%1234567890%', - }, - }, - }, ], }, { - and: [ - { - not: { - phones: { - primaryPhoneNumber: { - ilike: '%1234567890%', - }, - }, - }, - }, - { - not: { - phones: { - primaryPhoneCountryCode: { - ilike: '%1234567890%', - }, - }, + not: { + phones: { + primaryPhoneNumber: { + ilike: '%1234567890%', }, }, - ], + }, }, { and: [ @@ -639,24 +619,6 @@ describe('should work as expected for the different field types', () => { }, ], }, - { - or: [ - { - phones: { - primaryPhoneCountryCode: { - is: 'NULL', - }, - }, - }, - { - phones: { - primaryPhoneCountryCode: { - ilike: '', - }, - }, - }, - ], - }, ], }, { @@ -680,24 +642,6 @@ describe('should work as expected for the different field types', () => { }, ], }, - { - or: [ - { - phones: { - primaryPhoneCountryCode: { - is: 'NULL', - }, - }, - }, - { - phones: { - primaryPhoneCountryCode: { - ilike: '', - }, - }, - }, - ], - }, ], }, }, diff --git a/packages/twenty-front/src/modules/object-record/record-filter/utils/computeViewRecordGqlOperationFilter.ts b/packages/twenty-front/src/modules/object-record/record-filter/utils/computeViewRecordGqlOperationFilter.ts index c806dd3fe41d..c47c0f86fe2e 100644 --- a/packages/twenty-front/src/modules/object-record/record-filter/utils/computeViewRecordGqlOperationFilter.ts +++ b/packages/twenty-front/src/modules/object-record/record-filter/utils/computeViewRecordGqlOperationFilter.ts @@ -10,6 +10,7 @@ import { EmailsFilter, FloatFilter, MultiSelectFilter, + PhonesFilter, RatingFilter, RawJsonFilter, RecordGqlOperationFilter, @@ -831,23 +832,34 @@ const computeFilterRecordGqlOperationFilter = ( ); } case 'PHONES': { - const phonesFilters = generateILikeFiltersForCompositeFields( - filter.value, - correspondingField.name, - ['primaryPhoneNumber', 'primaryPhoneCountryCode'], - ); + const filterValue = filter.value.replace(/[^0-9]/g, ''); + switch (filter.operand) { case ViewFilterOperand.Contains: return { - or: phonesFilters, + or: [ + { + [correspondingField.name]: { + primaryPhoneNumber: { + ilike: `%${filterValue}%`, + }, + } as PhonesFilter, + }, + ], }; case ViewFilterOperand.DoesNotContain: - return { - and: phonesFilters.map((filter) => { - return { - not: filter, - }; - }), + return { + and: [ + { + not: { + [correspondingField.name]: { + primaryPhoneNumber: { + ilike: `%${filterValue}%`, + }, + } as PhonesFilter, + }, + }, + ], }; case ViewFilterOperand.IsEmpty: case ViewFilterOperand.IsNotEmpty: diff --git a/packages/twenty-front/src/modules/object-record/record-filter/utils/getEmptyRecordGqlOperationFilter.ts b/packages/twenty-front/src/modules/object-record/record-filter/utils/getEmptyRecordGqlOperationFilter.ts index b2cce9468bc5..5fb5a09464f0 100644 --- a/packages/twenty-front/src/modules/object-record/record-filter/utils/getEmptyRecordGqlOperationFilter.ts +++ b/packages/twenty-front/src/modules/object-record/record-filter/utils/getEmptyRecordGqlOperationFilter.ts @@ -46,7 +46,7 @@ export const getEmptyRecordGqlOperationFilter = ( const phonesFilter = generateILikeFiltersForCompositeFields( '', correspondingField.name, - ['primaryPhoneNumber', 'primaryPhoneCountryCode'], + ['primaryPhoneNumber'], true, ); diff --git a/packages/twenty-front/src/modules/object-record/record-filter/utils/isRecordMatchingFilter.ts b/packages/twenty-front/src/modules/object-record/record-filter/utils/isRecordMatchingFilter.ts index 88b3780b8c7e..e11a8fab0322 100644 --- a/packages/twenty-front/src/modules/object-record/record-filter/utils/isRecordMatchingFilter.ts +++ b/packages/twenty-front/src/modules/object-record/record-filter/utils/isRecordMatchingFilter.ts @@ -324,8 +324,7 @@ export const isRecordMatchingFilter = ({ const phonesFilter = filterValue as PhonesFilter; const keys: (keyof PhonesFilter)[] = [ - 'primaryPhoneNumber', - 'primaryPhoneCountryCode', + 'primaryPhoneNumber' ]; return keys.some((key) => {