From fa5fe30c34753b61cfdad3621a85bee1c8e7af78 Mon Sep 17 00:00:00 2001 From: Tatiana Nikolaeva Date: Wed, 14 May 2025 17:59:36 +0500 Subject: [PATCH] correction of working capacity --- SurveyFrontend/src/api/AuthApi.ts | 12 ++++ .../AnswerOption/AnswerOption.module.css | 49 +++++++++---- .../components/AnswerOption/AnswerOption.tsx | 35 +++++++--- .../src/components/Header/Header.tsx | 14 ++-- SurveyFrontend/src/components/Logo/Logo.tsx | 5 +- .../QuestionItem/QuestionItem.module.css | 3 + .../components/QuestionItem/QuestionItem.tsx | 8 +++ .../components/RegisterForm/RegisterForm.tsx | 6 +- .../SettingSurvey/SettingSurvey.module.css | 1 + .../SurveyInfo/SurveyInfo.module.css | 60 +++++++++------- .../src/components/SurveyInfo/SurveyInfo.tsx | 69 ++++++++++++------- 11 files changed, 180 insertions(+), 82 deletions(-) diff --git a/SurveyFrontend/src/api/AuthApi.ts b/SurveyFrontend/src/api/AuthApi.ts index 207da21..2855bad 100644 --- a/SurveyFrontend/src/api/AuthApi.ts +++ b/SurveyFrontend/src/api/AuthApi.ts @@ -20,6 +20,10 @@ export const registerUser = async (data: IRegistrationData) => { if (responseData.accessToken) { localStorage.setItem("token", responseData.accessToken); + localStorage.setItem("user", JSON.stringify({ + firstName: data.firstName, + lastName: data.lastName + })); } return responseData; @@ -41,6 +45,14 @@ export const authUser = async (data: IAuthData) => { const token = responseData.accessToken || responseData.token; if (token) { localStorage.setItem("token", token); + const user = localStorage.getItem("user"); + if (!responseData.user && user) { + responseData.user = JSON.parse(user); + } + + if (responseData.user) { + localStorage.setItem("user", JSON.stringify(responseData.user)); + } } return responseData; diff --git a/SurveyFrontend/src/components/AnswerOption/AnswerOption.module.css b/SurveyFrontend/src/components/AnswerOption/AnswerOption.module.css index 6a0ec90..9f0ce82 100644 --- a/SurveyFrontend/src/components/AnswerOption/AnswerOption.module.css +++ b/SurveyFrontend/src/components/AnswerOption/AnswerOption.module.css @@ -1,46 +1,67 @@ -/*AnswerOption.module.css*/ +/*!*AnswerOption.module.css*!*/ -.answer{ +.answer { width: 100%; display: flex; gap: 10px; margin-bottom: 17px; + align-items: flex-start; } -.textAnswer{ +.textAnswer { text-align: left; border: none; - background-color: #ffffff; + background: none; font-size: 18px; font-weight: 500; word-break: break-word; width: 70%; + padding: 0; + line-height: 24px; + cursor: text; + margin-top: 2px; } -.buttonMarker{ +.buttonMarker { padding: 0; border: none; - background-color: transparent; + background: none; + position: relative; + top: 0; + transition: top 0.1s ease; + cursor: pointer; + height: 24px; } -.answerIcon{ - vertical-align: middle; +.buttonMarker.editing { + top: 3px; +} + +.answerIcon { width: 24px; + height: 24px; + display: block; } -.answerInput{ - vertical-align: middle; +.answerInput { font-size: 18px; font-weight: 500; outline: none; border: none; resize: none; - display: flex; - align-items: center; - box-sizing: border-box; + width: 70%; + padding: 0; + margin-top: 2px; + font-family: inherit; + min-height: 24px; + height: auto; + overflow-y: hidden; + line-height: 1.5; + white-space: pre-wrap; + word-wrap: break-word; } -.deleteButton{ +.deleteButton { margin-left: auto; border: none; background-color: transparent; diff --git a/SurveyFrontend/src/components/AnswerOption/AnswerOption.tsx b/SurveyFrontend/src/components/AnswerOption/AnswerOption.tsx index e0c78b1..c08c213 100644 --- a/SurveyFrontend/src/components/AnswerOption/AnswerOption.tsx +++ b/SurveyFrontend/src/components/AnswerOption/AnswerOption.tsx @@ -32,8 +32,22 @@ const AnswerOption: React.FC = ({index, value, onChange, onDe const handleTextareaChange = (event: React.ChangeEvent) => { setCurrentValue(event.target.value); + // Автоматическое изменение высоты + if (textAreaRef.current) { + textAreaRef.current.style.height = 'auto'; + textAreaRef.current.style.height = `${textAreaRef.current.scrollHeight}px`; + } }; + useEffect(() => { + if (isEditing && textAreaRef.current) { + textAreaRef.current.focus(); + // Установка начальной высоты + textAreaRef.current.style.height = 'auto'; + textAreaRef.current.style.height = `${textAreaRef.current.scrollHeight}px`; + } + }, [isEditing]); + const handleSave = () => { setIsEditing(false); onChange(currentValue); @@ -66,7 +80,10 @@ const AnswerOption: React.FC = ({index, value, onChange, onDe return (
- {isEditing ? ( -