From 6ad89e4f4f73ae70a865cb7b61654e68bb0df994 Mon Sep 17 00:00:00 2001 From: Thanush19 <110150744+Thanush19@users.noreply.github.com> Date: Fri, 8 Mar 2024 20:13:06 +0530 Subject: [PATCH 1/6] fix ui layout of comment-box in shift page --- src/Components/Shifting/CommentsSection.tsx | 98 ++++++++++++--------- src/Components/Shifting/ShiftDetails.tsx | 32 +++++-- 2 files changed, 82 insertions(+), 48 deletions(-) diff --git a/src/Components/Shifting/CommentsSection.tsx b/src/Components/Shifting/CommentsSection.tsx index 767ab402265..0da9793f0b2 100644 --- a/src/Components/Shifting/CommentsSection.tsx +++ b/src/Components/Shifting/CommentsSection.tsx @@ -9,10 +9,63 @@ import { IComment } from "../Resource/models"; import PaginatedList from "../../CAREUI/misc/PaginatedList"; import request from "../../Utils/request/request"; -interface CommentSectionProps { +interface CommentProps { id: string; + comment: string; + created_by_object: any; + modified_date: string; } -const CommentSection = (props: CommentSectionProps) => { + +const Comment = ({ + id, + comment, + created_by_object, + modified_date, +}: CommentProps) => { + const { t } = useTranslation(); + const [expanded, setExpanded] = useState(false); + + const toggleExpanded = () => { + setExpanded(!expanded); + }; + + const truncatedComment = comment.split(" ").slice(0, 20).join(" "); + const remainingComment = comment.split(" ").slice(20).join(" "); + + return ( +
+
+

+ {expanded ? comment : truncatedComment} + {!expanded && remainingComment && ( + + )} +

+
+
+ + {modified_date ? formatDateTime(modified_date) : "-"} + +
+
+
+ {created_by_object?.first_name?.charAt(0) || t("unknown")} +
+ + {created_by_object?.first_name || t("unknown")}{" "} + {created_by_object?.last_name} + +
+
+ ); +}; + +const CommentSection = ({ id }: { id: string }) => { const [commentBox, setCommentBox] = useState(""); const { t } = useTranslation(); @@ -27,21 +80,17 @@ const CommentSection = (props: CommentSectionProps) => { return; } const { res } = await request(routes.addShiftComments, { - pathParams: { id: props.id }, + pathParams: { id: id }, body: payload, }); if (res?.ok) { Notification.Success({ msg: t("comment_added_successfully") }); - setCommentBox(""); } }; return ( - + {(_, query) => (