Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Organization's Team invite emails #12843

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/web/public/static/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"request_another_invitation_email": "If you prefer not to use {{toEmail}} as your {{appName}} email or already have a {{appName}} account, please request another invitation to that email.",
"you_have_been_invited": "You have been invited to join the team {{teamName}}",
"user_invited_you": "{{user}} invited you to join the {{entity}} {{team}} on {{appName}}",
"user_invited_you_to_subteam": "{{user}} invited you to join the team {{team}} of organization {{parentTeamName}} on {{appName}}",
"hidden_team_member_title": "You are hidden in this team",
"hidden_team_member_message": "Your seat is not paid for, either Upgrade to PRO or let the team owner know they can pay for your seat.",
"hidden_team_owner_message": "You need a pro account to use teams, you are hidden until you upgrade.",
Expand Down Expand Up @@ -1746,9 +1747,11 @@
"organizer_timezone": "Organizer timezone",
"email_user_cta": "View Invitation",
"email_no_user_invite_heading_team": "You’ve been invited to join a {{appName}} team",
"email_no_user_invite_heading_subteam": "You’ve been invited to join a team of {{parentTeamName}} organization",
"email_no_user_invite_heading_org": "You’ve been invited to join a {{appName}} organization",
"email_no_user_invite_subheading": "{{invitedBy}} has invited you to join their team on {{appName}}. {{appName}} is the event-juggling scheduler that enables you and your team to schedule meetings without the email tennis.",
"email_user_invite_subheading_team": "{{invitedBy}} has invited you to join their team `{{teamName}}` on {{appName}}. {{appName}} is the event-juggling scheduler that enables you and your team to schedule meetings without the email tennis.",
"email_user_invite_subheading_subteam": "{{invitedBy}} has invited you to join the team `{{teamName}}` in their organization {{parentTeamName}} on {{appName}}. {{appName}} is the event-juggling scheduler that enables you and your team to schedule meetings without the email tennis.",
"email_user_invite_subheading_org": "{{invitedBy}} has invited you to join their organization `{{teamName}}` on {{appName}}. {{appName}} is the event-juggling scheduler that enables you and your organization to schedule meetings without the email tennis.",
"email_no_user_invite_steps_intro": "We’ll walk you through a few short steps and you’ll be enjoying stress free scheduling with your {{entity}} in no time.",
"email_no_user_step_one": "Choose your username",
Expand Down
28 changes: 19 additions & 9 deletions packages/emails/src/templates/TeamInviteEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,30 @@ type TeamInvite = {
joinLink: string;
isCalcomMember: boolean;
isOrg: boolean;
parentTeamName: string | undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
parentTeamName: string | undefined;
parentTeamName?: string;

It makes more sense. As parentTeamName itself isn't undefined but the caller can choose to not pass this.

};

export const TeamInviteEmail = (
props: TeamInvite & Partial<React.ComponentProps<typeof V2BaseEmailHtml>>
) => {
return (
<V2BaseEmailHtml
subject={props.language("user_invited_you", {
subject={props.language(`user_invited_you${props.parentTeamName ? "_to_subteam" : ""}`, {
user: props.from,
team: props.teamName,
appName: APP_NAME,
parentTeamName: props.parentTeamName,
entity: props.language(props.isOrg ? "organization" : "team").toLowerCase(),
})}>
<p style={{ fontSize: "24px", marginBottom: "16px", textAlign: "center" }}>
<>
{props.language(`email_no_user_invite_heading_${props.isOrg ? "org" : "team"}`, {
appName: APP_NAME,
})}
{props.language(
`email_no_user_invite_heading_${props.isOrg ? "org" : props.parentTeamName ? "subteam" : "team"}`,
{
appName: APP_NAME,
parentTeamName: props.parentTeamName,
}
)}
</>
</p>
<img
Expand All @@ -56,11 +62,15 @@ export const TeamInviteEmail = (
lineHeightStep: "24px",
}}>
<>
{props.language(`email_user_invite_subheading_${props.isOrg ? "org" : "team"}`, {
invitedBy: props.from,
appName: APP_NAME,
teamName: props.teamName,
})}
{props.language(
`email_user_invite_subheading_${props.isOrg ? "org" : props.parentTeamName ? "subteam" : "team"}`,
{
invitedBy: props.from,
appName: APP_NAME,
teamName: props.teamName,
parentTeamName: props.parentTeamName,
}
)}
</>
</p>
<div style={{ display: "flex", justifyContent: "center" }}>
Expand Down
21 changes: 13 additions & 8 deletions packages/emails/templates/team-invite-email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type TeamInvite = {
joinLink: string;
isCalcomMember: boolean;
isOrg: boolean;
parentTeamName: string | undefined;
};

export default class TeamInviteEmail extends BaseEmail {
Expand All @@ -28,14 +29,18 @@ export default class TeamInviteEmail extends BaseEmail {
return {
to: this.teamInviteEvent.to,
from: `${APP_NAME} <${this.getMailerOptions().from}>`,
subject: this.teamInviteEvent.language("user_invited_you", {
user: this.teamInviteEvent.from,
team: this.teamInviteEvent.teamName,
appName: APP_NAME,
entity: this.teamInviteEvent
.language(this.teamInviteEvent.isOrg ? "organization" : "team")
.toLowerCase(),
}),
subject: this.teamInviteEvent.language(
`user_invited_you${this.teamInviteEvent.parentTeamName ? "_to_subteam" : ""}`,
{
user: this.teamInviteEvent.from,
team: this.teamInviteEvent.teamName,
appName: APP_NAME,
parentTeamName: this.teamInviteEvent.parentTeamName,
entity: this.teamInviteEvent
.language(this.teamInviteEvent.isOrg ? "organization" : "team")
.toLowerCase(),
}
),
html: await renderEmail("TeamInviteEmail", this.teamInviteEvent),
text: "",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export const inviteMemberHandler = async ({ ctx, input }: InviteMemberOptions) =
language: translation,
isOrg: input.isOrg,
teamId: team.id,
currentUserParentTeamName: team?.parent?.name,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,11 @@ export async function sendVerificationEmail({
language: translation,
from: ctx.user.name || `${team.name}'s admin`,
to: usernameOrEmail,
teamName: team?.parent?.name || team.name,
teamName: team.name,
joinLink: `${WEBAPP_URL}/signup?token=${token}&callbackUrl=/getting-started`,
isCalcomMember: false,
isOrg: input.isOrg,
parentTeamName: team?.parent?.name,
});
} else {
await sendOrganizationAutoJoinEmail({
Expand Down Expand Up @@ -478,12 +479,14 @@ export const sendTeamInviteEmails = async ({
language,
currentUserTeamName,
currentUserName,
currentUserParentTeamName,
isOrg,
teamId,
}: {
language: TFunction;
existingUsersWithMembersips: UserWithMembership[];
currentUserTeamName?: string;
currentUserParentTeamName: string | undefined;
currentUserName?: string | null;
isOrg: boolean;
teamId: number;
Expand Down Expand Up @@ -529,6 +532,7 @@ export const sendTeamInviteEmails = async ({
teamName: currentUserTeamName,
...inviteTeamOptions,
isOrg: isOrg,
parentTeamName: currentUserParentTeamName,
});
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ export const resendInvitationHandler = async ({ ctx, input }: InviteMemberOption
language: translation,
from: ctx.user.name || `${team.name}'s admin`,
to: input.email,
teamName: team?.parent?.name || team.name,
teamName: team.name,
...inviteTeamOptions,
isOrg: input.isOrg,
parentTeamName: team?.parent?.name,
});

return input;
Expand Down
Loading