<template>
  <modal name="CancelBooking" :clickToClose="false">
    <div class="tw-text-base-primary">
      <div class="modal-header tw-flex tw-w-full tw-justify-between tw-mb-[20px]">
        <div class="t14 tw-font-bold tw-mr-[120px] md:tw-text-[20px] md:tw-mb-[10px]">
          {{ $t("Cancel Booking") }}
        </div>
        <button class="close tw-transition tw-btn-md" @click="$modal.hide('CancelBooking')"></button>
      </div>
      <div class="modal-content md:tw-items-center">
        <div class="t14 tw-mb-[20px] md:t16 md:mb-[15px]">
          {{ $t("Are you sure you want to cancel this booking?") }}
        </div>
        <div class="tw-flex tw-flex-row tw-items-start">
          <img src="@/assets/svg/Notice.svg" class="tw-mr-[6px] md:tw-mr-[12px]" />
          <div class="t12 tw-mb-[25px] tw-whitespace-normal tw-text-neutrals-400 md:t14 md:tw-mb-[40px]">
            {{ $t("ShowEasy customer service will contact you for the cancellation process,please wait patiently.") }}
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <div class="tw-flex md:tw-justify-end">
          <button class="t14 tw-bg-[#FFFFFF] tw-text-primary-1 tw-rounded-[16px] tw-px-[45px] tw-py-[10px] tw-mr-[5px]">
            {{ $t("No") }}
          </button>
          <button class="t14 hover:tw-bg-primary-3 tw-bg-primary-1 tw-text-[#FFFFFF] tw-rounded-[16px] tw-px-[45px] tw-py-[10px]"
          @click="cancelBooking()"
          >
            {{ $t("Yes") }}
          </button>
        </div>
      </div>
    </div>
  </modal>
</template>
<script>
export default {
  name: "CancelBooking",

  data() {
    return {
      
    };
  },
  props:{
    BookingOrder:{

      type: Object,

    },
  },

  methods: {
    cancelBooking(){
      this.$axios
          .post(
            `/trending/api/BookingOnline/CancelBooking?Lang=${this.$i18n.localeProperties["langQuery"]}&BookingID=${this.BookingOrder.BookingID}`
          )
          .then((response) => {
            console.log(JSON.stringify(response))
            if(response && response.data){
              this.$modal.hide('CancelBooking');
              window.location.href = '/user/booking/' + this.BookingOrder.BookingNo;
            }
        })
        .catch((error) => {
          console.log(error);
        });
    },
  }
};
</script>
<style lang="scss" scoped>
.close {
  position: absolute;
  right: 25px;
  top: 25px;
  background-image: url("~/assets/svg/close.svg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  width: 14px;
  height: 14px;

  @media (min-width: 1366px) {
    position: relative;
    right: initial;
    top: initial;
  }
}

:deep() {
  .v--modal {
    background-color: #f8f8f8 !important;
    text-align: left;
    border-radius: 16px;
    box-shadow: 0 20px 60px -2px rgb(27 33 58 / 40%);
    padding: 20px;
    max-width: max-content;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    margin: 0 auto;
    height: auto !important;
    vertical-align: middle;

    @media screen and (min-width: 768px) {
      padding: 30px;
    }
  }

  .v--modal-overlay {
    position: fixed;
    box-sizing: border-box;
    left: 0;
    top: 0;
    width: max-content;
    height: auto;
    background: rgba(0, 0, 0, 0.2);
    z-index: 999;
    opacity: 1;
  }

  .v--modal-top-right {
    display: block;
    position: fixed;
    right: 0;
    top: 0;
  }

  .v--modal-background-click {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .v--modal-box {
    margin-left: 60px;
    margin-right: 60px;

    @media (min-width: 768px) {
      margin-left: 67px;
      margin-right: 67px;
    }
  }
}
</style>
