export default function NotificationsInit() {
  const notificationsContainer = document.querySelector('.homegrade-notifications');

  if (!notificationsContainer) return;
  const notifications = notificationsContainer.querySelectorAll('.notification');

  notifications.forEach((notification) => {
    const notificationClose = notification.querySelector('.notification__close');
    const notificationId = notification.getAttribute('data-notification-id');

    notificationClose.addEventListener('click', () => {
      notification.classList.add('notification--dismissed');
      const thirtyDays = 30 * 86400;
      document.cookie = `${notificationId}=dismissed; path=/; max-age=${thirtyDays}`;
    });
  });
}
