fix created at

This commit is contained in:
Tatiana Nikolaeva 2025-05-26 04:40:36 +05:00
parent 8c67784d62
commit a652b78230
4 changed files with 68 additions and 36 deletions

View file

@ -1,10 +1,38 @@
import SurveyInfo from "../SurveyInfo/SurveyInfo.tsx"; import SurveyInfo from "../SurveyInfo/SurveyInfo.tsx";
import styles from './Results.module.css' 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 = () => { export const Results = () => {
const [descriptionSurvey, setDescriptionSurvey] = useState(''); 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( return(
<div className={styles.results}> <div className={styles.results}>

View file

@ -2,6 +2,7 @@
.settingSurvey{ .settingSurvey{
width: 85%; width: 85%;
height: 100vh;
} }
.startEndTime{ .startEndTime{
@ -16,6 +17,7 @@
padding-top: 15px; padding-top: 15px;
padding-bottom: 97px; padding-bottom: 97px;
padding-left: 19px; padding-left: 19px;
margin-bottom: 30px;
} }
.param h2{ .param h2{

View file

@ -1,42 +1,41 @@
import React, {useState} from 'react'; import React, {useEffect, useState} from 'react';
import SurveyInfo from "../SurveyInfo/SurveyInfo.tsx"; import SurveyInfo from "../SurveyInfo/SurveyInfo.tsx";
import styles from "./SettingSurvey.module.css"; import styles from "./SettingSurvey.module.css";
import TimeEvent from "../TimeEvent/TimeEvent.tsx"; import TimeEvent from "../TimeEvent/TimeEvent.tsx";
// import {useParams} from "react-router-dom"; import SaveButton from "../SaveButton/SaveButton.tsx";
// import {getSurveyById, ISurvey} from "../../api/SurveyApi.ts"; import {useParams} from "react-router-dom";
import {getSurveyById} from "../../api/SurveyApi.ts";
const SettingSurvey: React.FC = () => { const SettingSurvey: React.FC = () => {
const [descriptionSurvey, setDescriptionSurvey] = useState(''); const [descriptionSurvey, setDescriptionSurvey] = useState('');
// const [survey, setSurvey] = useState<ISurvey | null>(null);
const [titleSurvey, setTitleSurvey] = useState(''); const [titleSurvey, setTitleSurvey] = useState('');
// const { surveyId } = useParams<{ surveyId: string }>(); const { surveyId } = useParams<{ surveyId: string }>();
// useEffect(() => { useEffect(() => {
// if (!surveyId) { if (!surveyId) {
// console.error('Survey ID is missing'); console.error('Survey ID is missing');
// return; return;
// } }
// const id = parseInt(surveyId); const id = parseInt(surveyId);
// if (isNaN(id)) { if (isNaN(id)) {
// console.error('Invalid survey ID'); console.error('Invalid survey ID');
// return; return;
// } }
//
// const fetchData = async () => { const fetchData = async () => {
// try { try {
// const surveyData = await getSurveyById(id); const surveyData = await getSurveyById(id);
// setSurvey(surveyData); setTitleSurvey(surveyData.title);
// setTitleSurvey(surveyData.title); setDescriptionSurvey(surveyData.description);
// setDescriptionSurvey(surveyData.description); } catch (error) {
// } catch (error) { console.error('Ошибка:', error);
// console.error('Ошибка:', error); }
// } };
// };
// fetchData();
// fetchData();
// }, [surveyId]);
// }, [surveyId]);
return ( return (
<div className={styles.settingSurvey}> <div className={styles.settingSurvey}>
@ -53,6 +52,7 @@ const SettingSurvey: React.FC = () => {
<div className={styles.param}> <div className={styles.param}>
<h2>Параметры видимости</h2> <h2>Параметры видимости</h2>
</div> </div>
<SaveButton onClick={() => {}}/>
</div> </div>
) )
} }

View file

@ -71,6 +71,7 @@ const SurveyInfo: React.FC<SurveyInfoProps> = ({titleSurvey, setDescriptionSurve
setShowDescriptionField(true); setShowDescriptionField(true);
} }
const handleTitleBlur = () => { const handleTitleBlur = () => {
setShowNewTitleField(false); setShowNewTitleField(false);
}; };
@ -87,7 +88,7 @@ const SurveyInfo: React.FC<SurveyInfoProps> = ({titleSurvey, setDescriptionSurve
} }
const renderTitle = () => { const renderTitle = () => {
if (isSurveyViewPage || isCompleteSurveyActive) { if ( isCompleteSurveyActive) {
return ( return (
<button className={styles.titleSurvey}> <button className={styles.titleSurvey}>
<h1>{titleSurvey || 'Название опроса'}</h1> <h1>{titleSurvey || 'Название опроса'}</h1>
@ -119,7 +120,7 @@ const SurveyInfo: React.FC<SurveyInfoProps> = ({titleSurvey, setDescriptionSurve
}; };
const renderDescription = () => { const renderDescription = () => {
if (isSurveyViewPage || isCompleteSurveyActive) { if (isCompleteSurveyActive) {
return descriptionSurvey ? ( return descriptionSurvey ? (
<p className={styles.desc}>{descriptionSurvey}</p> <p className={styles.desc}>{descriptionSurvey}</p>
) : 'Описание'; ) : 'Описание';
@ -146,7 +147,8 @@ const SurveyInfo: React.FC<SurveyInfoProps> = ({titleSurvey, setDescriptionSurve
/> />
</div> </div>
); );
} else { }
else {
return ( return (
<button <button
className={styles.descripButton} className={styles.descripButton}
@ -174,4 +176,4 @@ const SurveyInfo: React.FC<SurveyInfoProps> = ({titleSurvey, setDescriptionSurve
}; };
export default SurveyInfo; export default SurveyInfo;