<script>
import DefaultModal from '@inside-library/components/modals/default/DefaultModal'

import JobsModalHeaderCustoms from './sub-components/JobsModalHeaderCustoms'

import { http } from '@inside-library/helpers/Http'

export default {
  name: 'jobs-modal',
  extends: DefaultModal,
  $_i18nRootPath: 'customs.JOBS.MODAL',
  data() {
    return {
      selection: {
        uuid: 'uuid',
        title: 'title',
        start: 'published_at',
        location: 'locations.title',
        content: 'content'
      }
    }
  },
  async beforeMount() {
    await http.post(
      `statistics/modal/viewed/${this.heritedData.content_type}/${this.heritedData.uuid}`
    )
  },
  methods: {
    scaffold(fields) {
      return {
        title: fields.title,
        sections: [
          {
            fields: [
              {
                tag: JobsModalHeaderCustoms,
                data: {
                  start: fields.start.toString(),
                  location: fields.location
                }
              },
              {
                class: 'default-text',
                tag: 'paragraph-listing',
                data: {
                  heritedData: fields.content,
                  heritedOptions: { template: true }
                }
              }
            ]
          }
        ]
      }
    }
  }
}
</script>

<style lang="scss">
div.jobs-modal {
  .modal__body > * {
    max-width: 544px;
    margin: 0 auto;
  }
}
</style>
