<template>
  <div>
    <div class="shadow">
      <b-button class="btn1" @click="addEvent">
        <b-icon-calendar-plus></b-icon-calendar-plus> 新增事件
      </b-button>
      <b-button class="btn">
        <b-icon-list-check></b-icon-list-check> 匯出月報
      </b-button>
    </div>
    <modal
      :isOpen="AddEventModalOpen"
      title="新增事件"
      @closeEvent="AddEventModalOpen = false"
    >
      <addEvent @closeEvent="closeEvent" />
    </modal>
  </div>
</template>
<script>
import { mapActions, mapState } from 'vuex'
import addEvent from '@/views/Calendar/ModalContent/addEvent.vue'

export default {
  data () {
    return {
      AddEventModalOpen: false
    }
  },
  methods: {
    ...mapActions('schedule', ['initSchedule']),
    async addEvent () { // 新增事件
      this.AddEventModalOpen = true
      await this.initSchedule()
    },
    closeEvent () {
      this.AddEventModalOpen = false
      this.$emit('addEvent')
    }
  },
  computed: {
    ...mapState({
      schedule: state => state.schedule.Schedule
    })
  },
  components: {
    modal: () => import('@/views/Modal/index.vue'),
    addEvent
  }
}
</script>
<style scoped>
.shadow {
  background-color: #ffff;
  height: 65px;
  width: 100%;
  box-shadow: 2px 2px 20px rgba(0, 0, 0, 40);
  position: fixed;
  top: 55px;
  z-index: 500;
}
.btn {
  background-color: white;
  font-size: 16px;
  margin-top: 15px;
  margin-left: 15px;
  padding-left: 7px;
  padding-right: 7px;
  padding-top: 5px;
  padding-bottom: 5px;
  color: #383838;
  box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
  border: none;
}
.btn:hover {
  color: black;
  background-color: rgb(228, 228, 228);
}
.btn1 {
  background-color: rgb(75, 102, 255);
  font-size: 16px;
  margin-top: 15px;
  margin-left: 15px;
  padding-left: 7px;
  padding-right: 7px;
  padding-top: 5px;
  padding-bottom: 5px;
  color: #ffffff;
  box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
  border: none;
}
.btn1:hover {
  color: rgb(255, 255, 255);
  background-color: rgb(49, 68, 175);
}
</style>
