From 3f2c1b8f0b90cd72a81640ecb49197b7cc4b3da9 Mon Sep 17 00:00:00 2001 From: Komek Hayytnazarov Date: Tue, 27 Sep 2022 10:34:46 +0500 Subject: [PATCH] profile bugs fixed --- src/components/country-dropdown/Main.vue | 5 +- src/views/profile-forms/Business.vue | 44 +++-- src/views/profile-forms/Company.vue | 235 ++++++----------------- src/views/profile/Main.vue | 161 ++++++---------- 4 files changed, 145 insertions(+), 300 deletions(-) diff --git a/src/components/country-dropdown/Main.vue b/src/components/country-dropdown/Main.vue index 39fb500..4e8e325 100644 --- a/src/components/country-dropdown/Main.vue +++ b/src/components/country-dropdown/Main.vue @@ -35,8 +35,9 @@ onBeforeMount(async () => { if (props.id) { country.value = countries.value.find((item) => item.id === +props.id); - } else { + } + /* else { country.value = countries.value.find((item) => item.code === "TM"); - } + } */ }); \ No newline at end of file diff --git a/src/views/profile-forms/Business.vue b/src/views/profile-forms/Business.vue index db20f15..faf8788 100644 --- a/src/views/profile-forms/Business.vue +++ b/src/views/profile-forms/Business.vue @@ -212,6 +212,13 @@ :id="formData.citizenship_id" @on-change="(country) => onCountryChange(country)" /> + @@ -289,6 +296,8 @@ const isLoading = ref(false); const date = ref(""); +const isCitizenshipValid = ref(true); + const formData = reactive({ surname: "", name: "", @@ -296,6 +305,11 @@ const formData = reactive({ date_of_birth: "", birth_place: "", citizenship_id: "", + citizenship: { + id : 0, + code:"", + name: "", + }, registration_address: "", }); @@ -332,31 +346,30 @@ const rules = { const validate = useVuelidate(rules, toRefs(formData)); watch(date, (currentValue, oldValue) => { - formData.date_of_birth = currentValue; + console.log("currentValue: " + currentValue) + formData.date_of_birth = $h.changeDateFormat(currentValue); }); const onCountryChange = (value) => { - console.log("onCountryChange: ", value); - formData.citizenship_id = value.id; + + isCitizenshipValid.value = true; - localStorage.removeItem("country"); - localStorage.setItem("country", value.name); + formData.citizenship = value; }; const onRegister = async () => { + console.log("onRegister"); console.log("formData.account_date: ", formData.date_of_birth); - formData.date_of_birth = $h.changeDateFormat(formData.date_of_birth); - console.log("formData: ", formData); + if (!formData.citizenship_id) { isCitizenshipValid.value = false; } + validate.value.$touch(); if (validate.value.$invalid) { console.log("invalid form: "); return; } - console.log("onRegister"); - try { isLoading.value = true; @@ -366,13 +379,11 @@ const onRegister = async () => { ); isLoading.value = false; - console.log("response onRegister: ", response); // refresh LS "entrepreneurInfo" localStorage.removeItem("profile"); localStorage.setItem("profile", JSON.stringify(formData)); - //TODO: clean up router.push({ name: "profile", params: { loadFromLS: true } }); } catch (error) { isLoading.value = false; @@ -380,20 +391,13 @@ const onRegister = async () => { }; onMounted(() => { - const params = _.isEmpty(route.params) - ? JSON.parse(localStorage.getItem("profile")) - : route.params; - - console.log("Params: ", params); + const params = JSON.parse(localStorage.getItem("profile")) if (params) { - localStorage.setItem("profile", JSON.stringify(params)); Object.assign(formData, params); date.value = $h.formatDate(formData.date_of_birth, "DD.MM.YYYY"); + formData.citizenship_id = formData.citizenship.id; } - const country = JSON.parse(localStorage.getItem("country")); - console.log("country: ", country); - formData.citizenship_id = country.id; }); \ No newline at end of file diff --git a/src/views/profile-forms/Company.vue b/src/views/profile-forms/Company.vue index b308b87..a779dce 100644 --- a/src/views/profile-forms/Company.vue +++ b/src/views/profile-forms/Company.vue @@ -6,9 +6,7 @@
-
+

Company Form

@@ -16,30 +14,14 @@
-