feat: update Invito email template to include user credentials and remove invite URL
This commit is contained in:
parent
9452535a9f
commit
f3425c0cd5
3 changed files with 32 additions and 11 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { Button, Heading, Row, Section, Text } from "@react-email/components";
|
||||
import { env } from "~/env";
|
||||
import Base from "./base";
|
||||
export type Invito_NewMail = {
|
||||
mailType: "invito";
|
||||
|
|
@ -7,10 +8,17 @@ export type Invito_NewMail = {
|
|||
|
||||
type InvitoProps = {
|
||||
nome: string;
|
||||
inviteUrl: string;
|
||||
email: string;
|
||||
password: string;
|
||||
//inviteUrl: string;
|
||||
};
|
||||
|
||||
const Invito = ({ nome, inviteUrl }: InvitoProps) => {
|
||||
const Invito = ({
|
||||
nome,
|
||||
//inviteUrl,
|
||||
email,
|
||||
password
|
||||
}: InvitoProps) => {
|
||||
return (
|
||||
<Base preview="Procedi ora su Infoalloggi.it">
|
||||
<>
|
||||
|
|
@ -26,11 +34,21 @@ const Invito = ({ nome, inviteUrl }: InvitoProps) => {
|
|||
disponibili.
|
||||
</Text>
|
||||
</Row>
|
||||
<Row>
|
||||
<Text>
|
||||
Le tue credenziali sono:
|
||||
<br />
|
||||
Email: <b>{email}</b>
|
||||
<br />
|
||||
Password: <b>{password}</b>
|
||||
</Text>
|
||||
</Row>
|
||||
|
||||
<Section className="mb-5">
|
||||
<Button
|
||||
className="mx-auto box-border inline-flex h-10 items-center justify-center whitespace-nowrap rounded-md bg-sky-500 px-4 py-2 text-center align-middle font-semibold text-white"
|
||||
href={inviteUrl}
|
||||
//href={inviteUrl}
|
||||
href={`${env.BASE_URL}/area-riservata/dashboard`}
|
||||
>
|
||||
Clicca qui per procedere
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { TRPCError } from "@trpc/server";
|
||||
import { z } from "zod";
|
||||
import { env } from "~/env";
|
||||
import {
|
||||
adminProcedure,
|
||||
createTRPCRouter,
|
||||
|
|
@ -8,7 +7,6 @@ import {
|
|||
} from "~/server/api/trpc";
|
||||
import {
|
||||
consumeInviteToken,
|
||||
createInviteToken,
|
||||
sendInvitoEmail,
|
||||
verifyInviteToken,
|
||||
} from "~/server/controllers/invites.controller";
|
||||
|
|
@ -29,15 +27,16 @@ export const inviteRouter = createTRPCRouter({
|
|||
.mutation(async ({ input }) => {
|
||||
try {
|
||||
const user = await getUser({ userId: input.id, db });
|
||||
const token = await createInviteToken(user.email);
|
||||
//const token = await createInviteToken(user.email);
|
||||
|
||||
const inviteUrl = `${env.BASE_URL}/auth/accetta-invito/${token}`;
|
||||
//const inviteUrl = `${env.BASE_URL}/auth/accetta-invito/${token}`;
|
||||
|
||||
await sendInvitoEmail({
|
||||
userId: input.id,
|
||||
email: user.email,
|
||||
nome: user.nome,
|
||||
inviteUrl,
|
||||
password: user.password,
|
||||
//inviteUrl,
|
||||
});
|
||||
|
||||
return { success: true };
|
||||
|
|
|
|||
|
|
@ -67,21 +67,25 @@ export async function consumeInviteToken(token: string) {
|
|||
export const sendInvitoEmail = async ({
|
||||
userId,
|
||||
email,
|
||||
inviteUrl,
|
||||
password,
|
||||
nome,
|
||||
//inviteUrl,
|
||||
}: {
|
||||
userId: UsersId;
|
||||
email: string;
|
||||
inviteUrl: string;
|
||||
password: string;
|
||||
nome: string;
|
||||
//inviteUrl: string;
|
||||
}) => {
|
||||
try {
|
||||
await NewMail({
|
||||
template: {
|
||||
mailType: "invito",
|
||||
props: {
|
||||
inviteUrl,
|
||||
email,
|
||||
nome,
|
||||
password,
|
||||
//inviteUrl,
|
||||
},
|
||||
},
|
||||
mail: {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue