<!-- 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 {store} = useContext()
    const {createItem} = new UseDataUtils().invoke()
    const {create, loading, item} = createItem()

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

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