import FileManager from '@components/FileManager/index.vue';
import BaseButton from '@elements/BaseButton/index.vue';
import BaseSelect from '@elements/BaseSelect/index.vue';


export default {
  name: 'BaseInputFile',
  components: {
    FileManager,
    BaseButton,
    BaseSelect,
  },
  props: {
    name: String,
    label: String,
    description: String,
    options: Object,
    optionValue: Number,
    thumbnail: {
      type: String,
      default: '',
    },
    error: {
      type: String,
      default: '',
    },
    maxWidth: {
      type: Number | String,
    },
    maxHeight: {
      type: Number | String,
    },
    minWidth: {
      type: Number | String,
    },
    minHeight: {
      type: Number | String,
    },
    square: {
      type: Boolean,
      default: false,
    },
    value: {
      type: String,
      default: '',
    },
    extensions: {
      type: Array,
      default: () => ['jpg', 'jpeg', 'png', 'pdf'],
    },
  },
  data() {
    return {
      open: false,
      noImage: '',
      file: {},
    };
  },
  created() {
    const { no_image } = JSON.parse(document.body.dataset.globals);
    this.noImage = no_image;
  },
  methods: {
    onSelectedFile(file) {
      file.value = 'data/' + file.file;
      this.file = file;
      this.$emit('change', this.file);
    },
    onRemoveFile() {
      this.file = {};
      this.$emit('change', {});
    },
    changeOption(value){
      this.$emit('change_select',value);
    },
  },
};
