From 0f92e28ea6964aa2980a5e1b7ebc52a1c94657bd Mon Sep 17 00:00:00 2001 From: TBS093A Date: Wed, 15 Jan 2020 15:50:50 +0100 Subject: [PATCH] repair bad elements --- src/components/forum/forumSubjectUpdate.js | 26 ++++++++++++++++----- src/components/forum/forumSubjects.js | 26 +++++++++++++++++---- src/stores/subjects/duck/operations.js | 4 ++-- src/stores/user/duck/operations.js | 27 +++++++++++++++++----- src/stores/user/duck/reducers.js | 4 +++- src/styles/general.scss | 4 ++++ src/styles/indexForum.scss | 10 ++++++++ 7 files changed, 81 insertions(+), 20 deletions(-) diff --git a/src/components/forum/forumSubjectUpdate.js b/src/components/forum/forumSubjectUpdate.js index 1d20122..4ca6cec 100644 --- a/src/components/forum/forumSubjectUpdate.js +++ b/src/components/forum/forumSubjectUpdate.js @@ -17,14 +17,27 @@ const ForumSubjectUpdate = ({ const updateSubjectTitle = React.createRef() const updateSubjectAuthor = React.createRef() + const [selectAuthorID, setSelectAuthorID] = useState(-1) + const [selectThreadID, setSelectThreadID] = useState(-1) + const updateOldSubject = (event) => { event.preventDefault() - if ( updateSubjectTitle.current.value !== '') { + if ( updateSubjectTitle.current.value !== '' && selectAuthorID === -1 && selectThreadID === -1 ) { let putSubject = { id: subject.id, name: updateSubjectTitle.current.value, - user_id: user.id, - thread_id: threads.actualThreadID, + user_id: subject.user_id, + thread_id: subject.thread_id, + token: user.token + } + updateSubject(putSubject) + updateSubjectTitle.current.value = '' + } else if ( updateSubjectTitle.current.value !== '' && user.privilige >= 2 ) { + let putSubject = { + id: subject.id, + name: updateSubjectTitle.current.value, + user_id: selectAuthorID === -1 ? subject.user_id : selectAuthorID, + thread_id: selectThreadID === -1 ? subject.thread_id : selectThreadID, token: user.token } updateSubject(putSubject) @@ -51,8 +64,8 @@ const ForumSubjectUpdate = ({