From 7e131bf638cbde06b03925100eda3b99be16c3cd Mon Sep 17 00:00:00 2001 From: Vyacheslav K Date: Wed, 30 Apr 2025 14:27:13 +0300 Subject: [PATCH] some fixes --- src/App.css | 14 +++++++ src/App.js | 79 ++++++++++++++++++++-------------------- src/misc/Message.js | 6 +-- src/misc/SendForm.js | 6 +++ src/misc/Spinner.js | 14 +++++++ src/misc/WaitResponse.js | 25 +++++++++++++ 6 files changed, 102 insertions(+), 42 deletions(-) create mode 100644 src/misc/SendForm.js create mode 100644 src/misc/Spinner.js create mode 100644 src/misc/WaitResponse.js diff --git a/src/App.css b/src/App.css index e564177..74a714d 100644 --- a/src/App.css +++ b/src/App.css @@ -26,3 +26,17 @@ display: none; } +@keyframes fadeIn { + from { opacity: 0; } + to { opacity: 1; } +} + +/* Стилизация общего вида select */ +select { + + -webkit-appearance: none; /* Для Chrome, Safari */ + -moz-appearance: none; /* Для Firefox */ + appearance: none; /* Для остальных браузеров */ + + position: relative; +} diff --git a/src/App.js b/src/App.js index 39d3fd0..e3dbf4b 100644 --- a/src/App.js +++ b/src/App.js @@ -3,19 +3,24 @@ import SendIcon from './img/paper-plane.png'; import { useState } from 'react'; import Message from './misc/Message'; +import SendForm from './misc/SendForm'; +import Spinner from './misc/Spinner'; +import WaitResponse from './misc/WaitResponse'; import './App.css'; function App() { const [Stage, setStage] = useState(0); const [Loading, setLoading] = useState(false); + const [GenerationProcess, setGenerationProcess] = useState(false); + const [LoadingText, setLoadingText] = useState(""); const [formData, setFormData] = useState({ name: '', work_place: '', - problem:'', - message:'' + problem: '', + message: '' }); const handleChange = (e) => { @@ -26,32 +31,47 @@ function App() { })); }; + const [messages, setMessages] = useState([]); + + const addMessage = (text, self = true) => { + const newMessage = { + id: Date.now(), // уникальный ключ для нового элемента + text: text, + self: self + }; + + setMessages(prev => [...prev, newMessage]); + }; + window.addMessage = addMessage; const handleSubmit = (e) => { e.preventDefault(); // Останавливаем стандартную отправку формы console.log('Отправленные данные:', formData); setLoading(true); - - setTimeout(()=>{ + + setTimeout(() => { setStage(1); setLoading(false); + addMessage(formData.message); + + setTimeout(() => { + addMessage("Ваш вопрос отправлен в службу поддержки. Уже подбираем варианты решения проблемы...", false); + setTimeout(() => { + setGenerationProcess(true); + }, 500); + }, 500); + + }, 500) - },300) - }; return (
-
+
- {Loading && -
-
- {LoadingText} -
- } + {Stage == 0 && -
+

Сообщить о проблеме

@@ -85,7 +105,7 @@ function App() { className="mt-10 block w-full rounded-xl border border-gray-300 bg-gray-50 p-2.5 text-sm text-gray-900 focus:border-orange-500 focus:ring-orange-500 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400 dark:focus:border-orange-500 dark:focus:ring-orange-500" value={formData.problem} onChange={handleChange} - > + > @@ -115,32 +135,13 @@ function App() { <>
- - - - - - - + {messages.map(message => ( + + ))} - -
-
-
-
-
-
- Генерация ответа... -
- +
@@ -153,7 +154,7 @@ function App() { required="" />
diff --git a/src/misc/Message.js b/src/misc/Message.js index 16dd5c6..753b025 100644 --- a/src/misc/Message.js +++ b/src/misc/Message.js @@ -7,7 +7,7 @@ function Message(args) { return ( <> {args?.self && -
+
@@ -16,9 +16,9 @@ function Message(args) {
} {!args?.self && -
+
- + {args?.text}
diff --git a/src/misc/SendForm.js b/src/misc/SendForm.js new file mode 100644 index 0000000..877ec5d --- /dev/null +++ b/src/misc/SendForm.js @@ -0,0 +1,6 @@ + +async function SendForm(formData) { + +} + +export default SendForm; diff --git a/src/misc/Spinner.js b/src/misc/Spinner.js new file mode 100644 index 0000000..dc11bde --- /dev/null +++ b/src/misc/Spinner.js @@ -0,0 +1,14 @@ + +function Spinner(args) { + return ( + <> +
+
+ {args?.text} +
+ + + ); +} + +export default Spinner; diff --git a/src/misc/WaitResponse.js b/src/misc/WaitResponse.js new file mode 100644 index 0000000..782007e --- /dev/null +++ b/src/misc/WaitResponse.js @@ -0,0 +1,25 @@ + +function WaitResponse(args) { + return ( + <> + +
+
+
+
+
+
+ Генерация ответа... +
+ + + ); +} + +export default WaitResponse;