import React, { ChangeEvent, FormEvent, useState } from "react";
import { useNavigate } from "react-router-dom";
import { catchErrors } from "../helpers";
import { SpinnerIcon } from "../icons";
import { CreateQuestionData, ISurvey } from "../types";
import { QuestionsList } from "./QuestionsList";
import { SurveyTitle } from "./SurveyTitle";
import { SurveyTitleAndComment } from "./SurveyTitleAndComment";
type Props = {
questions: CreateQuestionData[];
survey: ISurvey;
addQuestion: () => void;
deleteQuestion: (id: string) => void;
handleQuestion: (question: CreateQuestionData) => void;
handleTitleComment: Function;
};
export const ModifySurveyView = ({
questions,
survey,
addQuestion,
deleteQuestion,
handleQuestion,
handleTitleComment,
}: Props) => {
const [error, setError] = useState("");
const [loading, setLoading] = useState(false);
return (
<>
{loading && (