* Allow user invitations * Restyle inviting members * Remove annoying comment * Add page for accepting an invitation * Send invitation email with Brevo * Prevent admins from removing personal project users * Mark access ceontrol for cancelProjectInvitation * Make RadioGroup controlled * Shorten form helper text * Use nodemailer to send emails * Update .env.example
30 lines
809 B
TypeScript
30 lines
809 B
TypeScript
import { env } from "~/env.mjs";
|
|
import { sendEmail } from "./sendEmail";
|
|
|
|
export const sendProjectInvitation = async ({
|
|
invitationToken,
|
|
recipientEmail,
|
|
invitationSenderName,
|
|
invitationSenderEmail,
|
|
projectName,
|
|
}: {
|
|
invitationToken: string;
|
|
recipientEmail: string;
|
|
invitationSenderName: string;
|
|
invitationSenderEmail: string;
|
|
projectName: string;
|
|
}) => {
|
|
const invitationLink = `${env.NEXT_PUBLIC_HOST}/invitations/${invitationToken}`;
|
|
|
|
const emailBody = `
|
|
<p>You have been invited to join ${projectName} by ${invitationSenderName} (${invitationSenderEmail}).</p>
|
|
<p>Click <a href="${invitationLink}">here</a> to accept the invitation.</p>
|
|
`;
|
|
|
|
await sendEmail({
|
|
to: recipientEmail,
|
|
subject: "You've been invited to join a project",
|
|
body: emailBody,
|
|
});
|
|
};
|