import React, { ChangeEvent, ChangeEventHandler, MouseEventHandler, useState, } from "react"; type Props = { // isEditing: boolean; title: string; comment: string; handleTitleComment: Function; }; export const SurveyTitleAndComment = ({ comment, title, handleTitleComment, }: Props) => { const [state, setState] = useState({ title: title, comment: comment }); const [disabled, setDisabled] = useState(true); console.log("title:", title, "comment:", comment, "state:", state); const handleChange = (e: ChangeEvent) => { const { name, value } = e.target; setState({ ...state, [name]: value }); }; const onEdit = () => { setDisabled(false); }; const onCancel = () => { setDisabled(true); setState({ title, comment }); }; const handleConfirm = () => { setDisabled(true); handleTitleComment(state); }; return (
{disabled ? ( <> ) : ( <> )}
); };