diff --git a/src/components/Activities/ReportTaskComments.jsx b/src/components/Activities/ReportTaskComments.jsx index 94ee1c7b..efe62d0a 100644 --- a/src/components/Activities/ReportTaskComments.jsx +++ b/src/components/Activities/ReportTaskComments.jsx @@ -27,15 +27,21 @@ const ReportTaskComments = ({ commentsData, closeModal }) => { }); const containerRef = useRef(null); + const firstRender = useRef(true); + + useEffect(() => { setComment(commentsData?.comments); }, [commentsData]); + // Scroll logic: scroll to bottom when new comments are added useEffect(() => { - if (containerRef.current) { + if (!firstRender.current && containerRef.current) { containerRef.current.scrollTop = containerRef.current.scrollHeight; + } else { + firstRender.current = false; // Mark the first render as complete } - }, [comments]); + }, [comments]); // Run this when comments array is updated const onSubmit = async (data) => { let sendComment = { @@ -70,9 +76,10 @@ const ReportTaskComments = ({ commentsData, closeModal }) => { // closeModal(); } catch (error) { setloading(false); - showToast(error.response.data?.message || "Something wrong", "error"); + showToast(error.response.data?.message || "Something went wrong", "error"); } }; + return (
{ onClick={closeModal} aria-label="Close" > -

- {`${commentsData?.workItem?.workArea?.floor?.building?.name}`}{" "} - {" "} - {`${commentsData?.workItem?.workArea?.floor?.floorName} `}{" "} - - {`${commentsData?.workItem?.workArea?.areaName}`} - - {` ${commentsData?.workItem?.activityMaster?.activityName}`} +

Activity Summary

+

+ {comments && comments[0]?.comment} +

+

+ Assigned By : + + {commentsData?.assignedBy.firstName + + " " + + commentsData?.assignedBy.lastName} + {" "}

- -
+ +