<!-- Page de détails d'une adresse postale -->
<template>
  <main>
    <v-skeleton-loader
      v-if="loading"
      type="text"
    />
    <FormOrganizationAddress :id="item.id" v-else></FormOrganizationAddress>
  </main>
</template>

<script lang="ts">
import {defineComponent, useContext} from '@nuxtjs/composition-api'
import { OrganizationAddressPostal } from '~/models/Organization/OrganizationAddressPostal'
import {AddressPostal} from "~/models/Core/AddressPostal";
import {useDataUtils} from "~/composables/data/useDataUtils";

export default defineComponent({
  name: 'NewOrganizationAddress',
  setup () {
    const {$dataProvider, store} = useContext()
    const {createItem} = useDataUtils($dataProvider)
    const {create, loading, item} = createItem(store, OrganizationAddressPostal)

    if(process.client){
      const itemToCreate: OrganizationAddressPostal = new OrganizationAddressPostal({addressPostal: new AddressPostal()})
      create(itemToCreate)
    }

    return {
      loading,
      item
    }
  }
})
</script>
