<template>
  <Modal :isModalOpen="true" @modal:close="() => zoneEditorStore.toggleSettingsModal()" :modal-width="300" :modal-height="370" :is-resizable="false">
    <template #modalHeader>
      <h3 class="m-0 font-medium shrink-0">Zone settings</h3>
    </template>

    <template #modalBody>
      <div class="settings m-[15px]">
        <form method="post" @submit.prevent="" class="inline">
          <div class="gap-2.5 flex flex-wrap">
            <div class="w-full flex flex-col mb-5">
              <label class="mb-1.5 font-titles" for="name">Name</label>
              <input class="input-cyan max-w-[250px]" v-model="name" name="name" id="name" />
            </div>
            <div class="w-[48%] flex flex-col mb-5">
              <label class="mb-1.5 font-titles" for="name">Width</label>
              <input class="input-cyan max-w-[250px]" v-model="width" name="name" id="name" type="number" />
            </div>
            <div class="w-[48%] flex flex-col mb-5">
              <label class="mb-1.5 font-titles" for="name">Height</label>
              <input class="input-cyan max-w-[250px]" v-model="height" name="name" id="name" type="number" />
            </div>
            <div class="w-full flex flex-col mb-5">
              <label class="mb-1.5 font-titles" for="name">PVP enabled</label>
              <input class="input-cyan max-w-[250px]" name="name" id="name" />
            </div>
          </div>
        </form>
      </div>
    </template>
  </Modal>
</template>

<script setup>
import { ref, watch } from 'vue'
import Modal from '@/components/utilities/Modal.vue'
import { useZoneEditorStore } from '@/stores/zoneEditor'

const zoneEditorStore = useZoneEditorStore()

const name = ref(zoneEditorStore.name)
const width = ref(zoneEditorStore.width)
const height = ref(zoneEditorStore.height)

watch(name, (value) => {
  zoneEditorStore.setName(value)
})

watch(width, (value) => {
  zoneEditorStore.setWidth(parseInt(value))
})

watch(height, (value) => {
  zoneEditorStore.setHeight(parseInt(value))
})
</script>