Skip to content

Commit

Permalink
fix: order list rejected (#597)
Browse files Browse the repository at this point in the history
fix order list rejected
  • Loading branch information
rubenkristian authored Dec 5, 2022
1 parent e7b29cf commit e1d5f2e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 26 deletions.
65 changes: 40 additions & 25 deletions src/components/OrderList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ export default {
}),
props: {
isDashboard: Boolean
isDashboard: {
type: Boolean,
default: false
}
},
async created() {
Expand All @@ -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
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/views/Dashboard/Lab/LabOrders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit e1d5f2e

Please sign in to comment.