Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/yoext 784/nan days staking #3292

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ type Props = {|
+percentage: number,
+days: string,
+currentEpoch: number,
+startEpochDate: string,
+endEpochDate: string,
+startEpochDate: string | Date,
+endEpochDate: string | Date,
|};

export function EpochProgressCard({
Expand Down Expand Up @@ -50,7 +50,7 @@ const Title = ({ label, value }: TitleProps): Node => {

type InfoColumnProps = {|
+label: string,
+value: string | number,
+value: string | number | Date,
|};
const LabelWithValue = ({ label, value }: InfoColumnProps): Node => {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
// @flow
import type { ComponentType, Node } from 'react';
import type { $npm$ReactIntl$IntlShape } from 'react-intl';
import { Box, styled } from '@mui/system';
import { Typography } from '@mui/material';
import { observer } from 'mobx-react';
import { injectIntl } from 'react-intl';
import type { $npm$ReactIntl$IntlShape } from 'react-intl';
import globalMessages from '../../../../i18n/global-messages';
import { EpochProgressCard } from './EpochProgressCard';
import globalMessages from '../../../../i18n/global-messages';
import moment from 'moment';

type Props = {|
epochProgress: {|
currentEpoch: number,
startEpochDate: string,
endEpochDate: string,
startEpochDate: string | Date,
endEpochDate: string | Date,
endEpochDateTime: Date,
percentage: number,
|},
|};
Expand All @@ -23,6 +24,8 @@ type Intl = {|
|};

function EpochProgressWrapper({ epochProgress, intl }: Props & Intl): Node {
const days = moment(epochProgress.endEpochDateTime).diff(moment(), 'days');

return (
<Card>
<Box
Expand All @@ -38,7 +41,7 @@ function EpochProgressWrapper({ epochProgress, intl }: Props & Intl): Node {
<Box sx={{ padding: '24px' }}>
<EpochProgressCard
percentage={epochProgress.percentage}
days={moment(epochProgress.endEpochDate).diff(moment(), 'days')}
days={days}
currentEpoch={epochProgress.currentEpoch}
startEpochDate={epochProgress.startEpochDate}
endEpochDate={epochProgress.endEpochDate}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class StakingPageContent extends Component<AllProps> {
const currentEpoch = currTimeRequests.currentEpoch;
const epochLength = getEpochLength();

const getDateFromEpoch = epoch => {
const getDateFromEpoch = (epoch, returnEpochTime = false) => {
const epochTime = toRealTime({
absoluteSlotNum: toAbsoluteSlot({
epoch,
Expand All @@ -270,11 +270,15 @@ class StakingPageContent extends Component<AllProps> {
}),
timeSinceGenesisFunc: timeSinceGenesis,
});

if (returnEpochTime) return epochTime;

const epochMoment = moment(epochTime).format('lll');
return epochMoment;
};

const endEpochDate = getDateFromEpoch(currentEpoch);
const endEpochDateTime = getDateFromEpoch(currentEpoch, true);
const previousEpochDate = getDateFromEpoch(currentEpoch - 1);

return (
Expand All @@ -283,6 +287,7 @@ class StakingPageContent extends Component<AllProps> {
startEpochDate: previousEpochDate,
currentEpoch,
endEpochDate,
endEpochDateTime,
percentage: Math.floor((100 * currTimeRequests.currentSlot) / epochLength),
}}
/>
Expand Down
Loading