From 49c7eb8c4298fb53c51e9e6170961c90ee082e43 Mon Sep 17 00:00:00 2001 From: Amir Hassan Date: Wed, 22 Feb 2023 11:50:07 +0800 Subject: [PATCH] Redirect to result when lelongId undefined in result-detail --- src/components/result/ResultDetail.vue | 44 ++++++++++++++------------ 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/components/result/ResultDetail.vue b/src/components/result/ResultDetail.vue index 54f32d2..db64267 100644 --- a/src/components/result/ResultDetail.vue +++ b/src/components/result/ResultDetail.vue @@ -590,27 +590,31 @@ export default { }, liveData() { this.loading = true; - axios - .get("/bayar/" + localStorage.getItem("id") + "/" + this.lelongId, { - headers: { - Authorization: "Bearer " + localStorage.getItem("token"), - }, - }) - .then((response) => { - // console.log("liveData", response); - if (response.data.success == true) { - this.isSuccess = true; + if(this.lelongId != null) { + axios + .get("/bayar/" + localStorage.getItem("id") + "/" + this.lelongId, { + headers: { + Authorization: "Bearer " + localStorage.getItem("token"), + }, + }) + .then((response) => { + // console.log("liveData", response); + if (response.data.success == true) { + this.isSuccess = true; + this.loading = false; + this.lists = response.data.data; + this.tarikhLelong = response.data.tarikh_lelong; + } else { + this.isSuccess = false; + } + }) + .catch((error) => { this.loading = false; - this.lists = response.data.data; - this.tarikhLelong = response.data.tarikh_lelong; - } else { - this.isSuccess = false; - } - }) - .catch((error) => { - this.loading = false; - console.log(error); - }); + console.log(error); + }); + } else { + this.$router.push({ name: "result" }); + } }, clickPayButton(value) { this.$router.push({ name: "pay", params: { lelongId: value } });