From fd607789f43bc24e5a93f16292fabd99f801a189 Mon Sep 17 00:00:00 2001 From: flox_x <93255373+flooxo@users.noreply.github.com> Date: Fri, 29 Dec 2023 15:11:30 +0100 Subject: [PATCH] Replace all hardcoded core object name by enum (#3170) * Replace hardcoded core object name by enum Signed-off-by: Florian Grabmeier * Fix typo Signed-off-by: Florian Grabmeier * Fixed duplicate import --------- Signed-off-by: Florian Grabmeier Co-authored-by: Lucas Bordeau --- .../components/ActivityBodyEditor.tsx | 3 ++- .../components/ActivityComments.tsx | 5 +++-- .../activities/components/ActivityEditor.tsx | 7 ++++--- .../files/components/AttachmentRow.tsx | 3 ++- .../files/components/Attachments.tsx | 3 ++- .../activities/files/hooks/useAttachments.tsx | 3 ++- .../useHandleCheckableActivityTargetChange.ts | 5 +++-- .../hooks/useOpenCreateActivityDrawer.ts | 5 +++-- .../ActivityTargetInlineCellEditMode.tsx | 9 ++++---- .../components/ActivityTargetsInlineCell.tsx | 3 ++- .../activities/notes/hooks/useNotes.ts | 5 +++-- .../components/ActivityActionBar.tsx | 3 ++- .../components/RightDrawerActivity.tsx | 3 ++- .../activities/tasks/components/TaskRow.tsx | 3 ++- .../activities/tasks/hooks/useCompleteTask.ts | 3 ++- .../tasks/hooks/useCurrentUserDueTaskCount.ts | 3 ++- .../activities/tasks/hooks/useTasks.ts | 7 ++++--- .../timeline/components/Timeline.tsx | 5 +++-- .../command-menu/components/CommandMenu.tsx | 7 ++++--- .../components/AddPersonToCompany.tsx | 3 ++- .../companies/components/CompanyBoardCard.tsx | 3 ++- .../companies/components/CompanyTeam.tsx | 3 ++- .../components/HooksCompanyBoardEffect.tsx | 3 ++- .../components/NewOpportunityButton.tsx | 5 +++-- .../components/OpportunityPicker.tsx | 5 +++-- .../hooks/useSpreadsheetCompanyImport.ts | 3 ++- .../modules/favorites/hooks/useFavorites.ts | 7 ++++--- .../types/CoreObjectNameSingular.ts | 21 +++++++++++++++++-- .../hooks/useObjectRecordBoard.ts | 7 ++++--- .../record-board/components/RecordBoard.tsx | 3 ++- .../hooks/internal/useCreateOpportunity.ts | 3 ++- ...eDeleteSelectedRecordBoardCardsInternal.ts | 3 ++- .../internal/useRecordBoardColumnsInternal.ts | 3 ++- .../modules/people/components/PeopleCard.tsx | 3 ++- .../hooks/useSpreadsheetPersonImport.ts | 3 ++- .../pipeline/hooks/usePipelineSteps.ts | 5 +++-- .../hooks/useRelationFieldPreviewValue.ts | 3 ++- .../profile/components/NameFields.tsx | 3 ++- .../components/ProfilePictureUploader.tsx | 3 ++- .../modules/ui/theme/hooks/useColorScheme.ts | 3 ++- .../views/components/ViewBarEffect.tsx | 3 ++- .../views/hooks/internal/useViewFields.ts | 5 +++-- .../views/hooks/internal/useViewFilters.ts | 5 +++-- .../views/hooks/internal/useViewSorts.ts | 5 +++-- .../modules/views/hooks/internal/useViews.ts | 3 ++- .../src/pages/auth/CreateProfile.tsx | 3 ++- .../src/pages/opportunities/Opportunities.tsx | 3 ++- .../settings/SettingsWorkspaceMembers.tsx | 5 +++-- .../SettingsObjectNewFieldStep2.tsx | 7 ++++--- .../SettingsDevelopersApiKeyDetail.tsx | 7 ++++--- .../api-keys/SettingsDevelopersApiKeys.tsx | 3 ++- .../api-keys/SettingsDevelopersApiKeysNew.tsx | 3 ++- 52 files changed, 150 insertions(+), 82 deletions(-) diff --git a/packages/twenty-front/src/modules/activities/components/ActivityBodyEditor.tsx b/packages/twenty-front/src/modules/activities/components/ActivityBodyEditor.tsx index 08c801fc95..91c6a11dfb 100644 --- a/packages/twenty-front/src/modules/activities/components/ActivityBodyEditor.tsx +++ b/packages/twenty-front/src/modules/activities/components/ActivityBodyEditor.tsx @@ -11,6 +11,7 @@ import { BlockEditor } from '@/ui/input/editor/components/BlockEditor'; import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; import { REACT_APP_SERVER_BASE_URL } from '~/config'; import { FileFolder, useUploadFileMutation } from '~/generated/graphql'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; const StyledBlockNoteStyledContainer = styled.div` width: 100%; @@ -27,7 +28,7 @@ export const ActivityBodyEditor = ({ }: ActivityBodyEditorProps) => { const [body, setBody] = useState(null); const { updateOneRecord } = useUpdateOneRecord({ - objectNameSingular: 'activity', + objectNameSingular: CoreObjectNameSingular.Activity, }); useEffect(() => { diff --git a/packages/twenty-front/src/modules/activities/components/ActivityComments.tsx b/packages/twenty-front/src/modules/activities/components/ActivityComments.tsx index f5eb54ffcc..3611fccd40 100644 --- a/packages/twenty-front/src/modules/activities/components/ActivityComments.tsx +++ b/packages/twenty-front/src/modules/activities/components/ActivityComments.tsx @@ -14,6 +14,7 @@ import { AutosizeTextInputVariant, } from '@/ui/input/components/AutosizeTextInput'; import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; const StyledThreadItemListContainer = styled.div` align-items: flex-start; @@ -61,13 +62,13 @@ export const ActivityComments = ({ scrollableContainerRef, }: ActivityCommentsProps) => { const { createOneRecord: createOneComment } = useCreateOneRecord({ - objectNameSingular: 'comment', + objectNameSingular: CoreObjectNameSingular.Comment, }); const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState); const { records: comments } = useFindManyRecords({ - objectNameSingular: 'comment', + objectNameSingular: CoreObjectNameSingular.Comment, filter: { activityId: { eq: activity?.id ?? '', diff --git a/packages/twenty-front/src/modules/activities/components/ActivityEditor.tsx b/packages/twenty-front/src/modules/activities/components/ActivityEditor.tsx index 0f40feb80a..34578d1bd7 100644 --- a/packages/twenty-front/src/modules/activities/components/ActivityEditor.tsx +++ b/packages/twenty-front/src/modules/activities/components/ActivityEditor.tsx @@ -9,6 +9,7 @@ import { Activity } from '@/activities/types/Activity'; import { ActivityTarget } from '@/activities/types/ActivityTarget'; import { Comment } from '@/activities/types/Comment'; import { GraphQLActivity } from '@/activities/types/GraphQLActivity'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; import { useFieldContext } from '@/object-record/hooks/useFieldContext'; import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord'; import { RecordInlineCell } from '@/object-record/record-inline-cell/components/RecordInlineCell'; @@ -81,11 +82,11 @@ export const ActivityEditor = ({ const containerRef = useRef(null); const { updateOneRecord: updateOneActivity } = useUpdateOneRecord({ - objectNameSingular: 'activity', + objectNameSingular: CoreObjectNameSingular.Activity, }); const { FieldContextProvider: DueAtFieldContextProvider } = useFieldContext({ - objectNameSingular: 'activity', + objectNameSingular: CoreObjectNameSingular.Activity, objectRecordId: activity.id, fieldMetadataName: 'dueAt', fieldPosition: 0, @@ -93,7 +94,7 @@ export const ActivityEditor = ({ const { FieldContextProvider: AssigneeFieldContextProvider } = useFieldContext({ - objectNameSingular: 'activity', + objectNameSingular: CoreObjectNameSingular.Activity, objectRecordId: activity.id, fieldMetadataName: 'assignee', fieldPosition: 1, diff --git a/packages/twenty-front/src/modules/activities/files/components/AttachmentRow.tsx b/packages/twenty-front/src/modules/activities/files/components/AttachmentRow.tsx index de533fc1d8..c8d430fc2f 100644 --- a/packages/twenty-front/src/modules/activities/files/components/AttachmentRow.tsx +++ b/packages/twenty-front/src/modules/activities/files/components/AttachmentRow.tsx @@ -14,6 +14,7 @@ import { useDeleteOneRecord } from '@/object-record/hooks/useDeleteOneRecord'; import { IconCalendar } from '@/ui/display/icon'; import { REACT_APP_SERVER_BASE_URL } from '~/config'; import { formatToHumanReadableDate } from '~/utils'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; const StyledRow = styled.div` align-items: center; @@ -63,7 +64,7 @@ export const AttachmentRow = ({ attachment }: { attachment: Attachment }) => { const { deleteOneRecord: deleteOneAttachment } = useDeleteOneRecord({ - objectNameSingular: 'attachment', + objectNameSingular: CoreObjectNameSingular.Attachment, }); const handleDelete = () => { diff --git a/packages/twenty-front/src/modules/activities/files/components/Attachments.tsx b/packages/twenty-front/src/modules/activities/files/components/Attachments.tsx index 1f4cf70e5e..7adacaf8ca 100644 --- a/packages/twenty-front/src/modules/activities/files/components/Attachments.tsx +++ b/packages/twenty-front/src/modules/activities/files/components/Attachments.tsx @@ -12,6 +12,7 @@ import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord'; import { IconPlus } from '@/ui/display/icon'; import { Button } from '@/ui/input/button/components/Button'; import { FileFolder, useUploadFileMutation } from '~/generated/graphql'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; const StyledTaskGroupEmptyContainer = styled.div` align-items: center; @@ -67,7 +68,7 @@ export const Attachments = ({ const { createOneRecord: createOneAttachment } = useCreateOneRecord({ - objectNameSingular: 'attachment', + objectNameSingular: CoreObjectNameSingular.Attachment, }); const handleFileChange = (e: ChangeEvent) => { diff --git a/packages/twenty-front/src/modules/activities/files/hooks/useAttachments.tsx b/packages/twenty-front/src/modules/activities/files/hooks/useAttachments.tsx index ae4c966532..4d4ec5f4ff 100644 --- a/packages/twenty-front/src/modules/activities/files/hooks/useAttachments.tsx +++ b/packages/twenty-front/src/modules/activities/files/hooks/useAttachments.tsx @@ -2,11 +2,12 @@ import { Attachment } from '@/activities/files/types/Attachment'; import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords'; import { ActivityTargetableEntity } from '../../types/ActivityTargetableEntity'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; // do we need to test this? export const useAttachments = (entity: ActivityTargetableEntity) => { const { records: attachments } = useFindManyRecords({ - objectNameSingular: 'attachment', + objectNameSingular: CoreObjectNameSingular.Attachment, filter: { [entity.type === 'Company' ? 'companyId' : 'personId']: { eq: entity.id }, }, diff --git a/packages/twenty-front/src/modules/activities/hooks/useHandleCheckableActivityTargetChange.ts b/packages/twenty-front/src/modules/activities/hooks/useHandleCheckableActivityTargetChange.ts index a1674f96b6..2903ee6dde 100644 --- a/packages/twenty-front/src/modules/activities/hooks/useHandleCheckableActivityTargetChange.ts +++ b/packages/twenty-front/src/modules/activities/hooks/useHandleCheckableActivityTargetChange.ts @@ -1,4 +1,5 @@ import { ActivityTarget } from '@/activities/types/ActivityTarget'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord'; import { useDeleteOneRecord } from '@/object-record/hooks/useDeleteOneRecord'; @@ -11,10 +12,10 @@ export const useHandleCheckableActivityTargetChange = ({ }) => { const { createOneRecord: createOneActivityTarget } = useCreateOneRecord({ - objectNameSingular: 'activityTarget', + objectNameSingular: CoreObjectNameSingular.ActivityTarget, }); const { deleteOneRecord: deleteOneActivityTarget } = useDeleteOneRecord({ - objectNameSingular: 'activityTarget', + objectNameSingular: CoreObjectNameSingular.ActivityTarget, }); return async ( diff --git a/packages/twenty-front/src/modules/activities/hooks/useOpenCreateActivityDrawer.ts b/packages/twenty-front/src/modules/activities/hooks/useOpenCreateActivityDrawer.ts index 628f884216..3fac7c4960 100644 --- a/packages/twenty-front/src/modules/activities/hooks/useOpenCreateActivityDrawer.ts +++ b/packages/twenty-front/src/modules/activities/hooks/useOpenCreateActivityDrawer.ts @@ -15,15 +15,16 @@ import { activityTargetableEntityArrayState } from '../states/activityTargetable import { viewableActivityIdState } from '../states/viewableActivityIdState'; import { ActivityTargetableEntity } from '../types/ActivityTargetableEntity'; import { getTargetableEntitiesWithParents } from '../utils/getTargetableEntitiesWithParents'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const useOpenCreateActivityDrawer = () => { const { openRightDrawer } = useRightDrawer(); const { createOneRecord: createOneActivityTarget } = useCreateOneRecord({ - objectNameSingular: 'activityTarget', + objectNameSingular: CoreObjectNameSingular.ActivityTarget, }); const { createOneRecord: createOneActivity } = useCreateOneRecord({ - objectNameSingular: 'activity', + objectNameSingular: CoreObjectNameSingular.Activity, }); const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState); const setHotkeyScope = useSetHotkeyScope(); 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 f915c834e7..b7fc41472b 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 @@ -11,6 +11,7 @@ import { MultipleEntitySelect } from '@/object-record/relation-picker/components import { useRelationPicker } from '@/object-record/relation-picker/hooks/useRelationPicker'; import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery'; import { assertNotNull } from '~/utils/assert'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; type ActivityTargetInlineCellEditModeProps = { activityId: string; @@ -56,12 +57,12 @@ export const ActivityTargetInlineCellEditMode = ({ ); const { findManyRecordsQuery: findManyPeopleQuery } = useObjectMetadataItem({ - objectNameSingular: 'person', + objectNameSingular: CoreObjectNameSingular.Person, }); const { findManyRecordsQuery: findManyCompaniesQuery } = useObjectMetadataItem({ - objectNameSingular: 'company', + objectNameSingular: CoreObjectNameSingular.Company, }); const useFindManyPeopleQuery = (options: any) => @@ -87,7 +88,7 @@ export const ActivityTargetInlineCellEditMode = ({ orderByField: 'createdAt', mappingFunction: (record: any) => identifiersMapper?.(record, 'person'), selectedIds: initialPeopleIds, - objectNameSingular: 'person', + objectNameSingular: CoreObjectNameSingular.Person, limit: 3, }); @@ -102,7 +103,7 @@ export const ActivityTargetInlineCellEditMode = ({ orderByField: 'createdAt', mappingFunction: (record: any) => identifiersMapper?.(record, 'company'), selectedIds: initialCompanyIds, - objectNameSingular: 'company', + objectNameSingular: CoreObjectNameSingular.Company, limit: 3, }); diff --git a/packages/twenty-front/src/modules/activities/inline-cell/components/ActivityTargetsInlineCell.tsx b/packages/twenty-front/src/modules/activities/inline-cell/components/ActivityTargetsInlineCell.tsx index 7f412dd778..cc94e6feef 100644 --- a/packages/twenty-front/src/modules/activities/inline-cell/components/ActivityTargetsInlineCell.tsx +++ b/packages/twenty-front/src/modules/activities/inline-cell/components/ActivityTargetsInlineCell.tsx @@ -2,6 +2,7 @@ import { ActivityTargetChips } from '@/activities/components/ActivityTargetChips import { ActivityTargetInlineCellEditMode } from '@/activities/inline-cell/components/ActivityTargetInlineCellEditMode'; import { ActivityTarget } from '@/activities/types/ActivityTarget'; import { GraphQLActivity } from '@/activities/types/GraphQLActivity'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords'; import { RecordInlineCellContainer } from '@/object-record/record-inline-cell/components/RecordInlineCellContainer'; import { FieldRecoilScopeContext } from '@/object-record/record-inline-cell/states/recoil-scope-contexts/FieldRecoilScopeContext'; @@ -28,7 +29,7 @@ export const ActivityTargetsInlineCell = ({ ) ?? []; const { records: activityTargets } = useFindManyRecords({ - objectNameSingular: 'activityTarget', + objectNameSingular: CoreObjectNameSingular.ActivityTarget, filter: { id: { in: activityTargetIds } }, }); diff --git a/packages/twenty-front/src/modules/activities/notes/hooks/useNotes.ts b/packages/twenty-front/src/modules/activities/notes/hooks/useNotes.ts index 3b8c436451..625339fd7b 100644 --- a/packages/twenty-front/src/modules/activities/notes/hooks/useNotes.ts +++ b/packages/twenty-front/src/modules/activities/notes/hooks/useNotes.ts @@ -3,10 +3,11 @@ import { OrderByField } from '@/object-metadata/types/OrderByField'; import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords'; import { ActivityTargetableEntity } from '../../types/ActivityTargetableEntity'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const useNotes = (entity: ActivityTargetableEntity) => { const { records: activityTargets } = useFindManyRecords({ - objectNameSingular: 'activityTarget', + objectNameSingular: CoreObjectNameSingular.ActivityTarget, filter: { [entity.type === 'Company' ? 'companyId' : 'personId']: { eq: entity.id }, }, @@ -24,7 +25,7 @@ export const useNotes = (entity: ActivityTargetableEntity) => { const { records: notes } = useFindManyRecords({ skip: !activityTargets?.length, - objectNameSingular: 'activity', + objectNameSingular: CoreObjectNameSingular.Activity, filter, orderBy, }); 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 a104636e17..b4cb50d247 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 @@ -4,6 +4,7 @@ import { useDeleteOneRecord } from '@/object-record/hooks/useDeleteOneRecord'; import { IconTrash } from '@/ui/display/icon'; import { LightIconButton } from '@/ui/input/button/components/LightIconButton'; import { isRightDrawerOpenState } from '@/ui/layout/right-drawer/states/isRightDrawerOpenState'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; type ActivityActionBarProps = { activityId: string; @@ -12,7 +13,7 @@ type ActivityActionBarProps = { export const ActivityActionBar = ({ activityId }: ActivityActionBarProps) => { const [, setIsRightDrawerOpen] = useRecoilState(isRightDrawerOpenState); const { deleteOneRecord: deleteOneActivity } = useDeleteOneRecord({ - objectNameSingular: 'activity', + objectNameSingular: CoreObjectNameSingular.Activity, refetchFindManyQuery: true, }); diff --git a/packages/twenty-front/src/modules/activities/right-drawer/components/RightDrawerActivity.tsx b/packages/twenty-front/src/modules/activities/right-drawer/components/RightDrawerActivity.tsx index d21a9ac19b..1eca5ce07d 100644 --- a/packages/twenty-front/src/modules/activities/right-drawer/components/RightDrawerActivity.tsx +++ b/packages/twenty-front/src/modules/activities/right-drawer/components/RightDrawerActivity.tsx @@ -8,6 +8,7 @@ import { entityFieldsFamilyState } from '@/object-record/field/states/entityFiel import { useFindOneRecord } from '@/object-record/hooks/useFindOneRecord'; import '@blocknote/core/style.css'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; const StyledContainer = styled.div` box-sizing: border-box; @@ -35,7 +36,7 @@ export const RightDrawerActivity = ({ ); const { record: activity } = useFindOneRecord({ - objectNameSingular: 'activity', + objectNameSingular: CoreObjectNameSingular.Activity, objectRecordId: activityId, skip: !activityId, onCompleted: (activity: Activity) => { diff --git a/packages/twenty-front/src/modules/activities/tasks/components/TaskRow.tsx b/packages/twenty-front/src/modules/activities/tasks/components/TaskRow.tsx index 866c2c2698..74e5d35c29 100644 --- a/packages/twenty-front/src/modules/activities/tasks/components/TaskRow.tsx +++ b/packages/twenty-front/src/modules/activities/tasks/components/TaskRow.tsx @@ -13,6 +13,7 @@ import { Checkbox, CheckboxShape } from '@/ui/input/components/Checkbox'; import { beautifyExactDate, hasDatePassed } from '~/utils/date-utils'; import { useCompleteTask } from '../hooks/useCompleteTask'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; const StyledContainer = styled.div` align-items: center; @@ -81,7 +82,7 @@ export const TaskRow = ({ ) ?? []; const { records: activityTargets } = useFindManyRecords({ - objectNameSingular: 'activityTarget', + objectNameSingular: CoreObjectNameSingular.ActivityTarget, filter: { id: { in: activityTargetIds } }, }); diff --git a/packages/twenty-front/src/modules/activities/tasks/hooks/useCompleteTask.ts b/packages/twenty-front/src/modules/activities/tasks/hooks/useCompleteTask.ts index 89b76ef5b6..56617d2c50 100644 --- a/packages/twenty-front/src/modules/activities/tasks/hooks/useCompleteTask.ts +++ b/packages/twenty-front/src/modules/activities/tasks/hooks/useCompleteTask.ts @@ -2,12 +2,13 @@ import { useCallback } from 'react'; import { Activity } from '@/activities/types/Activity'; import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; type Task = Pick; export const useCompleteTask = (task: Task) => { const { updateOneRecord: updateOneActivity } = useUpdateOneRecord({ - objectNameSingular: 'activity', + objectNameSingular: CoreObjectNameSingular.Activity, }); const completeTask = useCallback( 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 b313ef654a..5d5eb9f30b 100644 --- a/packages/twenty-front/src/modules/activities/tasks/hooks/useCurrentUserDueTaskCount.ts +++ b/packages/twenty-front/src/modules/activities/tasks/hooks/useCurrentUserDueTaskCount.ts @@ -4,12 +4,13 @@ import { useRecoilValue } from 'recoil'; import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState'; import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords'; import { parseDate } from '~/utils/date-utils'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const useCurrentUserTaskCount = () => { const currentWorkspaceMember = useRecoilValue(currentWorkspaceMemberState); const { records: tasks } = useFindManyRecords({ - objectNameSingular: 'activity', + objectNameSingular: CoreObjectNameSingular.Activity, filter: { type: { eq: 'Task' }, completedAt: { is: 'NULL' }, diff --git a/packages/twenty-front/src/modules/activities/tasks/hooks/useTasks.ts b/packages/twenty-front/src/modules/activities/tasks/hooks/useTasks.ts index e194a4d8d6..332769a79c 100644 --- a/packages/twenty-front/src/modules/activities/tasks/hooks/useTasks.ts +++ b/packages/twenty-front/src/modules/activities/tasks/hooks/useTasks.ts @@ -7,6 +7,7 @@ import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords'; import { useFilterDropdown } from '@/object-record/object-filter-dropdown/hooks/useFilterDropdown'; import { parseDate } from '~/utils/date-utils'; import { isDefined } from '~/utils/isDefined'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; type UseTasksProps = { filterDropdownId?: string; @@ -21,7 +22,7 @@ export const useTasks = (props?: UseTasksProps) => { }); const { records: activityTargets } = useFindManyRecords({ - objectNameSingular: 'activityTarget', + objectNameSingular: CoreObjectNameSingular.ActivityTarget, filter: isDefined(entity) ? { [entity?.type === 'Company' ? 'companyId' : 'personId']: { @@ -32,7 +33,7 @@ export const useTasks = (props?: UseTasksProps) => { }); const { records: completeTasksData } = useFindManyRecords({ - objectNameSingular: 'activity', + objectNameSingular: CoreObjectNameSingular.Activity, skip: !entity && !selectedFilter, filter: { completedAt: { is: 'NOT_NULL' }, @@ -56,7 +57,7 @@ export const useTasks = (props?: UseTasksProps) => { }); const { records: incompleteTaskData } = useFindManyRecords({ - objectNameSingular: 'activity', + objectNameSingular: CoreObjectNameSingular.Activity, skip: !entity && !selectedFilter, filter: { completedAt: { is: 'NULL' }, 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 4b61bf6ebc..2b54816eda 100644 --- a/packages/twenty-front/src/modules/activities/timeline/components/Timeline.tsx +++ b/packages/twenty-front/src/modules/activities/timeline/components/Timeline.tsx @@ -9,6 +9,7 @@ import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords'; import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile'; import { TimelineItemsContainer } from './TimelineItemsContainer'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; const StyledMainContainer = styled.div` align-items: flex-start; @@ -49,7 +50,7 @@ const StyledEmptyTimelineSubTitle = styled.div` export const Timeline = ({ entity }: { entity: ActivityTargetableEntity }) => { const { records: activityTargets, loading } = useFindManyRecords({ - objectNameSingular: 'activityTarget', + objectNameSingular: CoreObjectNameSingular.ActivityTarget, filter: { [entity.type === 'Company' ? 'companyId' : 'personId']: { eq: entity.id }, }, @@ -57,7 +58,7 @@ export const Timeline = ({ entity }: { entity: ActivityTargetableEntity }) => { const { records: activities } = useFindManyRecords({ skip: !activityTargets?.length, - objectNameSingular: 'activity', + objectNameSingular: CoreObjectNameSingular.Activity, filter: { id: { in: activityTargets?.map((activityTarget) => activityTarget.activityId), 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 7c583dd4b8..5431b79bdc 100644 --- a/packages/twenty-front/src/modules/command-menu/components/CommandMenu.tsx +++ b/packages/twenty-front/src/modules/command-menu/components/CommandMenu.tsx @@ -26,6 +26,7 @@ import { Command, CommandType } from '../types/Command'; import { CommandGroup } from './CommandGroup'; import { CommandMenuItem } from './CommandMenuItem'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const StyledDialog = styled.div` background: ${({ theme }) => theme.background.secondary}; @@ -132,7 +133,7 @@ export const CommandMenu = () => { const { records: people } = useFindManyRecords({ skip: !isCommandMenuOpened, - objectNameSingular: 'person', + objectNameSingular: CoreObjectNameSingular.Person, filter: { or: [ { name: { firstName: { ilike: `%${search}%` } } }, @@ -144,7 +145,7 @@ export const CommandMenu = () => { const { records: companies } = useFindManyRecords({ skip: !isCommandMenuOpened, - objectNameSingular: 'company', + objectNameSingular: CoreObjectNameSingular.Company, filter: { name: { ilike: `%${search}%` }, }, @@ -153,7 +154,7 @@ export const CommandMenu = () => { const { records: activities } = useFindManyRecords({ skip: !isCommandMenuOpened, - objectNameSingular: 'activity', + objectNameSingular: CoreObjectNameSingular.Activity, filter: { or: [ { title: { like: `%${search}%` } }, diff --git a/packages/twenty-front/src/modules/companies/components/AddPersonToCompany.tsx b/packages/twenty-front/src/modules/companies/components/AddPersonToCompany.tsx index 073126b5a1..18f69efbfd 100644 --- a/packages/twenty-front/src/modules/companies/components/AddPersonToCompany.tsx +++ b/packages/twenty-front/src/modules/companies/components/AddPersonToCompany.tsx @@ -16,6 +16,7 @@ import { LightIconButton } from '@/ui/input/button/components/LightIconButton'; import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope'; import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope'; import { FieldMetadataType } from '~/generated-metadata/graphql'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; const StyledContainer = styled.div` position: static; @@ -73,7 +74,7 @@ export const AddPersonToCompany = ({ updateOneRecordMutation, createOneRecordMutation, } = useObjectMetadataItem({ - objectNameSingular: 'person', + objectNameSingular: CoreObjectNameSingular.Person, }); const [updatePerson] = useMutation(updateOneRecordMutation); diff --git a/packages/twenty-front/src/modules/companies/components/CompanyBoardCard.tsx b/packages/twenty-front/src/modules/companies/components/CompanyBoardCard.tsx index 4837985f54..99e88385e8 100644 --- a/packages/twenty-front/src/modules/companies/components/CompanyBoardCard.tsx +++ b/packages/twenty-front/src/modules/companies/components/CompanyBoardCard.tsx @@ -24,6 +24,7 @@ import { getLogoUrlFromDomainName } from '~/utils'; import { companyProgressesFamilyState } from '../states/companyProgressesFamilyState'; import { CompanyChip } from './CompanyChip'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; const StyledBoardCard = styled.div<{ selected: boolean }>` background-color: ${({ theme, selected }) => @@ -151,7 +152,7 @@ export const CompanyBoardCard = () => { const useUpdateOneRecordMutation: RecordUpdateHook = () => { const { updateOneRecord: updateOneOpportunity } = useUpdateOneRecord({ - objectNameSingular: 'opportunity', + objectNameSingular: CoreObjectNameSingular.Opportunity, }); const updateEntity = ({ variables }: RecordUpdateHookParams) => { diff --git a/packages/twenty-front/src/modules/companies/components/CompanyTeam.tsx b/packages/twenty-front/src/modules/companies/components/CompanyTeam.tsx index 70963c7a04..58e80d6ca1 100644 --- a/packages/twenty-front/src/modules/companies/components/CompanyTeam.tsx +++ b/packages/twenty-front/src/modules/companies/components/CompanyTeam.tsx @@ -8,6 +8,7 @@ import { mapPaginatedRecordsToRecords } from '@/object-record/utils/mapPaginated import { PeopleCard } from '@/people/components/PeopleCard'; import { AddPersonToCompany } from './AddPersonToCompany'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export type CompanyTeamProps = { company: Pick; @@ -48,7 +49,7 @@ const StyledTitle = styled.div` export const CompanyTeam = ({ company }: { company: any }) => { const { findManyRecordsQuery } = useObjectMetadataItem({ - objectNameSingular: 'person', + objectNameSingular: CoreObjectNameSingular.Person, }); const { data } = useQuery(findManyRecordsQuery, { diff --git a/packages/twenty-front/src/modules/companies/components/HooksCompanyBoardEffect.tsx b/packages/twenty-front/src/modules/companies/components/HooksCompanyBoardEffect.tsx index 1b71db90a2..d68e3d1fdd 100644 --- a/packages/twenty-front/src/modules/companies/components/HooksCompanyBoardEffect.tsx +++ b/packages/twenty-front/src/modules/companies/components/HooksCompanyBoardEffect.tsx @@ -14,6 +14,7 @@ import { useViewScopedStates } from '@/views/hooks/internal/useViewScopedStates' import { useViewBar } from '@/views/hooks/useViewBar'; import { ViewType } from '@/views/types/ViewType'; import { mapViewFieldsToBoardFieldDefinitions } from '@/views/utils/mapViewFieldsToBoardFieldDefinitions'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; type HooksCompanyBoardEffectProps = { viewBarId: string; @@ -33,7 +34,7 @@ export const HooksCompanyBoardEffect = ({ } = useViewBar({ viewBarId }); const { objectMetadataItem } = useObjectMetadataItem({ - objectNameSingular: 'opportunity', + objectNameSingular: CoreObjectNameSingular.Opportunity, }); const { columnDefinitions, filterDefinitions, sortDefinitions } = diff --git a/packages/twenty-front/src/modules/companies/components/NewOpportunityButton.tsx b/packages/twenty-front/src/modules/companies/components/NewOpportunityButton.tsx index b4923005a2..c2134e3e19 100644 --- a/packages/twenty-front/src/modules/companies/components/NewOpportunityButton.tsx +++ b/packages/twenty-front/src/modules/companies/components/NewOpportunityButton.tsx @@ -11,6 +11,7 @@ import { RelationPickerHotkeyScope } from '@/object-record/relation-picker/types import { useFilteredSearchEntityQuery } from '@/search/hooks/useFilteredSearchEntityQuery'; import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar'; import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const NewOpportunityButton = () => { const [isCreatingCard, setIsCreatingCard] = useState(false); @@ -57,7 +58,7 @@ export const NewOpportunityButton = () => { // TODO: refactor useFilteredSearchEntityQuery const { findManyRecordsQuery } = useObjectMetadataItem({ - objectNameSingular: 'company', + objectNameSingular: CoreObjectNameSingular.Company, }); const useFindManyQuery = (options: any) => useQuery(findManyRecordsQuery, options); @@ -74,7 +75,7 @@ export const NewOpportunityButton = () => { orderByField: 'createdAt', selectedIds: [], mappingFunction: (record: any) => identifiersMapper?.(record, 'company'), - objectNameSingular: 'company', + objectNameSingular: CoreObjectNameSingular.Company, }); return ( diff --git a/packages/twenty-front/src/modules/companies/components/OpportunityPicker.tsx b/packages/twenty-front/src/modules/companies/components/OpportunityPicker.tsx index a9e697d521..9f86e3cbd0 100644 --- a/packages/twenty-front/src/modules/companies/components/OpportunityPicker.tsx +++ b/packages/twenty-front/src/modules/companies/components/OpportunityPicker.tsx @@ -17,6 +17,7 @@ import { DropdownMenuSearchInput } from '@/ui/layout/dropdown/components/Dropdow import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownMenuSeparator'; import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export type OpportunityPickerProps = { companyId: string | null; @@ -37,7 +38,7 @@ export const OpportunityPicker = ({ // TODO: refactor useFilteredSearchEntityQuery const { findManyRecordsQuery: findManyCompanies } = useObjectMetadataItem({ - objectNameSingular: 'company', + objectNameSingular: CoreObjectNameSingular.Company, }); const useFindManyQuery = (options: any) => useQuery(findManyCompanies, options); @@ -54,7 +55,7 @@ export const OpportunityPicker = ({ orderByField: 'createdAt', selectedIds: [], mappingFunction: (record: any) => identifiersMapper?.(record, 'company'), - objectNameSingular: 'company', + objectNameSingular: CoreObjectNameSingular.Company, }); const [isProgressSelectionUnfolded, setIsProgressSelectionUnfolded] = diff --git a/packages/twenty-front/src/modules/companies/hooks/useSpreadsheetCompanyImport.ts b/packages/twenty-front/src/modules/companies/hooks/useSpreadsheetCompanyImport.ts index d6aff40df8..1543c362af 100644 --- a/packages/twenty-front/src/modules/companies/hooks/useSpreadsheetCompanyImport.ts +++ b/packages/twenty-front/src/modules/companies/hooks/useSpreadsheetCompanyImport.ts @@ -5,6 +5,7 @@ import { SpreadsheetOptions } from '@/spreadsheet-import/types'; import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar'; import { fieldsForCompany } from '../utils/fieldsForCompany'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export type FieldCompanyMapping = (typeof fieldsForCompany)[number]['key']; @@ -14,7 +15,7 @@ export const useSpreadsheetCompanyImport = () => { const { createManyRecords: createManyCompanies } = useCreateManyRecords({ - objectNameSingular: 'company', + objectNameSingular: CoreObjectNameSingular.Company, }); const openCompanySpreadsheetImport = ( diff --git a/packages/twenty-front/src/modules/favorites/hooks/useFavorites.ts b/packages/twenty-front/src/modules/favorites/hooks/useFavorites.ts index 48d7ff7b10..8937ca2aa3 100644 --- a/packages/twenty-front/src/modules/favorites/hooks/useFavorites.ts +++ b/packages/twenty-front/src/modules/favorites/hooks/useFavorites.ts @@ -14,6 +14,7 @@ import { PaginatedRecordTypeResults } from '@/object-record/types/PaginatedRecor import { isDeeplyEqual } from '~/utils/isDeeplyEqual'; import { favoritesState } from '../states/favoritesState'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const useFavorites = ({ objectNamePlural, @@ -29,11 +30,11 @@ export const useFavorites = ({ createOneRecordMutation: createOneFavoriteMutation, deleteOneRecordMutation: deleteOneFavoriteMutation, } = useObjectMetadataItem({ - objectNameSingular: 'favorite', + objectNameSingular: CoreObjectNameSingular.Favorite, }); const { triggerOptimisticEffects } = useOptimisticEffect({ - objectNameSingular: 'favorite', + objectNameSingular: CoreObjectNameSingular.Favorite, }); const { performOptimisticEvict } = useOptimisticEvict(); @@ -49,7 +50,7 @@ export const useFavorites = ({ const apolloClient = useApolloClient(); useFindManyRecords({ - objectNameSingular: 'favorite', + objectNameSingular: CoreObjectNameSingular.Favorite, onCompleted: useRecoilCallback( ({ snapshot, set }) => async (data: PaginatedRecordTypeResults>) => { diff --git a/packages/twenty-front/src/modules/object-metadata/types/CoreObjectNameSingular.ts b/packages/twenty-front/src/modules/object-metadata/types/CoreObjectNameSingular.ts index 99bfe2b6e1..119f800494 100644 --- a/packages/twenty-front/src/modules/object-metadata/types/CoreObjectNameSingular.ts +++ b/packages/twenty-front/src/modules/object-metadata/types/CoreObjectNameSingular.ts @@ -1,6 +1,23 @@ export enum CoreObjectNameSingular { + Activity = 'activity', + ActivityTarget = 'activityTarget', + ApiKey = 'apiKey', + Attachment = 'attachment', + Comment = 'comment', Company = 'company', - Person = 'person', - WorkspaceMember = 'workspaceMember', + ConenctedAccount = 'conenctedAccount', + Favorite = 'favorite', + Message = 'message', + MessageChannel = 'messageChannel', + MessageRecipient = 'messageRecipient', + MessageThread = 'messageThread', Opportunity = 'opportunity', + Person = 'person', + PipelineStep = 'pipelineStep', + View = 'view', + ViewField = 'viewField', + ViewFilter = 'viewFilter', + ViewSort = 'viewSort', + Webhook = 'webhook', + WorkspaceMember = 'workspaceMember', } diff --git a/packages/twenty-front/src/modules/object-record/hooks/useObjectRecordBoard.ts b/packages/twenty-front/src/modules/object-record/hooks/useObjectRecordBoard.ts index ae6acaf0d7..8516a4d57d 100644 --- a/packages/twenty-front/src/modules/object-record/hooks/useObjectRecordBoard.ts +++ b/packages/twenty-front/src/modules/object-record/hooks/useObjectRecordBoard.ts @@ -11,6 +11,7 @@ import { Opportunity } from '@/pipeline/types/Opportunity'; import { PipelineStep } from '@/pipeline/types/PipelineStep'; import { useFindManyRecords } from './useFindManyRecords'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const useObjectRecordBoard = () => { const objectNameSingular = 'opportunity'; @@ -53,7 +54,7 @@ export const useObjectRecordBoard = () => { ); useFindManyRecords({ - objectNameSingular: 'pipelineStep', + objectNameSingular: CoreObjectNameSingular.PipelineStep, filter: {}, onCompleted: useCallback( (data: PaginatedRecordTypeResults) => { @@ -69,7 +70,7 @@ export const useObjectRecordBoard = () => { fetchMoreRecords: fetchMoreOpportunities, } = useFindManyRecords({ skip: !savedPipelineSteps.length, - objectNameSingular: 'opportunity', + objectNameSingular: CoreObjectNameSingular.Opportunity, filter, orderBy, onCompleted: useCallback(() => { @@ -79,7 +80,7 @@ export const useObjectRecordBoard = () => { const { fetchMoreRecords: fetchMoreCompanies } = useFindManyRecords({ skip: !savedOpportunities.length, - objectNameSingular: 'company', + objectNameSingular: CoreObjectNameSingular.Company, filter: { id: { in: savedOpportunities.map( diff --git a/packages/twenty-front/src/modules/object-record/record-board/components/RecordBoard.tsx b/packages/twenty-front/src/modules/object-record/record-board/components/RecordBoard.tsx index 9d44c77f96..0ae1400a0c 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/components/RecordBoard.tsx +++ b/packages/twenty-front/src/modules/object-record/record-board/components/RecordBoard.tsx @@ -22,6 +22,7 @@ import { BoardColumnDefinition } from '../types/BoardColumnDefinition'; import { BoardOptions } from '../types/BoardOptions'; import { RecordBoardColumn } from './RecordBoardColumn'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export type RecordBoardProps = { recordBoardId: string; @@ -73,7 +74,7 @@ export const RecordBoard = ({ const { updateOneRecord: updateOneOpportunity } = useUpdateOneRecord({ - objectNameSingular: 'opportunity', + objectNameSingular: CoreObjectNameSingular.Opportunity, }); const { unselectAllActiveCards, setCardSelected } = diff --git a/packages/twenty-front/src/modules/object-record/record-board/hooks/internal/useCreateOpportunity.ts b/packages/twenty-front/src/modules/object-record/record-board/hooks/internal/useCreateOpportunity.ts index 1dd0ccd6ba..6ad15368c0 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/hooks/internal/useCreateOpportunity.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/hooks/internal/useCreateOpportunity.ts @@ -4,11 +4,12 @@ import { v4 } from 'uuid'; import { useCreateOneRecord } from '@/object-record/hooks/useCreateOneRecord'; import { recordBoardCardIdsByColumnIdFamilyState } from '@/object-record/record-board/states/recordBoardCardIdsByColumnIdFamilyState'; import { Opportunity } from '@/pipeline/types/Opportunity'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const useCreateOpportunity = () => { const { createOneRecord: createOneOpportunity } = useCreateOneRecord({ - objectNameSingular: 'opportunity', + objectNameSingular: CoreObjectNameSingular.Opportunity, }); const createOpportunity = useRecoilCallback( diff --git a/packages/twenty-front/src/modules/object-record/record-board/hooks/internal/useDeleteSelectedRecordBoardCardsInternal.ts b/packages/twenty-front/src/modules/object-record/record-board/hooks/internal/useDeleteSelectedRecordBoardCardsInternal.ts index ab88e85bcc..980c47b768 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/hooks/internal/useDeleteSelectedRecordBoardCardsInternal.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/hooks/internal/useDeleteSelectedRecordBoardCardsInternal.ts @@ -6,6 +6,7 @@ import { useRecordBoardScopedStates } from '@/object-record/record-board/hooks/i import { Opportunity } from '@/pipeline/types/Opportunity'; import { useRemoveRecordBoardCardIdsInternal } from './useRemoveRecordBoardCardIdsInternal'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const useDeleteSelectedRecordBoardCardsInternal = () => { const removeCardIds = useRemoveRecordBoardCardIdsInternal(); @@ -13,7 +14,7 @@ export const useDeleteSelectedRecordBoardCardsInternal = () => { const { deleteManyRecords: deleteManyOpportunities } = useDeleteManyRecords({ - objectNameSingular: 'opportunity', + objectNameSingular: CoreObjectNameSingular.Opportunity, }); const { selectedCardIdsSelector } = useRecordBoardScopedStates(); diff --git a/packages/twenty-front/src/modules/object-record/record-board/hooks/internal/useRecordBoardColumnsInternal.ts b/packages/twenty-front/src/modules/object-record/record-board/hooks/internal/useRecordBoardColumnsInternal.ts index f5b8382028..78a6eae28c 100644 --- a/packages/twenty-front/src/modules/object-record/record-board/hooks/internal/useRecordBoardColumnsInternal.ts +++ b/packages/twenty-front/src/modules/object-record/record-board/hooks/internal/useRecordBoardColumnsInternal.ts @@ -6,6 +6,7 @@ import { PipelineStep } from '@/pipeline/types/PipelineStep'; import { useMoveViewColumns } from '@/views/hooks/useMoveViewColumns'; import { BoardColumnDefinition } from '../../types/BoardColumnDefinition'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const useBoardColumnsInternal = () => { const { boardColumnsState } = useRecordBoardScopedStates(); @@ -15,7 +16,7 @@ export const useBoardColumnsInternal = () => { const { updateOneRecord: updateOnePipelineStep } = useUpdateOneRecord({ - objectNameSingular: 'pipelineStep', + objectNameSingular: CoreObjectNameSingular.PipelineStep, }); const updatedPipelineSteps = (stages: BoardColumnDefinition[]) => { diff --git a/packages/twenty-front/src/modules/people/components/PeopleCard.tsx b/packages/twenty-front/src/modules/people/components/PeopleCard.tsx index 59a18d6b2f..f1145f6db1 100644 --- a/packages/twenty-front/src/modules/people/components/PeopleCard.tsx +++ b/packages/twenty-front/src/modules/people/components/PeopleCard.tsx @@ -14,6 +14,7 @@ import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/Drop import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem'; import { useListenClickOutside } from '@/ui/utilities/pointer-event/hooks/useListenClickOutside'; import { Avatar } from '@/users/components/Avatar'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export type PeopleCardProps = { person: Pick; @@ -112,7 +113,7 @@ export const PeopleCard = ({ updateOneRecordMutation, deleteOneRecordMutation, } = useObjectMetadataItem({ - objectNameSingular: 'person', + objectNameSingular: CoreObjectNameSingular.Person, }); const [updatePerson] = useMutation(updateOneRecordMutation); diff --git a/packages/twenty-front/src/modules/people/hooks/useSpreadsheetPersonImport.ts b/packages/twenty-front/src/modules/people/hooks/useSpreadsheetPersonImport.ts index 7464bc961f..8600b40672 100644 --- a/packages/twenty-front/src/modules/people/hooks/useSpreadsheetPersonImport.ts +++ b/packages/twenty-front/src/modules/people/hooks/useSpreadsheetPersonImport.ts @@ -7,6 +7,7 @@ import { SpreadsheetOptions } from '@/spreadsheet-import/types'; import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar'; import { fieldsForPerson } from '../utils/fieldsForPerson'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export type FieldPersonMapping = (typeof fieldsForPerson)[number]['key']; @@ -15,7 +16,7 @@ export const useSpreadsheetPersonImport = () => { const { enqueueSnackBar } = useSnackBar(); const { createManyRecords: createManyPeople } = useCreateManyRecords({ - objectNameSingular: 'person', + objectNameSingular: CoreObjectNameSingular.Person, }); const openPersonSpreadsheetImport = ( diff --git a/packages/twenty-front/src/modules/pipeline/hooks/usePipelineSteps.ts b/packages/twenty-front/src/modules/pipeline/hooks/usePipelineSteps.ts index 0d7ccc5235..cc07629dad 100644 --- a/packages/twenty-front/src/modules/pipeline/hooks/usePipelineSteps.ts +++ b/packages/twenty-front/src/modules/pipeline/hooks/usePipelineSteps.ts @@ -5,16 +5,17 @@ import { useDeleteOneRecord } from '@/object-record/hooks/useDeleteOneRecord'; import { BoardColumnDefinition } from '@/object-record/record-board/types/BoardColumnDefinition'; import { currentPipelineState } from '@/pipeline/states/currentPipelineState'; import { PipelineStep } from '@/pipeline/types/PipelineStep'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const usePipelineSteps = () => { const { createOneRecord: createOnePipelineStep } = useCreateOneRecord({ - objectNameSingular: 'pipelineStep', + objectNameSingular: CoreObjectNameSingular.PipelineStep, }); const { deleteOneRecord: deleteOnePipelineStep } = useDeleteOneRecord({ - objectNameSingular: 'pipelineStep', + objectNameSingular: CoreObjectNameSingular.PipelineStep, }); const handlePipelineStepAdd = useRecoilCallback( diff --git a/packages/twenty-front/src/modules/settings/data-model/hooks/useRelationFieldPreviewValue.ts b/packages/twenty-front/src/modules/settings/data-model/hooks/useRelationFieldPreviewValue.ts index 7a8b2328f8..73a9a935f0 100644 --- a/packages/twenty-front/src/modules/settings/data-model/hooks/useRelationFieldPreviewValue.ts +++ b/packages/twenty-front/src/modules/settings/data-model/hooks/useRelationFieldPreviewValue.ts @@ -1,4 +1,5 @@ import { useObjectMetadataItemForSettings } from '@/object-metadata/hooks/useObjectMetadataItemForSettings'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords'; export const useRelationFieldPreviewValue = ({ @@ -16,7 +17,7 @@ export const useRelationFieldPreviewValue = ({ : undefined; const { records: relationObjects } = useFindManyRecords({ - objectNameSingular: relationObjectMetadataItem?.nameSingular ?? 'company', // TODO fix this hack + objectNameSingular: relationObjectMetadataItem?.nameSingular ?? CoreObjectNameSingular.Company, // TODO fix this hack skip: skip || !relationObjectMetadataItem, }); 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 e9c0af8bb6..d6be90e7a0 100644 --- a/packages/twenty-front/src/modules/settings/profile/components/NameFields.tsx +++ b/packages/twenty-front/src/modules/settings/profile/components/NameFields.tsx @@ -8,6 +8,7 @@ import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMembe import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord'; import { TextInput } from '@/ui/input/components/TextInput'; import { logError } from '~/utils/logError'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; const StyledComboInputContainer = styled.div` display: flex; @@ -41,7 +42,7 @@ export const NameFields = ({ ); const { updateOneRecord } = useUpdateOneRecord({ - objectNameSingular: 'workspaceMember', + objectNameSingular: CoreObjectNameSingular.WorkspaceMember, }); // TODO: Enhance this with react-web-hook-form (https://www.react-hook-form.com) 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 7f8f194a2c..6e6a7d0407 100644 --- a/packages/twenty-front/src/modules/settings/profile/components/ProfilePictureUploader.tsx +++ b/packages/twenty-front/src/modules/settings/profile/components/ProfilePictureUploader.tsx @@ -6,6 +6,7 @@ import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord'; import { ImageInput } from '@/ui/input/components/ImageInput'; import { getImageAbsoluteURIOrBase64 } from '@/users/utils/getProfilePictureAbsoluteURI'; import { useUploadProfilePictureMutation } from '~/generated/graphql'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const ProfilePictureUploader = () => { const [uploadPicture, { loading: isUploading }] = @@ -20,7 +21,7 @@ export const ProfilePictureUploader = () => { const [errorMessage, setErrorMessage] = useState(null); const { updateOneRecord } = useUpdateOneRecord({ - objectNameSingular: 'workspaceMember', + objectNameSingular: CoreObjectNameSingular.WorkspaceMember, }); const handleUpload = async (file: File) => { 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 c02d0b9cc9..7843a91315 100644 --- a/packages/twenty-front/src/modules/ui/theme/hooks/useColorScheme.ts +++ b/packages/twenty-front/src/modules/ui/theme/hooks/useColorScheme.ts @@ -4,6 +4,7 @@ import { useRecoilState } from 'recoil'; import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState'; import { useUpdateOneRecord } from '@/object-record/hooks/useUpdateOneRecord'; import { ColorScheme } from '@/workspace-member/types/WorkspaceMember'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const useColorScheme = () => { const [currentWorkspaceMember, setCurrentWorkspaceMember] = useRecoilState( @@ -11,7 +12,7 @@ export const useColorScheme = () => { ); const { updateOneRecord: updateOneWorkspaceMember } = useUpdateOneRecord({ - objectNameSingular: 'workspaceMember', + objectNameSingular: CoreObjectNameSingular.WorkspaceMember, }); const colorScheme = currentWorkspaceMember?.colorScheme ?? 'System'; diff --git a/packages/twenty-front/src/modules/views/components/ViewBarEffect.tsx b/packages/twenty-front/src/modules/views/components/ViewBarEffect.tsx index 71488491ad..7868b9eee9 100644 --- a/packages/twenty-front/src/modules/views/components/ViewBarEffect.tsx +++ b/packages/twenty-front/src/modules/views/components/ViewBarEffect.tsx @@ -8,6 +8,7 @@ import { GraphQLView } from '@/views/types/GraphQLView'; import { isDeeplyEqual } from '~/utils/isDeeplyEqual'; import { useViewScopedStates } from '../hooks/internal/useViewScopedStates'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const ViewBarEffect = () => { const { @@ -35,7 +36,7 @@ export const ViewBarEffect = () => { const { records: newViews } = useFindManyRecords({ skip: !viewObjectMetadataId, - objectNameSingular: 'view', + objectNameSingular: CoreObjectNameSingular.View, filter: { type: { eq: viewType }, objectMetadataId: { eq: viewObjectMetadataId }, diff --git a/packages/twenty-front/src/modules/views/hooks/internal/useViewFields.ts b/packages/twenty-front/src/modules/views/hooks/internal/useViewFields.ts index fd4236ec3f..74e2910e43 100644 --- a/packages/twenty-front/src/modules/views/hooks/internal/useViewFields.ts +++ b/packages/twenty-front/src/modules/views/hooks/internal/useViewFields.ts @@ -5,15 +5,16 @@ import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadata import { ViewField } from '@/views/types/ViewField'; import { getViewScopedStatesFromSnapshot } from '@/views/utils/getViewScopedStatesFromSnapshot'; import { getViewScopedStateValuesFromSnapshot } from '@/views/utils/getViewScopedStateValuesFromSnapshot'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const useViewFields = (viewScopeId: string) => { const { updateOneRecordMutation, createOneRecordMutation } = useObjectMetadataItem({ - objectNameSingular: 'viewField', + objectNameSingular: CoreObjectNameSingular.ViewField, }); const { modifyRecordFromCache } = useObjectMetadataItem({ - objectNameSingular: 'view', + objectNameSingular: CoreObjectNameSingular.View, }); const apolloClient = useApolloClient(); diff --git a/packages/twenty-front/src/modules/views/hooks/internal/useViewFilters.ts b/packages/twenty-front/src/modules/views/hooks/internal/useViewFilters.ts index 9107a8f3f9..4d888f3875 100644 --- a/packages/twenty-front/src/modules/views/hooks/internal/useViewFilters.ts +++ b/packages/twenty-front/src/modules/views/hooks/internal/useViewFilters.ts @@ -9,6 +9,7 @@ import { ViewFilter } from '@/views/types/ViewFilter'; import { getViewScopedStateValuesFromSnapshot } from '@/views/utils/getViewScopedStateValuesFromSnapshot'; import { useViewScopedStates } from './useViewScopedStates'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const useViewFilters = (viewScopeId: string) => { const { @@ -16,11 +17,11 @@ export const useViewFilters = (viewScopeId: string) => { createOneRecordMutation, deleteOneRecordMutation, } = useObjectMetadataItem({ - objectNameSingular: 'viewFilter', + objectNameSingular: CoreObjectNameSingular.ViewFilter, }); const { modifyRecordFromCache } = useObjectMetadataItem({ - objectNameSingular: 'view', + objectNameSingular: CoreObjectNameSingular.View, }); const apolloClient = useApolloClient(); diff --git a/packages/twenty-front/src/modules/views/hooks/internal/useViewSorts.ts b/packages/twenty-front/src/modules/views/hooks/internal/useViewSorts.ts index eb03952dd3..86e9ada9a1 100644 --- a/packages/twenty-front/src/modules/views/hooks/internal/useViewSorts.ts +++ b/packages/twenty-front/src/modules/views/hooks/internal/useViewSorts.ts @@ -9,6 +9,7 @@ import { ViewSort } from '@/views/types/ViewSort'; import { getViewScopedStateValuesFromSnapshot } from '@/views/utils/getViewScopedStateValuesFromSnapshot'; import { useViewScopedStates } from './useViewScopedStates'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const useViewSorts = (viewScopeId: string) => { const { @@ -16,11 +17,11 @@ export const useViewSorts = (viewScopeId: string) => { createOneRecordMutation, deleteOneRecordMutation, } = useObjectMetadataItem({ - objectNameSingular: 'viewSort', + objectNameSingular: CoreObjectNameSingular.ViewSort, }); const { modifyRecordFromCache } = useObjectMetadataItem({ - objectNameSingular: 'view', + objectNameSingular: CoreObjectNameSingular.View, }); const apolloClient = useApolloClient(); diff --git a/packages/twenty-front/src/modules/views/hooks/internal/useViews.ts b/packages/twenty-front/src/modules/views/hooks/internal/useViews.ts index 96be0038f2..13717f47c4 100644 --- a/packages/twenty-front/src/modules/views/hooks/internal/useViews.ts +++ b/packages/twenty-front/src/modules/views/hooks/internal/useViews.ts @@ -4,6 +4,7 @@ import { useRecoilCallback } from 'recoil'; import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem'; import { GraphQLView } from '@/views/types/GraphQLView'; import { getViewScopedStateValuesFromSnapshot } from '@/views/utils/getViewScopedStateValuesFromSnapshot'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const useViews = (scopeId: string) => { const { @@ -12,7 +13,7 @@ export const useViews = (scopeId: string) => { deleteOneRecordMutation: deleteOneMutation, findManyRecordsQuery: findManyQuery, } = useObjectMetadataItem({ - objectNameSingular: 'view', + objectNameSingular: CoreObjectNameSingular.View, }); const apolloClient = useApolloClient(); diff --git a/packages/twenty-front/src/pages/auth/CreateProfile.tsx b/packages/twenty-front/src/pages/auth/CreateProfile.tsx index 8998e0f5b7..f8e2a7f738 100644 --- a/packages/twenty-front/src/pages/auth/CreateProfile.tsx +++ b/packages/twenty-front/src/pages/auth/CreateProfile.tsx @@ -21,6 +21,7 @@ import { MainButton } from '@/ui/input/button/components/MainButton'; import { TextInput } from '@/ui/input/components/TextInput'; import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys'; import { WorkspaceMember } from '@/workspace-member/types/WorkspaceMember'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; const StyledContentContainer = styled.div` width: 100%; @@ -63,7 +64,7 @@ export const CreateProfile = () => { ); const { updateOneRecord } = useUpdateOneRecord({ - objectNameSingular: 'workspaceMember', + objectNameSingular: CoreObjectNameSingular.WorkspaceMember, }); // Form diff --git a/packages/twenty-front/src/pages/opportunities/Opportunities.tsx b/packages/twenty-front/src/pages/opportunities/Opportunities.tsx index 63fb8db58c..5966d49e1f 100644 --- a/packages/twenty-front/src/pages/opportunities/Opportunities.tsx +++ b/packages/twenty-front/src/pages/opportunities/Opportunities.tsx @@ -9,6 +9,7 @@ import { IconTargetArrow } from '@/ui/display/icon'; import { PageBody } from '@/ui/layout/page/PageBody'; import { PageContainer } from '@/ui/layout/page/PageContainer'; import { PageHeader } from '@/ui/layout/page/PageHeader'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; const StyledBoardContainer = styled.div` display: flex; @@ -22,7 +23,7 @@ export const Opportunities = () => { const { updateOneRecord: updateOnePipelineStep } = useUpdateOneRecord({ - objectNameSingular: 'pipelineStep', + objectNameSingular: CoreObjectNameSingular.PipelineStep, }); const handleEditColumnTitle = ({ diff --git a/packages/twenty-front/src/pages/settings/SettingsWorkspaceMembers.tsx b/packages/twenty-front/src/pages/settings/SettingsWorkspaceMembers.tsx index 575620b4fa..a9d63968f1 100644 --- a/packages/twenty-front/src/pages/settings/SettingsWorkspaceMembers.tsx +++ b/packages/twenty-front/src/pages/settings/SettingsWorkspaceMembers.tsx @@ -16,6 +16,7 @@ import { Section } from '@/ui/layout/section/components/Section'; import { WorkspaceInviteLink } from '@/workspace/components/WorkspaceInviteLink'; import { WorkspaceMemberCard } from '@/workspace/components/WorkspaceMemberCard'; import { WorkspaceMember } from '@/workspace-member/types/WorkspaceMember'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; const StyledH1Title = styled(H1Title)` margin-bottom: 0; @@ -35,11 +36,11 @@ export const SettingsWorkspaceMembers = () => { >(); const { records: workspaceMembers } = useFindManyRecords({ - objectNameSingular: 'workspaceMember', + objectNameSingular: CoreObjectNameSingular.WorkspaceMember, }); const { deleteOneRecord: deleteOneWorkspaceMember } = useDeleteOneRecord({ - objectNameSingular: 'workspaceMember', + objectNameSingular: CoreObjectNameSingular.WorkspaceMember, }); const currentWorkspace = useRecoilValue(currentWorkspaceState); diff --git a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx index 871366c32a..b7031aec57 100644 --- a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx +++ b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx @@ -22,6 +22,7 @@ import { View } from '@/views/types/View'; import { ViewType } from '@/views/types/ViewType'; import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; import { FieldMetadataType } from '~/generated-metadata/graphql'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const SettingsObjectNewFieldStep2 = () => { const navigate = useNavigate(); @@ -83,11 +84,11 @@ export const SettingsObjectNewFieldStep2 = () => { const [relationObjectViews, setRelationObjectViews] = useState([]); const { modifyRecordFromCache: modifyViewFromCache } = useObjectMetadataItem({ - objectNameSingular: 'view', + objectNameSingular: CoreObjectNameSingular.View, }); useFindManyRecords({ - objectNameSingular: 'view', + objectNameSingular: CoreObjectNameSingular.View, filter: { type: { eq: ViewType.Table }, objectMetadataId: { eq: activeObjectMetadataItem?.id }, @@ -102,7 +103,7 @@ export const SettingsObjectNewFieldStep2 = () => { }); useFindManyRecords({ - objectNameSingular: 'view', + objectNameSingular: CoreObjectNameSingular.View, skip: !formValues.relation?.objectMetadataId, filter: { type: { eq: ViewType.Table }, diff --git a/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeyDetail.tsx b/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeyDetail.tsx index 632827bcc1..60c434d425 100644 --- a/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeyDetail.tsx +++ b/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeyDetail.tsx @@ -24,6 +24,7 @@ import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer' import { Section } from '@/ui/layout/section/components/Section'; import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb'; import { useGenerateApiKeyTokenMutation } from '~/generated/graphql'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; const StyledInfo = styled.span` color: ${({ theme }) => theme.font.color.light}; @@ -51,14 +52,14 @@ export const SettingsDevelopersApiKeyDetail = () => { const [generateOneApiKeyToken] = useGenerateApiKeyTokenMutation(); const { createOneRecord: createOneApiKey } = useCreateOneRecord({ - objectNameSingular: 'apiKey', + objectNameSingular: CoreObjectNameSingular.ApiKey, }); const { updateOneRecord: updateApiKey } = useUpdateOneRecord({ - objectNameSingular: 'apiKey', + objectNameSingular: CoreObjectNameSingular.ApiKey, }); const { record: apiKeyData } = useFindOneRecord({ - objectNameSingular: 'apiKey', + objectNameSingular: CoreObjectNameSingular.ApiKey, objectRecordId: apiKeyId, }); diff --git a/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeys.tsx b/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeys.tsx index a029eac385..10de37b2fd 100644 --- a/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeys.tsx +++ b/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeys.tsx @@ -15,6 +15,7 @@ import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer' import { Table } from '@/ui/layout/table/components/Table'; import { TableHeader } from '@/ui/layout/table/components/TableHeader'; import { TableRow } from '@/ui/layout/table/components/TableRow'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; const StyledContainer = styled.div` height: fit-content; @@ -43,7 +44,7 @@ export const SettingsDevelopersApiKeys = () => { const [apiKeys, setApiKeys] = useState>([]); useFindManyRecords({ - objectNameSingular: 'apiKey', + objectNameSingular: CoreObjectNameSingular.ApiKey, filter: { revokedAt: { is: 'NULL' } }, orderBy: {}, onCompleted: (data) => { diff --git a/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeysNew.tsx b/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeysNew.tsx index 173c90f001..2014aa3cbe 100644 --- a/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeysNew.tsx +++ b/packages/twenty-front/src/pages/settings/developers/api-keys/SettingsDevelopersApiKeysNew.tsx @@ -17,6 +17,7 @@ import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer' import { Section } from '@/ui/layout/section/components/Section'; import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb'; import { useGenerateApiKeyTokenMutation } from '~/generated/graphql'; +import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; export const SettingsDevelopersApiKeysNew = () => { const [generateOneApiKeyToken] = useGenerateApiKeyTokenMutation(); @@ -31,7 +32,7 @@ export const SettingsDevelopersApiKeysNew = () => { }); const { createOneRecord: createOneApiKey } = useCreateOneRecord({ - objectNameSingular: 'apiKey', + objectNameSingular: CoreObjectNameSingular.ApiKey, }); const onSave = async () => {