<template>
  <a-form-item :label="$t('scene.nameLabel1')" required>
    <a-input
      :value="data.name"
      name="radioGroup"
      :placeholder="$t('scene.nameLabel1Rule', { max: 40 })"
      :maxlength="40"
      @update:value="name => $emit('update:data', { ...data, name })"
    />
  </a-form-item>
  <a-form-item :label="$t('scene.fileLabel')" required>
    <Upload
      :disabled="update"
      :file="data.file"
      :max-size="5 * 1024"
      :extnames="['ifc', 'fbx']"
      @update:file="file => $emit('update:data', { ...data, file })"
    />
  </a-form-item>
</template>

<script setup lang="ts">
import Upload from '@/components/upload/index.vue'
import { BimUploadData } from '@/store'

import type { BUploadProps } from '@/components/upload/index.vue'

export type UploadData = Pick<BUploadProps, 'file'> &
  Omit<BimUploadData, 'file'>

defineOptions<{ name: 'project-bim-upload' }>()

defineProps<{ data: UploadData; update?: boolean }>()
defineEmits<{ (e: 'update:data', value: UploadData): void }>()
</script>
