feat: update Invito email template to include user credentials and remove invite URL

This commit is contained in:
Marco Pedone 2026-03-27 18:18:58 +01:00
parent 9452535a9f
commit f3425c0cd5
3 changed files with 32 additions and 11 deletions

View file

@ -1,4 +1,5 @@
import { Button, Heading, Row, Section, Text } from "@react-email/components"; import { Button, Heading, Row, Section, Text } from "@react-email/components";
import { env } from "~/env";
import Base from "./base"; import Base from "./base";
export type Invito_NewMail = { export type Invito_NewMail = {
mailType: "invito"; mailType: "invito";
@ -7,10 +8,17 @@ export type Invito_NewMail = {
type InvitoProps = { type InvitoProps = {
nome: string; nome: string;
inviteUrl: string; email: string;
password: string;
//inviteUrl: string;
}; };
const Invito = ({ nome, inviteUrl }: InvitoProps) => { const Invito = ({
nome,
//inviteUrl,
email,
password
}: InvitoProps) => {
return ( return (
<Base preview="Procedi ora su Infoalloggi.it"> <Base preview="Procedi ora su Infoalloggi.it">
<> <>
@ -26,11 +34,21 @@ const Invito = ({ nome, inviteUrl }: InvitoProps) => {
disponibili. disponibili.
</Text> </Text>
</Row> </Row>
<Row>
<Text>
Le tue credenziali sono:
<br />
Email: <b>{email}</b>
<br />
Password: <b>{password}</b>
</Text>
</Row>
<Section className="mb-5"> <Section className="mb-5">
<Button <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" 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 Clicca qui per procedere
</Button> </Button>

View file

@ -1,6 +1,5 @@
import { TRPCError } from "@trpc/server"; import { TRPCError } from "@trpc/server";
import { z } from "zod"; import { z } from "zod";
import { env } from "~/env";
import { import {
adminProcedure, adminProcedure,
createTRPCRouter, createTRPCRouter,
@ -8,7 +7,6 @@ import {
} from "~/server/api/trpc"; } from "~/server/api/trpc";
import { import {
consumeInviteToken, consumeInviteToken,
createInviteToken,
sendInvitoEmail, sendInvitoEmail,
verifyInviteToken, verifyInviteToken,
} from "~/server/controllers/invites.controller"; } from "~/server/controllers/invites.controller";
@ -29,15 +27,16 @@ export const inviteRouter = createTRPCRouter({
.mutation(async ({ input }) => { .mutation(async ({ input }) => {
try { try {
const user = await getUser({ userId: input.id, db }); 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({ await sendInvitoEmail({
userId: input.id, userId: input.id,
email: user.email, email: user.email,
nome: user.nome, nome: user.nome,
inviteUrl, password: user.password,
//inviteUrl,
}); });
return { success: true }; return { success: true };

View file

@ -67,21 +67,25 @@ export async function consumeInviteToken(token: string) {
export const sendInvitoEmail = async ({ export const sendInvitoEmail = async ({
userId, userId,
email, email,
inviteUrl, password,
nome, nome,
//inviteUrl,
}: { }: {
userId: UsersId; userId: UsersId;
email: string; email: string;
inviteUrl: string; password: string;
nome: string; nome: string;
//inviteUrl: string;
}) => { }) => {
try { try {
await NewMail({ await NewMail({
template: { template: {
mailType: "invito", mailType: "invito",
props: { props: {
inviteUrl, email,
nome, nome,
password,
//inviteUrl,
}, },
}, },
mail: { mail: {