diff --git a/packages/components/src/components/remaining-time/index.js b/packages/components/src/components/remaining-time/index.js deleted file mode 100644 index 59af37cd427d..000000000000 --- a/packages/components/src/components/remaining-time/index.js +++ /dev/null @@ -1,3 +0,0 @@ -import RemainingTime from './remaining-time.jsx'; - -export default RemainingTime; diff --git a/packages/components/src/components/remaining-time/index.ts b/packages/components/src/components/remaining-time/index.ts new file mode 100644 index 000000000000..7e11567f505d --- /dev/null +++ b/packages/components/src/components/remaining-time/index.ts @@ -0,0 +1,3 @@ +import RemainingTime from './remaining-time'; + +export default RemainingTime; diff --git a/packages/components/src/components/remaining-time/remaining-time.jsx b/packages/components/src/components/remaining-time/remaining-time.tsx similarity index 58% rename from packages/components/src/components/remaining-time/remaining-time.jsx rename to packages/components/src/components/remaining-time/remaining-time.tsx index 71598d4ebe7f..6e51e00b5181 100644 --- a/packages/components/src/components/remaining-time/remaining-time.jsx +++ b/packages/components/src/components/remaining-time/remaining-time.tsx @@ -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 +}; + +const RemainingTime = ({ end_time, format, getCardLabels, start_time }: TRemainingTimeProps) => { + if (!end_time || start_time.unix() > +end_time) { return ''; } @@ -17,11 +24,4 @@ const RemainingTime = ({ end_time = null, format, getCardLabels, start_time }) = return !is_zeroes &&
{remaining_time}
; }; -RemainingTime.propTypes = { - end_time: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), - start_time: PropTypes.object, - format: PropTypes.string, - getCardLabels: PropTypes.func, -}; - export default RemainingTime;