Skip to content

Commit 97648f5

Browse files
committed
Remove custom date formatting
Signed-off-by: Milos Dzepina <milos@aragon.org>
1 parent 1cc6e66 commit 97648f5

3 files changed

Lines changed: 5 additions & 77 deletions

File tree

src/modules/components/proposal/proposalActionSimulationStructure/proposalActionSimulationStructure.stories.tsx

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -80,34 +80,6 @@ export const WithErrorMessage: Story = {
8080
},
8181
};
8282

83-
/**
84-
* Recent simulation (shows "Now")
85-
*/
86-
export const RecentSimulation: Story = {
87-
args: {
88-
totalActions: 7,
89-
lastSimulation: {
90-
timestamp: DateTime.now().minus({ minutes: 5 }).toMillis(),
91-
url: 'https://dashboard.tenderly.co/simulation/12345',
92-
status: 'success',
93-
},
94-
},
95-
};
96-
97-
/**
98-
* Old simulation (shows formatted date)
99-
*/
100-
export const OldSimulation: Story = {
101-
args: {
102-
totalActions: 2,
103-
lastSimulation: {
104-
timestamp: DateTime.now().minus({ weeks: 2 }).toMillis(),
105-
url: 'https://dashboard.tenderly.co/simulation/12345',
106-
status: 'success',
107-
},
108-
},
109-
};
110-
11183
/**
11284
* Not simulatable - only shows Tenderly link
11385
*/

src/modules/components/proposal/proposalActionSimulationStructure/proposalActionSimulationStructure.test.tsx

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -41,34 +41,6 @@ describe('<ProposalActionSimulationStructure /> component', () => {
4141
expect(screen.getByText('Never')).toBeInTheDocument();
4242
});
4343

44-
it('renders relative time for recent simulation', () => {
45-
const recentTime = DateTime.now().minus({ days: 2 });
46-
render(
47-
createTestComponent({
48-
lastSimulation: {
49-
timestamp: recentTime.toMillis(),
50-
url: 'https://dashboard.tenderly.co/simulation/12345',
51-
status: 'success',
52-
},
53-
}),
54-
);
55-
expect(screen.getByText('2 days ago')).toBeInTheDocument();
56-
});
57-
58-
it('renders "Now" for very recent simulation', () => {
59-
const veryRecentTime = DateTime.now().minus({ seconds: 30 });
60-
render(
61-
createTestComponent({
62-
lastSimulation: {
63-
timestamp: veryRecentTime.toMillis(),
64-
url: 'https://dashboard.tenderly.co/simulation/12345',
65-
status: 'success',
66-
},
67-
}),
68-
);
69-
expect(screen.getByText('Now')).toBeInTheDocument();
70-
});
71-
7244
it('renders the execution status label', () => {
7345
render(
7446
createTestComponent({

src/modules/components/proposal/proposalActionSimulationStructure/proposalActionSimulationStructure.tsx

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import classNames from 'classnames';
2-
import { DateTime } from 'luxon';
32
import { useMemo } from 'react';
43
import {
54
AvatarIcon,
@@ -39,7 +38,6 @@ export interface IProposalActionSimulationStructureProps {
3938
*/
4039
className?: string;
4140
/**
42-
*
4341
* Optional error message to display.
4442
*/
4543
error?: string;
@@ -77,24 +75,10 @@ export const ProposalActionSimulationStructure: React.FC<IProposalActionSimulati
7775
}
7876
}, [simulationCopy, lastSimulation?.status]);
7977

80-
const formatSimulationDate = (timestamp?: number) => {
81-
if (!timestamp) {
82-
return copy.proposalActionSimulationStructure.never;
83-
}
84-
85-
const date = DateTime.fromMillis(timestamp);
86-
const now = DateTime.now();
87-
const diffInMinutes = now.diff(date, 'minutes').minutes;
88-
const diffInDays = now.diff(date, 'days').days;
89-
90-
if (diffInMinutes < 2) {
91-
return copy.proposalActionSimulationStructure.now;
92-
}
93-
94-
return formatterUtils.formatDate(date, {
95-
format: diffInDays > 3 ? DateFormat.YEAR_MONTH_DAY_TIME : DateFormat.RELATIVE,
96-
});
97-
};
78+
const formattedTimestamp =
79+
formatterUtils.formatDate(lastSimulation?.timestamp, {
80+
format: DateFormat.YEAR_MONTH_DAY_TIME,
81+
}) ?? simulationCopy.never;
9882

9983
return (
10084
<DataList.Item className={classNames('flex flex-col gap-4 p-4 pt-1 pb-4', className)}>
@@ -110,7 +94,7 @@ export const ProposalActionSimulationStructure: React.FC<IProposalActionSimulati
11094
{simulationCopy.simulating}
11195
</span>
11296
) : (
113-
formatSimulationDate(lastSimulation?.timestamp)
97+
<span className="inline-block first-letter:capitalize">{formattedTimestamp}</span>
11498
)}
11599
</DefinitionList.Item>
116100

0 commit comments

Comments
 (0)