<template>
    <div class="modal">
      <div class="modal-content">
        <h3>휴가 추가</h3>
        <input type="text" v-model="title" placeholder="제목" />
        <input type="date" v-model="date" />
        <button @click="addEvent">추가</button>
        <button @click="$emit('close')">닫기</button>
      </div>
    </div>
  </template>

  <script>
  import calendarStore from '@s/calendarStore';

  export default {
    data() {
      return {
        title: '',
        date: '',
      };
    },
    methods: {
      addEvent() {
        if (this.title && this.date) {
          calendarStore.addEvent({ title: this.title, start: this.date });
          this.$emit('close');
        } else {
          alert('모든 필드를 입력해주세요.');
        }
      },
    },
  };
  </script>

  <style scoped>
  .modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
  }
  .modal-content {
    background: white;
    padding: 20px;
    border-radius: 5px;
    width: 300px;
    text-align: center;
  }
  </style>
