fix created at
This commit is contained in:
parent
a652b78230
commit
6068c717d3
6 changed files with 34 additions and 73 deletions
|
|
@ -1,41 +1,43 @@
|
|||
import React, {useEffect, useState} from 'react';
|
||||
import React, {useState} from 'react';
|
||||
import SurveyInfo from "../SurveyInfo/SurveyInfo.tsx";
|
||||
import styles from "./SettingSurvey.module.css";
|
||||
import TimeEvent from "../TimeEvent/TimeEvent.tsx";
|
||||
import SaveButton from "../SaveButton/SaveButton.tsx";
|
||||
import {useParams} from "react-router-dom";
|
||||
import {getSurveyById} from "../../api/SurveyApi.ts";
|
||||
// import {useParams} from "react-router-dom";
|
||||
// import {getSurveyById, ISurvey} 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);
|
||||
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);
|
||||
// setSurvey(surveyData);
|
||||
// setTitleSurvey(surveyData.title);
|
||||
// setDescriptionSurvey(surveyData.description);
|
||||
// } catch (error) {
|
||||
// console.error('Ошибка:', error);
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// fetchData();
|
||||
//
|
||||
// }, [surveyId]);
|
||||
|
||||
return (
|
||||
<div className={styles.settingSurvey}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue