fix: wrong signing invitation message (#1497)

This commit is contained in:
Catalin Pit
2024-12-01 22:47:11 +02:00
committed by GitHub
parent 87186e08b1
commit 62806298cf
6 changed files with 69 additions and 31 deletions

View File

@ -53,6 +53,17 @@ export const SigningPageView = ({
}: SigningPageViewProps) => { }: SigningPageViewProps) => {
const { documentData, documentMeta } = document; const { documentData, documentMeta } = document;
const shouldUseTeamDetails =
document.teamId && document.team?.teamGlobalSettings?.includeSenderDetails === false;
let senderName = document.User.name ?? '';
let senderEmail = `(${document.User.email})`;
if (shouldUseTeamDetails) {
senderName = document.team?.name ?? '';
senderEmail = document.team?.teamEmail?.email ? `(${document.team.teamEmail.email})` : '';
}
return ( return (
<div className="mx-auto w-full max-w-screen-xl"> <div className="mx-auto w-full max-w-screen-xl">
<h1 <h1
@ -63,27 +74,41 @@ export const SigningPageView = ({
</h1> </h1>
<div className="mt-2.5 flex flex-wrap items-center justify-between gap-x-6"> <div className="mt-2.5 flex flex-wrap items-center justify-between gap-x-6">
<div> <div className="max-w-[50ch]">
<p <span className="text-muted-foreground truncate" title={senderName}>
className="text-muted-foreground truncate" {senderName} {senderEmail}
title={document.User.name ? document.User.name : ''} </span>{' '}
> <span className="text-muted-foreground">
{document.User.name}
</p>
<p className="text-muted-foreground">
{match(recipient.role) {match(recipient.role)
.with(RecipientRole.VIEWER, () => ( .with(RecipientRole.VIEWER, () =>
<Trans>({document.User.email}) has invited you to view this document</Trans> document.teamId && !shouldUseTeamDetails ? (
)) <Trans>
.with(RecipientRole.SIGNER, () => ( on behalf of "{document.team?.name}" has invited you to view this document
<Trans>({document.User.email}) has invited you to sign this document</Trans> </Trans>
)) ) : (
.with(RecipientRole.APPROVER, () => ( <Trans>has invited you to view this document</Trans>
<Trans>({document.User.email}) has invited you to approve this document</Trans> ),
)) )
.with(RecipientRole.SIGNER, () =>
document.teamId && !shouldUseTeamDetails ? (
<Trans>
on behalf of "{document.team?.name}" has invited you to sign this document
</Trans>
) : (
<Trans>has invited you to sign this document</Trans>
),
)
.with(RecipientRole.APPROVER, () =>
document.teamId && !shouldUseTeamDetails ? (
<Trans>
on behalf of "{document.team?.name}" has invited you to approve this document
</Trans>
) : (
<Trans>has invited you to approve this document</Trans>
),
)
.otherwise(() => null)} .otherwise(() => null)}
</p> </span>
</div> </div>
<RejectDocumentDialog document={document} token={recipient.token} /> <RejectDocumentDialog document={document} token={recipient.token} />

View File

@ -61,7 +61,7 @@ export const TemplateDocumentInvite = ({
<> <>
{includeSenderDetails ? ( {includeSenderDetails ? (
<Trans> <Trans>
{inviterName} on behalf of {teamName} has invited you to{' '} {inviterName} on behalf of "{teamName}" has invited you to{' '}
{_(actionVerb).toLowerCase()} {_(actionVerb).toLowerCase()}
</Trans> </Trans>
) : ( ) : (

View File

@ -42,7 +42,7 @@ export const DocumentInviteEmailTemplate = ({
if (isTeamInvite) { if (isTeamInvite) {
previewText = includeSenderDetails previewText = includeSenderDetails
? msg`${inviterName} on behalf of ${teamName} has invited you to ${action} ${documentName}` ? msg`${inviterName} on behalf of "${teamName}" has invited you to ${action} ${documentName}`
: msg`${teamName} has invited you to ${action} ${documentName}`; : msg`${teamName} has invited you to ${action} ${documentName}`;
} }
@ -90,14 +90,16 @@ export const DocumentInviteEmailTemplate = ({
<Container className="mx-auto mt-12 max-w-xl"> <Container className="mx-auto mt-12 max-w-xl">
<Section> <Section>
<Text className="my-4 text-base font-semibold"> {!isTeamInvite && (
<Trans> <Text className="my-4 text-base font-semibold">
{inviterName}{' '} <Trans>
<Link className="font-normal text-slate-400" href="mailto:{inviterEmail}"> {inviterName}{' '}
({inviterEmail}) <Link className="font-normal text-slate-400" href="mailto:{inviterEmail}">
</Link> ({inviterEmail})
</Trans> </Link>
</Text> </Trans>
</Text>
)}
<Text className="mt-2 text-base text-slate-400"> <Text className="mt-2 text-base text-slate-400">
{customBody ? ( {customBody ? (

View File

@ -133,7 +133,7 @@ export const SEND_SIGNING_EMAIL_JOB_DEFINITION = {
if (!emailMessage) { if (!emailMessage) {
emailMessage = i18n._( emailMessage = i18n._(
team.teamGlobalSettings?.includeSenderDetails team.teamGlobalSettings?.includeSenderDetails
? msg`${user.name} on behalf of ${team.name} has invited you to ${recipientActionVerb} the document "${document.title}".` ? msg`${user.name} on behalf of "${team.name}" has invited you to ${recipientActionVerb} the document "${document.title}".`
: msg`${team.name} has invited you to ${recipientActionVerb} the document "${document.title}".`, : msg`${team.name} has invited you to ${recipientActionVerb} the document "${document.title}".`,
); );
} }

View File

@ -81,6 +81,17 @@ export const getDocumentAndSenderByToken = async ({
token, token,
}, },
}, },
team: {
select: {
name: true,
teamEmail: true,
teamGlobalSettings: {
select: {
includeSenderDetails: true,
},
},
},
},
}, },
}); });

View File

@ -134,7 +134,7 @@ export const resendDocument = async ({
emailMessage = emailMessage =
customEmail?.message || customEmail?.message ||
i18n._( i18n._(
msg`${user.name} on behalf of ${document.team.name} has invited you to ${recipientActionVerb} the document "${document.title}".`, msg`${user.name} on behalf of "${document.team.name}" has invited you to ${recipientActionVerb} the document "${document.title}".`,
); );
} }