RelativeDateCell PureComponent
This commit is contained in:
parent
4d389ae5ce
commit
22778091f9
|
@ -1,42 +1,48 @@
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import formatDateTime from 'Utilities/Date/formatDateTime';
|
import formatDateTime from 'Utilities/Date/formatDateTime';
|
||||||
import getRelativeDate from 'Utilities/Date/getRelativeDate';
|
import getRelativeDate from 'Utilities/Date/getRelativeDate';
|
||||||
import TableRowCell from './TableRowCell';
|
import TableRowCell from './TableRowCell';
|
||||||
import styles from './RelativeDateCell.css';
|
import styles from './RelativeDateCell.css';
|
||||||
|
|
||||||
function RelativeDateCell(props) {
|
class RelativeDateCell extends PureComponent {
|
||||||
const {
|
|
||||||
className,
|
//
|
||||||
date,
|
// Render
|
||||||
includeSeconds,
|
|
||||||
showRelativeDates,
|
render() {
|
||||||
shortDateFormat,
|
const {
|
||||||
longDateFormat,
|
className,
|
||||||
timeFormat,
|
date,
|
||||||
component: Component,
|
includeSeconds,
|
||||||
dispatch,
|
showRelativeDates,
|
||||||
...otherProps
|
shortDateFormat,
|
||||||
} = props;
|
longDateFormat,
|
||||||
|
timeFormat,
|
||||||
|
component: Component,
|
||||||
|
dispatch,
|
||||||
|
...otherProps
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
if (!date) {
|
||||||
|
return (
|
||||||
|
<Component
|
||||||
|
className={className}
|
||||||
|
{...otherProps}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (!date) {
|
|
||||||
return (
|
return (
|
||||||
<Component
|
<Component
|
||||||
className={className}
|
className={className}
|
||||||
|
title={formatDateTime(date, longDateFormat, timeFormat, { includeSeconds, includeRelativeDay: !showRelativeDates })}
|
||||||
{...otherProps}
|
{...otherProps}
|
||||||
/>
|
>
|
||||||
|
{getRelativeDate(date, shortDateFormat, showRelativeDates, { timeFormat, includeSeconds, timeForToday: true })}
|
||||||
|
</Component>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
|
||||||
<Component
|
|
||||||
className={className}
|
|
||||||
title={formatDateTime(date, longDateFormat, timeFormat, { includeSeconds, includeRelativeDay: !showRelativeDates })}
|
|
||||||
{...otherProps}
|
|
||||||
>
|
|
||||||
{getRelativeDate(date, shortDateFormat, showRelativeDates, { timeFormat, includeSeconds, timeForToday: true })}
|
|
||||||
</Component>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RelativeDateCell.propTypes = {
|
RelativeDateCell.propTypes = {
|
||||||
|
|
Loading…
Reference in New Issue