mirror of
https://github.com/twentyhq/twenty.git
synced 2024-11-28 01:09:11 +03:00
Fix person activity creation broken
This commit is contained in:
parent
0c56989cb1
commit
148fe05e26
@ -2,6 +2,7 @@ import { useEffect, useMemo, useState } from 'react';
|
||||
import { BlockNoteEditor } from '@blocknote/core';
|
||||
import { useBlockNote } from '@blocknote/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import debounce from 'lodash.debounce';
|
||||
|
||||
import { Activity } from '@/activities/types/Activity';
|
||||
@ -48,7 +49,9 @@ export const ActivityBodyEditor = ({
|
||||
|
||||
const editor: BlockNoteEditor | null = useBlockNote({
|
||||
initialContent:
|
||||
activity.body !== '{}' ? JSON.parse(activity.body) : undefined,
|
||||
isNonEmptyString(activity.body) && activity.body !== '{}'
|
||||
? JSON.parse(activity.body)
|
||||
: undefined,
|
||||
editorDOMAttributes: { class: 'editor' },
|
||||
onEditorContentChange: (editor) => {
|
||||
debounceOnChange(JSON.stringify(editor.topLevelBlocks) ?? '');
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { useTheme } from '@emotion/react';
|
||||
import styled from '@emotion/styled';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
|
||||
import { ActivityTargetChips } from '@/activities/components/ActivityTargetChips';
|
||||
import { useOpenActivityRightDrawer } from '@/activities/hooks/useOpenActivityRightDrawer';
|
||||
@ -71,7 +72,8 @@ export const TaskRow = ({
|
||||
const theme = useTheme();
|
||||
const openActivityRightDrawer = useOpenActivityRightDrawer();
|
||||
|
||||
const body = JSON.parse(task.body)[0]?.content[0]?.text;
|
||||
const body = JSON.parse(isNonEmptyString(task.body) ? task.body : '{}')[0]
|
||||
?.content[0]?.text;
|
||||
const { completeTask } = useCompleteTask(task);
|
||||
|
||||
const activityTargetIds =
|
||||
|
@ -172,7 +172,12 @@ export const RecordShowPage = () => {
|
||||
key="add"
|
||||
entity={{
|
||||
id: object.id,
|
||||
type: 'Company',
|
||||
type:
|
||||
objectMetadataItem?.nameSingular === 'company'
|
||||
? 'Company'
|
||||
: objectMetadataItem?.nameSingular === 'person'
|
||||
? 'Person'
|
||||
: 'Custom',
|
||||
}}
|
||||
/>
|
||||
</PageHeader>
|
||||
|
@ -2,9 +2,6 @@ import { useState } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import styled from '@emotion/styled';
|
||||
|
||||
import { useOptimisticEffect } from '@/apollo/optimistic-effect/hooks/useOptimisticEffect';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { getRecordOptimisticEffectDefinition } from '@/object-record/graphql/optimistic-effect-definition/getRecordOptimisticEffectDefinition';
|
||||
import { useFindManyObjectRecords } from '@/object-record/hooks/useFindManyObjectRecords';
|
||||
import { objectSettingsWidth } from '@/settings/data-model/constants/objectSettings';
|
||||
import { SettingsApiKeysFieldItemTableRow } from '@/settings/developers/components/SettingsApiKeysFieldItemTableRow';
|
||||
@ -44,18 +41,12 @@ export const SettingsDevelopersApiKeys = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [apiKeys, setApiKeys] = useState<Array<ApiFieldItem>>([]);
|
||||
const { registerOptimisticEffect } = useOptimisticEffect({
|
||||
objectNameSingular: 'apiKey',
|
||||
});
|
||||
const { objectMetadataItem: foundObjectMetadataItem } = useObjectMetadataItem(
|
||||
{
|
||||
objectNameSingular: 'apiKey',
|
||||
},
|
||||
);
|
||||
|
||||
const filter = { revokedAt: { is: 'NULL' } };
|
||||
useFindManyObjectRecords({
|
||||
objectNamePlural: 'apiKeys',
|
||||
filter,
|
||||
orderBy: {},
|
||||
onCompleted: (data) => {
|
||||
setApiKeys(
|
||||
formatExpirations(
|
||||
@ -66,14 +57,6 @@ export const SettingsDevelopersApiKeys = () => {
|
||||
})),
|
||||
),
|
||||
);
|
||||
if (foundObjectMetadataItem) {
|
||||
registerOptimisticEffect({
|
||||
variables: { filter, first: 30, orderBy: {} },
|
||||
definition: getRecordOptimisticEffectDefinition({
|
||||
objectMetadataItem: foundObjectMetadataItem,
|
||||
}),
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user