Skip to content

Commit

Permalink
fix:user cant retrieve unstaked amount (#888)
Browse files Browse the repository at this point in the history
  • Loading branch information
RiXelanya authored Sep 7, 2023
1 parent f4904bf commit 9aa1bf4
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/views/Dashboard/Customer/Home/MyTest/StakingServiceTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@
:disabled="item.request.status === 'Open'"
) Proceed

.customer-staking-tab__actions(v-else-if="compareRemainingStakingDate(item.request.unstaked_at)" )
ui-debio-button.pa-4(
:disabled="item.request.status === 'Processed' || item.request.status === 'Finalized'"
height="25px"
width="100px"
style="font-size: 1em"
color="primary"
@click="getRetrieveDialog(item.request.hash)"
) Retrieve

.customer-staking-tab__actions(v-else)
ui-debio-button(disabled width="220px" color="white" )
vue-countdown-timer(
Expand Down Expand Up @@ -238,6 +248,12 @@ export default {
return dueDate
},
compareRemainingStakingDate(date) {
const formatedDate = new Date(parseInt(date.replace(/,/g, "")))
const dueDate = formatedDate.setDate(formatedDate.getDate() + 6)
return (Date.now() > dueDate)
},
async toRequestTest(req) {
this.loading = true
this.stakingData = req.request
Expand Down Expand Up @@ -300,6 +316,12 @@ export default {
this.requestId = id
},
async getRetrieveDialog(id) {
this.setStakingId(id)
await this.$emit("retrieve")
this.requestId = id
},
setButtonBackground(status) {
return STAKE_STATUS_DETAIL[status.toUpperCase()].color
},
Expand Down
34 changes: 33 additions & 1 deletion src/views/Dashboard/Customer/Home/MyTest/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,22 @@
StakingServiceTab(
ref="staking"
@unstake="showDialog = true"
@retrieve="showRetrieveDialog = true"
@loading="loadingDialog = true"
@closeLoading="loadingDialog = false"
@error="showError"
)
ConfirmationDialog(
:show="showRetrieveDialog"
:loading="isLoading"
:txWeight="Number(txWeight).toFixed(4)"
title="Retrieve"
btnMessage="Retrieve"
message="Retrieve your staked currency"
@click="retrieveService"
this.isLoding = true
@close="showRetrieveDialog=false"
)
ConfirmationDialog(
:show="showDialog"
:loading="isLoading"
Expand Down Expand Up @@ -175,7 +187,7 @@ import { u8aToHex } from "@polkadot/util"
import { syncDecryptedFromIPFS } from "@/common/lib/ipfs"
import ConfirmationDialog from "@/common/components/Dialog/ConfirmationDialog"
import { createSyncEvent, getCategories, getOrderList } from "@/common/lib/api"
import { queryDnaSamples, queryDnaTestResults, unstakeRequest, unstakeRequestFee } from "@debionetwork/polkadot-provider"
import { queryDnaSamples, queryDnaTestResults, unstakeRequest, unstakeRequestFee, retrieveUnstakedAmount } from "@debionetwork/polkadot-provider"
import { getDNACollectionProcess } from "@/common/lib/api"
import { ORDER_STATUS_DETAIL } from "@/common/constants/status"
import PaymentDialog from "@/common/components/Dialog/PaymentDialog"
Expand Down Expand Up @@ -205,6 +217,7 @@ export default {
isBounty: false,
isLoading: false,
showDialog: false,
showRetrieveDialog: false,
medicalResearchIllustration,
isLoding: false,
isLoadingData: false,
Expand Down Expand Up @@ -477,10 +490,29 @@ export default {
)
},
async retrieveService() {
const requestId = this.stakingId
this.isLoading = true
await retrieveUnstakedAmount(
this.api,
this.wallet,
requestId,
this.fetchStakingTab // eslint-disable-next-line no-unused-vars
).catch(this.retrieveError())
},
fetchStakingTab() {
this.$refs.staking.fetchData()
this.isLoading = false
this.showDialog = false
this.showRetrieveDialog = false
},
retrieveError() {
this.fetchStakingTab()
this.error = {
title: "Error",
message: "Retrieval of unstaked amount failed"
}
},
showError() {
Expand Down

0 comments on commit 9aa1bf4

Please sign in to comment.