diff --git a/src/components/OrderList.vue b/src/components/OrderList.vue index 4106f64c..db1f00a0 100644 --- a/src/components/OrderList.vue +++ b/src/components/OrderList.vue @@ -82,7 +82,10 @@ export default { }), props: { - isDashboard: Boolean + isDashboard: { + type: Boolean, + default: false + } }, async created() { @@ -98,32 +101,44 @@ export default { methods: { async fetchDataOrders(keyword) { - this.orders = [] - const listStatus = ["Refunded", "Fulfilled"] - - const orders = await this.dispatch(getOrdersData, this.pair.address, this.page, this.pageSize, keyword) - for (let order of orders.data) { - const dna = await queryDnaSamples(this.api, order._source.dna_sample_tracking_id) - const dnaTestResult = await queryDnaTestResults(this.api, order._source.dna_sample_tracking_id) - const data = { - ...order, - _source: { - ...order._source, - dna_sample_status: dna?.status, - testResult: dnaTestResult, - created_at: new Date(+order._source.created_at.replaceAll(",", "")).toLocaleDateString("id", { - day: "2-digit", - month: "short", - year: "numeric" - }) - } - } + this.isLoading = true + try { + const orderList = [] + const listStatus = ["Refunded", "Fulfilled"] - if (this.isDashboard) { - if (!listStatus.includes(data._source.status)) this.orders.push(data) - } else { - if (listStatus.includes(data._source.status)) this.orders.push(data) + const orders = await this.dispatch(getOrdersData, this.pair.address, this.page, this.pageSize, keyword) + for (let order of orders.data) { + const dna = await queryDnaSamples(this.api, order._source.dna_sample_tracking_id) + + if (this.isDashboard && dna?.status === "Rejected") continue + + const dnaTestResult = await queryDnaTestResults(this.api, order._source.dna_sample_tracking_id) + const data = { + ...order, + _source: { + ...order._source, + dna_sample_status: dna?.status, + testResult: dnaTestResult, + created_at: new Date(+order._source.created_at.replaceAll(",", "")).toLocaleDateString("id", { + day: "2-digit", + month: "short", + year: "numeric" + }) + } + } + + if (this.isDashboard) { + if (!listStatus.includes(data._source.status)) orderList.push(data) + } else { + if (listStatus.includes(data._source.status)) orderList.push(data) + } } + + this.orders = orderList + } catch (err) { + console.error(err) + } finally { + this.isLoading = false } }, diff --git a/src/views/Dashboard/Lab/LabOrders.vue b/src/views/Dashboard/Lab/LabOrders.vue index 34d18268..5052e9ac 100644 --- a/src/views/Dashboard/Lab/LabOrders.vue +++ b/src/views/Dashboard/Lab/LabOrders.vue @@ -107,7 +107,7 @@ export default { const title = detailOrder.lab_name const labName = detailOrder.service_name - const listStatus = ["Refunded", "Fulfilled", "Rejected"] + const listStatus = ["Refunded", "Fulfilled"] let icon = "mdi-needle" if (detailOrder.service_image) {