* - Changed to objectNameSingular always defined - Added ErrorCatchAll * - Added mock mode for companies logged out - Added a proper ErrorBoundary component * Removed react-error-boundary * Implemented proper ErrorBoundary * Fixes * Change strategy about mocks --------- Co-authored-by: Charles Bochet <charles@twenty.com>
21 lines
623 B
TypeScript
21 lines
623 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({
|
|
objectNameSingular: 'attachment',
|
|
filter: {
|
|
[entity.type === 'Company' ? 'companyId' : 'personId']: { eq: entity.id },
|
|
},
|
|
orderBy: {
|
|
createdAt: 'DescNullsFirst',
|
|
},
|
|
});
|
|
|
|
return {
|
|
attachments: attachments as Attachment[],
|
|
};
|
|
};
|