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

    <template #modalBody>
      <div class="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.zone?.name)
const width = ref(zoneEditorStore.zone?.width)
const height = ref(zoneEditorStore.zone?.height)

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

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

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