diff --git a/.changeset/omnichannel-contact-center-date-relative-time.md b/.changeset/omnichannel-contact-center-date-relative-time.md new file mode 100644 index 0000000000000..3da10de7b1caf --- /dev/null +++ b/.changeset/omnichannel-contact-center-date-relative-time.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Changes the date columns in the Omnichannel Contact Center to show both the formatted date and the relative time: the **Last Chat** column in the contacts list, and the **Started at** and **Last Message** columns in the chats list diff --git a/apps/meteor/client/views/omnichannel/directory/chats/ChatsTable/ChatsTableRow.tsx b/apps/meteor/client/views/omnichannel/directory/chats/ChatsTable/ChatsTableRow.tsx index 60138a3d5f182..516d8899da5f7 100644 --- a/apps/meteor/client/views/omnichannel/directory/chats/ChatsTable/ChatsTableRow.tsx +++ b/apps/meteor/client/views/omnichannel/directory/chats/ChatsTable/ChatsTableRow.tsx @@ -1,4 +1,5 @@ import type { IOmnichannelRoomWithDepartment } from '@rocket.chat/core-typings'; +import { css } from '@rocket.chat/css-in-js'; import { Tag, Box } from '@rocket.chat/fuselage'; import { useStableCallback } from '@rocket.chat/fuselage-hooks'; import { GenericTableCell, GenericTableRow } from '@rocket.chat/ui-client'; @@ -16,6 +17,15 @@ import { useOmnichannelSource } from '../../../hooks/useOmnichannelSource'; import { PriorityIcon } from '../../../priorities/PriorityIcon'; import { useOmnichannelDirectoryRouter } from '../../hooks/useOmnichannelDirectoryRouter'; +/** + * TODO: We should have a variant for aligning row cell instead of using custom CSS + **/ +const customAlignTop = css` + td { + vertical-align: top; + } +`; + const ChatsTableRow = (room: IOmnichannelRoomWithDepartment) => { const { t } = useTranslation(); const { _id, fname, tags, servedBy, ts, department, open, priorityWeight, lm, onHold, source, verified } = room; @@ -48,10 +58,12 @@ const ChatsTableRow = (room: IOmnichannelRoomWithDepartment) => { ); return ( - onRowClick(_id)} action> + onRowClick(_id)} action> - {fname} + + {fname} + {tags && ( {tags.map((tag: string) => ( @@ -83,11 +95,23 @@ const ChatsTableRow = (room: IOmnichannelRoomWithDepartment) => { {department?.name} - - {formatDate(ts)} + + + + {formatDate(ts)} + + {getTimeFromNow(ts)} + - - {lm ? formatDate(lm) : undefined} + + {lm && ( + + + {formatDate(lm)} + + {getTimeFromNow(lm)} + + )} diff --git a/apps/meteor/client/views/omnichannel/directory/contacts/ContactTableRow.tsx b/apps/meteor/client/views/omnichannel/directory/contacts/ContactTableRow.tsx index 6c66780f25abe..7763425497005 100644 --- a/apps/meteor/client/views/omnichannel/directory/contacts/ContactTableRow.tsx +++ b/apps/meteor/client/views/omnichannel/directory/contacts/ContactTableRow.tsx @@ -1,3 +1,4 @@ +import { css } from '@rocket.chat/css-in-js'; import { Box } from '@rocket.chat/fuselage'; import { useStableCallback } from '@rocket.chat/fuselage-hooks'; import type { ILivechatContactWithManagerData } from '@rocket.chat/rest-typings'; @@ -5,13 +6,24 @@ import { GenericTableCell, GenericTableRow } from '@rocket.chat/ui-client'; import ContactItemMenu from './ContactItemMenu'; import { OmnichannelRoomIcon } from '../../../../components/RoomIcon/OmnichannelRoomIcon'; +import { useFormatDate } from '../../../../hooks/useFormatDate'; import { useTimeFromNow } from '../../../../hooks/useTimeFromNow'; import { useOmnichannelSource } from '../../hooks/useOmnichannelSource'; import { useOmnichannelDirectoryRouter } from '../hooks/useOmnichannelDirectoryRouter'; +/** + * TODO: We should have a variant for aligning row cell instead of using custom CSS + **/ +const customAlignTop = css` + td { + vertical-align: top; + } +`; + const ContactTableRow = ({ _id, name, contactManager, lastChat, channels }: ILivechatContactWithManagerData) => { const { getSourceLabel } = useOmnichannelSource(); const getTimeFromNow = useTimeFromNow(true); + const formatDate = useFormatDate(); const omnichannelDirectoryRouter = useOmnichannelDirectoryRouter(); const latestChannel = channels?.sort((a, b) => { @@ -31,8 +43,18 @@ const ContactTableRow = ({ _id, name, contactManager, lastChat, channels }: ILiv ); return ( - onRowClick(_id)}> - {name} + onRowClick(_id)} + > + + {name} + {latestChannel?.details && ( @@ -44,7 +66,16 @@ const ContactTableRow = ({ _id, name, contactManager, lastChat, channels }: ILiv )} {contactManager?.username} - {lastChat && getTimeFromNow(lastChat.ts)} + + {lastChat && ( + + + {formatDate(lastChat.ts)} + + {getTimeFromNow(lastChat.ts)} + + )} +