From 845b2f2e5e9145117577e9c231fccd2dc9d04abe Mon Sep 17 00:00:00 2001 From: kemboi590 Date: Wed, 26 Jul 2023 10:03:29 +0300 Subject: [PATCH] done --- src/pages/Tasks/Discussions/Discussions.jsx | 50 ++++++++++++++----- src/pages/Tasks/Discussions/discussions.css | 5 +- .../Tasks/UpdateComment/UpdateComment.jsx | 29 +++++++++-- .../Tasks/UpdateComment/updatecomment.css | 31 ++++++++++++ 4 files changed, 96 insertions(+), 19 deletions(-) diff --git a/src/pages/Tasks/Discussions/Discussions.jsx b/src/pages/Tasks/Discussions/Discussions.jsx index 4030b4e..f5d39da 100644 --- a/src/pages/Tasks/Discussions/Discussions.jsx +++ b/src/pages/Tasks/Discussions/Discussions.jsx @@ -25,7 +25,7 @@ function Discussions() { Authorization: `${userData.token}`, }, }); - // console.log(response.data); + console.log(response.data); setCommentsDetails(response.data); } catch (response) { console.log(response); @@ -57,7 +57,10 @@ function Discussions() { }) .catch((error) => { console.log(error); - toast.error("Oops! Something went wrong. Please try again.", toastStyles.error); + toast.error( + "Oops! Something went wrong. Please try again.", + toastStyles.error + ); textareaRef.current.value = ""; }); }; @@ -74,7 +77,10 @@ function Discussions() { getAllComments(); } catch (error) { // console.log(error); - toast.error("Oops! Something went wrong. Please try again.", toastStyles.error); + toast.error( + "Oops! Something went wrong. Please try again.", + toastStyles.error + ); } }; @@ -99,7 +105,9 @@ function Discussions() { commentsDetails.map((comment, index) => { const timestamp = new Date(comment.timestamp).toLocaleString(); const isCurrentUserComment = comment.username === userData.username; - const chatClass = isCurrentUserComment ? "chat_bubble_right" : "chat_bubble_left"; + const chatClass = isCurrentUserComment + ? "chat_bubble_right" + : "chat_bubble_left"; return (
@@ -111,13 +119,26 @@ function Discussions() {

{comment.content}

-
- handleEditToggle(comment)} /> - {showEditForm[comment.comment_id] && } -
-
- handleCommentDelete(comment.comment_id)} /> -
+ {userData && userData.user_id === comment.user_id && ( +
+ handleEditToggle(comment)} /> + {showEditForm[comment.comment_id] && ( + + )} +
+ )} + + {/* here */} + {userData && userData.user_id === comment.user_id && ( +
+ handleCommentDelete(comment.comment_id)} + /> +
+ )}
); @@ -126,7 +147,12 @@ function Discussions() {
- - +
+ <> + + + <> + + +
); diff --git a/src/pages/Tasks/UpdateComment/updatecomment.css b/src/pages/Tasks/UpdateComment/updatecomment.css index e69de29..8934ff1 100644 --- a/src/pages/Tasks/UpdateComment/updatecomment.css +++ b/src/pages/Tasks/UpdateComment/updatecomment.css @@ -0,0 +1,31 @@ +.lets_update_comment { + display: flex; + gap: 5px; + width: 100%; + justify-content: center; + align-items: center; +} +.updateComment { + margin: 10px; + padding: 10px; +} +.inputupdateComment { + width: 100%; + resize: none; + border-radius: 5px; + padding: 10px; + margin-bottom: 10px; +} +.submitUpdate { + display: flex; + justify-content: center; + align-items: center; + height: 35px; + background-color: #333; + color: white; + border: none; + padding: 10px; + border-radius: 5px; + cursor: pointer; + margin-bottom: 10px; +}