<template>
  <div v-if="common.active === 'info'" class="row q-pa-md justify-center">
    <div class="col-12 max-1280-width flex">
      <FormGeneratorWrapper :model="model" :schema="schemaModel" />
    </div>
  </div>
</template>

<script lang="ts">
// @ts-nocheck
import FormGeneratorWrapper from '@components/common/node-generator/FormGeneratorWrapper.vue';
import { Component, Prop, Vue, Watch } from 'vue-property-decorator';
import cloneDeep from 'lodash/cloneDeep';
import get from 'lodash/get';

@Component({
  components: {
    FormGeneratorWrapper,
  },
})
export default class Info extends Vue {
  @Prop({}) common;
  @Prop({}) model;

  schemaModel: any = {};

  get card() {
    return this.$store.getters['registryService/services/servicesCard'];
  }

  get document() {
    const documentArr = get(this.card, 'documents');
    for (let i = 0; i <= documentArr.length; i++) {
      console.log(i, documentArr.length);
      if (documentArr[i].recruitInfoForm) {
        return documentArr[i].form[0];
      }
    }

    return {};
  }

  @Watch('model')
  changeModel(): void {
    this.setSchemaModel();
  }

  async setSchemaModel() {
    if (!this.model) {
      this.schemaModel = {};
    }

    this.schemaModel = cloneDeep(this.document);
  }
}
</script>

<style lang="scss" scoped></style>
