From 658e6ab3d3270e7254b82ee8440f675adc974a80 Mon Sep 17 00:00:00 2001 From: Sangeeth Thilakarathna <46221775+sanmaxdev@users.noreply.github.com> Date: Tue, 14 Jul 2026 16:29:55 +0530 Subject: [PATCH] feat(frontend): show client comments on mobile cards (#5942) * feat(frontend): show client comments on mobile cards * fix(frontend): bound mobile comment height --------- Co-authored-by: sanmaxdev --- .../components/clients/ClientCardComment.tsx | 14 ++++++++++ frontend/src/pages/clients/ClientsPage.css | 11 ++++++++ frontend/src/pages/clients/ClientsPage.tsx | 4 ++- .../src/test/client-card-comment.test.tsx | 27 +++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 frontend/src/components/clients/ClientCardComment.tsx create mode 100644 frontend/src/test/client-card-comment.test.tsx diff --git a/frontend/src/components/clients/ClientCardComment.tsx b/frontend/src/components/clients/ClientCardComment.tsx new file mode 100644 index 000000000..f323a63fd --- /dev/null +++ b/frontend/src/components/clients/ClientCardComment.tsx @@ -0,0 +1,14 @@ +type ClientCardCommentProps = { + comment?: string; + className?: string; +}; + +export default function ClientCardComment({ comment, className = 'client-card-comment' }: ClientCardCommentProps) { + if (!comment) return null; + + return ( + + {comment} + + ); +} \ No newline at end of file diff --git a/frontend/src/pages/clients/ClientsPage.css b/frontend/src/pages/clients/ClientsPage.css index d3c2e2fd7..850b1a59f 100644 --- a/frontend/src/pages/clients/ClientsPage.css +++ b/frontend/src/pages/clients/ClientsPage.css @@ -162,6 +162,17 @@ background: color-mix(in srgb, var(--ant-color-primary) 6%, transparent); } +.client-card-comment { + display: block; + margin-top: 6px; + color: var(--ant-color-text-secondary); + font-size: 12px; + max-height: 4.5em; + overflow-y: auto; + overflow-wrap: anywhere; + white-space: pre-wrap; +} + .client-card-speed { margin-top: 6px; font-size: 12px; diff --git a/frontend/src/pages/clients/ClientsPage.tsx b/frontend/src/pages/clients/ClientsPage.tsx index 89f9b6d8d..141e5a1b1 100644 --- a/frontend/src/pages/clients/ClientsPage.tsx +++ b/frontend/src/pages/clients/ClientsPage.tsx @@ -62,6 +62,7 @@ import { useDatepicker } from '@/hooks/useDatepicker'; import type { ClientRecord, InboundOption, ExternalLink, ExternalLinkInput } from '@/hooks/useClients'; import ClientTrafficCell from '@/components/clients/ClientTrafficCell'; import ClientSpeedTag, { isActiveSpeed } from '@/components/clients/ClientSpeedTag'; +import ClientCardComment from '@/components/clients/ClientCardComment'; import AppSidebar from '@/layouts/AppSidebar'; import { IntlUtil, SizeFormatter } from '@/utils'; import { setMessageInstance } from '@/utils/messageBus'; @@ -818,7 +819,7 @@ export default function ClientsPage() {
{record.email} {record.subId && {record.subId}} - {record.comment && {record.comment}} +
), }, @@ -1433,6 +1434,7 @@ export default function ClientsPage() { + { + it('renders a client comment in the card', () => { + render(); + + const comment = screen.getByText(/Primary mobile client/); + expect(comment.className).toContain('client-card-comment'); + expect(comment.textContent).toBe('Primary mobile client\nLine two'); + expect(comment.getAttribute('title')).toBe('Primary mobile client\nLine two'); + }); + + it('supports the compact desktop style', () => { + render(); + + expect(screen.getByText('Desktop comment').className).toBe('sub'); + }); + + it('renders nothing when no comment is set', () => { + const { container } = render(); + + expect(container.childElementCount).toBe(0); + }); +}); \ No newline at end of file