Fix relation creation bug + enable favorite for custom objects (#3392)
* Fix relation creation bug * Fix vale CI * Fix comment bug
This commit is contained in:
@ -67,8 +67,8 @@ export const CommentHeader = ({ comment, actionBar }: CommentHeaderProps) => {
|
||||
const showDate = beautifiedCreatedAt !== '';
|
||||
|
||||
const author = comment.author;
|
||||
const authorName = author.name.firstName + ' ' + author.name.lastName;
|
||||
const avatarUrl = author.avatarUrl;
|
||||
const authorName = author?.name?.firstName + ' ' + author?.name?.lastName;
|
||||
const avatarUrl = author?.avatarUrl;
|
||||
const commentId = comment.id;
|
||||
|
||||
return (
|
||||
@ -77,7 +77,7 @@ export const CommentHeader = ({ comment, actionBar }: CommentHeaderProps) => {
|
||||
<Avatar
|
||||
avatarUrl={avatarUrl}
|
||||
size="md"
|
||||
colorId={author.id}
|
||||
colorId={author?.id}
|
||||
placeholder={authorName}
|
||||
/>
|
||||
<StyledName>{authorName}</StyledName>
|
||||
|
||||
@ -86,6 +86,7 @@ export const ActivityComments = ({
|
||||
createOneComment?.({
|
||||
id: v4(),
|
||||
authorId: currentWorkspaceMember?.id ?? '',
|
||||
author: currentWorkspaceMember,
|
||||
activityId: activity?.id ?? '',
|
||||
body: commentText,
|
||||
createdAt: new Date().toISOString(),
|
||||
|
||||
@ -20,6 +20,7 @@ export const useActivityTargets = ({
|
||||
eq: targetableObject.id,
|
||||
},
|
||||
},
|
||||
skip: !targetableObject.id,
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
@ -24,7 +24,6 @@ export const useTasks = ({
|
||||
});
|
||||
|
||||
const isTargettingObjectRecords = isNonEmptyArray(targetableObjects);
|
||||
|
||||
const targetableObjectsFilter =
|
||||
targetableObjects.reduce<LeafObjectRecordFilter>(
|
||||
(aggregateFilter, targetableObject) => {
|
||||
|
||||
@ -1,15 +1,7 @@
|
||||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
||||
|
||||
export const getActivityTargetObjectFieldIdName = ({
|
||||
nameSingular,
|
||||
}: {
|
||||
nameSingular: string;
|
||||
}) => {
|
||||
const isCoreObject =
|
||||
nameSingular === CoreObjectNameSingular.Company ||
|
||||
nameSingular === CoreObjectNameSingular.Person;
|
||||
|
||||
const objectFieldIdName = `${!isCoreObject ? '_' : ''}${nameSingular}Id`;
|
||||
|
||||
return objectFieldIdName;
|
||||
return `${nameSingular}Id`;
|
||||
};
|
||||
|
||||
@ -91,12 +91,12 @@ export const useFavorites = () => {
|
||||
]);
|
||||
|
||||
const createFavorite = (
|
||||
targetObject: Record<string, any>,
|
||||
targetRecord: Record<string, any>,
|
||||
targetObjectNameSingular: string,
|
||||
) => {
|
||||
createOneFavorite({
|
||||
[`${targetObjectNameSingular}Id`]: targetObject.id,
|
||||
[`${targetObjectNameSingular}`]: targetObject,
|
||||
[`${targetObjectNameSingular}Id`]: targetRecord.id,
|
||||
[`${targetObjectNameSingular}`]: targetRecord,
|
||||
position: favorites.length + 1,
|
||||
workspaceMemberId: currentWorkspaceMember?.id,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user