Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: order list rejected #597

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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