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()}
|
created a {activity.type.toLowerCase()}
|
||||||
</StyledItemTitleContainer>
|
</StyledItemTitleContainer>
|
||||||
<StyledItemTitleDate id={`id-${activity.id}`}>
|
<StyledItemTitleDate id={`id-${activity.id}`}>
|
||||||
{beautifiedCreatedAt} ago
|
{beautifiedCreatedAt}
|
||||||
</StyledItemTitleDate>
|
</StyledItemTitleDate>
|
||||||
<StyledTooltip
|
<StyledTooltip
|
||||||
anchorSelect={`#id-${activity.id}`}
|
anchorSelect={`#id-${activity.id}`}
|
||||||
|
|||||||
@ -118,9 +118,7 @@ export function ShowPageSummaryCard({
|
|||||||
<OverflowingTextWithTooltip text={title} />
|
<OverflowingTextWithTooltip text={title} />
|
||||||
)}
|
)}
|
||||||
</StyledTitle>
|
</StyledTitle>
|
||||||
<StyledDate id={dateElementId}>
|
<StyledDate id={dateElementId}>Added {beautifiedCreatedAt}</StyledDate>
|
||||||
Added {beautifiedCreatedAt} ago
|
|
||||||
</StyledDate>
|
|
||||||
<StyledTooltip
|
<StyledTooltip
|
||||||
anchorSelect={`#${dateElementId}`}
|
anchorSelect={`#${dateElementId}`}
|
||||||
content={exactCreatedAt}
|
content={exactCreatedAt}
|
||||||
|
|||||||
@ -85,7 +85,7 @@ describe('beautifyPastDateRelativeToNow', () => {
|
|||||||
it('should return the correct relative date', () => {
|
it('should return the correct relative date', () => {
|
||||||
const mockDate = '2023-01-01';
|
const mockDate = '2023-01-01';
|
||||||
const actualDate = new Date(mockDate);
|
const actualDate = new Date(mockDate);
|
||||||
const expected = formatDistanceToNow(actualDate);
|
const expected = formatDistanceToNow(actualDate, { addSuffix: true });
|
||||||
|
|
||||||
const result = beautifyPastDateRelativeToNow(mockDate);
|
const result = beautifyPastDateRelativeToNow(mockDate);
|
||||||
expect(result).toEqual(expected);
|
expect(result).toEqual(expected);
|
||||||
|
|||||||
@ -61,7 +61,9 @@ export function beautifyPastDateRelativeToNow(
|
|||||||
try {
|
try {
|
||||||
const parsedDate = parseDate(pastDate);
|
const parsedDate = parseDate(pastDate);
|
||||||
|
|
||||||
return formatDistanceToNow(parsedDate.toJSDate());
|
return formatDistanceToNow(parsedDate.toJSDate(), {
|
||||||
|
addSuffix: true,
|
||||||
|
}).replace('less than a minute ago', 'now');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logError(error);
|
logError(error);
|
||||||
return '';
|
return '';
|
||||||
|
|||||||
Reference in New Issue
Block a user