<template>
  <Page :fetched-data="fetchedData" :image-data="image">
    <template #extra-fields>
      <section class="main-section">
        <Title tag="h4"> {{ $_tr('blockImage.title') }} </Title>

        <InputText
          :label="$_tr('blockImage.blockImageLink.label')"
          :default-value="fetchedData.homepage.blockImageLink"
          :form-id="formId"
          model-name="blockImageLink"
          class="input-advanced-settings"
        />

        <div class="mt-m">
          <BaseText>
            {{ $_tr('blockImage.blockImageBackground.title') }}
          </BaseText>

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

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

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

import InputText from '@inside-forms/displays/sub-components/fields/InputText'

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

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