2019-02-18 13:06:27 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Trans, withNamespaces } from 'react-i18next';
|
|
|
|
import isAfter from 'date-fns/is_after';
|
|
|
|
import addDays from 'date-fns/add_days';
|
|
|
|
|
|
|
|
import Topline from './Topline';
|
|
|
|
import { EMPTY_DATE } from '../../helpers/constants';
|
|
|
|
|
|
|
|
const EncryptionTopline = (props) => {
|
2019-02-21 12:39:15 +00:00
|
|
|
if (props.notAfter === EMPTY_DATE) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const isAboutExpire = isAfter(addDays(Date.now(), 30), props.notAfter);
|
|
|
|
const isExpired = isAfter(Date.now(), props.notAfter);
|
2019-02-18 13:06:27 +00:00
|
|
|
|
2019-02-21 12:39:15 +00:00
|
|
|
if (isExpired) {
|
|
|
|
return (
|
|
|
|
<Topline type="danger">
|
|
|
|
<Trans components={[<a href="#settings" key="0">link</a>]}>
|
|
|
|
topline_expired_certificate
|
|
|
|
</Trans>
|
|
|
|
</Topline>
|
|
|
|
);
|
|
|
|
} else if (isAboutExpire) {
|
|
|
|
return (
|
|
|
|
<Topline type="warning">
|
|
|
|
<Trans components={[<a href="#settings" key="0">link</a>]}>
|
|
|
|
topline_expiring_certificate
|
|
|
|
</Trans>
|
|
|
|
</Topline>
|
|
|
|
);
|
2019-02-18 13:06:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
EncryptionTopline.propTypes = {
|
|
|
|
notAfter: PropTypes.string.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default withNamespaces()(EncryptionTopline);
|