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

feat: ada logic to show error pop up before upload file #499

Merged
merged 5 commits into from
Jun 29, 2022
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
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