forked from Transparency/kgroad-frontend2
Added backend calls to support request
This commit is contained in:
parent
c7f7380821
commit
6837cfa46a
@ -13,21 +13,29 @@ import { useState } from "react";
|
|||||||
const Support = () => {
|
const Support = () => {
|
||||||
|
|
||||||
const [isSent, setIsSent] = useState(false);
|
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<
|
const handleSubmit: React.MouseEventHandler<
|
||||||
HTMLFormElement
|
HTMLFormElement
|
||||||
> = async (e) => {
|
> = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const formData = new FormData(e.currentTarget);
|
const data = {
|
||||||
console.log(formData);
|
name: userName,
|
||||||
|
phone: phone,
|
||||||
|
email: email,
|
||||||
|
message: email
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/*
|
|
||||||
const res = await apiInstance.post(
|
const res = await apiInstance.post(
|
||||||
`/${endpoint}/${id}/reviews/`,
|
"/support/",
|
||||||
formData,
|
data
|
||||||
config
|
);
|
||||||
);*/
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
@ -35,6 +43,12 @@ const Support = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function buttonIsActive()
|
||||||
|
{
|
||||||
|
return message === "" || userName === "";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="support page-padding">
|
<div className="support page-padding">
|
||||||
<BreadCrumbs homeRequired />
|
<BreadCrumbs homeRequired />
|
||||||
@ -49,10 +63,12 @@ const Support = () => {
|
|||||||
|
|
||||||
<form onSubmit={handleSubmit} className="support">
|
<form onSubmit={handleSubmit} className="support">
|
||||||
<div className="support__input">
|
<div className="support__input">
|
||||||
<label>Как вас зовут:</label>
|
<label>Как вас зовут*:</label>
|
||||||
<div>
|
<div>
|
||||||
<input name="name"
|
<input name="name"
|
||||||
type="text"
|
type="text"
|
||||||
|
value={userName}
|
||||||
|
onChange={(e) => setUserName(e.target.value)}
|
||||||
/></div>
|
/></div>
|
||||||
</div>
|
</div>
|
||||||
<div className="support__input">
|
<div className="support__input">
|
||||||
@ -61,6 +77,8 @@ const Support = () => {
|
|||||||
<input
|
<input
|
||||||
name="phone"
|
name="phone"
|
||||||
type="phone"
|
type="phone"
|
||||||
|
value={phone}
|
||||||
|
onChange={(e) => setPhone(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -70,17 +88,28 @@ const Support = () => {
|
|||||||
<input
|
<input
|
||||||
name="email"
|
name="email"
|
||||||
type="email"
|
type="email"
|
||||||
|
value={email}
|
||||||
|
onChange={(e) => setEmail(e.target.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="support__input">
|
<div className="support__input">
|
||||||
<label>Сообщение:</label>
|
<label>Сообщение*:</label>
|
||||||
<div>
|
<div>
|
||||||
<div className="support__input">
|
<div className="support__input">
|
||||||
<textarea name="review" />
|
<textarea name="review"
|
||||||
|
value={message}
|
||||||
|
onChange={(e) => setMessage(e.target.value)}
|
||||||
|
|
||||||
|
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" className="support__btn_active">Отправить</button>
|
<button type="submit"
|
||||||
|
className={`support__btn${
|
||||||
|
buttonIsActive() ? "" : "_active"
|
||||||
|
}`}
|
||||||
|
disabled={buttonIsActive()}>Отправить</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
) : (
|
) : (
|
||||||
|
Loading…
Reference in New Issue
Block a user