<template>
  <div>
    <div class="sparator" />
    <div class="section-title">
      reservations
    </div>
    <div class="reservation-container">
      <el-form-item
        label-width="155px"
        style="height: 40px; margin-right: 66px"
        label="Enable Reservation"
        :rules="[{ required: true,  trigger: 'blur',}]">
        <el-switch
          :value="enable"
          @change="enableChange" />
      </el-form-item>
      <el-form-item
        label-width="100px"
        :rules="[{ required: true,  trigger: 'blur',}]"
        label="Time Limit">
        <el-select
          :disabled="!enable"
          class="reservation-time-limit-select"
          :value="timeLimit"
          @change="limitTimeChange"
          placeholder="">
          <el-option 
            v-for="option in reservationTimeLimitOptions"
            :label="option.lable"
            :value="option.value"
            :key="option.lable"
          />
        </el-select>
        <span class="reservation-time-limit-unit">
          Minutes
        </span>
      </el-form-item>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Reservation',
  props: {
    enable: {
      type: Boolean,
      default: true,
    },
    timeLimit: {
      type: Number,
      default: 15,
    }
  },
  data() {
    return {
      reservationTimeLimitOptions: [
        {
          value: 15,
          lable: "15"
        },
        {
          value: 30,
          lable: "30"
        },
        {
          value: 45,
          lable: "45"
        },
        {
          value: 60,
          lable: "60"
        }
      ],
    }
  },
  methods: {
    limitTimeChange (limitTime) {
      this.$emit('time-limit-change', limitTime)
    },
    enableChange (enable) {
      this.$emit('enable', enable)
    }
  },
}
</script>

<style scoped lang='scss'>

  .sparator {
    margin: 10px -40px;
    height: 2px;
    background-color: #F0F5FC;
  }

  .section-title {
    color: #333333;
    margin-top: 20px;
    margin-bottom: 30px;
    font-size: 16px;
    line-height: 24px;
    font-weight: 500;
    font-family: sans-serif;
    text-transform: uppercase;
  }

  .reservation-container {
    display: flex;
    align-items: center;
  }

  .reservation-time-limit-select {
    width: 134px;
  }

  .reservation-time-limit-unit {
    font-family: sans-serif;
    font-style: normal;
    font-weight: 500;
    font-size: 14px;
    line-height: 21px;
    text-transform: capitalize;
    color: #434343;
    padding-left: 10px;
  }

  @media screen and (max-width: 851px) {
    .reservation-container {
      flex-wrap: wrap;
    }
  }

</style>