From 2faef9ae6536dabcb76bb8d0dc15e13633e90c21 Mon Sep 17 00:00:00 2001 From: ifraimka Date: Wed, 20 Nov 2024 17:16:16 +0300 Subject: [PATCH 1/6] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D1=88=D0=B8?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D1=8B=20=D0=BA=D0=B0=D0=BF=D1=87=D0=B8=20?= =?UTF-8?q?=D0=B8=20=D0=B5=D1=91=20=D0=B2=D0=B8=D0=B4=D0=B8=D0=BC=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ContactForm/ContactForm.jsx | 156 ++++++++++++++++++ .../ContactForm/ContactForm.styles.scss | 13 ++ src/pages/Contact/Contact.styles.scss | 14 +- 3 files changed, 176 insertions(+), 7 deletions(-) diff --git a/src/components/ContactForm/ContactForm.jsx b/src/components/ContactForm/ContactForm.jsx index db46509..2bde5a7 100644 --- a/src/components/ContactForm/ContactForm.jsx +++ b/src/components/ContactForm/ContactForm.jsx @@ -7,6 +7,7 @@ import "./ContactForm.styles.scss"; import { fileUpload } from "../../assets/images"; function ContactForm() { +<<<<<<< Updated upstream return (

Свяжитесь с нами!

@@ -46,6 +47,161 @@ function ContactForm() {
); +======= + const [formData, setFormData] = useState({ + name: '', + email: '', + message: '', + file: null, + captcha: '', + }); + const [isSubmitting, setIsSubmitting] = useState(false); + + const handleChange = (e) => { + const { name, value } = e.target; + setFormData({ ...formData, [name]: value }); + }; + + const mb = 10; // Ограничение размера в мегабайтах + const MAX_FILE_SIZE = mb * 1024 * 1024; // Переменная для проверки размера. Не менять + + const handleFileChange = (e) => { + const file = e.target.files[0]; + // Проверка размера + if (file.size > MAX_FILE_SIZE) { + alert(`Превышено ограничение размера файла (10 Мб)`); + return; + } + // Проверка расширения + const extension = file.name.match(/\.([^.]+)$/)[1]; + switch (extension) { + case 'doc': + case 'docx': + case 'pdf': + case 'txt': + case 'pptx': + case 'ppt': + setFormData({ ...formData, file: e.target.files[0] }); + break; + default: + alert('Неверный формат файла.'); + } + }; + + const handleRemoveFile = () => { + setFormData({ ...formData, file: null }); + }; + + const handleCaptchaChange = (token) => { + setFormData({ ...formData, captcha: token }); + console.log('Капча пришла'); + }; + + const handleTokenExpired = useCallback(() => { + setFormData({ ...formData, captcha: null }); + console.log('Капча просрочилась'); + }, []); + + const handleSubmit = async (e) => { + e.preventDefault(); + setIsSubmitting(true); + console.log('handleSubmit isSubmitting: ', isSubmitting); + + const formDataObj = new FormData(); + formDataObj.append('name', formData.name); + formDataObj.append('email', formData.email); + formDataObj.append('message', formData.message); + formDataObj.append('file', formData.file); + formDataObj.append('captcha', formData.captcha); + + try { + const response = await sendContactForm(formDataObj); + if (response) { + alert('Сообщение отправлено!'); + console.log('response', response); + } else { + alert('Ошибка отправки.'); + } + } catch (error) { + console.error('Ошибка:', error); + alert('Ошибка отправки.'); + } finally { + setIsSubmitting(false); + } + }; + + return ( +
+

Свяжитесь с нами!

+
+
+ + +
+ +
+ +
+ {formData.captcha && + + } +
+ +
+
+
+
+
+ ); +>>>>>>> Stashed changes } export default ContactForm; \ No newline at end of file diff --git a/src/components/ContactForm/ContactForm.styles.scss b/src/components/ContactForm/ContactForm.styles.scss index d47ed4c..b0cdd89 100644 --- a/src/components/ContactForm/ContactForm.styles.scss +++ b/src/components/ContactForm/ContactForm.styles.scss @@ -47,9 +47,22 @@ $color-file-button: rgb(7, 42, 200); width: 100%; cursor: pointer; +<<<<<<< Updated upstream padding: 12px; font-size: 18px; line-height: normal; +======= + .submit-container { + + .submit { + width: 100%; + cursor: pointer; + + padding: 12px; + font-size: 18px; + line-height: normal; + } +>>>>>>> Stashed changes } } } \ No newline at end of file diff --git a/src/pages/Contact/Contact.styles.scss b/src/pages/Contact/Contact.styles.scss index d719093..c099bd6 100644 --- a/src/pages/Contact/Contact.styles.scss +++ b/src/pages/Contact/Contact.styles.scss @@ -6,7 +6,7 @@ flex-wrap: wrap; justify-content: space-between; flex: 1 1 50%; - + margin-bottom: 2em; h1 { @@ -34,15 +34,15 @@ flex-wrap: wrap; justify-content: space-between; align-items: center; + + .submit-container { + margin: 0; + max-width: 35%; + } } - .row > * { + .row>* { flex: 1 1 calc(50% - ($gap / 2)); } - - .row:has(.submit)>* { - margin: 0; - max-width: 35%; - } } } \ No newline at end of file From e4b9c4aa786c3f31eb08e729e4bca5e31c9a7f2f Mon Sep 17 00:00:00 2001 From: ifraimka Date: Wed, 20 Nov 2024 17:16:16 +0300 Subject: [PATCH 2/6] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D1=88=D0=B8?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D1=8B=20=D0=BA=D0=B0=D0=BF=D1=87=D0=B8=20?= =?UTF-8?q?=D0=B8=20=D0=B5=D1=91=20=D0=B2=D0=B8=D0=B4=D0=B8=D0=BC=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ContactForm/ContactForm.styles.scss | 17 ++++++++++++----- src/pages/Contact/Contact.styles.scss | 14 +++++++------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/components/ContactForm/ContactForm.styles.scss b/src/components/ContactForm/ContactForm.styles.scss index 61f2826..0e7d29b 100644 --- a/src/components/ContactForm/ContactForm.styles.scss +++ b/src/components/ContactForm/ContactForm.styles.scss @@ -119,15 +119,22 @@ $color-file-button: rgb(7, 42, 200); width: 100%; cursor: pointer; +<<<<<<< Updated upstream + padding: 12px; + font-size: 18px; + line-height: normal; +======= + .submit-container { + + .submit { + width: 100%; + cursor: pointer; + padding: 12px; font-size: 18px; line-height: normal; } - - >div>div>div { - margin-left: auto; - margin-right: auto; - } +>>>>>>> Stashed changes } } } \ No newline at end of file diff --git a/src/pages/Contact/Contact.styles.scss b/src/pages/Contact/Contact.styles.scss index d719093..c099bd6 100644 --- a/src/pages/Contact/Contact.styles.scss +++ b/src/pages/Contact/Contact.styles.scss @@ -6,7 +6,7 @@ flex-wrap: wrap; justify-content: space-between; flex: 1 1 50%; - + margin-bottom: 2em; h1 { @@ -34,15 +34,15 @@ flex-wrap: wrap; justify-content: space-between; align-items: center; + + .submit-container { + margin: 0; + max-width: 35%; + } } - .row > * { + .row>* { flex: 1 1 calc(50% - ($gap / 2)); } - - .row:has(.submit)>* { - margin: 0; - max-width: 35%; - } } } \ No newline at end of file From 683956c010dbe8b5ed63527406b7301cb6e195d8 Mon Sep 17 00:00:00 2001 From: ifraimka Date: Wed, 20 Nov 2024 17:27:10 +0300 Subject: [PATCH 3/6] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D0=BE=D1=82?= =?UTF-8?q?=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BA?= =?UTF-8?q?=D0=B0=D0=BF=D1=87=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ContactForm/ContactForm.jsx | 11 +++++++---- src/components/ContactForm/ContactForm.styles.scss | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/ContactForm/ContactForm.jsx b/src/components/ContactForm/ContactForm.jsx index 8937eff..1bd2117 100644 --- a/src/components/ContactForm/ContactForm.jsx +++ b/src/components/ContactForm/ContactForm.jsx @@ -137,22 +137,25 @@ function ContactForm() { isDisabled={isSubmitting} />
- {formData.captcha ? ( + {formData.captcha && - ) : ( + } +
- )} +
diff --git a/src/components/ContactForm/ContactForm.styles.scss b/src/components/ContactForm/ContactForm.styles.scss index 4807670..2aea096 100644 --- a/src/components/ContactForm/ContactForm.styles.scss +++ b/src/components/ContactForm/ContactForm.styles.scss @@ -124,4 +124,5 @@ $color-file-button: rgb(7, 42, 200); line-height: normal; } } - } \ No newline at end of file + } +} \ No newline at end of file From 303fecec479a50e73fbf494a79f13e222fe699a1 Mon Sep 17 00:00:00 2001 From: ifraimka Date: Thu, 21 Nov 2024 19:33:30 +0300 Subject: [PATCH 4/6] =?UTF-8?q?=D0=9E=D1=82=D0=BA=D0=BB=D1=8E=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=81=D1=82=D0=B8=D0=BB=D0=B5=D0=B9=20?= =?UTF-8?q?=D0=B8=20=D1=8D=D0=BB=D0=B5=D0=BC=D0=B5=D0=BD=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=20wordpress?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/styles/global.scss | 3 ++- src/assets/styles/wp-disable.scss | 7 +++++++ src/pages/Main/Main.styles.scss | 2 +- src/pages/Main/components/Gallery/Gallery.styles.scss | 2 +- src/pages/Main/components/Partners/Partners.styles.scss | 2 +- src/pages/Root/Root.jsx | 2 +- src/pages/Root/Root.styles.scss | 2 +- 7 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 src/assets/styles/wp-disable.scss diff --git a/src/assets/styles/global.scss b/src/assets/styles/global.scss index 28c7655..92ef36d 100644 --- a/src/assets/styles/global.scss +++ b/src/assets/styles/global.scss @@ -1,5 +1,6 @@ @import "./theme.scss"; @import "./fonts.scss"; +@import "./wp-disable.scss"; input { border: none; @@ -83,7 +84,7 @@ header h1 { flex-direction: column; justify-content: flex-start; - #page { + #react-page { margin-bottom: 2em; } diff --git a/src/assets/styles/wp-disable.scss b/src/assets/styles/wp-disable.scss new file mode 100644 index 0000000..8bd2b81 --- /dev/null +++ b/src/assets/styles/wp-disable.scss @@ -0,0 +1,7 @@ +#page { + > #header, + > hr, + > #footer { + display: none; + } +} diff --git a/src/pages/Main/Main.styles.scss b/src/pages/Main/Main.styles.scss index ba9ccc8..3a74c81 100644 --- a/src/pages/Main/Main.styles.scss +++ b/src/pages/Main/Main.styles.scss @@ -1,6 +1,6 @@ @import "../../assets/styles/theme.scss"; -#page:has(> #mainpageheader) { +#react-page:has(> #mainpageheader) { margin-top: 0; #mainpageheader { diff --git a/src/pages/Main/components/Gallery/Gallery.styles.scss b/src/pages/Main/components/Gallery/Gallery.styles.scss index 54bb4d4..cc40111 100644 --- a/src/pages/Main/components/Gallery/Gallery.styles.scss +++ b/src/pages/Main/components/Gallery/Gallery.styles.scss @@ -1,4 +1,4 @@ -#page .content #gallery { +#react-page .content #gallery { margin-left: 0; margin-right: 0; diff --git a/src/pages/Main/components/Partners/Partners.styles.scss b/src/pages/Main/components/Partners/Partners.styles.scss index cfcddc9..f92e913 100644 --- a/src/pages/Main/components/Partners/Partners.styles.scss +++ b/src/pages/Main/components/Partners/Partners.styles.scss @@ -1,4 +1,4 @@ -#page .content #partners { +#react-page .content #partners { margin-left: 0; margin-right: 0; diff --git a/src/pages/Root/Root.jsx b/src/pages/Root/Root.jsx index 3326a99..180aa27 100755 --- a/src/pages/Root/Root.jsx +++ b/src/pages/Root/Root.jsx @@ -27,7 +27,7 @@ function Root() { return ( -
+