Skip to content

Commit

Permalink
feat: ada logic to show error pop up before upload file (#499)
Browse files Browse the repository at this point in the history
* fix: change let with const

* feat: add logic to show pop up insufficient balance before upload
  • Loading branch information
ciniiia authored Jun 29, 2022
1 parent 1c361a0 commit 797b278
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/common/components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export default {
metamaskWalletAddress() {
if (this.metamaskWalletAddress.currentAccount === this.metamaskWalletAddress.accountList[0]) {
this.loginStatus = true
this.getActiveMenu()
this.menus.find(menu => menu.active)
return
}
this.loginStatus = false
Expand Down Expand Up @@ -348,7 +348,7 @@ export default {
this.metamaskBalance = balance
this.setMetamaskBalance(balance)
this.loginStatus = true
this.getActiveMenu()
this.menus.find(menu => menu.active)
}
this.activeMetamaskAddress = ""
this.loginStatus = false
Expand Down
19 changes: 18 additions & 1 deletion src/views/Dashboard/Customer/Home/Emr/Create.vue
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ export default {
wallet: (state) => state.substrate.wallet,
lastEventData: (state) => state.substrate.lastEventData,
mnemonicData: (state) => state.substrate.mnemonicData,
web3: (state) => state.metamask.web3
web3: (state) => state.metamask.web3,
walletBalance: (state) => state.substrate.walletBalance
}),
computeFiles() {
Expand Down Expand Up @@ -352,6 +353,14 @@ export default {
},
handleNewFile() {
if (Number(this.walletBalance) < Number(this.txWeight.split(" ")[0])) {
this.error = {
title: "Insufficient Balance",
message: "Your transaction cannot succeed due to insufficient balance, check your account balance"
}
return
}
this._touchForms("document")
const { title: docTitle, description: docDescription, file: docFile } = this.isDirty?.document
if (docTitle || docDescription || docFile) return
Expand Down Expand Up @@ -437,6 +446,14 @@ export default {
},
async handleSubmit() {
if (Number(this.walletBalance) < Number(this.txWeight.split(" ")[0])) {
this.error = {
title: "Insufficient Balance",
message: "Your transaction cannot succeed due to insufficient balance, check your account balance"
}
return
}
this._touchForms("emr")
const isEMRValid = Object.values(this.isDirty?.emr).every(v => v !== null && v === false)
const isDocumentValid = Object.values(this.isDirty?.document).every(v => v !== null && v === false)
Expand Down
19 changes: 18 additions & 1 deletion src/views/Dashboard/Customer/Home/Emr/Edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ export default {
wallet: (state) => state.substrate.wallet,
lastEventData: (state) => state.substrate.lastEventData,
mnemonicData: (state) => state.substrate.mnemonicData,
web3: (state) => state.metamask.web3
web3: (state) => state.metamask.web3,
walletBalance: (state) => state.substrate.walletBalance
}),
computeFiles() {
Expand Down Expand Up @@ -410,6 +411,14 @@ export default {
},
handleNewFile() {
if (Number(this.walletBalance) < Number(this.txWeight.split(" ")[0])) {
this.error = {
title: "Insufficient Balance",
message: "Your transaction cannot succeed due to insufficient balance, check your account balance"
}
return
}
this._touchForms("document")
const { title: docTitle, description: docDescription, file: docFile } = this.isDirty?.document
if (docTitle || docDescription || docFile) return
Expand Down Expand Up @@ -496,6 +505,14 @@ export default {
},
handleModalPassword() {
if (Number(this.walletBalance) < Number(this.txWeight.split(" ")[0])) {
this.error = {
title: "Insufficient Balance",
message: "Your transaction cannot succeed due to insufficient balance, check your account balance"
}
return
}
this._touchForms("emr")
const isEMRValid = Object.values(this.isDirty?.emr).every(v => v !== null && v === false)
const isDocumentValid = Object.values(this.isDirty?.document).every(v => v !== null && v === false)
Expand Down
3 changes: 2 additions & 1 deletion src/views/Dashboard/Customer/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ export default {
{ text: "Payment History", disabled: false, active: false, route: "customer-payment-history", icon: creditCardIcon }
],
switchNetwork: false,
networkName: "",
currentNetwork: "",
network: {
Expand Down Expand Up @@ -273,7 +274,7 @@ export default {
}
},
async mounted() {
async created() {
if (!this.mnemonicData) this.showModalPassword = true
await this.getListNotification()
await this.checkMetamask()
Expand Down

0 comments on commit 797b278

Please sign in to comment.