<template>
  <project-block
    title="project_create__title_card"
    btnText="project_create__btn"
    @update="addProject"
  />
</template>

<script setup lang="ts">
  import { useRouter } from 'vue-router'
  import projectBlock from 'components/projectBlock.vue'
  import { useProjectsStore } from 'stores/projects'
  import type { ProjectParams } from 'types/Project'

  const router = useRouter()
  const projectsStore = useProjectsStore()

  async function addProject (projectData: ProjectParams) {
    const newDataProject = await projectsStore.add(projectData)
    await router.replace({ name: 'chats', params: { id: newDataProject.id }})
  }

</script>
