Skip to content

Commit

Permalink
fix: add loading display on my test (#490)
Browse files Browse the repository at this point in the history
* fix: add loading display on my test

* fix: add try catch on fetchin data
  • Loading branch information
ciniiia authored Jun 20, 2022
1 parent e691d17 commit d84af1e
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 26 deletions.
38 changes: 30 additions & 8 deletions src/views/Dashboard/Customer/Home/MyTest/OrderHistoryDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
div.bodyContent
v-row
v-col
div.leftSection.box.fillColor
div.leftSection.box.fillColor(v-if="isLoading")
div.topRow
div.topHead
v-skeleton-loader(
v-bind="attrs"
type="card-heading, list-item-avatar, divider, card-heading, list-item-avatar, devider, list-item"
)
div.leftSection.box.fillColor(v-if="!isLoading")
div.topRow
div.topHead
span Lab Details
Expand Down Expand Up @@ -60,7 +67,14 @@
span Specimen Number
span {{ myTest.dna_sample_tracking_id }}
v-col
div.rightSection.box
div.rightSection.box(v-if="isLoading")
div
v-skeleton-loader(
v-bind="attrs"
type="image, list-item-two-line"
)

div.rightSection.box(v-if="!isLoading")
div
div.imageBanner.box
ui-debio-icon(
Expand Down Expand Up @@ -186,7 +200,8 @@ export default {
servicePrice: 0,
qcPrice: 0,
currency: ""
}
},
isLoading: false
}),
async mounted() {
Expand All @@ -210,11 +225,18 @@ export default {
methods: {
async getOrderDetail() {
this.myTest = await getOrderDetail(this.$route.params.id)
this.dnaSample = await queryDnaSamples(this.api, this.myTest.dna_sample_tracking_id)
this.prices.servicePrice = formatPrice(this.myTest.service_info.prices_by_currency[0].total_price)
this.prices.qcPrice = formatPrice(this.myTest.service_info.prices_by_currency[0].additional_prices[0].value)
this.prices.currency = this.myTest.service_info.prices_by_currency[0].currency.toUpperCase()
this.isLoading = true
try {
this.myTest = await getOrderDetail(this.$route.params.id)
this.dnaSample = await queryDnaSamples(this.api, this.myTest.dna_sample_tracking_id)
this.prices.servicePrice = this.formatPrice(this.myTest.service_info.prices_by_currency[0].total_price)
this.prices.qcPrice = this.formatPrice(this.myTest.service_info.prices_by_currency[0].additional_prices[0].value)
this.prices.currency = this.myTest.service_info.prices_by_currency[0].currency.toUpperCase()
this.isLoading = false
} catch (error) {
console.error(error)
this.isLoading = false
}
},
toViewResult() {
Expand Down
46 changes: 28 additions & 18 deletions src/views/Dashboard/Customer/Home/MyTest/StakingServiceTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
ui-debio-data-table(
:headers="headers"
:items="items"
:loading="isLoadingData"
)
template(v-slot:[`item.id`]="{ item }")
.customer-staking-tab__id
Expand Down Expand Up @@ -130,7 +131,9 @@ export default {
tabs: null,
showDialog: false,
requestId: "",
countries: []
countries: [],
isLoadingData: false
}),
computed: {
Expand All @@ -155,23 +158,30 @@ export default {
}),
async fetchData () {
const { data } = await getServiceRequestByCustomer(this.pair.address)
this.items = data
this.items.sort((a, b) => {
const dateA = (a.request.created_at).replace(/,/g, "")
const dateB = (b.request.created_at).replace(/,/g, "")
if(new Date(parseInt(dateA)) < new Date(parseInt(dateB))) {
return 1
}
if (new Date(parseInt(dateA)) > new Date(parseInt(dateB))) {
return -1
}
return 0
})
try {
const { data } = await getServiceRequestByCustomer(this.pair.address)
this.items = data
this.items.sort((a, b) => {
const dateA = (a.request.created_at).replace(/,/g, "")
const dateB = (b.request.created_at).replace(/,/g, "")
if(new Date(parseInt(dateA)) < new Date(parseInt(dateB))) {
return 1
}
if (new Date(parseInt(dateA)) > new Date(parseInt(dateB))) {
return -1
}
return 0
})
this.isLoadingData = false
} catch (error) {
console.log(error)
this.isLoadingData = false
}
},
setAmount(amount) {
Expand Down
4 changes: 4 additions & 0 deletions src/views/Dashboard/Customer/Home/MyTest/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
ui-debio-data-table(
:headers="headers"
:items="testList"
:loading="isLoadingData"
)
template(class="titleSection" v-slot:[`item.serviceName`]="{item}")
div(class="detailLab d-flex align-center")
Expand Down Expand Up @@ -179,6 +180,7 @@ export default {
showDialog: false,
medicalResearchIllustration,
isLoding: false,
isLoadingData: false,
txWeight: 0,
testList: [],
headers: [
Expand Down Expand Up @@ -274,6 +276,7 @@ export default {
},
async fetchOrderList() {
this.isLoadingData = true
const result = await getOrderList()
const orderList = result.orders.data
const newList = orderList.filter(order => order._source.status !== "Unpaid" && order._source.status !== "Cancelled")
Expand Down Expand Up @@ -319,6 +322,7 @@ export default {
this.testList.sort(
(a, b) => parseInt(b.timestamp) - parseInt(a.timestamp)
)
this.isLoadingData = false
})
},
Expand Down

0 comments on commit d84af1e

Please sign in to comment.