@rango-dev/widget-embedded 0.20.1-next.1 → 0.20.1-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts +157 -0
- package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
- package/dist/components/Quote/QuoteSummary.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +2 -0
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -1
- package/dist/constants/routing.d.ts +1 -0
- package/dist/constants/routing.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/utils/date.d.ts.map +1 -1
- package/dist/utils/numbers.d.ts +1 -5
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/time.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/components/Quote/Quote.styles.ts +5 -1
- package/src/components/Quote/Quote.tsx +53 -15
- package/src/components/Quote/QuoteSummary.tsx +17 -2
- package/src/components/SwapDetails/SwapDetails.helpers.tsx +7 -1
- package/src/components/SwapDetails/SwapDetails.tsx +21 -1
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +6 -0
- package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +2 -0
- package/src/components/SwapsGroup/SwapsGroup.tsx +13 -7
- package/src/constants/routing.ts +2 -0
- package/src/pages/Home.tsx +11 -1
- package/src/utils/date.ts +22 -8
- package/src/utils/numbers.ts +8 -58
- package/src/utils/time.ts +25 -69
package/src/utils/time.ts
CHANGED
|
@@ -2,76 +2,32 @@ import type { PendingSwap } from 'rango-types';
|
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
pluralLabel: i18n.t('months'),
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
turningPoint: SECONDS_PER_DAY,
|
|
30
|
-
label: i18n.t('day'),
|
|
31
|
-
pluralLabel: i18n.t('days'),
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
turningPoint: SECONDS_PER_HOUR,
|
|
35
|
-
label: i18n.t('hour'),
|
|
36
|
-
pluralLabel: i18n.t('hours'),
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
turningPoint: SECONDS_PER_MINUTE,
|
|
40
|
-
label: i18n.t('minute'),
|
|
41
|
-
pluralLabel: i18n.t('minutes'),
|
|
42
|
-
},
|
|
43
|
-
];
|
|
44
|
-
|
|
45
|
-
const sortedIntervals = intervals.sort(
|
|
46
|
-
(a, b) => b.turningPoint - a.turningPoint
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
for (const interval of sortedIntervals) {
|
|
50
|
-
const { turningPoint, label, pluralLabel } = interval;
|
|
51
|
-
const intervalCount = Math.floor(seconds / turningPoint);
|
|
52
|
-
if (intervalCount > 1) {
|
|
53
|
-
return `${intervalCount} ${pluralLabel}`;
|
|
54
|
-
}
|
|
55
|
-
if (intervalCount === 1) {
|
|
56
|
-
return `${intervalCount} ${label}`;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (seconds > 1) {
|
|
61
|
-
return `${seconds} ${i18n.t('seconds')}`;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return `${seconds} ${i18n.t('second')}`;
|
|
5
|
+
const daysOfWeek = [
|
|
6
|
+
i18n.t('Sunday'),
|
|
7
|
+
i18n.t('Monday'),
|
|
8
|
+
i18n.t('Tuesday'),
|
|
9
|
+
i18n.t('Wednesday'),
|
|
10
|
+
i18n.t('Thursday'),
|
|
11
|
+
i18n.t('Friday'),
|
|
12
|
+
i18n.t('Saturday'),
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
export function timeSince(millisecond: number) {
|
|
16
|
+
const date = new Date(millisecond);
|
|
17
|
+
const day = date.getDate();
|
|
18
|
+
const month = date.toLocaleString('default', { month: 'long' });
|
|
19
|
+
const year = date.getFullYear();
|
|
20
|
+
const isToday = date.getDay() === new Date().getDay();
|
|
21
|
+
const formattedDate = isToday
|
|
22
|
+
? i18n.t('Today')
|
|
23
|
+
: `${daysOfWeek[date.getDay()]} ${day} ${month} ${year}`;
|
|
24
|
+
|
|
25
|
+
return `${formattedDate}, ${new Date(millisecond).toLocaleTimeString()}`;
|
|
65
26
|
}
|
|
66
27
|
|
|
67
28
|
export function getSwapDate(pendingSwap: PendingSwap) {
|
|
68
|
-
|
|
69
|
-
?
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
})
|
|
73
|
-
: i18n.t({
|
|
74
|
-
id: '{time} ago',
|
|
75
|
-
values: { time: timeSince(parseInt(pendingSwap.creationTime)) },
|
|
76
|
-
});
|
|
29
|
+
const time = pendingSwap.finishTime
|
|
30
|
+
? timeSince(parseInt(pendingSwap.finishTime))
|
|
31
|
+
: timeSince(parseInt(pendingSwap.creationTime));
|
|
32
|
+
return time;
|
|
77
33
|
}
|