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

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

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

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

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