<template>
  <div class="roomCreate">
    <div class="roomCreate-content">
      <n-upload
        action="#"
        :max="1"
        :show-file-list="false"
      >
        <n-image
          width="100%"
          height="200px"
          :preview-disabled="true"
          :src="data.erUrl"
        />
      </n-upload>
      <n-form>
        <n-form-item label="取个好名字">
          <n-input
            v-model:value="data.name"
            placeholder="输入房间名称"
          />
        </n-form-item>
      </n-form>
    </div>
    <div class="roomCreate-bar">
      <span>给房间取个名</span>
      <n-button
        type="warning"
        @click="change"
      >
        继续
      </n-button>
    </div>
  </div>
</template>

<script setup lang='ts'>
import useStore from '@/store'
import { reactive } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const store = useStore()
const data = reactive({
  erUrl: new URL('./img/2.png', import.meta.url).href,
  name: ''
})

function change() {
  router.push('/device')
  store.setRoomData({ name: 'test', id: 1 })
}
</script>
<style lang="scss" scoped>
.roomCreate {
  padding: 40px 4% 0 4%;
  min-width: 327px;
  height: 100%;

  &-content {
    height: calc(100% - 50px);
    text-align: center;
    padding: 0 5%;

    :deep(.n-upload-trigger) {
      width: 100%;
      max-width: 400px;

      &>div {
        width: 100%;
        cursor: pointer;
      }
    }
    :deep(.n-form) {
      min-width: 300px;
      max-width: 50%;
      margin: 0 auto;
    }
  }

  &-bar {
    width: 100%;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;

    :deep(.n-button) {
      --n-width: 30%;
      max-width: 200px;
      --n-border-radius: 10px;
    }
  }
}
</style>