From 43f61b8c82d09790cb2173e96584e363803198af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Magrin?= Date: Wed, 13 Nov 2024 15:50:26 +0100 Subject: [PATCH] fix: clean --- .../types/RecordGroupDefinition.ts | 6 +-- .../hooks/internal/useTableRowIds.ts | 45 ------------------- 2 files changed, 1 insertion(+), 50 deletions(-) delete mode 100644 packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useTableRowIds.ts diff --git a/packages/twenty-front/src/modules/object-record/record-group/types/RecordGroupDefinition.ts b/packages/twenty-front/src/modules/object-record/record-group/types/RecordGroupDefinition.ts index 8e088b2005b2..f1f4199d97bc 100644 --- a/packages/twenty-front/src/modules/object-record/record-group/types/RecordGroupDefinition.ts +++ b/packages/twenty-front/src/modules/object-record/record-group/types/RecordGroupDefinition.ts @@ -5,8 +5,6 @@ export const enum RecordGroupDefinitionType { NoValue = 'no-value', } -export const recordGroupDefaultId = 'default' as const; - export type RecordGroupDefinition = { id: string; fieldMetadataId: string; @@ -18,6 +16,4 @@ export type RecordGroupDefinition = { isVisible: boolean; }; -export type RecordGroupDefinitionId = - | RecordGroupDefinition['id'] - | typeof recordGroupDefaultId; +export type RecordGroupDefinitionId = RecordGroupDefinition['id']; diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useTableRowIds.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useTableRowIds.ts deleted file mode 100644 index abed8ecea931..000000000000 --- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useTableRowIds.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { recordGroupDefinitionsComponentState } from '@/object-record/record-group/states/recordGroupDefinitionsComponentState'; -import { recordGroupDefaultId } from '@/object-record/record-group/types/RecordGroupDefinition'; -import { tableRowIdsByGroupComponentFamilyState } from '@/object-record/record-table/states/tableRowIdsByGroupComponentFamilyState'; -import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; -import { useRecoilComponentCallbackStateV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentCallbackStateV2'; -import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; -import { useRecoilCallback } from 'recoil'; - -export const useTableRowIds = (recordTableId?: string) => { - const tableRowIdsByGroupFamilyState = useRecoilComponentCallbackStateV2( - tableRowIdsByGroupComponentFamilyState, - recordTableId, - ); - - const recordGroupDefinitions = useRecoilComponentValueV2( - recordGroupDefinitionsComponentState, - recordTableId, - ); - - return useRecoilCallback( - ({ snapshot }) => - () => { - if (recordGroupDefinitions.length === 0) { - const tableRowIds = getSnapshotValue( - snapshot, - tableRowIdsByGroupFamilyState(recordGroupDefaultId), - ); - - return tableRowIds; - } - - return recordGroupDefinitions - .map((recordGroupDefinition) => { - const tableRowIds = getSnapshotValue( - snapshot, - tableRowIdsByGroupFamilyState(recordGroupDefinition.id), - ); - - return tableRowIds; - }) - .flat(); - }, - [recordGroupDefinitions, tableRowIdsByGroupFamilyState], - ); -};