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 (
- {`${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} + {" "}
-+ Loaction : + + {`${commentsData?.workItem?.workArea?.floor?.building?.name}`}{" "} + {" "} + {`${commentsData?.workItem?.workArea?.floor?.floorName} `}{" "} + + {`${commentsData?.workItem?.workArea?.areaName}`} + + {` ${commentsData?.workItem?.activityMaster?.activityName}`} + +
++ Planned Work: {commentsData?.plannedTask} +
++ {" "} + Completed Work : {commentsData?.completedTask} +
+Team:
+{fullName}
-- {moment.utc(data?.commentDate).local().fromNow()} -
-- {data?.comment} -
-{fullName}
++ {moment.utc(data?.commentDate).local().fromNow()} +
+{data?.comment}
+