<template>
  <Page :fetched-data="fetchedData" :image-data="image">
    <template #extra-fields>
      <section class="main-section">
        <div>
          <BaseText class="input-title-advanced-settings">
            {{ $_tr('pAndPBackground.title') }}
          </BaseText>

          <AdvancedSettingsInputDropzone
            :default-value="fetchedData.homepage.p_and_p_background"
            :extra-options="{ acceptedFiles: '.png,.jpg,.jpeg,.svg' }"
            model-name="p_and_p_background"
            form-id="advanced-settings-homepage"
            @onImageUpdate="handleDataImageChange"
          />
        </div>
      </section>
    </template>
  </Page>
</template>

<script>
import { BaseText } from 'inside-collection/atoms'

import Page from '@inside-administration/components/pages/advanced-settings/AdminAdvancedSettingsHomePage'
import AdvancedSettingsInputDropzone from '@inside-administration/components/lib/advanced-settings/AdvancedSettingsInputDropzone'

export default {
  name: 'AdminAdvancedSettingsHomePage',
  $_i18nRootPath:
    'administration.PAGES.ADVANCED_SETTINGS.adminAdvancedSettingsHomePage',
  components: {
    BaseText,
    Page,
    AdvancedSettingsInputDropzone
  },
  props: {
    fetchedData: {
      type: Object
    }
  },
  data() {
    return {
      image: {}
    }
  },
  methods: {
    handleDataImageChange(data) {
      this.image = { ...this.image, ...data }
    }
  }
}
</script>
