Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show new line in comments #10004

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions src/components/Resource/ResourceCommentSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import TextAreaFormField from "@/components/Form/FormFields/TextAreaFormField";

import routes from "@/Utils/request/api";
import request from "@/Utils/request/request";
import { formatName } from "@/Utils/utils";
import { formatName, relativeTime } from "@/Utils/utils";
import { CommentModel } from "@/types/resourceRequest/resourceRequest";

import { Avatar } from "../Common/Avatar";
Expand Down Expand Up @@ -85,19 +85,28 @@ const CommentSection = (props: { id: string }) => {

export default CommentSection;

export const Comment = ({ comment, created_by }: CommentModel) => (
export const Comment = ({
comment,
created_by,
created_date,
}: CommentModel) => (
<div className="mt-4 flex w-full flex-col rounded-lg border border-secondary-300 bg-white p-4 text-secondary-800">
<div className="w-full">
<p className="break-words">{comment}</p>
<p className="break-words whitespace-pre-wrap">
{comment.replace(/\n+/g, "\n")}
</p>
</div>
<div className="mr-auto flex items-center rounded-md border bg-secondary-100 py-1 pl-2 pr-3">
<Avatar
name={`${created_by.first_name} ${created_by.first_name}`}
className="h-8 w-8 "
/>
<span className="pl-2 text-sm text-secondary-700">
{formatName(created_by)}
</span>
<div className="flex w-full items-center">
<div className="mr-auto flex items-center rounded-md border bg-secondary-100 py-1 pl-2 pr-3">
<Avatar
name={`${created_by.first_name} ${created_by.last_name}`}
className="h-8 w-8 "
/>
<span className="pl-2 text-sm text-secondary-700">
{formatName(created_by)}
</span>
</div>
<div className="text-xs">{relativeTime(created_date)}</div>
</div>
</div>
);
Loading