Update domain page UI

This commit is contained in:
KMKoushik
2024-04-13 07:34:13 +10:00
parent 3217387373
commit 293277ed32
9 changed files with 643 additions and 17 deletions

View File

@@ -13,6 +13,7 @@ import {
getDomain,
updateDomain,
} from "~/server/service/domain-service";
import { sendEmail } from "~/server/service/email-service";
export const domainRouter = createTRPCRouter({
createDomain: teamProcedure
@@ -61,4 +62,37 @@ export const domainRouter = createTRPCRouter({
await deleteDomain(input.id);
return { success: true };
}),
sendTestEmailFromDomain: teamProcedure
.input(z.object({ id: z.number() }))
.mutation(
async ({
ctx: {
session: { user },
team,
},
input,
}) => {
const domain = await db.domain.findFirst({
where: { id: input.id, teamId: team.id },
});
if (!domain) {
throw new Error("Domain not found");
}
if (!user.email) {
throw new Error("User email not found");
}
return sendEmail({
teamId: team.id,
to: user.email,
from: `hello@${domain.name}`,
subject: "Test mail",
text: "Hello this is a test mail",
html: "<p>Hello this is a test mail</p>",
});
}
),
});