<template>
  <company-block
    title="company_add__title_card"
    btnText="company_add__btn"
    @update="addCompany"
  />
</template>

<script setup lang="ts">
  import { useRouter } from 'vue-router'
  import companyBlock from 'components/companyBlock.vue'
  import { useCompaniesStore } from 'stores/companies'
  import type { CompanyParams } from 'types/Company'

  const router = useRouter()
  const companiesStore = useCompaniesStore()

  async function addCompany(companyData: CompanyParams) {
    await companiesStore.add(companyData)
    router.go(-1)
  }

</script>
