Skip to content

The open alternative to Salesforce, designed for AI.

Introduce ComponentState (#4386)

Charles Bochet86c0f311f58b
diff --git a/.github/workflows/ci-front.yaml b/.github/workflows/ci-front.yaml
index 66003014eab..1cb049749ce 100644
--- a/.github/workflows/ci-front.yaml
+++ b/.github/workflows/ci-front.yaml
@@ -172,4 +172,4 @@ jobs:
key: root-node_modules-${{hashFiles('yarn.lock')}}
restore-keys: root-node_modules-
- name: Front / Run jest
- run: yarn nx test twenty-front
\ No newline at end of file
+ run: yarn nx coverage twenty-front
\ No newline at end of file
diff --git a/packages/twenty-front/package.json b/packages/twenty-front/package.json
index ec0ff288267..9539629bfed 100644
--- a/packages/twenty-front/package.json
+++ b/packages/twenty-front/package.json
@@ -17,7 +17,7 @@
"lint:ci": "yarn lint --config .eslintrc-ci.cjs",
"fmt:fix": "prettier --cache --write \"src/**/*.ts\" \"src/**/*.tsx\"",
"fmt": "prettier --check \"src/**/*.ts\" \"src/**/*.tsx\"",
- "test": "jest src/modules/spreadsheet-import/utils/__tests__/dataMutations.test.ts",
+ "test": "jest",
"test-watch": "jest --watch",
"tsup": "tsup",
"coverage": "jest --coverage",
diff --git a/packages/twenty-front/src/effect-components/CommandMenuEffect.tsx b/packages/twenty-front/src/effect-components/CommandMenuEffect.tsx
index ece319312e9..7803c81032e 100644
--- a/packages/twenty-front/src/effect-components/CommandMenuEffect.tsx
+++ b/packages/twenty-front/src/effect-components/CommandMenuEffect.tsx
@@ -5,7 +5,7 @@ import { COMMAND_MENU_COMMANDS } from '@/command-menu/constants/CommandMenuComma
import { commandMenuCommandsState } from '@/command-menu/states/commandMenuCommandsState';
export const CommandMenuEffect = () => {
- const setCommands = useSetRecoilState(commandMenuCommandsState);
+ const setCommands = useSetRecoilState(commandMenuCommandsState());
const commands = COMMAND_MENU_COMMANDS;
useEffect(() => {
diff --git a/packages/twenty-front/src/effect-components/PageChangeEffect.tsx b/packages/twenty-front/src/effect-components/PageChangeEffect.tsx
index c5d8b32f307..4e0f299281b 100644
--- a/packages/twenty-front/src/effect-components/PageChangeEffect.tsx
+++ b/packages/twenty-front/src/effect-components/PageChangeEffect.tsx
@@ -45,7 +45,7 @@ export const PageChangeEffect = () => {
const openCreateActivity = useOpenCreateActivityDrawer();
- const isSignUpDisabled = useRecoilValue(isSignUpDisabledState);
+ const isSignUpDisabled = useRecoilValue(isSignUpDisabledState());
useEffect(() => {
if (!previousLocation || previousLocation !== location.pathname) {
diff --git a/packages/twenty-front/src/modules/activities/comment/__stories__/Comment.stories.tsx b/packages/twenty-front/src/modules/activities/comment/__stories__/Comment.stories.tsx
index 876d5a2517a..3c1b39bcbc7 100644
--- a/packages/twenty-front/src/modules/activities/comment/__stories__/Comment.stories.tsx
+++ b/packages/twenty-front/src/modules/activities/comment/__stories__/Comment.stories.tsx
@@ -11,7 +11,7 @@ import { Comment } from '../Comment';
import { mockComment, mockCommentWithLongValues } from './mock-comment';
const CommentSetterEffect = () => {
- const setViewableActivity = useSetRecoilState(viewableActivityIdState);
+ const setViewableActivity = useSetRecoilState(viewableActivityIdState());
useEffect(() => {
setViewableActivity('test-id');
diff --git a/packages/twenty-front/src/modules/activities/comment/__stories__/CommentHeader.stories.tsx b/packages/twenty-front/src/modules/activities/comment/__stories__/CommentHeader.stories.tsx
index d61ebc25b23..5206587ac08 100644
--- a/packages/twenty-front/src/modules/activities/comment/__stories__/CommentHeader.stories.tsx
+++ b/packages/twenty-front/src/modules/activities/comment/__stories__/CommentHeader.stories.tsx
@@ -13,7 +13,7 @@ import { CommentHeader } from '../CommentHeader';
import { mockComment, mockCommentWithLongValues } from './mock-comment';
const CommentHeaderSetterEffect = () => {
- const setViewableActivity = useSetRecoilState(viewableActivityIdState);
+ const setViewableActivity = useSetRecoilState(viewableActivityIdState());
useEffect(() => {
setViewableActivity('test-id');
diff --git a/packages/twenty-front/src/modules/activities/components/ActivityBodyEditor.tsx b/packages/twenty-front/src/modules/activities/components/ActivityBodyEditor.tsx
index 71ca1afb3a7..aec4a248d3a 100644
--- a/packages/twenty-front/src/modules/activities/components/ActivityBodyEditor.tsx
+++ b/packages/twenty-front/src/modules/activities/components/ActivityBodyEditor.tsx
@@ -118,7 +118,7 @@ export const ActivityBodyEditor = ({
);
const [canCreateActivity, setCanCreateActivity] = useRecoilState(
- canCreateActivityState,
+ canCreateActivityState(),
);
const slashMenuItems = getSlashMenu();
diff --git a/packages/twenty-front/src/modules/activities/components/ActivityComments.tsx b/packages/twenty-front/src/modules/activities/components/ActivityComments.tsx
index 16bdbed6961..8647c485e8c 100644
--- a/packages/twenty-front/src/modules/activities/components/ActivityComments.tsx
+++ b/packages/twenty-front/src/modules/activities/components/ActivityComments.tsx
@@ -61,7 +61,7 @@ export const ActivityComments = ({
objectNameSingular: CoreObjectNameSingular.Comment,
});
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
const { records: comments } = useFindManyRecords({
objectNameSingular: CoreObjectNameSingular.Comment,
diff --git a/packages/twenty-front/src/modules/activities/components/ActivityEditorEffect.tsx b/packages/twenty-front/src/modules/activities/components/ActivityEditorEffect.tsx
index 29c98e4ecd5..6c4c5406532 100644
--- a/packages/twenty-front/src/modules/activities/components/ActivityEditorEffect.tsx
+++ b/packages/twenty-front/src/modules/activities/components/ActivityEditorEffect.tsx
@@ -29,15 +29,15 @@ export const ActivityEditorEffect = ({
({ snapshot, set }) =>
() => {
const isUpsertingActivityInDB = snapshot
- .getLoadable(isUpsertingActivityInDBState)
+ .getLoadable(isUpsertingActivityInDBState())
.getValue();
const canCreateActivity = snapshot
- .getLoadable(canCreateActivityState)
+ .getLoadable(canCreateActivityState())
.getValue();
const isActivityInCreateMode = snapshot
- .getLoadable(isActivityInCreateModeState)
+ .getLoadable(isActivityInCreateModeState())
.getValue();
const activityFromStore = snapshot
@@ -71,7 +71,7 @@ export const ActivityEditorEffect = ({
deleteActivityFromCache(activity);
}
- set(isActivityInCreateModeState, false);
+ set(isActivityInCreateModeState(), false);
} else if (isNonNullable(activity)) {
if (
activity.title !== activityTitle ||
diff --git a/packages/twenty-front/src/modules/activities/components/ActivityTitle.tsx b/packages/twenty-front/src/modules/activities/components/ActivityTitle.tsx
index 4eb7b38033b..db321d469f5 100644
--- a/packages/twenty-front/src/modules/activities/components/ActivityTitle.tsx
+++ b/packages/twenty-front/src/modules/activities/components/ActivityTitle.tsx
@@ -71,7 +71,7 @@ export const ActivityTitle = ({ activityId }: ActivityTitleProps) => {
const activity = activityInStore as Activity;
const [canCreateActivity, setCanCreateActivity] = useRecoilState(
- canCreateActivityState,
+ canCreateActivityState(),
);
const { upsertActivity } = useUpsertActivity();
diff --git a/packages/twenty-front/src/modules/activities/emails/hooks/internal/useEmailThreadStates.ts b/packages/twenty-front/src/modules/activities/emails/hooks/internal/useEmailThreadStates.ts
index dc40a314dfb..946a43e0f83 100644
--- a/packages/twenty-front/src/modules/activities/emails/hooks/internal/useEmailThreadStates.ts
+++ b/packages/twenty-front/src/modules/activities/emails/hooks/internal/useEmailThreadStates.ts
@@ -1,7 +1,7 @@
-import { emailThreadsPageStateScopeMap } from '@/activities/emails/state/emailThreadsPageStateScopeMap';
+import { emailThreadsPageComponentState } from '@/activities/emails/state/emailThreadsPageComponentState';
import { TabListScopeInternalContext } from '@/ui/layout/tab/scopes/scope-internal-context/TabListScopeInternalContext';
import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';
-import { getState } from '@/ui/utilities/recoil-scope/utils/getState';
+import { extractComponentState } from '@/ui/utilities/state/component-state/utils/extractComponentState';
type useEmailThreadStatesProps = {
emailThreadScopeId?: string;
@@ -17,6 +17,9 @@ export const useEmailThreadStates = ({
return {
scopeId,
- getEmailThreadsPageState: getState(emailThreadsPageStateScopeMap, scopeId),
+ getEmailThreadsPageState: extractComponentState(
+ emailThreadsPageComponentState,
+ scopeId,
+ ),
};
};
diff --git a/packages/twenty-front/src/modules/activities/emails/hooks/useEmailThread.ts b/packages/twenty-front/src/modules/activities/emails/hooks/useEmailThread.ts
index a0e9bbc857c..bbc6d4c2815 100644
--- a/packages/twenty-front/src/modules/activities/emails/hooks/useEmailThread.ts
+++ b/packages/twenty-front/src/modules/activities/emails/hooks/useEmailThread.ts
@@ -1,11 +1,11 @@
-import { useRecoilState } from 'recoil';
+import { useSetRecoilState } from 'recoil';
import { useOpenEmailThreadRightDrawer } from '@/activities/emails/right-drawer/hooks/useOpenEmailThreadRightDrawer';
import { viewableEmailThreadIdState } from '@/activities/emails/state/viewableEmailThreadIdState';
export const useEmailThread = () => {
- const [, setViewableEmailThreadId] = useRecoilState(
- viewableEmailThreadIdState,
+ const setViewableEmailThreadId = useSetRecoilState(
+ viewableEmailThreadIdState(),
);
const openEmailThredRightDrawer = useOpenEmailThreadRightDrawer();
diff --git a/packages/twenty-front/src/modules/activities/emails/right-drawer/hooks/useRightDrawerEmailThread.ts b/packages/twenty-front/src/modules/activities/emails/right-drawer/hooks/useRightDrawerEmailThread.ts
index 1dbce6e0064..7415ba501f8 100644
--- a/packages/twenty-front/src/modules/activities/emails/right-drawer/hooks/useRightDrawerEmailThread.ts
+++ b/packages/twenty-front/src/modules/activities/emails/right-drawer/hooks/useRightDrawerEmailThread.ts
@@ -9,7 +9,7 @@ import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSi
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
export const useRightDrawerEmailThread = () => {
- const viewableEmailThreadId = useRecoilValue(viewableEmailThreadIdState);
+ const viewableEmailThreadId = useRecoilValue(viewableEmailThreadIdState());
const apolloClient = useApolloClient();
const thread = apolloClient.readFragment({
diff --git a/packages/twenty-front/src/modules/activities/emails/state/emailThreadsPageComponentState.ts b/packages/twenty-front/src/modules/activities/emails/state/emailThreadsPageComponentState.ts
new file mode 100644
index 00000000000..a1d52b61d5d
--- /dev/null
+++ b/packages/twenty-front/src/modules/activities/emails/state/emailThreadsPageComponentState.ts
@@ -0,0 +1,12 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export type EmailThreadsPageType = {
+ pageNumber: number;
+ hasNextPage: boolean;
+};
+
+export const emailThreadsPageComponentState =
+ createComponentState<EmailThreadsPageType>({
+ key: 'emailThreadsPageComponentState',
+ defaultValue: { pageNumber: 1, hasNextPage: true },
+ });
diff --git a/packages/twenty-front/src/modules/activities/emails/state/emailThreadsPageStateScopeMap.ts b/packages/twenty-front/src/modules/activities/emails/state/emailThreadsPageStateScopeMap.ts
deleted file mode 100644
index f7761acc793..00000000000
--- a/packages/twenty-front/src/modules/activities/emails/state/emailThreadsPageStateScopeMap.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export type EmailThreadsPageType = {
- pageNumber: number;
- hasNextPage: boolean;
-};
-
-export const emailThreadsPageStateScopeMap =
- createStateScopeMap<EmailThreadsPageType>({
- key: 'emailThreadsPageStateScopeMap',
- defaultValue: { pageNumber: 1, hasNextPage: true },
- });
diff --git a/packages/twenty-front/src/modules/activities/emails/state/viewableEmailThreadIdState.ts b/packages/twenty-front/src/modules/activities/emails/state/viewableEmailThreadIdState.ts
index 73b4a3b89a4..1785845e5ed 100644
--- a/packages/twenty-front/src/modules/activities/emails/state/viewableEmailThreadIdState.ts
+++ b/packages/twenty-front/src/modules/activities/emails/state/viewableEmailThreadIdState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const viewableEmailThreadIdState = atom<string | null>({
+export const viewableEmailThreadIdState = createState<string | null>({
key: 'viewableEmailThreadIdState',
- default: null,
+ defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/activities/files/hooks/useUploadAttachmentFile.tsx b/packages/twenty-front/src/modules/activities/files/hooks/useUploadAttachmentFile.tsx
index 1a0cceee7a5..bfc66abd484 100644
--- a/packages/twenty-front/src/modules/activities/files/hooks/useUploadAttachmentFile.tsx
+++ b/packages/twenty-front/src/modules/activities/files/hooks/useUploadAttachmentFile.tsx
@@ -10,7 +10,7 @@ import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord';
import { FileFolder, useUploadFileMutation } from '~/generated/graphql';
export const useUploadAttachmentFile = () => {
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
const [uploadFile] = useUploadFileMutation();
const { createOneRecord: createOneAttachment } =
diff --git a/packages/twenty-front/src/modules/activities/hooks/__tests__/useActivityConnectionUtils.test.tsx b/packages/twenty-front/src/modules/activities/hooks/__tests__/useActivityConnectionUtils.test.tsx
index a43b53fbaef..88da90b3a4c 100644
--- a/packages/twenty-front/src/modules/activities/hooks/__tests__/useActivityConnectionUtils.test.tsx
+++ b/packages/twenty-front/src/modules/activities/hooks/__tests__/useActivityConnectionUtils.test.tsx
@@ -58,7 +58,7 @@ describe('useActivityConnectionUtils', () => {
<RecoilRoot
initializeState={(snapshot) => {
snapshot.set(
- objectMetadataItemsState,
+ objectMetadataItemsState(),
getObjectMetadataItemsMock(),
);
}}
@@ -86,7 +86,7 @@ describe('useActivityConnectionUtils', () => {
<RecoilRoot
initializeState={(snapshot) => {
snapshot.set(
- objectMetadataItemsState,
+ objectMetadataItemsState(),
getObjectMetadataItemsMock(),
);
}}
diff --git a/packages/twenty-front/src/modules/activities/hooks/useActivityTargetObjectRecords.ts b/packages/twenty-front/src/modules/activities/hooks/useActivityTargetObjectRecords.ts
index 15e1fb1f9d5..00dacda4f03 100644
--- a/packages/twenty-front/src/modules/activities/hooks/useActivityTargetObjectRecords.ts
+++ b/packages/twenty-front/src/modules/activities/hooks/useActivityTargetObjectRecords.ts
@@ -14,7 +14,7 @@ export const useActivityTargetObjectRecords = ({
}: {
activityId: string;
}) => {
- const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
+ const objectMetadataItems = useRecoilValue(objectMetadataItemsState());
const { records: activityTargets, loading: loadingActivityTargets } =
useFindManyRecords<ActivityTarget>({
diff --git a/packages/twenty-front/src/modules/activities/hooks/useCreateActivityInCache.ts b/packages/twenty-front/src/modules/activities/hooks/useCreateActivityInCache.ts
index 5c1bd50d79b..5acbc05da01 100644
--- a/packages/twenty-front/src/modules/activities/hooks/useCreateActivityInCache.ts
+++ b/packages/twenty-front/src/modules/activities/hooks/useCreateActivityInCache.ts
@@ -27,7 +27,7 @@ export const useCreateActivityInCache = () => {
objectNameSingular: CoreObjectNameSingular.Activity,
});
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
const { record: currentWorkspaceMemberRecord } = useFindOneRecord({
objectNameSingular: CoreObjectNameSingular.WorkspaceMember,
diff --git a/packages/twenty-front/src/modules/activities/hooks/useOpenActivityRightDrawer.ts b/packages/twenty-front/src/modules/activities/hooks/useOpenActivityRightDrawer.ts
index 9bcc1ec21de..ae4d579a7c1 100644
--- a/packages/twenty-front/src/modules/activities/hooks/useOpenActivityRightDrawer.ts
+++ b/packages/twenty-front/src/modules/activities/hooks/useOpenActivityRightDrawer.ts
@@ -1,4 +1,4 @@
-import { useRecoilState } from 'recoil';
+import { useRecoilState, useSetRecoilState } from 'recoil';
import { activityIdInDrawerState } from '@/activities/states/activityIdInDrawerState';
import { useRightDrawer } from '@/ui/layout/right-drawer/hooks/useRightDrawer';
@@ -12,9 +12,9 @@ export const useOpenActivityRightDrawer = () => {
const { openRightDrawer, isRightDrawerOpen, rightDrawerPage } =
useRightDrawer();
const [viewableActivityId, setViewableActivityId] = useRecoilState(
- viewableActivityIdState,
+ viewableActivityIdState(),
);
- const [, setActivityIdInDrawer] = useRecoilState(activityIdInDrawerState);
+ const setActivityIdInDrawer = useSetRecoilState(activityIdInDrawerState());
const setHotkeyScope = useSetHotkeyScope();
return (activityId: string) => {
diff --git a/packages/twenty-front/src/modules/activities/hooks/useOpenCreateActivityDrawer.ts b/packages/twenty-front/src/modules/activities/hooks/useOpenCreateActivityDrawer.ts
index 6b7e83c447f..5b4c313fbb0 100644
--- a/packages/twenty-front/src/modules/activities/hooks/useOpenCreateActivityDrawer.ts
+++ b/packages/twenty-front/src/modules/activities/hooks/useOpenCreateActivityDrawer.ts
@@ -23,21 +23,23 @@ export const useOpenCreateActivityDrawer = () => {
const { createActivityInCache } = useCreateActivityInCache();
- const [, setActivityTargetableEntityArray] = useRecoilState(
- activityTargetableEntityArrayState,
+ const setActivityTargetableEntityArray = useSetRecoilState(
+ activityTargetableEntityArrayState(),
);
- const [, setViewableActivityId] = useRecoilState(viewableActivityIdState);
+ const setViewableActivityId = useSetRecoilState(viewableActivityIdState());
- const setIsCreatingActivity = useSetRecoilState(isActivityInCreateModeState);
+ const setIsCreatingActivity = useSetRecoilState(
+ isActivityInCreateModeState(),
+ );
const setTemporaryActivityForEditor = useSetRecoilState(
- temporaryActivityForEditorState,
+ temporaryActivityForEditorState(),
);
- const setActivityIdInDrawer = useSetRecoilState(activityIdInDrawerState);
+ const setActivityIdInDrawer = useSetRecoilState(activityIdInDrawerState());
const [, setIsUpsertingActivityInDB] = useRecoilState(
- isUpsertingActivityInDBState,
+ isUpsertingActivityInDBState(),
);
const openCreateActivityDrawer = async ({
diff --git a/packages/twenty-front/src/modules/activities/hooks/useUpsertActivity.ts b/packages/twenty-front/src/modules/activities/hooks/useUpsertActivity.ts
index 169586a63c0..776118678bc 100644
--- a/packages/twenty-front/src/modules/activities/hooks/useUpsertActivity.ts
+++ b/packages/twenty-front/src/modules/activities/hooks/useUpsertActivity.ts
@@ -21,7 +21,7 @@ import { isNonNullable } from '~/utils/isNonNullable';
// TODO: create a generic way to have records only in cache for create mode and delete them afterwards ?
export const useUpsertActivity = () => {
const [isActivityInCreateMode, setIsActivityInCreateMode] = useRecoilState(
- isActivityInCreateModeState,
+ isActivityInCreateModeState(),
);
const { updateOneRecord: updateOneActivity } = useUpdateOneRecord<Activity>({
@@ -31,10 +31,10 @@ export const useUpsertActivity = () => {
const { createActivityInDB } = useCreateActivityInDB();
const [, setIsUpsertingActivityInDB] = useRecoilState(
- isUpsertingActivityInDBState,
+ isUpsertingActivityInDBState(),
);
- const setActivityIdInDrawer = useSetRecoilState(activityIdInDrawerState);
+ const setActivityIdInDrawer = useSetRecoilState(activityIdInDrawerState());
const objectShowPageTargetableObject = useRecoilValue(
objectShowPageTargetableObjectState,
diff --git a/packages/twenty-front/src/modules/activities/inline-cell/components/ActivityTargetInlineCellEditMode.tsx b/packages/twenty-front/src/modules/activities/inline-cell/components/ActivityTargetInlineCellEditMode.tsx
index 3275f09233e..2c2c3a68edb 100644
--- a/packages/twenty-front/src/modules/activities/inline-cell/components/ActivityTargetInlineCellEditMode.tsx
+++ b/packages/twenty-front/src/modules/activities/inline-cell/components/ActivityTargetInlineCellEditMode.tsx
@@ -34,7 +34,9 @@ export const ActivityTargetInlineCellEditMode = ({
activity,
activityTargetWithTargetRecords,
}: ActivityTargetInlineCellEditModeProps) => {
- const [isActivityInCreateMode] = useRecoilState(isActivityInCreateModeState);
+ const [isActivityInCreateMode] = useRecoilState(
+ isActivityInCreateModeState(),
+ );
const selectedTargetObjectIds = activityTargetWithTargetRecords.map(
(activityTarget) => ({
diff --git a/packages/twenty-front/src/modules/activities/right-drawer/components/ActivityActionBar.tsx b/packages/twenty-front/src/modules/activities/right-drawer/components/ActivityActionBar.tsx
index a6653130a92..b52de3b4141 100644
--- a/packages/twenty-front/src/modules/activities/right-drawer/components/ActivityActionBar.tsx
+++ b/packages/twenty-front/src/modules/activities/right-drawer/components/ActivityActionBar.tsx
@@ -36,13 +36,13 @@ const StyledButtonContainer = styled.div`
`;
export const ActivityActionBar = () => {
- const viewableActivityId = useRecoilValue(viewableActivityIdState);
- const activityIdInDrawer = useRecoilValue(activityIdInDrawerState);
+ const viewableActivityId = useRecoilValue(viewableActivityIdState());
+ const activityIdInDrawer = useRecoilValue(activityIdInDrawerState());
const activityTargetableEntityArray = useRecoilValue(
- activityTargetableEntityArrayState,
+ activityTargetableEntityArrayState(),
);
- const [, setIsRightDrawerOpen] = useRecoilState(isRightDrawerOpenState);
+ const [, setIsRightDrawerOpen] = useRecoilState(isRightDrawerOpenState());
const { deleteOneRecord: deleteOneActivity } = useDeleteOneRecord({
objectNameSingular: CoreObjectNameSingular.Activity,
});
@@ -54,13 +54,15 @@ export const ActivityActionBar = () => {
);
const [temporaryActivityForEditor, setTemporaryActivityForEditor] =
- useRecoilState(temporaryActivityForEditorState);
+ useRecoilState(temporaryActivityForEditorState());
const { deleteActivityFromCache } = useDeleteActivityFromCache();
- const [isActivityInCreateMode] = useRecoilState(isActivityInCreateModeState);
+ const [isActivityInCreateMode] = useRecoilState(
+ isActivityInCreateModeState(),
+ );
const [isUpsertingActivityInDB] = useRecoilState(
- isUpsertingActivityInDBState,
+ isUpsertingActivityInDBState(),
);
const objectShowPageTargetableObject = useRecoilValue(
diff --git a/packages/twenty-front/src/modules/activities/right-drawer/components/create/RightDrawerCreateActivity.tsx b/packages/twenty-front/src/modules/activities/right-drawer/components/create/RightDrawerCreateActivity.tsx
index fe6ac8ecaf4..4ec49de22ac 100644
--- a/packages/twenty-front/src/modules/activities/right-drawer/components/create/RightDrawerCreateActivity.tsx
+++ b/packages/twenty-front/src/modules/activities/right-drawer/components/create/RightDrawerCreateActivity.tsx
@@ -5,7 +5,7 @@ import { viewableActivityIdState } from '@/activities/states/viewableActivityIdS
import { RightDrawerActivity } from '../RightDrawerActivity';
export const RightDrawerCreateActivity = () => {
- const viewableActivityId = useRecoilValue(viewableActivityIdState);
+ const viewableActivityId = useRecoilValue(viewableActivityIdState());
return (
<>
diff --git a/packages/twenty-front/src/modules/activities/right-drawer/components/edit/RightDrawerEditActivity.tsx b/packages/twenty-front/src/modules/activities/right-drawer/components/edit/RightDrawerEditActivity.tsx
index 288d7aca88a..971d34b81bb 100644
--- a/packages/twenty-front/src/modules/activities/right-drawer/components/edit/RightDrawerEditActivity.tsx
+++ b/packages/twenty-front/src/modules/activities/right-drawer/components/edit/RightDrawerEditActivity.tsx
@@ -5,7 +5,7 @@ import { viewableActivityIdState } from '@/activities/states/viewableActivityIdS
import { RightDrawerActivity } from '../RightDrawerActivity';
export const RightDrawerEditActivity = () => {
- const viewableActivityId = useRecoilValue(viewableActivityIdState);
+ const viewableActivityId = useRecoilValue(viewableActivityIdState());
return (
<>
diff --git a/packages/twenty-front/src/modules/activities/states/activityBodyFamilyState.ts b/packages/twenty-front/src/modules/activities/states/activityBodyFamilyState.ts
index 452dc022018..b9d5579573a 100644
--- a/packages/twenty-front/src/modules/activities/states/activityBodyFamilyState.ts
+++ b/packages/twenty-front/src/modules/activities/states/activityBodyFamilyState.ts
@@ -1,9 +1,9 @@
-import { atomFamily } from 'recoil';
+import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
-export const activityBodyFamilyState = atomFamily<
+export const activityBodyFamilyState = createFamilyState<
string,
{ activityId: string }
>({
key: 'activityBodyFamilyState',
- default: '',
+ defaultValue: '',
});
diff --git a/packages/twenty-front/src/modules/activities/states/activityIdInDrawerState.ts b/packages/twenty-front/src/modules/activities/states/activityIdInDrawerState.ts
index 7bc9362fc22..b275db31286 100644
--- a/packages/twenty-front/src/modules/activities/states/activityIdInDrawerState.ts
+++ b/packages/twenty-front/src/modules/activities/states/activityIdInDrawerState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const activityIdInDrawerState = atom<string | null>({
+export const activityIdInDrawerState = createState<string | null>({
key: 'activityIdInDrawerState',
- default: null,
+ defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/activities/states/activityTargetableEntityArrayState.ts b/packages/twenty-front/src/modules/activities/states/activityTargetableEntityArrayState.ts
index c3a06d48f82..dc1695f1060 100644
--- a/packages/twenty-front/src/modules/activities/states/activityTargetableEntityArrayState.ts
+++ b/packages/twenty-front/src/modules/activities/states/activityTargetableEntityArrayState.ts
@@ -1,10 +1,10 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
import { ActivityTargetableObject } from '../types/ActivityTargetableEntity';
-export const activityTargetableEntityArrayState = atom<
+export const activityTargetableEntityArrayState = createState<
ActivityTargetableObject[]
>({
key: 'activities/targetable-entity-array',
- default: [],
+ defaultValue: [],
});
diff --git a/packages/twenty-front/src/modules/activities/states/activityTitleFamilyState.ts b/packages/twenty-front/src/modules/activities/states/activityTitleFamilyState.ts
index 6196bae01d0..5a02e57fcb7 100644
--- a/packages/twenty-front/src/modules/activities/states/activityTitleFamilyState.ts
+++ b/packages/twenty-front/src/modules/activities/states/activityTitleFamilyState.ts
@@ -1,9 +1,9 @@
-import { atomFamily } from 'recoil';
+import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
-export const activityTitleFamilyState = atomFamily<
+export const activityTitleFamilyState = createFamilyState<
string,
{ activityId: string }
>({
key: 'activityTitleFamilyState',
- default: '',
+ defaultValue: '',
});
diff --git a/packages/twenty-front/src/modules/activities/states/activityTitleHasBeenSetFamilyState.ts b/packages/twenty-front/src/modules/activities/states/activityTitleHasBeenSetFamilyState.ts
index 096df500dd5..f47e13f84c4 100644
--- a/packages/twenty-front/src/modules/activities/states/activityTitleHasBeenSetFamilyState.ts
+++ b/packages/twenty-front/src/modules/activities/states/activityTitleHasBeenSetFamilyState.ts
@@ -1,9 +1,9 @@
-import { atomFamily } from 'recoil';
+import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
-export const activityTitleHasBeenSetFamilyState = atomFamily<
+export const activityTitleHasBeenSetFamilyState = createFamilyState<
boolean,
{ activityId: string }
>({
key: 'activityTitleHasBeenSetFamilyState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/activities/states/canCreateActivityState.ts b/packages/twenty-front/src/modules/activities/states/canCreateActivityState.ts
index 6d10623714a..287786f101f 100644
--- a/packages/twenty-front/src/modules/activities/states/canCreateActivityState.ts
+++ b/packages/twenty-front/src/modules/activities/states/canCreateActivityState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const canCreateActivityState = atom<boolean>({
+export const canCreateActivityState = createState<boolean>({
key: 'canCreateActivityState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/activities/states/isActivityInCreateModeState.ts b/packages/twenty-front/src/modules/activities/states/isActivityInCreateModeState.ts
index d0f32a48374..819670812ec 100644
--- a/packages/twenty-front/src/modules/activities/states/isActivityInCreateModeState.ts
+++ b/packages/twenty-front/src/modules/activities/states/isActivityInCreateModeState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const isActivityInCreateModeState = atom<boolean>({
+export const isActivityInCreateModeState = createState<boolean>({
key: 'isActivityInCreateModeState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/activities/states/isCreatingActivityInDBState.ts b/packages/twenty-front/src/modules/activities/states/isCreatingActivityInDBState.ts
index 315b623bb24..c1a560b824b 100644
--- a/packages/twenty-front/src/modules/activities/states/isCreatingActivityInDBState.ts
+++ b/packages/twenty-front/src/modules/activities/states/isCreatingActivityInDBState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const isUpsertingActivityInDBState = atom<boolean>({
+export const isUpsertingActivityInDBState = createState<boolean>({
key: 'isUpsertingActivityInDBState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/activities/states/targetableObjectsInDrawerState.ts b/packages/twenty-front/src/modules/activities/states/targetableObjectsInDrawerState.ts
index 553c7511088..e50a70c48bd 100644
--- a/packages/twenty-front/src/modules/activities/states/targetableObjectsInDrawerState.ts
+++ b/packages/twenty-front/src/modules/activities/states/targetableObjectsInDrawerState.ts
@@ -1,8 +1,9 @@
-import { atom } from 'recoil';
-
import { ActivityTargetableObject } from '@/activities/types/ActivityTargetableEntity';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const targetableObjectsInDrawerState = atom<ActivityTargetableObject[]>({
+export const targetableObjectsInDrawerState = createState<
+ ActivityTargetableObject[]
+>({
key: 'targetableObjectsInDrawerState',
- default: [],
+ defaultValue: [],
});
diff --git a/packages/twenty-front/src/modules/activities/states/temporaryActivityForEditorState.ts b/packages/twenty-front/src/modules/activities/states/temporaryActivityForEditorState.ts
index 5b657a36988..b1f64681f13 100644
--- a/packages/twenty-front/src/modules/activities/states/temporaryActivityForEditorState.ts
+++ b/packages/twenty-front/src/modules/activities/states/temporaryActivityForEditorState.ts
@@ -1,8 +1,8 @@
-import { atom } from 'recoil';
-
import { ActivityForEditor } from '@/activities/types/ActivityForEditor';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const temporaryActivityForEditorState = atom<ActivityForEditor | null>({
- key: 'temporaryActivityForEditorState',
- default: null,
-});
+export const temporaryActivityForEditorState =
+ createState<ActivityForEditor | null>({
+ key: 'temporaryActivityForEditorState',
+ defaultValue: null,
+ });
diff --git a/packages/twenty-front/src/modules/activities/states/viewableActivityIdState.ts b/packages/twenty-front/src/modules/activities/states/viewableActivityIdState.ts
index 95cfc1712bf..85aab18a1aa 100644
--- a/packages/twenty-front/src/modules/activities/states/viewableActivityIdState.ts
+++ b/packages/twenty-front/src/modules/activities/states/viewableActivityIdState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const viewableActivityIdState = atom<string | null>({
+export const viewableActivityIdState = createState<string | null>({
key: 'activities/viewable-activity-id',
- default: null,
+ defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/activities/tasks/components/CurrentUserDueTaskCountEffect.tsx b/packages/twenty-front/src/modules/activities/tasks/components/CurrentUserDueTaskCountEffect.tsx
index f725249b40a..802777746c5 100644
--- a/packages/twenty-front/src/modules/activities/tasks/components/CurrentUserDueTaskCountEffect.tsx
+++ b/packages/twenty-front/src/modules/activities/tasks/components/CurrentUserDueTaskCountEffect.tsx
@@ -9,10 +9,10 @@ import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
import { parseDate } from '~/utils/date-utils';
export const CurrentUserDueTaskCountEffect = () => {
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
const [currentUserDueTaskCount, setCurrentUserDueTaskCount] = useRecoilState(
- currentUserDueTaskCountState,
+ currentUserDueTaskCountState(),
);
const { records: tasks } = useFindManyRecords({
diff --git a/packages/twenty-front/src/modules/activities/tasks/hooks/useCurrentUserDueTaskCount.ts b/packages/twenty-front/src/modules/activities/tasks/hooks/useCurrentUserDueTaskCount.ts
index 836ed21bad8..8ef7e168f92 100644
--- a/packages/twenty-front/src/modules/activities/tasks/hooks/useCurrentUserDueTaskCount.ts
+++ b/packages/twenty-front/src/modules/activities/tasks/hooks/useCurrentUserDueTaskCount.ts
@@ -7,7 +7,7 @@ import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
import { parseDate } from '~/utils/date-utils';
export const useCurrentUserTaskCount = () => {
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
const { records: tasks } = useFindManyRecords({
objectNameSingular: CoreObjectNameSingular.Activity,
diff --git a/packages/twenty-front/src/modules/activities/tasks/states/currentUserTaskCountState.ts b/packages/twenty-front/src/modules/activities/tasks/states/currentUserTaskCountState.ts
index 4c7653ddfe6..f823e49a7d3 100644
--- a/packages/twenty-front/src/modules/activities/tasks/states/currentUserTaskCountState.ts
+++ b/packages/twenty-front/src/modules/activities/tasks/states/currentUserTaskCountState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const currentUserDueTaskCountState = atom<number>({
- default: 0,
+export const currentUserDueTaskCountState = createState<number>({
+ defaultValue: 0,
key: 'currentUserDueTaskCountState',
});
diff --git a/packages/twenty-front/src/modules/activities/timeline/components/Timeline.tsx b/packages/twenty-front/src/modules/activities/timeline/components/Timeline.tsx
index 37cc77560ed..96621b34a45 100644
--- a/packages/twenty-front/src/modules/activities/timeline/components/Timeline.tsx
+++ b/packages/twenty-front/src/modules/activities/timeline/components/Timeline.tsx
@@ -33,7 +33,7 @@ export const Timeline = ({
targetableObject: ActivityTargetableObject;
}) => {
const { initialized, noActivities } = useRecoilValue(
- timelineActivitiesNetworkingState,
+ timelineActivitiesNetworkingState(),
);
const showEmptyState = noActivities;
diff --git a/packages/twenty-front/src/modules/activities/timeline/components/TimelineItemsContainer.tsx b/packages/twenty-front/src/modules/activities/timeline/components/TimelineItemsContainer.tsx
index f509a4781aa..59a5a925e52 100644
--- a/packages/twenty-front/src/modules/activities/timeline/components/TimelineItemsContainer.tsx
+++ b/packages/twenty-front/src/modules/activities/timeline/components/TimelineItemsContainer.tsx
@@ -26,7 +26,7 @@ const StyledScrollWrapper = styled(ScrollWrapper)``;
export const TimelineItemsContainer = () => {
const timelineActivitiesForGroup = useRecoilValue(
- timelineActivitiesForGroupState,
+ timelineActivitiesForGroupState(),
);
const groupedActivities = groupActivitiesByMonth(timelineActivitiesForGroup);
diff --git a/packages/twenty-front/src/modules/activities/timeline/components/TimelineQueryEffect.tsx b/packages/twenty-front/src/modules/activities/timeline/components/TimelineQueryEffect.tsx
index 2f548e80a4c..5159d5d3648 100644
--- a/packages/twenty-front/src/modules/activities/timeline/components/TimelineQueryEffect.tsx
+++ b/packages/twenty-front/src/modules/activities/timeline/components/TimelineQueryEffect.tsx
@@ -35,10 +35,10 @@ export const TimelineQueryEffect = ({
});
const [timelineActivitiesNetworking, setTimelineActivitiesNetworking] =
- useRecoilState(timelineActivitiesNetworkingState);
+ useRecoilState(timelineActivitiesNetworkingState());
const [timelineActivitiesForGroup, setTimelineActivitiesForGroup] =
- useRecoilState(timelineActivitiesForGroupState);
+ useRecoilState(timelineActivitiesForGroupState());
useEffect(() => {
if (!isNonNullable(targetableObject)) {
diff --git a/packages/twenty-front/src/modules/activities/timeline/states/timelineActivitiesFamilyState.ts b/packages/twenty-front/src/modules/activities/timeline/states/timelineActivitiesFamilyState.ts
index de045ed0396..f2acc7a3312 100644
--- a/packages/twenty-front/src/modules/activities/timeline/states/timelineActivitiesFamilyState.ts
+++ b/packages/twenty-front/src/modules/activities/timeline/states/timelineActivitiesFamilyState.ts
@@ -1,11 +1,10 @@
-import { atomFamily } from 'recoil';
-
import { Activity } from '@/activities/types/Activity';
+import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
-export const timelineActivitiesFammilyState = atomFamily<
+export const timelineActivitiesFammilyState = createFamilyState<
Activity | null,
string
>({
key: 'timelineActivitiesFammilyState',
- default: null,
+ defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/activities/timeline/states/timelineActivitiesForGroupState.ts b/packages/twenty-front/src/modules/activities/timeline/states/timelineActivitiesForGroupState.ts
index ddbea64f213..f976d78fd57 100644
--- a/packages/twenty-front/src/modules/activities/timeline/states/timelineActivitiesForGroupState.ts
+++ b/packages/twenty-front/src/modules/activities/timeline/states/timelineActivitiesForGroupState.ts
@@ -1,10 +1,9 @@
-import { atom } from 'recoil';
-
import { ActivityForActivityGroup } from '@/activities/timeline/utils/groupActivitiesByMonth';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const timelineActivitiesForGroupState = atom<ActivityForActivityGroup[]>(
- {
- key: 'timelineActivitiesForGroupState',
- default: [],
- },
-);
+export const timelineActivitiesForGroupState = createState<
+ ActivityForActivityGroup[]
+>({
+ key: 'timelineActivitiesForGroupState',
+ defaultValue: [],
+});
diff --git a/packages/twenty-front/src/modules/activities/timeline/states/timelineActivitiesNetworkingState.ts b/packages/twenty-front/src/modules/activities/timeline/states/timelineActivitiesNetworkingState.ts
index e3ca7a83768..b652b0defb0 100644
--- a/packages/twenty-front/src/modules/activities/timeline/states/timelineActivitiesNetworkingState.ts
+++ b/packages/twenty-front/src/modules/activities/timeline/states/timelineActivitiesNetworkingState.ts
@@ -1,11 +1,11 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const timelineActivitiesNetworkingState = atom<{
+export const timelineActivitiesNetworkingState = createState<{
initialized: boolean;
noActivities: boolean;
}>({
key: 'timelineActivitiesNetworkingState',
- default: {
+ defaultValue: {
initialized: false,
noActivities: false,
},
diff --git a/packages/twenty-front/src/modules/activities/timeline/states/timelineActivityFirstLevelFamilySelector.ts b/packages/twenty-front/src/modules/activities/timeline/states/timelineActivityFirstLevelFamilySelector.ts
index 767bb5e8f2b..ece59dab240 100644
--- a/packages/twenty-front/src/modules/activities/timeline/states/timelineActivityFirstLevelFamilySelector.ts
+++ b/packages/twenty-front/src/modules/activities/timeline/states/timelineActivityFirstLevelFamilySelector.ts
@@ -1,11 +1,10 @@
-import { atomFamily } from 'recoil';
-
import { Activity } from '@/activities/types/Activity';
+import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
-export const timelineActivityWithoutTargetsFamilyState = atomFamily<
+export const timelineActivityWithoutTargetsFamilyState = createFamilyState<
Pick<Activity, 'id' | 'title' | 'createdAt' | 'author' | 'type'> | null,
string
>({
key: 'timelineActivityFirstLevelFamilySelector',
- default: null,
+ defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/analytics/hooks/useEventTracker.ts b/packages/twenty-front/src/modules/analytics/hooks/useEventTracker.ts
index 6cb0fcf4d10..75f80b4ba7c 100644
--- a/packages/twenty-front/src/modules/analytics/hooks/useEventTracker.ts
+++ b/packages/twenty-front/src/modules/analytics/hooks/useEventTracker.ts
@@ -1,5 +1,5 @@
import { useCallback } from 'react';
-import { useRecoilState } from 'recoil';
+import { useRecoilValue } from 'recoil';
import { telemetryState } from '@/client-config/states/telemetryState';
import { useCreateEventMutation } from '~/generated/graphql';
@@ -13,7 +13,7 @@ export interface EventData {
}
export const useEventTracker = () => {
- const [telemetry] = useRecoilState(telemetryState);
+ const telemetry = useRecoilValue(telemetryState());
const [createEventMutation] = useCreateEventMutation();
return useCallback(
diff --git a/packages/twenty-front/src/modules/apollo/hooks/useApolloFactory.ts b/packages/twenty-front/src/modules/apollo/hooks/useApolloFactory.ts
index 8c112965574..725deb4267a 100644
--- a/packages/twenty-front/src/modules/apollo/hooks/useApolloFactory.ts
+++ b/packages/twenty-front/src/modules/apollo/hooks/useApolloFactory.ts
@@ -16,11 +16,11 @@ import { ApolloFactory } from '../services/apollo.factory';
export const useApolloFactory = () => {
// eslint-disable-next-line @nx/workspace-no-state-useref
const apolloRef = useRef<ApolloFactory<NormalizedCacheObject> | null>(null);
- const [isDebugMode] = useRecoilState(isDebugModeState);
+ const [isDebugMode] = useRecoilState(isDebugModeState());
const navigate = useNavigate();
const isMatchingLocation = useIsMatchingLocation();
- const [tokenPair, setTokenPair] = useRecoilState(tokenPairState);
+ const [tokenPair, setTokenPair] = useRecoilState(tokenPairState());
const apolloClient = useMemo(() => {
apolloRef.current = new ApolloFactory({
diff --git a/packages/twenty-front/src/modules/auth/hooks/__test__/useAuth.test.tsx b/packages/twenty-front/src/modules/auth/hooks/__test__/useAuth.test.tsx
index 25bfda7511b..230075cdb5a 100644
--- a/packages/twenty-front/src/modules/auth/hooks/__test__/useAuth.test.tsx
+++ b/packages/twenty-front/src/modules/auth/hooks/__test__/useAuth.test.tsx
@@ -76,13 +76,13 @@ describe('useAuth', () => {
const { result } = renderHook(
() => {
const client = useApolloClient();
- const icons = useRecoilValue(iconsState);
- const authProviders = useRecoilValue(authProvidersState);
- const billing = useRecoilValue(billingState);
- const isSignInPrefilled = useRecoilValue(isSignInPrefilledState);
- const supportChat = useRecoilValue(supportChatState);
- const telemetry = useRecoilValue(telemetryState);
- const isDebugMode = useRecoilValue(isDebugModeState);
+ const icons = useRecoilValue(iconsState());
+ const authProviders = useRecoilValue(authProvidersState());
+ const billing = useRecoilValue(billingState());
+ const isSignInPrefilled = useRecoilValue(isSignInPrefilledState());
+ const supportChat = useRecoilValue(supportChatState());
+ const telemetry = useRecoilValue(telemetryState());
+ const isDebugMode = useRecoilValue(isDebugModeState());
return {
...useAuth(),
client,
diff --git a/packages/twenty-front/src/modules/auth/hooks/__test__/useIsLogged.test.ts b/packages/twenty-front/src/modules/auth/hooks/__test__/useIsLogged.test.ts
index 2674f26d9c9..a441c479708 100644
--- a/packages/twenty-front/src/modules/auth/hooks/__test__/useIsLogged.test.ts
+++ b/packages/twenty-front/src/modules/auth/hooks/__test__/useIsLogged.test.ts
@@ -9,7 +9,7 @@ const renderHooks = () => {
const { result } = renderHook(
() => {
const isLogged = useIsLogged();
- const setTokenPair = useSetRecoilState(tokenPairState);
+ const setTokenPair = useSetRecoilState(tokenPairState());
return {
isLogged,
diff --git a/packages/twenty-front/src/modules/auth/hooks/__test__/useOnboardingStatus.test.ts b/packages/twenty-front/src/modules/auth/hooks/__test__/useOnboardingStatus.test.ts
index 0758ed0d719..51387e2c991 100644
--- a/packages/twenty-front/src/modules/auth/hooks/__test__/useOnboardingStatus.test.ts
+++ b/packages/twenty-front/src/modules/auth/hooks/__test__/useOnboardingStatus.test.ts
@@ -35,13 +35,13 @@ const renderHooks = () => {
const { result } = renderHook(
() => {
const onboardingStatus = useOnboardingStatus();
- const setBilling = useSetRecoilState(billingState);
- const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState);
+ const setBilling = useSetRecoilState(billingState());
+ const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState());
const setCurrentWorkspaceMember = useSetRecoilState(
- currentWorkspaceMemberState,
+ currentWorkspaceMemberState(),
);
- const setTokenPair = useSetRecoilState(tokenPairState);
- const setVerifyPending = useSetRecoilState(isVerifyPendingState);
+ const setTokenPair = useSetRecoilState(tokenPairState());
+ const setVerifyPending = useSetRecoilState(isVerifyPendingState());
return {
onboardingStatus,
diff --git a/packages/twenty-front/src/modules/auth/hooks/useAuth.ts b/packages/twenty-front/src/modules/auth/hooks/useAuth.ts
index 85c11d26790..dc0d2458f0d 100644
--- a/packages/twenty-front/src/modules/auth/hooks/useAuth.ts
+++ b/packages/twenty-front/src/modules/auth/hooks/useAuth.ts
@@ -32,14 +32,14 @@ import { currentUserState } from '../states/currentUserState';
import { tokenPairState } from '../states/tokenPairState';
export const useAuth = () => {
- const [, setTokenPair] = useRecoilState(tokenPairState);
- const setCurrentUser = useSetRecoilState(currentUserState);
+ const [, setTokenPair] = useRecoilState(tokenPairState());
+ const setCurrentUser = useSetRecoilState(currentUserState());
const setCurrentWorkspaceMember = useSetRecoilState(
- currentWorkspaceMemberState,
+ currentWorkspaceMemberState(),
);
- const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState);
- const setIsVerifyPendingState = useSetRecoilState(isVerifyPendingState);
+ const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState());
+ const setIsVerifyPendingState = useSetRecoilState(isVerifyPendingState());
const [challenge] = useChallengeMutation();
const [signUp] = useSignUpMutation();
@@ -141,26 +141,26 @@ export const useAuth = () => {
({ snapshot }) =>
async () => {
const emptySnapshot = snapshot_UNSTABLE();
- const iconsValue = snapshot.getLoadable(iconsState).getValue();
+ const iconsValue = snapshot.getLoadable(iconsState()).getValue();
const authProvidersValue = snapshot
- .getLoadable(authProvidersState)
+ .getLoadable(authProvidersState())
.getValue();
- const billing = snapshot.getLoadable(billingState).getValue();
+ const billing = snapshot.getLoadable(billingState()).getValue();
const isSignInPrefilled = snapshot
- .getLoadable(isSignInPrefilledState)
+ .getLoadable(isSignInPrefilledState())
.getValue();
- const supportChat = snapshot.getLoadable(supportChatState).getValue();
- const telemetry = snapshot.getLoadable(telemetryState).getValue();
- const isDebugMode = snapshot.getLoadable(isDebugModeState).getValue();
+ const supportChat = snapshot.getLoadable(supportChatState()).getValue();
+ const telemetry = snapshot.getLoadable(telemetryState()).getValue();
+ const isDebugMode = snapshot.getLoadable(isDebugModeState()).getValue();
const initialSnapshot = emptySnapshot.map(({ set }) => {
- set(iconsState, iconsValue);
- set(authProvidersState, authProvidersValue);
- set(billingState, billing);
- set(isSignInPrefilledState, isSignInPrefilled);
- set(supportChatState, supportChat);
- set(telemetryState, telemetry);
- set(isDebugModeState, isDebugMode);
+ set(iconsState(), iconsValue);
+ set(authProvidersState(), authProvidersValue);
+ set(billingState(), billing);
+ set(isSignInPrefilledState(), isSignInPrefilled);
+ set(supportChatState(), supportChat);
+ set(telemetryState(), telemetry);
+ set(isDebugModeState(), isDebugMode);
return undefined;
});
diff --git a/packages/twenty-front/src/modules/auth/hooks/useIsLogged.ts b/packages/twenty-front/src/modules/auth/hooks/useIsLogged.ts
index 4399b564c06..1c235a747e9 100644
--- a/packages/twenty-front/src/modules/auth/hooks/useIsLogged.ts
+++ b/packages/twenty-front/src/modules/auth/hooks/useIsLogged.ts
@@ -5,8 +5,8 @@ import { isVerifyPendingState } from '@/auth/states/isVerifyPendingState';
import { tokenPairState } from '../states/tokenPairState';
export const useIsLogged = (): boolean => {
- const [tokenPair] = useRecoilState(tokenPairState);
- const isVerifyPending = useRecoilValue(isVerifyPendingState);
+ const [tokenPair] = useRecoilState(tokenPairState());
+ const isVerifyPending = useRecoilValue(isVerifyPendingState());
return !!tokenPair && !isVerifyPending;
};
diff --git a/packages/twenty-front/src/modules/auth/hooks/useOnboardingStatus.ts b/packages/twenty-front/src/modules/auth/hooks/useOnboardingStatus.ts
index 91a8a60e84e..bd8ed6b0dfe 100644
--- a/packages/twenty-front/src/modules/auth/hooks/useOnboardingStatus.ts
+++ b/packages/twenty-front/src/modules/auth/hooks/useOnboardingStatus.ts
@@ -11,9 +11,9 @@ import {
} from '../utils/getOnboardingStatus';
export const useOnboardingStatus = (): OnboardingStatus | undefined => {
- const billing = useRecoilValue(billingState);
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
- const currentWorkspace = useRecoilValue(currentWorkspaceState);
+ const billing = useRecoilValue(billingState());
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
+ const currentWorkspace = useRecoilValue(currentWorkspaceState());
const isLoggedIn = useIsLogged();
return getOnboardingStatus({
diff --git a/packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpForm.tsx b/packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpForm.tsx
index bc1997f2d48..b028ba01ad2 100644
--- a/packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpForm.tsx
+++ b/packages/twenty-front/src/modules/auth/sign-in-up/components/SignInUpForm.tsx
@@ -46,7 +46,7 @@ const StyledInputContainer = styled.div`
`;
export const SignInUpForm = () => {
- const [authProviders] = useRecoilState(authProvidersState);
+ const [authProviders] = useRecoilState(authProvidersState());
const [showErrors, setShowErrors] = useState(false);
const { handleResetPassword } = useHandleResetPassword();
const workspace = useWorkspaceFromInviteHash();
diff --git a/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useNavigateAfterSignInUp.ts b/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useNavigateAfterSignInUp.ts
index ee090c12708..e659696c4ce 100644
--- a/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useNavigateAfterSignInUp.ts
+++ b/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useNavigateAfterSignInUp.ts
@@ -9,7 +9,7 @@ import { WorkspaceMember } from '~/generated/graphql.tsx';
export const useNavigateAfterSignInUp = () => {
const navigate = useNavigate();
- const billing = useRecoilValue(billingState);
+ const billing = useRecoilValue(billingState());
const navigateAfterSignInUp = useCallback(
(
currentWorkspace: CurrentWorkspace,
diff --git a/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useSignInUpForm.ts b/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useSignInUpForm.ts
index 591abf368fb..6677754d26a 100644
--- a/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useSignInUpForm.ts
+++ b/packages/twenty-front/src/modules/auth/sign-in-up/hooks/useSignInUpForm.ts
@@ -19,7 +19,7 @@ const validationSchema = z
export type Form = z.infer<typeof validationSchema>;
export const useSignInUpForm = () => {
- const isSignInPrefilled = useRecoilValue(isSignInPrefilledState);
+ const isSignInPrefilled = useRecoilValue(isSignInPrefilledState());
const form = useForm<Form>({
mode: 'onChange',
defaultValues: {
diff --git a/packages/twenty-front/src/modules/auth/states/currentUserState.ts b/packages/twenty-front/src/modules/auth/states/currentUserState.ts
index db3ed7b67de..49339e189a7 100644
--- a/packages/twenty-front/src/modules/auth/states/currentUserState.ts
+++ b/packages/twenty-front/src/modules/auth/states/currentUserState.ts
@@ -1,5 +1,4 @@
-import { atom } from 'recoil';
-
+import { createState } from '@/ui/utilities/state/utils/createState';
import { User } from '~/generated/graphql';
export type CurrentUser = Pick<
@@ -7,7 +6,7 @@ export type CurrentUser = Pick<
'id' | 'email' | 'supportUserHash' | 'canImpersonate'
>;
-export const currentUserState = atom<CurrentUser | null>({
+export const currentUserState = createState<CurrentUser | null>({
key: 'currentUserState',
- default: null,
+ defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/auth/states/currentWorkspaceMemberState.ts b/packages/twenty-front/src/modules/auth/states/currentWorkspaceMemberState.ts
index 938e304a6f0..a6fbe62b03c 100644
--- a/packages/twenty-front/src/modules/auth/states/currentWorkspaceMemberState.ts
+++ b/packages/twenty-front/src/modules/auth/states/currentWorkspaceMemberState.ts
@@ -1,11 +1,10 @@
-import { atom } from 'recoil';
-
+import { createState } from '@/ui/utilities/state/utils/createState';
import { WorkspaceMember } from '@/workspace-member/types/WorkspaceMember';
-export const currentWorkspaceMemberState = atom<Omit<
+export const currentWorkspaceMemberState = createState<Omit<
WorkspaceMember,
'createdAt' | 'updatedAt' | 'userId' | 'userEmail'
> | null>({
key: 'currentWorkspaceMemberState',
- default: null,
+ defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/auth/states/currentWorkspaceState.ts b/packages/twenty-front/src/modules/auth/states/currentWorkspaceState.ts
index 594d16e1bb5..5f9032e9d4c 100644
--- a/packages/twenty-front/src/modules/auth/states/currentWorkspaceState.ts
+++ b/packages/twenty-front/src/modules/auth/states/currentWorkspaceState.ts
@@ -1,5 +1,4 @@
-import { atom } from 'recoil';
-
+import { createState } from '@/ui/utilities/state/utils/createState';
import { Workspace } from '~/generated/graphql';
export type CurrentWorkspace = Pick<
@@ -14,7 +13,7 @@ export type CurrentWorkspace = Pick<
| 'activationStatus'
>;
-export const currentWorkspaceState = atom<CurrentWorkspace | null>({
+export const currentWorkspaceState = createState<CurrentWorkspace | null>({
key: 'currentWorkspaceState',
- default: null,
+ defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/auth/states/isVerifyPendingState.ts b/packages/twenty-front/src/modules/auth/states/isVerifyPendingState.ts
index 6986efab0d9..1f976ebcda7 100644
--- a/packages/twenty-front/src/modules/auth/states/isVerifyPendingState.ts
+++ b/packages/twenty-front/src/modules/auth/states/isVerifyPendingState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const isVerifyPendingState = atom<boolean>({
+export const isVerifyPendingState = createState<boolean>({
key: 'isVerifyPendingState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/auth/states/tokenPairState.ts b/packages/twenty-front/src/modules/auth/states/tokenPairState.ts
index 2bf851df421..25589a0b657 100644
--- a/packages/twenty-front/src/modules/auth/states/tokenPairState.ts
+++ b/packages/twenty-front/src/modules/auth/states/tokenPairState.ts
@@ -1,10 +1,9 @@
-import { atom } from 'recoil';
-
+import { createState } from '@/ui/utilities/state/utils/createState';
import { AuthTokenPair } from '~/generated/graphql';
import { cookieStorageEffect } from '~/utils/recoil-effects';
-export const tokenPairState = atom<AuthTokenPair | null>({
+export const tokenPairState = createState<AuthTokenPair | null>({
key: 'tokenPairState',
- default: null,
+ defaultValue: null,
effects: [cookieStorageEffect('tokenPair')],
});
diff --git a/packages/twenty-front/src/modules/client-config/components/ClientConfigProvider.tsx b/packages/twenty-front/src/modules/client-config/components/ClientConfigProvider.tsx
index 75aa82669d8..debb354f148 100644
--- a/packages/twenty-front/src/modules/client-config/components/ClientConfigProvider.tsx
+++ b/packages/twenty-front/src/modules/client-config/components/ClientConfigProvider.tsx
@@ -15,17 +15,17 @@ import { isNonNullable } from '~/utils/isNonNullable';
export const ClientConfigProvider: React.FC<React.PropsWithChildren> = ({
children,
}) => {
- const setAuthProviders = useSetRecoilState(authProvidersState);
- const setIsDebugMode = useSetRecoilState(isDebugModeState);
+ const setAuthProviders = useSetRecoilState(authProvidersState());
+ const setIsDebugMode = useSetRecoilState(isDebugModeState());
- const setIsSignInPrefilled = useSetRecoilState(isSignInPrefilledState);
- const setIsSignUpDisabled = useSetRecoilState(isSignUpDisabledState);
+ const setIsSignInPrefilled = useSetRecoilState(isSignInPrefilledState());
+ const setIsSignUpDisabled = useSetRecoilState(isSignUpDisabledState());
- const setBilling = useSetRecoilState(billingState);
- const setTelemetry = useSetRecoilState(telemetryState);
- const setSupportChat = useSetRecoilState(supportChatState);
+ const setBilling = useSetRecoilState(billingState());
+ const setTelemetry = useSetRecoilState(telemetryState());
+ const setSupportChat = useSetRecoilState(supportChatState());
- const setSentryConfig = useSetRecoilState(sentryConfigState);
+ const setSentryConfig = useSetRecoilState(sentryConfigState());
const { data, loading } = useGetClientConfigQuery();
diff --git a/packages/twenty-front/src/modules/client-config/states/authProvidersState.ts b/packages/twenty-front/src/modules/client-config/states/authProvidersState.ts
index e0b087fa407..2fbc24d6f4b 100644
--- a/packages/twenty-front/src/modules/client-config/states/authProvidersState.ts
+++ b/packages/twenty-front/src/modules/client-config/states/authProvidersState.ts
@@ -1,8 +1,7 @@
-import { atom } from 'recoil';
-
+import { createState } from '@/ui/utilities/state/utils/createState';
import { AuthProviders } from '~/generated/graphql';
-export const authProvidersState = atom<AuthProviders>({
+export const authProvidersState = createState<AuthProviders>({
key: 'authProvidersState',
- default: { google: false, magicLink: false, password: true },
+ defaultValue: { google: false, magicLink: false, password: true },
});
diff --git a/packages/twenty-front/src/modules/client-config/states/billingState.ts b/packages/twenty-front/src/modules/client-config/states/billingState.ts
index 4f0982b4978..e0f46cf34b3 100644
--- a/packages/twenty-front/src/modules/client-config/states/billingState.ts
+++ b/packages/twenty-front/src/modules/client-config/states/billingState.ts
@@ -1,8 +1,7 @@
-import { atom } from 'recoil';
-
+import { createState } from '@/ui/utilities/state/utils/createState';
import { Billing } from '~/generated/graphql';
-export const billingState = atom<Billing | null>({
+export const billingState = createState<Billing | null>({
key: 'billingState',
- default: null,
+ defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/client-config/states/isDebugModeState.ts b/packages/twenty-front/src/modules/client-config/states/isDebugModeState.ts
index 82d8be49d12..7b9b0cf5a95 100644
--- a/packages/twenty-front/src/modules/client-config/states/isDebugModeState.ts
+++ b/packages/twenty-front/src/modules/client-config/states/isDebugModeState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const isDebugModeState = atom<boolean>({
+export const isDebugModeState = createState<boolean>({
key: 'isDebugModeState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/client-config/states/isSignInPrefilledState.ts b/packages/twenty-front/src/modules/client-config/states/isSignInPrefilledState.ts
index 649f42d25c0..57cc70c5770 100644
--- a/packages/twenty-front/src/modules/client-config/states/isSignInPrefilledState.ts
+++ b/packages/twenty-front/src/modules/client-config/states/isSignInPrefilledState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const isSignInPrefilledState = atom<boolean>({
+export const isSignInPrefilledState = createState<boolean>({
key: 'isSignInPrefilledState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/client-config/states/isSignUpDisabledState.ts b/packages/twenty-front/src/modules/client-config/states/isSignUpDisabledState.ts
index da7ec103e0c..095f74b1baf 100644
--- a/packages/twenty-front/src/modules/client-config/states/isSignUpDisabledState.ts
+++ b/packages/twenty-front/src/modules/client-config/states/isSignUpDisabledState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const isSignUpDisabledState = atom<boolean>({
+export const isSignUpDisabledState = createState<boolean>({
key: 'isSignUpDisabledState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/client-config/states/sentryConfigState.ts b/packages/twenty-front/src/modules/client-config/states/sentryConfigState.ts
index e88fd248391..fd4b7a1c9a3 100644
--- a/packages/twenty-front/src/modules/client-config/states/sentryConfigState.ts
+++ b/packages/twenty-front/src/modules/client-config/states/sentryConfigState.ts
@@ -1,8 +1,7 @@
-import { atom } from 'recoil';
-
+import { createState } from '@/ui/utilities/state/utils/createState';
import { Sentry } from '~/generated/graphql';
-export const sentryConfigState = atom<Sentry | null>({
+export const sentryConfigState = createState<Sentry | null>({
key: 'sentryConfigState',
- default: null,
+ defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/client-config/states/supportChatState.ts b/packages/twenty-front/src/modules/client-config/states/supportChatState.ts
index 8597704935c..28c7393567f 100644
--- a/packages/twenty-front/src/modules/client-config/states/supportChatState.ts
+++ b/packages/twenty-front/src/modules/client-config/states/supportChatState.ts
@@ -1,10 +1,9 @@
-import { atom } from 'recoil';
-
+import { createState } from '@/ui/utilities/state/utils/createState';
import { Support } from '~/generated/graphql';
-export const supportChatState = atom<Support>({
+export const supportChatState = createState<Support>({
key: 'supportChatState',
- default: {
+ defaultValue: {
supportDriver: 'none',
supportFrontChatId: null,
},
diff --git a/packages/twenty-front/src/modules/client-config/states/telemetryState.ts b/packages/twenty-front/src/modules/client-config/states/telemetryState.ts
index c6d09580795..1811862fdfe 100644
--- a/packages/twenty-front/src/modules/client-config/states/telemetryState.ts
+++ b/packages/twenty-front/src/modules/client-config/states/telemetryState.ts
@@ -1,8 +1,7 @@
-import { atom } from 'recoil';
-
+import { createState } from '@/ui/utilities/state/utils/createState';
import { Telemetry } from '~/generated/graphql';
-export const telemetryState = atom<Telemetry>({
+export const telemetryState = createState<Telemetry>({
key: 'telemetryState',
- default: { enabled: true, anonymizationEnabled: true },
+ defaultValue: { enabled: true, anonymizationEnabled: true },
});
diff --git a/packages/twenty-front/src/modules/command-menu/components/CommandMenu.tsx b/packages/twenty-front/src/modules/command-menu/components/CommandMenu.tsx
index 3cd35214ff4..e4cef7b5f0f 100644
--- a/packages/twenty-front/src/modules/command-menu/components/CommandMenu.tsx
+++ b/packages/twenty-front/src/modules/command-menu/components/CommandMenu.tsx
@@ -109,9 +109,9 @@ export const CommandMenu = () => {
const openActivityRightDrawer = useOpenActivityRightDrawer();
const isCommandMenuOpened = useRecoilValue(isCommandMenuOpenedState);
const [commandMenuSearch, setCommandMenuSearch] = useRecoilState(
- commandMenuSearchState,
+ commandMenuSearchState(),
);
- const commandMenuCommands = useRecoilValue(commandMenuCommandsState);
+ const commandMenuCommands = useRecoilValue(commandMenuCommandsState());
const { closeKeyboardShortcutMenu } = useKeyboardShortcutMenu();
const handleSearchChange = (event: React.ChangeEvent<HTMLInputElement>) => {
diff --git a/packages/twenty-front/src/modules/command-menu/components/__stories__/CommandMenu.stories.tsx b/packages/twenty-front/src/modules/command-menu/components/__stories__/CommandMenu.stories.tsx
index 6cf5c7fbf3c..95e4da7d182 100644
--- a/packages/twenty-front/src/modules/command-menu/components/__stories__/CommandMenu.stories.tsx
+++ b/packages/twenty-front/src/modules/command-menu/components/__stories__/CommandMenu.stories.tsx
@@ -27,9 +27,9 @@ const meta: Meta<typeof CommandMenu> = {
component: CommandMenu,
decorators: [
(Story) => {
- const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState);
+ const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState());
const setCurrentWorkspaceMember = useSetRecoilState(
- currentWorkspaceMemberState,
+ currentWorkspaceMemberState(),
);
const { addToCommandMenu, setToInitialCommandMenu, openCommandMenu } =
useCommandMenu();
diff --git a/packages/twenty-front/src/modules/command-menu/hooks/__test__/useCommandMenu.test.tsx b/packages/twenty-front/src/modules/command-menu/hooks/__test__/useCommandMenu.test.tsx
index e1ee5501382..2cdec0fdc4a 100644
--- a/packages/twenty-front/src/modules/command-menu/hooks/__test__/useCommandMenu.test.tsx
+++ b/packages/twenty-front/src/modules/command-menu/hooks/__test__/useCommandMenu.test.tsx
@@ -25,7 +25,7 @@ const renderHooks = () => {
const commandMenu = useCommandMenu();
const isCommandMenuOpened = useRecoilValue(isCommandMenuOpenedState);
const [commandMenuCommands, setCommandMenuCommands] = useRecoilState(
- commandMenuCommandsState,
+ commandMenuCommandsState(),
);
return {
diff --git a/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenu.ts b/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenu.ts
index 249eb89d88b..cf422e52372 100644
--- a/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenu.ts
+++ b/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenu.ts
@@ -17,7 +17,7 @@ import { Command } from '../types/Command';
export const useCommandMenu = () => {
const navigate = useNavigate();
const setIsCommandMenuOpened = useSetRecoilState(isCommandMenuOpenedState);
- const setCommands = useSetRecoilState(commandMenuCommandsState);
+ const setCommands = useSetRecoilState(commandMenuCommandsState());
const { resetSelectedItem } = useSelectableList('command-menu-list');
const {
setHotkeyScopeAndMemorizePreviousScope,
@@ -52,7 +52,7 @@ export const useCommandMenu = () => {
.getLoadable(isCommandMenuOpenedState)
.getValue();
- set(commandMenuSearchState, '');
+ set(commandMenuSearchState(), '');
if (isCommandMenuOpened) {
closeCommandMenu();
diff --git a/packages/twenty-front/src/modules/command-menu/states/commandMenuCommandsState.ts b/packages/twenty-front/src/modules/command-menu/states/commandMenuCommandsState.ts
index cfd4c359613..28d7cdc9d0c 100644
--- a/packages/twenty-front/src/modules/command-menu/states/commandMenuCommandsState.ts
+++ b/packages/twenty-front/src/modules/command-menu/states/commandMenuCommandsState.ts
@@ -1,10 +1,10 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
import { Command, CommandType } from '../types/Command';
-export const commandMenuCommandsState = atom<Command[]>({
+export const commandMenuCommandsState = createState<Command[]>({
key: 'command-menu/commandMenuCommandsState',
- default: [
+ defaultValue: [
{
id: '',
to: '',
diff --git a/packages/twenty-front/src/modules/command-menu/states/commandMenuSearchState.ts b/packages/twenty-front/src/modules/command-menu/states/commandMenuSearchState.ts
index b5be2a5d7ac..5d6aa126d9d 100644
--- a/packages/twenty-front/src/modules/command-menu/states/commandMenuSearchState.ts
+++ b/packages/twenty-front/src/modules/command-menu/states/commandMenuSearchState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const commandMenuSearchState = atom<string>({
+export const commandMenuSearchState = createState<string>({
key: 'command-menu/commandMenuSearchState',
- default: '',
+ defaultValue: '',
});
diff --git a/packages/twenty-front/src/modules/debug/components/ApolloDevLogEffect.tsx b/packages/twenty-front/src/modules/debug/components/ApolloDevLogEffect.tsx
index 93a6af6f0c5..7ce1508463a 100644
--- a/packages/twenty-front/src/modules/debug/components/ApolloDevLogEffect.tsx
+++ b/packages/twenty-front/src/modules/debug/components/ApolloDevLogEffect.tsx
@@ -5,7 +5,7 @@ import { useRecoilValue } from 'recoil';
import { isDebugModeState } from '@/client-config/states/isDebugModeState';
export const ApolloDevLogEffect = () => {
- const isDebugMode = useRecoilValue(isDebugModeState);
+ const isDebugMode = useRecoilValue(isDebugModeState());
useEffect(() => {
if (isDebugMode) {
diff --git a/packages/twenty-front/src/modules/debug/components/RecoilDebugObserver.tsx b/packages/twenty-front/src/modules/debug/components/RecoilDebugObserver.tsx
index 5031c1963f9..e603623f78e 100644
--- a/packages/twenty-front/src/modules/debug/components/RecoilDebugObserver.tsx
+++ b/packages/twenty-front/src/modules/debug/components/RecoilDebugObserver.tsx
@@ -15,7 +15,7 @@ const formatTitle = (stateName: string) => {
};
export const RecoilDebugObserverEffect = () => {
- const isDebugMode = useRecoilValue(isDebugModeState);
+ const isDebugMode = useRecoilValue(isDebugModeState());
useRecoilTransactionObserver_UNSTABLE(({ snapshot }) => {
if (!isDebugMode) {
diff --git a/packages/twenty-front/src/modules/error-handler/components/SentryInitiEffect.tsx b/packages/twenty-front/src/modules/error-handler/components/SentryInitiEffect.tsx
index ba7e1978df5..639f6c7818e 100644
--- a/packages/twenty-front/src/modules/error-handler/components/SentryInitiEffect.tsx
+++ b/packages/twenty-front/src/modules/error-handler/components/SentryInitiEffect.tsx
@@ -11,11 +11,11 @@ import { REACT_APP_SERVER_BASE_URL } from '~/config';
import { isNonNullable } from '~/utils/isNonNullable';
export const SentryInitEffect = () => {
- const sentryConfig = useRecoilValue(sentryConfigState);
+ const sentryConfig = useRecoilValue(sentryConfigState());
- const currentUser = useRecoilValue(currentUserState);
- const currentWorkspace = useRecoilValue(currentWorkspaceState);
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
+ const currentUser = useRecoilValue(currentUserState());
+ const currentWorkspace = useRecoilValue(currentWorkspaceState());
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
const [isSentryInitialized, setIsSentryInitialized] = useState(false);
diff --git a/packages/twenty-front/src/modules/favorites/hooks/__tests__/useFavorites.test.tsx b/packages/twenty-front/src/modules/favorites/hooks/__tests__/useFavorites.test.tsx
index f7fb44d6f52..08d86a5b7a9 100644
--- a/packages/twenty-front/src/modules/favorites/hooks/__tests__/useFavorites.test.tsx
+++ b/packages/twenty-front/src/modules/favorites/hooks/__tests__/useFavorites.test.tsx
@@ -50,11 +50,11 @@ describe('useFavorites', () => {
const { result } = renderHook(
() => {
const setCurrentWorkspaceMember = useSetRecoilState(
- currentWorkspaceMemberState,
+ currentWorkspaceMemberState(),
);
setCurrentWorkspaceMember(mockWorkspaceMember);
- const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
+ const setMetadataItems = useSetRecoilState(objectMetadataItemsState());
setMetadataItems(mockObjectMetadataItems);
return useFavorites();
@@ -71,11 +71,11 @@ describe('useFavorites', () => {
const { result } = renderHook(
() => {
const setCurrentWorkspaceMember = useSetRecoilState(
- currentWorkspaceMemberState,
+ currentWorkspaceMemberState(),
);
setCurrentWorkspaceMember(mockWorkspaceMember);
- const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
+ const setMetadataItems = useSetRecoilState(objectMetadataItemsState());
setMetadataItems(mockObjectMetadataItems);
return useFavorites();
@@ -99,11 +99,11 @@ describe('useFavorites', () => {
const { result } = renderHook(
() => {
const setCurrentWorkspaceMember = useSetRecoilState(
- currentWorkspaceMemberState,
+ currentWorkspaceMemberState(),
);
setCurrentWorkspaceMember(mockWorkspaceMember);
- const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
+ const setMetadataItems = useSetRecoilState(objectMetadataItemsState());
setMetadataItems(mockObjectMetadataItems);
return useFavorites();
@@ -124,11 +124,11 @@ describe('useFavorites', () => {
const { result } = renderHook(
() => {
const setCurrentWorkspaceMember = useSetRecoilState(
- currentWorkspaceMemberState,
+ currentWorkspaceMemberState(),
);
setCurrentWorkspaceMember(mockWorkspaceMember);
- const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
+ const setMetadataItems = useSetRecoilState(objectMetadataItemsState());
setMetadataItems(mockObjectMetadataItems);
return useFavorites();
diff --git a/packages/twenty-front/src/modules/favorites/hooks/useFavorites.ts b/packages/twenty-front/src/modules/favorites/hooks/useFavorites.ts
index 8614bfc60d1..19c71c11363 100644
--- a/packages/twenty-front/src/modules/favorites/hooks/useFavorites.ts
+++ b/packages/twenty-front/src/modules/favorites/hooks/useFavorites.ts
@@ -14,7 +14,7 @@ import { FieldMetadataType } from '~/generated-metadata/graphql';
import { isNonNullable } from '~/utils/isNonNullable';
export const useFavorites = () => {
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
const favoriteObjectNameSingular = 'favorite';
diff --git a/packages/twenty-front/src/modules/favorites/states/favoritesState.ts b/packages/twenty-front/src/modules/favorites/states/favoritesState.ts
index 298de69af83..a15a76e7035 100644
--- a/packages/twenty-front/src/modules/favorites/states/favoritesState.ts
+++ b/packages/twenty-front/src/modules/favorites/states/favoritesState.ts
@@ -1,8 +1,7 @@
-import { atom } from 'recoil';
-
import { Favorite } from '@/favorites/types/Favorite';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const favoritesState = atom<Favorite[]>({
+export const favoritesState = createState<Favorite[]>({
key: 'favoritesState',
- default: [],
+ defaultValue: [],
});
diff --git a/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx b/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx
index 0a8a50cdd21..216a12462f5 100644
--- a/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/AppNavigationDrawer.tsx
@@ -28,12 +28,12 @@ export const AppNavigationDrawer = ({
const isMobile = useIsMobile();
const isSettingsPage = useIsSettingsPage();
const currentMobileNavigationDrawer = useRecoilValue(
- currentMobileNavigationDrawerState,
+ currentMobileNavigationDrawerState(),
);
const setIsNavigationDrawerOpen = useSetRecoilState(
isNavigationDrawerOpenState,
);
- const currentWorkspace = useRecoilValue(currentWorkspaceState);
+ const currentWorkspace = useRecoilValue(currentWorkspaceState());
const isSettingsDrawer = isMobile
? currentMobileNavigationDrawer === 'settings'
diff --git a/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerItems.tsx b/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerItems.tsx
index f8a437ed7c5..102f5d7cf33 100644
--- a/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerItems.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/MainNavigationDrawerItems.tsx
@@ -24,11 +24,13 @@ export const MainNavigationDrawerItems = () => {
const isMobile = useIsMobile();
const { toggleCommandMenu } = useCommandMenu();
const isTasksPage = useIsTasksPage();
- const currentUserDueTaskCount = useRecoilValue(currentUserDueTaskCountState);
+ const currentUserDueTaskCount = useRecoilValue(
+ currentUserDueTaskCountState(),
+ );
const navigate = useNavigate();
const location = useLocation();
const setNavigationMemorizedUrl = useSetRecoilState(
- navigationMemorizedUrlState,
+ navigationMemorizedUrlState(),
);
return (
diff --git a/packages/twenty-front/src/modules/navigation/components/MobileNavigationBar.tsx b/packages/twenty-front/src/modules/navigation/components/MobileNavigationBar.tsx
index 3680415ba45..d671a284e85 100644
--- a/packages/twenty-front/src/modules/navigation/components/MobileNavigationBar.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/MobileNavigationBar.tsx
@@ -30,7 +30,7 @@ export const MobileNavigationBar = () => {
isNavigationDrawerOpenState,
);
const [currentMobileNavigationDrawer, setCurrentMobileNavigationDrawer] =
- useRecoilState(currentMobileNavigationDrawerState);
+ useRecoilState(currentMobileNavigationDrawerState());
const activeItemName = isNavigationDrawerOpen
? currentMobileNavigationDrawer
diff --git a/packages/twenty-front/src/modules/navigation/components/__stories__/AppNavigationDrawer.stories.tsx b/packages/twenty-front/src/modules/navigation/components/__stories__/AppNavigationDrawer.stories.tsx
index e267c7e24aa..3c538ccd635 100644
--- a/packages/twenty-front/src/modules/navigation/components/__stories__/AppNavigationDrawer.stories.tsx
+++ b/packages/twenty-front/src/modules/navigation/components/__stories__/AppNavigationDrawer.stories.tsx
@@ -24,7 +24,7 @@ const MobileNavigationDrawerStateSetterEffect = ({
isNavigationDrawerOpenState,
);
const setCurrentMobileNavigationDrawer = useSetRecoilState(
- currentMobileNavigationDrawerState,
+ currentMobileNavigationDrawerState(),
);
useEffect(() => {
diff --git a/packages/twenty-front/src/modules/navigation/states/currentMobileNavigationDrawerState.ts b/packages/twenty-front/src/modules/navigation/states/currentMobileNavigationDrawerState.ts
index acd302d4427..44acf85a18c 100644
--- a/packages/twenty-front/src/modules/navigation/states/currentMobileNavigationDrawerState.ts
+++ b/packages/twenty-front/src/modules/navigation/states/currentMobileNavigationDrawerState.ts
@@ -1,6 +1,8 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const currentMobileNavigationDrawerState = atom<'main' | 'settings'>({
+export const currentMobileNavigationDrawerState = createState<
+ 'main' | 'settings'
+>({
key: 'currentMobileNavigationDrawerState',
- default: 'main',
+ defaultValue: 'main',
});
diff --git a/packages/twenty-front/src/modules/object-metadata/components/ApolloMetadataClientProvider.tsx b/packages/twenty-front/src/modules/object-metadata/components/ApolloMetadataClientProvider.tsx
index 2af8362986e..38bd8fc66d1 100644
--- a/packages/twenty-front/src/modules/object-metadata/components/ApolloMetadataClientProvider.tsx
+++ b/packages/twenty-front/src/modules/object-metadata/components/ApolloMetadataClientProvider.tsx
@@ -13,7 +13,7 @@ export const ApolloMetadataClientProvider = ({
}: {
children: React.ReactNode;
}) => {
- const [tokenPair] = useRecoilState(tokenPairState);
+ const [tokenPair] = useRecoilState(tokenPairState());
const apolloMetadataClient = useMemo(() => {
if (isNonEmptyString(tokenPair?.accessToken.token)) {
return new ApolloClient({
diff --git a/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataItemsLoadEffect.tsx b/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataItemsLoadEffect.tsx
index 9288ec017b3..0313a164fbb 100644
--- a/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataItemsLoadEffect.tsx
+++ b/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataItemsLoadEffect.tsx
@@ -10,7 +10,7 @@ export const ObjectMetadataItemsLoadEffect = () => {
useFindManyObjectMetadataItems();
const [objectMetadataItems, setObjectMetadataItems] = useRecoilState(
- objectMetadataItemsState,
+ objectMetadataItemsState(),
);
useEffect(() => {
diff --git a/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataItemsProvider.tsx b/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataItemsProvider.tsx
index 872c8da1923..73441a4969b 100644
--- a/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataItemsProvider.tsx
+++ b/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataItemsProvider.tsx
@@ -9,8 +9,8 @@ import { RelationPickerScope } from '@/object-record/relation-picker/scopes/Rela
export const ObjectMetadataItemsProvider = ({
children,
}: React.PropsWithChildren) => {
- const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
+ const objectMetadataItems = useRecoilValue(objectMetadataItemsState());
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
const shouldDisplayChildren = () => {
if (objectMetadataItems.length > 0) {
return true;
diff --git a/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useFilterOutUnexistingObjectMetadataItems.test.tsx b/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useFilterOutUnexistingObjectMetadataItems.test.tsx
index e544f642c0b..d23f347d67a 100644
--- a/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useFilterOutUnexistingObjectMetadataItems.test.tsx
+++ b/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useFilterOutUnexistingObjectMetadataItems.test.tsx
@@ -12,7 +12,7 @@ describe('useFilterOutUnexistingObjectMetadataItems', () => {
it('should work as expected', async () => {
const { result } = renderHook(
() => {
- const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
+ const setMetadataItems = useSetRecoilState(objectMetadataItemsState());
setMetadataItems(mockObjectMetadataItems.slice(1));
return useFilterOutUnexistingObjectMetadataItems();
diff --git a/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useGetObjectRecordIdentifierByNameSingular.test.tsx b/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useGetObjectRecordIdentifierByNameSingular.test.tsx
index 1a4c0e2cbfc..6f25e039ca6 100644
--- a/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useGetObjectRecordIdentifierByNameSingular.test.tsx
+++ b/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useGetObjectRecordIdentifierByNameSingular.test.tsx
@@ -17,7 +17,7 @@ describe('useGetObjectRecordIdentifierByNameSingular', () => {
record: any;
objectNameSingular: string;
}) => {
- const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
+ const setMetadataItems = useSetRecoilState(objectMetadataItemsState());
setMetadataItems(mockObjectMetadataItems);
diff --git a/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useGetRelationMetadata.test.tsx b/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useGetRelationMetadata.test.tsx
index b13554ed6e1..45486629086 100644
--- a/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useGetRelationMetadata.test.tsx
+++ b/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useGetRelationMetadata.test.tsx
@@ -31,7 +31,7 @@ describe('useGetRelationMetadata', () => {
const { result } = renderHook(
() => {
- const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
+ const setMetadataItems = useSetRecoilState(objectMetadataItemsState());
useEffect(() => {
setMetadataItems(objectMetadataItems);
diff --git a/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useMapFieldMetadataToGraphQLQuery.test.tsx b/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useMapFieldMetadataToGraphQLQuery.test.tsx
index 43a5b676a2e..31d6bdfe99f 100644
--- a/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useMapFieldMetadataToGraphQLQuery.test.tsx
+++ b/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useMapFieldMetadataToGraphQLQuery.test.tsx
@@ -127,7 +127,7 @@ describe('useMapFieldMetadataToGraphQLQuery', () => {
it('should work as expected', async () => {
const { result } = renderHook(
() => {
- const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
+ const setMetadataItems = useSetRecoilState(objectMetadataItemsState());
setMetadataItems(mockObjectMetadataItems);
return {
diff --git a/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useObjectMetadataItemForSettings.test.tsx b/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useObjectMetadataItemForSettings.test.tsx
index c93057e2e8f..e13c468e4ea 100644
--- a/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useObjectMetadataItemForSettings.test.tsx
+++ b/packages/twenty-front/src/modules/object-metadata/hooks/__tests__/useObjectMetadataItemForSettings.test.tsx
@@ -44,7 +44,7 @@ describe('useObjectMetadataItemForSettings', () => {
it('should findActiveObjectMetadataItemBySlug', async () => {
const { result } = renderHook(
() => {
- const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
+ const setMetadataItems = useSetRecoilState(objectMetadataItemsState());
setMetadataItems(mockObjectMetadataItems);
return useObjectMetadataItemForSettings();
@@ -64,7 +64,7 @@ describe('useObjectMetadataItemForSettings', () => {
it('should findObjectMetadataItemById', async () => {
const { result } = renderHook(
() => {
- const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
+ const setMetadataItems = useSetRecoilState(objectMetadataItemsState());
setMetadataItems(mockObjectMetadataItems);
return useObjectMetadataItemForSettings();
@@ -86,7 +86,7 @@ describe('useObjectMetadataItemForSettings', () => {
it('should findObjectMetadataItemByNamePlural', async () => {
const { result } = renderHook(
() => {
- const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
+ const setMetadataItems = useSetRecoilState(objectMetadataItemsState());
setMetadataItems(mockObjectMetadataItems);
return useObjectMetadataItemForSettings();
diff --git a/packages/twenty-front/src/modules/object-metadata/hooks/useGetObjectRecordIdentifierByNameSingular.ts b/packages/twenty-front/src/modules/object-metadata/hooks/useGetObjectRecordIdentifierByNameSingular.ts
index be32e216294..53c878f873a 100644
--- a/packages/twenty-front/src/modules/object-metadata/hooks/useGetObjectRecordIdentifierByNameSingular.ts
+++ b/packages/twenty-front/src/modules/object-metadata/hooks/useGetObjectRecordIdentifierByNameSingular.ts
@@ -5,7 +5,7 @@ import { getObjectRecordIdentifier } from '@/object-metadata/utils/getObjectReco
import { ObjectRecordIdentifier } from '@/object-record/types/ObjectRecordIdentifier';
export const useGetObjectRecordIdentifierByNameSingular = () => {
- const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
+ const objectMetadataItems = useRecoilValue(objectMetadataItemsState());
return (record: any, objectNameSingular: string): ObjectRecordIdentifier => {
const objectMetadataItem = objectMetadataItems.find(
diff --git a/packages/twenty-front/src/modules/object-metadata/hooks/useMapFieldMetadataToGraphQLQuery.ts b/packages/twenty-front/src/modules/object-metadata/hooks/useMapFieldMetadataToGraphQLQuery.ts
index 41a69a93c14..6ddf40b418c 100644
--- a/packages/twenty-front/src/modules/object-metadata/hooks/useMapFieldMetadataToGraphQLQuery.ts
+++ b/packages/twenty-front/src/modules/object-metadata/hooks/useMapFieldMetadataToGraphQLQuery.ts
@@ -6,7 +6,7 @@ import { FieldType } from '@/object-record/record-field/types/FieldType';
import { FieldMetadataItem } from '../types/FieldMetadataItem';
export const useMapFieldMetadataToGraphQLQuery = () => {
- const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
+ const objectMetadataItems = useRecoilValue(objectMetadataItemsState());
const mapFieldMetadataToGraphQLQuery = ({
field,
diff --git a/packages/twenty-front/src/modules/object-metadata/hooks/useObjectMetadataItem.ts b/packages/twenty-front/src/modules/object-metadata/hooks/useObjectMetadataItem.ts
index 95b88de5e9f..1a156000380 100644
--- a/packages/twenty-front/src/modules/object-metadata/hooks/useObjectMetadataItem.ts
+++ b/packages/twenty-front/src/modules/object-metadata/hooks/useObjectMetadataItem.ts
@@ -41,7 +41,7 @@ export const useObjectMetadataItem = (
{ objectNameSingular }: ObjectMetadataItemIdentifier,
depth?: number,
) => {
- const currentWorkspace = useRecoilValue(currentWorkspaceState);
+ const currentWorkspace = useRecoilValue(currentWorkspaceState());
const mockObjectMetadataItems = getObjectMetadataItemsMock();
@@ -52,7 +52,7 @@ export const useObjectMetadataItem = (
}),
);
- let objectMetadataItems = useRecoilValue(objectMetadataItemsState);
+ let objectMetadataItems = useRecoilValue(objectMetadataItemsState());
if (currentWorkspace?.activationStatus !== 'active') {
objectMetadataItem =
diff --git a/packages/twenty-front/src/modules/object-metadata/hooks/useObjectMetadataItemForSettings.ts b/packages/twenty-front/src/modules/object-metadata/hooks/useObjectMetadataItemForSettings.ts
index eb8bfe651f1..fce0388690b 100644
--- a/packages/twenty-front/src/modules/object-metadata/hooks/useObjectMetadataItemForSettings.ts
+++ b/packages/twenty-front/src/modules/object-metadata/hooks/useObjectMetadataItemForSettings.ts
@@ -5,7 +5,7 @@ import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadat
import { getObjectSlug } from '../utils/getObjectSlug';
export const useObjectMetadataItemForSettings = () => {
- const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
+ const objectMetadataItems = useRecoilValue(objectMetadataItemsState());
const activeObjectMetadataItems = objectMetadataItems.filter(
({ isActive, isSystem }) => isActive && !isSystem,
diff --git a/packages/twenty-front/src/modules/object-metadata/hooks/useObjectMetadataItemOnly.ts b/packages/twenty-front/src/modules/object-metadata/hooks/useObjectMetadataItemOnly.ts
index 12dc6f28e1e..ca269ed1efe 100644
--- a/packages/twenty-front/src/modules/object-metadata/hooks/useObjectMetadataItemOnly.ts
+++ b/packages/twenty-front/src/modules/object-metadata/hooks/useObjectMetadataItemOnly.ts
@@ -12,7 +12,7 @@ import { ObjectMetadataItemIdentifier } from '../types/ObjectMetadataItemIdentif
export const useObjectMetadataItemOnly = ({
objectNameSingular,
}: ObjectMetadataItemIdentifier) => {
- const currentWorkspace = useRecoilValue(currentWorkspaceState);
+ const currentWorkspace = useRecoilValue(currentWorkspaceState());
const mockObjectMetadataItems = getObjectMetadataItemsMock();
@@ -23,7 +23,7 @@ export const useObjectMetadataItemOnly = ({
}),
);
- let objectMetadataItems = useRecoilValue(objectMetadataItemsState);
+ let objectMetadataItems = useRecoilValue(objectMetadataItemsState());
if (currentWorkspace?.activationStatus !== 'active') {
objectMetadataItem =
diff --git a/packages/twenty-front/src/modules/object-metadata/hooks/useObjectMetadataItems.ts b/packages/twenty-front/src/modules/object-metadata/hooks/useObjectMetadataItems.ts
index 215d61200c5..0085cccabcf 100644
--- a/packages/twenty-front/src/modules/object-metadata/hooks/useObjectMetadataItems.ts
+++ b/packages/twenty-front/src/modules/object-metadata/hooks/useObjectMetadataItems.ts
@@ -3,7 +3,7 @@ import { useRecoilValue } from 'recoil';
import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadataItemsState';
export const useObjectMetadataItems = () => {
- const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
+ const objectMetadataItems = useRecoilValue(objectMetadataItemsState());
return {
objectMetadataItems,
diff --git a/packages/twenty-front/src/modules/object-metadata/hooks/useObjectNamePluralFromSingular.ts b/packages/twenty-front/src/modules/object-metadata/hooks/useObjectNamePluralFromSingular.ts
index 41200610824..df0e65af0a3 100644
--- a/packages/twenty-front/src/modules/object-metadata/hooks/useObjectNamePluralFromSingular.ts
+++ b/packages/twenty-front/src/modules/object-metadata/hooks/useObjectNamePluralFromSingular.ts
@@ -10,7 +10,7 @@ export const useObjectNamePluralFromSingular = ({
}: {
objectNameSingular: string;
}) => {
- const currentWorkspace = useRecoilValue(currentWorkspaceState);
+ const currentWorkspace = useRecoilValue(currentWorkspaceState());
const mockObjectMetadataItems = getObjectMetadataItemsMock();
let objectMetadataItem = useRecoilValue(
diff --git a/packages/twenty-front/src/modules/object-metadata/hooks/useObjectNameSingularFromPlural.ts b/packages/twenty-front/src/modules/object-metadata/hooks/useObjectNameSingularFromPlural.ts
index 6a00794f8a5..a63b5630588 100644
--- a/packages/twenty-front/src/modules/object-metadata/hooks/useObjectNameSingularFromPlural.ts
+++ b/packages/twenty-front/src/modules/object-metadata/hooks/useObjectNameSingularFromPlural.ts
@@ -10,7 +10,7 @@ export const useObjectNameSingularFromPlural = ({
}: {
objectNamePlural: string;
}) => {
- const currentWorkspace = useRecoilValue(currentWorkspaceState);
+ const currentWorkspace = useRecoilValue(currentWorkspaceState());
const mockObjectMetadataItems = getObjectMetadataItemsMock();
diff --git a/packages/twenty-front/src/modules/object-metadata/states/objectMetadataItemFamilySelector.ts b/packages/twenty-front/src/modules/object-metadata/states/objectMetadataItemFamilySelector.ts
index b264758fbae..7e0d695b3e6 100644
--- a/packages/twenty-front/src/modules/object-metadata/states/objectMetadataItemFamilySelector.ts
+++ b/packages/twenty-front/src/modules/object-metadata/states/objectMetadataItemFamilySelector.ts
@@ -16,7 +16,7 @@ export const objectMetadataItemFamilySelector = selectorFamily<
get:
({ objectNameType, objectName }: ObjectMetadataItemSelector) =>
({ get }) => {
- const objectMetadataItems = get(objectMetadataItemsState);
+ const objectMetadataItems = get(objectMetadataItemsState());
if (objectNameType === 'singular') {
return (
diff --git a/packages/twenty-front/src/modules/object-metadata/states/objectMetadataItemsByNamePluralMapSelector.ts b/packages/twenty-front/src/modules/object-metadata/states/objectMetadataItemsByNamePluralMapSelector.ts
index 30dfb115ef8..7168e5054ea 100644
--- a/packages/twenty-front/src/modules/object-metadata/states/objectMetadataItemsByNamePluralMapSelector.ts
+++ b/packages/twenty-front/src/modules/object-metadata/states/objectMetadataItemsByNamePluralMapSelector.ts
@@ -8,7 +8,7 @@ export const objectMetadataItemsByNamePluralMapSelector = selector<
>({
key: 'objectMetadataItemsByNamePluralMapSelector',
get: ({ get }) => {
- const objectMetadataItems = get(objectMetadataItemsState);
+ const objectMetadataItems = get(objectMetadataItemsState());
return new Map(
objectMetadataItems.map((objectMetadataItem) => [
diff --git a/packages/twenty-front/src/modules/object-metadata/states/objectMetadataItemsByNameSingularMapSelector.ts b/packages/twenty-front/src/modules/object-metadata/states/objectMetadataItemsByNameSingularMapSelector.ts
index 2eddad42b1f..9111cc6c2d4 100644
--- a/packages/twenty-front/src/modules/object-metadata/states/objectMetadataItemsByNameSingularMapSelector.ts
+++ b/packages/twenty-front/src/modules/object-metadata/states/objectMetadataItemsByNameSingularMapSelector.ts
@@ -8,7 +8,7 @@ export const objectMetadataItemsByNameSingularMapSelector = selector<
>({
key: 'objectMetadataItemsByNameSingularMapSelector',
get: ({ get }) => {
- const objectMetadataItems = get(objectMetadataItemsState);
+ const objectMetadataItems = get(objectMetadataItemsState());
return new Map(
objectMetadataItems.map((objectMetadataItem) => [
diff --git a/packages/twenty-front/src/modules/object-metadata/states/objectMetadataItemsState.ts b/packages/twenty-front/src/modules/object-metadata/states/objectMetadataItemsState.ts
index 516a6440371..8d7ee619ea2 100644
--- a/packages/twenty-front/src/modules/object-metadata/states/objectMetadataItemsState.ts
+++ b/packages/twenty-front/src/modules/object-metadata/states/objectMetadataItemsState.ts
@@ -1,8 +1,7 @@
-import { atom } from 'recoil';
-
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const objectMetadataItemsState = atom<ObjectMetadataItem[]>({
+export const objectMetadataItemsState = createState<ObjectMetadataItem[]>({
key: 'objectMetadataItemsState',
- default: [],
+ defaultValue: [],
});
diff --git a/packages/twenty-front/src/modules/object-record/hooks/__tests__/useFindManyRecords.test.tsx b/packages/twenty-front/src/modules/object-record/hooks/__tests__/useFindManyRecords.test.tsx
index 480e74bab65..9da0f77fc28 100644
--- a/packages/twenty-front/src/modules/object-record/hooks/__tests__/useFindManyRecords.test.tsx
+++ b/packages/twenty-front/src/modules/object-record/hooks/__tests__/useFindManyRecords.test.tsx
@@ -57,7 +57,7 @@ describe('useFindManyRecords', () => {
const { result } = renderHook(
() => {
const setCurrentWorkspaceMember = useSetRecoilState(
- currentWorkspaceMemberState,
+ currentWorkspaceMemberState(),
);
setCurrentWorkspaceMember({
id: '32219445-f587-4c40-b2b1-6d3205ed96da',
@@ -67,7 +67,7 @@ describe('useFindManyRecords', () => {
const mockObjectMetadataItems = getObjectMetadataItemsMock();
- const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
+ const setMetadataItems = useSetRecoilState(objectMetadataItemsState());
setMetadataItems(mockObjectMetadataItems);
diff --git a/packages/twenty-front/src/modules/object-record/hooks/__tests__/useMapConnectionToRecords.test.tsx b/packages/twenty-front/src/modules/object-record/hooks/__tests__/useMapConnectionToRecords.test.tsx
index 9694cc6cee6..4cafb15a646 100644
--- a/packages/twenty-front/src/modules/object-record/hooks/__tests__/useMapConnectionToRecords.test.tsx
+++ b/packages/twenty-front/src/modules/object-record/hooks/__tests__/useMapConnectionToRecords.test.tsx
@@ -18,7 +18,7 @@ import { isNonNullable } from '~/utils/isNonNullable';
const Wrapper = getJestHookWrapper({
apolloMocks: [],
onInitializeRecoilSnapshot: (snapshot) => {
- snapshot.set(objectMetadataItemsState, getObjectMetadataItemsMock());
+ snapshot.set(objectMetadataItemsState(), getObjectMetadataItemsMock());
},
});
diff --git a/packages/twenty-front/src/modules/object-record/hooks/useFindManyRecords.ts b/packages/twenty-front/src/modules/object-record/hooks/useFindManyRecords.ts
index 22cbc2ec278..083e5396e82 100644
--- a/packages/twenty-front/src/modules/object-record/hooks/useFindManyRecords.ts
+++ b/packages/twenty-front/src/modules/object-record/hooks/useFindManyRecords.ts
@@ -69,7 +69,7 @@ export const useFindManyRecords = <T extends ObjectRecord = ObjectRecord>({
);
const { enqueueSnackBar } = useSnackBar();
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
const { data, loading, error, fetchMore } = useQuery<
ObjectRecordQueryResult<T>
diff --git a/packages/twenty-front/src/modules/object-record/hooks/useMapConnectionToRecords.ts b/packages/twenty-front/src/modules/object-record/hooks/useMapConnectionToRecords.ts
index 03b59984618..a73584a6196 100644
--- a/packages/twenty-front/src/modules/object-record/hooks/useMapConnectionToRecords.ts
+++ b/packages/twenty-front/src/modules/object-record/hooks/useMapConnectionToRecords.ts
@@ -11,7 +11,7 @@ import { FieldMetadataType } from '~/generated/graphql';
import { isNonNullable } from '~/utils/isNonNullable';
export const useMapConnectionToRecords = () => {
- const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
+ const objectMetadataItems = useRecoilValue(objectMetadataItemsState());
const mapConnectionToRecords = useCallback(
<T extends ObjectRecord>({
diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/scopes/scope-internal-context/ObjectFilterDropdownScopeInternalContext.ts b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/scopes/scope-internal-context/ObjectFilterDropdownScopeInternalContext.ts
index 30869a8a618..1c29844bd5f 100644
--- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/scopes/scope-internal-context/ObjectFilterDropdownScopeInternalContext.ts
+++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/scopes/scope-internal-context/ObjectFilterDropdownScopeInternalContext.ts
@@ -1,7 +1,7 @@
-import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
-type ObjectFilterDropdownScopeInternalContextProps = StateScopeMapKey;
+type ObjectFilterDropdownScopeInternalContextProps = ComponentStateKey;
export const ObjectFilterDropdownScopeInternalContext =
createScopeInternalContext<ObjectFilterDropdownScopeInternalContextProps>();
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 4ed3c9ce777..8433868e1b1 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
-export const availableFilterDefinitionsScopedState = createStateScopeMap<
+export const availableFilterDefinitionsScopedState = createComponentState<
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 1ee8f0b45d7..874d06a6305 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
import { FilterDefinition } from '../types/FilterDefinition';
export const filterDefinitionUsedInDropdownScopedState =
- createStateScopeMap<FilterDefinition | null>({
+ createComponentState<FilterDefinition | null>({
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 bec9fee84d3..5fc86fa8891 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
export const isObjectFilterDropdownOperandSelectUnfoldedScopedState =
- createStateScopeMap<boolean>({
+ createComponentState<boolean>({
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 432df347555..e07f31ca1b9 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
export const isObjectFilterDropdownUnfoldedScopedState =
- createStateScopeMap<boolean>({
+ createComponentState<boolean>({
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 b5cd0c1e43a..83c73842daa 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
export const objectFilterDropdownSearchInputScopedState =
- createStateScopeMap<string>({
+ createComponentState<string>({
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 a96a2c5e94e..9eba05a6b79 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
export const objectFilterDropdownSelectedEntityIdScopedState =
- createStateScopeMap<string | null>({
+ createComponentState<string | null>({
key: 'objectFilterDropdownSelectedEntityIdScopedState',
defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/objectFilterDropdownSelectedOptionValuesScopedState.ts b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/objectFilterDropdownSelectedOptionValuesScopedState.ts
index 372da4c5d6c..db1124959fc 100644
--- a/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/objectFilterDropdownSelectedOptionValuesScopedState.ts
+++ b/packages/twenty-front/src/modules/object-record/object-filter-dropdown/states/objectFilterDropdownSelectedOptionValuesScopedState.ts
@@ -1,7 +1,7 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
export const objectFilterDropdownSelectedOptionValuesScopedState =
- createStateScopeMap<string[]>({
+ createComponentState<string[]>({
key: 'objectFilterDropdownSelectedOptionValuesScopedState',
defaultValue: [],
});
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 10c1dab0b6a..e5e1b396c0d 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
export const objectFilterDropdownSelectedRecordIdsScopedState =
- createStateScopeMap<string[]>({
+ createComponentState<string[]>({
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 04c2199ce92..43a90fa7aa4 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
import { Filter } from '../types/Filter';
-export const onFilterSelectScopedState = createStateScopeMap<
+export const onFilterSelectScopedState = createComponentState<
((filter: Filter | null) => 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 7e45134475f..c9df2abcea3 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,8 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
import { Filter } from '../types/Filter';
-export const selectedFilterScopedState = createStateScopeMap<
+export const selectedFilterScopedState = createComponentState<
Filter | undefined | null
>({
key: 'selectedFilterScopedState',
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 2cb8e270c6b..087ac6d07f4 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
import { ViewFilterOperand } from '@/views/types/ViewFilterOperand';
export const selectedOperandInDropdownScopedState =
- createStateScopeMap<ViewFilterOperand | null>({
+ createComponentState<ViewFilterOperand | null>({
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 45a636d5fcb..8454813f3d8 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 { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
import { Sort } from '../../types/Sort';
-type ObjectSortDropdownScopeInternalContextProps = StateScopeMapKey & {
+type ObjectSortDropdownScopeInternalContextProps = ComponentStateKey & {
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 27da40c6b74..3f8165b63d5 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
import { SortDefinition } from '../types/SortDefinition';
-export const availableSortDefinitionsScopedState = createStateScopeMap<
+export const availableSortDefinitionsScopedState = createComponentState<
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 02514a4c4d4..071d662741c 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
-export const isSortSelectedScopedState = createStateScopeMap<boolean>({
+export const isSortSelectedScopedState = createComponentState<boolean>({
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 0b76031e6ab..9e066172296 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
import { Sort } from '../types/Sort';
-export const onSortSelectScopedState = createStateScopeMap<
+export const onSortSelectScopedState = createComponentState<
((sort: Sort) => void) | undefined
>({
key: 'onSortSelectScopedState',
diff --git a/packages/twenty-front/src/modules/object-record/record-action-bar/hooks/useRecordActionBar.tsx b/packages/twenty-front/src/modules/object-record/record-action-bar/hooks/useRecordActionBar.tsx
index 3d7c972632b..591b2df404a 100644
--- a/packages/twenty-front/src/modules/object-record/record-action-bar/hooks/useRecordActionBar.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-action-bar/hooks/useRecordActionBar.tsx
@@ -32,8 +32,8 @@ export const useRecordActionBar = ({
selectedRecordIds,
callback,
}: useRecordActionBarProps) => {
- const setContextMenuEntries = useSetRecoilState(contextMenuEntriesState);
- const setActionBarEntriesState = useSetRecoilState(actionBarEntriesState);
+ const setContextMenuEntries = useSetRecoilState(contextMenuEntriesState());
+ const setActionBarEntriesState = useSetRecoilState(actionBarEntriesState());
const { createFavorite, favorites, deleteFavorite } = useFavorites();
diff --git a/packages/twenty-front/src/modules/object-record/record-board/hooks/internal/useRecordBoardStates.ts b/packages/twenty-front/src/modules/object-record/record-board/hooks/internal/useRecordBoardStates.ts
index 291db2655e4..cd5b2cf3141 100644
--- a/packages/twenty-front/src/modules/object-record/record-board/hooks/internal/useRecordBoardStates.ts
+++ b/packages/twenty-front/src/modules/object-record/record-board/hooks/internal/useRecordBoardStates.ts
@@ -1,24 +1,24 @@
import { RecordBoardScopeInternalContext } from '@/object-record/record-board/scopes/scope-internal-context/RecordBoardScopeInternalContext';
-import { isFirstRecordBoardColumnFamilyStateScopeMap } from '@/object-record/record-board/states/isFirstRecordBoardColumnFamilyStateScopeMap';
-import { isLastRecordBoardColumnFamilyStateScopeMap } from '@/object-record/record-board/states/isLastRecordBoardColumnFamilyStateScopeMap';
-import { isRecordBoardCardSelectedFamilyStateScopeMap } from '@/object-record/record-board/states/isRecordBoardCardSelectedFamilyStateScopeMap';
-import { isRecordBoardCompactModeActiveStateScopeMap } from '@/object-record/record-board/states/isRecordBoardCompactModeActiveStateScopeMap';
-import { isRecordBoardFetchingRecordsStateScopeMap } from '@/object-record/record-board/states/isRecordBoardFetchingRecordsStateScopeMap';
-import { onRecordBoardFetchMoreVisibilityChangeStateScopeMap } from '@/object-record/record-board/states/onRecordBoardFetchMoreVisibilityChangeStateScopeMap';
-import { recordBoardColumnIdsStateScopeMap } from '@/object-record/record-board/states/recordBoardColumnIdsStateScopeMap';
-import { recordBoardFieldDefinitionsStateScopeMap } from '@/object-record/record-board/states/recordBoardFieldDefinitionsStateScopeMap';
-import { recordBoardFiltersStateScopeMap } from '@/object-record/record-board/states/recordBoardFiltersStateScopeMap';
-import { recordBoardObjectSingularNameStateScopeMap } from '@/object-record/record-board/states/recordBoardObjectSingularNameStateScopeMap';
-import { recordBoardRecordIdsByColumnIdFamilyStateScopeMap } from '@/object-record/record-board/states/recordBoardRecordIdsByColumnIdFamilyStateScopeMap';
-import { recordBoardSortsStateScopeMap } from '@/object-record/record-board/states/recordBoardSortsStateScopeMap';
-import { recordBoardColumnsFamilySelectorScopeMap } from '@/object-record/record-board/states/selectors/recordBoardColumnsFamilySelectorScopeMap';
-import { recordBoardSelectedRecordIdsSelectorScopeMap } from '@/object-record/record-board/states/selectors/recordBoardSelectedRecordIdsSelectorScopeMap';
-import { recordBoardVisibleFieldDefinitionsScopedSelector } from '@/object-record/record-board/states/selectors/recordBoardVisibleFieldDefinitionsScopedSelector';
+import { isFirstRecordBoardColumnComponentFamilyState } from '@/object-record/record-board/states/isFirstRecordBoardColumnComponentFamilyState';
+import { isLastRecordBoardColumnComponentFamilyState } from '@/object-record/record-board/states/isLastRecordBoardColumnComponentFamilyState';
+import { isRecordBoardCardSelectedComponentFamilyState } from '@/object-record/record-board/states/isRecordBoardCardSelectedComponentFamilyState';
+import { isRecordBoardCompactModeActiveComponentState } from '@/object-record/record-board/states/isRecordBoardCompactModeActiveComponentState';
+import { isRecordBoardFetchingRecordsComponentState } from '@/object-record/record-board/states/isRecordBoardFetchingRecordsComponentState';
+import { onRecordBoardFetchMoreVisibilityChangeComponentState } from '@/object-record/record-board/states/onRecordBoardFetchMoreVisibilityChangeComponentState';
+import { recordBoardColumnIdsComponentState } from '@/object-record/record-board/states/recordBoardColumnIdsComponentState';
+import { recordBoardFieldDefinitionsComponentState } from '@/object-record/record-board/states/recordBoardFieldDefinitionsComponentState';
+import { recordBoardFiltersComponentState } from '@/object-record/record-board/states/recordBoardFiltersComponentState';
+import { recordBoardObjectSingularNameComponentState } from '@/object-record/record-board/states/recordBoardObjectSingularNameComponentState';
+import { recordBoardRecordIdsByColumnIdComponentFamilyState } from '@/object-record/record-board/states/recordBoardRecordIdsByColumnIdComponentFamilyState';
+import { recordBoardSortsComponentState } from '@/object-record/record-board/states/recordBoardSortsComponentState';
+import { recordBoardColumnsComponentFamilySelector } from '@/object-record/record-board/states/selectors/recordBoardColumnsComponentFamilySelector';
+import { recordBoardSelectedRecordIdsComponentSelector } from '@/object-record/record-board/states/selectors/recordBoardSelectedRecordIdsComponentSelector';
+import { recordBoardVisibleFieldDefinitionsComponentSelector } from '@/object-record/record-board/states/selectors/recordBoardVisibleFieldDefinitionsComponentSelector';
import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';
-import { getFamilyState } from '@/ui/utilities/recoil-scope/utils/getFamilyState';
import { getScopeIdOrUndefinedFromComponentId } from '@/ui/utilities/recoil-scope/utils/getScopeIdOrUndefinedFromComponentId';
-import { getSelectorReadOnly } from '@/ui/utilities/recoil-scope/utils/getSelectorReadOnly';
-import { getState } from '@/ui/utilities/recoil-scope/utils/getState';
+import { extractComponentFamilyState } from '@/ui/utilities/state/component-state/utils/extractComponentFamilyState';
+import { extractComponentReadOnlySelector } from '@/ui/utilities/state/component-state/utils/extractComponentReadOnlySelector';
+import { extractComponentState } from '@/ui/utilities/state/component-state/utils/extractComponentState';
export const useRecordBoardStates = (recordBoardId?: string) => {
const scopeId = useAvailableScopeIdOrThrow(
@@ -28,59 +28,68 @@ export const useRecordBoardStates = (recordBoardId?: string) => {
return {
scopeId,
- getObjectSingularNameState: getState(
- recordBoardObjectSingularNameStateScopeMap,
+ getObjectSingularNameState: extractComponentState(
+ recordBoardObjectSingularNameComponentState,
scopeId,
),
- getIsFetchingRecordState: getState(
- isRecordBoardFetchingRecordsStateScopeMap,
+ getIsFetchingRecordState: extractComponentState(
+ isRecordBoardFetchingRecordsComponentState,
scopeId,
),
- getColumnIdsState: getState(recordBoardColumnIdsStateScopeMap, scopeId),
- isFirstColumnFamilyState: getFamilyState(
- isFirstRecordBoardColumnFamilyStateScopeMap,
+ getColumnIdsState: extractComponentState(
+ recordBoardColumnIdsComponentState,
scopeId,
),
- isLastColumnFamilyState: getFamilyState(
- isLastRecordBoardColumnFamilyStateScopeMap,
+ isFirstColumnFamilyState: extractComponentFamilyState(
+ isFirstRecordBoardColumnComponentFamilyState,
scopeId,
),
- columnsFamilySelector: getFamilyState(
- recordBoardColumnsFamilySelectorScopeMap,
+ isLastColumnFamilyState: extractComponentFamilyState(
+ isLastRecordBoardColumnComponentFamilyState,
+ scopeId,
+ ),
+ columnsFamilySelector: extractComponentFamilyState(
+ recordBoardColumnsComponentFamilySelector,
scopeId,
),
- getFiltersState: getState(recordBoardFiltersStateScopeMap, scopeId),
- getSortsState: getState(recordBoardSortsStateScopeMap, scopeId),
- getFieldDefinitionsState: getState(
- recordBoardFieldDefinitionsStateScopeMap,
+ getFiltersState: extractComponentState(
+ recordBoardFiltersComponentState,
+ scopeId,
+ ),
+ getSortsState: extractComponentState(
+ recordBoardSortsComponentState,
+ scopeId,
+ ),
+ getFieldDefinitionsState: extractComponentState(
+ recordBoardFieldDefinitionsComponentState,
scopeId,
),
- getVisibleFieldDefinitionsState: getSelectorReadOnly(
- recordBoardVisibleFieldDefinitionsScopedSelector,
+ getVisibleFieldDefinitionsState: extractComponentReadOnlySelector(
+ recordBoardVisibleFieldDefinitionsComponentSelector,
scopeId,
),
- recordIdsByColumnIdFamilyState: getFamilyState(
- recordBoardRecordIdsByColumnIdFamilyStateScopeMap,
+ recordIdsByColumnIdFamilyState: extractComponentFamilyState(
+ recordBoardRecordIdsByColumnIdComponentFamilyState,
scopeId,
),
- isRecordBoardCardSelectedFamilyState: getFamilyState(
- isRecordBoardCardSelectedFamilyStateScopeMap,
+ isRecordBoardCardSelectedFamilyState: extractComponentFamilyState(
+ isRecordBoardCardSelectedComponentFamilyState,
scopeId,
),
- getSelectedRecordIdsSelector: getSelectorReadOnly(
- recordBoardSelectedRecordIdsSelectorScopeMap,
+ getSelectedRecordIdsSelector: extractComponentReadOnlySelector(
+ recordBoardSelectedRecordIdsComponentSelector,
scopeId,
),
- getIsCompactModeActiveState: getState(
- isRecordBoardCompactModeActiveStateScopeMap,
+ getIsCompactModeActiveState: extractComponentState(
+ isRecordBoardCompactModeActiveComponentState,
scopeId,
),
- getOnFetchMoreVisibilityChangeState: getState(
- onRecordBoardFetchMoreVisibilityChangeStateScopeMap,
+ getOnFetchMoreVisibilityChangeState: extractComponentState(
+ onRecordBoardFetchMoreVisibilityChangeComponentState,
scopeId,
),
};
diff --git a/packages/twenty-front/src/modules/object-record/record-board/record-board-card/components/RecordBoardCard.tsx b/packages/twenty-front/src/modules/object-record/record-board/record-board-card/components/RecordBoardCard.tsx
index 15f2424e97c..03446687371 100644
--- a/packages/twenty-front/src/modules/object-record/record-board/record-board-card/components/RecordBoardCard.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-board/record-board-card/components/RecordBoardCard.tsx
@@ -152,8 +152,8 @@ export const RecordBoardCard = () => {
const record = useRecoilValue(recordStoreFamilyState(recordId));
- const setContextMenuPosition = useSetRecoilState(contextMenuPositionState);
- const setContextMenuOpenState = useSetRecoilState(contextMenuIsOpenState);
+ const setContextMenuPosition = useSetRecoilState(contextMenuPositionState());
+ const setContextMenuOpenState = useSetRecoilState(contextMenuIsOpenState());
const handleContextMenu = (event: React.MouseEvent) => {
event.preventDefault();
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 03da78cce76..22aeae0edc3 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,10 +1,10 @@
import { RecordBoardColumnDefinition } from '@/object-record/record-board/types/RecordBoardColumnDefinition';
import { FieldDefinition } from '@/object-record/record-field/types/FieldDefinition';
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
-import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
-type RecordBoardScopeInternalContextProps = StateScopeMapKey & {
+type RecordBoardScopeInternalContextProps = ComponentStateKey & {
onFieldsChange: (fields: FieldDefinition<FieldMetadata>[]) => void;
onColumnsChange: (column: RecordBoardColumnDefinition[]) => void;
};
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/isFirstRecordBoardColumnComponentFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/isFirstRecordBoardColumnComponentFamilyState.ts
new file mode 100644
index 00000000000..bef4219700d
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-board/states/isFirstRecordBoardColumnComponentFamilyState.ts
@@ -0,0 +1,7 @@
+import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
+
+export const isFirstRecordBoardColumnComponentFamilyState =
+ createComponentFamilyState<boolean, string>({
+ key: 'isFirstRecordBoardColumnComponentFamilyState',
+ defaultValue: false,
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/isFirstRecordBoardColumnFamilyStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-board/states/isFirstRecordBoardColumnFamilyStateScopeMap.ts
deleted file mode 100644
index 989f3277b8c..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-board/states/isFirstRecordBoardColumnFamilyStateScopeMap.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
-
-export const isFirstRecordBoardColumnFamilyStateScopeMap =
- createFamilyStateScopeMap<boolean, string>({
- key: 'isFirstRecordBoardColumnFamilyStateScopeMap',
- defaultValue: false,
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/isLastRecordBoardColumnComponentFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/isLastRecordBoardColumnComponentFamilyState.ts
new file mode 100644
index 00000000000..9174fba1cac
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-board/states/isLastRecordBoardColumnComponentFamilyState.ts
@@ -0,0 +1,7 @@
+import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
+
+export const isLastRecordBoardColumnComponentFamilyState =
+ createComponentFamilyState<boolean, string>({
+ key: 'isLastRecordBoardColumnComponentFamilyState',
+ defaultValue: false,
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/isLastRecordBoardColumnFamilyStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-board/states/isLastRecordBoardColumnFamilyStateScopeMap.ts
deleted file mode 100644
index b29e9ecaeb4..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-board/states/isLastRecordBoardColumnFamilyStateScopeMap.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
-
-export const isLastRecordBoardColumnFamilyStateScopeMap =
- createFamilyStateScopeMap<boolean, string>({
- key: 'isLastRecordBoardColumnFamilyStateScopeMap',
- defaultValue: false,
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardCardSelectedComponentFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardCardSelectedComponentFamilyState.ts
new file mode 100644
index 00000000000..8cb7c99f495
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardCardSelectedComponentFamilyState.ts
@@ -0,0 +1,7 @@
+import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
+
+export const isRecordBoardCardSelectedComponentFamilyState =
+ createComponentFamilyState<boolean, string>({
+ key: 'isRecordBoardCardSelectedComponentFamilyState',
+ defaultValue: false,
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardCardSelectedFamilyStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardCardSelectedFamilyStateScopeMap.ts
deleted file mode 100644
index 825e46ed3ca..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardCardSelectedFamilyStateScopeMap.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
-
-export const isRecordBoardCardSelectedFamilyStateScopeMap =
- createFamilyStateScopeMap<boolean, string>({
- key: 'isRecordBoardCardSelectedFamilyStateScopeMap',
- defaultValue: false,
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardCompactModeActiveComponentState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardCompactModeActiveComponentState.ts
new file mode 100644
index 00000000000..68741ee81a9
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardCompactModeActiveComponentState.ts
@@ -0,0 +1,7 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const isRecordBoardCompactModeActiveComponentState =
+ createComponentState<boolean>({
+ key: 'isRecordBoardCompactModeActiveComponentState',
+ defaultValue: false,
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardCompactModeActiveStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardCompactModeActiveStateScopeMap.ts
deleted file mode 100644
index 0ad51b9a984..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardCompactModeActiveStateScopeMap.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const isRecordBoardCompactModeActiveStateScopeMap =
- createStateScopeMap<boolean>({
- key: 'isRecordBoardCompactModeActiveStateScopeMap',
- defaultValue: false,
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardFetchingRecordsComponentState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardFetchingRecordsComponentState.ts
new file mode 100644
index 00000000000..c76a8777e32
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardFetchingRecordsComponentState.ts
@@ -0,0 +1,7 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const isRecordBoardFetchingRecordsComponentState =
+ createComponentState<boolean>({
+ key: 'isRecordBoardFetchingRecordsComponentState',
+ defaultValue: false,
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardFetchingRecordsStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardFetchingRecordsStateScopeMap.ts
deleted file mode 100644
index 83c35a4be90..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-board/states/isRecordBoardFetchingRecordsStateScopeMap.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const isRecordBoardFetchingRecordsStateScopeMap =
- createStateScopeMap<boolean>({
- key: 'isRecordBoardFetchingRecordsStateScopeMap',
- defaultValue: false,
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/onRecordBoardFetchMoreVisibilityChangeComponentState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/onRecordBoardFetchMoreVisibilityChangeComponentState.ts
new file mode 100644
index 00000000000..c977c8851b4
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-board/states/onRecordBoardFetchMoreVisibilityChangeComponentState.ts
@@ -0,0 +1,7 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const onRecordBoardFetchMoreVisibilityChangeComponentState =
+ createComponentState<(visbility: boolean) => void>({
+ key: 'onRecordBoardFetchMoreVisibilityChangeComponentState',
+ defaultValue: () => {},
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/onRecordBoardFetchMoreVisibilityChangeStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-board/states/onRecordBoardFetchMoreVisibilityChangeStateScopeMap.ts
deleted file mode 100644
index fb5da620aa7..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-board/states/onRecordBoardFetchMoreVisibilityChangeStateScopeMap.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const onRecordBoardFetchMoreVisibilityChangeStateScopeMap =
- createStateScopeMap<(visbility: boolean) => void>({
- key: 'onRecordBoardFetchMoreVisibilityChangeStateScopeMap',
- defaultValue: () => {},
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardColumnIdsComponentState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardColumnIdsComponentState.ts
new file mode 100644
index 00000000000..3ae094376c2
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardColumnIdsComponentState.ts
@@ -0,0 +1,8 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const recordBoardColumnIdsComponentState = createComponentState<
+ string[]
+>({
+ key: 'recordBoardColumnIdsComponentState',
+ defaultValue: [],
+});
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardColumnIdsStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardColumnIdsStateScopeMap.ts
deleted file mode 100644
index 82118caf348..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardColumnIdsStateScopeMap.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const recordBoardColumnIdsStateScopeMap = createStateScopeMap<string[]>({
- key: 'recordBoardColumnIdsStateScopeMap',
- defaultValue: [],
-});
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardColumnsComponentFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardColumnsComponentFamilyState.ts
new file mode 100644
index 00000000000..c2b6cc1cfe5
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardColumnsComponentFamilyState.ts
@@ -0,0 +1,8 @@
+import { RecordBoardColumnDefinition } from '@/object-record/record-board/types/RecordBoardColumnDefinition';
+import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
+
+export const recordBoardColumnsComponentFamilyState =
+ createComponentFamilyState<RecordBoardColumnDefinition | undefined, string>({
+ key: 'recordBoardColumnsComponentFamilyState',
+ defaultValue: undefined,
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardColumnsFamilyStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardColumnsFamilyStateScopeMap.ts
deleted file mode 100644
index aca09ce52f7..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardColumnsFamilyStateScopeMap.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { RecordBoardColumnDefinition } from '@/object-record/record-board/types/RecordBoardColumnDefinition';
-import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
-
-export const recordBoardColumnsFamilyStateScopeMap = createFamilyStateScopeMap<
- RecordBoardColumnDefinition | undefined,
- string
->({
- key: 'recordBoardColumnsFamilyStateScopeMap',
- defaultValue: undefined,
-});
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardFieldDefinitionsStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardFieldDefinitionsComponentState.ts
similarity index 53%
rename from packages/twenty-front/src/modules/object-record/record-board/states/recordBoardFieldDefinitionsStateScopeMap.ts
rename to packages/twenty-front/src/modules/object-record/record-board/states/recordBoardFieldDefinitionsComponentState.ts
index 4248350bceb..e8fb862be66 100644
--- a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardFieldDefinitionsStateScopeMap.ts
+++ b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardFieldDefinitionsComponentState.ts
@@ -1,10 +1,10 @@
import { RecordBoardFieldDefinition } from '@/object-record/record-board/types/RecordBoardFieldDefinition';
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
-export const recordBoardFieldDefinitionsStateScopeMap = createStateScopeMap<
+export const recordBoardFieldDefinitionsComponentState = createComponentState<
RecordBoardFieldDefinition<FieldMetadata>[]
>({
- key: 'recordBoardFieldDefinitionsStateScopeMap',
+ key: 'recordBoardFieldDefinitionsComponentState',
defaultValue: [],
});
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardFiltersComponentState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardFiltersComponentState.ts
new file mode 100644
index 00000000000..7d493b349e5
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardFiltersComponentState.ts
@@ -0,0 +1,7 @@
+import { Filter } from '@/object-record/object-filter-dropdown/types/Filter';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const recordBoardFiltersComponentState = createComponentState<Filter[]>({
+ key: 'recordBoardFiltersComponentState',
+ defaultValue: [],
+});
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardFiltersStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardFiltersStateScopeMap.ts
deleted file mode 100644
index 71c8528ceb7..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardFiltersStateScopeMap.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { Filter } from '@/object-record/object-filter-dropdown/types/Filter';
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const recordBoardFiltersStateScopeMap = createStateScopeMap<Filter[]>({
- key: 'recordBoardFiltersStateScopeMap',
- defaultValue: [],
-});
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardObjectSingularNameComponentState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardObjectSingularNameComponentState.ts
new file mode 100644
index 00000000000..b3efddfd765
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardObjectSingularNameComponentState.ts
@@ -0,0 +1,8 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const recordBoardObjectSingularNameComponentState = createComponentState<
+ string | undefined
+>({
+ key: 'recordBoardObjectSingularNameComponentState',
+ defaultValue: undefined,
+});
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardObjectSingularNameStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardObjectSingularNameStateScopeMap.ts
deleted file mode 100644
index fd35c826a24..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardObjectSingularNameStateScopeMap.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const recordBoardObjectSingularNameStateScopeMap = createStateScopeMap<
- string | undefined
->({
- key: 'recordBoardObjectSingularNameStateScopeMap',
- defaultValue: undefined,
-});
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardRecordIdsByColumnIdComponentFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardRecordIdsByColumnIdComponentFamilyState.ts
new file mode 100644
index 00000000000..9cb2f0df334
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardRecordIdsByColumnIdComponentFamilyState.ts
@@ -0,0 +1,7 @@
+import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
+
+export const recordBoardRecordIdsByColumnIdComponentFamilyState =
+ createComponentFamilyState<string[], string>({
+ key: 'recordBoardRecordIdsByColumnIdComponentFamilyState',
+ defaultValue: [],
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardRecordIdsByColumnIdFamilyStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardRecordIdsByColumnIdFamilyStateScopeMap.ts
deleted file mode 100644
index 8a413e0b5de..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardRecordIdsByColumnIdFamilyStateScopeMap.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
-
-export const recordBoardRecordIdsByColumnIdFamilyStateScopeMap =
- createFamilyStateScopeMap<string[], string>({
- key: 'recordBoardRecordIdsByColumnIdFamilyStateScopeMap',
- defaultValue: [],
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardSortsComponentState.ts b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardSortsComponentState.ts
new file mode 100644
index 00000000000..d2aa0923f33
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardSortsComponentState.ts
@@ -0,0 +1,7 @@
+import { Sort } from '@/object-record/object-sort-dropdown/types/Sort';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const recordBoardSortsComponentState = createComponentState<Sort[]>({
+ key: 'recordBoardSortsComponentState',
+ defaultValue: [],
+});
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardSortsStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardSortsStateScopeMap.ts
deleted file mode 100644
index b49376153a4..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-board/states/recordBoardSortsStateScopeMap.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { Sort } from '@/object-record/object-sort-dropdown/types/Sort';
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const recordBoardSortsStateScopeMap = createStateScopeMap<Sort[]>({
- key: 'recordBoardSortsStateScopeMap',
- defaultValue: [],
-});
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardColumnsComponentFamilySelector.ts b/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardColumnsComponentFamilySelector.ts
new file mode 100644
index 00000000000..3c10cb0a01d
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardColumnsComponentFamilySelector.ts
@@ -0,0 +1,118 @@
+import { isUndefined } from '@sniptt/guards';
+
+import { isFirstRecordBoardColumnComponentFamilyState } from '@/object-record/record-board/states/isFirstRecordBoardColumnComponentFamilyState';
+import { isLastRecordBoardColumnComponentFamilyState } from '@/object-record/record-board/states/isLastRecordBoardColumnComponentFamilyState';
+import { recordBoardColumnIdsComponentState } from '@/object-record/record-board/states/recordBoardColumnIdsComponentState';
+import { recordBoardColumnsComponentFamilyState } from '@/object-record/record-board/states/recordBoardColumnsComponentFamilyState';
+import { RecordBoardColumnDefinition } from '@/object-record/record-board/types/RecordBoardColumnDefinition';
+import { guardRecoilDefaultValue } from '@/ui/utilities/recoil-scope/utils/guardRecoilDefaultValue';
+import { createComponentFamilySelector } from '@/ui/utilities/state/component-state/utils/createComponentFamilySelector';
+import { isNonNullable } from '~/utils/isNonNullable';
+
+export const recordBoardColumnsComponentFamilySelector =
+ createComponentFamilySelector<
+ RecordBoardColumnDefinition | undefined,
+ string
+ >({
+ key: 'recordBoardColumnsComponentFamilySelector',
+ get:
+ ({
+ scopeId,
+ familyKey: columnId,
+ }: {
+ scopeId: string;
+ familyKey: string;
+ }) =>
+ ({ get }) => {
+ return get(
+ recordBoardColumnsComponentFamilyState({
+ scopeId,
+ familyKey: columnId,
+ }),
+ );
+ },
+ set:
+ ({
+ scopeId,
+ familyKey: columnId,
+ }: {
+ scopeId: string;
+ familyKey: string;
+ }) =>
+ ({ set, get }, newColumn) => {
+ set(
+ recordBoardColumnsComponentFamilyState({
+ scopeId,
+ familyKey: columnId,
+ }),
+ newColumn,
+ );
+
+ if (guardRecoilDefaultValue(newColumn)) return;
+
+ const columnIds = get(recordBoardColumnIdsComponentState({ scopeId }));
+
+ const columns = columnIds
+ .map((columnId) => {
+ return get(
+ recordBoardColumnsComponentFamilyState({
+ scopeId,
+ familyKey: columnId,
+ }),
+ );
+ })
+ .filter(isNonNullable);
+
+ const lastColumn = [...columns].sort(
+ (a, b) => b.position - a.position,
+ )[0];
+
+ const firstColumn = [...columns].sort(
+ (a, b) => a.position - b.position,
+ )[0];
+
+ if (!newColumn) {
+ return;
+ }
+
+ if (!lastColumn || newColumn.position > lastColumn.position) {
+ set(
+ isLastRecordBoardColumnComponentFamilyState({
+ scopeId,
+ familyKey: columnId,
+ }),
+ true,
+ );
+
+ if (!isUndefined(lastColumn)) {
+ set(
+ isLastRecordBoardColumnComponentFamilyState({
+ scopeId,
+ familyKey: lastColumn.id,
+ }),
+ false,
+ );
+ }
+ }
+
+ if (!firstColumn || newColumn.position < firstColumn.position) {
+ set(
+ isFirstRecordBoardColumnComponentFamilyState({
+ scopeId,
+ familyKey: columnId,
+ }),
+ true,
+ );
+
+ if (!isUndefined(firstColumn)) {
+ set(
+ isFirstRecordBoardColumnComponentFamilyState({
+ scopeId,
+ familyKey: firstColumn.id,
+ }),
+ false,
+ );
+ }
+ }
+ },
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardColumnsFamilySelectorScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardColumnsFamilySelectorScopeMap.ts
deleted file mode 100644
index 007734fe990..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardColumnsFamilySelectorScopeMap.ts
+++ /dev/null
@@ -1,115 +0,0 @@
-import { isFirstRecordBoardColumnFamilyStateScopeMap } from '@/object-record/record-board/states/isFirstRecordBoardColumnFamilyStateScopeMap';
-import { isLastRecordBoardColumnFamilyStateScopeMap } from '@/object-record/record-board/states/isLastRecordBoardColumnFamilyStateScopeMap';
-import { recordBoardColumnIdsStateScopeMap } from '@/object-record/record-board/states/recordBoardColumnIdsStateScopeMap';
-import { recordBoardColumnsFamilyStateScopeMap } from '@/object-record/record-board/states/recordBoardColumnsFamilyStateScopeMap';
-import { RecordBoardColumnDefinition } from '@/object-record/record-board/types/RecordBoardColumnDefinition';
-import { createFamilySelectorScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilySelectorScopeMap';
-import { guardRecoilDefaultValue } from '@/ui/utilities/recoil-scope/utils/guardRecoilDefaultValue';
-import { isNonNullable } from '~/utils/isNonNullable';
-
-export const recordBoardColumnsFamilySelectorScopeMap =
- createFamilySelectorScopeMap<RecordBoardColumnDefinition | undefined, string>(
- {
- key: 'recordBoardColumnsFamilySelectorScopeMap',
- get:
- ({
- scopeId,
- familyKey: columnId,
- }: {
- scopeId: string;
- familyKey: string;
- }) =>
- ({ get }) => {
- return get(
- recordBoardColumnsFamilyStateScopeMap({
- scopeId,
- familyKey: columnId,
- }),
- );
- },
- set:
- ({
- scopeId,
- familyKey: columnId,
- }: {
- scopeId: string;
- familyKey: string;
- }) =>
- ({ set, get }, newColumn) => {
- set(
- recordBoardColumnsFamilyStateScopeMap({
- scopeId,
- familyKey: columnId,
- }),
- newColumn,
- );
-
- if (guardRecoilDefaultValue(newColumn)) return;
-
- const columnIds = get(recordBoardColumnIdsStateScopeMap({ scopeId }));
-
- const columns = columnIds
- .map((columnId) => {
- return get(
- recordBoardColumnsFamilyStateScopeMap({
- scopeId,
- familyKey: columnId,
- }),
- );
- })
- .filter(isNonNullable);
-
- const lastColumn = [...columns].sort(
- (a, b) => b.position - a.position,
- )[0];
-
- const firstColumn = [...columns].sort(
- (a, b) => a.position - b.position,
- )[0];
-
- if (!newColumn) {
- return;
- }
-
- if (!lastColumn || newColumn.position > lastColumn.position) {
- set(
- isLastRecordBoardColumnFamilyStateScopeMap({
- scopeId,
- familyKey: columnId,
- }),
- true,
- );
-
- if (isNonNullable(lastColumn)) {
- set(
- isLastRecordBoardColumnFamilyStateScopeMap({
- scopeId,
- familyKey: lastColumn.id,
- }),
- false,
- );
- }
- }
-
- if (!firstColumn || newColumn.position < firstColumn.position) {
- set(
- isFirstRecordBoardColumnFamilyStateScopeMap({
- scopeId,
- familyKey: columnId,
- }),
- true,
- );
-
- if (isNonNullable(firstColumn)) {
- set(
- isFirstRecordBoardColumnFamilyStateScopeMap({
- scopeId,
- familyKey: firstColumn.id,
- }),
- false,
- );
- }
- }
- },
- },
- );
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardSelectedRecordIdsComponentSelector.ts b/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardSelectedRecordIdsComponentSelector.ts
new file mode 100644
index 00000000000..ce2b1e4cac4
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardSelectedRecordIdsComponentSelector.ts
@@ -0,0 +1,35 @@
+import { isRecordBoardCardSelectedComponentFamilyState } from '@/object-record/record-board/states/isRecordBoardCardSelectedComponentFamilyState';
+import { recordBoardColumnIdsComponentState } from '@/object-record/record-board/states/recordBoardColumnIdsComponentState';
+import { recordBoardRecordIdsByColumnIdComponentFamilyState } from '@/object-record/record-board/states/recordBoardRecordIdsByColumnIdComponentFamilyState';
+import { createComponentReadOnlySelector } from '@/ui/utilities/state/component-state/utils/createComponentReadOnlySelector';
+
+export const recordBoardSelectedRecordIdsComponentSelector =
+ createComponentReadOnlySelector<string[]>({
+ key: 'recordBoardSelectedRecordIdsSelector',
+ get:
+ ({ scopeId }) =>
+ ({ get }) => {
+ const columnIds = get(recordBoardColumnIdsComponentState({ scopeId }));
+
+ const recordIdsByColumn = columnIds.map((columnId) =>
+ get(
+ recordBoardRecordIdsByColumnIdComponentFamilyState({
+ scopeId,
+ familyKey: columnId,
+ }),
+ ),
+ );
+
+ const recordIds = recordIdsByColumn.flat();
+
+ return recordIds.filter(
+ (recordId) =>
+ get(
+ isRecordBoardCardSelectedComponentFamilyState({
+ scopeId,
+ familyKey: recordId,
+ }),
+ ) === true,
+ );
+ },
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardSelectedRecordIdsSelectorScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardSelectedRecordIdsSelectorScopeMap.ts
deleted file mode 100644
index 437fcfa5636..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardSelectedRecordIdsSelectorScopeMap.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { isRecordBoardCardSelectedFamilyStateScopeMap } from '@/object-record/record-board/states/isRecordBoardCardSelectedFamilyStateScopeMap';
-import { recordBoardColumnIdsStateScopeMap } from '@/object-record/record-board/states/recordBoardColumnIdsStateScopeMap';
-import { recordBoardRecordIdsByColumnIdFamilyStateScopeMap } from '@/object-record/record-board/states/recordBoardRecordIdsByColumnIdFamilyStateScopeMap';
-import { createSelectorReadOnlyScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorReadOnlyScopeMap';
-
-export const recordBoardSelectedRecordIdsSelectorScopeMap =
- createSelectorReadOnlyScopeMap<string[]>({
- key: 'recordBoardSelectedRecordIdsSelectorScopeMap',
- get:
- ({ scopeId }) =>
- ({ get }) => {
- const columnIds = get(recordBoardColumnIdsStateScopeMap({ scopeId }));
-
- const recordIdsByColumn = columnIds.map((columnId) =>
- get(
- recordBoardRecordIdsByColumnIdFamilyStateScopeMap({
- scopeId,
- familyKey: columnId,
- }),
- ),
- );
-
- const recordIds = recordIdsByColumn.flat();
-
- return recordIds.filter(
- (recordId) =>
- get(
- isRecordBoardCardSelectedFamilyStateScopeMap({
- scopeId,
- familyKey: recordId,
- }),
- ) === true,
- );
- },
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardVisibleFieldDefinitionsComponentSelector.ts b/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardVisibleFieldDefinitionsComponentSelector.ts
new file mode 100644
index 00000000000..4b2732eb36d
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardVisibleFieldDefinitionsComponentSelector.ts
@@ -0,0 +1,13 @@
+import { recordBoardFieldDefinitionsComponentState } from '@/object-record/record-board/states/recordBoardFieldDefinitionsComponentState';
+import { createComponentReadOnlySelector } from '@/ui/utilities/state/component-state/utils/createComponentReadOnlySelector';
+
+export const recordBoardVisibleFieldDefinitionsComponentSelector =
+ createComponentReadOnlySelector({
+ key: 'recordBoardVisibleFieldDefinitionsComponentSelector',
+ get:
+ ({ scopeId }) =>
+ ({ get }) =>
+ get(recordBoardFieldDefinitionsComponentState({ scopeId }))
+ .filter((field) => field.isVisible)
+ .sort((a, b) => a.position - b.position),
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardVisibleFieldDefinitionsScopedSelector.ts b/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardVisibleFieldDefinitionsScopedSelector.ts
deleted file mode 100644
index edae8d879c5..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-board/states/selectors/recordBoardVisibleFieldDefinitionsScopedSelector.ts
+++ /dev/null
@@ -1,13 +0,0 @@
-import { recordBoardFieldDefinitionsStateScopeMap } from '@/object-record/record-board/states/recordBoardFieldDefinitionsStateScopeMap';
-import { createSelectorReadOnlyScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorReadOnlyScopeMap';
-
-export const recordBoardVisibleFieldDefinitionsScopedSelector =
- createSelectorReadOnlyScopeMap({
- key: 'recordBoardVisibleFieldDefinitionsScopedSelector',
- get:
- ({ scopeId }) =>
- ({ get }) =>
- get(recordBoardFieldDefinitionsStateScopeMap({ scopeId }))
- .filter((field) => field.isVisible)
- .sort((a, b) => a.position - b.position),
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-field/hooks/internal/useRecordFieldInputStates.ts b/packages/twenty-front/src/modules/object-record/record-field/hooks/internal/useRecordFieldInputStates.ts
index 8efcb745d7a..924e838b71a 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/hooks/internal/useRecordFieldInputStates.ts
+++ b/packages/twenty-front/src/modules/object-record/record-field/hooks/internal/useRecordFieldInputStates.ts
@@ -1,9 +1,9 @@
import { RecordFieldInputScopeInternalContext } from '@/object-record/record-field/scopes/scope-internal-context/RecordFieldInputScopeInternalContext';
-import { recordFieldInputDraftValueSelectorScopeMap } from '@/object-record/record-field/states/selectors/recordFieldInputDraftValueSelectorScopeMap';
+import { recordFieldInputDraftValueComponentSelector } from '@/object-record/record-field/states/selectors/recordFieldInputDraftValueComponentSelector';
import { FieldInputDraftValue } from '@/object-record/record-field/types/FieldInputDraftValue';
import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';
import { getScopeIdOrUndefinedFromComponentId } from '@/ui/utilities/recoil-scope/utils/getScopeIdOrUndefinedFromComponentId';
-import { getSelector } from '@/ui/utilities/recoil-scope/utils/getSelector';
+import { extractComponentSelector } from '@/ui/utilities/state/component-state/utils/extractComponentSelector';
export const useRecordFieldInputStates = <FieldValue>(
recordFieldInputId?: string,
@@ -15,8 +15,8 @@ export const useRecordFieldInputStates = <FieldValue>(
return {
scopeId,
- getDraftValueSelector: getSelector<
+ getDraftValueSelector: extractComponentSelector<
FieldInputDraftValue<FieldValue> | undefined
- >(recordFieldInputDraftValueSelectorScopeMap, scopeId),
+ >(recordFieldInputDraftValueComponentSelector, scopeId),
};
};
diff --git a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/__stories__/RelationFieldInput.stories.tsx b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/__stories__/RelationFieldInput.stories.tsx
index 3cbe87a498a..9d8dd603400 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/__stories__/RelationFieldInput.stories.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/meta-types/input/components/__stories__/RelationFieldInput.stories.tsx
@@ -30,9 +30,9 @@ import {
} from '../RelationFieldInput';
const RelationWorkspaceSetterEffect = () => {
- const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState);
+ const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState());
const setCurrentWorkspaceMember = useSetRecoilState(
- currentWorkspaceMemberState,
+ currentWorkspaceMemberState(),
);
useEffect(() => {
diff --git a/packages/twenty-front/src/modules/object-record/record-field/scopes/scope-internal-context/RecordFieldInputScopeInternalContext.ts b/packages/twenty-front/src/modules/object-record/record-field/scopes/scope-internal-context/RecordFieldInputScopeInternalContext.ts
index 240470e528e..eebf6c22d58 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/scopes/scope-internal-context/RecordFieldInputScopeInternalContext.ts
+++ b/packages/twenty-front/src/modules/object-record/record-field/scopes/scope-internal-context/RecordFieldInputScopeInternalContext.ts
@@ -1,7 +1,7 @@
-import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
-type RecordFieldInputScopeInternalContextProps = StateScopeMapKey;
+type RecordFieldInputScopeInternalContextProps = ComponentStateKey;
export const RecordFieldInputScopeInternalContext =
createScopeInternalContext<RecordFieldInputScopeInternalContextProps>();
diff --git a/packages/twenty-front/src/modules/object-record/record-field/states/recordFieldInputDraftValueComponentState.ts b/packages/twenty-front/src/modules/object-record/record-field/states/recordFieldInputDraftValueComponentState.ts
new file mode 100644
index 00000000000..ccc67af8074
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-field/states/recordFieldInputDraftValueComponentState.ts
@@ -0,0 +1,7 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const recordFieldInputDraftValueComponentState =
+ createComponentState<any>({
+ key: 'recordFieldInputDraftValueComponentState',
+ defaultValue: undefined,
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-field/states/recordFieldInputDraftValueStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-field/states/recordFieldInputDraftValueStateScopeMap.ts
deleted file mode 100644
index 1d0720c4309..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-field/states/recordFieldInputDraftValueStateScopeMap.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const recordFieldInputDraftValueStateScopeMap = createStateScopeMap<any>(
- {
- key: 'recordFieldInputDraftValueStateScopeMap',
- defaultValue: undefined,
- },
-);
diff --git a/packages/twenty-front/src/modules/object-record/record-field/states/selectors/recordFieldInputDraftValueComponentSelector.ts b/packages/twenty-front/src/modules/object-record/record-field/states/selectors/recordFieldInputDraftValueComponentSelector.ts
new file mode 100644
index 00000000000..e96dd407561
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-field/states/selectors/recordFieldInputDraftValueComponentSelector.ts
@@ -0,0 +1,16 @@
+import { recordFieldInputDraftValueComponentState } from '@/object-record/record-field/states/recordFieldInputDraftValueComponentState';
+import { createComponentSelector } from '@/ui/utilities/state/component-state/utils/createComponentSelector';
+
+export const recordFieldInputDraftValueComponentSelector =
+ createComponentSelector<any>({
+ key: 'recordFieldInputDraftValueComponentSelector',
+ get:
+ <T>({ scopeId }: { scopeId: string }) =>
+ ({ get }) =>
+ get(recordFieldInputDraftValueComponentState({ scopeId })) as T,
+ set:
+ <T>({ scopeId }: { scopeId: string }) =>
+ ({ set }, newValue: T) => {
+ set(recordFieldInputDraftValueComponentState({ scopeId }), newValue);
+ },
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-field/states/selectors/recordFieldInputDraftValueSelectorScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-field/states/selectors/recordFieldInputDraftValueSelectorScopeMap.ts
deleted file mode 100644
index e785ec31374..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-field/states/selectors/recordFieldInputDraftValueSelectorScopeMap.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { recordFieldInputDraftValueStateScopeMap } from '@/object-record/record-field/states/recordFieldInputDraftValueStateScopeMap';
-import { createSelectorScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorScopeMap';
-
-export const recordFieldInputDraftValueSelectorScopeMap =
- createSelectorScopeMap<any>({
- key: 'recordFieldInputDraftValueSelectorScopeMap',
- get:
- <T>({ scopeId }: { scopeId: string }) =>
- ({ get }) =>
- get(recordFieldInputDraftValueStateScopeMap({ scopeId })) as T,
- set:
- <T>({ scopeId }: { scopeId: string }) =>
- ({ set }, newValue: T) => {
- set(recordFieldInputDraftValueStateScopeMap({ scopeId }), newValue);
- },
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexBoardContainerEffect.tsx b/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexBoardContainerEffect.tsx
index 44f0ab12af3..08e3bd35d90 100644
--- a/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexBoardContainerEffect.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexBoardContainerEffect.tsx
@@ -78,7 +78,7 @@ export const RecordIndexBoardContainerEffect = ({
]);
const recordIndexFieldDefinitions = useRecoilValue(
- recordIndexFieldDefinitionsState,
+ recordIndexFieldDefinitionsState(),
);
useEffect(() => {
diff --git a/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexContainer.tsx b/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexContainer.tsx
index 81679b9c64f..d9873a1b14b 100644
--- a/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexContainer.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexContainer.tsx
@@ -47,7 +47,7 @@ export const RecordIndexContainer = ({
objectNamePlural,
}: RecordIndexContainerProps) => {
const [recordIndexViewType, setRecordIndexViewType] = useRecoilState(
- recordIndexViewTypeState,
+ recordIndexViewTypeState(),
);
const { objectNameSingular } = useObjectNameSingularFromPlural({
objectNamePlural,
@@ -60,10 +60,10 @@ export const RecordIndexContainer = ({
const { columnDefinitions } =
useColumnDefinitionsFromFieldMetadata(objectMetadataItem);
- const setRecordIndexFilters = useSetRecoilState(recordIndexFiltersState);
- const setRecordIndexSorts = useSetRecoilState(recordIndexSortsState);
+ const setRecordIndexFilters = useSetRecoilState(recordIndexFiltersState());
+ const setRecordIndexSorts = useSetRecoilState(recordIndexSortsState());
const setRecordIndexIsCompactModeActive = useSetRecoilState(
- recordIndexIsCompactModeActiveState,
+ recordIndexIsCompactModeActiveState(),
);
const { setTableFilters, setTableSorts, setTableColumns } = useRecordTable({
@@ -85,7 +85,7 @@ export const RecordIndexContainer = ({
);
const existingRecordIndexFieldDefinitions = snapshot
- .getLoadable(recordIndexFieldDefinitionsState)
+ .getLoadable(recordIndexFieldDefinitionsState())
.getValue();
if (
@@ -94,7 +94,10 @@ export const RecordIndexContainer = ({
newRecordIndexFieldDefinitions,
)
) {
- set(recordIndexFieldDefinitionsState, newRecordIndexFieldDefinitions);
+ set(
+ recordIndexFieldDefinitionsState(),
+ newRecordIndexFieldDefinitions,
+ );
}
},
[columnDefinitions, setTableColumns],
diff --git a/packages/twenty-front/src/modules/object-record/record-index/hooks/useLoadRecordIndexBoard.ts b/packages/twenty-front/src/modules/object-record/record-index/hooks/useLoadRecordIndexBoard.ts
index 622be1ecdfc..fa894ebb19a 100644
--- a/packages/twenty-front/src/modules/object-record/record-index/hooks/useLoadRecordIndexBoard.ts
+++ b/packages/twenty-front/src/modules/object-record/record-index/hooks/useLoadRecordIndexBoard.ts
@@ -35,14 +35,14 @@ export const useLoadRecordIndexBoard = ({
const { setRecords: setRecordsInStore } = useSetRecordInStore();
const recordIndexFieldDefinitions = useRecoilValue(
- recordIndexFieldDefinitionsState,
+ recordIndexFieldDefinitionsState(),
);
useEffect(() => {
setFieldDefinitions(recordIndexFieldDefinitions);
}, [recordIndexFieldDefinitions, setFieldDefinitions]);
- const recordIndexFilters = useRecoilValue(recordIndexFiltersState);
- const recordIndexSorts = useRecoilValue(recordIndexSortsState);
+ const recordIndexFilters = useRecoilValue(recordIndexFiltersState());
+ const recordIndexSorts = useRecoilValue(recordIndexSortsState());
const requestFilters = turnObjectDropdownFilterIntoQueryFilter(
recordIndexFilters,
objectMetadataItem?.fields ?? [],
@@ -53,7 +53,7 @@ export const useLoadRecordIndexBoard = ({
);
const recordIndexIsCompactModeActive = useRecoilValue(
- recordIndexIsCompactModeActiveState,
+ recordIndexIsCompactModeActiveState(),
);
const {
diff --git a/packages/twenty-front/src/modules/object-record/record-index/hooks/useLoadRecordIndexTable.ts b/packages/twenty-front/src/modules/object-record/record-index/hooks/useLoadRecordIndexTable.ts
index 48d9f64ef8f..cc4005c4989 100644
--- a/packages/twenty-front/src/modules/object-record/record-index/hooks/useLoadRecordIndexTable.ts
+++ b/packages/twenty-front/src/modules/object-record/record-index/hooks/useLoadRecordIndexTable.ts
@@ -38,7 +38,7 @@ export const useLoadRecordIndexTable = (objectNameSingular: string) => {
useRecordTable();
const { getTableLastRowVisibleState } = useRecordTableStates();
const setLastRowVisible = useSetRecoilState(getTableLastRowVisibleState());
- const currentWorkspace = useRecoilValue(currentWorkspaceState);
+ const currentWorkspace = useRecoilValue(currentWorkspaceState());
const params = useFindManyParams(objectNameSingular);
const {
diff --git a/packages/twenty-front/src/modules/object-record/record-index/options/hooks/useRecordIndexOptionsForBoard.ts b/packages/twenty-front/src/modules/object-record/record-index/options/hooks/useRecordIndexOptionsForBoard.ts
index 770e9d6bd67..c109087fcfc 100644
--- a/packages/twenty-front/src/modules/object-record/record-index/options/hooks/useRecordIndexOptionsForBoard.ts
+++ b/packages/twenty-front/src/modules/object-record/record-index/options/hooks/useRecordIndexOptionsForBoard.ts
@@ -28,7 +28,7 @@ export const useRecordIndexOptionsForBoard = ({
viewBarId,
}: useRecordIndexOptionsForBoardParams) => {
const [recordIndexFieldDefinitions, setRecordIndexFieldDefinitions] =
- useRecoilState(recordIndexFieldDefinitionsState);
+ useRecoilState(recordIndexFieldDefinitionsState());
const { persistViewFields } = useViewFields(viewBarId);
const { updateView } = useViews(viewBarId);
diff --git a/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexFieldDefinitionsState.ts b/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexFieldDefinitionsState.ts
index 9fccbe7ab14..a02f9573ca5 100644
--- a/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexFieldDefinitionsState.ts
+++ b/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexFieldDefinitionsState.ts
@@ -1,11 +1,10 @@
-import { atom } from 'recoil';
-
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
import { ColumnDefinition } from '@/object-record/record-table/types/ColumnDefinition';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const recordIndexFieldDefinitionsState = atom<
+export const recordIndexFieldDefinitionsState = createState<
ColumnDefinition<FieldMetadata>[]
>({
key: 'recordIndexFieldDefinitionsState',
- default: [],
+ defaultValue: [],
});
diff --git a/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexFiltersState.ts b/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexFiltersState.ts
index 83349211e6b..aae23cae0e5 100644
--- a/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexFiltersState.ts
+++ b/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexFiltersState.ts
@@ -1,8 +1,7 @@
-import { atom } from 'recoil';
-
import { Filter } from '@/object-record/object-filter-dropdown/types/Filter';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const recordIndexFiltersState = atom<Filter[]>({
+export const recordIndexFiltersState = createState<Filter[]>({
key: 'recordIndexFiltersState',
- default: [],
+ defaultValue: [],
});
diff --git a/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexIsCompactModeActiveState.ts b/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexIsCompactModeActiveState.ts
index e0fba894047..5c78c52a544 100644
--- a/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexIsCompactModeActiveState.ts
+++ b/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexIsCompactModeActiveState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const recordIndexIsCompactModeActiveState = atom<boolean>({
+export const recordIndexIsCompactModeActiveState = createState<boolean>({
key: 'recordIndexIsCompactModeActiveState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexSortsState.ts b/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexSortsState.ts
index fe98a2f6181..1d8f791504a 100644
--- a/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexSortsState.ts
+++ b/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexSortsState.ts
@@ -1,8 +1,7 @@
-import { atom } from 'recoil';
-
import { Sort } from '@/object-record/object-sort-dropdown/types/Sort';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const recordIndexSortsState = atom<Sort[]>({
+export const recordIndexSortsState = createState<Sort[]>({
key: 'recordIndexSortsState',
- default: [],
+ defaultValue: [],
});
diff --git a/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexViewTypeState.ts b/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexViewTypeState.ts
index 28dcdef038a..2075ad5cd81 100644
--- a/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexViewTypeState.ts
+++ b/packages/twenty-front/src/modules/object-record/record-index/states/recordIndexViewTypeState.ts
@@ -1,8 +1,7 @@
-import { atom } from 'recoil';
-
+import { createState } from '@/ui/utilities/state/utils/createState';
import { ViewType } from '@/views/types/ViewType';
-export const recordIndexViewTypeState = atom<ViewType | undefined>({
+export const recordIndexViewTypeState = createState<ViewType | undefined>({
key: 'recordIndexViewTypeState',
- default: undefined,
+ defaultValue: undefined,
});
diff --git a/packages/twenty-front/src/modules/object-record/record-inline-cell/states/customEditHotkeyScopeForFieldScopedState.ts b/packages/twenty-front/src/modules/object-record/record-inline-cell/states/customEditHotkeyScopeForFieldScopedState.ts
index 37abc8db156..96db47ff940 100644
--- a/packages/twenty-front/src/modules/object-record/record-inline-cell/states/customEditHotkeyScopeForFieldScopedState.ts
+++ b/packages/twenty-front/src/modules/object-record/record-inline-cell/states/customEditHotkeyScopeForFieldScopedState.ts
@@ -1,11 +1,10 @@
-import { atomFamily } from 'recoil';
-
import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
+import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
-export const customEditHotkeyScopeForFieldScopedState = atomFamily<
+export const customEditHotkeyScopeForFieldScopedState = createFamilyState<
HotkeyScope | null,
string
>({
key: 'customEditHotkeyScopeForFieldScopedState',
- default: null,
+ defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/object-record/record-inline-cell/states/isInlineCellInEditModeScopedState.ts b/packages/twenty-front/src/modules/object-record/record-inline-cell/states/isInlineCellInEditModeScopedState.ts
index bdc57ccb36a..9142d9400e0 100644
--- a/packages/twenty-front/src/modules/object-record/record-inline-cell/states/isInlineCellInEditModeScopedState.ts
+++ b/packages/twenty-front/src/modules/object-record/record-inline-cell/states/isInlineCellInEditModeScopedState.ts
@@ -1,6 +1,9 @@
-import { atomFamily } from 'recoil';
+import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
-export const isInlineCellInEditModeScopedState = atomFamily<boolean, string>({
+export const isInlineCellInEditModeScopedState = createFamilyState<
+ boolean,
+ string
+>({
key: 'isInlineCellInEditModeScopedState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/object-record/record-inline-cell/states/parentHotkeyScopeForFieldScopedState.ts b/packages/twenty-front/src/modules/object-record/record-inline-cell/states/parentHotkeyScopeForFieldScopedState.ts
index 0314469079d..4562c09cfa9 100644
--- a/packages/twenty-front/src/modules/object-record/record-inline-cell/states/parentHotkeyScopeForFieldScopedState.ts
+++ b/packages/twenty-front/src/modules/object-record/record-inline-cell/states/parentHotkeyScopeForFieldScopedState.ts
@@ -1,11 +1,10 @@
-import { atomFamily } from 'recoil';
-
import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
+import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
-export const parentHotkeyScopeForFieldScopedState = atomFamily<
+export const parentHotkeyScopeForFieldScopedState = createFamilyState<
HotkeyScope | null,
string
>({
key: 'parentHotkeyScopeForFieldScopedState',
- default: null,
+ defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/object-record/record-store/states/recordLoadingFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-store/states/recordLoadingFamilyState.ts
index 68a97545e46..cbfd3ebb021 100644
--- a/packages/twenty-front/src/modules/object-record/record-store/states/recordLoadingFamilyState.ts
+++ b/packages/twenty-front/src/modules/object-record/record-store/states/recordLoadingFamilyState.ts
@@ -1,6 +1,6 @@
-import { atomFamily } from 'recoil';
+import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
-export const recordLoadingFamilyState = atomFamily<boolean, string>({
+export const recordLoadingFamilyState = createFamilyState<boolean, string>({
key: 'recordLoadingFamilyState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/object-record/record-store/states/recordStoreFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-store/states/recordStoreFamilyState.ts
index a0e71f0bb09..9c7877004c7 100644
--- a/packages/twenty-front/src/modules/object-record/record-store/states/recordStoreFamilyState.ts
+++ b/packages/twenty-front/src/modules/object-record/record-store/states/recordStoreFamilyState.ts
@@ -1,8 +1,10 @@
-import { atomFamily } from 'recoil';
-
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
+import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
-export const recordStoreFamilyState = atomFamily<ObjectRecord | null, string>({
+export const recordStoreFamilyState = createFamilyState<
+ ObjectRecord | null,
+ string
+>({
key: 'recordStoreFamilyState',
- default: null,
+ defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/object-record/record-store/states/selectors/recordStoreIdentifierSelector.ts b/packages/twenty-front/src/modules/object-record/record-store/states/selectors/recordStoreIdentifierSelector.ts
index 24502a28810..10167cc4c8e 100644
--- a/packages/twenty-front/src/modules/object-record/record-store/states/selectors/recordStoreIdentifierSelector.ts
+++ b/packages/twenty-front/src/modules/object-record/record-store/states/selectors/recordStoreIdentifierSelector.ts
@@ -17,7 +17,7 @@ export const recordStoreIdentifierFamilySelector = selectorFamily({
({ get }) => {
const recordFromStore = get(recordStoreFamilyState(recordId));
- const objectMetadataItems = get(objectMetadataItemsState);
+ const objectMetadataItems = get(objectMetadataItemsState());
const objectMetadataItem = objectMetadataItems.find(
(item) => item.nameSingular === objectNameSingular,
diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/CheckboxCell.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/CheckboxCell.tsx
index 2aff77e1b16..d6c432c8154 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/components/CheckboxCell.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/components/CheckboxCell.tsx
@@ -22,7 +22,7 @@ const StyledContainer = styled.div`
export const CheckboxCell = () => {
const { recordId } = useContext(RecordTableRowContext);
const { isRowSelectedFamilyState } = useRecordTableStates();
- const setActionBarOpenState = useSetRecoilState(actionBarOpenState);
+ const setActionBarOpenState = useSetRecoilState(actionBarOpenState());
const { setCurrentRowSelected } = useSetCurrentRowSelected();
const currentRowSelected = useRecoilValue(isRowSelectedFamilyState(recordId));
diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/ColumnHead.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/ColumnHead.tsx
index 5f3207bfa27..2cd9432bd2f 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/components/ColumnHead.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/components/ColumnHead.tsx
@@ -53,7 +53,7 @@ export const ColumnHead = ({ column }: ColumnHeadProps) => {
const { getIcon } = useIcons();
const Icon = getIcon(column.iconName);
- const scrollLeft = useRecoilValue(scrollLeftState);
+ const scrollLeft = useRecoilValue(scrollLeftState());
return (
<StyledTitle hideTitle={!!column.isLabelIdentifier && scrollLeft > 0}>
diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTable.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTable.tsx
index 80dbedafd40..6d9a60ca708 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTable.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTable.tsx
@@ -122,7 +122,7 @@ export const RecordTable = ({
createRecord,
}: RecordTableProps) => {
const { scopeId } = useRecordTableStates(recordTableId);
- const scrollLeft = useRecoilValue(scrollLeftState);
+ const scrollLeft = useRecoilValue(scrollLeftState());
const { objectMetadataItem } = useObjectMetadataItemOnly({
objectNameSingular,
diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableCellContainer.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableCellContainer.tsx
index 5d85a719320..70337e666f3 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableCellContainer.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableCellContainer.tsx
@@ -23,8 +23,8 @@ const StyledContainer = styled.td<{ isSelected: boolean }>`
`;
export const RecordTableCellContainer = () => {
- const setContextMenuPosition = useSetRecoilState(contextMenuPositionState);
- const setContextMenuOpenState = useSetRecoilState(contextMenuIsOpenState);
+ const setContextMenuPosition = useSetRecoilState(contextMenuPositionState());
+ const setContextMenuOpenState = useSetRecoilState(contextMenuIsOpenState());
const { setCurrentRowSelected } = useSetCurrentRowSelected();
diff --git a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeaderCell.tsx b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeaderCell.tsx
index f6ec3a6607b..9d1f7f89a90 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeaderCell.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/components/RecordTableHeaderCell.tsx
@@ -165,7 +165,7 @@ export const RecordTableHeaderCell = ({
});
const isMobile = useIsMobile();
- const scrollLeft = useRecoilValue(scrollLeftState);
+ const scrollLeft = useRecoilValue(scrollLeftState());
const disableColumnResize =
column.isLabelIdentifier && isMobile && scrollLeft > 0;
diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useLeaveTableFocus.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useLeaveTableFocus.ts
index ffb3eb2a8db..ff2e2b877c4 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useLeaveTableFocus.ts
+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useLeaveTableFocus.ts
@@ -25,7 +25,7 @@ export const useLeaveTableFocus = (recordTableId?: string) => {
);
const currentHotkeyScope = snapshot
- .getLoadable(currentHotkeyScopeState)
+ .getLoadable(currentHotkeyScopeState())
.getValue();
if (!isSoftFocusActive) {
diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useRecordTableStates.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useRecordTableStates.ts
index 7238fec4415..21414ec2d70 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useRecordTableStates.ts
+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/internal/useRecordTableStates.ts
@@ -1,31 +1,31 @@
-import { isRowSelectedFamilyStateScopeMap } from '@/object-record/record-table/record-table-row/states/isRowSelectedFamilyStateScopeMap';
+import { isRowSelectedComponentFamilyState } from '@/object-record/record-table/record-table-row/states/isRowSelectedComponentFamilyState';
import { RecordTableScopeInternalContext } from '@/object-record/record-table/scopes/scope-internal-context/RecordTableScopeInternalContext';
-import { availableTableColumnsStateScopeMap } from '@/object-record/record-table/states/availableTableColumnsStateScopeMap';
-import { currentTableCellInEditModePositionStateScopeMap } from '@/object-record/record-table/states/currentTableCellInEditModePositionStateScopeMap';
-import { isRecordTableInitialLoadingStateScopeMap } from '@/object-record/record-table/states/isRecordTableInitialLoadingStateScopeMap';
-import { isSoftFocusActiveStateScopeMap } from '@/object-record/record-table/states/isSoftFocusActiveStateScopeMap';
-import { isSoftFocusOnTableCellFamilyStateScopeMap } from '@/object-record/record-table/states/isSoftFocusOnTableCellFamilyStateScopeMap';
-import { isTableCellInEditModeFamilyStateScopeMap } from '@/object-record/record-table/states/isTableCellInEditModeFamilyStateScopeMap';
-import { numberOfTableRowsStateScopeMap } from '@/object-record/record-table/states/numberOfTableRowsStateScopeMap';
-import { onColumnsChangeStateScopeMap } from '@/object-record/record-table/states/onColumnsChangeStateScopeMap';
-import { onEntityCountChangeStateScopeMap } from '@/object-record/record-table/states/onEntityCountChangeStateScopeMap';
-import { resizeFieldOffsetStateScopeMap } from '@/object-record/record-table/states/resizeFieldOffsetStateScopeMap';
-import { allRowsSelectedStatusSelectorScopeMap } from '@/object-record/record-table/states/selectors/allRowsSelectedStatusSelectorScopeMap';
-import { hiddenTableColumnsSelectorScopeMap } from '@/object-record/record-table/states/selectors/hiddenTableColumnsSelectorScopeMap';
-import { numberOfTableColumnsSelectorScopeMap } from '@/object-record/record-table/states/selectors/numberOfTableColumnsSelectorScopeMap';
-import { selectedRowIdsSelectorScopeMap } from '@/object-record/record-table/states/selectors/selectedRowIdsSelectorScopeMap';
-import { visibleTableColumnsSelectorScopeMap } from '@/object-record/record-table/states/selectors/visibleTableColumnsSelectorScopeMap';
-import { softFocusPositionStateScopeMap } from '@/object-record/record-table/states/softFocusPositionStateScopeMap';
-import { tableColumnsStateScopeMap } from '@/object-record/record-table/states/tableColumnsStateScopeMap';
-import { tableFiltersStateScopeMap } from '@/object-record/record-table/states/tableFiltersStateScopeMap';
-import { tableLastRowVisibleStateScopeMap } from '@/object-record/record-table/states/tableLastRowVisibleStateScopeMap';
-import { tableRowIdsStateScopeMap } from '@/object-record/record-table/states/tableRowIdsStateScopeMap';
-import { tableSortsStateScopeMap } from '@/object-record/record-table/states/tableSortsStateScopeMap';
+import { availableTableColumnsComponentState } from '@/object-record/record-table/states/availableTableColumnsComponentState';
+import { currentTableCellInEditModePositionComponentState } from '@/object-record/record-table/states/currentTableCellInEditModePositionComponentState';
+import { isRecordTableInitialLoadingComponentState } from '@/object-record/record-table/states/isRecordTableInitialLoadingComponentState';
+import { isSoftFocusActiveComponentState } from '@/object-record/record-table/states/isSoftFocusActiveComponentState';
+import { isSoftFocusOnTableCellComponentFamilyState } from '@/object-record/record-table/states/isSoftFocusOnTableCellComponentFamilyState';
+import { isTableCellInEditModeComponentFamilyState } from '@/object-record/record-table/states/isTableCellInEditModeComponentFamilyState';
+import { numberOfTableRowsComponentState } from '@/object-record/record-table/states/numberOfTableRowsComponentState';
+import { onColumnsChangeComponentState } from '@/object-record/record-table/states/onColumnsChangeComponentState';
+import { onEntityCountChangeComponentState } from '@/object-record/record-table/states/onEntityCountChangeComponentState';
+import { resizeFieldOffsetComponentState } from '@/object-record/record-table/states/resizeFieldOffsetComponentState';
+import { allRowsSelectedStatusComponentSelector } from '@/object-record/record-table/states/selectors/allRowsSelectedStatusComponentSelector';
+import { hiddenTableColumnsComponentSelector } from '@/object-record/record-table/states/selectors/hiddenTableColumnsComponentSelector';
+import { numberOfTableColumnsComponentSelector } from '@/object-record/record-table/states/selectors/numberOfTableColumnsComponentSelector';
+import { selectedRowIdsComponentSelector } from '@/object-record/record-table/states/selectors/selectedRowIdsComponentSelector';
+import { visibleTableColumnsComponentSelector } from '@/object-record/record-table/states/selectors/visibleTableColumnsComponentSelector';
+import { softFocusPositionComponentState } from '@/object-record/record-table/states/softFocusPositionComponentState';
+import { tableColumnsComponentState } from '@/object-record/record-table/states/tableColumnsComponentState';
+import { tableFiltersComponentState } from '@/object-record/record-table/states/tableFiltersComponentState';
+import { tableLastRowVisibleComponentState } from '@/object-record/record-table/states/tableLastRowVisibleComponentState';
+import { tableRowIdsComponentState } from '@/object-record/record-table/states/tableRowIdsComponentState';
+import { tableSortsComponentState } from '@/object-record/record-table/states/tableSortsComponentState';
import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';
-import { getFamilyState } from '@/ui/utilities/recoil-scope/utils/getFamilyState';
import { getScopeIdOrUndefinedFromComponentId } from '@/ui/utilities/recoil-scope/utils/getScopeIdOrUndefinedFromComponentId';
-import { getSelectorReadOnly } from '@/ui/utilities/recoil-scope/utils/getSelectorReadOnly';
-import { getState } from '@/ui/utilities/recoil-scope/utils/getState';
+import { extractComponentFamilyState } from '@/ui/utilities/state/component-state/utils/extractComponentFamilyState';
+import { extractComponentReadOnlySelector } from '@/ui/utilities/state/component-state/utils/extractComponentReadOnlySelector';
+import { extractComponentState } from '@/ui/utilities/state/component-state/utils/extractComponentState';
export const useRecordTableStates = (recordTableId?: string) => {
const scopeId = useAvailableScopeIdOrThrow(
@@ -35,78 +35,93 @@ export const useRecordTableStates = (recordTableId?: string) => {
return {
scopeId,
- getAvailableTableColumnsState: getState(
- availableTableColumnsStateScopeMap,
+ getAvailableTableColumnsState: extractComponentState(
+ availableTableColumnsComponentState,
+ scopeId,
+ ),
+ getTableFiltersState: extractComponentState(
+ tableFiltersComponentState,
+ scopeId,
+ ),
+ getTableSortsState: extractComponentState(
+ tableSortsComponentState,
+ scopeId,
+ ),
+ getTableColumnsState: extractComponentState(
+ tableColumnsComponentState,
scopeId,
),
- getTableFiltersState: getState(tableFiltersStateScopeMap, scopeId),
- getTableSortsState: getState(tableSortsStateScopeMap, scopeId),
- getTableColumnsState: getState(tableColumnsStateScopeMap, scopeId),
- getOnColumnsChangeState: getState(onColumnsChangeStateScopeMap, scopeId),
- getOnEntityCountChangeState: getState(
- onEntityCountChangeStateScopeMap,
+ getOnColumnsChangeState: extractComponentState(
+ onColumnsChangeComponentState,
+ scopeId,
+ ),
+ getOnEntityCountChangeState: extractComponentState(
+ onEntityCountChangeComponentState,
+ scopeId,
+ ),
+ getTableLastRowVisibleState: extractComponentState(
+ tableLastRowVisibleComponentState,
scopeId,
),
- getTableLastRowVisibleState: getState(
- tableLastRowVisibleStateScopeMap,
+ getSoftFocusPositionState: extractComponentState(
+ softFocusPositionComponentState,
scopeId,
),
- getSoftFocusPositionState: getState(
- softFocusPositionStateScopeMap,
+ getNumberOfTableRowsState: extractComponentState(
+ numberOfTableRowsComponentState,
scopeId,
),
- getNumberOfTableRowsState: getState(
- numberOfTableRowsStateScopeMap,
+ getCurrentTableCellInEditModePositionState: extractComponentState(
+ currentTableCellInEditModePositionComponentState,
scopeId,
),
- getCurrentTableCellInEditModePositionState: getState(
- currentTableCellInEditModePositionStateScopeMap,
+ isTableCellInEditModeFamilyState: extractComponentFamilyState(
+ isTableCellInEditModeComponentFamilyState,
scopeId,
),
- isTableCellInEditModeFamilyState: getFamilyState(
- isTableCellInEditModeFamilyStateScopeMap,
+ getIsSoftFocusActiveState: extractComponentState(
+ isSoftFocusActiveComponentState,
scopeId,
),
- getIsSoftFocusActiveState: getState(
- isSoftFocusActiveStateScopeMap,
+ getTableRowIdsState: extractComponentState(
+ tableRowIdsComponentState,
scopeId,
),
- getTableRowIdsState: getState(tableRowIdsStateScopeMap, scopeId),
- getIsRecordTableInitialLoadingState: getState(
- isRecordTableInitialLoadingStateScopeMap,
+ getIsRecordTableInitialLoadingState: extractComponentState(
+ isRecordTableInitialLoadingComponentState,
scopeId,
),
- getResizeFieldOffsetState: getState(
- resizeFieldOffsetStateScopeMap,
+ getResizeFieldOffsetState: extractComponentState(
+ resizeFieldOffsetComponentState,
scopeId,
),
- isSoftFocusOnTableCellFamilyState: getFamilyState(
- isSoftFocusOnTableCellFamilyStateScopeMap,
+ isSoftFocusOnTableCellFamilyState: extractComponentFamilyState(
+ isSoftFocusOnTableCellComponentFamilyState,
scopeId,
),
- isRowSelectedFamilyState: getFamilyState(
- isRowSelectedFamilyStateScopeMap,
+ isRowSelectedFamilyState: extractComponentFamilyState(
+ isRowSelectedComponentFamilyState,
scopeId,
),
- getAllRowsSelectedStatusSelector: getSelectorReadOnly(
- allRowsSelectedStatusSelectorScopeMap,
+ getAllRowsSelectedStatusSelector: extractComponentReadOnlySelector(
+ allRowsSelectedStatusComponentSelector,
scopeId,
),
- getHiddenTableColumnsSelector: getSelectorReadOnly(
- hiddenTableColumnsSelectorScopeMap,
+ getHiddenTableColumnsSelector: extractComponentReadOnlySelector(
+ hiddenTableColumnsComponentSelector,
scopeId,
),
- getNumberOfTableColumnsSelector: getSelectorReadOnly(
- numberOfTableColumnsSelectorScopeMap,
+ getNumberOfTableColumnsSelector: extractComponentReadOnlySelector(
+ numberOfTableColumnsComponentSelector,
scopeId,
),
- getSelectedRowIdsSelector: getSelectorReadOnly(
- selectedRowIdsSelectorScopeMap,
+ getSelectedRowIdsSelector: extractComponentReadOnlySelector(
+ selectedRowIdsComponentSelector,
scopeId,
),
- getVisibleTableColumnsSelector: getSelectorReadOnly(
- visibleTableColumnsSelectorScopeMap,
+ getVisibleTableColumnsSelector: extractComponentReadOnlySelector(
+ visibleTableColumnsComponentSelector,
scopeId,
),
};
diff --git a/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTable.ts b/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTable.ts
index 2941893c6b4..a530bb63533 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTable.ts
+++ b/packages/twenty-front/src/modules/object-record/record-table/hooks/useRecordTable.ts
@@ -128,7 +128,7 @@ export const useRecordTable = (props?: useRecordTableProps) => {
const setHotkeyScope = useSetHotkeyScope();
const setIsSoftFocusUsingMouseState = useSetRecoilState(
- isSoftFocusUsingMouseState,
+ isSoftFocusUsingMouseState(),
);
useScopedHotkeys(
diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellContainer.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellContainer.tsx
index 344988c941a..b5ac47aafcc 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellContainer.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellContainer.tsx
@@ -64,7 +64,7 @@ export const RecordTableCellContainer = ({
const isSomeCellInEditMode = useRecoilValue(isSomeCellInEditModeState());
const setIsSoftFocusUsingMouseState = useSetRecoilState(
- isSoftFocusUsingMouseState,
+ isSoftFocusUsingMouseState(),
);
const moveSoftFocusToCurrentCellOnHover =
diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellSoftFocusMode.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellSoftFocusMode.tsx
index 7c6947aa5cf..f4893922098 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellSoftFocusMode.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/components/RecordTableCellSoftFocusMode.tsx
@@ -24,7 +24,7 @@ export const RecordTableCellSoftFocusMode = ({
const toggleEditOnlyInput = useToggleEditOnlyInput();
const scrollRef = useRef<HTMLDivElement>(null);
- const isSoftFocusUsingMouse = useRecoilValue(isSoftFocusUsingMouseState);
+ const isSoftFocusUsingMouse = useRecoilValue(isSoftFocusUsingMouseState());
useEffect(() => {
if (!isSoftFocusUsingMouse) {
diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/__tests__/useMoveSoftFocusToCurrentCellOnHover.test.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/__tests__/useMoveSoftFocusToCurrentCellOnHover.test.tsx
index f8337c3ba89..1ebad63a8fe 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/__tests__/useMoveSoftFocusToCurrentCellOnHover.test.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/__tests__/useMoveSoftFocusToCurrentCellOnHover.test.tsx
@@ -13,19 +13,19 @@ import { TableCellPosition } from '@/object-record/record-table/types/TableCellP
import { TableHotkeyScope } from '@/object-record/record-table/types/TableHotkeyScope';
const mockSoftFocusPositionState = {
- key: 'softFocusPositionStateScopeMap__{"scopeId":"scopeId"}',
+ key: 'softFocusPositionComponentState__{"scopeId":"scopeId"}',
};
const mockSoftFocusActiveState = {
- key: 'isSoftFocusActiveStateScopeMap__{"scopeId":"scopeId"}',
+ key: 'isSoftFocusActiveComponentState__{"scopeId":"scopeId"}',
};
const mockIsSoftFocusOnTableCellFamilyState = {
- key: 'isSoftFocusOnTableCellFamilyStateScopeMap__{"familyKey":{"column":1,"row":0},"scopeId":"scopeId"}',
+ key: 'isSoftFocusOnTableCellFamilyComponentState__{"familyKey":{"column":1,"row":0},"scopeId":"scopeId"}',
};
const mockCurrentTableCellInEditModePositionState = {
- key: 'currentTableCellInEditModePositionStateScopeMap__{"scopeId":"scopeId"}',
+ key: 'currentTableCellInEditModePositionComponentState__{"scopeId":"scopeId"}',
};
const mockIsTableCellInEditModeFamilyState = {
- key: 'isTableCellInEditModeFamilyStateScopeMap__{"familyKey":{"column":1,"row":0},"scopeId":"scopeId"}',
+ key: 'isTableCellInEditModeFamilyComponentState__{"familyKey":{"column":1,"row":0},"scopeId":"scopeId"}',
};
const mockCurrentHotKeyScopeState = {
key: 'currentHotkeyScopeState',
diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/__tests__/useSelectedTableCellEditMode.test.tsx b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/__tests__/useSelectedTableCellEditMode.test.tsx
index 9cbf45efe27..1e7ec2088d2 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/__tests__/useSelectedTableCellEditMode.test.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/__tests__/useSelectedTableCellEditMode.test.tsx
@@ -48,19 +48,14 @@ describe('useSelectedTableCellEditMode', () => {
expect(mockCallbackInterface.set).toHaveBeenCalledWith(
{
- key: 'isTableCellInEditModeFamilyStateScopeMap__{"familyKey":{"column":0,"row":0},"scopeId":"yourScopeId-scope"}',
+ key: 'isTableCellInEditModeComponentFamilyState__{"familyKey":{"column":0,"row":0},"scopeId":"yourScopeId-scope"}',
},
false,
);
+
expect(mockCallbackInterface.set).toHaveBeenCalledWith(
{
- key: 'currentTableCellInEditModePositionStateScopeMap__{"scopeId":"yourScopeId-scope"}',
- },
- { column: 5, row: 1 },
- );
- expect(mockCallbackInterface.set).toHaveBeenCalledWith(
- {
- key: 'isTableCellInEditModeFamilyStateScopeMap__{"familyKey":{"column":5,"row":1},"scopeId":"yourScopeId-scope"}',
+ key: 'isTableCellInEditModeComponentFamilyState__{"familyKey":{"column":5,"row":1},"scopeId":"yourScopeId-scope"}',
},
true,
);
diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useMoveSoftFocusToCurrentCellOnHover.ts b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useMoveSoftFocusToCurrentCellOnHover.ts
index 4bb8b9f8747..0ddc6fe6a11 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useMoveSoftFocusToCurrentCellOnHover.ts
+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-cell/hooks/useMoveSoftFocusToCurrentCellOnHover.ts
@@ -33,7 +33,7 @@ export const useMoveSoftFocusToCurrentCellOnHover = () => {
.getValue();
const currentHotkeyScope = snapshot
- .getLoadable(currentHotkeyScopeState)
+ .getLoadable(currentHotkeyScopeState())
.getValue();
if (
diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-row/states/isRowSelectedComponentFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-table/record-table-row/states/isRowSelectedComponentFamilyState.ts
new file mode 100644
index 00000000000..803921f1e27
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/record-table-row/states/isRowSelectedComponentFamilyState.ts
@@ -0,0 +1,9 @@
+import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
+
+export const isRowSelectedComponentFamilyState = createComponentFamilyState<
+ boolean,
+ string
+>({
+ key: 'isRowSelectedComponentFamilyState',
+ defaultValue: false,
+});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/record-table-row/states/isRowSelectedFamilyStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/record-table-row/states/isRowSelectedFamilyStateScopeMap.ts
deleted file mode 100644
index ebb2af41213..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/record-table-row/states/isRowSelectedFamilyStateScopeMap.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
-
-export const isRowSelectedFamilyStateScopeMap = createFamilyStateScopeMap<
- boolean,
- string
->({
- key: 'isRowSelectedFamilyStateScopeMap',
- defaultValue: false,
-});
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 e2588219603..a4dcca14424 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/record-field/types/FieldMetadata';
-import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
import { ColumnDefinition } from '../../types/ColumnDefinition';
-type RecordTableScopeInternalContextProps = StateScopeMapKey & {
+type RecordTableScopeInternalContextProps = ComponentStateKey & {
onColumnsChange: (columns: ColumnDefinition<FieldMetadata>[]) => void;
};
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/availableTableColumnsComponentState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/availableTableColumnsComponentState.ts
new file mode 100644
index 00000000000..d7fcfa0721f
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/availableTableColumnsComponentState.ts
@@ -0,0 +1,11 @@
+import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+import { ColumnDefinition } from '../types/ColumnDefinition';
+
+export const availableTableColumnsComponentState = createComponentState<
+ ColumnDefinition<FieldMetadata>[]
+>({
+ key: 'availableTableColumnsComponentState',
+ defaultValue: [],
+});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/availableTableColumnsStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/availableTableColumnsStateScopeMap.ts
deleted file mode 100644
index f60d3afb1f6..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/availableTableColumnsStateScopeMap.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-import { ColumnDefinition } from '../types/ColumnDefinition';
-
-export const availableTableColumnsStateScopeMap = createStateScopeMap<
- ColumnDefinition<FieldMetadata>[]
->({
- key: 'availableTableColumnsStateScopeMap',
- defaultValue: [],
-});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/currentTableCellInEditModePositionComponentState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/currentTableCellInEditModePositionComponentState.ts
new file mode 100644
index 00000000000..88616eb1b40
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/currentTableCellInEditModePositionComponentState.ts
@@ -0,0 +1,12 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+import { TableCellPosition } from '../types/TableCellPosition';
+
+export const currentTableCellInEditModePositionComponentState =
+ createComponentState<TableCellPosition>({
+ key: 'currentTableCellInEditModePositionComponentState',
+ defaultValue: {
+ row: 0,
+ column: 1,
+ },
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/currentTableCellInEditModePositionStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/currentTableCellInEditModePositionStateScopeMap.ts
deleted file mode 100644
index 87379002984..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/currentTableCellInEditModePositionStateScopeMap.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-import { TableCellPosition } from '../types/TableCellPosition';
-
-export const currentTableCellInEditModePositionStateScopeMap =
- createStateScopeMap<TableCellPosition>({
- key: 'currentTableCellInEditModePositionStateScopeMap',
- defaultValue: {
- row: 0,
- column: 1,
- },
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isRecordTableInitialLoadingComponentState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isRecordTableInitialLoadingComponentState.ts
new file mode 100644
index 00000000000..01d7f280d96
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/isRecordTableInitialLoadingComponentState.ts
@@ -0,0 +1,7 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const isRecordTableInitialLoadingComponentState =
+ createComponentState<boolean>({
+ key: 'isRecordTableInitialLoadingComponentState',
+ defaultValue: true,
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isRecordTableInitialLoadingStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isRecordTableInitialLoadingStateScopeMap.ts
deleted file mode 100644
index 6b320ced8a1..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/isRecordTableInitialLoadingStateScopeMap.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const isRecordTableInitialLoadingStateScopeMap =
- createStateScopeMap<boolean>({
- key: 'isRecordTableInitialLoadingStateScopeMap',
- defaultValue: true,
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusActiveComponentState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusActiveComponentState.ts
new file mode 100644
index 00000000000..a9b726ddf4b
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusActiveComponentState.ts
@@ -0,0 +1,6 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const isSoftFocusActiveComponentState = createComponentState<boolean>({
+ key: 'isSoftFocusActiveComponentState',
+ defaultValue: false,
+});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusActiveStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusActiveStateScopeMap.ts
deleted file mode 100644
index 917733d8782..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusActiveStateScopeMap.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const isSoftFocusActiveStateScopeMap = createStateScopeMap<boolean>({
- key: 'isSoftFocusActiveStateScopeMap',
- defaultValue: false,
-});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusOnTableCellComponentFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusOnTableCellComponentFamilyState.ts
new file mode 100644
index 00000000000..dd9023404bd
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusOnTableCellComponentFamilyState.ts
@@ -0,0 +1,9 @@
+import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
+
+import { TableCellPosition } from '../types/TableCellPosition';
+
+export const isSoftFocusOnTableCellComponentFamilyState =
+ createComponentFamilyState<boolean, TableCellPosition>({
+ key: 'isSoftFocusOnTableCellComponentFamilyState',
+ defaultValue: false,
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusOnTableCellFamilyStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusOnTableCellFamilyStateScopeMap.ts
deleted file mode 100644
index f9c48a851ff..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusOnTableCellFamilyStateScopeMap.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
-
-import { TableCellPosition } from '../types/TableCellPosition';
-
-export const isSoftFocusOnTableCellFamilyStateScopeMap =
- createFamilyStateScopeMap<boolean, TableCellPosition>({
- key: 'isSoftFocusOnTableCellFamilyStateScopeMap',
- defaultValue: false,
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusUsingMouseState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusUsingMouseState.ts
index 7895269f933..234db43ec91 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusUsingMouseState.ts
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/isSoftFocusUsingMouseState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const isSoftFocusUsingMouseState = atom({
+export const isSoftFocusUsingMouseState = createState<boolean>({
key: 'isSoftFocusUsingMouseState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isTableCellInEditModeComponentFamilyState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isTableCellInEditModeComponentFamilyState.ts
new file mode 100644
index 00000000000..e049c034971
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/isTableCellInEditModeComponentFamilyState.ts
@@ -0,0 +1,9 @@
+import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
+
+import { TableCellPosition } from '../types/TableCellPosition';
+
+export const isTableCellInEditModeComponentFamilyState =
+ createComponentFamilyState<boolean, TableCellPosition>({
+ key: 'isTableCellInEditModeComponentFamilyState',
+ defaultValue: false,
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/isTableCellInEditModeFamilyStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/isTableCellInEditModeFamilyStateScopeMap.ts
deleted file mode 100644
index ff9ba4bd713..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/isTableCellInEditModeFamilyStateScopeMap.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
-
-import { TableCellPosition } from '../types/TableCellPosition';
-
-export const isTableCellInEditModeFamilyStateScopeMap =
- createFamilyStateScopeMap<boolean, TableCellPosition>({
- key: 'isTableCellInEditModeFamilyStateScopeMap',
- defaultValue: false,
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/numberOfTableRowsComponentState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/numberOfTableRowsComponentState.ts
new file mode 100644
index 00000000000..2e6340e6d58
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/numberOfTableRowsComponentState.ts
@@ -0,0 +1,6 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const numberOfTableRowsComponentState = createComponentState<number>({
+ key: 'numberOfTableRowsComponentState',
+ defaultValue: 0,
+});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/numberOfTableRowsStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/numberOfTableRowsStateScopeMap.ts
deleted file mode 100644
index f67a8a40c43..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/numberOfTableRowsStateScopeMap.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const numberOfTableRowsStateScopeMap = createStateScopeMap<number>({
- key: 'numberOfTableRowsStateScopeMap',
- defaultValue: 0,
-});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/onColumnsChangeStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/onColumnsChangeComponentState.ts
similarity index 56%
rename from packages/twenty-front/src/modules/object-record/record-table/states/onColumnsChangeStateScopeMap.ts
rename to packages/twenty-front/src/modules/object-record/record-table/states/onColumnsChangeComponentState.ts
index 9253e244357..b157eb071d5 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/states/onColumnsChangeStateScopeMap.ts
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/onColumnsChangeComponentState.ts
@@ -1,10 +1,10 @@
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
import { ColumnDefinition } from '@/object-record/record-table/types/ColumnDefinition';
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
-export const onColumnsChangeStateScopeMap = createStateScopeMap<
+export const onColumnsChangeComponentState = createComponentState<
((columns: ColumnDefinition<FieldMetadata>[]) => void) | undefined
>({
- key: 'onColumnsChangeStateScopeMap',
+ key: 'onColumnsChangeComponentState',
defaultValue: undefined,
});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/onEntityCountChangeComponentState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/onEntityCountChangeComponentState.ts
new file mode 100644
index 00000000000..65356e5dc7e
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/onEntityCountChangeComponentState.ts
@@ -0,0 +1,8 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const onEntityCountChangeComponentState = createComponentState<
+ ((entityCount: number) => void) | undefined
+>({
+ key: 'onEntityCountChangeComponentState',
+ defaultValue: undefined,
+});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/onEntityCountChangeStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/onEntityCountChangeStateScopeMap.ts
deleted file mode 100644
index 6aefeedb7b2..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/onEntityCountChangeStateScopeMap.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const onEntityCountChangeStateScopeMap = createStateScopeMap<
- ((entityCount: number) => void) | undefined
->({
- key: 'onEntityCountChangeStateScopeMap',
- defaultValue: undefined,
-});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/resizeFieldOffsetComponentState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/resizeFieldOffsetComponentState.ts
new file mode 100644
index 00000000000..9e2700f4596
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/resizeFieldOffsetComponentState.ts
@@ -0,0 +1,6 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const resizeFieldOffsetComponentState = createComponentState<number>({
+ key: 'resizeFieldOffsetComponentState',
+ defaultValue: 0,
+});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/resizeFieldOffsetStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/resizeFieldOffsetStateScopeMap.ts
deleted file mode 100644
index 21ca29d2d42..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/resizeFieldOffsetStateScopeMap.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const resizeFieldOffsetStateScopeMap = createStateScopeMap<number>({
- key: 'resizeFieldOffsetStateScopeMap',
- defaultValue: 0,
-});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/allRowsSelectedStatusComponentSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/allRowsSelectedStatusComponentSelector.ts
new file mode 100644
index 00000000000..c0a42ea8101
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/allRowsSelectedStatusComponentSelector.ts
@@ -0,0 +1,30 @@
+import { numberOfTableRowsComponentState } from '@/object-record/record-table/states/numberOfTableRowsComponentState';
+import { selectedRowIdsComponentSelector } from '@/object-record/record-table/states/selectors/selectedRowIdsComponentSelector';
+import { createComponentReadOnlySelector } from '@/ui/utilities/state/component-state/utils/createComponentReadOnlySelector';
+
+import { AllRowsSelectedStatus } from '../../types/AllRowSelectedStatus';
+
+export const allRowsSelectedStatusComponentSelector =
+ createComponentReadOnlySelector<AllRowsSelectedStatus>({
+ key: 'allRowsSelectedStatusComponentSelector',
+ get:
+ ({ scopeId }) =>
+ ({ get }) => {
+ const numberOfRows = get(numberOfTableRowsComponentState({ scopeId }));
+
+ const selectedRowIds = get(
+ selectedRowIdsComponentSelector({ scopeId }),
+ );
+
+ const numberOfSelectedRows = selectedRowIds.length;
+
+ const allRowsSelectedStatus =
+ numberOfSelectedRows === 0
+ ? 'none'
+ : numberOfRows === numberOfSelectedRows
+ ? 'all'
+ : 'some';
+
+ return allRowsSelectedStatus;
+ },
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/allRowsSelectedStatusSelectorScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/allRowsSelectedStatusSelectorScopeMap.ts
deleted file mode 100644
index ee0a66e804c..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/allRowsSelectedStatusSelectorScopeMap.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-import { createSelectorReadOnlyScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorReadOnlyScopeMap';
-
-import { AllRowsSelectedStatus } from '../../types/AllRowSelectedStatus';
-import { numberOfTableRowsStateScopeMap } from '../numberOfTableRowsStateScopeMap';
-
-import { selectedRowIdsSelectorScopeMap } from './selectedRowIdsSelectorScopeMap';
-
-export const allRowsSelectedStatusSelectorScopeMap =
- createSelectorReadOnlyScopeMap<AllRowsSelectedStatus>({
- key: 'allRowsSelectedStatusSelectorScopeMap',
- get:
- ({ scopeId }) =>
- ({ get }) => {
- const numberOfRows = get(numberOfTableRowsStateScopeMap({ scopeId }));
-
- const selectedRowIds = get(selectedRowIdsSelectorScopeMap({ scopeId }));
-
- const numberOfSelectedRows = selectedRowIds.length;
-
- const allRowsSelectedStatus =
- numberOfSelectedRows === 0
- ? 'none'
- : numberOfRows === numberOfSelectedRows
- ? 'all'
- : 'some';
-
- return allRowsSelectedStatus;
- },
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/hiddenTableColumnsSelectorScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/hiddenTableColumnsComponentSelector.ts
similarity index 57%
rename from packages/twenty-front/src/modules/object-record/record-table/states/selectors/hiddenTableColumnsSelectorScopeMap.ts
rename to packages/twenty-front/src/modules/object-record/record-table/states/selectors/hiddenTableColumnsComponentSelector.ts
index 1fcd14587ed..c6692670d42 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/hiddenTableColumnsSelectorScopeMap.ts
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/hiddenTableColumnsComponentSelector.ts
@@ -1,17 +1,17 @@
-import { availableTableColumnsStateScopeMap } from '@/object-record/record-table/states/availableTableColumnsStateScopeMap';
-import { tableColumnsStateScopeMap } from '@/object-record/record-table/states/tableColumnsStateScopeMap';
-import { createSelectorReadOnlyScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorReadOnlyScopeMap';
+import { availableTableColumnsComponentState } from '@/object-record/record-table/states/availableTableColumnsComponentState';
+import { tableColumnsComponentState } from '@/object-record/record-table/states/tableColumnsComponentState';
+import { createComponentReadOnlySelector } from '@/ui/utilities/state/component-state/utils/createComponentReadOnlySelector';
import { mapArrayToObject } from '~/utils/array/mapArrayToObject';
-export const hiddenTableColumnsSelectorScopeMap =
- createSelectorReadOnlyScopeMap({
- key: 'hiddenTableColumnsSelectorScopeMap',
+export const hiddenTableColumnsComponentSelector =
+ createComponentReadOnlySelector({
+ key: 'hiddenTableColumnsComponentSelector',
get:
({ scopeId }) =>
({ get }) => {
- const tableColumns = get(tableColumnsStateScopeMap({ scopeId }));
+ const tableColumns = get(tableColumnsComponentState({ scopeId }));
const availableColumns = get(
- availableTableColumnsStateScopeMap({ scopeId }),
+ availableTableColumnsComponentState({ scopeId }),
);
const tableColumnsByKey = mapArrayToObject(
tableColumns,
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/numberOfTableColumnsComponentSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/numberOfTableColumnsComponentSelector.ts
new file mode 100644
index 00000000000..83754490c11
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/numberOfTableColumnsComponentSelector.ts
@@ -0,0 +1,11 @@
+import { tableColumnsComponentState } from '@/object-record/record-table/states/tableColumnsComponentState';
+import { createComponentReadOnlySelector } from '@/ui/utilities/state/component-state/utils/createComponentReadOnlySelector';
+
+export const numberOfTableColumnsComponentSelector =
+ createComponentReadOnlySelector({
+ key: 'numberOfTableColumnsComponentSelector',
+ get:
+ ({ scopeId }) =>
+ ({ get }) =>
+ get(tableColumnsComponentState({ scopeId })).length,
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/numberOfTableColumnsSelectorScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/numberOfTableColumnsSelectorScopeMap.ts
deleted file mode 100644
index a4afd9ccbff..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/numberOfTableColumnsSelectorScopeMap.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { createSelectorReadOnlyScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorReadOnlyScopeMap';
-
-import { tableColumnsStateScopeMap } from '../tableColumnsStateScopeMap';
-
-export const numberOfTableColumnsSelectorScopeMap =
- createSelectorReadOnlyScopeMap({
- key: 'numberOfTableColumnsSelectorScopeMap',
- get:
- ({ scopeId }) =>
- ({ get }) =>
- get(tableColumnsStateScopeMap({ scopeId })).length,
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/selectedRowIdsComponentSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/selectedRowIdsComponentSelector.ts
new file mode 100644
index 00000000000..3a3a020c89b
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/selectedRowIdsComponentSelector.ts
@@ -0,0 +1,24 @@
+import { isRowSelectedComponentFamilyState } from '@/object-record/record-table/record-table-row/states/isRowSelectedComponentFamilyState';
+import { tableRowIdsComponentState } from '@/object-record/record-table/states/tableRowIdsComponentState';
+import { createComponentReadOnlySelector } from '@/ui/utilities/state/component-state/utils/createComponentReadOnlySelector';
+
+export const selectedRowIdsComponentSelector = createComponentReadOnlySelector<
+ string[]
+>({
+ key: 'selectedRowIdsComponentSelector',
+ get:
+ ({ scopeId }) =>
+ ({ get }) => {
+ const rowIds = get(tableRowIdsComponentState({ scopeId }));
+
+ return rowIds.filter(
+ (rowId) =>
+ get(
+ isRowSelectedComponentFamilyState({
+ scopeId,
+ familyKey: rowId,
+ }),
+ ) === true,
+ );
+ },
+});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/selectedRowIdsSelectorScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/selectedRowIdsSelectorScopeMap.ts
deleted file mode 100644
index b395c54d3dc..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/selectedRowIdsSelectorScopeMap.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { createSelectorReadOnlyScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorReadOnlyScopeMap';
-
-import { isRowSelectedFamilyStateScopeMap } from '../../record-table-row/states/isRowSelectedFamilyStateScopeMap';
-import { tableRowIdsStateScopeMap } from '../tableRowIdsStateScopeMap';
-
-export const selectedRowIdsSelectorScopeMap = createSelectorReadOnlyScopeMap<
- string[]
->({
- key: 'selectedRowIdsSelectorScopeMap',
- get:
- ({ scopeId }) =>
- ({ get }) => {
- const rowIds = get(tableRowIdsStateScopeMap({ scopeId }));
-
- return rowIds.filter(
- (rowId) =>
- get(
- isRowSelectedFamilyStateScopeMap({
- scopeId,
- familyKey: rowId,
- }),
- ) === true,
- );
- },
-});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/visibleTableColumnsComponentSelector.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/visibleTableColumnsComponentSelector.ts
new file mode 100644
index 00000000000..fc58195cad5
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/visibleTableColumnsComponentSelector.ts
@@ -0,0 +1,15 @@
+import { tableColumnsComponentState } from '@/object-record/record-table/states/tableColumnsComponentState';
+import { createComponentReadOnlySelector } from '@/ui/utilities/state/component-state/utils/createComponentReadOnlySelector';
+
+export const visibleTableColumnsComponentSelector =
+ createComponentReadOnlySelector({
+ key: 'visibleTableColumnsComponentSelector',
+ get:
+ ({ scopeId }) =>
+ ({ get }) => {
+ const columns = get(tableColumnsComponentState({ scopeId }));
+ return columns
+ .filter((column) => column.isVisible)
+ .sort((columnA, columnB) => columnA.position - columnB.position);
+ },
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/visibleTableColumnsSelectorScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/selectors/visibleTableColumnsSelectorScopeMap.ts
deleted file mode 100644
index 01a818edb61..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/selectors/visibleTableColumnsSelectorScopeMap.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { tableColumnsStateScopeMap } from '@/object-record/record-table/states/tableColumnsStateScopeMap';
-import { createSelectorReadOnlyScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorReadOnlyScopeMap';
-
-export const visibleTableColumnsSelectorScopeMap =
- createSelectorReadOnlyScopeMap({
- key: 'visibleTableColumnsSelectorScopeMap',
- get:
- ({ scopeId }) =>
- ({ get }) => {
- const columns = get(tableColumnsStateScopeMap({ scopeId }));
- return columns
- .filter((column) => column.isVisible)
- .sort((columnA, columnB) => columnA.position - columnB.position);
- },
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/softFocusPositionComponentState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/softFocusPositionComponentState.ts
new file mode 100644
index 00000000000..212b581cc7a
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/softFocusPositionComponentState.ts
@@ -0,0 +1,12 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+import { TableCellPosition } from '../types/TableCellPosition';
+
+export const softFocusPositionComponentState =
+ createComponentState<TableCellPosition>({
+ key: 'softFocusPositionComponentState',
+ defaultValue: {
+ row: 0,
+ column: 1,
+ },
+ });
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/softFocusPositionStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/softFocusPositionStateScopeMap.ts
deleted file mode 100644
index 5a4b87fb96a..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/softFocusPositionStateScopeMap.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-import { TableCellPosition } from '../types/TableCellPosition';
-
-export const softFocusPositionStateScopeMap =
- createStateScopeMap<TableCellPosition>({
- key: 'softFocusPositionStateScopeMap',
- defaultValue: {
- row: 0,
- column: 1,
- },
- });
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/tableColumnsStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/tableColumnsComponentState.ts
similarity index 50%
rename from packages/twenty-front/src/modules/object-record/record-table/states/tableColumnsStateScopeMap.ts
rename to packages/twenty-front/src/modules/object-record/record-table/states/tableColumnsComponentState.ts
index d04192bb62e..8c89c297259 100644
--- a/packages/twenty-front/src/modules/object-record/record-table/states/tableColumnsStateScopeMap.ts
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/tableColumnsComponentState.ts
@@ -1,11 +1,11 @@
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata';
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
import { ColumnDefinition } from '../types/ColumnDefinition';
-export const tableColumnsStateScopeMap = createStateScopeMap<
+export const tableColumnsComponentState = createComponentState<
ColumnDefinition<FieldMetadata>[]
>({
- key: 'tableColumnsStateScopeMap',
+ key: 'tableColumnsComponentState',
defaultValue: [],
});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/tableFiltersComponentState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/tableFiltersComponentState.ts
new file mode 100644
index 00000000000..d19698d0f90
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/tableFiltersComponentState.ts
@@ -0,0 +1,8 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+import { Filter } from '../../object-filter-dropdown/types/Filter';
+
+export const tableFiltersComponentState = createComponentState<Filter[]>({
+ key: 'tableFiltersComponentState',
+ defaultValue: [],
+});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/tableFiltersStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/tableFiltersStateScopeMap.ts
deleted file mode 100644
index 87c37e6f9a8..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/tableFiltersStateScopeMap.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-import { Filter } from '../../object-filter-dropdown/types/Filter';
-
-export const tableFiltersStateScopeMap = createStateScopeMap<Filter[]>({
- key: 'tableFiltersStateScopeMap',
- defaultValue: [],
-});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/tableLastRowVisibleComponentState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/tableLastRowVisibleComponentState.ts
new file mode 100644
index 00000000000..371cd72d6a0
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/tableLastRowVisibleComponentState.ts
@@ -0,0 +1,6 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const tableLastRowVisibleComponentState = createComponentState<boolean>({
+ key: 'tableLastRowVisibleComponentState',
+ defaultValue: false,
+});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/tableLastRowVisibleStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/tableLastRowVisibleStateScopeMap.ts
deleted file mode 100644
index 8648e7bbefd..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/tableLastRowVisibleStateScopeMap.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const tableLastRowVisibleStateScopeMap = createStateScopeMap<boolean>({
- key: 'tableLastRowVisibleStateScopeMap',
- defaultValue: false,
-});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/tableRowIdsComponentState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/tableRowIdsComponentState.ts
new file mode 100644
index 00000000000..5350c7f448d
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/tableRowIdsComponentState.ts
@@ -0,0 +1,6 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const tableRowIdsComponentState = createComponentState<string[]>({
+ key: 'tableRowIdsComponentState',
+ defaultValue: [],
+});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/tableRowIdsStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/tableRowIdsStateScopeMap.ts
deleted file mode 100644
index a9027a4edc3..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/tableRowIdsStateScopeMap.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const tableRowIdsStateScopeMap = createStateScopeMap<string[]>({
- key: 'tableRowIdsStateScopeMap',
- defaultValue: [],
-});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/tableSortsComponentState.ts b/packages/twenty-front/src/modules/object-record/record-table/states/tableSortsComponentState.ts
new file mode 100644
index 00000000000..e36730a2819
--- /dev/null
+++ b/packages/twenty-front/src/modules/object-record/record-table/states/tableSortsComponentState.ts
@@ -0,0 +1,8 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+import { Sort } from '../../object-sort-dropdown/types/Sort';
+
+export const tableSortsComponentState = createComponentState<Sort[]>({
+ key: 'tableSortsComponentState',
+ defaultValue: [],
+});
diff --git a/packages/twenty-front/src/modules/object-record/record-table/states/tableSortsStateScopeMap.ts b/packages/twenty-front/src/modules/object-record/record-table/states/tableSortsStateScopeMap.ts
deleted file mode 100644
index 2e1900a2b7d..00000000000
--- a/packages/twenty-front/src/modules/object-record/record-table/states/tableSortsStateScopeMap.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-import { Sort } from '../../object-sort-dropdown/types/Sort';
-
-export const tableSortsStateScopeMap = createStateScopeMap<Sort[]>({
- key: 'tableSortsStateScopeMap',
- defaultValue: [],
-});
diff --git a/packages/twenty-front/src/modules/object-record/relation-picker/hooks/__tests__/useMultiObjectRecordsQueryResultFormattedAsObjectRecordForSelectArray.test.tsx b/packages/twenty-front/src/modules/object-record/relation-picker/hooks/__tests__/useMultiObjectRecordsQueryResultFormattedAsObjectRecordForSelectArray.test.tsx
index decadcd2e51..92661b8e611 100644
--- a/packages/twenty-front/src/modules/object-record/relation-picker/hooks/__tests__/useMultiObjectRecordsQueryResultFormattedAsObjectRecordForSelectArray.test.tsx
+++ b/packages/twenty-front/src/modules/object-record/relation-picker/hooks/__tests__/useMultiObjectRecordsQueryResultFormattedAsObjectRecordForSelectArray.test.tsx
@@ -58,7 +58,7 @@ describe('useMultiObjectRecordsQueryResultFormattedAsObjectRecordForSelectArray'
},
},
),
- setObjectMetadata: useSetRecoilState(objectMetadataItemsState),
+ setObjectMetadata: useSetRecoilState(objectMetadataItemsState()),
};
},
{
diff --git a/packages/twenty-front/src/modules/object-record/relation-picker/hooks/__tests__/useMultiObjectSearch.test.tsx b/packages/twenty-front/src/modules/object-record/relation-picker/hooks/__tests__/useMultiObjectSearch.test.tsx
index a117719c04b..23dafb5788d 100644
--- a/packages/twenty-front/src/modules/object-record/relation-picker/hooks/__tests__/useMultiObjectSearch.test.tsx
+++ b/packages/twenty-front/src/modules/object-record/relation-picker/hooks/__tests__/useMultiObjectSearch.test.tsx
@@ -102,7 +102,7 @@ describe('useMultiObjectSearch', () => {
},
],
}),
- setObjectMetadata: useSetRecoilState(objectMetadataItemsState),
+ setObjectMetadata: useSetRecoilState(objectMetadataItemsState()),
}),
{
wrapper: Wrapper,
diff --git a/packages/twenty-front/src/modules/object-record/relation-picker/hooks/useMultiObjectSearchMatchesSearchFilterAndSelectedItemsQuery.ts b/packages/twenty-front/src/modules/object-record/relation-picker/hooks/useMultiObjectSearchMatchesSearchFilterAndSelectedItemsQuery.ts
index 635f2e7546d..2afb0c8ea93 100644
--- a/packages/twenty-front/src/modules/object-record/relation-picker/hooks/useMultiObjectSearchMatchesSearchFilterAndSelectedItemsQuery.ts
+++ b/packages/twenty-front/src/modules/object-record/relation-picker/hooks/useMultiObjectSearchMatchesSearchFilterAndSelectedItemsQuery.ts
@@ -25,7 +25,7 @@ export const useMultiObjectSearchMatchesSearchFilterAndSelectedItemsQuery = ({
searchFilterValue: string;
limit?: number;
}) => {
- const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
+ const objectMetadataItems = useRecoilValue(objectMetadataItemsState());
const { searchFilterPerMetadataItemNameSingular } =
useSearchFilterPerMetadataItem({
diff --git a/packages/twenty-front/src/modules/object-record/relation-picker/hooks/useMultiObjectSearchMatchesSearchFilterAndToSelectQuery.ts b/packages/twenty-front/src/modules/object-record/relation-picker/hooks/useMultiObjectSearchMatchesSearchFilterAndToSelectQuery.ts
index 538b6191984..6c17af6db24 100644
--- a/packages/twenty-front/src/modules/object-record/relation-picker/hooks/useMultiObjectSearchMatchesSearchFilterAndToSelectQuery.ts
+++ b/packages/twenty-front/src/modules/object-record/relation-picker/hooks/useMultiObjectSearchMatchesSearchFilterAndToSelectQuery.ts
@@ -28,7 +28,7 @@ export const useMultiObjectSearchMatchesSearchFilterAndToSelectQuery = ({
searchFilterValue: string;
limit?: number;
}) => {
- const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
+ const objectMetadataItems = useRecoilValue(objectMetadataItemsState());
const nonSystemObjectMetadataItems = objectMetadataItems.filter(
({ nameSingular, isSystem }) =>
diff --git a/packages/twenty-front/src/modules/object-record/relation-picker/hooks/useMultiObjectSearchSelectedItemsQuery.ts b/packages/twenty-front/src/modules/object-record/relation-picker/hooks/useMultiObjectSearchSelectedItemsQuery.ts
index 2c18f7d3bae..1d993dc61d7 100644
--- a/packages/twenty-front/src/modules/object-record/relation-picker/hooks/useMultiObjectSearchSelectedItemsQuery.ts
+++ b/packages/twenty-front/src/modules/object-record/relation-picker/hooks/useMultiObjectSearchSelectedItemsQuery.ts
@@ -26,7 +26,7 @@ export const useMultiObjectSearchSelectedItemsQuery = ({
}: {
selectedObjectRecordIds: SelectedObjectRecordId[];
}) => {
- const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
+ const objectMetadataItems = useRecoilValue(objectMetadataItemsState());
const objectMetadataItemsUsedInSelectedIdsQuery = objectMetadataItems.filter(
({ nameSingular }) => {
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 8e49b1267aa..3dbbfc7eff0 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 { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
-type RelationPickerScopeInternalContextProps = StateScopeMapKey;
+type RelationPickerScopeInternalContextProps = ComponentStateKey;
export const RelationPickerScopeInternalContext =
createScopeInternalContext<RelationPickerScopeInternalContextProps>();
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 2266afc5b33..c0c2ba232dd 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
-export const relationPickerPreselectedIdScopedState = createStateScopeMap<
+export const relationPickerPreselectedIdScopedState = createComponentState<
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 5184ff81074..60841557533 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,7 +1,7 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
export const relationPickerSearchFilterScopedState =
- createStateScopeMap<string>({
+ createComponentState<string>({
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 5f94b225a2d..70a072e0f79 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
-export const searchQueryScopedState = createStateScopeMap<SearchQuery | null>({
+export const searchQueryScopedState = createComponentState<SearchQuery | null>({
key: 'searchQueryScopedState',
defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/object-record/spreadsheet-import/__tests__/useSpreadsheetRecordImport.test.tsx b/packages/twenty-front/src/modules/object-record/spreadsheet-import/__tests__/useSpreadsheetRecordImport.test.tsx
index a26df2b1c81..248b81a94a5 100644
--- a/packages/twenty-front/src/modules/object-record/spreadsheet-import/__tests__/useSpreadsheetRecordImport.test.tsx
+++ b/packages/twenty-front/src/modules/object-record/spreadsheet-import/__tests__/useSpreadsheetRecordImport.test.tsx
@@ -75,7 +75,7 @@ describe('useSpreadsheetCompanyImport', () => {
it('should work as expected', async () => {
const { result } = renderHook(
() => {
- const spreadsheetImport = useRecoilValue(spreadsheetImportState);
+ const spreadsheetImport = useRecoilValue(spreadsheetImportState());
const { openRecordSpreadsheetImport } = useSpreadsheetRecordImport(
CoreObjectNameSingular.Company,
);
diff --git a/packages/twenty-front/src/modules/object-record/states/cursorFamilyState.ts b/packages/twenty-front/src/modules/object-record/states/cursorFamilyState.ts
index e9c44191e4b..44fb5742cb5 100644
--- a/packages/twenty-front/src/modules/object-record/states/cursorFamilyState.ts
+++ b/packages/twenty-front/src/modules/object-record/states/cursorFamilyState.ts
@@ -1,6 +1,6 @@
-import { atomFamily } from 'recoil';
+import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
-export const cursorFamilyState = atomFamily<string, string | undefined>({
+export const cursorFamilyState = createFamilyState<string, string | undefined>({
key: 'cursorFamilyState',
- default: '',
+ defaultValue: '',
});
diff --git a/packages/twenty-front/src/modules/object-record/states/hasNextPageFamilyState.ts b/packages/twenty-front/src/modules/object-record/states/hasNextPageFamilyState.ts
index 20260b92788..2a5f9e89478 100644
--- a/packages/twenty-front/src/modules/object-record/states/hasNextPageFamilyState.ts
+++ b/packages/twenty-front/src/modules/object-record/states/hasNextPageFamilyState.ts
@@ -1,6 +1,9 @@
-import { atomFamily } from 'recoil';
+import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
-export const hasNextPageFamilyState = atomFamily<boolean, string | undefined>({
+export const hasNextPageFamilyState = createFamilyState<
+ boolean,
+ string | undefined
+>({
key: 'hasNextPageFamilyState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/object-record/states/isFetchingMoreRecordsFamilyState.ts b/packages/twenty-front/src/modules/object-record/states/isFetchingMoreRecordsFamilyState.ts
index 4137f67a710..e254f92318c 100644
--- a/packages/twenty-front/src/modules/object-record/states/isFetchingMoreRecordsFamilyState.ts
+++ b/packages/twenty-front/src/modules/object-record/states/isFetchingMoreRecordsFamilyState.ts
@@ -1,9 +1,9 @@
-import { atomFamily } from 'recoil';
+import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
-export const isFetchingMoreRecordsFamilyState = atomFamily<
+export const isFetchingMoreRecordsFamilyState = createFamilyState<
boolean,
string | undefined
>({
key: 'isFetchingMoreRecordsFamilyState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/search/hooks/__tests__/useFilteredSearchEntityQuery.test.tsx b/packages/twenty-front/src/modules/search/hooks/__tests__/useFilteredSearchEntityQuery.test.tsx
index 57a93cdec66..ea46bac44bf 100644
--- a/packages/twenty-front/src/modules/search/hooks/__tests__/useFilteredSearchEntityQuery.test.tsx
+++ b/packages/twenty-front/src/modules/search/hooks/__tests__/useFilteredSearchEntityQuery.test.tsx
@@ -67,7 +67,7 @@ describe('useFilteredSearchEntityQuery', () => {
const { result } = renderHook(
() => {
const setCurrentWorkspaceMember = useSetRecoilState(
- currentWorkspaceMemberState,
+ currentWorkspaceMemberState(),
);
setCurrentWorkspaceMember({
id: '32219445-f587-4c40-b2b1-6d3205ed96da',
@@ -76,7 +76,7 @@ describe('useFilteredSearchEntityQuery', () => {
const mockObjectMetadataItems = getObjectMetadataItemsMock();
- const setMetadataItems = useSetRecoilState(objectMetadataItemsState);
+ const setMetadataItems = useSetRecoilState(objectMetadataItemsState());
setMetadataItems(mockObjectMetadataItems);
diff --git a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsCalendarAccountsListCard.tsx b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsCalendarAccountsListCard.tsx
index 5425976316e..b157fb588fc 100644
--- a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsCalendarAccountsListCard.tsx
+++ b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsCalendarAccountsListCard.tsx
@@ -20,7 +20,7 @@ const StyledRowRightContainer = styled.div`
`;
export const SettingsAccountsCalendarAccountsListCard = () => {
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
const navigate = useNavigate();
const { records: _accounts, loading } = useFindManyRecords<ConnectedAccount>({
diff --git a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsEmailsAccountsListCard.tsx b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsEmailsAccountsListCard.tsx
index 2fc6154f1e4..7999f062b9a 100644
--- a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsEmailsAccountsListCard.tsx
+++ b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsEmailsAccountsListCard.tsx
@@ -20,7 +20,7 @@ const StyledRowRightContainer = styled.div`
`;
export const SettingsAccountsEmailsAccountsListCard = () => {
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
const navigate = useNavigate();
const { records: accounts, loading: accountsLoading } =
diff --git a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsEmailsBlocklistSection.tsx b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsEmailsBlocklistSection.tsx
index 28646b9d8cb..03e6a9e25bd 100644
--- a/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsEmailsBlocklistSection.tsx
+++ b/packages/twenty-front/src/modules/settings/accounts/components/SettingsAccountsEmailsBlocklistSection.tsx
@@ -12,7 +12,7 @@ import { H2Title } from '@/ui/display/typography/components/H2Title';
import { Section } from '@/ui/layout/section/components/Section';
export const SettingsAccountsEmailsBlocklistSection = () => {
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
const { records: blocklist } = useFindManyRecords<BlocklistItem>({
objectNameSingular: CoreObjectNameSingular.Blocklist,
diff --git a/packages/twenty-front/src/modules/settings/developers/states/generatedApiKeyFamilyState.ts b/packages/twenty-front/src/modules/settings/developers/states/generatedApiKeyFamilyState.ts
index 329e1b6487b..f12c24e7dda 100644
--- a/packages/twenty-front/src/modules/settings/developers/states/generatedApiKeyFamilyState.ts
+++ b/packages/twenty-front/src/modules/settings/developers/states/generatedApiKeyFamilyState.ts
@@ -1,9 +1,9 @@
-import { atomFamily } from 'recoil';
+import { createFamilyState } from '@/ui/utilities/state/utils/createFamilyState';
-export const generatedApiKeyFamilyState = atomFamily<
+export const generatedApiKeyFamilyState = createFamilyState<
string | null | undefined,
string
>({
key: 'generatedApiKeyFamilyState',
- default: null,
+ defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/settings/profile/components/ChangePassword.tsx b/packages/twenty-front/src/modules/settings/profile/components/ChangePassword.tsx
index ee60971528c..eb08cd04526 100644
--- a/packages/twenty-front/src/modules/settings/profile/components/ChangePassword.tsx
+++ b/packages/twenty-front/src/modules/settings/profile/components/ChangePassword.tsx
@@ -9,7 +9,7 @@ import { useEmailPasswordResetLinkMutation } from '~/generated/graphql';
export const ChangePassword = () => {
const { enqueueSnackBar } = useSnackBar();
- const currentUser = useRecoilValue(currentUserState);
+ const currentUser = useRecoilValue(currentUserState());
const [emailPasswordResetLink] = useEmailPasswordResetLinkMutation();
diff --git a/packages/twenty-front/src/modules/settings/profile/components/DeleteAccount.tsx b/packages/twenty-front/src/modules/settings/profile/components/DeleteAccount.tsx
index d3e52ad09ec..bd0de3f17a2 100644
--- a/packages/twenty-front/src/modules/settings/profile/components/DeleteAccount.tsx
+++ b/packages/twenty-front/src/modules/settings/profile/components/DeleteAccount.tsx
@@ -15,7 +15,7 @@ export const DeleteAccount = () => {
useState(false);
const [deleteUserAccount] = useDeleteUserAccountMutation();
- const currentUser = useRecoilValue(currentUserState);
+ const currentUser = useRecoilValue(currentUserState());
const userEmail = currentUser?.email;
const { signOut } = useAuth();
const navigate = useNavigate();
diff --git a/packages/twenty-front/src/modules/settings/profile/components/DeleteWorkspace.tsx b/packages/twenty-front/src/modules/settings/profile/components/DeleteWorkspace.tsx
index 4264bd92829..b0fcdf1215e 100644
--- a/packages/twenty-front/src/modules/settings/profile/components/DeleteWorkspace.tsx
+++ b/packages/twenty-front/src/modules/settings/profile/components/DeleteWorkspace.tsx
@@ -17,7 +17,7 @@ export const DeleteWorkspace = () => {
useState(false);
const [deleteCurrentWorkspace] = useDeleteCurrentWorkspaceMutation();
- const currentUser = useRecoilValue(currentUserState);
+ const currentUser = useRecoilValue(currentUserState());
const userEmail = currentUser?.email;
const { signOut } = useAuth();
const navigate = useNavigate();
diff --git a/packages/twenty-front/src/modules/settings/profile/components/EmailField.tsx b/packages/twenty-front/src/modules/settings/profile/components/EmailField.tsx
index 02c1e87341a..80494ebbbee 100644
--- a/packages/twenty-front/src/modules/settings/profile/components/EmailField.tsx
+++ b/packages/twenty-front/src/modules/settings/profile/components/EmailField.tsx
@@ -4,7 +4,7 @@ import { currentUserState } from '@/auth/states/currentUserState';
import { TextInput } from '@/ui/input/components/TextInput';
export const EmailField = () => {
- const currentUser = useRecoilValue(currentUserState);
+ const currentUser = useRecoilValue(currentUserState());
return (
<TextInput
diff --git a/packages/twenty-front/src/modules/settings/profile/components/NameFields.tsx b/packages/twenty-front/src/modules/settings/profile/components/NameFields.tsx
index 7db7cd24b5f..22ceb53e0bd 100644
--- a/packages/twenty-front/src/modules/settings/profile/components/NameFields.tsx
+++ b/packages/twenty-front/src/modules/settings/profile/components/NameFields.tsx
@@ -29,9 +29,9 @@ export const NameFields = ({
onFirstNameUpdate,
onLastNameUpdate,
}: NameFieldsProps) => {
- const currentUser = useRecoilValue(currentUserState);
+ const currentUser = useRecoilValue(currentUserState());
const [currentWorkspaceMember, setCurrentWorkspaceMember] = useRecoilState(
- currentWorkspaceMemberState,
+ currentWorkspaceMemberState(),
);
const [firstName, setFirstName] = useState(
diff --git a/packages/twenty-front/src/modules/settings/profile/components/ProfilePictureUploader.tsx b/packages/twenty-front/src/modules/settings/profile/components/ProfilePictureUploader.tsx
index 751422c6f7e..47a8f4033db 100644
--- a/packages/twenty-front/src/modules/settings/profile/components/ProfilePictureUploader.tsx
+++ b/packages/twenty-front/src/modules/settings/profile/components/ProfilePictureUploader.tsx
@@ -15,7 +15,7 @@ export const ProfilePictureUploader = () => {
useUploadProfilePictureMutation();
const [currentWorkspaceMember, setCurrentWorkspaceMember] = useRecoilState(
- currentWorkspaceMemberState,
+ currentWorkspaceMemberState(),
);
const [uploadController, setUploadController] =
diff --git a/packages/twenty-front/src/modules/settings/workspace/components/NameField.tsx b/packages/twenty-front/src/modules/settings/workspace/components/NameField.tsx
index f7337f9847d..1b0fb6cdc84 100644
--- a/packages/twenty-front/src/modules/settings/workspace/components/NameField.tsx
+++ b/packages/twenty-front/src/modules/settings/workspace/components/NameField.tsx
@@ -27,7 +27,7 @@ export const NameField = ({
autoSave = true,
onNameUpdate,
}: NameFieldProps) => {
- const currentWorkspace = useRecoilValue(currentWorkspaceState);
+ const currentWorkspace = useRecoilValue(currentWorkspaceState());
const [displayName, setDisplayName] = useState(
currentWorkspace?.displayName ?? '',
diff --git a/packages/twenty-front/src/modules/settings/workspace/components/ToggleImpersonate.tsx b/packages/twenty-front/src/modules/settings/workspace/components/ToggleImpersonate.tsx
index 453cfc21dd0..ebb909ede87 100644
--- a/packages/twenty-front/src/modules/settings/workspace/components/ToggleImpersonate.tsx
+++ b/packages/twenty-front/src/modules/settings/workspace/components/ToggleImpersonate.tsx
@@ -9,7 +9,7 @@ export const ToggleImpersonate = () => {
const { enqueueSnackBar } = useSnackBar();
const [currentWorkspace, setCurrentWorkspace] = useRecoilState(
- currentWorkspaceState,
+ currentWorkspaceState(),
);
const [updateWorkspace] = useUpdateWorkspaceMutation();
diff --git a/packages/twenty-front/src/modules/settings/workspace/components/WorkspaceLogoUploader.tsx b/packages/twenty-front/src/modules/settings/workspace/components/WorkspaceLogoUploader.tsx
index 7f004a59993..b8ca38179ae 100644
--- a/packages/twenty-front/src/modules/settings/workspace/components/WorkspaceLogoUploader.tsx
+++ b/packages/twenty-front/src/modules/settings/workspace/components/WorkspaceLogoUploader.tsx
@@ -13,7 +13,7 @@ export const WorkspaceLogoUploader = () => {
const [uploadLogo] = useUploadWorkspaceLogoMutation();
const [updateWorkspce] = useUpdateWorkspaceMutation();
const [currentWorkspace, setCurrentWorkspace] = useRecoilState(
- currentWorkspaceState,
+ currentWorkspaceState(),
);
const onUpload = async (file: File) => {
diff --git a/packages/twenty-front/src/modules/spreadsheet-import/hooks/__tests__/useSpreadsheetImport.test.tsx b/packages/twenty-front/src/modules/spreadsheet-import/hooks/__tests__/useSpreadsheetImport.test.tsx
index c54a5498a53..a2948066346 100644
--- a/packages/twenty-front/src/modules/spreadsheet-import/hooks/__tests__/useSpreadsheetImport.test.tsx
+++ b/packages/twenty-front/src/modules/spreadsheet-import/hooks/__tests__/useSpreadsheetImport.test.tsx
@@ -44,7 +44,7 @@ describe('useSpreadsheetImport', () => {
const { result } = renderHook(
() => ({
useSpreadsheetImport: useSpreadsheetImport<SpreadsheetKey>(),
- spreadsheetImportState: useRecoilState(spreadsheetImportState)[0],
+ spreadsheetImportState: useRecoilState(spreadsheetImportState())[0],
}),
{
wrapper: Wrapper,
diff --git a/packages/twenty-front/src/modules/spreadsheet-import/hooks/useSpreadsheetImport.ts b/packages/twenty-front/src/modules/spreadsheet-import/hooks/useSpreadsheetImport.ts
index 0259faad604..160ba49caa8 100644
--- a/packages/twenty-front/src/modules/spreadsheet-import/hooks/useSpreadsheetImport.ts
+++ b/packages/twenty-front/src/modules/spreadsheet-import/hooks/useSpreadsheetImport.ts
@@ -4,7 +4,7 @@ import { spreadsheetImportState } from '@/spreadsheet-import/states/spreadsheetI
import { SpreadsheetOptions } from '@/spreadsheet-import/types';
export const useSpreadsheetImport = <T extends string>() => {
- const setSpreadSheetImport = useSetRecoilState(spreadsheetImportState);
+ const setSpreadSheetImport = useSetRecoilState(spreadsheetImportState());
const openSpreadsheetImport = (
options: Omit<SpreadsheetOptions<T>, 'isOpen' | 'onClose'>,
diff --git a/packages/twenty-front/src/modules/spreadsheet-import/provider/components/SpreadsheetImportProvider.tsx b/packages/twenty-front/src/modules/spreadsheet-import/provider/components/SpreadsheetImportProvider.tsx
index 5c5b7a13770..3bec782699d 100644
--- a/packages/twenty-front/src/modules/spreadsheet-import/provider/components/SpreadsheetImportProvider.tsx
+++ b/packages/twenty-front/src/modules/spreadsheet-import/provider/components/SpreadsheetImportProvider.tsx
@@ -11,7 +11,7 @@ export const SpreadsheetImportProvider = (
props: SpreadsheetImportProviderProps,
) => {
const [spreadsheetImport, setSpreadsheetImport] = useRecoilState(
- spreadsheetImportState,
+ spreadsheetImportState(),
);
const handleClose = () => {
diff --git a/packages/twenty-front/src/modules/spreadsheet-import/states/spreadsheetImportState.ts b/packages/twenty-front/src/modules/spreadsheet-import/states/spreadsheetImportState.ts
index d1f0da412b7..5bb6d2fdad1 100644
--- a/packages/twenty-front/src/modules/spreadsheet-import/states/spreadsheetImportState.ts
+++ b/packages/twenty-front/src/modules/spreadsheet-import/states/spreadsheetImportState.ts
@@ -1,4 +1,4 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
import { SpreadsheetOptions } from '../types';
@@ -7,9 +7,9 @@ export type SpreadsheetImportState<T extends string> = {
options: Omit<SpreadsheetOptions<T>, 'isOpen' | 'onClose'> | null;
};
-export const spreadsheetImportState = atom<SpreadsheetImportState<any>>({
+export const spreadsheetImportState = createState<SpreadsheetImportState<any>>({
key: 'spreadsheetImportState',
- default: {
+ defaultValue: {
isOpen: false,
options: null,
},
diff --git a/packages/twenty-front/src/modules/support/components/SupportChat.tsx b/packages/twenty-front/src/modules/support/components/SupportChat.tsx
index 7a0818c7bbd..a9c609ccbfe 100644
--- a/packages/twenty-front/src/modules/support/components/SupportChat.tsx
+++ b/packages/twenty-front/src/modules/support/components/SupportChat.tsx
@@ -33,9 +33,9 @@ const insertScript = ({
};
export const SupportChat = () => {
- const currentUser = useRecoilValue(currentUserState);
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
- const supportChat = useRecoilValue(supportChatState);
+ const currentUser = useRecoilValue(currentUserState());
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
+ const supportChat = useRecoilValue(supportChatState());
const [isFrontChatLoaded, setIsFrontChatLoaded] = useState(false);
const configureFront = useCallback(
diff --git a/packages/twenty-front/src/modules/ui/display/icon/components/IconsProvider.tsx b/packages/twenty-front/src/modules/ui/display/icon/components/IconsProvider.tsx
index 918d7d32d60..16112d90fcb 100644
--- a/packages/twenty-front/src/modules/ui/display/icon/components/IconsProvider.tsx
+++ b/packages/twenty-front/src/modules/ui/display/icon/components/IconsProvider.tsx
@@ -8,7 +8,7 @@ type IconsProviderProps = {
};
export const IconsProvider = ({ children }: IconsProviderProps) => {
- const setIcons = useSetRecoilState(iconsState);
+ const setIcons = useSetRecoilState(iconsState());
useEffect(() => {
import('../constants/index').then((lazyLoadedIcons) => {
diff --git a/packages/twenty-front/src/modules/ui/display/icon/hooks/useIcons.ts b/packages/twenty-front/src/modules/ui/display/icon/hooks/useIcons.ts
index 4efd71e7f63..e3619b770da 100644
--- a/packages/twenty-front/src/modules/ui/display/icon/hooks/useIcons.ts
+++ b/packages/twenty-front/src/modules/ui/display/icon/hooks/useIcons.ts
@@ -4,7 +4,7 @@ import { Icon123 } from '@/ui/display/icon';
import { iconsState } from '@/ui/display/icon/states/iconsState';
export const useIcons = () => {
- const icons = useRecoilValue(iconsState);
+ const icons = useRecoilValue(iconsState());
const defaultIcon = Icon123;
const getIcons = () => {
diff --git a/packages/twenty-front/src/modules/ui/display/icon/states/iconsState.ts b/packages/twenty-front/src/modules/ui/display/icon/states/iconsState.ts
index 4f489150a76..e2d7a2e8e34 100644
--- a/packages/twenty-front/src/modules/ui/display/icon/states/iconsState.ts
+++ b/packages/twenty-front/src/modules/ui/display/icon/states/iconsState.ts
@@ -1,8 +1,7 @@
-import { atom } from 'recoil';
-
import { IconComponent } from '@/ui/display/icon/types/IconComponent';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const iconsState = atom<Record<string, IconComponent>>({
+export const iconsState = createState<Record<string, IconComponent>>({
key: 'iconsState',
- default: {},
+ defaultValue: {},
});
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 428596e8f44..fb6183db810 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 { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
-type DialogManagerScopeInternalContextProps = StateScopeMapKey;
+type DialogManagerScopeInternalContextProps = ComponentStateKey;
export const DialogManagerScopeInternalContext =
createScopeInternalContext<DialogManagerScopeInternalContextProps>();
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 13bc5cb7df0..4f8c44a3454 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
import { DialogOptions } from '../types/DialogOptions';
@@ -7,7 +7,7 @@ type DialogState = {
queue: DialogOptions[];
};
-export const dialogInternalScopedState = createStateScopeMap<DialogState>({
+export const dialogInternalScopedState = createComponentState<DialogState>({
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 274d356a84c..75b7e1e1358 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 { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
-type SnackBarManagerScopeInternalContextProps = StateScopeMapKey;
+type SnackBarManagerScopeInternalContextProps = ComponentStateKey;
export const SnackBarManagerScopeInternalContext =
createScopeInternalContext<SnackBarManagerScopeInternalContextProps>();
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 e6f613fcdf0..a880abccceb 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
import { SnackBarProps } from '../components/SnackBar';
@@ -11,7 +11,7 @@ export type SnackBarState = {
queue: SnackBarOptions[];
};
-export const snackBarInternalScopedState = createStateScopeMap<SnackBarState>({
+export const snackBarInternalScopedState = createComponentState<SnackBarState>({
key: 'snackBarState',
defaultValue: {
maxQueue: 3,
diff --git a/packages/twenty-front/src/modules/ui/input/hooks/useIconPicker.ts b/packages/twenty-front/src/modules/ui/input/hooks/useIconPicker.ts
index 141431c715c..998dd0dee4d 100644
--- a/packages/twenty-front/src/modules/ui/input/hooks/useIconPicker.ts
+++ b/packages/twenty-front/src/modules/ui/input/hooks/useIconPicker.ts
@@ -3,7 +3,7 @@ import { useRecoilState } from 'recoil';
import { iconPickerState } from '../states/iconPickerState';
export const useIconPicker = () => {
- const [iconPicker, setIconPicker] = useRecoilState(iconPickerState);
+ const [iconPicker, setIconPicker] = useRecoilState(iconPickerState());
return {
Icon: iconPicker.Icon,
diff --git a/packages/twenty-front/src/modules/ui/input/states/iconPickerState.ts b/packages/twenty-front/src/modules/ui/input/states/iconPickerState.ts
index f2698c00779..5a2926bb910 100644
--- a/packages/twenty-front/src/modules/ui/input/states/iconPickerState.ts
+++ b/packages/twenty-front/src/modules/ui/input/states/iconPickerState.ts
@@ -1,14 +1,13 @@
-import { atom } from 'recoil';
-
import { IconApps } from '@/ui/display/icon';
import { IconComponent } from '@/ui/display/icon/types/IconComponent';
+import { createState } from '@/ui/utilities/state/utils/createState';
type IconPickerState = {
Icon: IconComponent;
iconKey: string;
};
-export const iconPickerState = atom<IconPickerState>({
+export const iconPickerState = createState<IconPickerState>({
key: 'iconPickerState',
- default: { Icon: IconApps, iconKey: 'IconApps' },
+ defaultValue: { Icon: IconApps, iconKey: 'IconApps' },
});
diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/internal/useDropdownStates.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/internal/useDropdownStates.ts
index b0f35ce5859..c976f2bd003 100644
--- a/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/internal/useDropdownStates.ts
+++ b/packages/twenty-front/src/modules/ui/layout/dropdown/hooks/internal/useDropdownStates.ts
@@ -1,9 +1,9 @@
import { DropdownScopeInternalContext } from '@/ui/layout/dropdown/scopes/scope-internal-context/DropdownScopeInternalContext';
-import { dropdownHotkeyStateScopeMap } from '@/ui/layout/dropdown/states/dropdownHotkeyStateScopeMap';
-import { dropdownWidthStateScopeMap } from '@/ui/layout/dropdown/states/dropdownWidthStateScopeMap';
-import { isDropdownOpenStateScopeMap } from '@/ui/layout/dropdown/states/isDropdownOpenStateScopeMap';
+import { dropdownHotkeyComponentState } from '@/ui/layout/dropdown/states/dropdownHotkeyComponentState';
+import { dropdownWidthComponentState } from '@/ui/layout/dropdown/states/dropdownWidthComponentState';
+import { isDropdownOpenComponentState } from '@/ui/layout/dropdown/states/isDropdownOpenComponentState';
import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';
-import { getState } from '@/ui/utilities/recoil-scope/utils/getState';
+import { extractComponentState } from '@/ui/utilities/state/component-state/utils/extractComponentState';
type UseDropdownStatesProps = {
dropdownScopeId?: string;
@@ -19,8 +19,17 @@ export const useDropdownStates = ({
return {
scopeId,
- dropdownHotkeyScopeState: getState(dropdownHotkeyStateScopeMap, scopeId),
- dropdownWidthState: getState(dropdownWidthStateScopeMap, scopeId),
- isDropdownOpenState: getState(isDropdownOpenStateScopeMap, scopeId),
+ dropdownHotkeyScopeState: extractComponentState(
+ dropdownHotkeyComponentState,
+ scopeId,
+ ),
+ dropdownWidthState: extractComponentState(
+ dropdownWidthComponentState,
+ scopeId,
+ ),
+ isDropdownOpenState: extractComponentState(
+ isDropdownOpenComponentState,
+ scopeId,
+ ),
};
};
diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/scopes/scope-internal-context/DropdownScopeInternalContext.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/scopes/scope-internal-context/DropdownScopeInternalContext.ts
index 5b6ae045b9c..0d117b23f22 100644
--- a/packages/twenty-front/src/modules/ui/layout/dropdown/scopes/scope-internal-context/DropdownScopeInternalContext.ts
+++ b/packages/twenty-front/src/modules/ui/layout/dropdown/scopes/scope-internal-context/DropdownScopeInternalContext.ts
@@ -1,7 +1,7 @@
-import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
-type DropdownScopeInternalContextProps = StateScopeMapKey;
+type DropdownScopeInternalContextProps = ComponentStateKey;
export const DropdownScopeInternalContext =
createScopeInternalContext<DropdownScopeInternalContextProps>();
diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownHotkeyComponentState.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownHotkeyComponentState.ts
new file mode 100644
index 00000000000..72947255547
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownHotkeyComponentState.ts
@@ -0,0 +1,9 @@
+import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const dropdownHotkeyComponentState = createComponentState<
+ HotkeyScope | null | undefined
+>({
+ key: 'dropdownHotkeyComponentState',
+ defaultValue: null,
+});
diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownHotkeyStateScopeMap.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownHotkeyStateScopeMap.ts
deleted file mode 100644
index 60951e8f5a1..00000000000
--- a/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownHotkeyStateScopeMap.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const dropdownHotkeyStateScopeMap = createStateScopeMap<
- HotkeyScope | null | undefined
->({
- key: 'dropdownHotkeyStateScopeMap',
- defaultValue: null,
-});
diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownWidthComponentState.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownWidthComponentState.ts
new file mode 100644
index 00000000000..a9879b5f015
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownWidthComponentState.ts
@@ -0,0 +1,8 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const dropdownWidthComponentState = createComponentState<
+ number | undefined
+>({
+ key: 'dropdownWidthComponentState',
+ defaultValue: 160,
+});
diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownWidthStateScopeMap.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownWidthStateScopeMap.ts
deleted file mode 100644
index 9a39a52fd15..00000000000
--- a/packages/twenty-front/src/modules/ui/layout/dropdown/states/dropdownWidthStateScopeMap.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const dropdownWidthStateScopeMap = createStateScopeMap<
- number | undefined
->({
- key: 'dropdownWidthStateScopeMap',
- defaultValue: 160,
-});
diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/states/isDropdownOpenComponentState.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/states/isDropdownOpenComponentState.ts
new file mode 100644
index 00000000000..22aa5bc6699
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/dropdown/states/isDropdownOpenComponentState.ts
@@ -0,0 +1,6 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const isDropdownOpenComponentState = createComponentState<boolean>({
+ key: 'isDropdownOpenComponentState',
+ defaultValue: false,
+});
diff --git a/packages/twenty-front/src/modules/ui/layout/dropdown/states/isDropdownOpenStateScopeMap.ts b/packages/twenty-front/src/modules/ui/layout/dropdown/states/isDropdownOpenStateScopeMap.ts
deleted file mode 100644
index 124ae55be51..00000000000
--- a/packages/twenty-front/src/modules/ui/layout/dropdown/states/isDropdownOpenStateScopeMap.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const isDropdownOpenStateScopeMap = createStateScopeMap<boolean>({
- key: 'isDropdownOpenStateScopeMap',
- defaultValue: false,
-});
diff --git a/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawer.tsx b/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawer.tsx
index 1543b1f67b2..69289ef3d0e 100644
--- a/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawer.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawer.tsx
@@ -2,7 +2,7 @@ import { useRef } from 'react';
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { motion } from 'framer-motion';
-import { useRecoilState } from 'recoil';
+import { useRecoilState, useRecoilValue } from 'recoil';
import { Key } from 'ts-key-enum';
import { RIGHT_DRAWER_CLICK_OUTSIDE_LISTENER_ID } from '@/ui/layout/right-drawer/constants/RightDrawerClickOutsideListener';
@@ -41,12 +41,12 @@ const StyledRightDrawer = styled.div`
export const RightDrawer = () => {
const [isRightDrawerOpen, setIsRightDrawerOpen] = useRecoilState(
- isRightDrawerOpenState,
+ isRightDrawerOpenState(),
);
- const [isRightDrawerExpanded] = useRecoilState(isRightDrawerExpandedState);
+ const isRightDrawerExpanded = useRecoilValue(isRightDrawerExpandedState());
- const [rightDrawerPage] = useRecoilState(rightDrawerPageState);
+ const rightDrawerPage = useRecoilValue(rightDrawerPageState());
const { closeRightDrawer } = useRightDrawer();
diff --git a/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawerRouter.tsx b/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawerRouter.tsx
index d35dc5781cc..cb981739beb 100644
--- a/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawerRouter.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawerRouter.tsx
@@ -28,7 +28,7 @@ const StyledRightDrawerBody = styled.div`
`;
export const RightDrawerRouter = () => {
- const [rightDrawerPage] = useRecoilState(rightDrawerPageState);
+ const [rightDrawerPage] = useRecoilState(rightDrawerPageState());
let page = <></>;
let topBar = <></>;
diff --git a/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawerTopBarExpandButton.tsx b/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawerTopBarExpandButton.tsx
index 701c69edfab..d22700e7324 100644
--- a/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawerTopBarExpandButton.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/right-drawer/components/RightDrawerTopBarExpandButton.tsx
@@ -10,7 +10,7 @@ import { isRightDrawerExpandedState } from '../states/isRightDrawerExpandedState
export const RightDrawerTopBarExpandButton = () => {
const [isRightDrawerExpanded, setIsRightDrawerExpanded] = useRecoilState(
- isRightDrawerExpandedState,
+ isRightDrawerExpandedState(),
);
const handleButtonClick = () => {
diff --git a/packages/twenty-front/src/modules/ui/layout/right-drawer/hooks/__tests__/useRightDrawer.test.tsx b/packages/twenty-front/src/modules/ui/layout/right-drawer/hooks/__tests__/useRightDrawer.test.tsx
index 843de0118c6..727f6a7ca90 100644
--- a/packages/twenty-front/src/modules/ui/layout/right-drawer/hooks/__tests__/useRightDrawer.test.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/right-drawer/hooks/__tests__/useRightDrawer.test.tsx
@@ -12,10 +12,12 @@ describe('useRightDrawer', () => {
it('Should test the default behavior of useRightDrawer and change the states as the function calls', async () => {
const useCombinedHooks = () => {
const { openRightDrawer, closeRightDrawer } = useRightDrawer();
- const isRightDrawerOpen = useRecoilValue(isRightDrawerOpenState);
- const isRightDrawerExpanded = useRecoilValue(isRightDrawerExpandedState);
+ const isRightDrawerOpen = useRecoilValue(isRightDrawerOpenState());
+ const isRightDrawerExpanded = useRecoilValue(
+ isRightDrawerExpandedState(),
+ );
- const rightDrawerPage = useRecoilValue(rightDrawerPageState);
+ const rightDrawerPage = useRecoilValue(rightDrawerPageState());
return {
openRightDrawer,
diff --git a/packages/twenty-front/src/modules/ui/layout/right-drawer/hooks/useRightDrawer.ts b/packages/twenty-front/src/modules/ui/layout/right-drawer/hooks/useRightDrawer.ts
index 08cb391cc8b..a6cb22d7f18 100644
--- a/packages/twenty-front/src/modules/ui/layout/right-drawer/hooks/useRightDrawer.ts
+++ b/packages/twenty-front/src/modules/ui/layout/right-drawer/hooks/useRightDrawer.ts
@@ -1,4 +1,4 @@
-import { useRecoilState } from 'recoil';
+import { useRecoilState, useSetRecoilState } from 'recoil';
import { isRightDrawerExpandedState } from '../states/isRightDrawerExpandedState';
import { isRightDrawerOpenState } from '../states/isRightDrawerOpenState';
@@ -7,14 +7,15 @@ import { RightDrawerPages } from '../types/RightDrawerPages';
export const useRightDrawer = () => {
const [isRightDrawerOpen, setIsRightDrawerOpen] = useRecoilState(
- isRightDrawerOpenState,
+ isRightDrawerOpenState(),
);
- const [, setIsRightDrawerExpanded] = useRecoilState(
- isRightDrawerExpandedState,
+ const setIsRightDrawerExpanded = useSetRecoilState(
+ isRightDrawerExpandedState(),
);
- const [rightDrawerPage, setRightDrawerPage] =
- useRecoilState(rightDrawerPageState);
+ const [rightDrawerPage, setRightDrawerPage] = useRecoilState(
+ rightDrawerPageState(),
+ );
const openRightDrawer = (rightDrawerPage: RightDrawerPages) => {
setRightDrawerPage(rightDrawerPage);
diff --git a/packages/twenty-front/src/modules/ui/layout/right-drawer/states/isRightDrawerExpandedState.ts b/packages/twenty-front/src/modules/ui/layout/right-drawer/states/isRightDrawerExpandedState.ts
index 09a450fc1c4..8a871b26176 100644
--- a/packages/twenty-front/src/modules/ui/layout/right-drawer/states/isRightDrawerExpandedState.ts
+++ b/packages/twenty-front/src/modules/ui/layout/right-drawer/states/isRightDrawerExpandedState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const isRightDrawerExpandedState = atom<boolean>({
+export const isRightDrawerExpandedState = createState<boolean>({
key: 'isRightDrawerExpandedState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/ui/layout/right-drawer/states/isRightDrawerOpenState.ts b/packages/twenty-front/src/modules/ui/layout/right-drawer/states/isRightDrawerOpenState.ts
index fcfd6297521..749bb1b0003 100644
--- a/packages/twenty-front/src/modules/ui/layout/right-drawer/states/isRightDrawerOpenState.ts
+++ b/packages/twenty-front/src/modules/ui/layout/right-drawer/states/isRightDrawerOpenState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const isRightDrawerOpenState = atom<boolean>({
+export const isRightDrawerOpenState = createState<boolean>({
key: 'ui/layout/is-right-drawer-open',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/ui/layout/right-drawer/states/rightDrawerPageState.ts b/packages/twenty-front/src/modules/ui/layout/right-drawer/states/rightDrawerPageState.ts
index 8d0de858e27..ba023e66dbe 100644
--- a/packages/twenty-front/src/modules/ui/layout/right-drawer/states/rightDrawerPageState.ts
+++ b/packages/twenty-front/src/modules/ui/layout/right-drawer/states/rightDrawerPageState.ts
@@ -1,8 +1,8 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
import { RightDrawerPages } from '../types/RightDrawerPages';
-export const rightDrawerPageState = atom<RightDrawerPages | null>({
+export const rightDrawerPageState = createState<RightDrawerPages | null>({
key: 'ui/layout/right-drawer-page',
- default: null,
+ defaultValue: null,
});
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
index 97179525c1a..004132921bd 100644
--- 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
@@ -1,11 +1,11 @@
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 { selectableItemIdsComponentState } from '@/ui/layout/selectable-list/states/selectableItemIdsComponentState';
+import { selectableListOnEnterComponentState } from '@/ui/layout/selectable-list/states/selectableListOnEnterComponentState';
+import { selectedItemIdComponentState } from '@/ui/layout/selectable-list/states/selectedItemIdComponentState';
+import { isSelectedItemIdFamilySelector } from '@/ui/layout/selectable-list/states/selectors/isSelectedItemIdFamilySelector';
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';
+import { extractComponentFamilyState } from '@/ui/utilities/state/component-state/utils/extractComponentFamilyState';
+import { extractComponentState } from '@/ui/utilities/state/component-state/utils/extractComponentState';
type useSelectableListStatesProps = {
selectableListScopeId?: string;
@@ -21,15 +21,21 @@ export const useSelectableListStates = ({
return {
scopeId,
- isSelectedItemIdSelector: getFamilyState(
- isSelectedItemIdFamilySelectorScopeMap,
+ isSelectedItemIdSelector: extractComponentFamilyState(
+ isSelectedItemIdFamilySelector,
scopeId,
),
- selectableItemIdsState: getState(selectableItemIdsStateScopeMap, scopeId),
- selectableListOnEnterState: getState(
- selectableListOnEnterStateScopeMap,
+ selectableItemIdsState: extractComponentState(
+ selectableItemIdsComponentState,
+ scopeId,
+ ),
+ selectableListOnEnterState: extractComponentState(
+ selectableListOnEnterComponentState,
+ scopeId,
+ ),
+ selectedItemIdState: extractComponentState(
+ selectedItemIdComponentState,
scopeId,
),
- selectedItemIdState: getState(selectedItemIdStateScopeMap, scopeId),
};
};
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 7857bfdd37b..c347ce3f054 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 { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
-type SelectableListScopeInternalContextProps = StateScopeMapKey;
+type SelectableListScopeInternalContextProps = ComponentStateKey;
export const SelectableListScopeInternalContext =
createScopeInternalContext<SelectableListScopeInternalContextProps>();
diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/isSelectedItemIdComponentFamilyState.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/isSelectedItemIdComponentFamilyState.ts
new file mode 100644
index 00000000000..8dcbeb829f6
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/isSelectedItemIdComponentFamilyState.ts
@@ -0,0 +1,9 @@
+import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
+
+export const isSelectedItemIdComponentFamilyState = createComponentFamilyState<
+ boolean,
+ string
+>({
+ key: 'isSelectedItemIdComponentFamilyState',
+ defaultValue: false,
+});
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
deleted file mode 100644
index 84bc20fd41c..00000000000
--- a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/isSelectedItemIdFamilyStateScopeMap.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-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/selectableItemIdsComponentState.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableItemIdsComponentState.ts
new file mode 100644
index 00000000000..05a239e567d
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableItemIdsComponentState.ts
@@ -0,0 +1,8 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const selectableItemIdsComponentState = createComponentState<string[][]>(
+ {
+ key: 'selectableItemIdsComponentState',
+ 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
deleted file mode 100644
index 19c3e68eb60..00000000000
--- a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableItemIdsStateScopeMap.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const selectableItemIdsStateScopeMap = createStateScopeMap<string[][]>({
- key: 'selectableItemIdsScopedState',
- defaultValue: [[]],
-});
diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableListOnEnterComponentState.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableListOnEnterComponentState.ts
new file mode 100644
index 00000000000..f0cbc21eac0
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableListOnEnterComponentState.ts
@@ -0,0 +1,8 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const selectableListOnEnterComponentState = createComponentState<
+ ((itemId: string) => void) | undefined
+>({
+ key: 'selectableListOnEnterComponentState',
+ 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
deleted file mode 100644
index 055b1d117f4..00000000000
--- a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectableListOnEnterStateScopeMap.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-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/selectedItemIdComponentState.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectedItemIdComponentState.ts
new file mode 100644
index 00000000000..8587373a102
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectedItemIdComponentState.ts
@@ -0,0 +1,8 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const selectedItemIdComponentState = createComponentState<string | null>(
+ {
+ key: 'selectedItemIdComponentState',
+ 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
deleted file mode 100644
index 8445a2c2ec1..00000000000
--- a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectedItemIdStateScopeMap.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const selectedItemIdStateScopeMap = createStateScopeMap<string | null>({
- key: 'selectedItemIdScopedState',
- defaultValue: null,
-});
diff --git a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectors/isSelectedItemIdFamilySelector.ts b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectors/isSelectedItemIdFamilySelector.ts
new file mode 100644
index 00000000000..a93df20ce5a
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectors/isSelectedItemIdFamilySelector.ts
@@ -0,0 +1,28 @@
+import { isSelectedItemIdComponentFamilyState } from '@/ui/layout/selectable-list/states/isSelectedItemIdComponentFamilyState';
+import { createComponentFamilySelector } from '@/ui/utilities/state/component-state/utils/createComponentFamilySelector';
+
+export const isSelectedItemIdFamilySelector = createComponentFamilySelector<
+ boolean,
+ string
+>({
+ key: 'isSelectedItemIdFamilySelector',
+ get:
+ ({ scopeId, familyKey }: { scopeId: string; familyKey: string }) =>
+ ({ get }) =>
+ get(
+ isSelectedItemIdComponentFamilyState({
+ scopeId: scopeId,
+ familyKey: familyKey,
+ }),
+ ),
+ set:
+ ({ scopeId, familyKey }: { scopeId: string; familyKey: string }) =>
+ ({ set }, newValue) =>
+ set(
+ isSelectedItemIdComponentFamilyState({
+ scopeId: scopeId,
+ familyKey: familyKey,
+ }),
+ newValue,
+ ),
+});
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
deleted file mode 100644
index 6eae4ad0c1c..00000000000
--- a/packages/twenty-front/src/modules/ui/layout/selectable-list/states/selectors/isSelectedItemIdFamilySelectorScopeMap.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { isSelectedItemIdFamilyStateScopeMap } from '@/ui/layout/selectable-list/states/isSelectedItemIdFamilyStateScopeMap';
-import { createFamilySelectorScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilySelectorScopeMap';
-
-export const isSelectedItemIdFamilySelectorScopeMap =
- createFamilySelectorScopeMap<boolean, string>({
- 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/show-page/components/ShowPageMoreButton.tsx b/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageMoreButton.tsx
index fee1454b6f8..3b75efe6269 100644
--- a/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageMoreButton.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/show-page/components/ShowPageMoreButton.tsx
@@ -26,7 +26,7 @@ export const ShowPageMoreButton = ({
objectNameSingular: string;
}) => {
const { closeDropdown, toggleDropdown } = useDropdown('more-show-page');
- const navigationMemorizedUrl = useRecoilValue(navigationMemorizedUrlState);
+ const navigationMemorizedUrl = useRecoilValue(navigationMemorizedUrlState());
const navigate = useNavigate();
const { deleteOneRecord } = useDeleteOneRecord({
diff --git a/packages/twenty-front/src/modules/ui/layout/tab/hooks/internal/useTabListStates.ts b/packages/twenty-front/src/modules/ui/layout/tab/hooks/internal/useTabListStates.ts
index c1a47b9ca49..6915852548e 100644
--- a/packages/twenty-front/src/modules/ui/layout/tab/hooks/internal/useTabListStates.ts
+++ b/packages/twenty-front/src/modules/ui/layout/tab/hooks/internal/useTabListStates.ts
@@ -1,7 +1,7 @@
import { TabListScopeInternalContext } from '@/ui/layout/tab/scopes/scope-internal-context/TabListScopeInternalContext';
-import { activeTabIdStateScopeMap } from '@/ui/layout/tab/states/activeTabIdStateScopeMap';
+import { activeTabIdComponentState } from '@/ui/layout/tab/states/activeTabIdComponentState';
import { useAvailableScopeIdOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useAvailableScopeId';
-import { getState } from '@/ui/utilities/recoil-scope/utils/getState';
+import { extractComponentState } from '@/ui/utilities/state/component-state/utils/extractComponentState';
type useTabListStatesProps = {
tabListScopeId?: string;
@@ -15,6 +15,9 @@ export const useTabListStates = ({ tabListScopeId }: useTabListStatesProps) => {
return {
scopeId,
- getActiveTabIdState: getState(activeTabIdStateScopeMap, scopeId),
+ getActiveTabIdState: extractComponentState(
+ activeTabIdComponentState,
+ scopeId,
+ ),
};
};
diff --git a/packages/twenty-front/src/modules/ui/layout/tab/scopes/scope-internal-context/TabListScopeInternalContext.ts b/packages/twenty-front/src/modules/ui/layout/tab/scopes/scope-internal-context/TabListScopeInternalContext.ts
index be207055bb5..878955256f7 100644
--- a/packages/twenty-front/src/modules/ui/layout/tab/scopes/scope-internal-context/TabListScopeInternalContext.ts
+++ b/packages/twenty-front/src/modules/ui/layout/tab/scopes/scope-internal-context/TabListScopeInternalContext.ts
@@ -1,7 +1,7 @@
-import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
-type TabListScopeInternalContextProps = StateScopeMapKey;
+type TabListScopeInternalContextProps = ComponentStateKey;
export const TabListScopeInternalContext =
createScopeInternalContext<TabListScopeInternalContextProps>();
diff --git a/packages/twenty-front/src/modules/ui/layout/tab/states/activeTabIdComponentState.ts b/packages/twenty-front/src/modules/ui/layout/tab/states/activeTabIdComponentState.ts
new file mode 100644
index 00000000000..fcb07559b73
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/tab/states/activeTabIdComponentState.ts
@@ -0,0 +1,6 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const activeTabIdComponentState = createComponentState<string | null>({
+ key: 'activeTabIdComponentState',
+ defaultValue: null,
+});
diff --git a/packages/twenty-front/src/modules/ui/layout/tab/states/activeTabIdStateScopeMap.ts b/packages/twenty-front/src/modules/ui/layout/tab/states/activeTabIdStateScopeMap.ts
deleted file mode 100644
index 500ccc57a22..00000000000
--- a/packages/twenty-front/src/modules/ui/layout/tab/states/activeTabIdStateScopeMap.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const activeTabIdStateScopeMap = createStateScopeMap<string | null>({
- key: 'activeTabIdStateScopeMap',
- defaultValue: null,
-});
diff --git a/packages/twenty-front/src/modules/ui/navigation/action-bar/components/ActionBar.tsx b/packages/twenty-front/src/modules/ui/navigation/action-bar/components/ActionBar.tsx
index bf5c2586a0a..2c7b9db3b55 100644
--- a/packages/twenty-front/src/modules/ui/navigation/action-bar/components/ActionBar.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/action-bar/components/ActionBar.tsx
@@ -28,8 +28,8 @@ const StyledContainerActionBar = styled.div`
`;
export const ActionBar = () => {
- const contextMenuIsOpen = useRecoilValue(contextMenuIsOpenState);
- const actionBarEntries = useRecoilValue(actionBarEntriesState);
+ const contextMenuIsOpen = useRecoilValue(contextMenuIsOpenState());
+ const actionBarEntries = useRecoilValue(actionBarEntriesState());
const wrapperRef = useRef<HTMLDivElement>(null);
if (contextMenuIsOpen) {
diff --git a/packages/twenty-front/src/modules/ui/navigation/action-bar/components/__stories__/ActionBar.stories.tsx b/packages/twenty-front/src/modules/ui/navigation/action-bar/components/__stories__/ActionBar.stories.tsx
index 24daaea8557..460ee204878 100644
--- a/packages/twenty-front/src/modules/ui/navigation/action-bar/components/__stories__/ActionBar.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/action-bar/components/__stories__/ActionBar.stories.tsx
@@ -9,7 +9,7 @@ import { actionBarOpenState } from '../../states/actionBarIsOpenState';
import { ActionBar } from '../ActionBar';
const FilledActionBar = () => {
- const setActionBarOpenState = useSetRecoilState(actionBarOpenState);
+ const setActionBarOpenState = useSetRecoilState(actionBarOpenState());
setActionBarOpenState(true);
return <ActionBar />;
};
diff --git a/packages/twenty-front/src/modules/ui/navigation/action-bar/states/actionBarEntriesState.ts b/packages/twenty-front/src/modules/ui/navigation/action-bar/states/actionBarEntriesState.ts
index 2e9d0cf61a9..d4ead431793 100644
--- a/packages/twenty-front/src/modules/ui/navigation/action-bar/states/actionBarEntriesState.ts
+++ b/packages/twenty-front/src/modules/ui/navigation/action-bar/states/actionBarEntriesState.ts
@@ -1,8 +1,8 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
import { ActionBarEntry } from '../types/ActionBarEntry';
-export const actionBarEntriesState = atom<ActionBarEntry[]>({
+export const actionBarEntriesState = createState<ActionBarEntry[]>({
key: 'actionBarEntriesState',
- default: [],
+ defaultValue: [],
});
diff --git a/packages/twenty-front/src/modules/ui/navigation/action-bar/states/actionBarIsOpenState.ts b/packages/twenty-front/src/modules/ui/navigation/action-bar/states/actionBarIsOpenState.ts
index 3d150e9783d..30f62036258 100644
--- a/packages/twenty-front/src/modules/ui/navigation/action-bar/states/actionBarIsOpenState.ts
+++ b/packages/twenty-front/src/modules/ui/navigation/action-bar/states/actionBarIsOpenState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const actionBarOpenState = atom<boolean>({
+export const actionBarOpenState = createState<boolean>({
key: 'actionBarOpenState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/ui/navigation/context-menu/components/ContextMenu.tsx b/packages/twenty-front/src/modules/ui/navigation/context-menu/components/ContextMenu.tsx
index 8a3a1cfd0e8..519c6bf87a0 100644
--- a/packages/twenty-front/src/modules/ui/navigation/context-menu/components/ContextMenu.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/context-menu/components/ContextMenu.tsx
@@ -37,10 +37,10 @@ const StyledContainerContextMenu = styled.div<StyledContainerProps>`
`;
export const ContextMenu = () => {
- const contextMenuPosition = useRecoilValue(contextMenuPositionState);
- const contextMenuIsOpen = useRecoilValue(contextMenuIsOpenState);
- const contextMenuEntries = useRecoilValue(contextMenuEntriesState);
- const setContextMenuOpenState = useSetRecoilState(contextMenuIsOpenState);
+ const contextMenuPosition = useRecoilValue(contextMenuPositionState());
+ const contextMenuIsOpen = useRecoilValue(contextMenuIsOpenState());
+ const contextMenuEntries = useRecoilValue(contextMenuEntriesState());
+ const setContextMenuOpenState = useSetRecoilState(contextMenuIsOpenState());
const wrapperRef = useRef<HTMLDivElement>(null);
useListenClickOutside({
diff --git a/packages/twenty-front/src/modules/ui/navigation/context-menu/components/__stories__/ContextMenu.stories.tsx b/packages/twenty-front/src/modules/ui/navigation/context-menu/components/__stories__/ContextMenu.stories.tsx
index ee9eddd2f81..d0a5f4a7982 100644
--- a/packages/twenty-front/src/modules/ui/navigation/context-menu/components/__stories__/ContextMenu.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/context-menu/components/__stories__/ContextMenu.stories.tsx
@@ -10,12 +10,12 @@ import { contextMenuPositionState } from '../../states/contextMenuPositionState'
import { ContextMenu } from '../ContextMenu';
const FilledContextMenu = () => {
- const setContextMenuPosition = useSetRecoilState(contextMenuPositionState);
+ const setContextMenuPosition = useSetRecoilState(contextMenuPositionState());
setContextMenuPosition({
x: 100,
y: 10,
});
- const setContextMenuOpenState = useSetRecoilState(contextMenuIsOpenState);
+ const setContextMenuOpenState = useSetRecoilState(contextMenuIsOpenState());
setContextMenuOpenState(true);
return <ContextMenu />;
};
diff --git a/packages/twenty-front/src/modules/ui/navigation/context-menu/states/contextMenuEntriesState.ts b/packages/twenty-front/src/modules/ui/navigation/context-menu/states/contextMenuEntriesState.ts
index e5ba5396d6e..1d4977249c3 100644
--- a/packages/twenty-front/src/modules/ui/navigation/context-menu/states/contextMenuEntriesState.ts
+++ b/packages/twenty-front/src/modules/ui/navigation/context-menu/states/contextMenuEntriesState.ts
@@ -1,8 +1,8 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
import { ContextMenuEntry } from '../types/ContextMenuEntry';
-export const contextMenuEntriesState = atom<ContextMenuEntry[]>({
+export const contextMenuEntriesState = createState<ContextMenuEntry[]>({
key: 'contextMenuEntriesState',
- default: [],
+ defaultValue: [],
});
diff --git a/packages/twenty-front/src/modules/ui/navigation/context-menu/states/contextMenuIsOpenState.ts b/packages/twenty-front/src/modules/ui/navigation/context-menu/states/contextMenuIsOpenState.ts
index a41032e2184..60b54873a48 100644
--- a/packages/twenty-front/src/modules/ui/navigation/context-menu/states/contextMenuIsOpenState.ts
+++ b/packages/twenty-front/src/modules/ui/navigation/context-menu/states/contextMenuIsOpenState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const contextMenuIsOpenState = atom<boolean>({
+export const contextMenuIsOpenState = createState<boolean>({
key: 'contextMenuIsOpenState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/ui/navigation/context-menu/states/contextMenuPositionState.ts b/packages/twenty-front/src/modules/ui/navigation/context-menu/states/contextMenuPositionState.ts
index efa4c44732e..dbc877de0ca 100644
--- a/packages/twenty-front/src/modules/ui/navigation/context-menu/states/contextMenuPositionState.ts
+++ b/packages/twenty-front/src/modules/ui/navigation/context-menu/states/contextMenuPositionState.ts
@@ -1,10 +1,9 @@
-import { atom } from 'recoil';
-
import { PositionType } from '@/ui/navigation/context-menu/types/PositionType';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const contextMenuPositionState = atom<PositionType>({
+export const contextMenuPositionState = createState<PositionType>({
key: 'contextMenuPositionState',
- default: {
+ defaultValue: {
x: null,
y: null,
},
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerBackButton.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerBackButton.tsx
index 30f478a9336..14f4cc3b6c9 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerBackButton.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerBackButton.tsx
@@ -37,7 +37,7 @@ export const NavigationDrawerBackButton = ({
}: NavigationDrawerBackButtonProps) => {
const theme = useTheme();
const navigate = useNavigate();
- const navigationMemorizedUrl = useRecoilValue(navigationMemorizedUrlState);
+ const navigationMemorizedUrl = useRecoilValue(navigationMemorizedUrlState());
return (
<StyledContainer>
diff --git a/packages/twenty-front/src/modules/ui/navigation/states/navigationMemorizedUrlState.ts b/packages/twenty-front/src/modules/ui/navigation/states/navigationMemorizedUrlState.ts
index 6537c265ae8..27076c1d5ba 100644
--- a/packages/twenty-front/src/modules/ui/navigation/states/navigationMemorizedUrlState.ts
+++ b/packages/twenty-front/src/modules/ui/navigation/states/navigationMemorizedUrlState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const navigationMemorizedUrlState = atom<string>({
+export const navigationMemorizedUrlState = createState<string>({
key: 'navigationMemorizedUrlState',
- default: '/',
+ defaultValue: '/',
});
diff --git a/packages/twenty-front/src/modules/ui/navigation/step-bar/hooks/__tests__/useStepBar.test.tsx b/packages/twenty-front/src/modules/ui/navigation/step-bar/hooks/__tests__/useStepBar.test.tsx
index 9acd228fb98..5dfbd9c79a8 100644
--- a/packages/twenty-front/src/modules/ui/navigation/step-bar/hooks/__tests__/useStepBar.test.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/step-bar/hooks/__tests__/useStepBar.test.tsx
@@ -11,7 +11,7 @@ const renderHooks = (initialStep: number) => {
const { nextStep, prevStep, reset, setStep } = useStepBar({
initialStep,
});
- const stepBarInternal = useRecoilValue(stepBarInternalState);
+ const stepBarInternal = useRecoilValue(stepBarInternalState());
return {
nextStep,
diff --git a/packages/twenty-front/src/modules/ui/navigation/step-bar/hooks/useStepBar.ts b/packages/twenty-front/src/modules/ui/navigation/step-bar/hooks/useStepBar.ts
index 0bc14494209..f567d9c4da9 100644
--- a/packages/twenty-front/src/modules/ui/navigation/step-bar/hooks/useStepBar.ts
+++ b/packages/twenty-front/src/modules/ui/navigation/step-bar/hooks/useStepBar.ts
@@ -8,8 +8,9 @@ export type StepsOptions = {
};
export const useStepBar = ({ initialStep }: StepsOptions) => {
- const [stepBarInternal, setStepBarInternal] =
- useRecoilState(stepBarInternalState);
+ const [stepBarInternal, setStepBarInternal] = useRecoilState(
+ stepBarInternalState(),
+ );
const nextStep = () => {
setStepBarInternal((prevState) => ({
diff --git a/packages/twenty-front/src/modules/ui/navigation/step-bar/states/stepBarInternalState.ts b/packages/twenty-front/src/modules/ui/navigation/step-bar/states/stepBarInternalState.ts
index 5917096d920..55fe1252233 100644
--- a/packages/twenty-front/src/modules/ui/navigation/step-bar/states/stepBarInternalState.ts
+++ b/packages/twenty-front/src/modules/ui/navigation/step-bar/states/stepBarInternalState.ts
@@ -1,12 +1,12 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
export type StepsState = {
activeStep: number;
};
-export const stepBarInternalState = atom<StepsState>({
+export const stepBarInternalState = createState<StepsState>({
key: 'step-bar/internal-state',
- default: {
+ defaultValue: {
activeStep: -1,
},
});
diff --git a/packages/twenty-front/src/modules/ui/theme/hooks/__tests__/useColorScheme.test.tsx b/packages/twenty-front/src/modules/ui/theme/hooks/__tests__/useColorScheme.test.tsx
index f84692bfad9..84125306122 100644
--- a/packages/twenty-front/src/modules/ui/theme/hooks/__tests__/useColorScheme.test.tsx
+++ b/packages/twenty-front/src/modules/ui/theme/hooks/__tests__/useColorScheme.test.tsx
@@ -32,7 +32,7 @@ describe('useColorScheme', () => {
const colorScheme = useColorScheme();
const setCurrentWorkspaceMember = useSetRecoilState(
- currentWorkspaceMemberState,
+ currentWorkspaceMemberState(),
);
setCurrentWorkspaceMember(workspaceMember);
diff --git a/packages/twenty-front/src/modules/ui/theme/hooks/useColorScheme.ts b/packages/twenty-front/src/modules/ui/theme/hooks/useColorScheme.ts
index e3b46c7adba..46cfa93571d 100644
--- a/packages/twenty-front/src/modules/ui/theme/hooks/useColorScheme.ts
+++ b/packages/twenty-front/src/modules/ui/theme/hooks/useColorScheme.ts
@@ -8,7 +8,7 @@ import { ColorScheme } from '@/workspace-member/types/WorkspaceMember';
export const useColorScheme = () => {
const [currentWorkspaceMember, setCurrentWorkspaceMember] = useRecoilState(
- currentWorkspaceMemberState,
+ currentWorkspaceMemberState(),
);
const { updateOneRecord: updateOneWorkspaceMember } = useUpdateOneRecord({
diff --git a/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/usePreviousHotkeyScope.ts b/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/usePreviousHotkeyScope.ts
index d332b9df0eb..d3eb6d043e7 100644
--- a/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/usePreviousHotkeyScope.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/usePreviousHotkeyScope.ts
@@ -13,7 +13,7 @@ export const usePreviousHotkeyScope = () => {
({ snapshot, set }) =>
() => {
const previousHotkeyScope = snapshot
- .getLoadable(previousHotkeyScopeState)
+ .getLoadable(previousHotkeyScopeState())
.getValue();
if (!previousHotkeyScope) {
@@ -25,7 +25,7 @@ export const usePreviousHotkeyScope = () => {
previousHotkeyScope.customScopes,
);
- set(previousHotkeyScopeState, null);
+ set(previousHotkeyScopeState(), null);
},
[setHotkeyScope],
);
@@ -34,11 +34,11 @@ export const usePreviousHotkeyScope = () => {
({ snapshot, set }) =>
(scope: string, customScopes?: CustomHotkeyScopes) => {
const currentHotkeyScope = snapshot
- .getLoadable(currentHotkeyScopeState)
+ .getLoadable(currentHotkeyScopeState())
.getValue();
setHotkeyScope(scope, customScopes);
- set(previousHotkeyScopeState, currentHotkeyScope);
+ set(previousHotkeyScopeState(), currentHotkeyScope);
},
[setHotkeyScope],
);
diff --git a/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useScopedHotkeyCallback.ts b/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useScopedHotkeyCallback.ts
index 6e3d2d10208..92ebc8b8982 100644
--- a/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useScopedHotkeyCallback.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useScopedHotkeyCallback.ts
@@ -24,7 +24,7 @@ export const useScopedHotkeyCallback = () =>
preventDefault?: boolean;
}) => {
const currentHotkeyScopes = snapshot
- .getLoadable(internalHotkeysEnabledScopesState)
+ .getLoadable(internalHotkeysEnabledScopesState())
.getValue();
if (!currentHotkeyScopes.includes(scope)) {
diff --git a/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useScopedHotkeys.ts b/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useScopedHotkeys.ts
index b8c7ff31dad..b8059643c4a 100644
--- a/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useScopedHotkeys.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useScopedHotkeys.ts
@@ -22,7 +22,8 @@ export const useScopedHotkeys = (
preventDefault: true,
},
) => {
- const [pendingHotkey, setPendingHotkey] = useRecoilState(pendingHotkeyState);
+ const [pendingHotkey, setPendingHotkey] =
+ useRecoilState(pendingHotkeyState());
const callScopedHotkeyCallback = useScopedHotkeyCallback();
diff --git a/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useSequenceScopedHotkeys.ts b/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useSequenceScopedHotkeys.ts
index 6f3d795faba..144d74813cd 100644
--- a/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useSequenceScopedHotkeys.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useSequenceScopedHotkeys.ts
@@ -20,7 +20,8 @@ export const useSequenceHotkeys = (
},
deps: any[] = [],
) => {
- const [pendingHotkey, setPendingHotkey] = useRecoilState(pendingHotkeyState);
+ const [pendingHotkey, setPendingHotkey] =
+ useRecoilState(pendingHotkeyState());
const callScopedHotkeyCallback = useScopedHotkeyCallback();
diff --git a/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useSetHotkeyScope.ts b/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useSetHotkeyScope.ts
index 83b12c2fc1a..4d6a4f6770e 100644
--- a/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useSetHotkeyScope.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/hotkey/hooks/useSetHotkeyScope.ts
@@ -26,7 +26,7 @@ export const useSetHotkeyScope = () =>
({ snapshot, set }) =>
async (hotkeyScopeToSet: string, customScopes?: CustomHotkeyScopes) => {
const currentHotkeyScope = snapshot
- .getLoadable(currentHotkeyScopeState)
+ .getLoadable(currentHotkeyScopeState())
.getValue();
if (currentHotkeyScope.scope === hotkeyScopeToSet) {
@@ -76,8 +76,8 @@ export const useSetHotkeyScope = () =>
}
scopesToSet.push(newHotkeyScope.scope);
- set(internalHotkeysEnabledScopesState, scopesToSet);
- set(currentHotkeyScopeState, newHotkeyScope);
+ set(internalHotkeysEnabledScopesState(), scopesToSet);
+ set(currentHotkeyScopeState(), newHotkeyScope);
},
[],
);
diff --git a/packages/twenty-front/src/modules/ui/utilities/hotkey/states/internal/currentHotkeyScopeState.ts b/packages/twenty-front/src/modules/ui/utilities/hotkey/states/internal/currentHotkeyScopeState.ts
index 98eeabde6a4..c948f65b763 100644
--- a/packages/twenty-front/src/modules/ui/utilities/hotkey/states/internal/currentHotkeyScopeState.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/hotkey/states/internal/currentHotkeyScopeState.ts
@@ -1,9 +1,9 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
import { INITIAL_HOTKEYS_SCOPE } from '../../constants/InitialHotkeysScope';
import { HotkeyScope } from '../../types/HotkeyScope';
-export const currentHotkeyScopeState = atom<HotkeyScope>({
+export const currentHotkeyScopeState = createState<HotkeyScope>({
key: 'currentHotkeyScopeState',
- default: INITIAL_HOTKEYS_SCOPE,
+ defaultValue: INITIAL_HOTKEYS_SCOPE,
});
diff --git a/packages/twenty-front/src/modules/ui/utilities/hotkey/states/internal/internalHotkeysEnabledScopesState.ts b/packages/twenty-front/src/modules/ui/utilities/hotkey/states/internal/internalHotkeysEnabledScopesState.ts
index 5bc666110dc..b86f4f7da2f 100644
--- a/packages/twenty-front/src/modules/ui/utilities/hotkey/states/internal/internalHotkeysEnabledScopesState.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/hotkey/states/internal/internalHotkeysEnabledScopesState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const internalHotkeysEnabledScopesState = atom<string[]>({
+export const internalHotkeysEnabledScopesState = createState<string[]>({
key: 'internalHotkeysEnabledScopesState',
- default: [],
+ defaultValue: [],
});
diff --git a/packages/twenty-front/src/modules/ui/utilities/hotkey/states/internal/pendingHotkeysState.ts b/packages/twenty-front/src/modules/ui/utilities/hotkey/states/internal/pendingHotkeysState.ts
index da2dbf173be..fe3e81b2725 100644
--- a/packages/twenty-front/src/modules/ui/utilities/hotkey/states/internal/pendingHotkeysState.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/hotkey/states/internal/pendingHotkeysState.ts
@@ -1,7 +1,8 @@
import { Keys } from 'react-hotkeys-hook/dist/types';
-import { atom } from 'recoil';
-export const pendingHotkeyState = atom<Keys | null>({
+import { createState } from '@/ui/utilities/state/utils/createState';
+
+export const pendingHotkeyState = createState<Keys | null>({
key: 'pendingHotkeyState',
- default: null,
+ defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/ui/utilities/hotkey/states/internal/previousHotkeyScopeState.ts b/packages/twenty-front/src/modules/ui/utilities/hotkey/states/internal/previousHotkeyScopeState.ts
index fd076d8e22e..a39c86315d4 100644
--- a/packages/twenty-front/src/modules/ui/utilities/hotkey/states/internal/previousHotkeyScopeState.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/hotkey/states/internal/previousHotkeyScopeState.ts
@@ -1,8 +1,8 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
import { HotkeyScope } from '../../types/HotkeyScope';
-export const previousHotkeyScopeState = atom<HotkeyScope | null>({
+export const previousHotkeyScopeState = createState<HotkeyScope | null>({
key: 'previousHotkeyScopeState',
- default: null,
+ defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/ui/utilities/loading-state/states/currentPageLocationState.ts b/packages/twenty-front/src/modules/ui/utilities/loading-state/states/currentPageLocationState.ts
index 0d96571b386..335acb58cf2 100644
--- a/packages/twenty-front/src/modules/ui/utilities/loading-state/states/currentPageLocationState.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/loading-state/states/currentPageLocationState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const currentPageLocationState = atom<string>({
+export const currentPageLocationState = createState<string>({
key: 'currentPageLocationState',
- default: '',
+ defaultValue: '',
});
diff --git a/packages/twenty-front/src/modules/ui/utilities/pointer-event/hooks/useClickOustideListenerStates.ts b/packages/twenty-front/src/modules/ui/utilities/pointer-event/hooks/useClickOustideListenerStates.ts
index 9ca424aef76..dc267544039 100644
--- a/packages/twenty-front/src/modules/ui/utilities/pointer-event/hooks/useClickOustideListenerStates.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/pointer-event/hooks/useClickOustideListenerStates.ts
@@ -1,25 +1,25 @@
-import { clickOutsideListenerCallbacksStateScopeMap } from '@/ui/utilities/pointer-event/states/clickOutsideListenerCallbacksStateScopeMap';
-import { clickOutsideListenerIsActivatedStateScopeMap } from '@/ui/utilities/pointer-event/states/clickOutsideListenerIsActivatedStateScopeMap';
-import { clickOutsideListenerIsMouseDownInsideStateScopeMap } from '@/ui/utilities/pointer-event/states/clickOutsideListenerIsMouseDownInsideStateScopeMap';
+import { clickOutsideListenerCallbacksComponentState } from '@/ui/utilities/pointer-event/states/clickOutsideListenerCallbacksComponentState';
+import { clickOutsideListenerIsActivatedComponentState } from '@/ui/utilities/pointer-event/states/clickOutsideListenerIsActivatedComponentState';
+import { clickOutsideListenerIsMouseDownInsideComponentState } from '@/ui/utilities/pointer-event/states/clickOutsideListenerIsMouseDownInsideComponentState';
import { lockedListenerIdState } from '@/ui/utilities/pointer-event/states/lockedListenerIdState';
import { getScopeIdFromComponentId } from '@/ui/utilities/recoil-scope/utils/getScopeIdFromComponentId';
-import { getState } from '@/ui/utilities/recoil-scope/utils/getState';
+import { extractComponentState } from '@/ui/utilities/state/component-state/utils/extractComponentState';
export const useClickOustideListenerStates = (componentId: string) => {
const scopeId = getScopeIdFromComponentId(componentId);
return {
scopeId,
- getClickOutsideListenerCallbacksState: getState(
- clickOutsideListenerCallbacksStateScopeMap,
+ getClickOutsideListenerCallbacksState: extractComponentState(
+ clickOutsideListenerCallbacksComponentState,
scopeId,
),
- getClickOutsideListenerIsMouseDownInsideState: getState(
- clickOutsideListenerIsMouseDownInsideStateScopeMap,
+ getClickOutsideListenerIsMouseDownInsideState: extractComponentState(
+ clickOutsideListenerIsMouseDownInsideComponentState,
scopeId,
),
- getClickOutsideListenerIsActivatedState: getState(
- clickOutsideListenerIsActivatedStateScopeMap,
+ getClickOutsideListenerIsActivatedState: extractComponentState(
+ clickOutsideListenerIsActivatedComponentState,
scopeId,
),
lockedListenerIdState,
diff --git a/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerCallbacksComponentState.ts b/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerCallbacksComponentState.ts
new file mode 100644
index 00000000000..d0c1ec29182
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerCallbacksComponentState.ts
@@ -0,0 +1,9 @@
+import { ClickOutsideListenerCallback } from '@/ui/utilities/pointer-event/types/ClickOutsideListenerCallback';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const clickOutsideListenerCallbacksComponentState = createComponentState<
+ ClickOutsideListenerCallback[]
+>({
+ key: 'clickOutsideListenerCallbacksComponentState',
+ defaultValue: [],
+});
diff --git a/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerCallbacksStateScopeMap.ts b/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerCallbacksStateScopeMap.ts
deleted file mode 100644
index 425c3ca81d8..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerCallbacksStateScopeMap.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import { ClickOutsideListenerCallback } from '@/ui/utilities/pointer-event/types/ClickOutsideListenerCallback';
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const clickOutsideListenerCallbacksStateScopeMap = createStateScopeMap<
- ClickOutsideListenerCallback[]
->({
- key: 'clickOutsideListenerCallbacksStateScopeMap',
- defaultValue: [],
-});
diff --git a/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerIsActivatedComponentState.ts b/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerIsActivatedComponentState.ts
new file mode 100644
index 00000000000..8c08b27decf
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerIsActivatedComponentState.ts
@@ -0,0 +1,7 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const clickOutsideListenerIsActivatedComponentState =
+ createComponentState<boolean>({
+ key: 'clickOutsideListenerIsActivatedComponentState',
+ defaultValue: true,
+ });
diff --git a/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerIsActivatedStateScopeMap.ts b/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerIsActivatedStateScopeMap.ts
deleted file mode 100644
index 61367a9aee1..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerIsActivatedStateScopeMap.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const clickOutsideListenerIsActivatedStateScopeMap =
- createStateScopeMap<boolean>({
- key: 'clickOutsideListenerIsActivatedStateScopeMap',
- defaultValue: true,
- });
diff --git a/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerIsMouseDownInsideComponentState.ts b/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerIsMouseDownInsideComponentState.ts
new file mode 100644
index 00000000000..47bb8f0f518
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerIsMouseDownInsideComponentState.ts
@@ -0,0 +1,7 @@
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
+
+export const clickOutsideListenerIsMouseDownInsideComponentState =
+ createComponentState<boolean>({
+ key: 'clickOutsideListenerIsMouseDownInsideComponentState',
+ defaultValue: false,
+ });
diff --git a/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerIsMouseDownInsideStateScopeMap.ts b/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerIsMouseDownInsideStateScopeMap.ts
deleted file mode 100644
index cf425313977..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/clickOutsideListenerIsMouseDownInsideStateScopeMap.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
-
-export const clickOutsideListenerIsMouseDownInsideStateScopeMap =
- createStateScopeMap<boolean>({
- key: 'clickOutsideListenerIsMouseDownInsideStateScopeMap',
- defaultValue: false,
- });
diff --git a/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/lockedListenerIdState.ts b/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/lockedListenerIdState.ts
index 1349627fce9..c7739cc9501 100644
--- a/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/lockedListenerIdState.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/pointer-event/states/lockedListenerIdState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const lockedListenerIdState = atom<string | null>({
+export const lockedListenerIdState = createState<string | null>({
key: 'lockedListenerIdState',
- default: null,
+ defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useRecoilScopedFamilyState.test.tsx b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useRecoilScopedFamilyState.test.tsx
deleted file mode 100644
index d670a955443..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useRecoilScopedFamilyState.test.tsx
+++ /dev/null
@@ -1,64 +0,0 @@
-import { act, renderHook } from '@testing-library/react';
-import { RecoilRoot, RecoilState } from 'recoil';
-import { undefined } from 'zod';
-
-import { useRecoilScopedFamilyState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedFamilyState';
-import { FamilyStateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/FamilyStateScopeMapKey';
-import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
-
-const testState = createFamilyStateScopeMap({
- key: 'sampleKey',
- defaultValue: 'defaultValue',
-});
-
-describe('useRecoilScopedFamilyState', () => {
- it('Should work as expected', async () => {
- const { result, rerender } = renderHook(
- ({
- recoilState,
- scopeId,
- familyKey,
- }: {
- recoilState: (
- scopedFamilyKey: FamilyStateScopeMapKey<string>,
- ) => RecoilState<string>;
- scopeId: string;
- familyKey?: string;
- }) => useRecoilScopedFamilyState(recoilState, scopeId, familyKey),
- {
- wrapper: RecoilRoot,
- initialProps: {
- recoilState: testState,
- scopeId: 'scopeId',
- },
- },
- );
-
- expect(result.current).toEqual([undefined, undefined]);
-
- rerender({
- recoilState: testState,
- scopeId: 'scopeId',
- familyKey: 'familyKey',
- });
-
- const [value, setValue] = result.current;
-
- expect(value).toBe('defaultValue');
- expect(setValue).toBeInstanceOf(Function);
-
- act(() => {
- setValue?.('newValue');
- });
-
- expect(result.current[0]).toBe('newValue');
-
- rerender({
- recoilState: testState,
- scopeId: 'scopeId1',
- familyKey: 'familyKey',
- });
-
- expect(result.current[0]).toBe('defaultValue');
- });
-});
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useRecoilScopedState.test.tsx b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useRecoilScopedState.test.tsx
deleted file mode 100644
index 706e72f9077..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useRecoilScopedState.test.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import { createContext } from 'react';
-import { act, renderHook } from '@testing-library/react';
-import { atomFamily, RecoilRoot } from 'recoil';
-
-import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
-
-const testScopedState = atomFamily<string | null, string>({
- key: 'testKey',
- default: null,
-});
-
-const mockedContextValue = 'mocked-scope-id';
-const MockedContext = createContext<string | null>(mockedContextValue);
-const nullContext = createContext<string | null>(null);
-
-const ERROR_MESSAGE =
- 'Using a scoped atom without a RecoilScope : testKey__"", verify that you are using a RecoilScope with a specific context if you intended to do so.';
-
-describe('useRecoilScopedState', () => {
- it('Should return the getter and setter for the state and context passed and work properly', async () => {
- const { result } = renderHook(
- () => useRecoilScopedState(testScopedState, MockedContext),
- {
- wrapper: ({ children }) => (
- <MockedContext.Provider value={mockedContextValue}>
- <RecoilRoot>{children}</RecoilRoot>
- </MockedContext.Provider>
- ),
- },
- );
-
- const [scopedState, setScopedState] = result.current;
-
- expect(scopedState).toBeNull();
-
- await act(async () => {
- setScopedState('testValue');
- });
-
- const [scopedStateAfterSetter] = result.current;
-
- expect(scopedStateAfterSetter).toEqual('testValue');
- });
-
- it('Should throw an error when the recoilScopeId is not found by the context', () => {
- expect(() => {
- renderHook(() => useRecoilScopedState(testScopedState, nullContext));
- }).toThrow(ERROR_MESSAGE);
- });
-});
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useRecoilScopedValue.test.tsx b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useRecoilScopedValue.test.tsx
deleted file mode 100644
index 50061216383..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useRecoilScopedValue.test.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import { createContext } from 'react';
-import { renderHook } from '@testing-library/react';
-import { atomFamily, RecoilRoot } from 'recoil';
-
-import { useRecoilScopedValue } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedValue';
-
-const testScopedState = atomFamily<string | null, string>({
- key: 'testKey',
- default: null,
-});
-
-const mockedContextValue = 'mocked-scope-id';
-const MockedContext = createContext<string | null>(mockedContextValue);
-const nullContext = createContext<string | null>(null);
-
-const ERROR_MESSAGE =
- 'Using a scoped atom without a RecoilScope : testKey__"", verify that you are using a RecoilScope with a specific context if you intended to do so.';
-
-describe('useRecoilScopedValue', () => {
- it('Should return the getter and setter for the state and context passed and work properly', async () => {
- const { result } = renderHook(
- () => useRecoilScopedValue(testScopedState, MockedContext),
- {
- wrapper: ({ children }) => (
- <MockedContext.Provider value={mockedContextValue}>
- <RecoilRoot>{children}</RecoilRoot>
- </MockedContext.Provider>
- ),
- },
- );
-
- const scopedState = result.current;
-
- expect(scopedState).toBeNull();
- });
-
- it('Should throw an error when the recoilScopeId is not found by the context', () => {
- expect(() => {
- renderHook(() => useRecoilScopedValue(testScopedState, nullContext));
- }).toThrow(ERROR_MESSAGE);
- });
-});
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useRecoilScopedValueV2.test.tsx b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useRecoilScopedValueV2.test.tsx
deleted file mode 100644
index ddd9230c452..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useRecoilScopedValueV2.test.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { renderHook } from '@testing-library/react';
-import { atomFamily, RecoilRoot } from 'recoil';
-
-import { useRecoilScopedValueV2 } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedValueV2';
-import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
-
-const scopedAtom = atomFamily<string, StateScopeMapKey>({
- key: 'scopedAtomKey',
- default: 'initialValue',
-});
-
-describe('useRecoilScopedValueV2', () => {
- const mockedScopeId = 'mocked-scope-id';
-
- it('Should return the scoped value using useRecoilScopedValueV2', () => {
- const { result } = renderHook(
- () => useRecoilScopedValueV2(scopedAtom, mockedScopeId),
- {
- wrapper: RecoilRoot,
- },
- );
-
- const scopedValue = result.current;
-
- expect(scopedValue).toBe('initialValue');
- });
-});
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useSetRecoilScopedFamilyState.test.tsx b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useSetRecoilScopedFamilyState.test.tsx
deleted file mode 100644
index f2d1a259247..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useSetRecoilScopedFamilyState.test.tsx
+++ /dev/null
@@ -1,79 +0,0 @@
-import { act, renderHook } from '@testing-library/react';
-import { atomFamily, RecoilRoot } from 'recoil';
-
-import { useRecoilScopedFamilyState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedFamilyState';
-import { useSetRecoilScopedFamilyState } from '@/ui/utilities/recoil-scope/hooks/useSetRecoilScopedFamilyState';
-import { FamilyStateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/FamilyStateScopeMapKey';
-
-const mockedScopedFamilyState = atomFamily<
- string,
- FamilyStateScopeMapKey<string>
->({
- key: 'scopedAtomKey',
- default: 'initialValue',
-});
-
-describe('useSetRecoilScopedFamilyState', () => {
- const mockedScopeId = 'mocked-scope-id';
- const mockedFamilyKey = 'test-key-value';
-
- it('Should return a setter that updates the state value and work properly', async () => {
- const useCombinedHooks = () => {
- const setRecoilScopedFamilyState = useSetRecoilScopedFamilyState(
- mockedScopedFamilyState,
- mockedScopeId,
- mockedFamilyKey,
- );
-
- const [mocked] = useRecoilScopedFamilyState(
- mockedScopedFamilyState,
- mockedScopeId,
- mockedFamilyKey,
- );
-
- return {
- setRecoilScopedFamilyState,
- scopedFamilyState: mocked,
- };
- };
-
- const { result } = renderHook(() => useCombinedHooks(), {
- wrapper: RecoilRoot,
- });
-
- expect(result.current.scopedFamilyState).toBe('initialValue');
- expect(result.current.setRecoilScopedFamilyState).toBeInstanceOf(Function);
-
- await act(async () => {
- result.current.setRecoilScopedFamilyState?.('testValue');
- });
-
- expect(result.current.scopedFamilyState).toBe('testValue');
- });
-
- it('Should return undefined when familyKey is missing', async () => {
- const useCombinedHooks = () => {
- const setRecoilScopedFamilyState = useSetRecoilScopedFamilyState(
- mockedScopedFamilyState,
- mockedScopeId,
- );
-
- const [mocked] = useRecoilScopedFamilyState(
- mockedScopedFamilyState,
- mockedScopeId,
- );
-
- return {
- setRecoilScopedFamilyState,
- scopedFamilyState: mocked,
- };
- };
-
- const { result } = renderHook(() => useCombinedHooks(), {
- wrapper: RecoilRoot,
- });
-
- expect(result.current.scopedFamilyState).toBeUndefined();
- expect(result.current.setRecoilScopedFamilyState).toBeUndefined();
- });
-});
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useSetRecoilScopedStateV2.test.tsx b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useSetRecoilScopedStateV2.test.tsx
deleted file mode 100644
index da1b93ba2aa..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/__tests__/useSetRecoilScopedStateV2.test.tsx
+++ /dev/null
@@ -1,47 +0,0 @@
-import { act, renderHook } from '@testing-library/react';
-import { atomFamily, RecoilRoot } from 'recoil';
-
-import { useRecoilScopedValueV2 } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedValueV2';
-import { useSetRecoilScopedStateV2 } from '@/ui/utilities/recoil-scope/hooks/useSetRecoilScopedStateV2';
-import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
-
-const scopedAtom = atomFamily<string, StateScopeMapKey>({
- key: 'scopedAtomKey',
- default: 'initialValue',
-});
-
-describe('useSetRecoilScopedStateV2', () => {
- const mockedScopeId = 'mocked-scope-id';
-
- it('Should return a setter that updates the state value', async () => {
- const useCombinedHooks = () => {
- const setRecoilScopedStateV2 = useSetRecoilScopedStateV2(
- scopedAtom,
- mockedScopeId,
- );
-
- const recoilScopedStateValue = useRecoilScopedValueV2(
- scopedAtom,
- mockedScopeId,
- );
-
- return {
- setRecoilScopedStateV2,
- recoilScopedStateValue,
- };
- };
-
- const { result } = renderHook(() => useCombinedHooks(), {
- wrapper: RecoilRoot,
- });
-
- expect(result.current.recoilScopedStateValue).toBe('initialValue');
- expect(result.current.setRecoilScopedStateV2).toBeInstanceOf(Function);
-
- await act(async () => {
- result.current.setRecoilScopedStateV2('testValue');
- });
-
- expect(result.current.recoilScopedStateValue).toBe('testValue');
- });
-});
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
deleted file mode 100644
index 457a8fb09ba..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedFamilyState.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { RecoilState, SerializableParam, useRecoilState } from 'recoil';
-
-import { FamilyStateScopeMapKey } from '../scopes-internal/types/FamilyStateScopeMapKey';
-
-export const useRecoilScopedFamilyState = <
- StateType,
- FamilyKey extends SerializableParam,
->(
- recoilState: (
- scopedFamilyKey: FamilyStateScopeMapKey<FamilyKey>,
- ) => RecoilState<StateType>,
- scopeId: string,
- familyKey?: FamilyKey,
-) => {
- const familyState = useRecoilState<StateType>(
- recoilState({
- scopeId,
- familyKey: familyKey || ('' as FamilyKey),
- }),
- );
-
- if (!familyKey) {
- return [undefined, undefined];
- }
-
- return familyState;
-};
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedState.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedState.ts
deleted file mode 100644
index a4c37a62069..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedState.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { Context, useContext } from 'react';
-import { RecoilState, useRecoilState } from 'recoil';
-
-import { RecoilScopeContext } from '../states/RecoilScopeContext';
-
-export const useRecoilScopedState = <StateType>(
- recoilState: (param: string) => RecoilState<StateType>,
- CustomRecoilScopeContext?: Context<string | null>,
-) => {
- const recoilScopeId = useContext(
- CustomRecoilScopeContext ?? RecoilScopeContext,
- );
-
- if (!recoilScopeId)
- throw new Error(
- `Using a scoped atom without a RecoilScope : ${
- recoilState('').key
- }, verify that you are using a RecoilScope with a specific context if you intended to do so.`,
- );
-
- return useRecoilState<StateType>(recoilState(recoilScopeId));
-};
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 389a4aa32f8..952fbfb0ee0 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 { StateScopeMapKey } from '../scopes-internal/types/StateScopeMapKey';
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
export const useRecoilScopedStateV2 = <StateType>(
- recoilState: (scopedKey: StateScopeMapKey) => RecoilState<StateType>,
+ recoilState: (scopedKey: ComponentStateKey) => RecoilState<StateType>,
scopeId: string,
) => {
return useRecoilState<StateType>(
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedValue.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedValue.ts
deleted file mode 100644
index 413b5560523..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedValue.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-import { Context, useContext } from 'react';
-import { RecoilState, RecoilValueReadOnly, useRecoilValue } from 'recoil';
-
-import { RecoilScopeContext } from '../states/RecoilScopeContext';
-
-/**
- * @deprecated use useRecoilScopedStateV2 instead
- */
-export const useRecoilScopedValue = <T>(
- recoilState: (param: string) => RecoilState<T> | RecoilValueReadOnly<T>,
- CustomRecoilScopeContext?: Context<string | null>,
-) => {
- const recoilScopeId = useContext(
- CustomRecoilScopeContext ?? RecoilScopeContext,
- );
-
- if (!recoilScopeId)
- throw new Error(
- `Using a scoped atom without a RecoilScope : ${
- recoilState('').key
- }, verify that you are using a RecoilScope with a specific context if you intended to do so.`,
- );
-
- return useRecoilValue<T>(recoilState(recoilScopeId));
-};
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
deleted file mode 100644
index f3f90d1e8da..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useRecoilScopedValueV2.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { RecoilState, useRecoilValue } from 'recoil';
-
-import { StateScopeMapKey } from '../scopes-internal/types/StateScopeMapKey';
-
-export const useRecoilScopedValueV2 = <StateType>(
- recoilState: (scopedKey: StateScopeMapKey) => RecoilState<StateType>,
- scopeId: string,
-) => {
- return useRecoilValue<StateType>(
- recoilState({
- scopeId,
- }),
- );
-};
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
deleted file mode 100644
index e74d1f171f5..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useSetRecoilScopedFamilyState.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { RecoilState, SerializableParam, useSetRecoilState } from 'recoil';
-
-import { FamilyStateScopeMapKey } from '../scopes-internal/types/FamilyStateScopeMapKey';
-
-export const useSetRecoilScopedFamilyState = <
- StateType,
- FamilyKey extends SerializableParam,
->(
- recoilState: (
- scopedFamilyKey: FamilyStateScopeMapKey<FamilyKey>,
- ) => RecoilState<StateType>,
- scopeId: string,
- familyKey?: FamilyKey,
-) => {
- const familyState = useSetRecoilState<StateType>(
- recoilState({
- scopeId,
- familyKey: familyKey || ('' as FamilyKey),
- }),
- );
-
- if (!familyKey) {
- return;
- }
-
- return familyState;
-};
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
deleted file mode 100644
index 35396eebcd5..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/hooks/useSetRecoilScopedStateV2.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { RecoilState, useSetRecoilState } from 'recoil';
-
-import { StateScopeMapKey } from '../scopes-internal/types/StateScopeMapKey';
-
-export const useSetRecoilScopedStateV2 = <StateType>(
- recoilState: (scopedKey: StateScopeMapKey) => RecoilState<StateType>,
- scopeId: string,
-) => {
- return useSetRecoilState<StateType>(
- recoilState({
- scopeId,
- }),
- );
-};
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/__tests__/useScopeInternalContextOrThrow.test.tsx b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/__tests__/useScopeInternalContextOrThrow.test.tsx
deleted file mode 100644
index c83c7d246d8..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/__tests__/useScopeInternalContextOrThrow.test.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-import { createContext } from 'react';
-import { renderHook } from '@testing-library/react';
-
-import { useScopeInternalContextOrThrow } from '@/ui/utilities/recoil-scope/scopes-internal/hooks/useScopeInternalContextOrThrow';
-import { ScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/types/ScopeInternalContext';
-
-const mockedContextValue = 'mocked-scope-id';
-const MockedContext = createContext<string | null>(mockedContextValue);
-const nullContext = createContext<string | null>(null);
-
-const ERROR_MESSAGE =
- 'Using a scope context without a ScopeInternalContext.Provider wrapper for context';
-
-const Wrapper = ({ children }: { children: React.ReactNode }) => (
- <MockedContext.Provider value={mockedContextValue}>
- {children}
- </MockedContext.Provider>
-);
-
-describe('useScopeInternalContextOrThrow', () => {
- it('should work as expected', () => {
- const { result } = renderHook(
- () =>
- useScopeInternalContextOrThrow(
- MockedContext as ScopeInternalContext<{ scopeId: string }>,
- ),
- {
- wrapper: Wrapper,
- },
- );
-
- expect(result.current).toBe(mockedContextValue);
- });
-
- it('should throw an error when used outside of the specified context', () => {
- expect(() => {
- renderHook(() =>
- useScopeInternalContextOrThrow(
- nullContext as ScopeInternalContext<{ scopeId: string }>,
- ),
- );
- }).toThrow(ERROR_MESSAGE);
- });
-});
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/__tests__/useScopedState.test.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/__tests__/useScopedState.test.ts
deleted file mode 100644
index 1e5374797c5..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/__tests__/useScopedState.test.ts
+++ /dev/null
@@ -1,192 +0,0 @@
-import { expect } from '@storybook/test';
-import { act, renderHook } from '@testing-library/react';
-import {
- atomFamily,
- RecoilRoot,
- selector,
- useRecoilCallback,
- useRecoilState,
- useRecoilValue,
-} from 'recoil';
-
-import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
-import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
-import { getFamilyScopeInjector } from '@/ui/utilities/recoil-scope/utils/getFamilyScopeInjector';
-import { getScopeInjector } from '@/ui/utilities/recoil-scope/utils/getScopeInjector';
-import { getSelectorScopeInjector } from '@/ui/utilities/recoil-scope/utils/getSelectorScopeInjector';
-
-import { useScopedState } from '../useScopedState';
-
-const scopeId = 'scopeId';
-
-// scoped state
-const defaultScopedState = 'defaultString';
-const scopedState = atomFamily<string, StateScopeMapKey>({
- key: 'ScopedStateKey',
- default: defaultScopedState,
-});
-const scopedStateScopeInjector = getScopeInjector(scopedState);
-
-// scoped selector
-const anotherScopedState = atomFamily<number[], StateScopeMapKey>({
- key: 'ScopedStateKey',
- default: [1, 2, 3, 4, 5],
-});
-const scopedSelector = ({ scopeId }: StateScopeMapKey) =>
- selector({
- key: 'FilteredState',
- get: ({ get }) => {
- const scopedStateValue = get(anotherScopedState({ scopeId }));
- return scopedStateValue.filter((value) => value % 2 === 0);
- },
- });
-const selectorScopeInjector = getSelectorScopeInjector(scopedSelector);
-
-// family state
-const defaultValue = 'defaultString';
-const scopedFamilyState = createFamilyStateScopeMap<string, string>({
- key: 'FamilyStateKey',
- defaultValue,
-});
-const familyScopeInjector = getFamilyScopeInjector(scopedFamilyState);
-
-describe('useScopedState', () => {
- it('should get scoped state', () => {
- const {
- result: {
- current: { getScopedState },
- },
- } = renderHook(() => useScopedState(scopeId));
-
- const scopedState = getScopedState(scopedStateScopeInjector);
-
- const { result } = renderHook(
- () => {
- const [scoped, setScoped] = useRecoilState(scopedState);
- return { scoped, setScoped };
- },
- {
- wrapper: RecoilRoot,
- },
- );
-
- expect(result.current.scoped).toBe(defaultScopedState);
-
- const newValue = 'anotherValue';
-
- act(() => {
- result.current.setScoped(newValue);
- });
-
- expect(result.current.scoped).toBe(newValue);
- });
-
- it('should get scoped snapshot value', () => {
- const {
- result: {
- current: { getScopedSnapshotValue },
- },
- } = renderHook(() => useScopedState(scopeId));
-
- const { result } = renderHook(
- () =>
- useRecoilCallback(
- ({ snapshot }) =>
- () =>
- getScopedSnapshotValue(snapshot, scopedStateScopeInjector),
- )(),
- { wrapper: RecoilRoot },
- );
-
- expect(result.current).toBe(defaultScopedState);
- });
-
- it('should get scoped selector', () => {
- const {
- result: {
- current: { getScopedSelector },
- },
- } = renderHook(() => useScopedState(scopeId));
-
- const recoilValue = getScopedSelector(selectorScopeInjector);
-
- const { result } = renderHook(() => useRecoilValue(recoilValue), {
- wrapper: RecoilRoot,
- });
-
- expect(result.current).toEqual([2, 4]);
- });
-
- it('should get scoped selector snapshot value', () => {
- const {
- result: {
- current: { getScopedSelectorSnapshotValue },
- },
- } = renderHook(() => useScopedState(scopeId));
-
- const { result } = renderHook(
- () =>
- useRecoilCallback(
- ({ snapshot }) =>
- () =>
- getScopedSelectorSnapshotValue(snapshot, selectorScopeInjector),
- )(),
- { wrapper: RecoilRoot },
- );
-
- expect(result.current).toEqual([2, 4]);
- });
-
- it('should get scoped family state', () => {
- const {
- result: {
- current: { getScopedFamilyState },
- },
- } = renderHook(() => useScopedState(scopeId));
-
- const scopedFamilyState = getScopedFamilyState(familyScopeInjector);
-
- const { result } = renderHook(
- () => {
- const [familyState, setFamilyState] = useRecoilState(
- scopedFamilyState('familyKey'),
- );
-
- return { familyState, setFamilyState };
- },
- {
- wrapper: RecoilRoot,
- },
- );
-
- expect(result.current.familyState).toBe('defaultString');
-
- const newValue = 'newValue';
-
- act(() => {
- result.current.setFamilyState(newValue);
- });
-
- expect(result.current.familyState).toBe(newValue);
- });
-
- it('should get scoped family snapshot value', () => {
- const {
- result: {
- current: { getScopedFamilySnapshotValue },
- },
- } = renderHook(() => useScopedState(scopeId));
-
- const { result } = renderHook(
- () =>
- useRecoilCallback(
- ({ snapshot }) =>
- () =>
- getScopedFamilySnapshotValue(snapshot, familyScopeInjector),
- )(),
- { wrapper: RecoilRoot },
- );
-
- expect(result.current('sampleKey')).toBe('defaultString');
- });
-});
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useScopeInternalContextOrThrow.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useScopeInternalContextOrThrow.ts
deleted file mode 100644
index 4c199e8d9cb..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useScopeInternalContextOrThrow.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { useContext } from 'react';
-
-import { isNonNullable } from '~/utils/isNonNullable';
-
-import { ScopeInternalContext } from '../types/ScopeInternalContext';
-
-export const useScopeInternalContextOrThrow = <T extends { scopeId: string }>(
- Context: ScopeInternalContext<T>,
-) => {
- const context = useContext(Context);
-
- if (!isNonNullable(context)) {
- throw new Error(
- `Using a scope context without a ScopeInternalContext.Provider wrapper for context : ${Context.displayName}.`,
- );
- }
-
- return context;
-};
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useScopedState.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useScopedState.ts
deleted file mode 100644
index a1a82a18462..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/hooks/useScopedState.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-import { SerializableParam, Snapshot } from 'recoil';
-
-import { FamilyScopeInjector } from '@/ui/utilities/recoil-scope/utils/getFamilyScopeInjector';
-import { ScopeInjector } from '@/ui/utilities/recoil-scope/utils/getScopeInjector';
-import { SelectorScopeInjector } from '@/ui/utilities/recoil-scope/utils/getSelectorScopeInjector';
-import { getSnapshotValue } from '@/ui/utilities/recoil-scope/utils/getSnapshotValue';
-
-export const useScopedState = (scopeId: string) => {
- const getScopedState = <StateType>(scopeInjector: ScopeInjector<StateType>) =>
- scopeInjector(scopeId);
-
- const getScopedSelector = <StateType>(
- scopeInjector: SelectorScopeInjector<StateType>,
- ) => scopeInjector(scopeId);
-
- const getScopedFamilyState =
- <StateType, FamilyKey extends SerializableParam>(
- familyScopeInjector: FamilyScopeInjector<StateType, FamilyKey>,
- ) =>
- (familyKey: FamilyKey) =>
- familyScopeInjector(scopeId, familyKey);
-
- const getScopedSnapshotValue = <StateType>(
- snapshot: Snapshot,
- scopeInjector: ScopeInjector<StateType>,
- ) => getSnapshotValue(snapshot, scopeInjector(scopeId));
-
- const getScopedSelectorSnapshotValue = <StateType>(
- snapshot: Snapshot,
- scopeInjector: SelectorScopeInjector<StateType>,
- ) => getSnapshotValue(snapshot, scopeInjector(scopeId));
-
- const getScopedFamilySnapshotValue =
- <StateType, FamilyKey extends SerializableParam>(
- snapshot: Snapshot,
- familyScopeInjector: FamilyScopeInjector<StateType, FamilyKey>,
- ) =>
- (familyKey: FamilyKey) =>
- getSnapshotValue(snapshot, familyScopeInjector(scopeId, familyKey));
-
- return {
- scopeId,
- getScopedState,
- getScopedSelector,
- getScopedFamilyState,
- getScopedSnapshotValue,
- getScopedSelectorSnapshotValue,
- getScopedFamilySnapshotValue,
- };
-};
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
deleted file mode 100644
index 3915d9478ee..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-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 8789a15726c..78911a1abcd 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 { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
-type ScopeInternalContext<T extends StateScopeMapKey> = Context<T | null>;
+type ScopeInternalContext<T extends ComponentStateKey> = Context<T | null>;
-export const createScopeInternalContext = <T extends StateScopeMapKey>(
+export const createScopeInternalContext = <T extends ComponentStateKey>(
initialValue?: T,
) => {
return createContext<T | null>(
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 69803560096..8e92014b557 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 { StateScopeMapKey } from '../scopes-internal/types/StateScopeMapKey';
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
export type RecoilScopedSelector<StateType> = (
- scopedKey: StateScopeMapKey,
+ scopedKey: ComponentStateKey,
) => RecoilValueReadOnly<StateType>;
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 ace7ab39ec9..beb36d9e994 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 { StateScopeMapKey } from '../scopes-internal/types/StateScopeMapKey';
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
export type RecoilScopedState<StateType> = (
- scopedKey: StateScopeMapKey,
+ scopedKey: ComponentStateKey,
) => RecoilState<StateType>;
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/__tests__/getFamilyScopeInjector.test.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/__tests__/getFamilyScopeInjector.test.ts
deleted file mode 100644
index 559221bcb1e..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/__tests__/getFamilyScopeInjector.test.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { act, renderHook } from '@testing-library/react';
-import { RecoilRoot, useRecoilState } from 'recoil';
-
-import { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
-
-import { getFamilyScopeInjector } from '../getFamilyScopeInjector';
-
-const defaultValue = 'defaultString';
-
-const testState = createFamilyStateScopeMap<string, string>({
- key: 'familyStateKey',
- defaultValue,
-});
-
-describe('getFamilyScopeInjector', () => {
- it('should return a scoped family state', () => {
- const familyScopeInjector = getFamilyScopeInjector(testState);
- const familyState = familyScopeInjector('scopeId', 'familyKey');
-
- const { result } = renderHook(
- () => {
- const [family, setFamily] = useRecoilState(familyState);
- return { family, setFamily };
- },
- {
- wrapper: RecoilRoot,
- },
- );
-
- expect(result.current.family).toBe(defaultValue);
-
- const newValue = 'anotherValue';
-
- act(() => {
- result.current.setFamily(newValue);
- });
-
- expect(result.current.family).toBe(newValue);
- });
-});
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/__tests__/getScopeInjector.test.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/__tests__/getScopeInjector.test.ts
deleted file mode 100644
index ef8ab5993ec..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/__tests__/getScopeInjector.test.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import { act, renderHook } from '@testing-library/react';
-import { atomFamily, RecoilRoot, useRecoilState } from 'recoil';
-
-import { getScopeInjector } from '../getScopeInjector';
-
-const defaultValue = 'defaultString';
-
-const scopedState = atomFamily<
- string,
- {
- scopeId: string;
- }
->({
- key: 'myStateKey',
- default: defaultValue,
-});
-
-describe('getScopeInjector', () => {
- it('should return the scoped state for the given scopeId', () => {
- const scopeInjector = getScopeInjector(scopedState);
-
- const scopeId = 'scopeId';
- const recoilState = scopeInjector(scopeId);
-
- const { result } = renderHook(
- () => {
- const [recoil, setRecoil] = useRecoilState(recoilState);
- return { recoil, setRecoil };
- },
- {
- wrapper: RecoilRoot,
- },
- );
-
- expect(result.current.recoil).toBe(defaultValue);
-
- const newValue = 'anotherValue';
-
- act(() => {
- result.current.setRecoil(newValue);
- });
-
- expect(result.current.recoil).toBe(newValue);
- });
-});
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/__tests__/getSelectorScopeInjector.test.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/__tests__/getSelectorScopeInjector.test.ts
deleted file mode 100644
index 0f3e6d0bd7f..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/__tests__/getSelectorScopeInjector.test.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import { renderHook } from '@testing-library/react';
-import { atomFamily, RecoilRoot, selector, useRecoilValue } from 'recoil';
-
-import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
-
-import { getSelectorScopeInjector } from '../getSelectorScopeInjector';
-
-const scopedState = atomFamily<
- number[],
- {
- scopeId: string;
- }
->({
- key: 'myStateKey',
- default: [1, 2, 3, 4, 5],
-});
-
-const scopedSelector = ({ scopeId }: StateScopeMapKey) =>
- selector({
- key: 'FilteredState',
- get: ({ get }) => {
- const scopedStateValue = get(scopedState({ scopeId }));
- return scopedStateValue.filter((value) => value % 2 === 0);
- },
- });
-
-describe('getSelectorScopeInjector', () => {
- it('should return a valid SelectorScopeInjector', () => {
- const selectorScopeInjector = getSelectorScopeInjector(scopedSelector);
- const recoilValue = selectorScopeInjector('scopeId');
-
- const { result } = renderHook(() => useRecoilValue(recoilValue), {
- wrapper: RecoilRoot,
- });
-
- expect(result.current).toEqual([2, 4]);
- });
-});
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createFamilySelectorScopeMap.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createFamilySelectorScopeMap.ts
deleted file mode 100644
index cdfbc6a102d..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createFamilySelectorScopeMap.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import {
- DefaultValue,
- GetCallback,
- GetRecoilValue,
- Loadable,
- RecoilValue,
- ResetRecoilState,
- selectorFamily,
- SerializableParam,
- SetRecoilState,
- WrappedValue,
-} from 'recoil';
-
-import { FamilyStateScopeMapKey } from '../scopes-internal/types/FamilyStateScopeMapKey';
-
-type SelectorGetter<T, P> = (
- param: P,
-) => (opts: {
- get: GetRecoilValue;
- getCallback: GetCallback;
-}) => Promise<T> | RecoilValue<T> | Loadable<T> | WrappedValue<T> | T;
-
-type SelectorSetter<T, P> = (
- param: P,
-) => (
- opts: { set: SetRecoilState; get: GetRecoilValue; reset: ResetRecoilState },
- newValue: T | DefaultValue,
-) => void;
-
-export const createFamilySelectorScopeMap = <
- ValueType,
- FamilyKey extends SerializableParam,
->({
- key,
- get,
- set,
-}: {
- key: string;
- get: SelectorGetter<ValueType, FamilyStateScopeMapKey<FamilyKey>>;
- set: SelectorSetter<ValueType, FamilyStateScopeMapKey<FamilyKey>>;
-}) => {
- return selectorFamily<ValueType, FamilyStateScopeMapKey<FamilyKey>>({
- key,
- get,
- set,
- });
-};
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createSelectorReadOnlyScopeMap.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createSelectorReadOnlyScopeMap.ts
deleted file mode 100644
index 8b537fdf97f..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createSelectorReadOnlyScopeMap.ts
+++ /dev/null
@@ -1,30 +0,0 @@
-import {
- GetCallback,
- GetRecoilValue,
- Loadable,
- RecoilValue,
- selectorFamily,
- WrappedValue,
-} from 'recoil';
-
-import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
-
-type SelectorGetter<T, P> = (
- param: P,
-) => (opts: {
- get: GetRecoilValue;
- getCallback: GetCallback;
-}) => Promise<T> | RecoilValue<T> | Loadable<T> | WrappedValue<T> | T;
-
-export const createSelectorReadOnlyScopeMap = <ValueType>({
- key,
- get,
-}: {
- key: string;
- get: SelectorGetter<ValueType, StateScopeMapKey>;
-}) => {
- return selectorFamily<ValueType, StateScopeMapKey>({
- key,
- get,
- });
-};
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createSelectorScopeMap.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createSelectorScopeMap.ts
deleted file mode 100644
index 81e34b8af58..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createSelectorScopeMap.ts
+++ /dev/null
@@ -1,43 +0,0 @@
-import {
- DefaultValue,
- GetCallback,
- GetRecoilValue,
- Loadable,
- RecoilValue,
- ResetRecoilState,
- selectorFamily,
- SetRecoilState,
- WrappedValue,
-} from 'recoil';
-
-import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
-
-type SelectorGetter<T, P> = (
- param: P,
-) => (opts: {
- get: GetRecoilValue;
- getCallback: GetCallback;
-}) => Promise<T> | RecoilValue<T> | Loadable<T> | WrappedValue<T> | T;
-
-type SelectorSetter<T, P> = (
- param: P,
-) => (
- opts: { set: SetRecoilState; get: GetRecoilValue; reset: ResetRecoilState },
- newValue: T | DefaultValue,
-) => void;
-
-export const createSelectorScopeMap = <ValueType>({
- key,
- get,
- set,
-}: {
- key: string;
- get: SelectorGetter<ValueType, StateScopeMapKey>;
- set: SelectorSetter<ValueType, StateScopeMapKey>;
-}) => {
- return selectorFamily<ValueType, StateScopeMapKey>({
- key,
- get,
- set,
- });
-};
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
deleted file mode 100644
index 58efdf2ec08..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createStateScopeMap.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { atomFamily } from 'recoil';
-
-import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
-
-export const createStateScopeMap = <ValueType>({
- key,
- defaultValue,
-}: {
- key: string;
- defaultValue: ValueType;
-}) => {
- return atomFamily<ValueType, StateScopeMapKey>({
- 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
deleted file mode 100644
index ffde95aa1f9..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getFamilyScopeInjector.ts
+++ /dev/null
@@ -1,23 +0,0 @@
-import { RecoilState, SerializableParam } from 'recoil';
-
-import { FamilyStateScopeMapKey } from '../scopes-internal/types/FamilyStateScopeMapKey';
-
-export type FamilyScopeInjector<
- StateType,
- FamilyKey extends SerializableParam,
-> = (scopeId: string, familyKey: FamilyKey) => RecoilState<StateType>;
-
-export const getFamilyScopeInjector = <
- StateType,
- FamilyKey extends SerializableParam,
->(
- scopedFamilyState: (
- scopedFamilyKey: FamilyStateScopeMapKey<FamilyKey>,
- ) => RecoilState<StateType>,
-) => {
- return (scopeId: string, familyKey: FamilyKey) =>
- scopedFamilyState({
- scopeId,
- familyKey: familyKey || ('' as 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
deleted file mode 100644
index 932920bab57..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getFamilyState.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { RecoilState, SerializableParam } from 'recoil';
-
-import { FamilyStateScopeMapKey } from '../scopes-internal/types/FamilyStateScopeMapKey';
-
-export const getFamilyState = <StateType, FamilyKey extends SerializableParam>(
- familyStateScopeMap: (
- scopedFamilyKey: FamilyStateScopeMapKey<FamilyKey>,
- ) => RecoilState<StateType>,
- scopeId: string,
-) => {
- return (familyKey: FamilyKey) =>
- familyStateScopeMap({
- scopeId,
- familyKey: familyKey || ('' as FamilyKey),
- });
-};
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getScopeInjector.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getScopeInjector.ts
deleted file mode 100644
index 45337270023..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getScopeInjector.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { RecoilState } from 'recoil';
-
-import { RecoilScopedState } from '../types/RecoilScopedState';
-
-export type ScopeInjector<StateType> = (
- scopeId: string,
-) => RecoilState<StateType>;
-
-export const getScopeInjector = <StateType>(
- scopedState: RecoilScopedState<StateType>,
-): ScopeInjector<StateType> => {
- return (scopeId: string) =>
- scopedState({
- scopeId,
- });
-};
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 771d61a1cb0..89dad50b949 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 { FamilyStateScopeMapKey } from '../scopes-internal/types/FamilyStateScopeMapKey';
+import { ComponentFamilyStateKey } from '@/ui/utilities/state/component-state/types/ComponentFamilyStateKey';
export const getScopedFamilyStateDeprecated = <
StateType,
FamilyKey extends SerializableParam,
>(
recoilState: (
- scopedFamilyKey: FamilyStateScopeMapKey<FamilyKey>,
+ scopedFamilyKey: ComponentFamilyStateKey<FamilyKey>,
) => RecoilState<StateType>,
scopeId: string,
familyKey: FamilyKey,
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getSelector.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getSelector.ts
deleted file mode 100644
index e81a0c60037..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getSelector.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { RecoilState } from 'recoil';
-
-import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
-
-export const getSelector = <StateType>(
- stateScopeMap: (stateScopeMapKey: StateScopeMapKey) => RecoilState<StateType>,
- scopeId: string,
-) => {
- return () => stateScopeMap({ scopeId });
-};
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getSelectorReadOnly.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getSelectorReadOnly.ts
deleted file mode 100644
index ff40618a3df..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getSelectorReadOnly.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-import { RecoilValueReadOnly } from 'recoil';
-
-import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
-
-export const getSelectorReadOnly = <StateType>(
- stateScopeMap: (
- stateScopeMapKey: StateScopeMapKey,
- ) => RecoilValueReadOnly<StateType>,
- scopeId: string,
-) => {
- return () => stateScopeMap({ scopeId });
-};
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getSelectorScopeInjector.ts b/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getSelectorScopeInjector.ts
deleted file mode 100644
index ffd4e49866b..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getSelectorScopeInjector.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import { RecoilValueReadOnly } from 'recoil';
-
-import { RecoilScopedSelector } from '@/ui/utilities/recoil-scope/types/RecoilScopedSelector';
-
-export type SelectorScopeInjector<StateType> = (
- scopeId: string,
-) => RecoilValueReadOnly<StateType>;
-
-export const getSelectorScopeInjector = <StateType>(
- scopedSelector: RecoilScopedSelector<StateType>,
-): SelectorScopeInjector<StateType> => {
- return (scopeId: string) =>
- scopedSelector({
- scopeId,
- });
-};
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
deleted file mode 100644
index 556edb66cbb..00000000000
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/getState.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { RecoilState } from 'recoil';
-
-import { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
-
-export const getState = <StateType>(
- stateScopeMap: (stateScopeMapKey: StateScopeMapKey) => RecoilState<StateType>,
- scopeId: string,
-) => {
- return () => stateScopeMap({ scopeId });
-};
diff --git a/packages/twenty-front/src/modules/ui/utilities/scroll/hooks/__tests__/useListenScroll.test.tsx b/packages/twenty-front/src/modules/ui/utilities/scroll/hooks/__tests__/useListenScroll.test.tsx
index 8ac2c33c3d6..1829a014276 100644
--- a/packages/twenty-front/src/modules/ui/utilities/scroll/hooks/__tests__/useListenScroll.test.tsx
+++ b/packages/twenty-front/src/modules/ui/utilities/scroll/hooks/__tests__/useListenScroll.test.tsx
@@ -24,7 +24,7 @@ describe('useListenScroll', () => {
const { result } = renderHook(
() => {
useListenScroll({ scrollableRef: containerRef });
- const isScrolling = useRecoilValue(isScrollingState);
+ const isScrolling = useRecoilValue(isScrollingState());
return { isScrolling };
},
diff --git a/packages/twenty-front/src/modules/ui/utilities/scroll/hooks/useListenScroll.ts b/packages/twenty-front/src/modules/ui/utilities/scroll/hooks/useListenScroll.ts
index c6039fc2acf..825cb82c5d3 100644
--- a/packages/twenty-front/src/modules/ui/utilities/scroll/hooks/useListenScroll.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/scroll/hooks/useListenScroll.ts
@@ -13,7 +13,7 @@ export const useListenScroll = <T extends Element>({
scrollableRef: React.RefObject<T>;
}) => {
const hideScrollBarsCallback = useRecoilCallback(({ snapshot }) => () => {
- const isScrolling = snapshot.getLoadable(isScrollingState).getValue();
+ const isScrolling = snapshot.getLoadable(isScrollingState()).getValue();
if (!isScrolling) {
scrollableRef.current?.classList.remove('scrolling');
@@ -21,17 +21,17 @@ export const useListenScroll = <T extends Element>({
});
const handleScrollStart = useRecoilCallback(({ set }) => (event: Event) => {
- set(isScrollingState, true);
+ set(isScrollingState(), true);
scrollableRef.current?.classList.add('scrolling');
const target = event.target as HTMLElement;
- set(scrollTopState, target.scrollTop);
- set(scrollLeftState, target.scrollLeft);
+ set(scrollTopState(), target.scrollTop);
+ set(scrollLeftState(), target.scrollLeft);
});
const handleScrollEnd = useRecoilCallback(({ set }) => () => {
- set(isScrollingState, false);
+ set(isScrollingState(), false);
debounce(hideScrollBarsCallback, 1000)();
});
diff --git a/packages/twenty-front/src/modules/ui/utilities/scroll/states/isScrollingState.ts b/packages/twenty-front/src/modules/ui/utilities/scroll/states/isScrollingState.ts
index 5dad01cf4ff..08ba13a85b2 100644
--- a/packages/twenty-front/src/modules/ui/utilities/scroll/states/isScrollingState.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/scroll/states/isScrollingState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const isScrollingState = atom({
+export const isScrollingState = createState({
key: 'scroll/isScollingState',
- default: false,
+ defaultValue: false,
});
diff --git a/packages/twenty-front/src/modules/ui/utilities/scroll/states/scrollLeftState.ts b/packages/twenty-front/src/modules/ui/utilities/scroll/states/scrollLeftState.ts
index 97ab75dffc7..7335341d594 100644
--- a/packages/twenty-front/src/modules/ui/utilities/scroll/states/scrollLeftState.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/scroll/states/scrollLeftState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const scrollLeftState = atom<number>({
+export const scrollLeftState = createState<number>({
key: 'scroll/scrollLeftState',
- default: 0,
+ defaultValue: 0,
});
diff --git a/packages/twenty-front/src/modules/ui/utilities/scroll/states/scrollTopState.ts b/packages/twenty-front/src/modules/ui/utilities/scroll/states/scrollTopState.ts
index cc8ceef3214..091b369b01e 100644
--- a/packages/twenty-front/src/modules/ui/utilities/scroll/states/scrollTopState.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/scroll/states/scrollTopState.ts
@@ -1,6 +1,6 @@
-import { atom } from 'recoil';
+import { createState } from '@/ui/utilities/state/utils/createState';
-export const scrollTopState = atom<number>({
+export const scrollTopState = createState<number>({
key: 'scroll/scrollTopState',
- default: 0,
+ defaultValue: 0,
});
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/FamilyStateScopeMapKey.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/types/ComponentFamilyStateKey.ts
similarity index 54%
rename from packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/FamilyStateScopeMapKey.ts
rename to packages/twenty-front/src/modules/ui/utilities/state/component-state/types/ComponentFamilyStateKey.ts
index 96733c979d9..e5b9fa304a5 100644
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/scopes-internal/types/FamilyStateScopeMapKey.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/state/component-state/types/ComponentFamilyStateKey.ts
@@ -1,6 +1,6 @@
import { SerializableParam } from 'recoil';
-export type FamilyStateScopeMapKey<FamilyKey extends SerializableParam> = {
+export type ComponentFamilyStateKey<FamilyKey extends SerializableParam> = {
scopeId: string;
familyKey: FamilyKey;
};
diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/types/ComponentStateKey.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/types/ComponentStateKey.ts
new file mode 100644
index 00000000000..fb69c4c1221
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/state/component-state/types/ComponentStateKey.ts
@@ -0,0 +1,3 @@
+export type ComponentStateKey = {
+ scopeId: string;
+};
diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentFamilySelector.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentFamilySelector.ts
new file mode 100644
index 00000000000..af2c6c42716
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentFamilySelector.ts
@@ -0,0 +1,24 @@
+import { selectorFamily, SerializableParam } from 'recoil';
+
+import { ComponentFamilyStateKey } from '@/ui/utilities/state/component-state/types/ComponentFamilyStateKey';
+import { SelectorGetter } from '@/ui/utilities/state/types/SelectorGetter';
+import { SelectorSetter } from '@/ui/utilities/state/types/SelectorSetter';
+
+export const createComponentFamilySelector = <
+ ValueType,
+ FamilyKey extends SerializableParam,
+>({
+ key,
+ get,
+ set,
+}: {
+ key: string;
+ get: SelectorGetter<ValueType, ComponentFamilyStateKey<FamilyKey>>;
+ set: SelectorSetter<ValueType, ComponentFamilyStateKey<FamilyKey>>;
+}) => {
+ return selectorFamily<ValueType, ComponentFamilyStateKey<FamilyKey>>({
+ key,
+ get,
+ set,
+ });
+};
diff --git a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentFamilyState.ts
similarity index 51%
rename from packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap.ts
rename to packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentFamilyState.ts
index 0c44711cc2f..fea9894e1bb 100644
--- a/packages/twenty-front/src/modules/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap.ts
+++ b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentFamilyState.ts
@@ -1,8 +1,8 @@
import { atomFamily, SerializableParam } from 'recoil';
-import { FamilyStateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/FamilyStateScopeMapKey';
+import { ComponentFamilyStateKey } from '@/ui/utilities/state/component-state/types/ComponentFamilyStateKey';
-export const createFamilyStateScopeMap = <
+export const createComponentFamilyState = <
ValueType,
FamilyKey extends SerializableParam,
>({
@@ -12,7 +12,7 @@ export const createFamilyStateScopeMap = <
key: string;
defaultValue: ValueType;
}) => {
- return atomFamily<ValueType, FamilyStateScopeMapKey<FamilyKey>>({
+ return atomFamily<ValueType, ComponentFamilyStateKey<FamilyKey>>({
key,
default: defaultValue,
});
diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentReadOnlySelector.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentReadOnlySelector.ts
new file mode 100644
index 00000000000..3369abc7743
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentReadOnlySelector.ts
@@ -0,0 +1,17 @@
+import { selectorFamily } from 'recoil';
+
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
+import { SelectorGetter } from '@/ui/utilities/state/types/SelectorGetter';
+
+export const createComponentReadOnlySelector = <ValueType>({
+ key,
+ get,
+}: {
+ key: string;
+ get: SelectorGetter<ValueType, ComponentStateKey>;
+}) => {
+ return selectorFamily<ValueType, ComponentStateKey>({
+ key,
+ get,
+ });
+};
diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentSelector.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentSelector.ts
new file mode 100644
index 00000000000..c4dfc647bb8
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentSelector.ts
@@ -0,0 +1,21 @@
+import { selectorFamily } from 'recoil';
+
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
+import { SelectorGetter } from '@/ui/utilities/state/types/SelectorGetter';
+import { SelectorSetter } from '@/ui/utilities/state/types/SelectorSetter';
+
+export const createComponentSelector = <ValueType>({
+ key,
+ get,
+ set,
+}: {
+ key: string;
+ get: SelectorGetter<ValueType, ComponentStateKey>;
+ set: SelectorSetter<ValueType, ComponentStateKey>;
+}) => {
+ return selectorFamily<ValueType, ComponentStateKey>({
+ key,
+ get,
+ set,
+ });
+};
diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentState.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentState.ts
new file mode 100644
index 00000000000..2e2cd8ada9d
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/createComponentState.ts
@@ -0,0 +1,16 @@
+import { atomFamily } from 'recoil';
+
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
+
+export const createComponentState = <ValueType>({
+ key,
+ defaultValue,
+}: {
+ key: string;
+ defaultValue: ValueType;
+}) => {
+ return atomFamily<ValueType, ComponentStateKey>({
+ key,
+ default: defaultValue,
+ });
+};
diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentFamilyState.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentFamilyState.ts
new file mode 100644
index 00000000000..85ada7fd6ca
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentFamilyState.ts
@@ -0,0 +1,19 @@
+import { RecoilState, SerializableParam } from 'recoil';
+
+import { ComponentFamilyStateKey } from '@/ui/utilities/state/component-state/types/ComponentFamilyStateKey';
+
+export const extractComponentFamilyState = <
+ StateType,
+ FamilyKey extends SerializableParam,
+>(
+ componentfamilyState: (
+ componentFamilyStateKey: ComponentFamilyStateKey<FamilyKey>,
+ ) => RecoilState<StateType>,
+ scopeId: string,
+) => {
+ return (familyKey: FamilyKey) =>
+ componentfamilyState({
+ scopeId,
+ familyKey: familyKey || ('' as FamilyKey),
+ });
+};
diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentReadOnlySelector.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentReadOnlySelector.ts
new file mode 100644
index 00000000000..98489a2669e
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentReadOnlySelector.ts
@@ -0,0 +1,12 @@
+import { RecoilValueReadOnly } from 'recoil';
+
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
+
+export const extractComponentReadOnlySelector = <StateType>(
+ componentSelector: (
+ componentStateKey: ComponentStateKey,
+ ) => RecoilValueReadOnly<StateType>,
+ scopeId: string,
+) => {
+ return () => componentSelector({ scopeId });
+};
diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentSelector.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentSelector.ts
new file mode 100644
index 00000000000..60f6fa75da6
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentSelector.ts
@@ -0,0 +1,12 @@
+import { RecoilState } from 'recoil';
+
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
+
+export const extractComponentSelector = <StateType>(
+ componentSelector: (
+ componentStateKey: ComponentStateKey,
+ ) => RecoilState<StateType>,
+ scopeId: string,
+) => {
+ return () => componentSelector({ scopeId });
+};
diff --git a/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentState.ts b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentState.ts
new file mode 100644
index 00000000000..c9b6478c2e5
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/state/component-state/utils/extractComponentState.ts
@@ -0,0 +1,12 @@
+import { RecoilState } from 'recoil';
+
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
+
+export const extractComponentState = <StateType>(
+ componentState: (
+ componentStateKey: ComponentStateKey,
+ ) => RecoilState<StateType>,
+ scopeId: string,
+) => {
+ return () => componentState({ scopeId });
+};
diff --git a/packages/twenty-front/src/modules/ui/utilities/state/types/SelectorGetter.ts b/packages/twenty-front/src/modules/ui/utilities/state/types/SelectorGetter.ts
new file mode 100644
index 00000000000..330fa568d42
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/state/types/SelectorGetter.ts
@@ -0,0 +1,14 @@
+import {
+ GetCallback,
+ GetRecoilValue,
+ Loadable,
+ RecoilValue,
+ WrappedValue,
+} from 'recoil';
+
+export type SelectorGetter<T, P> = (
+ param: P,
+) => (opts: {
+ get: GetRecoilValue;
+ getCallback: GetCallback;
+}) => Promise<T> | RecoilValue<T> | Loadable<T> | WrappedValue<T> | T;
diff --git a/packages/twenty-front/src/modules/ui/utilities/state/types/SelectorSetter.ts b/packages/twenty-front/src/modules/ui/utilities/state/types/SelectorSetter.ts
new file mode 100644
index 00000000000..d21af0380c0
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/state/types/SelectorSetter.ts
@@ -0,0 +1,13 @@
+import {
+ DefaultValue,
+ GetRecoilValue,
+ ResetRecoilState,
+ SetRecoilState,
+} from 'recoil';
+
+export type SelectorSetter<T, P> = (
+ param: P,
+) => (
+ opts: { set: SetRecoilState; get: GetRecoilValue; reset: ResetRecoilState },
+ newValue: T | DefaultValue,
+) => void;
diff --git a/packages/twenty-front/src/modules/ui/utilities/state/utils/createFamilyState.ts b/packages/twenty-front/src/modules/ui/utilities/state/utils/createFamilyState.ts
new file mode 100644
index 00000000000..8fc8a5d941c
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/state/utils/createFamilyState.ts
@@ -0,0 +1,17 @@
+import { atomFamily, SerializableParam } from 'recoil';
+
+export const createFamilyState = <
+ ValueType,
+ FamilyKey extends SerializableParam,
+>({
+ key,
+ defaultValue,
+}: {
+ key: string;
+ defaultValue: ValueType;
+}) => {
+ return atomFamily<ValueType, FamilyKey>({
+ key,
+ default: defaultValue,
+ });
+};
diff --git a/packages/twenty-front/src/modules/ui/utilities/state/utils/createState.ts b/packages/twenty-front/src/modules/ui/utilities/state/utils/createState.ts
new file mode 100644
index 00000000000..b2fdfcdd0cf
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/state/utils/createState.ts
@@ -0,0 +1,18 @@
+import { atom, AtomEffect } from 'recoil';
+
+export const createState = <ValueType>({
+ key,
+ defaultValue,
+ effects,
+}: {
+ key: string;
+ defaultValue: ValueType;
+ effects?: ReadonlyArray<AtomEffect<ValueType>>;
+}) => {
+ const recoilState = atom<ValueType>({
+ key,
+ default: defaultValue,
+ effects,
+ });
+ return () => recoilState;
+};
diff --git a/packages/twenty-front/src/modules/ui/utilities/state/utils/getSnapshotValue.ts b/packages/twenty-front/src/modules/ui/utilities/state/utils/getSnapshotValue.ts
new file mode 100644
index 00000000000..711d21a4ae5
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/state/utils/getSnapshotValue.ts
@@ -0,0 +1,8 @@
+import { RecoilState, RecoilValueReadOnly, Snapshot } from 'recoil';
+
+export const getSnapshotValue = <StateType>(
+ snapshot: Snapshot,
+ state: RecoilState<StateType> | RecoilValueReadOnly<StateType>,
+) => {
+ return snapshot.getLoadable(state).getValue();
+};
diff --git a/packages/twenty-front/src/modules/ui/utilities/state/utils/guardRecoilDefaultValue.ts b/packages/twenty-front/src/modules/ui/utilities/state/utils/guardRecoilDefaultValue.ts
new file mode 100644
index 00000000000..84349601126
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/utilities/state/utils/guardRecoilDefaultValue.ts
@@ -0,0 +1,8 @@
+import { DefaultValue } from 'recoil';
+
+export const guardRecoilDefaultValue = (
+ candidate: any,
+): candidate is DefaultValue => {
+ if (candidate instanceof DefaultValue) return true;
+ return false;
+};
diff --git a/packages/twenty-front/src/modules/users/components/UserProvider.tsx b/packages/twenty-front/src/modules/users/components/UserProvider.tsx
index fe73117ad60..98ecb8704aa 100644
--- a/packages/twenty-front/src/modules/users/components/UserProvider.tsx
+++ b/packages/twenty-front/src/modules/users/components/UserProvider.tsx
@@ -12,11 +12,11 @@ import { isNonNullable } from '~/utils/isNonNullable';
export const UserProvider = ({ children }: React.PropsWithChildren) => {
const [isLoading, setIsLoading] = useState(true);
- const setCurrentUser = useSetRecoilState(currentUserState);
- const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState);
+ const setCurrentUser = useSetRecoilState(currentUserState());
+ const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState());
const setCurrentWorkspaceMember = useSetRecoilState(
- currentWorkspaceMemberState,
+ currentWorkspaceMemberState(),
);
const { loading: queryLoading, data: queryData } = useQuery(GET_CURRENT_USER);
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 39dcf968432..d9affe26c25 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 { StateScopeMapKey } from '@/ui/utilities/recoil-scope/scopes-internal/types/StateScopeMapKey';
import { createScopeInternalContext } from '@/ui/utilities/recoil-scope/scopes-internal/utils/createScopeInternalContext';
+import { ComponentStateKey } from '@/ui/utilities/state/component-state/types/ComponentStateKey';
-type ViewScopeInternalContextProps = StateScopeMapKey;
+type ViewScopeInternalContextProps = ComponentStateKey;
export const ViewScopeInternalContext =
createScopeInternalContext<ViewScopeInternalContextProps>();
diff --git a/packages/twenty-front/src/modules/views/states/availableFieldDefinitionsScopedState.ts b/packages/twenty-front/src/modules/views/states/availableFieldDefinitionsScopedState.ts
index cf7744d4f16..39e08739fab 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/record-field/types/FieldMetadata';
import { ColumnDefinition } from '@/object-record/record-table/types/ColumnDefinition';
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
-export const availableFieldDefinitionsScopedState = createStateScopeMap<
+export const availableFieldDefinitionsScopedState = createComponentState<
ColumnDefinition<FieldMetadata>[]
>({
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 4ed3c9ce777..8433868e1b1 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
-export const availableFilterDefinitionsScopedState = createStateScopeMap<
+export const availableFilterDefinitionsScopedState = createComponentState<
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 43912ec2429..ad93c309257 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
-export const availableSortDefinitionsScopedState = createStateScopeMap<
+export const availableSortDefinitionsScopedState = createComponentState<
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 4c071e69bea..2e73a4f2a5f 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 { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
+import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
import { ViewField } from '../types/ViewField';
-export const currentViewFieldsScopedFamilyState = createFamilyStateScopeMap<
+export const currentViewFieldsScopedFamilyState = createComponentFamilyState<
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 fa807a56ddc..8365c3a021b 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 { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
+import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
import { ViewFilter } from '../types/ViewFilter';
-export const currentViewFiltersScopedFamilyState = createFamilyStateScopeMap<
+export const currentViewFiltersScopedFamilyState = createComponentFamilyState<
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 98a46cbbd3f..806a02384ef 100644
--- a/packages/twenty-front/src/modules/views/states/currentViewIdScopedState.ts
+++ b/packages/twenty-front/src/modules/views/states/currentViewIdScopedState.ts
@@ -1,8 +1,8 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
-export const currentViewIdScopedState = createStateScopeMap<string | undefined>(
- {
- key: 'currentViewIdScopedState',
- defaultValue: undefined,
- },
-);
+export const currentViewIdScopedState = createComponentState<
+ string | undefined
+>({
+ 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 f12bd262636..bb209e6d01f 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 { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
+import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
import { ViewSort } from '../types/ViewSort';
-export const currentViewSortsScopedFamilyState = createFamilyStateScopeMap<
+export const currentViewSortsScopedFamilyState = createComponentFamilyState<
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 6bea66a6d0d..e78260b1e67 100644
--- a/packages/twenty-front/src/modules/views/states/entityCountInCurrentViewScopedState.ts
+++ b/packages/twenty-front/src/modules/views/states/entityCountInCurrentViewScopedState.ts
@@ -1,6 +1,8 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
-export const entityCountInCurrentViewScopedState = createStateScopeMap<number>({
- key: 'entityCountInCurrentViewScopedState',
- defaultValue: 0,
-});
+export const entityCountInCurrentViewScopedState = createComponentState<number>(
+ {
+ 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 24b11da0ce2..ad648dc44ec 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
-export const isPersistingViewScopedState = createStateScopeMap<boolean>({
+export const isPersistingViewScopedState = createComponentState<boolean>({
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 acd1a312ea1..c809b40872b 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
-export const isViewBarExpandedScopedState = createStateScopeMap<boolean>({
+export const isViewBarExpandedScopedState = createComponentState<boolean>({
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 0c318836ddb..8e8f45838c3 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 { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
+import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
-export const noneScopedFamilyState = createFamilyStateScopeMap<any, string>({
+export const noneScopedFamilyState = createComponentFamilyState<any, string>({
key: 'noneScopedFamilyState',
defaultValue: null,
});
diff --git a/packages/twenty-front/src/modules/views/states/onViewCompactModeChangeScopeState.ts b/packages/twenty-front/src/modules/views/states/onViewCompactModeChangeScopeState.ts
index c1e18cbaad7..267682f96b4 100644
--- a/packages/twenty-front/src/modules/views/states/onViewCompactModeChangeScopeState.ts
+++ b/packages/twenty-front/src/modules/views/states/onViewCompactModeChangeScopeState.ts
@@ -1,6 +1,6 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
-export const onViewCompactModeChangeScopeState = createStateScopeMap<
+export const onViewCompactModeChangeScopeState = createComponentState<
((isCompactModeActive: boolean) => void | Promise<void>) | undefined
>({
key: 'onViewCompactModeChangeScopeState',
diff --git a/packages/twenty-front/src/modules/views/states/onViewFieldsChangeScopedState.ts b/packages/twenty-front/src/modules/views/states/onViewFieldsChangeScopedState.ts
index baed107d650..e7e002f35a1 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
import { ViewField } from '../types/ViewField';
-export const onViewFieldsChangeScopedState = createStateScopeMap<
+export const onViewFieldsChangeScopedState = createComponentState<
((fields: ViewField[]) => void | Promise<void>) | 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 a2abce59f20..2e16b7ab481 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
import { ViewFilter } from '@/views/types/ViewFilter';
-export const onViewFiltersChangeScopedState = createStateScopeMap<
+export const onViewFiltersChangeScopedState = createComponentState<
((filters: ViewFilter[]) => void | Promise<void>) | 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 d72a0dfa98b..551c165de64 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
import { ViewSort } from '@/views/types/ViewSort';
-export const onViewSortsChangeScopedState = createStateScopeMap<
+export const onViewSortsChangeScopedState = createComponentState<
((sorts: ViewSort[]) => void | Promise<void>) | undefined
>({
key: 'onViewSortsChangeScopedState',
diff --git a/packages/twenty-front/src/modules/views/states/onViewTypeChangeScopedState.ts b/packages/twenty-front/src/modules/views/states/onViewTypeChangeScopedState.ts
index cc40b91ffe9..b48c3f29e85 100644
--- a/packages/twenty-front/src/modules/views/states/onViewTypeChangeScopedState.ts
+++ b/packages/twenty-front/src/modules/views/states/onViewTypeChangeScopedState.ts
@@ -1,7 +1,7 @@
-import { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
import { ViewType } from '@/views/types/ViewType';
-export const onViewTypeChangeScopedState = createStateScopeMap<
+export const onViewTypeChangeScopedState = createComponentState<
((viewType: ViewType) => void | Promise<void>) | undefined
>({
key: 'onViewTypeChangeScopedState',
diff --git a/packages/twenty-front/src/modules/views/states/savedViewFieldsScopedFamilyState.ts b/packages/twenty-front/src/modules/views/states/savedViewFieldsScopedFamilyState.ts
index 1610e5d6bc7..d0fd3ddac4a 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 { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
+import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
import { ViewField } from '../types/ViewField';
-export const savedViewFieldsScopedFamilyState = createFamilyStateScopeMap<
+export const savedViewFieldsScopedFamilyState = createComponentFamilyState<
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 06a49096b78..cc90fa73de2 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 { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
+import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
import { ViewFilter } from '../types/ViewFilter';
-export const savedViewFiltersScopedFamilyState = createFamilyStateScopeMap<
+export const savedViewFiltersScopedFamilyState = createComponentFamilyState<
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 ea0a9811d0c..a6d0eceb55a 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 { createFamilyStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createFamilyStateScopeMap';
+import { createComponentFamilyState } from '@/ui/utilities/state/component-state/utils/createComponentFamilyState';
import { ViewSort } from '../types/ViewSort';
-export const savedViewSortsScopedFamilyState = createFamilyStateScopeMap<
+export const savedViewSortsScopedFamilyState = createComponentFamilyState<
ViewSort[],
string
>({
diff --git a/packages/twenty-front/src/modules/views/states/selectors/currentViewScopedSelector.ts b/packages/twenty-front/src/modules/views/states/selectors/currentViewComponentSelector.ts
similarity index 72%
rename from packages/twenty-front/src/modules/views/states/selectors/currentViewScopedSelector.ts
rename to packages/twenty-front/src/modules/views/states/selectors/currentViewComponentSelector.ts
index 3719da07fb8..7f8770d6c93 100644
--- a/packages/twenty-front/src/modules/views/states/selectors/currentViewScopedSelector.ts
+++ b/packages/twenty-front/src/modules/views/states/selectors/currentViewComponentSelector.ts
@@ -1,11 +1,11 @@
-import { createSelectorReadOnlyScopeMap } from '@/ui/utilities/recoil-scope/utils/createSelectorReadOnlyScopeMap';
+import { createComponentReadOnlySelector } from '@/ui/utilities/state/component-state/utils/createComponentReadOnlySelector';
import { GraphQLView } from '@/views/types/GraphQLView';
import { currentViewIdScopedState } from '../currentViewIdScopedState';
import { viewsByIdScopedSelector } from './viewsByIdScopedSelector';
-export const currentViewScopedSelector = createSelectorReadOnlyScopeMap<
+export const currentViewComponentSelector = createComponentReadOnlySelector<
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 5234afb9694..638502faf42 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
-export const viewEditModeScopedState = createStateScopeMap<
+export const viewEditModeScopedState = createComponentState<
'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 a67bc387d68..12e397f558b 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
-export const viewObjectMetadataIdScopeState = createStateScopeMap<
+export const viewObjectMetadataIdScopeState = createComponentState<
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 2424bc19ce0..899166dd8bb 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
import { ViewType } from '../types/ViewType';
-export const viewTypeScopedState = createStateScopeMap<ViewType>({
+export const viewTypeScopedState = createComponentState<ViewType>({
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 23c2c29b062..6186528b836 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 { createStateScopeMap } from '@/ui/utilities/recoil-scope/utils/createStateScopeMap';
+import { createComponentState } from '@/ui/utilities/state/component-state/utils/createComponentState';
import { GraphQLView } from '@/views/types/GraphQLView';
-export const viewsScopedState = createStateScopeMap<GraphQLView[]>({
+export const viewsScopedState = createComponentState<GraphQLView[]>({
key: 'viewsScopedState',
defaultValue: [],
});
diff --git a/packages/twenty-front/src/modules/views/utils/internal/getViewScopedStates.ts b/packages/twenty-front/src/modules/views/utils/internal/getViewScopedStates.ts
index eb47990c952..5e3d5f29b3b 100644
--- a/packages/twenty-front/src/modules/views/utils/internal/getViewScopedStates.ts
+++ b/packages/twenty-front/src/modules/views/utils/internal/getViewScopedStates.ts
@@ -5,7 +5,8 @@ import { currentViewIdScopedState } from '@/views/states/currentViewIdScopedStat
import { isPersistingViewScopedState } from '@/views/states/isPersistingViewScopedState';
import { onViewCompactModeChangeScopeState } from '@/views/states/onViewCompactModeChangeScopeState';
import { onViewTypeChangeScopedState } from '@/views/states/onViewTypeChangeScopedState';
-import { currentViewScopedSelector } from '@/views/states/selectors/currentViewScopedSelector';
+import { currentViewComponentSelector } from '@/views/states/selectors/currentViewComponentSelector';
+import { savedViewFieldByKeyScopedFamilySelector } from '@/views/states/selectors/savedViewFieldByKeyScopedFamilySelector';
import { availableFieldDefinitionsScopedState } from '../../states/availableFieldDefinitionsScopedState';
import { availableFilterDefinitionsScopedState } from '../../states/availableFilterDefinitionsScopedState';
@@ -23,7 +24,6 @@ import { savedViewFiltersScopedFamilyState } from '../../states/savedViewFilters
import { savedViewSortsScopedFamilyState } from '../../states/savedViewSortsScopedFamilyState';
import { canPersistViewFiltersScopedFamilySelector } from '../../states/selectors/canPersistViewFiltersScopedFamilySelector';
import { canPersistViewSortsScopedFamilySelector } from '../../states/selectors/canPersistViewSortsScopedFamilySelector';
-import { savedViewFieldByKeyScopedFamilySelector } from '../../states/selectors/savedViewFieldByKeyScopedFamilySelector';
import { savedViewFiltersByKeyScopedFamilySelector } from '../../states/selectors/savedViewFiltersByKeyScopedFamilySelector';
import { savedViewSortsByKeyScopedFamilySelector } from '../../states/selectors/savedViewSortsByKeyScopedFamilySelector';
import { viewEditModeScopedState } from '../../states/viewEditModeScopedState';
@@ -182,7 +182,7 @@ export const getViewScopedStates = ({
);
const currentViewSelector = getScopedSelectorDeprecated(
- currentViewScopedSelector,
+ currentViewComponentSelector,
viewScopeId,
);
diff --git a/packages/twenty-front/src/modules/workspace/hooks/useIsFeatureEnabled.ts b/packages/twenty-front/src/modules/workspace/hooks/useIsFeatureEnabled.ts
index 31906107de8..ac3786d375d 100644
--- a/packages/twenty-front/src/modules/workspace/hooks/useIsFeatureEnabled.ts
+++ b/packages/twenty-front/src/modules/workspace/hooks/useIsFeatureEnabled.ts
@@ -4,7 +4,7 @@ import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
import { FeatureFlagKey } from '@/workspace/types/FeatureFlagKey';
export const useIsFeatureEnabled = (featureKey: FeatureFlagKey) => {
- const currentWorkspace = useRecoilValue(currentWorkspaceState);
+ const currentWorkspace = useRecoilValue(currentWorkspaceState());
const featureFlag = currentWorkspace?.featureFlags?.find(
(flag) => flag.key === featureKey,
diff --git a/packages/twenty-front/src/pages/auth/ChooseYourPlan.tsx b/packages/twenty-front/src/pages/auth/ChooseYourPlan.tsx
index 66b0b640252..7e2d02bafee 100644
--- a/packages/twenty-front/src/pages/auth/ChooseYourPlan.tsx
+++ b/packages/twenty-front/src/pages/auth/ChooseYourPlan.tsx
@@ -43,7 +43,7 @@ const StyledBenefitsContainer = styled.div`
`;
export const ChooseYourPlan = () => {
- const billing = useRecoilValue(billingState);
+ const billing = useRecoilValue(billingState());
const [planSelected, setPlanSelected] = useState('month');
diff --git a/packages/twenty-front/src/pages/auth/CreateProfile.tsx b/packages/twenty-front/src/pages/auth/CreateProfile.tsx
index edbaa99bcfc..554c14beabd 100644
--- a/packages/twenty-front/src/pages/auth/CreateProfile.tsx
+++ b/packages/twenty-front/src/pages/auth/CreateProfile.tsx
@@ -58,7 +58,7 @@ export const CreateProfile = () => {
const { enqueueSnackBar } = useSnackBar();
const [currentWorkspaceMember, setCurrentWorkspaceMember] = useRecoilState(
- currentWorkspaceMemberState,
+ currentWorkspaceMemberState(),
);
const { updateOneRecord } = useUpdateOneRecord<WorkspaceMember>({
diff --git a/packages/twenty-front/src/pages/auth/PlanRequired.tsx b/packages/twenty-front/src/pages/auth/PlanRequired.tsx
index 8c8a18fb767..6cf1f55aff9 100644
--- a/packages/twenty-front/src/pages/auth/PlanRequired.tsx
+++ b/packages/twenty-front/src/pages/auth/PlanRequired.tsx
@@ -16,7 +16,7 @@ const StyledButtonContainer = styled.div`
`;
export const PlanRequired = () => {
- const billing = useRecoilValue(billingState);
+ const billing = useRecoilValue(billingState());
const handleButtonClick = () => {
billing?.billingUrl && window.location.replace(billing.billingUrl);
diff --git a/packages/twenty-front/src/pages/auth/VerifyEffect.tsx b/packages/twenty-front/src/pages/auth/VerifyEffect.tsx
index cda60b1bc44..c4ba1c21b7f 100644
--- a/packages/twenty-front/src/pages/auth/VerifyEffect.tsx
+++ b/packages/twenty-front/src/pages/auth/VerifyEffect.tsx
@@ -10,7 +10,7 @@ import { AppPath } from '@/types/AppPath';
export const VerifyEffect = () => {
const [searchParams] = useSearchParams();
const loginToken = searchParams.get('loginToken');
- const currentWorkspace = useRecoilValue(currentWorkspaceState);
+ const currentWorkspace = useRecoilValue(currentWorkspaceState());
const isLogged = useIsLogged();
const navigate = useNavigate();
diff --git a/packages/twenty-front/src/pages/auth/__stories__/CreateWorkspace.stories.tsx b/packages/twenty-front/src/pages/auth/__stories__/CreateWorkspace.stories.tsx
index 61d2f8316fb..1d1fe2f8417 100644
--- a/packages/twenty-front/src/pages/auth/__stories__/CreateWorkspace.stories.tsx
+++ b/packages/twenty-front/src/pages/auth/__stories__/CreateWorkspace.stories.tsx
@@ -21,7 +21,7 @@ const meta: Meta<PageDecoratorArgs> = {
component: CreateWorkspace,
decorators: [
(Story) => {
- const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState);
+ const setCurrentWorkspace = useSetRecoilState(currentWorkspaceState());
setCurrentWorkspace(mockedOnboardingUsersData[1].defaultWorkspace);
return <Story />;
},
diff --git a/packages/twenty-front/src/pages/impersonate/ImpersonateEffect.tsx b/packages/twenty-front/src/pages/impersonate/ImpersonateEffect.tsx
index f4eaae8ffe7..d8090655cd5 100644
--- a/packages/twenty-front/src/pages/impersonate/ImpersonateEffect.tsx
+++ b/packages/twenty-front/src/pages/impersonate/ImpersonateEffect.tsx
@@ -14,8 +14,8 @@ export const ImpersonateEffect = () => {
const navigate = useNavigate();
const { userId } = useParams();
- const [currentUser, setCurrentUser] = useRecoilState(currentUserState);
- const setTokenPair = useSetRecoilState(tokenPairState);
+ const [currentUser, setCurrentUser] = useRecoilState(currentUserState());
+ const setTokenPair = useSetRecoilState(tokenPairState());
const [impersonate] = useImpersonateMutation();
diff --git a/packages/twenty-front/src/pages/object-record/RecordIndexPageHeader.tsx b/packages/twenty-front/src/pages/object-record/RecordIndexPageHeader.tsx
index fd24ab76f1b..0ea96ca435d 100644
--- a/packages/twenty-front/src/pages/object-record/RecordIndexPageHeader.tsx
+++ b/packages/twenty-front/src/pages/object-record/RecordIndexPageHeader.tsx
@@ -27,7 +27,7 @@ export const RecordIndexPageHeader = ({
findObjectMetadataItemByNamePlural(objectNamePlural)?.icon,
);
- const recordIndexViewType = useRecoilValue(recordIndexViewTypeState);
+ const recordIndexViewType = useRecoilValue(recordIndexViewTypeState());
return (
<PageHeader title={capitalize(objectNamePlural)} Icon={Icon}>
diff --git a/packages/twenty-front/src/pages/settings/SettingsBilling.tsx b/packages/twenty-front/src/pages/settings/SettingsBilling.tsx
index 466f627f06c..ebecdfdab2a 100644
--- a/packages/twenty-front/src/pages/settings/SettingsBilling.tsx
+++ b/packages/twenty-front/src/pages/settings/SettingsBilling.tsx
@@ -30,8 +30,8 @@ const StyledInvisibleChat = styled.div`
export const SettingsBilling = () => {
const onboardingStatus = useOnboardingStatus();
- const supportChat = useRecoilValue(supportChatState);
- const currentWorkspace = useRecoilValue(currentWorkspaceState);
+ const supportChat = useRecoilValue(supportChatState());
+ const currentWorkspace = useRecoilValue(currentWorkspaceState());
const { data, loading } = useBillingPortalSessionQuery({
variables: {
returnUrlPath: '/settings/billing',
diff --git a/packages/twenty-front/src/pages/settings/SettingsWorkspaceMembers.tsx b/packages/twenty-front/src/pages/settings/SettingsWorkspaceMembers.tsx
index bd63e8978ab..48345f869ec 100644
--- a/packages/twenty-front/src/pages/settings/SettingsWorkspaceMembers.tsx
+++ b/packages/twenty-front/src/pages/settings/SettingsWorkspaceMembers.tsx
@@ -42,8 +42,8 @@ export const SettingsWorkspaceMembers = () => {
const { deleteOneRecord: deleteOneWorkspaceMember } = useDeleteOneRecord({
objectNameSingular: CoreObjectNameSingular.WorkspaceMember,
});
- const currentWorkspace = useRecoilValue(currentWorkspaceState);
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
+ const currentWorkspace = useRecoilValue(currentWorkspaceState());
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
const handleRemoveWorkspaceMember = async (workspaceMemberId: string) => {
await deleteOneWorkspaceMember?.(workspaceMemberId);
diff --git a/packages/twenty-front/src/pages/settings/accounts/SettingsAccounts.tsx b/packages/twenty-front/src/pages/settings/accounts/SettingsAccounts.tsx
index 72576db59f1..6b66c48261a 100644
--- a/packages/twenty-front/src/pages/settings/accounts/SettingsAccounts.tsx
+++ b/packages/twenty-front/src/pages/settings/accounts/SettingsAccounts.tsx
@@ -14,7 +14,7 @@ import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { SettingsAccountLoader } from '~/pages/settings/accounts/SettingsAccountLoader';
export const SettingsAccounts = () => {
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
const { records: accounts, loading } = useFindManyRecords<ConnectedAccount>({
objectNameSingular: 'connectedAccount',
diff --git a/packages/twenty-front/src/pages/settings/accounts/SettingsAccountsCalendars.tsx b/packages/twenty-front/src/pages/settings/accounts/SettingsAccountsCalendars.tsx
index 145ff310085..e65204f01ba 100644
--- a/packages/twenty-front/src/pages/settings/accounts/SettingsAccountsCalendars.tsx
+++ b/packages/twenty-front/src/pages/settings/accounts/SettingsAccountsCalendars.tsx
@@ -17,7 +17,7 @@ import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
import { mockedConnectedAccounts } from '~/testing/mock-data/accounts';
export const SettingsAccountsCalendars = () => {
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
const { records: _accounts } = useFindManyRecords<ConnectedAccount>({
objectNameSingular: CoreObjectNameSingular.ConnectedAccount,
filter: {
diff --git a/packages/twenty-front/src/pages/tasks/TasksEffect.tsx b/packages/twenty-front/src/pages/tasks/TasksEffect.tsx
index 588383510f6..9dc18238b6d 100644
--- a/packages/twenty-front/src/pages/tasks/TasksEffect.tsx
+++ b/packages/twenty-front/src/pages/tasks/TasksEffect.tsx
@@ -13,7 +13,7 @@ type TasksEffectProps = {
};
export const TasksEffect = ({ filterDropdownId }: TasksEffectProps) => {
- const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState);
+ const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState());
const {
setSelectedFilter,
setAvailableFilterDefinitions,
diff --git a/packages/twenty-front/src/testing/decorators/ObjectMetadataItemsDecorator.tsx b/packages/twenty-front/src/testing/decorators/ObjectMetadataItemsDecorator.tsx
index a657c995380..ec961a8700f 100644
--- a/packages/twenty-front/src/testing/decorators/ObjectMetadataItemsDecorator.tsx
+++ b/packages/twenty-front/src/testing/decorators/ObjectMetadataItemsDecorator.tsx
@@ -8,9 +8,9 @@ import { objectMetadataItemsState } from '@/object-metadata/states/objectMetadat
import { mockWorkspaceMembers } from '~/testing/mock-data/workspace-members';
export const ObjectMetadataItemsDecorator: Decorator = (Story) => {
- const objectMetadataItems = useRecoilValue(objectMetadataItemsState);
+ const objectMetadataItems = useRecoilValue(objectMetadataItemsState());
const setCurrentWorkspaceMember = useSetRecoilState(
- currentWorkspaceMemberState,
+ currentWorkspaceMemberState(),
);
useEffect(