From 6837cfa46a99dbecc187e5bf31b76907e86efb48 Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Thu, 11 Apr 2024 11:41:33 +0000 Subject: [PATCH] Added backend calls to support request --- src/app/[locale]/support/page.tsx | 53 ++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/src/app/[locale]/support/page.tsx b/src/app/[locale]/support/page.tsx index 42e924d..229e900 100644 --- a/src/app/[locale]/support/page.tsx +++ b/src/app/[locale]/support/page.tsx @@ -13,21 +13,29 @@ import { useState } from "react"; const Support = () => { const [isSent, setIsSent] = useState(false); - + const [userName, setUserName] = useState(""); + const [phone, setPhone] = useState(""); + const [email, setEmail] = useState(""); + const [message, setMessage] = useState(""); + const handleSubmit: React.MouseEventHandler< HTMLFormElement > = async (e) => { e.preventDefault(); - const formData = new FormData(e.currentTarget); - console.log(formData); + const data = { + name: userName, + phone: phone, + email: email, + message: email + }; + try { - /* + const res = await apiInstance.post( - `/${endpoint}/${id}/reviews/`, - formData, - config - );*/ + "/support/", + data + ); } catch (error) { console.log(error); } @@ -35,6 +43,12 @@ const Support = () => { }; + function buttonIsActive() + { + return message === "" || userName === ""; + } + + return (
@@ -49,10 +63,12 @@ const Support = () => {
- +
setUserName(e.target.value)} />
@@ -61,6 +77,8 @@ const Support = () => { setPhone(e.target.value)} />
@@ -70,17 +88,28 @@ const Support = () => { setEmail(e.target.value)} />
- +
-