From 33c749c0e2c2d2a0e0ee17eb83ac2fd5d6efbef7 Mon Sep 17 00:00:00 2001 From: pepermao Date: Fri, 1 Dec 2023 16:43:15 +0100 Subject: [PATCH] Fixed cross-checking comments card click - Fixed disappearance of crossChecking comments after report change - Fixed default value to prevent old claim review tasks cross-checking error - remove console.log --- .../Collaborative/Comment/CommentCard.tsx | 2 ++ .../Collaborative/Comment/CommentContainer.tsx | 15 +++++++++------ src/components/Form/UserInput.tsx | 2 +- src/components/Notification/NotificationCard.tsx | 1 - 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/components/Collaborative/Comment/CommentCard.tsx b/src/components/Collaborative/Comment/CommentCard.tsx index 1bae6fd57..b62c92ec2 100644 --- a/src/components/Collaborative/Comment/CommentCard.tsx +++ b/src/components/Collaborative/Comment/CommentCard.tsx @@ -23,9 +23,11 @@ const CommentCard = ({ const [isSelected, setIsSelected] = useState(false); const handleClickCard = () => { + const isCrossCheckingComment = comment.type === "cross-checking"; if (enableEditorAnnotations && comment?.from && comment?.to) { selectText({ from: comment.from, to: comment.to }); } + setIsSelected(isCrossCheckingComment); }; return !isResolved ? ( diff --git a/src/components/Collaborative/Comment/CommentContainer.tsx b/src/components/Collaborative/Comment/CommentContainer.tsx index db616ef00..799f6bd37 100644 --- a/src/components/Collaborative/Comment/CommentContainer.tsx +++ b/src/components/Collaborative/Comment/CommentContainer.tsx @@ -1,6 +1,6 @@ import "remirror/styles/all.css"; -import React, { useContext, useEffect, useState } from "react"; +import React, { useContext, useEffect, useMemo, useState } from "react"; import { CommandButton, FloatingToolbar, @@ -38,6 +38,13 @@ const CommentContainer = ({ readonly, state }) => { ? addAnnotation?.enabled({ id: "" }) : true; const annotations = enableEditorAnnotations ? getAnnotations() : null; + const crossCheckingComments = useMemo( + () => + reviewData?.crossCheckingComments?.filter( + (crossCheckingComment) => !crossCheckingComment?.resolved + ), + [reviewData?.crossCheckingComments] + ); useEffect(() => { if (hasSession) { @@ -52,10 +59,6 @@ const CommentContainer = ({ readonly, state }) => { const reviewComments = reviewData?.reviewComments?.filter( (comment) => !comment?.resolved ); - const crossCheckingComments = - reviewData?.crossCheckingComments?.filter( - (crossCheckingComment) => !crossCheckingComment?.resolved - ); setComments([ ...(reviewComments ? reviewComments : []), ...(crossCheckingComments ? crossCheckingComments : []), @@ -71,7 +74,7 @@ const CommentContainer = ({ readonly, state }) => { ) { setAnnotations(comments); } else if (comments && state.doc.content.size) { - setComments(annotations); + setComments([...annotations, ...crossCheckingComments]); } } }, [setAnnotations, setComments, state.doc]); diff --git a/src/components/Form/UserInput.tsx b/src/components/Form/UserInput.tsx index 4f51595ed..50e62ca78 100644 --- a/src/components/Form/UserInput.tsx +++ b/src/components/Form/UserInput.tsx @@ -22,7 +22,7 @@ const UserInput = ({ dataLoader, mode = "multiple", style = {}, - value = [], + value = null, preloadedOptions = [], }: UserInputProps) => { const [treatedValue, setTreatedValue] = useState([]); diff --git a/src/components/Notification/NotificationCard.tsx b/src/components/Notification/NotificationCard.tsx index 100e73c6d..e937ba89d 100644 --- a/src/components/Notification/NotificationCard.tsx +++ b/src/components/Notification/NotificationCard.tsx @@ -22,7 +22,6 @@ const NotificationCard = ({ notification, handleNotificationClick }) => { setIsSeen(true); } if (payload.redirectUrl) { - console.log(payload); setIsLoading(true); window.location = payload.redirectUrl; }