- {isCompleteSurveyActive ? (
+ {isReadOnly ? (
{textQuestion || initialTextQuestion}
@@ -194,7 +192,6 @@ const QuestionItem: React.FC = ({
value={answer.text}
isSelected={selectedAnswers.includes(index)}
toggleSelect={() => toggleSelect(index)}
- isCompleteSurveyActive={isCompleteSurveyActive}
/>
))}
diff --git a/SurveyFrontend/src/components/QuestionsList/QuestionsList.tsx b/SurveyFrontend/src/components/QuestionsList/QuestionsList.tsx
index fa40be2..24c6dc4 100644
--- a/SurveyFrontend/src/components/QuestionsList/QuestionsList.tsx
+++ b/SurveyFrontend/src/components/QuestionsList/QuestionsList.tsx
@@ -3,8 +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/AnswerVariantsApi.ts";
-import {useLocation} from "react-router-dom";
import styles from './QuestionsList.module.css'
+import {useRouteReadOnly} from "../../hooks/useRouteReadOnly.ts";
interface QuestionsListProps {
questions: Question[];
@@ -23,8 +23,7 @@ export interface Question {
}
const QuestionsList: React.FC
= ({questions, setQuestions, surveyId}) => {
- const location = useLocation();
- const isCompleteSurveyActive = location.pathname === '/complete-survey';
+ const isReadOnly = useRouteReadOnly();
const handleAddQuestion = async () => {
if (!surveyId) {
@@ -128,7 +127,7 @@ const QuestionsList: React.FC = ({questions, setQuestions, s
surveyId={surveyId}
/>
))}
- {!isCompleteSurveyActive ? : (
+ {!isReadOnly ? : (
)}
diff --git a/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.module.css b/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.module.css
index 444399f..59134d9 100644
--- a/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.module.css
+++ b/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.module.css
@@ -24,4 +24,19 @@
font-size: 24px;
font-weight: 600;
border-radius: 4px;
+}
+
+.copyButton {
+ padding: 10px 15px;
+ background-color: #4CAF50;
+ color: white;
+ border: none;
+ border-radius: 4px;
+ cursor: pointer;
+ font-size: 16px;
+ margin-bottom: 20px;
+}
+
+.copyButton:hover {
+ background-color: #45a049;
}
\ No newline at end of file
diff --git a/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.tsx b/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.tsx
index a2a6568..f64f8ec 100644
--- a/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.tsx
+++ b/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.tsx
@@ -18,6 +18,15 @@ const SettingSurvey: React.FC = () => {
const [descriptionSurvey, setDescriptionSurvey] = useState('');
const [titleSurvey, setTitleSurvey] = useState('');
+ const handleCopyLink = () => {
+ if (!survey?.id)
+ return;
+ const link = `${window.location.origin}/complete-survey/${survey.id}`;
+ navigator.clipboard.writeText(link)
+ .then(() => console.log('Copied!'))
+ .catch(error => console.error(`Не удалось скопировать ссылку: ${error}`));
+ }
+
return (
{isSettingCreatePage ? (
@@ -43,6 +52,7 @@ const SettingSurvey: React.FC = () => {
Параметры видимости
{}}/>
+
)
}
diff --git a/SurveyFrontend/src/components/SurveyInfo/SurveyInfo.tsx b/SurveyFrontend/src/components/SurveyInfo/SurveyInfo.tsx
index 3ce15ff..41e015a 100644
--- a/SurveyFrontend/src/components/SurveyInfo/SurveyInfo.tsx
+++ b/SurveyFrontend/src/components/SurveyInfo/SurveyInfo.tsx
@@ -3,6 +3,7 @@ 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";
+import {useRouteReadOnly} from "../../hooks/useRouteReadOnly.ts";
interface SurveyInfoProps {
@@ -20,10 +21,11 @@ const SurveyInfo: React.FC
= ({titleSurvey, setDescriptionSurve
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 isReadOnly = useRouteReadOnly();
+
const handleDescriptionChange = (descripEvent: React.ChangeEvent) => {
setDescriptionSurvey?.(descripEvent.target.value);
};
@@ -88,7 +90,7 @@ const SurveyInfo: React.FC = ({titleSurvey, setDescriptionSurve
}
const renderTitle = () => {
- if (isCompleteSurveyActive) {
+ if (isReadOnly) {
return (
diff --git a/SurveyFrontend/src/components/SurveyPage/SurveyPage.tsx b/SurveyFrontend/src/components/SurveyPage/SurveyPage.tsx
index 8f70177..6b5dfbc 100644
--- a/SurveyFrontend/src/components/SurveyPage/SurveyPage.tsx
+++ b/SurveyFrontend/src/components/SurveyPage/SurveyPage.tsx
@@ -153,11 +153,9 @@ class ActionQueue {
}
export const SurveyPage: React.FC = () => {
- // const [survey, setSurvey] = useState