Fix: create time (#1250)
* change date strings * remove additional suffix * fix tests --------- Co-authored-by: corentin <corentin@twenty.com>
This commit is contained in:
committed by
GitHub
parent
2e01efb8f3
commit
587c74667c
@ -144,7 +144,7 @@ export function TimelineActivity({ activity }: OwnProps) {
|
||||
created a {activity.type.toLowerCase()}
|
||||
</StyledItemTitleContainer>
|
||||
<StyledItemTitleDate id={`id-${activity.id}`}>
|
||||
{beautifiedCreatedAt} ago
|
||||
{beautifiedCreatedAt}
|
||||
</StyledItemTitleDate>
|
||||
<StyledTooltip
|
||||
anchorSelect={`#id-${activity.id}`}
|
||||
|
||||
@ -118,9 +118,7 @@ export function ShowPageSummaryCard({
|
||||
<OverflowingTextWithTooltip text={title} />
|
||||
)}
|
||||
</StyledTitle>
|
||||
<StyledDate id={dateElementId}>
|
||||
Added {beautifiedCreatedAt} ago
|
||||
</StyledDate>
|
||||
<StyledDate id={dateElementId}>Added {beautifiedCreatedAt}</StyledDate>
|
||||
<StyledTooltip
|
||||
anchorSelect={`#${dateElementId}`}
|
||||
content={exactCreatedAt}
|
||||
|
||||
@ -85,7 +85,7 @@ describe('beautifyPastDateRelativeToNow', () => {
|
||||
it('should return the correct relative date', () => {
|
||||
const mockDate = '2023-01-01';
|
||||
const actualDate = new Date(mockDate);
|
||||
const expected = formatDistanceToNow(actualDate);
|
||||
const expected = formatDistanceToNow(actualDate, { addSuffix: true });
|
||||
|
||||
const result = beautifyPastDateRelativeToNow(mockDate);
|
||||
expect(result).toEqual(expected);
|
||||
|
||||
@ -61,7 +61,9 @@ export function beautifyPastDateRelativeToNow(
|
||||
try {
|
||||
const parsedDate = parseDate(pastDate);
|
||||
|
||||
return formatDistanceToNow(parsedDate.toJSDate());
|
||||
return formatDistanceToNow(parsedDate.toJSDate(), {
|
||||
addSuffix: true,
|
||||
}).replace('less than a minute ago', 'now');
|
||||
} catch (error) {
|
||||
logError(error);
|
||||
return '';
|
||||
|
||||
Reference in New Issue
Block a user