diff --git a/client/src/components/issueDetail/header/index.js b/client/src/components/issueDetail/header/index.js index 07ed767..1e8e8cf 100644 --- a/client/src/components/issueDetail/header/index.js +++ b/client/src/components/issueDetail/header/index.js @@ -7,6 +7,7 @@ import S from './style'; const Header = ({ issue, commentsCount }) => { const [isEditClicked, setIsEditClicked] = useState(false); const [title, setTitle] = useState(''); + const [prevTitle, setprevTitle] = useState(''); const dispatch = useIssueDetailDispatch(); @@ -19,12 +20,22 @@ const Header = ({ issue, commentsCount }) => { setIsEditClicked(false); }; + const cancelHandler = () => { + setIsEditClicked(false); + setTitle(prevTitle); + }; + const changeHandler = (e) => { setTitle(e.target.value); }; + const editHandler = () => { + setprevTitle(title); + setIsEditClicked(true); + }; + const editButton = isEditClicked ? null : ( - ); @@ -43,14 +54,7 @@ const Header = ({ issue, commentsCount }) => { - { - setIsEditClicked(false); - }} - value="Cancel" - /> + ) : (