Skip to content

Commit 28995e3

Browse files
authored
display ON epoch instead of Unix epoch (#466)
1 parent 7c4e8df commit 28995e3

4 files changed

Lines changed: 51 additions & 13 deletions

File tree

src/components/chart/use-custom-tooltip.tsx

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ChartTypeEnum } from '@/components/chart/chart-type';
2+
import config from '@/config';
23
import React, { useCallback, useEffect, useRef, useState } from 'react';
34
import ReactDOM from 'react-dom';
45

@@ -14,6 +15,23 @@ type UseCustomTooltipProps = {
1415
labelKey: string;
1516
};
1617

18+
const EpochLabel: React.FC<{
19+
children: React.ReactNode;
20+
epoch: number;
21+
}> = ({ children, epoch }) => {
22+
const onEpoch = epoch - config.epochDiff;
23+
return (
24+
<div>
25+
<div>
26+
{onEpoch < 1 ? <span>ON Testing Phase</span> : <span>ON Epoch {onEpoch.toLocaleString()}</span>}
27+
:&nbsp;
28+
<span>{children}</span>
29+
</div>
30+
<div className="text10 textSecondary">Unix epoch {epoch.toLocaleString()}</div>
31+
</div>
32+
);
33+
};
34+
1735
const RechartsTooltipContent = ({ active, payload, label, cardIdRef, setTooltipInfo, mousePositionRef }: any) => {
1836
const prevActiveRef = useRef(active);
1937
const prevPayloadRef = useRef(payload);
@@ -88,7 +106,7 @@ export const useCustomTooltip = ({ chartType, labelKey }: UseCustomTooltipProps)
88106
mousePositionRef={mousePositionRef}
89107
/>
90108
),
91-
[cardIdRef, setTooltipInfo, mousePositionRef]
109+
[]
92110
);
93111

94112
const renderTooltipPortal = useCallback(() => {
@@ -137,9 +155,9 @@ export const useCustomTooltip = ({ chartType, labelKey }: UseCustomTooltipProps)
137155
tooltipContent = null;
138156
} else {
139157
tooltipContent = (
140-
<div>
141-
Epoch {label}: {Number(value).toLocaleString()} jobs
142-
</div>
158+
<EpochLabel epoch={Number(label)}>
159+
<strong>{Number(value).toLocaleString()}</strong> jobs
160+
</EpochLabel>
143161
);
144162
}
145163
break;
@@ -149,9 +167,9 @@ export const useCustomTooltip = ({ chartType, labelKey }: UseCustomTooltipProps)
149167
tooltipContent = null;
150168
} else {
151169
tooltipContent = (
152-
<div>
153-
Epoch {label}: USDC {Number(value).toLocaleString()}
154-
</div>
170+
<EpochLabel epoch={Number(label)}>
171+
USDC <strong>{Number(value).toLocaleString()}</strong>
172+
</EpochLabel>
155173
);
156174
}
157175
break;

src/components/chart/v-bar-chart.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,9 @@ const VBarChart = ({ axisKey, barKey, chartType, data, footer, minBars, title }:
6666
}, [axisKey, barKey, data, minBars]);
6767

6868
return (
69-
<div className={styles.chartWrapper}>
69+
<div className={styles.chartWrapper} onMouseLeave={handleMouseLeave}>
7070
<h3 className={styles.heading}>{title}</h3>
71-
<div
72-
onMouseMove={handleMouseMove}
73-
onMouseLeave={handleMouseLeave}
74-
style={{ width: '100%', height: '100%', position: 'relative' }}
75-
>
71+
<div onMouseMove={handleMouseMove} style={{ width: '100%', height: '100%', position: 'relative' }}>
7672
<ResponsiveContainer width="100%" height="100%">
7773
<RechartsBarChart
7874
barGap={-8}

src/config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ type Config = {
4848
[key: string]: string;
4949
};
5050
supportEmail: string;
51+
/**
52+
* Diff between ON Epoch 1 and Unix 0.
53+
* ON Epoch is displayed to users in the UI.
54+
* Unix epoch is used in data.
55+
* 1 epoch = 7 days.
56+
*/
57+
epochDiff: number;
5158
};
5259

5360
const config: Config = {
@@ -99,6 +106,11 @@ const config: Config = {
99106
cookies: {
100107
accessToken: 'access_token',
101108
},
109+
/**
110+
* Unix epoch 0 from 1970-01-01.
111+
* ON Epoch 1 from 2026-02-26.
112+
*/
113+
epochDiff: 2929,
102114
};
103115

104116
export default config;

src/styles/globals.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,18 @@ a {
264264
gap: 32px;
265265
}
266266

267+
.text10 {
268+
font-size: 10px;
269+
}
270+
.text12 {
271+
font-size: 12px;
272+
}
273+
.text14 {
274+
font-size: 14px;
275+
}
276+
.text16 {
277+
font-size: 16px;
278+
}
267279
.textAccent1 {
268280
color: var(--accent1);
269281
}

0 commit comments

Comments
 (0)