<template>
  <v-container fluid>
    <LayoutBannerTop>
      <template v-slot:bloc1>{{entry.name}}</template>
      <template v-slot:bloc2>N°Siret : {{entry.siretNumber}}</template>
      <template v-slot:bloc3>{{entry.description}}</template>
    </LayoutBannerTop>
    <NuxtChild />
  </v-container>
</template>


<script lang="ts">
  import {computed, defineComponent, useContext} from '@nuxtjs/composition-api'
  import {QUERY_TYPE} from "~/types/enums";
  import {Organization} from "~/models/Organization/Organization";
  import {queryHelper} from "~/services/store/query";
  import {repositoryHelper} from "~/services/store/repository";

  export default defineComponent({
    name: 'organization',
    setup() {
      const {store} = useContext()
      const repository = repositoryHelper.getRepository(Organization)
      const query = computed(() => repository.query())
      const entry = computed(() => {
        return queryHelper.getItem(query.value, store.state.profile.organization.id)
      })
      return {
        entry
      }
    },
    async asyncData({store, $dataProvider}) {
      await $dataProvider.invoke({
        type: QUERY_TYPE.MODEL,
        model: Organization,
        id: store.state.profile.organization.id
      })
    }
  })

</script>
