Skip to content

Commit

Permalink
check if targetTableObject is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ehconitin committed Aug 20, 2024
1 parent 3f4591d commit 8e50a3c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const PageChangeEffect = () => {
Icon: IconCheckbox,
onCommandClick: () =>
openCreateActivity({
targetableObjects: [{ id: '', targetObjectNameSingular: '' }],
targetableObjects: [],
}),
},
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,40 @@ export const useOpenCreateActivityDrawer = ({
assigneeId: customAssignee?.id,
});

const targetableObjectRelationIdName = `${targetableObjects[0].targetObjectNameSingular}Id`;

await createOneActivityTarget({
taskId:
activityObjectNameSingular === CoreObjectNameSingular.Task
? activity.id
: undefined,
noteId:
activityObjectNameSingular === CoreObjectNameSingular.Note
? activity.id
: undefined,
[targetableObjectRelationIdName]: targetableObjects[0].id,
});
if (targetableObjects.length > 0) {
const targetableObjectRelationIdName = `${targetableObjects[0].targetObjectNameSingular}Id`;

await createOneActivityTarget({
taskId:
activityObjectNameSingular === CoreObjectNameSingular.Task
? activity.id
: undefined,
noteId:
activityObjectNameSingular === CoreObjectNameSingular.Note
? activity.id
: undefined,
[targetableObjectRelationIdName]: targetableObjects[0].id,
});

setActivityTargetableEntityArray(targetableObjects);
} else {
await createOneActivityTarget({
taskId:
activityObjectNameSingular === CoreObjectNameSingular.Task
? activity.id
: undefined,
noteId:
activityObjectNameSingular === CoreObjectNameSingular.Note
? activity.id
: undefined,
});

setActivityTargetableEntityArray([]);
}

setHotkeyScope(RightDrawerHotkeyScope.RightDrawer, { goto: false });
setViewableRecordId(activity.id);
setViewableRecordNameSingular(activityObjectNameSingular);
setActivityTargetableEntityArray(targetableObjects ?? []);

openRightDrawer(RightDrawerPages.ViewRecord);
setIsUpsertingActivityInDB(false);
Expand Down

0 comments on commit 8e50a3c

Please sign in to comment.