From aff1564b643b4cf62beefac788dae4fdb0ab6fff Mon Sep 17 00:00:00 2001 From: Denys Seredenko Date: Fri, 6 Jan 2023 23:23:28 +0100 Subject: [PATCH] * Hot-fix of bug with rendering a variable from vuex store before it's load(when variable is null) feature: no-task --- src/service/ContractsService.js | 1 + src/store/contracts.module.js | 13 +++++++++---- src/views/ContractView.vue | 17 ++++++++++------- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/service/ContractsService.js b/src/service/ContractsService.js index 770cfd8..6e1d0b5 100644 --- a/src/service/ContractsService.js +++ b/src/service/ContractsService.js @@ -28,6 +28,7 @@ export async function getContractById(identifier) { return resp.data }) .catch(error => { + console.error(error) router.push('/error?message=' + error.message + '&code=' + error.code) }) } diff --git a/src/store/contracts.module.js b/src/store/contracts.module.js index 4676d7d..07f31c4 100644 --- a/src/store/contracts.module.js +++ b/src/store/contracts.module.js @@ -18,10 +18,15 @@ export default { const contracts = await getContracts() commit('initContracts', contracts) }, - async fetchContractById({ commit }, id) { - const currentContract = await getContractById(id) - commit('setCurrentContract', currentContract) + async fetchContractById({ commit, state }, id) { + const contract = await getContractById(id) + commit('setCurrentContract', contract) + return state.currentContract } }, - getters: {} + getters: { + currentContract: state => { + return state.currentContract + } + } } diff --git a/src/views/ContractView.vue b/src/views/ContractView.vue index 0e96eff..083d117 100644 --- a/src/views/ContractView.vue +++ b/src/views/ContractView.vue @@ -1,7 +1,7 @@ \ No newline at end of file