Total Complexity | 1 |
Complexity/F | 0 |
Lines of Code | 35 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import React from 'react' |
||
2 | import PropTypes from 'prop-types' |
||
3 | import { withTranslation } from 'react-i18next' |
||
4 | import { connect } from 'react-redux' |
||
5 | import { autoDetectDmy } from 'Src/utils/timeFormat' |
||
6 | import tbbStyle from './TimeBasedBlock.scss' |
||
7 | |||
8 | const ItemTime = ({ from, to, currentLang, t }) => { |
||
9 | const fromLocale = autoDetectDmy(from, currentLang) |
||
10 | const toLocale = autoDetectDmy(to, currentLang) |
||
11 | return ( |
||
12 | <div className={tbbStyle.time}> |
||
13 | {to |
||
14 | ? t('{{from}} – {{to}}', { |
||
15 | from: fromLocale, |
||
16 | to: toLocale, |
||
17 | }) |
||
18 | : t('{{from}} – now', { from: fromLocale })} |
||
19 | </div> |
||
20 | ) |
||
21 | } |
||
22 | |||
23 | ItemTime.propTypes = { |
||
24 | from: PropTypes.string.isRequired, |
||
25 | to: PropTypes.string, |
||
26 | currentLang: PropTypes.string.isRequired, |
||
27 | t: PropTypes.func.isRequired, |
||
28 | } |
||
29 | |||
30 | const mapStateToProps = (state) => ({ |
||
31 | currentLang: state.lang, |
||
32 | }) |
||
33 | |||
34 | export default connect(mapStateToProps)(withTranslation()(ItemTime)) |
||
35 |