Files
twenty_crm/packages/twenty-front/src/modules/activities/files/hooks/useAttachments.tsx
Félix Malfait 858c294f14 Website improvements 4 (#3182)
* Add contributor individual page

* Improve mobile menu

* Fix

* Remove yarn.lock from twenty-website

* Add yarn to gitingore

* Fix linter
2023-12-31 10:41:53 +01:00

23 lines
761 B
TypeScript

import { Attachment } from '@/activities/files/types/Attachment';
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
import { ActivityTargetableEntity } from '../../types/ActivityTargetableEntity';
// do we need to test this?
export const useAttachments = (entity: ActivityTargetableEntity) => {
const { records: attachments } = useFindManyRecords({
objectNameSingular: CoreObjectNameSingular.Attachment,
filter: {
[entity.type === 'Company' ? 'companyId' : 'personId']: { eq: entity.id },
},
orderBy: {
createdAt: 'DescNullsFirst',
},
});
return {
attachments: attachments as Attachment[],
};
};