import { InobyModule } from "@lib/inoby-module";
import * as $ from "jquery";

class GiftCardCheckout extends InobyModule {
  private allowedTabs: number[] = [1, 2, 3];

  run() {
    $("#wc_gc_cart_redeem_form").hide();
    $(document).on("click", ".add_gift_card_form h4", (_, target) => {
      $("#wc_gc_cart_redeem_form").slideToggle(400, "swing");
    });
    $(document.body).on("tab.change.before", (_, { oldTab, newTab }) => {
      let tab: number = newTab.split("-")[1];
      if (this.allowedTabs.find((t) => t == tab)) {
        $(".add_gift_card_form").slideDown(400, "swing");
      } else {
        $(".add_gift_card_form").slideUp(400, "swing");
      }
    });
  }
}

new GiftCardCheckout().runOnReady();
