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

Jim/76927/remaining-time-component-ts-migration #32

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
3 changes: 0 additions & 3 deletions packages/components/src/components/remaining-time/index.js

This file was deleted.

3 changes: 3 additions & 0 deletions packages/components/src/components/remaining-time/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import RemainingTime from './remaining-time';

export default RemainingTime;
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import PropTypes from 'prop-types';
import React from 'react';
import { formatDuration, getDiffDuration } from '@deriv/shared';
import moment from 'moment';

const RemainingTime = ({ end_time = null, format, getCardLabels, start_time }) => {
if (!+end_time || start_time.unix() > +end_time) {
type TRemainingTimeProps = {
end_time?: number;
start_time: moment.Moment;
format: string;
getCardLabels: () => { [key: string]: string }; // TODO Use the one from common after contract-card migration
jim-deriv marked this conversation as resolved.
Show resolved Hide resolved
};

const RemainingTime = ({ end_time, format, getCardLabels, start_time }: TRemainingTimeProps) => {
if (!end_time || start_time.unix() > +end_time) {
return '';
}

Expand All @@ -17,11 +24,4 @@ const RemainingTime = ({ end_time = null, format, getCardLabels, start_time }) =
return !is_zeroes && <div className='dc-remaining-time'>{remaining_time}</div>;
};

RemainingTime.propTypes = {
end_time: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
start_time: PropTypes.object,
format: PropTypes.string,
getCardLabels: PropTypes.func,
};

export default RemainingTime;