diff --git a/SurveyFrontend/src/components/Results/Results.tsx b/SurveyFrontend/src/components/Results/Results.tsx index d41409c..9566bad 100644 --- a/SurveyFrontend/src/components/Results/Results.tsx +++ b/SurveyFrontend/src/components/Results/Results.tsx @@ -1,10 +1,38 @@ import SurveyInfo from "../SurveyInfo/SurveyInfo.tsx"; import styles from './Results.module.css' -import {useState} from "react"; +import {useEffect, useState} from "react"; +import {useParams} from "react-router-dom"; +import {getSurveyById} from "../../api/SurveyApi.ts"; export const Results = () => { const [descriptionSurvey, setDescriptionSurvey] = useState(''); - const [titleSurvey, setTitleSurvey] = useState('Название опроса'); + const [titleSurvey, setTitleSurvey] = useState(''); + const { surveyId } = useParams<{ surveyId: string }>(); + + useEffect(() => { + if (!surveyId) { + console.error('Survey ID is missing'); + return; + } + const id = parseInt(surveyId); + if (isNaN(id)) { + console.error('Invalid survey ID'); + return; + } + + const fetchData = async () => { + try { + const surveyData = await getSurveyById(id); + setTitleSurvey(surveyData.title); + setDescriptionSurvey(surveyData.description); + } catch (error) { + console.error('Ошибка:', error); + } + }; + + fetchData(); + + }, [surveyId]); return(
diff --git a/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.module.css b/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.module.css index 44d135a..fd5b485 100644 --- a/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.module.css +++ b/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.module.css @@ -2,6 +2,7 @@ .settingSurvey{ width: 85%; + height: 100vh; } .startEndTime{ @@ -16,6 +17,7 @@ padding-top: 15px; padding-bottom: 97px; padding-left: 19px; + margin-bottom: 30px; } .param h2{ diff --git a/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.tsx b/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.tsx index 3a02b44..ec91bcb 100644 --- a/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.tsx +++ b/SurveyFrontend/src/components/SettingSurvey/SettingSurvey.tsx @@ -1,42 +1,41 @@ -import React, {useState} from 'react'; +import React, {useEffect, useState} from 'react'; import SurveyInfo from "../SurveyInfo/SurveyInfo.tsx"; import styles from "./SettingSurvey.module.css"; import TimeEvent from "../TimeEvent/TimeEvent.tsx"; -// import {useParams} from "react-router-dom"; -// import {getSurveyById, ISurvey} from "../../api/SurveyApi.ts"; +import SaveButton from "../SaveButton/SaveButton.tsx"; +import {useParams} from "react-router-dom"; +import {getSurveyById} from "../../api/SurveyApi.ts"; const SettingSurvey: React.FC = () => { const [descriptionSurvey, setDescriptionSurvey] = useState(''); - // const [survey, setSurvey] = useState(null); const [titleSurvey, setTitleSurvey] = useState(''); - // const { surveyId } = useParams<{ surveyId: string }>(); + const { surveyId } = useParams<{ surveyId: string }>(); - // useEffect(() => { - // if (!surveyId) { - // console.error('Survey ID is missing'); - // return; - // } - // const id = parseInt(surveyId); - // if (isNaN(id)) { - // console.error('Invalid survey ID'); - // return; - // } - // - // const fetchData = async () => { - // try { - // const surveyData = await getSurveyById(id); - // setSurvey(surveyData); - // setTitleSurvey(surveyData.title); - // setDescriptionSurvey(surveyData.description); - // } catch (error) { - // console.error('Ошибка:', error); - // } - // }; - // - // fetchData(); - // - // }, [surveyId]); + useEffect(() => { + if (!surveyId) { + console.error('Survey ID is missing'); + return; + } + const id = parseInt(surveyId); + if (isNaN(id)) { + console.error('Invalid survey ID'); + return; + } + + const fetchData = async () => { + try { + const surveyData = await getSurveyById(id); + setTitleSurvey(surveyData.title); + setDescriptionSurvey(surveyData.description); + } catch (error) { + console.error('Ошибка:', error); + } + }; + + fetchData(); + + }, [surveyId]); return (
@@ -53,6 +52,7 @@ const SettingSurvey: React.FC = () => {

Параметры видимости

+ {}}/>
) } diff --git a/SurveyFrontend/src/components/SurveyInfo/SurveyInfo.tsx b/SurveyFrontend/src/components/SurveyInfo/SurveyInfo.tsx index fb1906d..11bfeb9 100644 --- a/SurveyFrontend/src/components/SurveyInfo/SurveyInfo.tsx +++ b/SurveyFrontend/src/components/SurveyInfo/SurveyInfo.tsx @@ -71,6 +71,7 @@ const SurveyInfo: React.FC = ({titleSurvey, setDescriptionSurve setShowDescriptionField(true); } + const handleTitleBlur = () => { setShowNewTitleField(false); }; @@ -87,7 +88,7 @@ const SurveyInfo: React.FC = ({titleSurvey, setDescriptionSurve } const renderTitle = () => { - if (isSurveyViewPage || isCompleteSurveyActive) { + if ( isCompleteSurveyActive) { return (
); - } else { + } + else { return (