jQuery("body").on("click", '#flex-travel-welcome-notice .notice-dismiss', function (event) {
    event.preventDefault();

    console.log("close clicked");

    jQuery.ajax({
      type: 'POST',
      url: ajaxurl,
      data: {
          action: 'flex_travel_dismissed_notice',
      },
      success: function () {
          // Remove the notice on success
          $('.notice[data-notice="example"]').remove();
      }
    });
  }
)

//Coupon Code
document.addEventListener('DOMContentLoaded', function () {
    const flex_travel_couponBtn = document.getElementById('copyCouponBtn');
    const flex_travel_tooltip = document.getElementById('copyTooltip');

    flex_travel_couponBtn.addEventListener('click', function (e) {
        navigator.clipboard.writeText('FLEXPRO').then(function () {

            flex_travel_tooltip.style.left = (e.clientX + 10) + 'px';
            flex_travel_tooltip.style.top = (e.clientY + 10) + 'px';
            flex_travel_tooltip.style.display = 'block';

            setTimeout(function () {
                flex_travel_tooltip.style.display = 'none';
            }, 1500);
        });
    });
});