fix surveyInfo
This commit is contained in:
parent
6068c717d3
commit
33f2b5ef62
8 changed files with 91 additions and 62 deletions
|
|
@ -1,51 +1,25 @@
|
|||
import React, {useState} from 'react';
|
||||
import React 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, ISurvey} from "../../api/SurveyApi.ts";
|
||||
import {ISurvey} from "../../api/SurveyApi.ts";
|
||||
import {useOutletContext} from "react-router-dom";
|
||||
|
||||
|
||||
const SettingSurvey: React.FC = () => {
|
||||
const [descriptionSurvey, setDescriptionSurvey] = useState('');
|
||||
// const [survey, setSurvey] = useState<ISurvey | null>(null);
|
||||
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);
|
||||
// setSurvey(surveyData);
|
||||
// setTitleSurvey(surveyData.title);
|
||||
// setDescriptionSurvey(surveyData.description);
|
||||
// } catch (error) {
|
||||
// console.error('Ошибка:', error);
|
||||
// }
|
||||
// };
|
||||
//
|
||||
// fetchData();
|
||||
//
|
||||
// }, [surveyId]);
|
||||
const { survey, setSurvey } = useOutletContext<{
|
||||
survey: ISurvey;
|
||||
setSurvey: (survey: ISurvey) => void;
|
||||
}>();
|
||||
|
||||
return (
|
||||
<div className={styles.settingSurvey}>
|
||||
<SurveyInfo
|
||||
titleSurvey={titleSurvey}
|
||||
descriptionSurvey={descriptionSurvey}
|
||||
setDescriptionSurvey={setDescriptionSurvey}
|
||||
setTitleSurvey={setTitleSurvey}
|
||||
titleSurvey={survey.title}
|
||||
descriptionSurvey={survey.description}
|
||||
setDescriptionSurvey={(value) => setSurvey({ ...survey, description: value })}
|
||||
setTitleSurvey={(value) => setSurvey({ ...survey, title: value })}
|
||||
/>
|
||||
<div className={styles.startEndTime}>
|
||||
<TimeEvent title='Время начала'/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue