<!-- 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, useContext} from '@nuxtjs/composition-api'
import {ContactPoint} from "~/models/Core/ContactPoint";
import {useDataUtils} from "~/composables/data/useDataUtils";

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

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

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