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:
Charles Bochet
2024-01-11 22:46:43 +01:00
committed by GitHub
parent 3ad032cdc1
commit 10fd67ba32
9 changed files with 223 additions and 99 deletions

View File

@ -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>

View File

@ -86,6 +86,7 @@ export const ActivityComments = ({
createOneComment?.({
id: v4(),
authorId: currentWorkspaceMember?.id ?? '',
author: currentWorkspaceMember,
activityId: activity?.id ?? '',
body: commentText,
createdAt: new Date().toISOString(),

View File

@ -20,6 +20,7 @@ export const useActivityTargets = ({
eq: targetableObject.id,
},
},
skip: !targetableObject.id,
});
return {

View File

@ -24,7 +24,6 @@ export const useTasks = ({
});
const isTargettingObjectRecords = isNonEmptyArray(targetableObjects);
const targetableObjectsFilter =
targetableObjects.reduce<LeafObjectRecordFilter>(
(aggregateFilter, targetableObject) => {

View File

@ -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`;
};

View File

@ -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,
});