From 4f1a7cc434379d0306fb471ae3c44a561846802f Mon Sep 17 00:00:00 2001 From: Tatiana Nikolaeva Date: Mon, 26 May 2025 03:06:47 +0500 Subject: [PATCH] add page completing survey --- SurveyFrontend/src/App.tsx | 6 + .../components/AnswerOption/AnswerOption.tsx | 75 +++++++++--- .../CompletingSurvey.module.css | 7 ++ .../CompletingSurvey/CompletingSurvey.tsx | 32 +++++ .../src/components/Header/Header.module.css | 3 +- .../src/components/Header/Header.tsx | 31 +++-- .../MySurveyList/MySurveysList.module.css | 4 +- .../components/QuestionItem/QuestionItem.tsx | 115 +++++++++++------- .../QuestionsList/QuestionsList.module.css | 14 +++ .../QuestionsList/QuestionsList.tsx | 10 +- .../SurveyInfo/SurveyInfo.module.css | 40 ++++-- .../src/components/SurveyInfo/SurveyInfo.tsx | 87 +++++++++---- .../CompleteSurvey/CompleteSurvey.module.css | 3 + .../pages/CompleteSurvey/CompleteSurvey.tsx | 14 +++ .../MySurveysPage/MySurveysPage.module.css | 12 -- 15 files changed, 333 insertions(+), 120 deletions(-) create mode 100644 SurveyFrontend/src/components/CompletingSurvey/CompletingSurvey.module.css create mode 100644 SurveyFrontend/src/components/CompletingSurvey/CompletingSurvey.tsx create mode 100644 SurveyFrontend/src/pages/CompleteSurvey/CompleteSurvey.module.css create mode 100644 SurveyFrontend/src/pages/CompleteSurvey/CompleteSurvey.tsx diff --git a/SurveyFrontend/src/App.tsx b/SurveyFrontend/src/App.tsx index 8838013..3f02788 100644 --- a/SurveyFrontend/src/App.tsx +++ b/SurveyFrontend/src/App.tsx @@ -8,6 +8,8 @@ import {Results} from "./components/Results/Results.tsx"; import {MySurveyList} from "./components/MySurveyList/MySurveyList.tsx"; import AuthForm from "./pages/AuthForm/AuthForm.tsx"; import {SurveyPage} from "./components/SurveyPage/SurveyPage.tsx"; +import CompleteSurvey from "./pages/CompleteSurvey/CompleteSurvey.tsx"; +import CompletingSurvey from "./components/CompletingSurvey/CompletingSurvey.tsx"; const App = () => { return( @@ -31,6 +33,10 @@ const App = () => { } /> + }> + }/> + + } /> diff --git a/SurveyFrontend/src/components/AnswerOption/AnswerOption.tsx b/SurveyFrontend/src/components/AnswerOption/AnswerOption.tsx index b042df9..1bf5bb5 100644 --- a/SurveyFrontend/src/components/AnswerOption/AnswerOption.tsx +++ b/SurveyFrontend/src/components/AnswerOption/AnswerOption.tsx @@ -3,17 +3,22 @@ import styles from'./AnswerOption.module.css'; import Delete from '../../assets/delete.svg?react'; import Single from '../../assets/radio_button_unchecked.svg?react'; import Multiple from '../../assets/emptyCheckbox.svg?react'; +import SelectedSingle from '../../assets/radio_button_checked.svg?react' +import SelectedMultiple from '../../assets/check_box.svg?react'; +import TextareaAutosize from 'react-textarea-autosize'; interface AnswerOptionProps{ index: number; value: string; - onChange: (value: string) => void; - onDelete:(index: number) => void; + onChange?: (value: string) => void; + onDelete?:(index: number) => void; selectedType: 'SingleAnswerQuestion' | 'MultipleAnswerQuestion'; - toggleSelect: () => void; + isSelected?: boolean; + toggleSelect?: () => void; + isCompleteSurveyActive?: boolean; } -const AnswerOption: React.FC = ({index, value, onChange, onDelete, selectedType, toggleSelect}) => { +const AnswerOption: React.FC = ({index, value, onChange, onDelete, selectedType, isSelected, toggleSelect, isCompleteSurveyActive = false}) => { const [currentValue, setCurrentValue] = useState(value); const [isEditing, setIsEditing] = useState(false); @@ -45,7 +50,7 @@ const AnswerOption: React.FC = ({index, value, onChange, onDe const handleSave = () => { setIsEditing(false); - onChange(currentValue); + onChange?.(currentValue); }; const handleKeyDown = (event: React.KeyboardEvent) => { @@ -65,16 +70,50 @@ const AnswerOption: React.FC = ({index, value, onChange, onDe } }, [isEditing]); + const handleMarkerClick = () => { + if (isCompleteSurveyActive && toggleSelect) { + toggleSelect(); + } + }; + + return (
- - {isEditing ? ( -