2019-02-18 13:06:27 +00:00
|
|
|
import React from 'react';
|
2020-08-13 08:15:45 +00:00
|
|
|
import { Trans } from 'react-i18next';
|
2019-02-18 13:06:27 +00:00
|
|
|
import isAfter from 'date-fns/is_after';
|
|
|
|
|
import addDays from 'date-fns/add_days';
|
2020-08-13 08:15:45 +00:00
|
|
|
import { useSelector } from 'react-redux';
|
2019-02-18 13:06:27 +00:00
|
|
|
import Topline from './Topline';
|
|
|
|
|
import { EMPTY_DATE } from '../../helpers/constants';
|
|
|
|
|
|
2020-08-13 08:15:45 +00:00
|
|
|
const EncryptionTopline = () => {
|
|
|
|
|
const not_after = useSelector((state) => state.encryption.not_after);
|
|
|
|
|
|
|
|
|
|
if (not_after === EMPTY_DATE) {
|
|
|
|
|
return null;
|
2019-02-21 12:39:15 +00:00
|
|
|
}
|
|
|
|
|
|
2020-08-13 08:15:45 +00:00
|
|
|
const isAboutExpire = isAfter(addDays(Date.now(), 30), not_after);
|
|
|
|
|
const isExpired = isAfter(Date.now(), not_after);
|
2019-02-18 13:06:27 +00:00
|
|
|
|
2019-02-21 12:39:15 +00:00
|
|
|
if (isExpired) {
|
|
|
|
|
return (
|
|
|
|
|
<Topline type="danger">
|
2019-06-06 18:06:19 +00:00
|
|
|
<Trans components={[<a href="#encryption" key="0">link</a>]}>
|
2019-02-21 12:39:15 +00:00
|
|
|
topline_expired_certificate
|
|
|
|
|
</Trans>
|
|
|
|
|
</Topline>
|
|
|
|
|
);
|
2020-08-13 08:15:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isAboutExpire) {
|
2019-02-21 12:39:15 +00:00
|
|
|
return (
|
|
|
|
|
<Topline type="warning">
|
2019-06-06 18:06:19 +00:00
|
|
|
<Trans components={[<a href="#encryption" key="0">link</a>]}>
|
2019-02-21 12:39:15 +00:00
|
|
|
topline_expiring_certificate
|
|
|
|
|
</Trans>
|
|
|
|
|
</Topline>
|
|
|
|
|
);
|
2019-02-18 13:06:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
|
2020-08-13 08:15:45 +00:00
|
|
|
export default EncryptionTopline;
|