Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/omnichannel-contact-center-date-relative-time.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -48,10 +58,12 @@ const ChatsTableRow = (room: IOmnichannelRoomWithDepartment) => {
);

return (
<GenericTableRow key={_id} tabIndex={0} onClick={() => onRowClick(_id)} action>
<GenericTableRow className={customAlignTop} key={_id} tabIndex={0} onClick={() => onRowClick(_id)} action>
<GenericTableCell withTruncatedText>
<Box display='flex' flexDirection='column'>
<Box withTruncatedText>{fname}</Box>
<Box withTruncatedText fontScale='p2m' color='default'>
{fname}
</Box>
{tags && (
<Box color='hint' display='flex' flex-direction='row'>
{tags.map((tag: string) => (
Expand Down Expand Up @@ -83,11 +95,23 @@ const ChatsTableRow = (room: IOmnichannelRoomWithDepartment) => {
</Box>
</GenericTableCell>
<GenericTableCell withTruncatedText>{department?.name}</GenericTableCell>
<GenericTableCell withTruncatedText title={getTimeFromNow(ts)}>
{formatDate(ts)}
<GenericTableCell withTruncatedText>
<Box display='flex' flexDirection='column'>
<Box fontScale='p2m' withTruncatedText color='default'>
{formatDate(ts)}
</Box>
<Box withTruncatedText>{getTimeFromNow(ts)}</Box>
Comment thread
dougfabris marked this conversation as resolved.
Resolved
</Box>
</GenericTableCell>
<GenericTableCell withTruncatedText title={lm ? getTimeFromNow(lm) : undefined}>
{lm ? formatDate(lm) : undefined}
<GenericTableCell withTruncatedText>
{lm && (
<Box display='flex' flexDirection='column'>
<Box fontScale='p2m' withTruncatedText color='default'>
{formatDate(lm)}
</Box>
<Box withTruncatedText>{getTimeFromNow(lm)}</Box>
</Box>
)}
</GenericTableCell>
<GenericTableCell withTruncatedText>
<RoomActivityIcon room={room} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
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';
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) => {
Expand All @@ -31,8 +43,18 @@ const ContactTableRow = ({ _id, name, contactManager, lastChat, channels }: ILiv
);

return (
<GenericTableRow action key={_id} tabIndex={0} height='40px' rcx-show-call-button-on-hover onClick={() => onRowClick(_id)}>
<GenericTableCell withTruncatedText>{name}</GenericTableCell>
<GenericTableRow
action
key={_id}
tabIndex={0}
height='40px'
rcx-show-call-button-on-hover
className={customAlignTop}
onClick={() => onRowClick(_id)}
>
<GenericTableCell fontScale='p2m' color='default' withTruncatedText>
{name}
</GenericTableCell>
<GenericTableCell withTruncatedText>
{latestChannel?.details && (
<Box withTruncatedText display='flex' alignItems='center'>
Expand All @@ -44,7 +66,16 @@ const ContactTableRow = ({ _id, name, contactManager, lastChat, channels }: ILiv
)}
</GenericTableCell>
<GenericTableCell withTruncatedText>{contactManager?.username}</GenericTableCell>
<GenericTableCell withTruncatedText>{lastChat && getTimeFromNow(lastChat.ts)}</GenericTableCell>
<GenericTableCell withTruncatedText>
{lastChat && (
<Box display='flex' flexDirection='column'>
<Box fontScale='p2m' withTruncatedText color='default'>
{formatDate(lastChat.ts)}
</Box>
<Box withTruncatedText>{getTimeFromNow(lastChat.ts)}</Box>
</Box>
)}
</GenericTableCell>
<GenericTableCell>
<ContactItemMenu _id={_id} name={name} channels={channels} />
</GenericTableCell>
Expand Down
Loading