mirror of
https://github.com/TheRealOwenRees/chess-scribe-website.git
synced 2026-07-23 09:56:57 +00:00
discord server component and toast on state change
This commit is contained in:
@@ -1,17 +1,26 @@
|
||||
import Contact from "#/pages/Contact/Contact.tsx";
|
||||
import { sendToDiscord } from "#/server/contact.ts";
|
||||
|
||||
const ContactContainer = () => {
|
||||
const handleSubmit = async (_prevState: unknown, data: FormData) => {
|
||||
const name = data.get("name");
|
||||
const email = data.get("email");
|
||||
const subject = data.get("subject");
|
||||
const message = data.get("message");
|
||||
const payload = {
|
||||
name: (data.get("name") as string) || "",
|
||||
email: (data.get("email") as string) || "",
|
||||
subject: (data.get("subject") as string) || "",
|
||||
message: (data.get("message") as string) || "",
|
||||
};
|
||||
|
||||
try {
|
||||
return { success: true, message: "Message sent!" };
|
||||
await sendToDiscord({ data: payload });
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Message sent successfully!",
|
||||
};
|
||||
} catch (error) {
|
||||
// TODO logger
|
||||
console.error("Error sending message:", error);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
message: "Failed to send message. Please try again.",
|
||||
|
||||
Reference in New Issue
Block a user