976f86093c
* 2394-feat(front): create new record on click of plus icon * 2394-feat(front): fix of Icon Button * 2394-fix: PR fixes --------- Co-authored-by: Charles Bochet <charles@twenty.com>
21 lines
622 B
TypeScript
21 lines
622 B
TypeScript
import { Attachment } from '@/activities/files/types/Attachment';
|
|
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
|
|
|
|
import { ActivityTargetableEntity } from '../../types/ActivityTargetableEntity';
|
|
|
|
export const useAttachments = (entity: ActivityTargetableEntity) => {
|
|
const { records: attachments } = useFindManyRecords({
|
|
objectNamePlural: 'attachments',
|
|
filter: {
|
|
[entity.type === 'Company' ? 'companyId' : 'personId']: { eq: entity.id },
|
|
},
|
|
orderBy: {
|
|
createdAt: 'DescNullsFirst',
|
|
},
|
|
});
|
|
|
|
return {
|
|
attachments: attachments as Attachment[],
|
|
};
|
|
};
|