From ce760eb72109bca9e6db921ef11140c365f6e4ee Mon Sep 17 00:00:00 2001 From: Theis Gaedigk Date: Tue, 27 Jan 2026 20:59:02 +0100 Subject: [PATCH] edited frontend for sending messages --- FrontendV2/src/pages/ContactPage.tsx | 78 +++++++++++++++++++++++++--- 1 file changed, 70 insertions(+), 8 deletions(-) diff --git a/FrontendV2/src/pages/ContactPage.tsx b/FrontendV2/src/pages/ContactPage.tsx index 8a0e129..18f669f 100644 --- a/FrontendV2/src/pages/ContactPage.tsx +++ b/FrontendV2/src/pages/ContactPage.tsx @@ -1,13 +1,75 @@ -import { Field, Textarea } from "@chakra-ui/react" +import { Field, Textarea, Button, Alert } from "@chakra-ui/react"; +import { useTranslation } from "react-i18next"; +import { useState } from "react"; +import { API_BASE } from "@/config/api.config"; +import Cookies from "js-cookie"; + +interface Alert { + type: "info" | "warning" | "success" | "error" | "neutral"; + headline: string; + text: string; +} export const ContactPage = () => { + const { t } = useTranslation(); + const [message, setMessage] = useState(""); + const [alert, setAlert] = useState(null); + + const sendMessage = async () => { + // Logic to send the message + const result = await fetch(`${API_BASE}/contact`, { + method: "POST", + headers: { + Authorization: `Bearer ${Cookies.get("token") || ""}`, + "Content-Type": "application/json", + Accept: "application/json", + }, + body: JSON.stringify({ message }), + }); + + if (result.ok) { + setAlert({ + type: "success", + headline: t("contactPage_successHeadline"), + text: t("contactPage_successText"), + }); + setMessage(""); + } else { + setAlert({ + type: "error", + headline: t("contactPage_errorHeadline"), + text: t("contactPage_errorText"), + }); + } + }; + return ( - - - Comment - -