From 9ff2c742459a2195126783292c957dc0c5b4ae35 Mon Sep 17 00:00:00 2001 From: Lvyshnevska Date: Mon, 25 Nov 2024 20:01:20 +0100 Subject: [PATCH] updated feedback form --- FrontEnd/src/components/Contact/Contact.jsx | 178 +--------- .../src/components/Contact/Contact.module.css | 332 +----------------- .../components/Contact/ContactFormContent.jsx | 206 +++++++++++ .../Contact/ContactFormContent.module.css | 228 ++++++++++++ .../src/pages/CustomThemes/customTheme.js | 1 + 5 files changed, 462 insertions(+), 483 deletions(-) create mode 100644 FrontEnd/src/components/Contact/ContactFormContent.jsx create mode 100644 FrontEnd/src/components/Contact/ContactFormContent.module.css diff --git a/FrontEnd/src/components/Contact/Contact.jsx b/FrontEnd/src/components/Contact/Contact.jsx index 697e4d92b..f057ccd7c 100644 --- a/FrontEnd/src/components/Contact/Contact.jsx +++ b/FrontEnd/src/components/Contact/Contact.jsx @@ -1,28 +1,13 @@ import { useState, useEffect, useRef } from 'react'; -import { useForm, Controller } from 'react-hook-form'; -import { Link } from 'react-router-dom'; -import axios from 'axios'; -import { Spin, Select, Space } from 'antd'; - -import { - EMAIL_PATTERN, - MESSAGE_PATTERN -} from '../../constants/constants'; - +import { Spin } from 'antd'; +import SignUpComponentsPageLayout from '../../pages/SignUp/SignUp/SignUpComponentsPageLayout'; +import { ContactFormContent } from './ContactFormContent'; import styles from './Contact.module.css'; -const CATEGORY_OPTIONS = [ - { value: 'Технічне питання', label: 'Технічне питання' }, - { value: 'Рекомендації', label: 'Рекомендації' }, - { value: 'Питання', label: 'Питання' }, - { value: 'Інше', label: 'Інше' }, -]; - const Contact = () => { - const [loading, setLoading] = useState(false); - const [modalMessage, setModalMessage] = useState(''); const [percent, setPercent] = useState(-50); + const [isLoading, setIsLoading] = useState(false); const timerRef = useRef(); useEffect(() => { @@ -35,149 +20,24 @@ const Contact = () => { return () => clearTimeout(timerRef.current); }, [percent]); - const { - register, - handleSubmit, - reset, - control, - formState: { errors }, - } = useForm({ - mode: 'all', - defaultValues: { - 'message': '', - 'email': '', - }, - }); - - const onSubmit = async (value) => { - setLoading(true); - try { - const response = await axios.post(`${process.env.REACT_APP_BASE_API_URL}/api/admin/feedback/`, { - email: value.email, - message: value.message, - category: value.category, - }); - - if (response.status === 200 || response.status === 201) { - setModalMessage('Повідомлення успішно надіслано!'); - reset(); - } - } catch (error) { - setModalMessage('Щось пішло не так! Будь ласка, спробуйте ще раз!'); - } finally { - setLoading(false); - } - }; - const closeModal = () => { - setModalMessage(''); + const handleLoading = (loadingState) => { + setIsLoading(loadingState); }; return ( -
-
-

Зворотній зв'язок

-

* Обов'язкові поля позначені зірочкою

-
-
-
- - - {errors.email &&

{errors.email.message}

} -
-
- - - -