fix created at
This commit is contained in:
parent
8c67784d62
commit
a652b78230
4 changed files with 68 additions and 36 deletions
|
|
@ -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(
|
||||
<div className={styles.results}>
|
||||
|
|
|
|||
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -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<ISurvey | null>(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 (
|
||||
<div className={styles.settingSurvey}>
|
||||
|
|
@ -53,6 +52,7 @@ const SettingSurvey: React.FC = () => {
|
|||
<div className={styles.param}>
|
||||
<h2>Параметры видимости</h2>
|
||||
</div>
|
||||
<SaveButton onClick={() => {}}/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ const SurveyInfo: React.FC<SurveyInfoProps> = ({titleSurvey, setDescriptionSurve
|
|||
setShowDescriptionField(true);
|
||||
}
|
||||
|
||||
|
||||
const handleTitleBlur = () => {
|
||||
setShowNewTitleField(false);
|
||||
};
|
||||
|
|
@ -87,7 +88,7 @@ const SurveyInfo: React.FC<SurveyInfoProps> = ({titleSurvey, setDescriptionSurve
|
|||
}
|
||||
|
||||
const renderTitle = () => {
|
||||
if (isSurveyViewPage || isCompleteSurveyActive) {
|
||||
if ( isCompleteSurveyActive) {
|
||||
return (
|
||||
<button className={styles.titleSurvey}>
|
||||
<h1>{titleSurvey || 'Название опроса'}</h1>
|
||||
|
|
@ -119,7 +120,7 @@ const SurveyInfo: React.FC<SurveyInfoProps> = ({titleSurvey, setDescriptionSurve
|
|||
};
|
||||
|
||||
const renderDescription = () => {
|
||||
if (isSurveyViewPage || isCompleteSurveyActive) {
|
||||
if (isCompleteSurveyActive) {
|
||||
return descriptionSurvey ? (
|
||||
<p className={styles.desc}>{descriptionSurvey}</p>
|
||||
) : 'Описание';
|
||||
|
|
@ -146,7 +147,8 @@ const SurveyInfo: React.FC<SurveyInfoProps> = ({titleSurvey, setDescriptionSurve
|
|||
/>
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return (
|
||||
<button
|
||||
className={styles.descripButton}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue