2020-01-28 13:08:35 -05:00
|
|
|
import Cookies from 'js-cookie';
|
|
|
|
|
|
|
|
const handleOnDismiss = ({ currentTarget }) => {
|
|
|
|
currentTarget.removeEventListener('click', handleOnDismiss);
|
|
|
|
const {
|
2020-04-28 08:09:44 -04:00
|
|
|
dataset: { id, expireDate },
|
2020-01-28 13:08:35 -05:00
|
|
|
} = currentTarget;
|
|
|
|
|
2020-04-28 08:09:44 -04:00
|
|
|
Cookies.set(`hide_broadcast_message_${id}`, true, { expires: new Date(expireDate) });
|
2020-01-28 13:08:35 -05:00
|
|
|
|
|
|
|
const notification = document.querySelector(`.js-broadcast-notification-${id}`);
|
|
|
|
notification.parentNode.removeChild(notification);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default () => {
|
2020-03-04 19:07:49 -05:00
|
|
|
document
|
|
|
|
.querySelectorAll('.js-dismiss-current-broadcast-notification')
|
2020-12-23 16:10:24 -05:00
|
|
|
.forEach((dismissButton) => dismissButton.addEventListener('click', handleOnDismiss));
|
2020-01-28 13:08:35 -05:00
|
|
|
};
|