<script setup lang="ts">
const { t } = useI18n();

definePageMeta({
  title: "New Project",
});

const router = useRouter();
const { createProject } = useProjectApi();
const saving = ref(false);

async function handleSubmit(body: { name: string; description?: string; status: string }) {
  saving.value = true;
  const project = await createProject(body);
  saving.value = false;
  if (project) router.push("/projects");
}
</script>

<template>
  <UPage>
    <UPageHeader
      :title="t('projects.create')"
      :description="t('projects.createDescription')"
    />

    <UPageBody>
      <UCard>
        <ProjectForm
          :saving
          @submit="handleSubmit"
        />
      </UCard>
    </UPageBody>
  </UPage>
</template>
