Add record chip for sender and add receivers (#3629)

* Add record chip for sender and add receivers

* Build enum for roles

* Rename var and use string literal

---------

Co-authored-by: Thomas Trompette <thomast@twenty.com>
This commit is contained in:
Thomas Trompette
2024-01-25 18:34:19 +01:00
committed by GitHub
parent b0c14ba5b9
commit 43b10cb00c
6 changed files with 109 additions and 46 deletions

View File

@ -0,0 +1,35 @@
import { EmailThreadMessageParticipant } from '@/activities/emails/types/EmailThreadMessageParticipant';
export const getDisplayNameFromParticipant = ({
participant,
shouldUseFullName = false,
}: {
participant: EmailThreadMessageParticipant;
shouldUseFullName?: boolean;
}) => {
if (participant.person) {
return (
`${participant.person?.name?.firstName}` +
(shouldUseFullName ? ` ${participant.person?.name?.lastName}` : '')
);
}
if (participant.workspaceMember) {
return (
participant.workspaceMember?.name?.firstName +
(shouldUseFullName
? ` ${participant.workspaceMember?.name?.lastName}`
: '')
);
}
if (participant.displayName) {
return participant.displayName;
}
if (participant.handle) {
return participant.handle;
}
return 'Unknown';
};