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 [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 ( | ||||
|     <div className="support page-padding"> | ||||
|       <BreadCrumbs homeRequired /> | ||||
| @ -49,10 +63,12 @@ const Support = () => { | ||||
| 
 | ||||
|           <form onSubmit={handleSubmit} className="support"> | ||||
|             <div className="support__input"> | ||||
|               <label>Как вас зовут:</label> | ||||
|               <label>Как вас зовут*:</label> | ||||
|               <div> | ||||
|                 <input name="name" | ||||
|                   type="text" | ||||
|                   value={userName} | ||||
|                   onChange={(e) => setUserName(e.target.value)} | ||||
|                 /></div> | ||||
|             </div> | ||||
|             <div className="support__input"> | ||||
| @ -61,6 +77,8 @@ const Support = () => { | ||||
|                 <input | ||||
|                   name="phone" | ||||
|                   type="phone" | ||||
|                   value={phone} | ||||
|                   onChange={(e) => setPhone(e.target.value)} | ||||
|                 /> | ||||
|               </div> | ||||
|             </div> | ||||
| @ -70,17 +88,28 @@ const Support = () => { | ||||
|                 <input | ||||
|                   name="email" | ||||
|                   type="email" | ||||
|                   value={email} | ||||
|                   onChange={(e) => setEmail(e.target.value)} | ||||
|                 /> | ||||
|               </div> | ||||
|             </div> | ||||
|             <div className="support__input"> | ||||
|               <label>Сообщение:</label> | ||||
|               <label>Сообщение*:</label> | ||||
|               <div> | ||||
|                 <div className="support__input"> | ||||
|                   <textarea name="review" /> | ||||
|                   <textarea name="review"  | ||||
|                                     value={message} | ||||
|                                     onChange={(e) => setMessage(e.target.value)} | ||||
|                    | ||||
|                    | ||||
|                   /> | ||||
|                 </div> | ||||
|               </div> | ||||
|               <button type="submit" className="support__btn_active">Отправить</button> | ||||
|               <button type="submit"  | ||||
|               className={`support__btn${ | ||||
|                 buttonIsActive() ? "" : "_active" | ||||
|               }`}
 | ||||
|               disabled={buttonIsActive()}>Отправить</button> | ||||
|             </div> | ||||
|           </form> | ||||
|         ) : ( | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user