From ed9e80af299e11c96cd0e0184a1154afb3068ea3 Mon Sep 17 00:00:00 2001 From: DomWane Date: Tue, 1 Oct 2024 13:59:25 +0200 Subject: [PATCH] fix: validations --- components/Project/Create/Categories/BasicInfo.vue | 4 ++-- pages/project/[id]/edit.vue | 8 ++++---- pages/project/create.vue | 13 +++++++------ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/components/Project/Create/Categories/BasicInfo.vue b/components/Project/Create/Categories/BasicInfo.vue index 7aa0045..54bb655 100644 --- a/components/Project/Create/Categories/BasicInfo.vue +++ b/components/Project/Create/Categories/BasicInfo.vue @@ -38,8 +38,8 @@ resetForm({ }, }) -function isFormValid() { - validate() +async function isFormValid() { + await validate() if (meta.value.valid) { return true diff --git a/pages/project/[id]/edit.vue b/pages/project/[id]/edit.vue index 6899139..d6b85ac 100644 --- a/pages/project/[id]/edit.vue +++ b/pages/project/[id]/edit.vue @@ -108,7 +108,7 @@ async function next() { return if (selectedTab.value === 'basic_info') { - if (!currentComponent.value.isFormValid()) + if (!(await currentComponent.value.isFormValid())) return else save() } @@ -122,7 +122,7 @@ async function next() { async function publish() { if (selectedTab.value === 'basic_info') { - if (!currentComponent.value.isFormValid()) + if (!(await currentComponent.value.isFormValid())) return else save() } @@ -136,9 +136,9 @@ async function publish() { navigateTo(`/project/${project.value?.id || project.value?.name?.toLowerCase().replace(/\s+/g, '-')}`) } -function jumpTo(tab: string) { +async function jumpTo(tab: string) { if (selectedTab.value === 'basic_info') { - if (!currentComponent.value.isFormValid()) + if (!(await currentComponent.value.isFormValid())) return else save() } diff --git a/pages/project/create.vue b/pages/project/create.vue index fbadc91..f0b223a 100644 --- a/pages/project/create.vue +++ b/pages/project/create.vue @@ -89,9 +89,9 @@ function save() { }) } -function next() { +async function next() { if (selectedTab.value === 'basic_info') { - if (!currentComponent.value.isFormValid()) + if (!(await currentComponent.value.isFormValid())) return else save() } @@ -105,7 +105,7 @@ function next() { async function publish() { if (selectedTab.value === 'basic_info') { - if (!currentComponent.value.isFormValid()) + if (!(await currentComponent.value.isFormValid())) return else save() } @@ -119,9 +119,10 @@ async function publish() { navigateTo('/') } -function jumpTo(tab: string) { +async function jumpTo(tab: string) { + console.log(tab, selectedTab.value) if (selectedTab.value === 'basic_info') { - if (!currentComponent.value.isFormValid()) + if (!(await currentComponent.value.isFormValid())) return else save() } @@ -273,7 +274,7 @@ const transitionDone = ref(false) pb-8px leading-40px :class="selectedTab === tab.value ? 'font-bold border-b-4 border-app-white' : ''" - @click="selectedTab = tab.value" + @click="jumpTo(tab.value)" > {{ tab.label }}