From 96264e264ccfaaaa1a7290e1b3fab91deb5f4f40 Mon Sep 17 00:00:00 2001 From: Charles Bochet Date: Fri, 5 Jan 2024 19:18:22 +0100 Subject: [PATCH] Refactor recoil v4 (#3266) * Refactor recoil v4 * Fix ci --- packages/twenty-front/package.json | 4 +- .../modules/activities/blocks/slashMenu.tsx | 2 +- .../components/CommandMenuItem.tsx | 4 +- ...bjectFilterDropdownScopeInternalContext.ts | 4 +- .../availableFilterDefinitionsScopedState.ts | 4 +- ...lterDefinitionUsedInDropdownScopedState.ts | 4 +- ...ropdownOperandSelectUnfoldedScopedState.ts | 4 +- ...ObjectFilterDropdownUnfoldedScopedState.ts | 4 +- ...ectFilterDropdownSearchInputScopedState.ts | 4 +- ...lterDropdownSelectedEntityIdScopedState.ts | 4 +- ...terDropdownSelectedRecordIdsScopedState.ts | 4 +- .../states/onFilterSelectScopedState.ts | 4 +- .../states/selectedFilterScopedState.ts | 6 +- .../selectedOperandInDropdownScopedState.ts | 4 +- .../ObjectSortDropdownScopeInternalContext.ts | 4 +- .../availableSortDefinitionsScopedState.ts | 4 +- .../states/isSortSelectedScopedState.ts | 4 +- .../states/onSortSelectScopedState.ts | 4 +- .../RecordBoardScopeInternalContext.ts | 4 +- .../activeRecordBoardCardIdsScopedState.ts | 6 +- ...ailableRecordBoardCardFieldsScopedState.ts | 4 +- .../states/isCompactViewEnabledScopedState.ts | 4 +- .../states/isRecordBoardLoadedScopedState.ts | 4 +- .../states/onFieldsChangeScopedState.ts | 4 +- .../recordBoardCardFieldsScopedState.ts | 4 +- .../states/recordBoardColumnsScopedState.ts | 4 +- .../states/recordBoardFiltersScopedState.ts | 4 +- .../states/recordBoardSortsScopedState.ts | 4 +- .../states/savedOpportunitiesScopedState.ts | 12 ++-- .../states/savedPipelineStepsScopedState.ts | 6 +- .../savedRecordBoardCardFieldsScopedState.ts | 4 +- .../savedRecordBoardColumnsScopedState.ts | 4 +- .../states/savedRecordsScopedState.ts | 4 +- ...ddenRecordBoardCardFieldsScopedSelector.ts | 36 ++++++------ ...electedRecordBoardCardIdsScopedSelector.ts | 4 +- ...ibleRecordBoardCardFieldsScopedSelector.ts | 21 +++---- .../states/isRowSelectedScopedFamilyState.ts | 4 +- .../RecordTableScopeInternalContext.ts | 4 +- .../availableTableColumnsScopedState.ts | 4 +- ...tTableCellInEditModePositionScopedState.ts | 4 +- .../isRecordTableInitialLoadingScopedState.ts | 4 +- .../states/isSoftFocusActiveScopedState.ts | 4 +- ...isSoftFocusOnTableCellScopedFamilyState.ts | 14 ++--- .../isTableCellInEditModeScopedFamilyState.ts | 4 +- .../states/numberOfTableRowsScopedState.ts | 4 +- .../states/objectMetadataConfigScopedState.ts | 4 +- .../states/onColumnsChangeScopedState.ts | 4 +- .../states/onEntityCountChangeScopedState.ts | 4 +- .../states/resizeFieldOffsetScopedState.ts | 4 +- .../allRowsSelectedStatusScopedSelector.ts | 4 +- .../hiddenTableColumnsScopedSelector.ts | 4 +- .../numberOfTableColumnsScopedSelector.ts | 4 +- .../selectors/selectedRowIdsScopedSelector.ts | 4 +- .../tableColumnsByKeyScopedSelector.ts | 4 +- .../visibleTableColumnsScopedSelector.ts | 4 +- .../states/softFocusPositionScopedState.ts | 4 +- .../states/tableColumnsScopedState.ts | 4 +- .../states/tableFiltersScopedState.ts | 4 +- .../states/tableLastRowVisibleScopedState.ts | 4 +- .../states/tableRowIdsScopedState.ts | 4 +- .../states/tableSortsScopedState.ts | 4 +- .../components/SelectableMenuItemSelect.tsx | 6 +- .../RelationPickerScopeInternalContext.ts | 4 +- .../states/identifiersMapperScopedState.ts | 4 +- .../relationPickerPreselectedIdScopedState.ts | 4 +- .../relationPickerSearchFilterScopedState.ts | 11 ++-- .../states/searchQueryScopedState.ts | 4 +- .../components/SettingsAccountsEmailsCard.tsx | 4 +- .../DialogManagerScopeInternalContext.ts | 4 +- .../states/dialogInternalScopedState.ts | 4 +- .../SnackBarManagerScopeInternalContext.ts | 4 +- .../states/snackBarInternalScopedState.ts | 4 +- .../ui/input/components/IconPicker.tsx | 4 +- .../DropdownScopeInternalContext.ts | 4 +- .../states/dropdownHotkeyScopeScopedState.ts | 4 +- .../states/dropdownWidthScopedState.ts | 12 ++-- .../states/isDropdownOpenScopedState.ts | 4 +- .../components/SelectableItem.tsx | 4 +- .../internal/useSelectableListHotKeys.tsx | 57 +++++++------------ .../internal/useSelectableListScopedState.ts | 32 ----------- .../hooks/internal/useSelectableListStates.ts | 35 ++++++++++++ .../hooks/useSelectableList.ts | 34 ++++------- .../SelectableListScopeInternalContext.ts | 4 +- .../isSelectedItemIdFamilyStateScopeMap.ts | 9 +++ .../isSelectedItemIdMapScopedFamilyState.ts | 9 --- .../states/selectableItemIdsScopedState.ts | 6 -- .../states/selectableItemIdsStateScopeMap.ts | 6 ++ .../selectableListOnEnterScopedState.ts | 8 --- .../selectableListOnEnterStateScopeMap.ts | 8 +++ .../states/selectedItemIdScopedState.ts | 6 -- .../states/selectedItemIdStateScopeMap.ts | 6 ++ .../isSelectedItemIdFamilySelectorScopeMap.ts | 26 +++++++++ .../isSelectedItemIdScopedFamilySelector.ts | 28 --------- .../getSelectableListScopeInjectors.ts | 28 --------- .../hooks/useRecoilScopedFamilyState.ts | 4 +- .../hooks/useRecoilScopedStateV2.ts | 4 +- .../hooks/useRecoilScopedValueV2.ts | 4 +- .../hooks/useSetRecoilScopedFamilyState.ts | 4 +- .../hooks/useSetRecoilScopedStateV2.ts | 4 +- ...yStateKey.ts => FamilyStateScopeMapKey.ts} | 2 +- .../scopes-internal/types/ScopedStateKey.ts | 3 - .../scopes-internal/types/StateScopeMapKey.ts | 3 + .../utils/createScopeInternalContext.ts | 6 +- .../types/RecoilScopedSelector.ts | 4 +- .../recoil-scope/types/RecoilScopedState.ts | 4 +- ...tor.ts => createFamilySelectorScopeMap.ts} | 10 ++-- ...yState.ts => createFamilyStateScopeMap.ts} | 6 +- .../recoil-scope/utils/createScopedState.ts | 14 ----- ...dSelector.ts => createSelectorScopeMap.ts} | 8 +-- .../recoil-scope/utils/createStateScopeMap.ts | 16 ++++++ .../utils/getFamilyScopeInjector.ts | 4 +- .../recoil-scope/utils/getFamilyState.ts | 16 ++++++ .../utils/getScopedFamilyStateDeprecated.ts | 4 +- .../utilities/recoil-scope/utils/getState.ts | 10 ++++ .../ViewScopeInternalContext.ts | 4 +- .../availableFieldDefinitionsScopedState.ts | 4 +- .../availableFilterDefinitionsScopedState.ts | 4 +- .../availableSortDefinitionsScopedState.ts | 4 +- .../currentViewFieldsScopedFamilyState.ts | 4 +- .../currentViewFiltersScopedFamilyState.ts | 4 +- .../views/states/currentViewIdScopedState.ts | 12 ++-- .../currentViewSortsScopedFamilyState.ts | 4 +- .../entityCountInCurrentViewScopedState.ts | 4 +- .../states/isPersistingViewScopedState.ts | 4 +- .../states/isViewBarExpandedScopedState.ts | 4 +- .../views/states/noneScopedFamilyState.ts | 4 +- .../states/onViewFieldsChangeScopedState.ts | 4 +- .../states/onViewFiltersChangeScopedState.ts | 4 +- .../states/onViewSortsChangeScopedState.ts | 4 +- .../savedViewFieldsScopedFamilyState.ts | 4 +- .../savedViewFiltersScopedFamilyState.ts | 4 +- .../states/savedViewSortsScopedFamilyState.ts | 4 +- .../selectors/currentViewScopedSelector.ts | 4 +- .../views/states/viewEditModeScopedState.ts | 4 +- .../states/viewObjectMetadataIdScopeState.ts | 4 +- .../views/states/viewTypeScopedState.ts | 4 +- .../modules/views/states/viewsScopedState.ts | 4 +- .../SettingsAccountsEmailsInboxSettings.tsx | 6 +- .../src/testing/mock-data/accounts.ts | 8 +-- packages/twenty-front/tsconfig.app.json | 3 +- 140 files changed, 467 insertions(+), 482 deletions(-) delete mode 100644 packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListScopedState.ts create mode 100644 packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListStates.ts create mode 100644 packages/twenty-front/src/modules/ui/layout/selectable-list/states/isSelectedItemIdFamilyStateScopeMap.ts delete mode 100644 packages/twenty-front/src/modules/ui/layout/selectable-list/states/isSelectedItemIdMapScopedFamilyState.ts delete mode 100644 packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableItemIdsScopedState.ts create mode 100644 packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableItemIdsStateScopeMap.ts delete mode 100644 packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableListOnEnterScopedState.ts create mode 100644 packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableListOnEnterStateScopeMap.ts delete mode 100644 packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectedItemIdScopedState.ts create mode 100644 packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectedItemIdStateScopeMap.ts create mode 100644 packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectors/isSelectedItemIdFamilySelectorScopeMap.ts delete mode 100644 packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectors/isSelectedItemIdScopedFamilySelector.ts delete mode 100644 packages/twenty-front/src/modules/ui/layout/selectable-list/utils/internal/getSelectableListScopeInjectors.ts rename packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/{ScopedFamilyStateKey.ts => FamilyStateScopeMapKey.ts} (54%) delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/ScopedStateKey.ts create mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey.ts rename packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/{createScopedFamilySelector.ts => createFamilySelectorScopeMap.ts} (66%) rename packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/{createScopedFamilyState.ts => createFamilyStateScopeMap.ts} (51%) delete mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createScopedState.ts rename packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/{createScopedSelector.ts => createSelectorScopeMap.ts} (58%) create mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createStateScopeMap.ts create mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getFamilyState.ts create mode 100644 packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getState.ts diff --git a/packages/twenty-front/package.json b/packages/twenty-front/package.json index 506e35d13..4d95ea994 100644 --- a/packages/twenty-front/package.json +++ b/packages/twenty-front/package.json @@ -9,8 +9,8 @@ "start:clean": "yarn start --force", "build": "tsc && vite build && yarn build:inject-runtime-env", "build:inject-runtime-env": "sh ./scripts/inject-runtime-env.sh", - "tsc": "tsc --watch", - "tsc:ci": "tsc", + "tsc": "tsc --project tsconfig.app.json --watch", + "tsc:ci": "tsc --project tsconfig.app.json", "preview": "vite preview", "lint": "eslint . --report-unused-disable-directives --max-warnings 0 --config .eslintrc.cjs", "lint:ci": "yarn lint --config .eslintrc-ci.cjs", diff --git a/packages/twenty-front/src/modules/activities/blocks/slashMenu.tsx b/packages/twenty-front/src/modules/activities/blocks/slashMenu.tsx index ced25f9c8..c36d3e862 100644 --- a/packages/twenty-front/src/modules/activities/blocks/slashMenu.tsx +++ b/packages/twenty-front/src/modules/activities/blocks/slashMenu.tsx @@ -42,7 +42,7 @@ export const getSlashMenu = (imagesActivated: boolean) => { ]; if (!imagesActivated) { - items = items.filter((x) => x.name != 'Image'); + items = items.filter((x) => x.name !== 'Image'); } return items; diff --git a/packages/twenty-front/src/modules/command-menu/components/CommandMenuItem.tsx b/packages/twenty-front/src/modules/command-menu/components/CommandMenuItem.tsx index 0ab61d11c..52e4a307c 100644 --- a/packages/twenty-front/src/modules/command-menu/components/CommandMenuItem.tsx +++ b/packages/twenty-front/src/modules/command-menu/components/CommandMenuItem.tsx @@ -32,8 +32,8 @@ export const CommandMenuItem = ({ Icon = IconArrowUpRight; } - const { isSelectedItemIdFamilyState } = useSelectableList(); - const isSelectedItemId = useRecoilValue(isSelectedItemIdFamilyState(id)); + const { isSelectedItemIdSelector } = useSelectableList(); + const isSelectedItemId = useRecoilValue(isSelectedItemIdSelector(id)); return ( (); diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/availableFilterDefinitionsScopedState.ts b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/availableFilterDefinitionsScopedState.ts index 17d0cd616..4ed3c9ce7 100644 --- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/availableFilterDefinitionsScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/availableFilterDefinitionsScopedState.ts @@ -1,7 +1,7 @@ import { FilterDefinition } from '@/object-record/object-filter-dropdown/types/FilterDefinition'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const availableFilterDefinitionsScopedState = createScopedState< +export const availableFilterDefinitionsScopedState = createStateScopeMap< FilterDefinition[] >({ key: 'availableFilterDefinitionsScopedState', diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/filterDefinitionUsedInDropdownScopedState.ts b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/filterDefinitionUsedInDropdownScopedState.ts index c848f4052..1ee8f0b45 100644 --- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/filterDefinitionUsedInDropdownScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/filterDefinitionUsedInDropdownScopedState.ts @@ -1,9 +1,9 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { FilterDefinition } from '../types/FilterDefinition'; export const filterDefinitionUsedInDropdownScopedState = - createScopedState({ + createStateScopeMap({ key: 'filterDefinitionUsedInDropdownScopedState', defaultValue: null, }); diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/isObjectFilterDropdownOperandSelectUnfoldedScopedState.ts b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/isObjectFilterDropdownOperandSelectUnfoldedScopedState.ts index ed25013a9..bec9fee84 100644 --- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/isObjectFilterDropdownOperandSelectUnfoldedScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/isObjectFilterDropdownOperandSelectUnfoldedScopedState.ts @@ -1,7 +1,7 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; export const isObjectFilterDropdownOperandSelectUnfoldedScopedState = - createScopedState({ + createStateScopeMap({ key: 'isObjectFilterDropdownOperandSelectUnfoldedScopedState', defaultValue: false, }); diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/isObjectFilterDropdownUnfoldedScopedState.ts b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/isObjectFilterDropdownUnfoldedScopedState.ts index 178886c5a..432df3475 100644 --- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/isObjectFilterDropdownUnfoldedScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/isObjectFilterDropdownUnfoldedScopedState.ts @@ -1,7 +1,7 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; export const isObjectFilterDropdownUnfoldedScopedState = - createScopedState({ + createStateScopeMap({ key: 'isObjectFilterDropdownUnfoldedScopedState', defaultValue: false, }); diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/objectFilterDropdownSearchInputScopedState.ts b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/objectFilterDropdownSearchInputScopedState.ts index bfdd12e32..b5cd0c1e4 100644 --- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/objectFilterDropdownSearchInputScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/objectFilterDropdownSearchInputScopedState.ts @@ -1,7 +1,7 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; export const objectFilterDropdownSearchInputScopedState = - createScopedState({ + createStateScopeMap({ key: 'objectFilterDropdownSearchInputScopedState', defaultValue: '', }); diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/objectFilterDropdownSelectedEntityIdScopedState.ts b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/objectFilterDropdownSelectedEntityIdScopedState.ts index a0bd47aa7..a96a2c5e9 100644 --- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/objectFilterDropdownSelectedEntityIdScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/objectFilterDropdownSelectedEntityIdScopedState.ts @@ -1,7 +1,7 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; export const objectFilterDropdownSelectedEntityIdScopedState = - createScopedState({ + createStateScopeMap({ key: 'objectFilterDropdownSelectedEntityIdScopedState', defaultValue: null, }); diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/objectFilterDropdownSelectedRecordIdsScopedState.ts b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/objectFilterDropdownSelectedRecordIdsScopedState.ts index 70d897971..10c1dab0b 100644 --- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/objectFilterDropdownSelectedRecordIdsScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/objectFilterDropdownSelectedRecordIdsScopedState.ts @@ -1,7 +1,7 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; export const objectFilterDropdownSelectedRecordIdsScopedState = - createScopedState({ + createStateScopeMap({ key: 'objectFilterDropdownSelectedRecordIdsScopedState', defaultValue: [], }); diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/onFilterSelectScopedState.ts b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/onFilterSelectScopedState.ts index fe0f84d0e..90e2140da 100644 --- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/onFilterSelectScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/onFilterSelectScopedState.ts @@ -1,8 +1,8 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { Filter } from '../types/Filter'; -export const onFilterSelectScopedState = createScopedState< +export const onFilterSelectScopedState = createStateScopeMap< ((filter: Filter) => void) | undefined >({ key: 'onFilterSelectScopedState', diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/selectedFilterScopedState.ts b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/selectedFilterScopedState.ts index a7e81e80d..c2161049b 100644 --- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/selectedFilterScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/selectedFilterScopedState.ts @@ -1,8 +1,10 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { Filter } from '../types/Filter'; -export const selectedFilterScopedState = createScopedState({ +export const selectedFilterScopedState = createStateScopeMap< + Filter | undefined +>({ key: 'selectedFilterScopedState', defaultValue: undefined, }); diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/selectedOperandInDropdownScopedState.ts b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/selectedOperandInDropdownScopedState.ts index 2a5dbd9cb..2cb8e270c 100644 --- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/selectedOperandInDropdownScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/selectedOperandInDropdownScopedState.ts @@ -1,8 +1,8 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { ViewFilterOperand } from '@/views/types/ViewFilterOperand'; export const selectedOperandInDropdownScopedState = - createScopedState({ + createStateScopeMap({ key: 'selectedOperandInDropdownScopedState', defaultValue: null, }); diff --git a/packages/twenty-front/src/modules/object-record/object-sort-dropdown/scopes/scope-internal-context/ObjectSortDropdownScopeInternalContext.ts b/packages/twenty-front/src/modules/object-record/object-sort-dropdown/scopes/scope-internal-context/ObjectSortDropdownScopeInternalContext.ts index 628b843a9..45a636d5f 100644 --- a/packages/twenty-front/src/modules/object-record/object-sort-dropdown/scopes/scope-internal-context/ObjectSortDropdownScopeInternalContext.ts +++ b/packages/twenty-front/src/modules/object-record/object-sort-dropdown/scopes/scope-internal-context/ObjectSortDropdownScopeInternalContext.ts @@ -1,9 +1,9 @@ -import { ScopedStateKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/ScopedStateKey'; +import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey'; import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext'; import { Sort } from '../../types/Sort'; -type ObjectSortDropdownScopeInternalContextProps = ScopedStateKey & { +type ObjectSortDropdownScopeInternalContextProps = StateScopeMapKey & { onSortSelect?: (sort: Sort) => void; }; diff --git a/packages/twenty-front/src/modules/object-record/object-sort-dropdown/states/availableSortDefinitionsScopedState.ts b/packages/twenty-front/src/modules/object-record/object-sort-dropdown/states/availableSortDefinitionsScopedState.ts index 0258a0d85..27da40c6b 100644 --- a/packages/twenty-front/src/modules/object-record/object-sort-dropdown/states/availableSortDefinitionsScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/object-sort-dropdown/states/availableSortDefinitionsScopedState.ts @@ -1,8 +1,8 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { SortDefinition } from '../types/SortDefinition'; -export const availableSortDefinitionsScopedState = createScopedState< +export const availableSortDefinitionsScopedState = createStateScopeMap< SortDefinition[] >({ key: 'availableSortDefinitionsScopedState', diff --git a/packages/twenty-front/src/modules/object-record/object-sort-dropdown/states/isSortSelectedScopedState.ts b/packages/twenty-front/src/modules/object-record/object-sort-dropdown/states/isSortSelectedScopedState.ts index b377baea8..02514a4c4 100644 --- a/packages/twenty-front/src/modules/object-record/object-sort-dropdown/states/isSortSelectedScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/object-sort-dropdown/states/isSortSelectedScopedState.ts @@ -1,6 +1,6 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const isSortSelectedScopedState = createScopedState({ +export const isSortSelectedScopedState = createStateScopeMap({ key: 'isSortSelectedScopedState', defaultValue: false, }); diff --git a/packages/twenty-front/src/modules/object-record/object-sort-dropdown/states/onSortSelectScopedState.ts b/packages/twenty-front/src/modules/object-record/object-sort-dropdown/states/onSortSelectScopedState.ts index ee77698b6..0b76031e6 100644 --- a/packages/twenty-front/src/modules/object-record/object-sort-dropdown/states/onSortSelectScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/object-sort-dropdown/states/onSortSelectScopedState.ts @@ -1,8 +1,8 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { Sort } from '../types/Sort'; -export const onSortSelectScopedState = createScopedState< +export const onSortSelectScopedState = createStateScopeMap< ((sort: Sort) => void) | undefined >({ key: 'onSortSelectScopedState', diff --git a/packages/twenty-front/src/modules/object-record/record-board/scopes/scope-internal-context/RecordBoardScopeInternalContext.ts b/packages/twenty-front/src/modules/object-record/record-board/scopes/scope-internal-context/RecordBoardScopeInternalContext.ts index a20426426..1ea057c98 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/scopes/scope-internal-context/RecordBoardScopeInternalContext.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/scopes/scope-internal-context/RecordBoardScopeInternalContext.ts @@ -1,7 +1,7 @@ -import { ScopedStateKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/ScopedStateKey'; +import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey'; import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext'; -type RecordBoardScopeInternalContextProps = ScopedStateKey; +type RecordBoardScopeInternalContextProps = StateScopeMapKey; export const RecordBoardScopeInternalContext = createScopeInternalContext(); diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/activeRecordBoardCardIdsScopedState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/activeRecordBoardCardIdsScopedState.ts index a0e788c6e..19d449f00 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/states/activeRecordBoardCardIdsScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/states/activeRecordBoardCardIdsScopedState.ts @@ -1,6 +1,8 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const activeRecordBoardCardIdsScopedState = createScopedState({ +export const activeRecordBoardCardIdsScopedState = createStateScopeMap< + string[] +>({ key: 'activeRecordBoardCardIdsScopedState', defaultValue: [], }); diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/availableRecordBoardCardFieldsScopedState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/availableRecordBoardCardFieldsScopedState.ts index 20450c158..8f1cb7848 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/states/availableRecordBoardCardFieldsScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/states/availableRecordBoardCardFieldsScopedState.ts @@ -1,9 +1,9 @@ import { FieldMetadata } from '@/object-record/field/types/FieldMetadata'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { BoardFieldDefinition } from '../types/BoardFieldDefinition'; -export const availableRecordBoardCardFieldsScopedState = createScopedState< +export const availableRecordBoardCardFieldsScopedState = createStateScopeMap< BoardFieldDefinition[] >({ key: 'availableRecordBoardCardFieldsScopedState', diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/isCompactViewEnabledScopedState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/isCompactViewEnabledScopedState.ts index 4a9ab49a3..2e7a35df2 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/states/isCompactViewEnabledScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/states/isCompactViewEnabledScopedState.ts @@ -1,6 +1,6 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const isCompactViewEnabledScopedState = createScopedState({ +export const isCompactViewEnabledScopedState = createStateScopeMap({ key: 'isCompactViewEnabledScopedState', defaultValue: false, }); diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardLoadedScopedState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardLoadedScopedState.ts index 7c201cb1c..5206edf9c 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardLoadedScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardLoadedScopedState.ts @@ -1,6 +1,6 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const isRecordBoardLoadedScopedState = createScopedState({ +export const isRecordBoardLoadedScopedState = createStateScopeMap({ key: 'isRecordBoardLoadedScopedState', defaultValue: false, }); diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/onFieldsChangeScopedState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/onFieldsChangeScopedState.ts index 33da31631..06914e686 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/states/onFieldsChangeScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/states/onFieldsChangeScopedState.ts @@ -1,8 +1,8 @@ import { FieldMetadata } from '@/object-record/field/types/FieldMetadata'; import { BoardFieldDefinition } from '@/object-record/record-board/types/BoardFieldDefinition'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const onFieldsChangeScopedState = createScopedState< +export const onFieldsChangeScopedState = createStateScopeMap< (fields: BoardFieldDefinition[]) => void >({ key: 'onFieldsChangeScopedState', diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardCardFieldsScopedState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardCardFieldsScopedState.ts index ee38ec75b..3aae12e9e 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardCardFieldsScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardCardFieldsScopedState.ts @@ -1,9 +1,9 @@ import { FieldMetadata } from '@/object-record/field/types/FieldMetadata'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { BoardFieldDefinition } from '../types/BoardFieldDefinition'; -export const recordBoardCardFieldsScopedState = createScopedState< +export const recordBoardCardFieldsScopedState = createStateScopeMap< BoardFieldDefinition[] >({ key: 'recordBoardCardFieldsScopedState', diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardColumnsScopedState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardColumnsScopedState.ts index 5b4f0c82b..0480f8f2a 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardColumnsScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardColumnsScopedState.ts @@ -1,7 +1,7 @@ import { BoardColumnDefinition } from '@/object-record/record-board/types/BoardColumnDefinition'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const recordBoardColumnsScopedState = createScopedState< +export const recordBoardColumnsScopedState = createStateScopeMap< BoardColumnDefinition[] >({ key: 'recordBoardColumnsScopedState', diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardFiltersScopedState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardFiltersScopedState.ts index 3ea2c2a28..a0d02927e 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardFiltersScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardFiltersScopedState.ts @@ -1,7 +1,7 @@ import { Filter } from '@/object-record/object-filter-dropdown/types/Filter'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const recordBoardFiltersScopedState = createScopedState({ +export const recordBoardFiltersScopedState = createStateScopeMap({ key: 'recordBoardFiltersScopedState', defaultValue: [], }); diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardSortsScopedState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardSortsScopedState.ts index 28ee2daa9..b19b5f483 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardSortsScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardSortsScopedState.ts @@ -1,8 +1,8 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { Sort } from '../../object-sort-dropdown/types/Sort'; -export const recordBoardSortsScopedState = createScopedState({ +export const recordBoardSortsScopedState = createStateScopeMap({ key: 'recordBoardSortsScopedState', defaultValue: [], }); diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/savedOpportunitiesScopedState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/savedOpportunitiesScopedState.ts index b3da8ff9d..57443838c 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/states/savedOpportunitiesScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/states/savedOpportunitiesScopedState.ts @@ -1,7 +1,9 @@ import { Opportunity } from '@/pipeline/types/Opportunity'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const savedOpportunitiesScopedState = createScopedState({ - key: 'savedOpportunitiesScopedState', - defaultValue: [], -}); +export const savedOpportunitiesScopedState = createStateScopeMap( + { + key: 'savedOpportunitiesScopedState', + defaultValue: [], + }, +); diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/savedPipelineStepsScopedState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/savedPipelineStepsScopedState.ts index b9f651ed6..347ae076a 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/states/savedPipelineStepsScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/states/savedPipelineStepsScopedState.ts @@ -1,7 +1,9 @@ import { PipelineStep } from '@/pipeline/types/PipelineStep'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const savedPipelineStepsScopedState = createScopedState({ +export const savedPipelineStepsScopedState = createStateScopeMap< + PipelineStep[] +>({ key: 'savedPipelineStepsScopedState', defaultValue: [], }); diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/savedRecordBoardCardFieldsScopedState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/savedRecordBoardCardFieldsScopedState.ts index 80997547e..ef2d64633 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/states/savedRecordBoardCardFieldsScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/states/savedRecordBoardCardFieldsScopedState.ts @@ -1,9 +1,9 @@ import { FieldMetadata } from '@/object-record/field/types/FieldMetadata'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { BoardFieldDefinition } from '../types/BoardFieldDefinition'; -export const savedRecordBoardCardFieldsScopedState = createScopedState< +export const savedRecordBoardCardFieldsScopedState = createStateScopeMap< BoardFieldDefinition[] >({ key: 'savedRecordBoardCardFieldsScopedState', diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/savedRecordBoardColumnsScopedState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/savedRecordBoardColumnsScopedState.ts index e285bc94e..e8e76c974 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/states/savedRecordBoardColumnsScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/states/savedRecordBoardColumnsScopedState.ts @@ -1,8 +1,8 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { BoardColumnDefinition } from '../types/BoardColumnDefinition'; -export const savedRecordBoardColumnsScopedState = createScopedState< +export const savedRecordBoardColumnsScopedState = createStateScopeMap< BoardColumnDefinition[] >({ key: 'savedRecordBoardColumnsScopedState', diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/savedRecordsScopedState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/savedRecordsScopedState.ts index 5b6c01039..ac17469e4 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/states/savedRecordsScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/states/savedRecordsScopedState.ts @@ -1,7 +1,7 @@ import { Company } from '@/companies/types/Company'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const savedRecordsScopedState = createScopedState({ +export const savedRecordsScopedState = createStateScopeMap({ key: 'savedRecordsScopedState', defaultValue: [], }); diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/selectors/hiddenRecordBoardCardFieldsScopedSelector.ts b/packages/twenty-front/src/modules/object-record/record-board/states/selectors/hiddenRecordBoardCardFieldsScopedSelector.ts index f3c7bba35..7924b73c6 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/states/selectors/hiddenRecordBoardCardFieldsScopedSelector.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/states/selectors/hiddenRecordBoardCardFieldsScopedSelector.ts @@ -1,22 +1,24 @@ -import { createScopedSelector } from '@/ui/utilities/recoil-scope/utils/createScopedSelector'; +import { createSelectorScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorScopeMap'; import { availableRecordBoardCardFieldsScopedState } from '../availableRecordBoardCardFieldsScopedState'; import { recordBoardCardFieldsScopedState } from '../recordBoardCardFieldsScopedState'; -export const hiddenRecordBoardCardFieldsScopedSelector = createScopedSelector({ - key: 'hiddenRecordBoardCardFieldsScopedSelector', - get: - ({ scopeId }) => - ({ get }) => { - const fields = get(recordBoardCardFieldsScopedState({ scopeId })); - const fieldKeys = fields.map(({ fieldMetadataId }) => fieldMetadataId); - const otherAvailableKeys = get( - availableRecordBoardCardFieldsScopedState({ scopeId }), - ).filter(({ fieldMetadataId }) => !fieldKeys.includes(fieldMetadataId)); +export const hiddenRecordBoardCardFieldsScopedSelector = createSelectorScopeMap( + { + key: 'hiddenRecordBoardCardFieldsScopedSelector', + get: + ({ scopeId }) => + ({ get }) => { + const fields = get(recordBoardCardFieldsScopedState({ scopeId })); + const fieldKeys = fields.map(({ fieldMetadataId }) => fieldMetadataId); + const otherAvailableKeys = get( + availableRecordBoardCardFieldsScopedState({ scopeId }), + ).filter(({ fieldMetadataId }) => !fieldKeys.includes(fieldMetadataId)); - return [ - ...fields.filter((field) => !field.isVisible), - ...otherAvailableKeys, - ]; - }, -}); + return [ + ...fields.filter((field) => !field.isVisible), + ...otherAvailableKeys, + ]; + }, + }, +); diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/selectors/selectedRecordBoardCardIdsScopedSelector.ts b/packages/twenty-front/src/modules/object-record/record-board/states/selectors/selectedRecordBoardCardIdsScopedSelector.ts index a93e65544..0c75069e3 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/states/selectors/selectedRecordBoardCardIdsScopedSelector.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/states/selectors/selectedRecordBoardCardIdsScopedSelector.ts @@ -1,10 +1,10 @@ -import { createScopedSelector } from '@/ui/utilities/recoil-scope/utils/createScopedSelector'; +import { createSelectorScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorScopeMap'; import { isRecordBoardCardSelectedFamilyState } from '../isRecordBoardCardSelectedFamilyState'; import { recordBoardCardIdsByColumnIdFamilyState } from '../recordBoardCardIdsByColumnIdFamilyState'; import { recordBoardColumnsScopedState } from '../recordBoardColumnsScopedState'; -export const selectedRecordBoardCardIdsScopedSelector = createScopedSelector< +export const selectedRecordBoardCardIdsScopedSelector = createSelectorScopeMap< string[] >({ key: 'selectedRecordBoardCardIdsScopedSelector', diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/selectors/visibleRecordBoardCardFieldsScopedSelector.ts b/packages/twenty-front/src/modules/object-record/record-board/states/selectors/visibleRecordBoardCardFieldsScopedSelector.ts index 47ee4ac2d..bca23f303 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/states/selectors/visibleRecordBoardCardFieldsScopedSelector.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/states/selectors/visibleRecordBoardCardFieldsScopedSelector.ts @@ -1,13 +1,14 @@ -import { createScopedSelector } from '@/ui/utilities/recoil-scope/utils/createScopedSelector'; +import { createSelectorScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorScopeMap'; import { recordBoardCardFieldsScopedState } from '../recordBoardCardFieldsScopedState'; -export const visibleRecordBoardCardFieldsScopedSelector = createScopedSelector({ - key: 'visibleRecordBoardCardFieldsScopedSelector', - get: - ({ scopeId }) => - ({ get }) => - get(recordBoardCardFieldsScopedState({ scopeId })) - .filter((field) => field.isVisible) - .sort((a, b) => a.position - b.position), -}); +export const visibleRecordBoardCardFieldsScopedSelector = + createSelectorScopeMap({ + key: 'visibleRecordBoardCardFieldsScopedSelector', + get: + ({ scopeId }) => + ({ get }) => + get(recordBoardCardFieldsScopedState({ scopeId })) + .filter((field) => field.isVisible) + .sort((a, b) => a.position - b.position), + }); diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-row/states/isRowSelectedScopedFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-table/record-table-row/states/isRowSelectedScopedFamilyState.ts index 8a684cec6..5ea9257c6 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/record-table-row/states/isRowSelectedScopedFamilyState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-row/states/isRowSelectedScopedFamilyState.ts @@ -1,6 +1,6 @@ -import { createScopedFamilyState } from '@/ui/utilities/recoil-scope/utils/createScopedFamilyState'; +import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap'; -export const isRowSelectedScopedFamilyState = createScopedFamilyState< +export const isRowSelectedScopedFamilyState = createFamilyStateScopeMap< boolean, string >({ diff --git a/packages/twenty-front/src/modules/object-record/record-table/scopes/scope-internal-context/RecordTableScopeInternalContext.ts b/packages/twenty-front/src/modules/object-record/record-table/scopes/scope-internal-context/RecordTableScopeInternalContext.ts index b63b07132..b621b6777 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/scopes/scope-internal-context/RecordTableScopeInternalContext.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/scopes/scope-internal-context/RecordTableScopeInternalContext.ts @@ -1,10 +1,10 @@ import { FieldMetadata } from '@/object-record/field/types/FieldMetadata'; -import { ScopedStateKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/ScopedStateKey'; +import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey'; import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext'; import { ColumnDefinition } from '../../types/ColumnDefinition'; -type RecordTableScopeInternalContextProps = ScopedStateKey & { +type RecordTableScopeInternalContextProps = StateScopeMapKey & { onColumnsChange: (columns: ColumnDefinition[]) => void; }; diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/availableTableColumnsScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/availableTableColumnsScopedState.ts index 9b3cf7c7c..2cd00c185 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/availableTableColumnsScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/availableTableColumnsScopedState.ts @@ -1,9 +1,9 @@ import { FieldMetadata } from '@/object-record/field/types/FieldMetadata'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { ColumnDefinition } from '../types/ColumnDefinition'; -export const availableTableColumnsScopedState = createScopedState< +export const availableTableColumnsScopedState = createStateScopeMap< ColumnDefinition[] >({ key: 'availableTableColumnsScopedState', diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/currentTableCellInEditModePositionScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/currentTableCellInEditModePositionScopedState.ts index c6560c4b1..1e9e3123a 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/currentTableCellInEditModePositionScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/currentTableCellInEditModePositionScopedState.ts @@ -1,9 +1,9 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { TableCellPosition } from '../types/TableCellPosition'; export const currentTableCellInEditModePositionScopedState = - createScopedState({ + createStateScopeMap({ key: 'currentTableCellInEditModePositionScopedState', defaultValue: { row: 0, diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isRecordTableInitialLoadingScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isRecordTableInitialLoadingScopedState.ts index e7637024f..56dbcbadf 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/isRecordTableInitialLoadingScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/isRecordTableInitialLoadingScopedState.ts @@ -1,7 +1,7 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; export const isRecordTableInitialLoadingScopedState = - createScopedState({ + createStateScopeMap({ key: 'isRecordTableInitialLoadingScopedState', defaultValue: true, }); diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusActiveScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusActiveScopedState.ts index a81b5c1ba..a967e74de 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusActiveScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusActiveScopedState.ts @@ -1,6 +1,6 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const isSoftFocusActiveScopedState = createScopedState({ +export const isSoftFocusActiveScopedState = createStateScopeMap({ key: 'isSoftFocusActiveScopedState', defaultValue: false, }); diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusOnTableCellScopedFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusOnTableCellScopedFamilyState.ts index 24fd6769a..1ee7324dd 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusOnTableCellScopedFamilyState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusOnTableCellScopedFamilyState.ts @@ -1,11 +1,9 @@ -import { createScopedFamilyState } from '@/ui/utilities/recoil-scope/utils/createScopedFamilyState'; +import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap'; import { TableCellPosition } from '../types/TableCellPosition'; -export const isSoftFocusOnTableCellScopedFamilyState = createScopedFamilyState< - boolean, - TableCellPosition ->({ - key: 'isSoftFocusOnTableCellScopedFamilyState', - defaultValue: false, -}); +export const isSoftFocusOnTableCellScopedFamilyState = + createFamilyStateScopeMap({ + key: 'isSoftFocusOnTableCellScopedFamilyState', + defaultValue: false, + }); diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isTableCellInEditModeScopedFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isTableCellInEditModeScopedFamilyState.ts index ea9ec0889..3a4c90777 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/isTableCellInEditModeScopedFamilyState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/isTableCellInEditModeScopedFamilyState.ts @@ -1,8 +1,8 @@ -import { createScopedFamilyState } from '@/ui/utilities/recoil-scope/utils/createScopedFamilyState'; +import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap'; import { TableCellPosition } from '../types/TableCellPosition'; -export const isTableCellInEditModeScopedFamilyState = createScopedFamilyState< +export const isTableCellInEditModeScopedFamilyState = createFamilyStateScopeMap< boolean, TableCellPosition >({ diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/numberOfTableRowsScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/numberOfTableRowsScopedState.ts index f7111d95e..a5b136b55 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/numberOfTableRowsScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/numberOfTableRowsScopedState.ts @@ -1,6 +1,6 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const numberOfTableRowsScopedState = createScopedState({ +export const numberOfTableRowsScopedState = createStateScopeMap({ key: 'numberOfTableRowsScopedState', defaultValue: 0, }); diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/objectMetadataConfigScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/objectMetadataConfigScopedState.ts index ed3ef2fa4..cb8bb728c 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/objectMetadataConfigScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/objectMetadataConfigScopedState.ts @@ -1,8 +1,8 @@ import { ObjectMetadataConfig } from '@/object-record/record-table/types/ObjectMetadataConfig'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; export const objectMetadataConfigScopedState = - createScopedState({ + createStateScopeMap({ key: 'objectMetadataConfigScopedState', defaultValue: null, }); diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/onColumnsChangeScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/onColumnsChangeScopedState.ts index 88c183a58..9f34a0aa0 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/onColumnsChangeScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/onColumnsChangeScopedState.ts @@ -1,9 +1,9 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { FieldMetadata } from '../../field/types/FieldMetadata'; import { ColumnDefinition } from '../types/ColumnDefinition'; -export const onColumnsChangeScopedState = createScopedState< +export const onColumnsChangeScopedState = createStateScopeMap< ((columns: ColumnDefinition[]) => void) | undefined >({ key: 'onColumnsChangeScopedState', diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/onEntityCountChangeScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/onEntityCountChangeScopedState.ts index b28896936..cfd6c3738 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/onEntityCountChangeScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/onEntityCountChangeScopedState.ts @@ -1,6 +1,6 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const onEntityCountChangeScopedState = createScopedState< +export const onEntityCountChangeScopedState = createStateScopeMap< ((entityCount: number) => void) | undefined >({ key: 'onEntityCountChangeScopedState', diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/resizeFieldOffsetScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/resizeFieldOffsetScopedState.ts index 06f88bdf5..70a570f94 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/resizeFieldOffsetScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/resizeFieldOffsetScopedState.ts @@ -1,6 +1,6 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const resizeFieldOffsetScopedState = createScopedState({ +export const resizeFieldOffsetScopedState = createStateScopeMap({ key: 'resizeFieldOffsetScopedState', defaultValue: 0, }); diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/allRowsSelectedStatusScopedSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/allRowsSelectedStatusScopedSelector.ts index 8eb788e21..d3d269866 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/allRowsSelectedStatusScopedSelector.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/allRowsSelectedStatusScopedSelector.ts @@ -1,4 +1,4 @@ -import { createScopedSelector } from '@/ui/utilities/recoil-scope/utils/createScopedSelector'; +import { createSelectorScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorScopeMap'; import { AllRowsSelectedStatus } from '../../types/AllRowSelectedStatus'; import { numberOfTableRowsScopedState } from '../numberOfTableRowsScopedState'; @@ -6,7 +6,7 @@ import { numberOfTableRowsScopedState } from '../numberOfTableRowsScopedState'; import { selectedRowIdsScopedSelector } from './selectedRowIdsScopedSelector'; export const allRowsSelectedStatusScopedSelector = - createScopedSelector({ + createSelectorScopeMap({ key: 'allRowsSelectedStatusScopedSelector', get: ({ scopeId }) => diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/hiddenTableColumnsScopedSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/hiddenTableColumnsScopedSelector.ts index a6eabee8d..4a6695ac6 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/hiddenTableColumnsScopedSelector.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/hiddenTableColumnsScopedSelector.ts @@ -1,9 +1,9 @@ -import { createScopedSelector } from '@/ui/utilities/recoil-scope/utils/createScopedSelector'; +import { createSelectorScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorScopeMap'; import { availableTableColumnsScopedState } from '../availableTableColumnsScopedState'; import { tableColumnsScopedState } from '../tableColumnsScopedState'; -export const hiddenTableColumnsScopedSelector = createScopedSelector({ +export const hiddenTableColumnsScopedSelector = createSelectorScopeMap({ key: 'hiddenTableColumnsScopedSelector', get: ({ scopeId }) => diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/numberOfTableColumnsScopedSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/numberOfTableColumnsScopedSelector.ts index 1e74626af..887683e60 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/numberOfTableColumnsScopedSelector.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/numberOfTableColumnsScopedSelector.ts @@ -1,8 +1,8 @@ -import { createScopedSelector } from '@/ui/utilities/recoil-scope/utils/createScopedSelector'; +import { createSelectorScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorScopeMap'; import { tableColumnsScopedState } from '../tableColumnsScopedState'; -export const numberOfTableColumnsScopedSelector = createScopedSelector({ +export const numberOfTableColumnsScopedSelector = createSelectorScopeMap({ key: 'numberOfTableColumnsScopedSelector', get: ({ scopeId }) => diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/selectedRowIdsScopedSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/selectedRowIdsScopedSelector.ts index 5988954c3..74abdda26 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/selectedRowIdsScopedSelector.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/selectedRowIdsScopedSelector.ts @@ -1,9 +1,9 @@ -import { createScopedSelector } from '@/ui/utilities/recoil-scope/utils/createScopedSelector'; +import { createSelectorScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorScopeMap'; import { isRowSelectedScopedFamilyState } from '../../record-table-row/states/isRowSelectedScopedFamilyState'; import { tableRowIdsScopedState } from '../tableRowIdsScopedState'; -export const selectedRowIdsScopedSelector = createScopedSelector({ +export const selectedRowIdsScopedSelector = createSelectorScopeMap({ key: 'selectedRowIdsScopedSelector', get: ({ scopeId }) => diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/tableColumnsByKeyScopedSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/tableColumnsByKeyScopedSelector.ts index 743d541db..ccc4a281c 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/tableColumnsByKeyScopedSelector.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/tableColumnsByKeyScopedSelector.ts @@ -1,10 +1,10 @@ import { FieldMetadata } from '@/object-record/field/types/FieldMetadata'; -import { createScopedSelector } from '@/ui/utilities/recoil-scope/utils/createScopedSelector'; +import { createSelectorScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorScopeMap'; import { ColumnDefinition } from '../../types/ColumnDefinition'; import { tableColumnsScopedState } from '../tableColumnsScopedState'; -export const tableColumnsByKeyScopedSelector = createScopedSelector({ +export const tableColumnsByKeyScopedSelector = createSelectorScopeMap({ key: 'tableColumnsByKeyScopedSelector', get: ({ scopeId }) => diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/visibleTableColumnsScopedSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/visibleTableColumnsScopedSelector.ts index 35e57373b..1e26e5ac1 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/visibleTableColumnsScopedSelector.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/visibleTableColumnsScopedSelector.ts @@ -1,9 +1,9 @@ -import { createScopedSelector } from '@/ui/utilities/recoil-scope/utils/createScopedSelector'; +import { createSelectorScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorScopeMap'; import { availableTableColumnsScopedState } from '../availableTableColumnsScopedState'; import { tableColumnsScopedState } from '../tableColumnsScopedState'; -export const visibleTableColumnsScopedSelector = createScopedSelector({ +export const visibleTableColumnsScopedSelector = createSelectorScopeMap({ key: 'visibleTableColumnsScopedSelector', get: ({ scopeId }) => diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/softFocusPositionScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/softFocusPositionScopedState.ts index ab46025c2..df114dd14 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/softFocusPositionScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/softFocusPositionScopedState.ts @@ -1,9 +1,9 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { TableCellPosition } from '../types/TableCellPosition'; export const softFocusPositionScopedState = - createScopedState({ + createStateScopeMap({ key: 'softFocusPositionScopedState', defaultValue: { row: 0, diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/tableColumnsScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/tableColumnsScopedState.ts index 45489b2cc..bcb95a9d5 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/tableColumnsScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/tableColumnsScopedState.ts @@ -1,9 +1,9 @@ import { FieldMetadata } from '@/object-record/field/types/FieldMetadata'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { ColumnDefinition } from '../types/ColumnDefinition'; -export const tableColumnsScopedState = createScopedState< +export const tableColumnsScopedState = createStateScopeMap< ColumnDefinition[] >({ key: 'tableColumnsScopedState', diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/tableFiltersScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/tableFiltersScopedState.ts index 5206f3fd7..bc1d3d65d 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/tableFiltersScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/tableFiltersScopedState.ts @@ -1,8 +1,8 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { Filter } from '../../object-filter-dropdown/types/Filter'; -export const tableFiltersScopedState = createScopedState({ +export const tableFiltersScopedState = createStateScopeMap({ key: 'tableFiltersScopedState', defaultValue: [], }); diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/tableLastRowVisibleScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/tableLastRowVisibleScopedState.ts index db2363d29..c4857afe3 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/tableLastRowVisibleScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/tableLastRowVisibleScopedState.ts @@ -1,6 +1,6 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const tableLastRowVisibleScopedState = createScopedState({ +export const tableLastRowVisibleScopedState = createStateScopeMap({ key: 'tableLastRowVisibleScopedState', defaultValue: false, }); diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/tableRowIdsScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/tableRowIdsScopedState.ts index 79d5c2dc3..4e55d0c5d 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/tableRowIdsScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/tableRowIdsScopedState.ts @@ -1,6 +1,6 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const tableRowIdsScopedState = createScopedState({ +export const tableRowIdsScopedState = createStateScopeMap({ key: 'tableRowIdsScopedState', defaultValue: [], }); diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/tableSortsScopedState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/tableSortsScopedState.ts index 1d555cc9b..37f4e568c 100644 --- a/packages/twenty-front/src/modules/object-record/record-table/states/tableSortsScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/record-table/states/tableSortsScopedState.ts @@ -1,8 +1,8 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { Sort } from '../../object-sort-dropdown/types/Sort'; -export const tableSortsScopedState = createScopedState({ +export const tableSortsScopedState = createStateScopeMap({ key: 'tableSortsScopedState', defaultValue: [], }); diff --git a/packages/twenty-front/src/modules/object-record/relation-picker/components/SelectableMenuItemSelect.tsx b/packages/twenty-front/src/modules/object-record/relation-picker/components/SelectableMenuItemSelect.tsx index 0a8815257..5d8784fab 100644 --- a/packages/twenty-front/src/modules/object-record/relation-picker/components/SelectableMenuItemSelect.tsx +++ b/packages/twenty-front/src/modules/object-record/relation-picker/components/SelectableMenuItemSelect.tsx @@ -22,13 +22,11 @@ export const SelectableMenuItemSelect = ({ onEntitySelected, selectedEntity, }: SelectableMenuItemSelectProps) => { - const { isSelectedItemIdFamilyState } = useSelectableList( + const { isSelectedItemIdSelector } = useSelectableList( 'single-entity-select-base-list', ); - const isSelectedItemId = useRecoilValue( - isSelectedItemIdFamilyState(entity.id), - ); + const isSelectedItemId = useRecoilValue(isSelectedItemIdSelector(entity.id)); return ( diff --git a/packages/twenty-front/src/modules/object-record/relation-picker/scopes/scope-internal-context/RelationPickerScopeInternalContext.ts b/packages/twenty-front/src/modules/object-record/relation-picker/scopes/scope-internal-context/RelationPickerScopeInternalContext.ts index 6458f6065..8e49b1267 100644 --- a/packages/twenty-front/src/modules/object-record/relation-picker/scopes/scope-internal-context/RelationPickerScopeInternalContext.ts +++ b/packages/twenty-front/src/modules/object-record/relation-picker/scopes/scope-internal-context/RelationPickerScopeInternalContext.ts @@ -1,7 +1,7 @@ -import { ScopedStateKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/ScopedStateKey'; +import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey'; import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext'; -type RelationPickerScopeInternalContextProps = ScopedStateKey; +type RelationPickerScopeInternalContextProps = StateScopeMapKey; export const RelationPickerScopeInternalContext = createScopeInternalContext(); diff --git a/packages/twenty-front/src/modules/object-record/relation-picker/states/identifiersMapperScopedState.ts b/packages/twenty-front/src/modules/object-record/relation-picker/states/identifiersMapperScopedState.ts index 0153df80c..7b2683e25 100644 --- a/packages/twenty-front/src/modules/object-record/relation-picker/states/identifiersMapperScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/relation-picker/states/identifiersMapperScopedState.ts @@ -1,8 +1,8 @@ import { IdentifiersMapper } from '@/object-record/relation-picker/types/IdentifiersMapper'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; export const identifiersMapperScopedState = - createScopedState({ + createStateScopeMap({ key: 'identifiersMapperScopedState', defaultValue: null, }); diff --git a/packages/twenty-front/src/modules/object-record/relation-picker/states/relationPickerPreselectedIdScopedState.ts b/packages/twenty-front/src/modules/object-record/relation-picker/states/relationPickerPreselectedIdScopedState.ts index 33707973b..2266afc5b 100644 --- a/packages/twenty-front/src/modules/object-record/relation-picker/states/relationPickerPreselectedIdScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/relation-picker/states/relationPickerPreselectedIdScopedState.ts @@ -1,6 +1,6 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const relationPickerPreselectedIdScopedState = createScopedState< +export const relationPickerPreselectedIdScopedState = createStateScopeMap< string | undefined >({ key: 'relationPickerPreselectedIdScopedState', diff --git a/packages/twenty-front/src/modules/object-record/relation-picker/states/relationPickerSearchFilterScopedState.ts b/packages/twenty-front/src/modules/object-record/relation-picker/states/relationPickerSearchFilterScopedState.ts index 113d2f4ce..5184ff810 100644 --- a/packages/twenty-front/src/modules/object-record/relation-picker/states/relationPickerSearchFilterScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/relation-picker/states/relationPickerSearchFilterScopedState.ts @@ -1,6 +1,7 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const relationPickerSearchFilterScopedState = createScopedState({ - key: 'relationPickerSearchFilterScopedState', - defaultValue: '', -}); +export const relationPickerSearchFilterScopedState = + createStateScopeMap({ + key: 'relationPickerSearchFilterScopedState', + defaultValue: '', + }); diff --git a/packages/twenty-front/src/modules/object-record/relation-picker/states/searchQueryScopedState.ts b/packages/twenty-front/src/modules/object-record/relation-picker/states/searchQueryScopedState.ts index f9dd1a64f..5f94b225a 100644 --- a/packages/twenty-front/src/modules/object-record/relation-picker/states/searchQueryScopedState.ts +++ b/packages/twenty-front/src/modules/object-record/relation-picker/states/searchQueryScopedState.ts @@ -1,7 +1,7 @@ import { SearchQuery } from '@/object-record/relation-picker/types/SearchQuery'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const searchQueryScopedState = createScopedState({ +export const searchQueryScopedState = createStateScopeMap({ key: 'searchQueryScopedState', defaultValue: null, }); diff --git a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsEmailsCard.tsx b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsEmailsCard.tsx index 742e479f9..362be4c24 100644 --- a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsEmailsCard.tsx +++ b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsEmailsCard.tsx @@ -30,7 +30,7 @@ export const SettingsAccountsEmailsCard = ({ {accounts.map((account, index) => ( } - onClick={() => navigate(`/settings/accounts/emails/${account.uuid}`)} + onClick={() => navigate(`/settings/accounts/emails/${account.id}`)} divider={index < accounts.length - 1} /> ))} diff --git a/packages/twenty-front/src/modules/ui/feedback/dialog-manager/scopes/scope-internal-context/DialogManagerScopeInternalContext.ts b/packages/twenty-front/src/modules/ui/feedback/dialog-manager/scopes/scope-internal-context/DialogManagerScopeInternalContext.ts index 346dcc5fb..428596e8f 100644 --- a/packages/twenty-front/src/modules/ui/feedback/dialog-manager/scopes/scope-internal-context/DialogManagerScopeInternalContext.ts +++ b/packages/twenty-front/src/modules/ui/feedback/dialog-manager/scopes/scope-internal-context/DialogManagerScopeInternalContext.ts @@ -1,7 +1,7 @@ -import { ScopedStateKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/ScopedStateKey'; +import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey'; import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext'; -type DialogManagerScopeInternalContextProps = ScopedStateKey; +type DialogManagerScopeInternalContextProps = StateScopeMapKey; export const DialogManagerScopeInternalContext = createScopeInternalContext(); diff --git a/packages/twenty-front/src/modules/ui/feedback/dialog-manager/states/dialogInternalScopedState.ts b/packages/twenty-front/src/modules/ui/feedback/dialog-manager/states/dialogInternalScopedState.ts index 797e07c62..13bc5cb7d 100644 --- a/packages/twenty-front/src/modules/ui/feedback/dialog-manager/states/dialogInternalScopedState.ts +++ b/packages/twenty-front/src/modules/ui/feedback/dialog-manager/states/dialogInternalScopedState.ts @@ -1,4 +1,4 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { DialogOptions } from '../types/DialogOptions'; @@ -7,7 +7,7 @@ type DialogState = { queue: DialogOptions[]; }; -export const dialogInternalScopedState = createScopedState({ +export const dialogInternalScopedState = createStateScopeMap({ key: 'dialog/internal-state', defaultValue: { maxQueue: 2, diff --git a/packages/twenty-front/src/modules/ui/feedback/snack-bar-manager/scopes/scope-internal-context/SnackBarManagerScopeInternalContext.ts b/packages/twenty-front/src/modules/ui/feedback/snack-bar-manager/scopes/scope-internal-context/SnackBarManagerScopeInternalContext.ts index c7be54b38..274d356a8 100644 --- a/packages/twenty-front/src/modules/ui/feedback/snack-bar-manager/scopes/scope-internal-context/SnackBarManagerScopeInternalContext.ts +++ b/packages/twenty-front/src/modules/ui/feedback/snack-bar-manager/scopes/scope-internal-context/SnackBarManagerScopeInternalContext.ts @@ -1,7 +1,7 @@ -import { ScopedStateKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/ScopedStateKey'; +import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey'; import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext'; -type SnackBarManagerScopeInternalContextProps = ScopedStateKey; +type SnackBarManagerScopeInternalContextProps = StateScopeMapKey; export const SnackBarManagerScopeInternalContext = createScopeInternalContext(); diff --git a/packages/twenty-front/src/modules/ui/feedback/snack-bar-manager/states/snackBarInternalScopedState.ts b/packages/twenty-front/src/modules/ui/feedback/snack-bar-manager/states/snackBarInternalScopedState.ts index 18dc03e4f..e92de1f5f 100644 --- a/packages/twenty-front/src/modules/ui/feedback/snack-bar-manager/states/snackBarInternalScopedState.ts +++ b/packages/twenty-front/src/modules/ui/feedback/snack-bar-manager/states/snackBarInternalScopedState.ts @@ -1,4 +1,4 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { SnackBarProps } from '../components/SnackBar'; @@ -11,7 +11,7 @@ type SnackBarState = { queue: SnackBarOptions[]; }; -export const snackBarInternalScopedState = createScopedState({ +export const snackBarInternalScopedState = createStateScopeMap({ key: 'snackBarState', defaultValue: { maxQueue: 3, diff --git a/packages/twenty-front/src/modules/ui/input/components/IconPicker.tsx b/packages/twenty-front/src/modules/ui/input/components/IconPicker.tsx index 0beec0fbf..97182ec1c 100644 --- a/packages/twenty-front/src/modules/ui/input/components/IconPicker.tsx +++ b/packages/twenty-front/src/modules/ui/input/components/IconPicker.tsx @@ -61,9 +61,9 @@ const IconPickerIcon = ({ selectedIconKey, Icon, }: IconPickerIconProps) => { - const { isSelectedItemIdFamilyState } = useSelectableList(); + const { isSelectedItemIdSelector } = useSelectableList(); - const isSelectedItemId = useRecoilValue(isSelectedItemIdFamilyState(iconKey)); + const isSelectedItemId = useRecoilValue(isSelectedItemIdSelector(iconKey)); return ( (); diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownHotkeyScopeScopedState.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownHotkeyScopeScopedState.ts index fbcac52b3..d47015633 100644 --- a/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownHotkeyScopeScopedState.ts +++ b/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownHotkeyScopeScopedState.ts @@ -1,7 +1,7 @@ import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const dropdownHotkeyScopeScopedState = createScopedState< +export const dropdownHotkeyScopeScopedState = createStateScopeMap< HotkeyScope | null | undefined >({ key: 'dropdownHotkeyScopeScopedState', diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownWidthScopedState.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownWidthScopedState.ts index b620687c6..717a3a1cd 100644 --- a/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownWidthScopedState.ts +++ b/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownWidthScopedState.ts @@ -1,6 +1,8 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const dropdownWidthScopedState = createScopedState({ - key: 'dropdownWidthScopedState', - defaultValue: 160, -}); +export const dropdownWidthScopedState = createStateScopeMap( + { + key: 'dropdownWidthScopedState', + defaultValue: 160, + }, +); diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/states/isDropdownOpenScopedState.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/states/isDropdownOpenScopedState.ts index 56d6f905e..65d0c073c 100644 --- a/packages/twenty-front/src/modules/ui/layout/dropdown/states/isDropdownOpenScopedState.ts +++ b/packages/twenty-front/src/modules/ui/layout/dropdown/states/isDropdownOpenScopedState.ts @@ -1,6 +1,6 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const isDropdownOpenScopedState = createScopedState({ +export const isDropdownOpenScopedState = createStateScopeMap({ key: 'isDropdownOpenScopedState', defaultValue: false, }); diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/components/SelectableItem.tsx b/packages/twenty-front/src/modules/ui/layout/selectable-list/components/SelectableItem.tsx index 9c6315a42..c4678f4d2 100644 --- a/packages/twenty-front/src/modules/ui/layout/selectable-list/components/SelectableItem.tsx +++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/components/SelectableItem.tsx @@ -14,9 +14,9 @@ export const SelectableItem = ({ children, className, }: SelectableItemProps) => { - const { isSelectedItemIdFamilyState } = useSelectableList(); + const { isSelectedItemIdSelector } = useSelectableList(); - const isSelectedItemId = useRecoilValue(isSelectedItemIdFamilyState(itemId)); + const isSelectedItemId = useRecoilValue(isSelectedItemIdSelector(itemId)); const scrollRef = useRef(null); diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.tsx b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.tsx index 924c61c56..9a9d74cfc 100644 --- a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.tsx +++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListHotKeys.tsx @@ -1,9 +1,9 @@ import { useRecoilCallback } from 'recoil'; import { Key } from 'ts-key-enum'; -import { useSelectableListScopedState } from '@/ui/layout/selectable-list/hooks/internal/useSelectableListScopedState'; -import { getSelectableListScopeInjectors } from '@/ui/layout/selectable-list/utils/internal/getSelectableListScopeInjectors'; +import { useSelectableListStates } from '@/ui/layout/selectable-list/hooks/internal/useSelectableListStates'; import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys'; +import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue'; type Direction = 'up' | 'down' | 'left' | 'right'; @@ -27,27 +27,22 @@ export const useSelectableListHotKeys = ( } }; - const { injectSnapshotValueWithSelectableListScopeId } = - useSelectableListScopedState({ - selectableListScopeId: scopeId, - }); + const { + selectedItemIdState, + selectableItemIdsState, + isSelectedItemIdSelector, + selectableListOnEnterState, + } = useSelectableListStates({ + selectableListScopeId: scopeId, + }); const handleSelect = useRecoilCallback( ({ snapshot, set }) => (direction: Direction) => { - const { - selectedItemIdScopeInjector, - selectableItemIdsScopeInjector, - isSelectedItemIdFamilyScopeInjector, - } = getSelectableListScopeInjectors(); - - const selectedItemId = injectSnapshotValueWithSelectableListScopeId( + const selectedItemId = getSnapshotValue(snapshot, selectedItemIdState); + const selectableItemIds = getSnapshotValue( snapshot, - selectedItemIdScopeInjector, - ); - const selectableItemIds = injectSnapshotValueWithSelectableListScopeId( - snapshot, - selectableItemIdsScopeInjector, + selectableItemIdsState, ); const currentPosition = findPosition(selectableItemIds, selectedItemId); @@ -107,19 +102,16 @@ export const useSelectableListHotKeys = ( if (selectedItemId !== nextId) { if (nextId) { - set(isSelectedItemIdFamilyScopeInjector(scopeId, nextId), true); - set(selectedItemIdScopeInjector(scopeId), nextId); + set(isSelectedItemIdSelector(nextId), true); + set(selectedItemIdState, nextId); } if (selectedItemId) { - set( - isSelectedItemIdFamilyScopeInjector(scopeId, selectedItemId), - false, - ); + set(isSelectedItemIdSelector(selectedItemId), false); } } }, - [injectSnapshotValueWithSelectableListScopeId, scopeId], + [isSelectedItemIdSelector, selectableItemIdsState, selectedItemIdState], ); useScopedHotkeys(Key.ArrowUp, () => handleSelect('up'), hotkeyScope, []); @@ -140,25 +132,20 @@ export const useSelectableListHotKeys = ( useRecoilCallback( ({ snapshot }) => () => { - const { - selectedItemIdScopeInjector, - selectableListOnEnterScopeInjector, - } = getSelectableListScopeInjectors(); - const selectedItemId = injectSnapshotValueWithSelectableListScopeId( + const selectedItemId = getSnapshotValue( snapshot, - selectedItemIdScopeInjector, + selectedItemIdState, ); - - const onEnter = injectSnapshotValueWithSelectableListScopeId( + const onEnter = getSnapshotValue( snapshot, - selectableListOnEnterScopeInjector, + selectableListOnEnterState, ); if (selectedItemId) { onEnter?.(selectedItemId); } }, - [injectSnapshotValueWithSelectableListScopeId], + [selectableListOnEnterState, selectedItemIdState], ), hotkeyScope, [], diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListScopedState.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListScopedState.ts deleted file mode 100644 index 2388ebb11..000000000 --- a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListScopedState.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { SelectableListScopeInternalContext } from '@/ui/layout/selectable-list/scopes/scope-internal-context/SelectableListScopeInternalContext'; -import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId'; -import { useScopedState } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useScopedState'; - -type UseSelectableListScopedStatesProps = { - selectableListScopeId?: string; -}; - -export const useSelectableListScopedState = ({ - selectableListScopeId, -}: UseSelectableListScopedStatesProps) => { - const scopeId = useAvailableScopeIdOrThrow( - SelectableListScopeInternalContext, - selectableListScopeId, - ); - - const { - getScopedState, - getScopedFamilyState, - getScopedSnapshotValue, - getScopedFamilySnapshotValue, - } = useScopedState(scopeId); - - return { - scopeId, - injectStateWithSelectableListScopeId: getScopedState, - injectFamilyStateWithSelectableListScopeId: getScopedFamilyState, - injectSnapshotValueWithSelectableListScopeId: getScopedSnapshotValue, - injectFamilySnapshotValueWithSelectableListScopeId: - getScopedFamilySnapshotValue, - }; -}; diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListStates.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListStates.ts new file mode 100644 index 000000000..97179525c --- /dev/null +++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/internal/useSelectableListStates.ts @@ -0,0 +1,35 @@ +import { SelectableListScopeInternalContext } from '@/ui/layout/selectable-list/scopes/scope-internal-context/SelectableListScopeInternalContext'; +import { selectableItemIdsStateScopeMap } from '@/ui/layout/selectable-list/states/selectableItemIdsStateScopeMap'; +import { selectableListOnEnterStateScopeMap } from '@/ui/layout/selectable-list/states/selectableListOnEnterStateScopeMap'; +import { selectedItemIdStateScopeMap } from '@/ui/layout/selectable-list/states/selectedItemIdStateScopeMap'; +import { isSelectedItemIdFamilySelectorScopeMap } from '@/ui/layout/selectable-list/states/selectors/isSelectedItemIdFamilySelectorScopeMap'; +import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId'; +import { getFamilyState } from '@/ui/utilities/recoil-scope/utils/getFamilyState'; +import { getState } from '@/ui/utilities/recoil-scope/utils/getState'; + +type useSelectableListStatesProps = { + selectableListScopeId?: string; +}; + +export const useSelectableListStates = ({ + selectableListScopeId, +}: useSelectableListStatesProps) => { + const scopeId = useAvailableScopeIdOrThrow( + SelectableListScopeInternalContext, + selectableListScopeId, + ); + + return { + scopeId, + isSelectedItemIdSelector: getFamilyState( + isSelectedItemIdFamilySelectorScopeMap, + scopeId, + ), + selectableItemIdsState: getState(selectableItemIdsStateScopeMap, scopeId), + selectableListOnEnterState: getState( + selectableListOnEnterStateScopeMap, + scopeId, + ), + selectedItemIdState: getState(selectedItemIdStateScopeMap, scopeId), + }; +}; diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts index ccadbba65..37098d3c9 100644 --- a/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts +++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/hooks/useSelectableList.ts @@ -1,38 +1,24 @@ import { useResetRecoilState, useSetRecoilState } from 'recoil'; -import { useSelectableListScopedState } from '@/ui/layout/selectable-list/hooks/internal/useSelectableListScopedState'; -import { getSelectableListScopeInjectors } from '@/ui/layout/selectable-list/utils/internal/getSelectableListScopeInjectors'; +import { useSelectableListStates } from '@/ui/layout/selectable-list/hooks/internal/useSelectableListStates'; export const useSelectableList = (selectableListId?: string) => { const { - injectStateWithSelectableListScopeId, - injectFamilyStateWithSelectableListScopeId, scopeId, - } = useSelectableListScopedState({ + selectableItemIdsState, + selectableListOnEnterState, + isSelectedItemIdSelector, + selectedItemIdState, + } = useSelectableListStates({ selectableListScopeId: selectableListId, }); - const { - selectedItemIdScopeInjector, - selectableItemIdsScopeInjector, - selectableListOnEnterScopeInjector, - isSelectedItemIdFamilyScopeInjector, - } = getSelectableListScopeInjectors(); - - const setSelectableItemIds = useSetRecoilState( - injectStateWithSelectableListScopeId(selectableItemIdsScopeInjector), - ); + const setSelectableItemIds = useSetRecoilState(selectableItemIdsState); const setSelectableListOnEnter = useSetRecoilState( - injectStateWithSelectableListScopeId(selectableListOnEnterScopeInjector), + selectableListOnEnterState, ); - const isSelectedItemIdFamilyState = - injectFamilyStateWithSelectableListScopeId( - isSelectedItemIdFamilyScopeInjector, - ); - const resetSelectedItemIdState = useResetRecoilState( - injectStateWithSelectableListScopeId(selectedItemIdScopeInjector), - ); + const resetSelectedItemIdState = useResetRecoilState(selectedItemIdState); const resetSelectedItem = () => { resetSelectedItemIdState(); @@ -42,7 +28,7 @@ export const useSelectableList = (selectableListId?: string) => { selectableListId: scopeId, setSelectableItemIds, - isSelectedItemIdFamilyState, + isSelectedItemIdSelector, setSelectableListOnEnter, resetSelectedItem, }; diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/scopes/scope-internal-context/SelectableListScopeInternalContext.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/scopes/scope-internal-context/SelectableListScopeInternalContext.ts index 57285e0ea..7857bfdd3 100644 --- a/packages/twenty-front/src/modules/ui/layout/selectable-list/scopes/scope-internal-context/SelectableListScopeInternalContext.ts +++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/scopes/scope-internal-context/SelectableListScopeInternalContext.ts @@ -1,7 +1,7 @@ -import { ScopedStateKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/ScopedStateKey'; +import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey'; import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext'; -type SelectableListScopeInternalContextProps = ScopedStateKey; +type SelectableListScopeInternalContextProps = StateScopeMapKey; export const SelectableListScopeInternalContext = createScopeInternalContext(); diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/isSelectedItemIdFamilyStateScopeMap.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/isSelectedItemIdFamilyStateScopeMap.ts new file mode 100644 index 000000000..84bc20fd4 --- /dev/null +++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/isSelectedItemIdFamilyStateScopeMap.ts @@ -0,0 +1,9 @@ +import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap'; + +export const isSelectedItemIdFamilyStateScopeMap = createFamilyStateScopeMap< + boolean, + string +>({ + key: 'isSelectedItemIdMapScopedFamilyState', + defaultValue: false, +}); diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/isSelectedItemIdMapScopedFamilyState.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/isSelectedItemIdMapScopedFamilyState.ts deleted file mode 100644 index ed527c59a..000000000 --- a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/isSelectedItemIdMapScopedFamilyState.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { createScopedFamilyState } from '@/ui/utilities/recoil-scope/utils/createScopedFamilyState'; - -export const isSelectedItemIdMapScopedFamilyState = createScopedFamilyState< - boolean, - string ->({ - key: 'isSelectedItemIdMapScopedFamilyState', - defaultValue: false, -}); diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableItemIdsScopedState.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableItemIdsScopedState.ts deleted file mode 100644 index 1e56312e9..000000000 --- a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableItemIdsScopedState.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; - -export const selectableItemIdsScopedState = createScopedState({ - key: 'selectableItemIdsScopedState', - defaultValue: [[]], -}); diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableItemIdsStateScopeMap.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableItemIdsStateScopeMap.ts new file mode 100644 index 000000000..19c3e68eb --- /dev/null +++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableItemIdsStateScopeMap.ts @@ -0,0 +1,6 @@ +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; + +export const selectableItemIdsStateScopeMap = createStateScopeMap({ + key: 'selectableItemIdsScopedState', + defaultValue: [[]], +}); diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableListOnEnterScopedState.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableListOnEnterScopedState.ts deleted file mode 100644 index ef6752569..000000000 --- a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableListOnEnterScopedState.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; - -export const selectableListOnEnterScopedState = createScopedState< - ((itemId: string) => void) | undefined ->({ - key: 'selectableListOnEnterScopedState', - defaultValue: undefined, -}); diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableListOnEnterStateScopeMap.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableListOnEnterStateScopeMap.ts new file mode 100644 index 000000000..055b1d117 --- /dev/null +++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableListOnEnterStateScopeMap.ts @@ -0,0 +1,8 @@ +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; + +export const selectableListOnEnterStateScopeMap = createStateScopeMap< + ((itemId: string) => void) | undefined +>({ + key: 'selectableListOnEnterScopedState', + defaultValue: undefined, +}); diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectedItemIdScopedState.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectedItemIdScopedState.ts deleted file mode 100644 index b1b41c3cf..000000000 --- a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectedItemIdScopedState.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; - -export const selectedItemIdScopedState = createScopedState({ - key: 'selectedItemIdScopedState', - defaultValue: null, -}); diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectedItemIdStateScopeMap.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectedItemIdStateScopeMap.ts new file mode 100644 index 000000000..8445a2c2e --- /dev/null +++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectedItemIdStateScopeMap.ts @@ -0,0 +1,6 @@ +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; + +export const selectedItemIdStateScopeMap = createStateScopeMap({ + key: 'selectedItemIdScopedState', + defaultValue: null, +}); diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectors/isSelectedItemIdFamilySelectorScopeMap.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectors/isSelectedItemIdFamilySelectorScopeMap.ts new file mode 100644 index 000000000..6eae4ad0c --- /dev/null +++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectors/isSelectedItemIdFamilySelectorScopeMap.ts @@ -0,0 +1,26 @@ +import { isSelectedItemIdFamilyStateScopeMap } from '@/ui/layout/selectable-list/states/isSelectedItemIdFamilyStateScopeMap'; +import { createFamilySelectorScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilySelectorScopeMap'; + +export const isSelectedItemIdFamilySelectorScopeMap = + createFamilySelectorScopeMap({ + key: 'isSelectedItemIdScopedFamilySelector', + get: + ({ scopeId, familyKey }: { scopeId: string; familyKey: string }) => + ({ get }) => + get( + isSelectedItemIdFamilyStateScopeMap({ + scopeId: scopeId, + familyKey: familyKey, + }), + ), + set: + ({ scopeId, familyKey }: { scopeId: string; familyKey: string }) => + ({ set }, newValue) => + set( + isSelectedItemIdFamilyStateScopeMap({ + scopeId: scopeId, + familyKey: familyKey, + }), + newValue, + ), + }); diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectors/isSelectedItemIdScopedFamilySelector.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectors/isSelectedItemIdScopedFamilySelector.ts deleted file mode 100644 index 31cb4b048..000000000 --- a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectors/isSelectedItemIdScopedFamilySelector.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { isSelectedItemIdMapScopedFamilyState } from '@/ui/layout/selectable-list/states/isSelectedItemIdMapScopedFamilyState'; -import { createScopedFamilySelector } from '@/ui/utilities/recoil-scope/utils/createScopedFamilySelector'; - -export const isSelectedItemIdScopedFamilySelector = createScopedFamilySelector< - boolean, - string ->({ - key: 'isSelectedItemIdScopedFamilySelector', - get: - ({ scopeId, familyKey }: { scopeId: string; familyKey: string }) => - ({ get }) => - get( - isSelectedItemIdMapScopedFamilyState({ - scopeId: scopeId, - familyKey: familyKey, - }), - ), - set: - ({ scopeId, familyKey }: { scopeId: string; familyKey: string }) => - ({ set }, newValue) => - set( - isSelectedItemIdMapScopedFamilyState({ - scopeId: scopeId, - familyKey: familyKey, - }), - newValue, - ), -}); diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/utils/internal/getSelectableListScopeInjectors.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/utils/internal/getSelectableListScopeInjectors.ts deleted file mode 100644 index c02eebbc4..000000000 --- a/packages/twenty-front/src/modules/ui/layout/selectable-list/utils/internal/getSelectableListScopeInjectors.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { selectableItemIdsScopedState } from '@/ui/layout/selectable-list/states/selectableItemIdsScopedState'; -import { selectableListOnEnterScopedState } from '@/ui/layout/selectable-list/states/selectableListOnEnterScopedState'; -import { selectedItemIdScopedState } from '@/ui/layout/selectable-list/states/selectedItemIdScopedState'; -import { isSelectedItemIdScopedFamilySelector } from '@/ui/layout/selectable-list/states/selectors/isSelectedItemIdScopedFamilySelector'; -import { getFamilyScopeInjector } from '@/ui/utilities/recoil-scope/utils/getFamilyScopeInjector'; -import { getScopeInjector } from '@/ui/utilities/recoil-scope/utils/getScopeInjector'; - -export const getSelectableListScopeInjectors = () => { - const selectedItemIdScopeInjector = getScopeInjector( - selectedItemIdScopedState, - ); - const selectableItemIdsScopeInjector = getScopeInjector( - selectableItemIdsScopedState, - ); - const selectableListOnEnterScopeInjector = getScopeInjector( - selectableListOnEnterScopedState, - ); - const isSelectedItemIdFamilyScopeInjector = getFamilyScopeInjector( - isSelectedItemIdScopedFamilySelector, - ); - - return { - selectedItemIdScopeInjector, - selectableItemIdsScopeInjector, - selectableListOnEnterScopeInjector, - isSelectedItemIdFamilyScopeInjector, - }; -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedFamilyState.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedFamilyState.ts index 76b4efcf2..457a8fb09 100644 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedFamilyState.ts +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedFamilyState.ts @@ -1,13 +1,13 @@ import { RecoilState, SerializableParam, useRecoilState } from 'recoil'; -import { ScopedFamilyStateKey } from '../scopes-internal/types/ScopedFamilyStateKey'; +import { FamilyStateScopeMapKey } from '../scopes-internal/types/FamilyStateScopeMapKey'; export const useRecoilScopedFamilyState = < StateType, FamilyKey extends SerializableParam, >( recoilState: ( - scopedFamilyKey: ScopedFamilyStateKey, + scopedFamilyKey: FamilyStateScopeMapKey, ) => RecoilState, scopeId: string, familyKey?: FamilyKey, diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedStateV2.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedStateV2.ts index 8e81182f6..389a4aa32 100644 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedStateV2.ts +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedStateV2.ts @@ -1,9 +1,9 @@ import { RecoilState, useRecoilState } from 'recoil'; -import { ScopedStateKey } from '../scopes-internal/types/ScopedStateKey'; +import { StateScopeMapKey } from '../scopes-internal/types/StateScopeMapKey'; export const useRecoilScopedStateV2 = ( - recoilState: (scopedKey: ScopedStateKey) => RecoilState, + recoilState: (scopedKey: StateScopeMapKey) => RecoilState, scopeId: string, ) => { return useRecoilState( diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedValueV2.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedValueV2.ts index b3b2126b7..f3f90d1e8 100644 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedValueV2.ts +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedValueV2.ts @@ -1,9 +1,9 @@ import { RecoilState, useRecoilValue } from 'recoil'; -import { ScopedStateKey } from '../scopes-internal/types/ScopedStateKey'; +import { StateScopeMapKey } from '../scopes-internal/types/StateScopeMapKey'; export const useRecoilScopedValueV2 = ( - recoilState: (scopedKey: ScopedStateKey) => RecoilState, + recoilState: (scopedKey: StateScopeMapKey) => RecoilState, scopeId: string, ) => { return useRecoilValue( diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useSetRecoilScopedFamilyState.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useSetRecoilScopedFamilyState.ts index ee1a3be8e..e74d1f171 100644 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useSetRecoilScopedFamilyState.ts +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useSetRecoilScopedFamilyState.ts @@ -1,13 +1,13 @@ import { RecoilState, SerializableParam, useSetRecoilState } from 'recoil'; -import { ScopedFamilyStateKey } from '../scopes-internal/types/ScopedFamilyStateKey'; +import { FamilyStateScopeMapKey } from '../scopes-internal/types/FamilyStateScopeMapKey'; export const useSetRecoilScopedFamilyState = < StateType, FamilyKey extends SerializableParam, >( recoilState: ( - scopedFamilyKey: ScopedFamilyStateKey, + scopedFamilyKey: FamilyStateScopeMapKey, ) => RecoilState, scopeId: string, familyKey?: FamilyKey, diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useSetRecoilScopedStateV2.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useSetRecoilScopedStateV2.ts index fc043036f..35396eebc 100644 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useSetRecoilScopedStateV2.ts +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useSetRecoilScopedStateV2.ts @@ -1,9 +1,9 @@ import { RecoilState, useSetRecoilState } from 'recoil'; -import { ScopedStateKey } from '../scopes-internal/types/ScopedStateKey'; +import { StateScopeMapKey } from '../scopes-internal/types/StateScopeMapKey'; export const useSetRecoilScopedStateV2 = ( - recoilState: (scopedKey: ScopedStateKey) => RecoilState, + recoilState: (scopedKey: StateScopeMapKey) => RecoilState, scopeId: string, ) => { return useSetRecoilState( diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/ScopedFamilyStateKey.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/FamilyStateScopeMapKey.ts similarity index 54% rename from packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/ScopedFamilyStateKey.ts rename to packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/FamilyStateScopeMapKey.ts index 2930aaed4..96733c979 100644 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/ScopedFamilyStateKey.ts +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/FamilyStateScopeMapKey.ts @@ -1,6 +1,6 @@ import { SerializableParam } from 'recoil'; -export type ScopedFamilyStateKey = { +export type FamilyStateScopeMapKey = { scopeId: string; familyKey: FamilyKey; }; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/ScopedStateKey.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/ScopedStateKey.ts deleted file mode 100644 index e0904f87f..000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/ScopedStateKey.ts +++ /dev/null @@ -1,3 +0,0 @@ -export type ScopedStateKey = { - scopeId: string; -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey.ts new file mode 100644 index 000000000..3915d9478 --- /dev/null +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey.ts @@ -0,0 +1,3 @@ +export type StateScopeMapKey = { + scopeId: string; +}; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext.ts index e5a3c0ab2..8789a1572 100644 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext.ts +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext.ts @@ -1,10 +1,10 @@ import { Context, createContext } from 'react'; -import { ScopedStateKey } from '../types/ScopedStateKey'; +import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey'; -type ScopeInternalContext = Context; +type ScopeInternalContext = Context; -export const createScopeInternalContext = ( +export const createScopeInternalContext = ( initialValue?: T, ) => { return createContext( diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/types/RecoilScopedSelector.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/types/RecoilScopedSelector.ts index 99d96b736..698035600 100644 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/types/RecoilScopedSelector.ts +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/types/RecoilScopedSelector.ts @@ -1,7 +1,7 @@ import { RecoilValueReadOnly } from 'recoil'; -import { ScopedStateKey } from '../scopes-internal/types/ScopedStateKey'; +import { StateScopeMapKey } from '../scopes-internal/types/StateScopeMapKey'; export type RecoilScopedSelector = ( - scopedKey: ScopedStateKey, + scopedKey: StateScopeMapKey, ) => RecoilValueReadOnly; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/types/RecoilScopedState.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/types/RecoilScopedState.ts index f17cc4d71..ace7ab39e 100644 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/types/RecoilScopedState.ts +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/types/RecoilScopedState.ts @@ -1,7 +1,7 @@ import { RecoilState } from 'recoil'; -import { ScopedStateKey } from '../scopes-internal/types/ScopedStateKey'; +import { StateScopeMapKey } from '../scopes-internal/types/StateScopeMapKey'; export type RecoilScopedState = ( - scopedKey: ScopedStateKey, + scopedKey: StateScopeMapKey, ) => RecoilState; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createScopedFamilySelector.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createFamilySelectorScopeMap.ts similarity index 66% rename from packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createScopedFamilySelector.ts rename to packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createFamilySelectorScopeMap.ts index 7701f0d46..cdfbc6a10 100644 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createScopedFamilySelector.ts +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createFamilySelectorScopeMap.ts @@ -11,7 +11,7 @@ import { WrappedValue, } from 'recoil'; -import { ScopedFamilyStateKey } from '../scopes-internal/types/ScopedFamilyStateKey'; +import { FamilyStateScopeMapKey } from '../scopes-internal/types/FamilyStateScopeMapKey'; type SelectorGetter = ( param: P, @@ -27,7 +27,7 @@ type SelectorSetter = ( newValue: T | DefaultValue, ) => void; -export const createScopedFamilySelector = < +export const createFamilySelectorScopeMap = < ValueType, FamilyKey extends SerializableParam, >({ @@ -36,10 +36,10 @@ export const createScopedFamilySelector = < set, }: { key: string; - get: SelectorGetter>; - set: SelectorSetter>; + get: SelectorGetter>; + set: SelectorSetter>; }) => { - return selectorFamily>({ + return selectorFamily>({ key, get, set, diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createScopedFamilyState.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap.ts similarity index 51% rename from packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createScopedFamilyState.ts rename to packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap.ts index e73a891ef..0c44711cc 100644 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createScopedFamilyState.ts +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap.ts @@ -1,8 +1,8 @@ import { atomFamily, SerializableParam } from 'recoil'; -import { ScopedFamilyStateKey } from '../scopes-internal/types/ScopedFamilyStateKey'; +import { FamilyStateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/FamilyStateScopeMapKey'; -export const createScopedFamilyState = < +export const createFamilyStateScopeMap = < ValueType, FamilyKey extends SerializableParam, >({ @@ -12,7 +12,7 @@ export const createScopedFamilyState = < key: string; defaultValue: ValueType; }) => { - return atomFamily>({ + return atomFamily>({ key, default: defaultValue, }); diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createScopedState.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createScopedState.ts deleted file mode 100644 index 74d128ac0..000000000 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createScopedState.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { atomFamily } from 'recoil'; - -export const createScopedState = ({ - key, - defaultValue, -}: { - key: string; - defaultValue: ValueType; -}) => { - return atomFamily({ - key, - default: defaultValue, - }); -}; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createScopedSelector.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createSelectorScopeMap.ts similarity index 58% rename from packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createScopedSelector.ts rename to packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createSelectorScopeMap.ts index 53e9ca672..5f8db8343 100644 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createScopedSelector.ts +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createSelectorScopeMap.ts @@ -7,7 +7,7 @@ import { WrappedValue, } from 'recoil'; -import { ScopedStateKey } from '../scopes-internal/types/ScopedStateKey'; +import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey'; type SelectorGetter = ( param: P, @@ -16,14 +16,14 @@ type SelectorGetter = ( getCallback: GetCallback; }) => Promise | RecoilValue | Loadable | WrappedValue | T; -export const createScopedSelector = ({ +export const createSelectorScopeMap = ({ key, get, }: { key: string; - get: SelectorGetter; + get: SelectorGetter; }) => { - return selectorFamily({ + return selectorFamily({ key, get, }); diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createStateScopeMap.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createStateScopeMap.ts new file mode 100644 index 000000000..58efdf2ec --- /dev/null +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createStateScopeMap.ts @@ -0,0 +1,16 @@ +import { atomFamily } from 'recoil'; + +import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey'; + +export const createStateScopeMap = ({ + key, + defaultValue, +}: { + key: string; + defaultValue: ValueType; +}) => { + return atomFamily({ + key, + default: defaultValue, + }); +}; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getFamilyScopeInjector.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getFamilyScopeInjector.ts index dc328ddc7..ffde95aa1 100644 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getFamilyScopeInjector.ts +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getFamilyScopeInjector.ts @@ -1,6 +1,6 @@ import { RecoilState, SerializableParam } from 'recoil'; -import { ScopedFamilyStateKey } from '../scopes-internal/types/ScopedFamilyStateKey'; +import { FamilyStateScopeMapKey } from '../scopes-internal/types/FamilyStateScopeMapKey'; export type FamilyScopeInjector< StateType, @@ -12,7 +12,7 @@ export const getFamilyScopeInjector = < FamilyKey extends SerializableParam, >( scopedFamilyState: ( - scopedFamilyKey: ScopedFamilyStateKey, + scopedFamilyKey: FamilyStateScopeMapKey, ) => RecoilState, ) => { return (scopeId: string, familyKey: FamilyKey) => diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getFamilyState.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getFamilyState.ts new file mode 100644 index 000000000..932920bab --- /dev/null +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getFamilyState.ts @@ -0,0 +1,16 @@ +import { RecoilState, SerializableParam } from 'recoil'; + +import { FamilyStateScopeMapKey } from '../scopes-internal/types/FamilyStateScopeMapKey'; + +export const getFamilyState = ( + familyStateScopeMap: ( + scopedFamilyKey: FamilyStateScopeMapKey, + ) => RecoilState, + scopeId: string, +) => { + return (familyKey: FamilyKey) => + familyStateScopeMap({ + scopeId, + familyKey: familyKey || ('' as FamilyKey), + }); +}; diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getScopedFamilyStateDeprecated.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getScopedFamilyStateDeprecated.ts index b95fbe01c..771d61a1c 100644 --- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getScopedFamilyStateDeprecated.ts +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getScopedFamilyStateDeprecated.ts @@ -1,13 +1,13 @@ import { RecoilState, SerializableParam } from 'recoil'; -import { ScopedFamilyStateKey } from '../scopes-internal/types/ScopedFamilyStateKey'; +import { FamilyStateScopeMapKey } from '../scopes-internal/types/FamilyStateScopeMapKey'; export const getScopedFamilyStateDeprecated = < StateType, FamilyKey extends SerializableParam, >( recoilState: ( - scopedFamilyKey: ScopedFamilyStateKey, + scopedFamilyKey: FamilyStateScopeMapKey, ) => RecoilState, scopeId: string, familyKey: FamilyKey, diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getState.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getState.ts new file mode 100644 index 000000000..60717e2d8 --- /dev/null +++ b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getState.ts @@ -0,0 +1,10 @@ +import { RecoilState } from 'recoil'; + +import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey'; + +export const getState = ( + stateScopeMap: (stateScopeMapKey: StateScopeMapKey) => RecoilState, + scopeId: string, +) => { + return stateScopeMap({ scopeId }); +}; diff --git a/packages/twenty-front/src/modules/views/scopes/scope-internal-context/ViewScopeInternalContext.ts b/packages/twenty-front/src/modules/views/scopes/scope-internal-context/ViewScopeInternalContext.ts index 18824dc99..39dcf9684 100644 --- a/packages/twenty-front/src/modules/views/scopes/scope-internal-context/ViewScopeInternalContext.ts +++ b/packages/twenty-front/src/modules/views/scopes/scope-internal-context/ViewScopeInternalContext.ts @@ -1,7 +1,7 @@ -import { ScopedStateKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/ScopedStateKey'; +import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey'; import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext'; -type ViewScopeInternalContextProps = ScopedStateKey; +type ViewScopeInternalContextProps = StateScopeMapKey; export const ViewScopeInternalContext = createScopeInternalContext(); diff --git a/packages/twenty-front/src/modules/views/states/availableFieldDefinitionsScopedState.ts b/packages/twenty-front/src/modules/views/states/availableFieldDefinitionsScopedState.ts index d488fdbbe..c91b8bb82 100644 --- a/packages/twenty-front/src/modules/views/states/availableFieldDefinitionsScopedState.ts +++ b/packages/twenty-front/src/modules/views/states/availableFieldDefinitionsScopedState.ts @@ -1,8 +1,8 @@ import { FieldMetadata } from '@/object-record/field/types/FieldMetadata'; import { ColumnDefinition } from '@/object-record/record-table/types/ColumnDefinition'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const availableFieldDefinitionsScopedState = createScopedState< +export const availableFieldDefinitionsScopedState = createStateScopeMap< ColumnDefinition[] >({ key: 'availableFieldDefinitionsScopedState', diff --git a/packages/twenty-front/src/modules/views/states/availableFilterDefinitionsScopedState.ts b/packages/twenty-front/src/modules/views/states/availableFilterDefinitionsScopedState.ts index 17d0cd616..4ed3c9ce7 100644 --- a/packages/twenty-front/src/modules/views/states/availableFilterDefinitionsScopedState.ts +++ b/packages/twenty-front/src/modules/views/states/availableFilterDefinitionsScopedState.ts @@ -1,7 +1,7 @@ import { FilterDefinition } from '@/object-record/object-filter-dropdown/types/FilterDefinition'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const availableFilterDefinitionsScopedState = createScopedState< +export const availableFilterDefinitionsScopedState = createStateScopeMap< FilterDefinition[] >({ key: 'availableFilterDefinitionsScopedState', diff --git a/packages/twenty-front/src/modules/views/states/availableSortDefinitionsScopedState.ts b/packages/twenty-front/src/modules/views/states/availableSortDefinitionsScopedState.ts index f61eda447..43912ec24 100644 --- a/packages/twenty-front/src/modules/views/states/availableSortDefinitionsScopedState.ts +++ b/packages/twenty-front/src/modules/views/states/availableSortDefinitionsScopedState.ts @@ -1,7 +1,7 @@ import { SortDefinition } from '@/object-record/object-sort-dropdown/types/SortDefinition'; -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const availableSortDefinitionsScopedState = createScopedState< +export const availableSortDefinitionsScopedState = createStateScopeMap< SortDefinition[] >({ key: 'availableSortDefinitionsScopedState', diff --git a/packages/twenty-front/src/modules/views/states/currentViewFieldsScopedFamilyState.ts b/packages/twenty-front/src/modules/views/states/currentViewFieldsScopedFamilyState.ts index fbc327b4d..4c071e69b 100644 --- a/packages/twenty-front/src/modules/views/states/currentViewFieldsScopedFamilyState.ts +++ b/packages/twenty-front/src/modules/views/states/currentViewFieldsScopedFamilyState.ts @@ -1,8 +1,8 @@ -import { createScopedFamilyState } from '@/ui/utilities/recoil-scope/utils/createScopedFamilyState'; +import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap'; import { ViewField } from '../types/ViewField'; -export const currentViewFieldsScopedFamilyState = createScopedFamilyState< +export const currentViewFieldsScopedFamilyState = createFamilyStateScopeMap< ViewField[], string >({ diff --git a/packages/twenty-front/src/modules/views/states/currentViewFiltersScopedFamilyState.ts b/packages/twenty-front/src/modules/views/states/currentViewFiltersScopedFamilyState.ts index 41a8eb9e0..fa807a56d 100644 --- a/packages/twenty-front/src/modules/views/states/currentViewFiltersScopedFamilyState.ts +++ b/packages/twenty-front/src/modules/views/states/currentViewFiltersScopedFamilyState.ts @@ -1,8 +1,8 @@ -import { createScopedFamilyState } from '@/ui/utilities/recoil-scope/utils/createScopedFamilyState'; +import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap'; import { ViewFilter } from '../types/ViewFilter'; -export const currentViewFiltersScopedFamilyState = createScopedFamilyState< +export const currentViewFiltersScopedFamilyState = createFamilyStateScopeMap< ViewFilter[], string >({ diff --git a/packages/twenty-front/src/modules/views/states/currentViewIdScopedState.ts b/packages/twenty-front/src/modules/views/states/currentViewIdScopedState.ts index 748d3c04c..98a46cbbd 100644 --- a/packages/twenty-front/src/modules/views/states/currentViewIdScopedState.ts +++ b/packages/twenty-front/src/modules/views/states/currentViewIdScopedState.ts @@ -1,6 +1,8 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const currentViewIdScopedState = createScopedState({ - key: 'currentViewIdScopedState', - defaultValue: undefined, -}); +export const currentViewIdScopedState = createStateScopeMap( + { + key: 'currentViewIdScopedState', + defaultValue: undefined, + }, +); diff --git a/packages/twenty-front/src/modules/views/states/currentViewSortsScopedFamilyState.ts b/packages/twenty-front/src/modules/views/states/currentViewSortsScopedFamilyState.ts index d4cedc66c..f12bd2626 100644 --- a/packages/twenty-front/src/modules/views/states/currentViewSortsScopedFamilyState.ts +++ b/packages/twenty-front/src/modules/views/states/currentViewSortsScopedFamilyState.ts @@ -1,8 +1,8 @@ -import { createScopedFamilyState } from '@/ui/utilities/recoil-scope/utils/createScopedFamilyState'; +import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap'; import { ViewSort } from '../types/ViewSort'; -export const currentViewSortsScopedFamilyState = createScopedFamilyState< +export const currentViewSortsScopedFamilyState = createFamilyStateScopeMap< ViewSort[], string >({ diff --git a/packages/twenty-front/src/modules/views/states/entityCountInCurrentViewScopedState.ts b/packages/twenty-front/src/modules/views/states/entityCountInCurrentViewScopedState.ts index 837cac87b..6bea66a6d 100644 --- a/packages/twenty-front/src/modules/views/states/entityCountInCurrentViewScopedState.ts +++ b/packages/twenty-front/src/modules/views/states/entityCountInCurrentViewScopedState.ts @@ -1,6 +1,6 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const entityCountInCurrentViewScopedState = createScopedState({ +export const entityCountInCurrentViewScopedState = createStateScopeMap({ key: 'entityCountInCurrentViewScopedState', defaultValue: 0, }); diff --git a/packages/twenty-front/src/modules/views/states/isPersistingViewScopedState.ts b/packages/twenty-front/src/modules/views/states/isPersistingViewScopedState.ts index aadf01e8f..24b11da0c 100644 --- a/packages/twenty-front/src/modules/views/states/isPersistingViewScopedState.ts +++ b/packages/twenty-front/src/modules/views/states/isPersistingViewScopedState.ts @@ -1,6 +1,6 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const isPersistingViewScopedState = createScopedState({ +export const isPersistingViewScopedState = createStateScopeMap({ key: 'isPersistingViewScopedState', defaultValue: false, }); diff --git a/packages/twenty-front/src/modules/views/states/isViewBarExpandedScopedState.ts b/packages/twenty-front/src/modules/views/states/isViewBarExpandedScopedState.ts index c51fd165c..acd1a312e 100644 --- a/packages/twenty-front/src/modules/views/states/isViewBarExpandedScopedState.ts +++ b/packages/twenty-front/src/modules/views/states/isViewBarExpandedScopedState.ts @@ -1,6 +1,6 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const isViewBarExpandedScopedState = createScopedState({ +export const isViewBarExpandedScopedState = createStateScopeMap({ key: 'isViewBarExpandedScopedState', defaultValue: true, }); diff --git a/packages/twenty-front/src/modules/views/states/noneScopedFamilyState.ts b/packages/twenty-front/src/modules/views/states/noneScopedFamilyState.ts index feeacd214..0c318836d 100644 --- a/packages/twenty-front/src/modules/views/states/noneScopedFamilyState.ts +++ b/packages/twenty-front/src/modules/views/states/noneScopedFamilyState.ts @@ -1,6 +1,6 @@ -import { createScopedFamilyState } from '@/ui/utilities/recoil-scope/utils/createScopedFamilyState'; +import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap'; -export const noneScopedFamilyState = createScopedFamilyState({ +export const noneScopedFamilyState = createFamilyStateScopeMap({ key: 'noneScopedFamilyState', defaultValue: null, }); diff --git a/packages/twenty-front/src/modules/views/states/onViewFieldsChangeScopedState.ts b/packages/twenty-front/src/modules/views/states/onViewFieldsChangeScopedState.ts index cd2e11832..baed107d6 100644 --- a/packages/twenty-front/src/modules/views/states/onViewFieldsChangeScopedState.ts +++ b/packages/twenty-front/src/modules/views/states/onViewFieldsChangeScopedState.ts @@ -1,8 +1,8 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { ViewField } from '../types/ViewField'; -export const onViewFieldsChangeScopedState = createScopedState< +export const onViewFieldsChangeScopedState = createStateScopeMap< ((fields: ViewField[]) => void | Promise) | undefined >({ key: 'onViewFieldsChangeScopedState', diff --git a/packages/twenty-front/src/modules/views/states/onViewFiltersChangeScopedState.ts b/packages/twenty-front/src/modules/views/states/onViewFiltersChangeScopedState.ts index 0d4b30ab0..a2abce59f 100644 --- a/packages/twenty-front/src/modules/views/states/onViewFiltersChangeScopedState.ts +++ b/packages/twenty-front/src/modules/views/states/onViewFiltersChangeScopedState.ts @@ -1,7 +1,7 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { ViewFilter } from '@/views/types/ViewFilter'; -export const onViewFiltersChangeScopedState = createScopedState< +export const onViewFiltersChangeScopedState = createStateScopeMap< ((filters: ViewFilter[]) => void | Promise) | undefined >({ key: 'onViewFiltersChangeScopedState', diff --git a/packages/twenty-front/src/modules/views/states/onViewSortsChangeScopedState.ts b/packages/twenty-front/src/modules/views/states/onViewSortsChangeScopedState.ts index a76a2da1a..d72a0dfa9 100644 --- a/packages/twenty-front/src/modules/views/states/onViewSortsChangeScopedState.ts +++ b/packages/twenty-front/src/modules/views/states/onViewSortsChangeScopedState.ts @@ -1,7 +1,7 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { ViewSort } from '@/views/types/ViewSort'; -export const onViewSortsChangeScopedState = createScopedState< +export const onViewSortsChangeScopedState = createStateScopeMap< ((sorts: ViewSort[]) => void | Promise) | undefined >({ key: 'onViewSortsChangeScopedState', diff --git a/packages/twenty-front/src/modules/views/states/savedViewFieldsScopedFamilyState.ts b/packages/twenty-front/src/modules/views/states/savedViewFieldsScopedFamilyState.ts index 130a812c5..1610e5d6b 100644 --- a/packages/twenty-front/src/modules/views/states/savedViewFieldsScopedFamilyState.ts +++ b/packages/twenty-front/src/modules/views/states/savedViewFieldsScopedFamilyState.ts @@ -1,8 +1,8 @@ -import { createScopedFamilyState } from '@/ui/utilities/recoil-scope/utils/createScopedFamilyState'; +import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap'; import { ViewField } from '../types/ViewField'; -export const savedViewFieldsScopedFamilyState = createScopedFamilyState< +export const savedViewFieldsScopedFamilyState = createFamilyStateScopeMap< ViewField[], string >({ diff --git a/packages/twenty-front/src/modules/views/states/savedViewFiltersScopedFamilyState.ts b/packages/twenty-front/src/modules/views/states/savedViewFiltersScopedFamilyState.ts index 96b0cac67..06a49096b 100644 --- a/packages/twenty-front/src/modules/views/states/savedViewFiltersScopedFamilyState.ts +++ b/packages/twenty-front/src/modules/views/states/savedViewFiltersScopedFamilyState.ts @@ -1,8 +1,8 @@ -import { createScopedFamilyState } from '@/ui/utilities/recoil-scope/utils/createScopedFamilyState'; +import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap'; import { ViewFilter } from '../types/ViewFilter'; -export const savedViewFiltersScopedFamilyState = createScopedFamilyState< +export const savedViewFiltersScopedFamilyState = createFamilyStateScopeMap< ViewFilter[], string >({ diff --git a/packages/twenty-front/src/modules/views/states/savedViewSortsScopedFamilyState.ts b/packages/twenty-front/src/modules/views/states/savedViewSortsScopedFamilyState.ts index 14316cc7c..ea0a9811d 100644 --- a/packages/twenty-front/src/modules/views/states/savedViewSortsScopedFamilyState.ts +++ b/packages/twenty-front/src/modules/views/states/savedViewSortsScopedFamilyState.ts @@ -1,8 +1,8 @@ -import { createScopedFamilyState } from '@/ui/utilities/recoil-scope/utils/createScopedFamilyState'; +import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap'; import { ViewSort } from '../types/ViewSort'; -export const savedViewSortsScopedFamilyState = createScopedFamilyState< +export const savedViewSortsScopedFamilyState = createFamilyStateScopeMap< ViewSort[], string >({ diff --git a/packages/twenty-front/src/modules/views/states/selectors/currentViewScopedSelector.ts b/packages/twenty-front/src/modules/views/states/selectors/currentViewScopedSelector.ts index fbecda597..a40f83125 100644 --- a/packages/twenty-front/src/modules/views/states/selectors/currentViewScopedSelector.ts +++ b/packages/twenty-front/src/modules/views/states/selectors/currentViewScopedSelector.ts @@ -1,11 +1,11 @@ -import { createScopedSelector } from '@/ui/utilities/recoil-scope/utils/createScopedSelector'; +import { createSelectorScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorScopeMap'; import { GraphQLView } from '@/views/types/GraphQLView'; import { currentViewIdScopedState } from '../currentViewIdScopedState'; import { viewsByIdScopedSelector } from './viewsByIdScopedSelector'; -export const currentViewScopedSelector = createScopedSelector< +export const currentViewScopedSelector = createSelectorScopeMap< GraphQLView | undefined >({ key: 'currentViewScopedSelector', diff --git a/packages/twenty-front/src/modules/views/states/viewEditModeScopedState.ts b/packages/twenty-front/src/modules/views/states/viewEditModeScopedState.ts index 3a3ba3abc..5234afb96 100644 --- a/packages/twenty-front/src/modules/views/states/viewEditModeScopedState.ts +++ b/packages/twenty-front/src/modules/views/states/viewEditModeScopedState.ts @@ -1,6 +1,6 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const viewEditModeScopedState = createScopedState< +export const viewEditModeScopedState = createStateScopeMap< 'none' | 'edit' | 'create' >({ key: 'viewEditModeScopedState', diff --git a/packages/twenty-front/src/modules/views/states/viewObjectMetadataIdScopeState.ts b/packages/twenty-front/src/modules/views/states/viewObjectMetadataIdScopeState.ts index c39aece36..a67bc387d 100644 --- a/packages/twenty-front/src/modules/views/states/viewObjectMetadataIdScopeState.ts +++ b/packages/twenty-front/src/modules/views/states/viewObjectMetadataIdScopeState.ts @@ -1,6 +1,6 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; -export const viewObjectMetadataIdScopeState = createScopedState< +export const viewObjectMetadataIdScopeState = createStateScopeMap< string | undefined >({ key: 'viewObjectMetadataIdScopeState', diff --git a/packages/twenty-front/src/modules/views/states/viewTypeScopedState.ts b/packages/twenty-front/src/modules/views/states/viewTypeScopedState.ts index 312b6112e..2424bc19c 100644 --- a/packages/twenty-front/src/modules/views/states/viewTypeScopedState.ts +++ b/packages/twenty-front/src/modules/views/states/viewTypeScopedState.ts @@ -1,8 +1,8 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { ViewType } from '../types/ViewType'; -export const viewTypeScopedState = createScopedState({ +export const viewTypeScopedState = createStateScopeMap({ key: 'viewTypeScopedState', defaultValue: ViewType.Table, }); diff --git a/packages/twenty-front/src/modules/views/states/viewsScopedState.ts b/packages/twenty-front/src/modules/views/states/viewsScopedState.ts index 3f141877b..23c2c29b0 100644 --- a/packages/twenty-front/src/modules/views/states/viewsScopedState.ts +++ b/packages/twenty-front/src/modules/views/states/viewsScopedState.ts @@ -1,7 +1,7 @@ -import { createScopedState } from '@/ui/utilities/recoil-scope/utils/createScopedState'; +import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap'; import { GraphQLView } from '@/views/types/GraphQLView'; -export const viewsScopedState = createScopedState({ +export const viewsScopedState = createStateScopeMap({ key: 'viewsScopedState', defaultValue: [], }); diff --git a/packages/twenty-front/src/pages/settings/accounts/SettingsAccountsEmailsInboxSettings.tsx b/packages/twenty-front/src/pages/settings/accounts/SettingsAccountsEmailsInboxSettings.tsx index 93570ecf1..b3138a9d2 100644 --- a/packages/twenty-front/src/pages/settings/accounts/SettingsAccountsEmailsInboxSettings.tsx +++ b/packages/twenty-front/src/pages/settings/accounts/SettingsAccountsEmailsInboxSettings.tsx @@ -17,9 +17,7 @@ import { mockedAccounts } from '~/testing/mock-data/accounts'; export const SettingsAccountsEmailsInboxSettings = () => { const navigate = useNavigate(); const { accountUuid = '' } = useParams(); - const account = mockedAccounts.find( - (account) => account.uuid === accountUuid, - ); + const account = mockedAccounts.find((account) => account.id === accountUuid); useEffect(() => { if (!account) navigate(AppPath.NotFound); @@ -40,7 +38,7 @@ export const SettingsAccountsEmailsInboxSettings = () => { links={[ { children: 'Accounts', href: '/settings/accounts' }, { children: 'Emails', href: '/settings/accounts/emails' }, - { children: account?.email || '' }, + { children: account?.handle || '' }, ]} />