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

<script lang="ts">
import {defineComponent, useStore} from '@nuxtjs/composition-api'
import {ContactPoint} from "~/models/Core/ContactPoint";
import {UseDataUtils} from "~/use/data/useDataUtils";
import {Store} from "vuex";

export default defineComponent({
  name: 'NewContactPoint',
  setup (){
    const store:Store<any> = useStore()
    const {createItem} = new UseDataUtils().invoke()
    const {create, loading, item} = createItem()

    if(process.client){
      const itemToCreate: ContactPoint = new ContactPoint({organization:[`/api/organizations/${store.state.profile.organization.id}`]})
      create(itemToCreate, ContactPoint)
    }

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