Files
twenty/front/src/modules/activities/files/hooks/useAttachments.tsx
T
Kanav Arora 976f86093c 2394-feat(front): create new record on click of plus icon (#2660)
* 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>
2023-11-29 20:07:55 +01:00

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[],
};
};