You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
106 lines
3.0 KiB
106 lines
3.0 KiB
4 years ago
|
import React, { useState } from 'react';
|
||
|
import classnames from 'classnames';
|
||
|
import PropTypes from 'prop-types';
|
||
|
import Button from '../../ui/button';
|
||
|
import Checkbox from '../../ui/check-box';
|
||
|
import Tooltip from '../../ui/tooltip';
|
||
5 years ago
|
|
||
4 years ago
|
const HomeNotification = ({
|
||
|
acceptText,
|
||
4 years ago
|
checkboxText,
|
||
|
checkboxTooltipText,
|
||
4 years ago
|
classNames = [],
|
||
|
descriptionText,
|
||
|
ignoreText,
|
||
|
infoText,
|
||
|
onAccept,
|
||
|
onIgnore,
|
||
|
}) => {
|
||
4 years ago
|
const [checkboxState, setCheckBoxState] = useState(false);
|
||
4 years ago
|
|
||
|
const checkboxElement = checkboxText && (
|
||
|
<Checkbox
|
||
|
id="homeNotification_checkbox"
|
||
|
checked={checkboxState}
|
||
|
className="home-notification__checkbox"
|
||
|
onClick={() => setCheckBoxState((checked) => !checked)}
|
||
|
/>
|
||
4 years ago
|
);
|
||
4 years ago
|
|
||
4 years ago
|
return (
|
||
|
<div className={classnames('home-notification', ...classNames)}>
|
||
|
<div className="home-notification__content">
|
||
|
<div className="home-notification__content-container">
|
||
|
<div className="home-notification__text">{descriptionText}</div>
|
||
5 years ago
|
</div>
|
||
4 years ago
|
{infoText ? (
|
||
|
<Tooltip
|
||
|
position="top"
|
||
|
title={infoText}
|
||
|
wrapperClassName="home-notification__tooltip-wrapper"
|
||
|
>
|
||
|
<i className="fa fa-info-circle" />
|
||
|
</Tooltip>
|
||
|
) : null}
|
||
|
</div>
|
||
|
<div className="home-notification__buttons">
|
||
|
{onAccept && acceptText ? (
|
||
|
<Button
|
||
|
type="primary"
|
||
|
className="home-notification__accept-button"
|
||
|
onClick={onAccept}
|
||
|
>
|
||
|
{acceptText}
|
||
|
</Button>
|
||
|
) : null}
|
||
|
{onIgnore && ignoreText ? (
|
||
|
<Button
|
||
|
type="secondary"
|
||
|
className="home-notification__ignore-button"
|
||
4 years ago
|
// Some onIgnore handlers use the checkboxState to determine whether
|
||
|
// to disable the notification
|
||
|
onClick={() => onIgnore(checkboxState)}
|
||
4 years ago
|
>
|
||
|
{ignoreText}
|
||
|
</Button>
|
||
|
) : null}
|
||
4 years ago
|
{checkboxText ? (
|
||
|
<div className="home-notification__checkbox-wrapper">
|
||
|
{checkboxTooltipText ? (
|
||
|
<Tooltip
|
||
|
position="top"
|
||
|
title={checkboxTooltipText}
|
||
|
wrapperClassName="home-notification__checkbox-label-tooltip"
|
||
|
>
|
||
|
{checkboxElement}
|
||
|
</Tooltip>
|
||
|
) : (
|
||
|
checkboxElement
|
||
|
)}
|
||
|
<label
|
||
|
className="home-notification__checkbox-label"
|
||
|
htmlFor="homeNotification_checkbox"
|
||
|
>
|
||
|
{checkboxText}
|
||
|
</label>
|
||
|
</div>
|
||
|
) : null}
|
||
5 years ago
|
</div>
|
||
4 years ago
|
</div>
|
||
4 years ago
|
);
|
||
|
};
|
||
4 years ago
|
|
||
|
HomeNotification.propTypes = {
|
||
|
acceptText: PropTypes.node,
|
||
4 years ago
|
checkboxText: PropTypes.node,
|
||
|
checkboxTooltipText: PropTypes.node,
|
||
4 years ago
|
classNames: PropTypes.array,
|
||
|
descriptionText: PropTypes.node.isRequired,
|
||
|
ignoreText: PropTypes.node,
|
||
|
infoText: PropTypes.node,
|
||
|
onAccept: PropTypes.func,
|
||
|
onIgnore: PropTypes.func,
|
||
4 years ago
|
};
|
||
4 years ago
|
|
||
4 years ago
|
export default HomeNotification;
|