diff --git a/src/components/Dialogs/PopupPersonalNew.vue b/src/components/Dialogs/PopupPersonalNew.vue index 33182a51f..109ebd3f9 100644 --- a/src/components/Dialogs/PopupPersonalNew.vue +++ b/src/components/Dialogs/PopupPersonalNew.vue @@ -40,16 +40,8 @@ const props = defineProps({ /** emit*/ const emit = defineEmits(["update:modal"]); -/** interface*/ -interface StatusLoad { - val: boolean; - val2: boolean; - val3: boolean; -} - /** ตัวแปร*/ const modal = ref(false); -const statusLoad = ref({ val: false, val2: false, val3: false }); // เช็คสถานะการโหลด const avatar = reactive({ avatar: "", fullname: "", @@ -119,17 +111,14 @@ async function fetchInformation(id: string) { avatar.position = data.position ? data.position : "-"; if (data.avatarName) { - fetchProfile(data.id as string); - } else { - statusLoad.value.val = true; + fetchProfile(data.id as string,data.avatarName); } }) .catch((err) => { messageError($q, err); }) .finally(() => { - statusLoad.value.val2 = true; - loaderFunction(); + hideLoader(); }); } @@ -162,17 +151,10 @@ async function fetchProfileGov(id: string) { messageError($q, err); }) .finally(() => { - statusLoad.value.val3 = true; - loaderFunction(); + hideLoader(); }); } -/** functoion เช็คการโหลดของข้อมูล*/ -function loaderFunction() { - const allTrue = Object.values(statusLoad.value).every((val) => val); - allTrue && hideLoader(); -} - function redirecToRegistry() { router.push(`/registry-new/${props.id}`); modal.value = false; @@ -199,15 +181,15 @@ watch(modal, (newValue) => { } }); -async function fetchProfile(id: string) { +async function fetchProfile(id: string, avatarName: string) { showLoader(); await http - .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, fileName.value)) + .get(config.API.fileByFile("ทะเบียนประวัติ", "โปรไฟล์", id, avatarName)) .then(async (res) => { avatar.avatar = res.data.downloadUrl; }) .finally(() => { - statusLoad.value.val = true; + hideLoader(); }); }