<script setup lang="ts">
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="New Project"
      description="Create a new project"
    />

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