Move from TRPC to server actions

This commit is contained in:
Timothy Armes
2024-04-08 14:55:06 +02:00
parent cd83db2385
commit 0540ecc05a
25 changed files with 1802 additions and 1774 deletions
+36
View File
@@ -0,0 +1,36 @@
"use server";
import { z } from "zod";
import { contactUsSchema } from "@/schemas";
import { errorLog } from "@/utils/logger";
import { action } from "./safeAction";
export const contactUs = action(contactUsSchema, async (input) => {
try {
const { email, subject, message } = input;
await fetch(process.env.DISCORD_WEBHOOK_CONTACT_URL as string, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
embeds: [
{
title: "Contact",
fields: [
{ name: "Email", value: email },
{ name: "Subject", value: subject },
{ name: "Message", value: message },
],
},
],
}),
});
return true;
} catch (error) {
errorLog(error);
throw error;
}
});