corrected targetableobject being undefined when clicked on create task in command menu (#6635)

Issue #6630

It seems this bug is caused by `targetableObjects` being assigned an
empty array, which then leads to an error due to it being undefined.
I've made some changes that should address the issue, but I would
appreciate any feedback or suggestions on alternative solutions.

Please let me know if there is a better approach to resolving this.

Thank you!








https://github.com/user-attachments/assets/d6409798-3320-49b3-834f-2b6888847ed8
This commit is contained in:
nitin
2024-08-21 20:06:04 +05:30
committed by GitHub
parent c2cf8b4554
commit da5dfb7a5b
2 changed files with 34 additions and 15 deletions

View File

@ -68,24 +68,40 @@ export const useOpenCreateActivityDrawer = ({
assigneeId: customAssignee?.id,
});
const targetableObjectRelationIdName = `${targetableObjects[0].targetObjectNameSingular}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,
});
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);