<template>
  <div>
    <div class="row">
      <div id="bc-graph" class="col-sm-12 col-md-6 mb-4">
        <lp-graph></lp-graph>
      </div>
      <div id="bc-buy-sell" class="col-sm-12 col-md-6">
      <!-- <div id="bc-buy-sell" class="col-sm-12 col-md-8 offset-md-2"> -->
        <div class="row">
          <div class="col-12">
            <div class="card text-bg-light mb-2">
              <div class="card-body">
                <div class="row d-flex justify-content-around">
                  <div class="col-6">
                    <button id="buy-btn" :class="isBuy ? 'btn-meta-1' : 'btn-meta-2'" class="btn w-100" type="button"
                            @click="rotateBuySell($event)">{{
                        $t(i18nConst.bondingBuy)
                      }}
                    </button>
                  </div>
                  <div class="col-6">
                    <button id="sell-btn" :class="!isBuy ? 'btn-meta-1' : 'btn-meta-2'" class="btn w-100" type="button"
                            @click="rotateBuySell($event)">{{
                        $t(i18nConst.bondingSell)
                      }}
                    </button>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div :class="{ 'rotate-buy': isBuy, 'rotate-sell': !isBuy }" class="flip-card-inner container">
          
          <lp-buy v-if="isBuy" class="bc-buy" style="z-index:-1"></lp-buy>
          
          <lp-sell v-else class="bc-sell" style="z-index:-1" :governanceToken="governanceToken" :reserveToken="reserveToken"></lp-sell>
        </div>
      </div>
    </div>
    <vesting></vesting>
  </div>
</template>

<script>
import LpBuy from '../components/liquidityPool/LpBuy.vue';
import LpSell from '../components/liquidityPool/LpSell.vue';
import LpGraph from '../components/liquidityPool/LpGraph.vue';
import Vesting from "../components/bonding/vesting/Vesting.vue";
import i18nConstantes from "@/constantes/i18n.constantes.js";
import constantes from "@/constantes/constantes.js";

export default {
  data() {
    return {
      i18nConst: i18nConstantes,
      constantes: constantes,
      reserveToken: 'USDC',
      governanceToken: 'METADEXDAO',
      isBuy: true
    }
  },
  components: {
    Vesting,
    LpBuy,
    LpSell,
    LpGraph
  },
  methods: {
    rotateBuySell(event) {
      this.isBuy = event.target.id === 'buy-btn' ? true : false;
    }
  },
  mounted() {
  }
};
</script>

<style>
.card-bc-item {
  padding: 0.8rem;
  border-radius: 0.3rem;
}

.card-bc-item:hover {
  background-color: var(--grey-custom);
}

.flip-card-inner {
  position: relative;
  transition: transform 0.5s;
  transform-style: preserve-3d;
}

.rotate-sell {
  transform: rotateY(180deg);
  padding: unset;
  margin-left: -0.7rem;
  margin-bottom: 1rem;
}

.rotate-buy {
  transform: rotateY(0);
  padding: unset;
  margin-left: 0.7rem;
  margin-bottom: 1rem;
}

.bc-buy,
.bc-sell {
  /*position: absolute;*/
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  /* Safari */
  backface-visibility: hidden;
}

.bc-sell {
  transform: rotateY(180deg);
}


#bc-buy-sell {
  perspective: 1000px;
}

.bonding-offline-title {
  margin: 2rem;
  text-align: center;
}
</style>