fix created at
This commit is contained in:
parent
a652b78230
commit
6068c717d3
6 changed files with 34 additions and 73 deletions
|
|
@ -1,38 +1,10 @@
|
|||
import SurveyInfo from "../SurveyInfo/SurveyInfo.tsx";
|
||||
import styles from './Results.module.css'
|
||||
import {useEffect, useState} from "react";
|
||||
import {useParams} from "react-router-dom";
|
||||
import {getSurveyById} from "../../api/SurveyApi.ts";
|
||||
import {useState} from "react";
|
||||
|
||||
export const Results = () => {
|
||||
const [descriptionSurvey, setDescriptionSurvey] = 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]);
|
||||
const [titleSurvey, setTitleSurvey] = useState('Название опроса');
|
||||
|
||||
return(
|
||||
<div className={styles.results}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue