diff --git a/SurveyFrontend/src/components/MySurveyList/MySurveysList.module.css b/SurveyFrontend/src/components/MySurveyList/MySurveysList.module.css
index ec43e84..1ca9d3c 100644
--- a/SurveyFrontend/src/components/MySurveyList/MySurveysList.module.css
+++ b/SurveyFrontend/src/components/MySurveyList/MySurveysList.module.css
@@ -1,9 +1,9 @@
.main {
background-color: #F6F6F6;
- width: 100%;
max-width: 100vw;
min-height: 100vh;
- padding: 34px 10%;
+ padding-top: 34px;
+ padding-left: 12%;
}
.survey {
diff --git a/SurveyFrontend/src/components/QuestionItem/QuestionItem.tsx b/SurveyFrontend/src/components/QuestionItem/QuestionItem.tsx
index 098d1e5..18627bf 100644
--- a/SurveyFrontend/src/components/QuestionItem/QuestionItem.tsx
+++ b/SurveyFrontend/src/components/QuestionItem/QuestionItem.tsx
@@ -10,6 +10,8 @@ import {
getAnswerVariants,
updateAnswerVariant
} from "../../api/AnswerApi.ts";
+import {useLocation} from "react-router-dom";
+import TextareaAutosize from "react-textarea-autosize";
interface QuestionItemProps {
questionId: number;
@@ -43,6 +45,10 @@ const QuestionItem: React.FC
= ({
const [questionType, setQuestionType] = useState<'SingleAnswerQuestion' | 'MultipleAnswerQuestion'>(initialQuestionType);
const textareaQuestionRef = useRef(null);
+ const location = useLocation();
+ const isCompleteSurveyActive = location.pathname === '/complete-survey';
+
+
useEffect(() => {
setTextQuestion(valueQuestion);
}, [valueQuestion]);
@@ -162,62 +168,81 @@ const QuestionItem: React.FC = ({
};
const toggleSelect = (index: number) => {
- if (questionType === 'SingleAnswerQuestion') {
+ if (initialQuestionType === 'SingleAnswerQuestion') {
+ // Для одиночного выбора: заменяем массив одним выбранным индексом
setSelectedAnswers([index]);
} else {
- setSelectedAnswers((prev) => {
- if (prev.includes(index)) {
- return prev.filter((i) => i !== index);
- } else {
- return [...prev, index];
- }
- });
+ // Для множественного выбора: добавляем/удаляем индекс
+ setSelectedAnswers(prev =>
+ prev.includes(index)
+ ? prev.filter(i => i !== index)
+ : [...prev, index]
+ );
}
};
return (
-
-
- {isEditingQuestion ? (
-
+ ) : (
+
+
+ {isEditingQuestion ? (
+
+ ) : (
+
+ )}
+
+
- {initialAnswerVariants.map((answer, index) => (
-
handleAnswerChange(index, value)}
- onDelete={() => handleDeleteAnswer(index)}
- toggleSelect={() => toggleSelect(index)}
- />
- ))}
+ {initialAnswerVariants.map((answer, index) => (
+ handleAnswerChange(index, value)}
+ onDelete={() => handleDeleteAnswer(index)}
+ toggleSelect={() => toggleSelect(index)}
+ />
+ ))}
-
-
+
+
)
+ }
);
};
diff --git a/SurveyFrontend/src/components/QuestionsList/QuestionsList.module.css b/SurveyFrontend/src/components/QuestionsList/QuestionsList.module.css
index c150798..c75e0d5 100644
--- a/SurveyFrontend/src/components/QuestionsList/QuestionsList.module.css
+++ b/SurveyFrontend/src/components/QuestionsList/QuestionsList.module.css
@@ -1,2 +1,16 @@
/*QuestionsList.module.css*/
+.departur_button{
+ display: block;
+ margin: 10px auto;
+ padding: 25px 50.5px;
+ border: none;
+ border-radius: 20px;
+ background-color: #3788D6;
+ color: white;
+ font-weight: 700;
+ font-size: 24px;
+ text-align: center;
+ box-shadow: 0 0 7.4px 0 rgba(154, 202, 247, 1);
+ box-sizing: border-box;
+}
\ No newline at end of file
diff --git a/SurveyFrontend/src/components/QuestionsList/QuestionsList.tsx b/SurveyFrontend/src/components/QuestionsList/QuestionsList.tsx
index 1043330..d755eb7 100644
--- a/SurveyFrontend/src/components/QuestionsList/QuestionsList.tsx
+++ b/SurveyFrontend/src/components/QuestionsList/QuestionsList.tsx
@@ -3,6 +3,8 @@ import QuestionItem from "../QuestionItem/QuestionItem.tsx";
import AddQuestionButton from "../AddQuestionButton/AddQuestionButton.tsx";
import {addNewQuestion, deleteQuestion, getListQuestions} from "../../api/QuestionApi.ts";
import {addNewAnswerVariant} from "../../api/AnswerApi.ts";
+import {useLocation} from "react-router-dom";
+import styles from './QuestionsList.module.css'
interface QuestionsListProps {
questions: Question[];
@@ -21,6 +23,9 @@ export interface Question {
}
const QuestionsList: React.FC = ({questions, setQuestions, surveyId}) => {
+ const location = useLocation();
+ const isCompleteSurveyActive = location.pathname === '/complete-survey';
+
const handleAddQuestion = async () => {
if (!surveyId) {
const newQuestion: Question = {
@@ -123,7 +128,10 @@ const QuestionsList: React.FC = ({questions, setQuestions, s
surveyId={surveyId}
/>
))}
-
+ {!isCompleteSurveyActive ? : (
+
+ )}
+
>
);
};
diff --git a/SurveyFrontend/src/components/SurveyInfo/SurveyInfo.module.css b/SurveyFrontend/src/components/SurveyInfo/SurveyInfo.module.css
index e4dbd0f..3ba7298 100644
--- a/SurveyFrontend/src/components/SurveyInfo/SurveyInfo.module.css
+++ b/SurveyFrontend/src/components/SurveyInfo/SurveyInfo.module.css
@@ -7,37 +7,45 @@
margin-top: 34px;
margin-bottom: 49px;
border-radius: 14px;
- min-height: 191px;
+ /*min-height: 191px;*/
+ /*max-height: 100vh;*/
+ max-height: fit-content;
}
.info{
min-width: 373px;
- display: block;
+ /*display: block;*/
padding: 35px;
+ display: flex; /* Добавляем flex */
+ flex-direction: column; /* Элементы в колонку */
+ align-items: center;
}
.titleSurvey{
+ width: 80%;
display: block;
border: none;
- margin: 0 auto;
+ margin: 0 auto 13px;
background-color: white;
text-align: center;
font-size: 20px;
font-weight: 600;
- margin-bottom: 23px;
+ /*margin-bottom: 23px;*/
+ /*margin-bottom: 15px;*/
word-break: break-word;
padding: 0;
}
.textareaTitle,
.textareaDescrip {
- width: 100%;
+ width: 80%;
+ max-width: 100%;
resize: none;
border: none;
outline: none;
font-family: inherit;
padding: 0;
- margin: 0;
+ margin: 0 auto;
background: transparent;
display: block;
overflow-y: hidden;
@@ -48,7 +56,7 @@
font-weight: 600;
text-align: center;
line-height: 1.2;
- min-height: 40px;
+ min-height: 60px;
}
.textareaDescrip {
@@ -67,7 +75,7 @@
.description {
border: none;
- font-size: 18px;
+ font-size: 24px;
font-weight: 500;
text-align: center;
background-color: white;
@@ -78,6 +86,15 @@
word-break: break-word;
}
+.desc{
+ font-size: 24px;
+ font-weight: 500;
+ background-color: white;
+ max-width: 80%;
+ word-break: break-word;
+ margin: 0;
+ text-align: center;
+}
.descripButton{
border: none;
@@ -97,4 +114,11 @@
font-weight: 500;
color: #7D7983;
padding: 10px;
+}
+
+.createdAt{
+ text-align: center;
+ font-size: 18px;
+ font-weight: 500;
+ color: #7D7983;
}
\ No newline at end of file
diff --git a/SurveyFrontend/src/components/SurveyInfo/SurveyInfo.tsx b/SurveyFrontend/src/components/SurveyInfo/SurveyInfo.tsx
index 36e955c..fb1906d 100644
--- a/SurveyFrontend/src/components/SurveyInfo/SurveyInfo.tsx
+++ b/SurveyFrontend/src/components/SurveyInfo/SurveyInfo.tsx
@@ -2,27 +2,34 @@ import React, {useState, useRef, useEffect} from "react";
import styles from './SurveyInfo.module.css'
import AddDescripImg from '../../assets/add_circle.svg?react';
import TextareaAutosize from 'react-textarea-autosize';
+import {useLocation} from "react-router-dom";
interface SurveyInfoProps {
titleSurvey: string;
descriptionSurvey: string;
- setDescriptionSurvey: (text: string) => void;
- setTitleSurvey: (text: string) => void;
+ setDescriptionSurvey?: (text: string) => void;
+ setTitleSurvey?: (text: string) => void;
+ createdAt?: Date;
}
-const SurveyInfo: React.FC = ({titleSurvey, setDescriptionSurvey, descriptionSurvey, setTitleSurvey}) => {
+const SurveyInfo: React.FC = ({titleSurvey, setDescriptionSurvey, descriptionSurvey, setTitleSurvey, createdAt = new Date()}) => {
const [showDescriptionField, setShowDescriptionField] = useState(false);
const [showNewTitleField, setShowNewTitleField] = useState(false);
const titleTextareaRef = useRef(null);
const descriptionTextareaRef = useRef(null);
+ const location = useLocation();
+ const isCompleteSurveyActive = location.pathname === '/complete-survey';
+ const isSurveyViewPage = location.pathname.startsWith('/survey/') &&
+ !location.pathname.startsWith('/survey/create');
+
const handleDescriptionChange = (descripEvent: React.ChangeEvent) => {
- setDescriptionSurvey(descripEvent.target.value);
+ setDescriptionSurvey?.(descripEvent.target.value);
};
const handleNewTitleChange = (titleEvent: React.ChangeEvent) => {
- setTitleSurvey(titleEvent.target.value);
+ setTitleSurvey?.(titleEvent.target.value);
};
useEffect(() => {
@@ -72,8 +79,52 @@ const SurveyInfo: React.FC = ({titleSurvey, setDescriptionSurve
setShowDescriptionField(false);
};
+ const addDate = () => {
+ const year = createdAt.getFullYear();
+ const month = String(createdAt.getMonth() + 1).padStart(2, '0');
+ const day = String(createdAt.getDate()).padStart(2, '0');
+ return `${day}/${month}/${year}`;
+ }
+
+ const renderTitle = () => {
+ if (isSurveyViewPage || isCompleteSurveyActive) {
+ return (
+
+ )
+ }
+
+ if (showNewTitleField) {
+ return (
+
+
+
+ );
+ }
+
+ return (
+
+ );
+ };
const renderDescription = () => {
+ if (isSurveyViewPage || isCompleteSurveyActive) {
+ return descriptionSurvey ? (
+ {descriptionSurvey}
+ ) : 'Описание';
+ }
+
if (descriptionSurvey && !showDescriptionField) {
return (
);
}
- }
+ };
return (
- {
- showNewTitleField ? (
-
-
-
- ) : (
-
- )
- }
-
+ {renderTitle()}
{renderDescription()}
+ {(isSurveyViewPage || isCompleteSurveyActive) && createdAt && (
+
Дата создания: {addDate()}
+ )}
);
+
};
export default SurveyInfo;
\ No newline at end of file
diff --git a/SurveyFrontend/src/pages/CompleteSurvey/CompleteSurvey.module.css b/SurveyFrontend/src/pages/CompleteSurvey/CompleteSurvey.module.css
new file mode 100644
index 0000000..79251c9
--- /dev/null
+++ b/SurveyFrontend/src/pages/CompleteSurvey/CompleteSurvey.module.css
@@ -0,0 +1,3 @@
+.layout{
+ width: 100%;
+}
\ No newline at end of file
diff --git a/SurveyFrontend/src/pages/CompleteSurvey/CompleteSurvey.tsx b/SurveyFrontend/src/pages/CompleteSurvey/CompleteSurvey.tsx
new file mode 100644
index 0000000..32d9cd8
--- /dev/null
+++ b/SurveyFrontend/src/pages/CompleteSurvey/CompleteSurvey.tsx
@@ -0,0 +1,14 @@
+import Header from "../../components/Header/Header.tsx";
+import styles from './CompleteSurvey.module.css'
+import CompletingSurvey from "../../components/CompletingSurvey/CompletingSurvey.tsx";
+
+export const CompleteSurvey = () => {
+ return(
+
+
+
+
+ )
+}
+
+export default CompleteSurvey
\ No newline at end of file
diff --git a/SurveyFrontend/src/pages/MySurveysPage/MySurveysPage.module.css b/SurveyFrontend/src/pages/MySurveysPage/MySurveysPage.module.css
index 1e2ee9a..e0ae7d1 100644
--- a/SurveyFrontend/src/pages/MySurveysPage/MySurveysPage.module.css
+++ b/SurveyFrontend/src/pages/MySurveysPage/MySurveysPage.module.css
@@ -2,16 +2,4 @@
.layout{
width: 100%;
-}
-
-.main{
- width: 100%;
- min-height: 85vh;
- display: flex;
- background-color: #F6F6F6;
-}
-
-.content{
- width: 100%;
- margin-left: 8.9%;
}
\ No newline at end of file