MT#60161 add an error message and stop the loading on network error

Change-Id: I620be6f60d27ea24fd5a25552be23f67336df1f8
mr13.0
Hugo Zigha 1 year ago
parent a0dfa84bc3
commit a66dff24a4

@ -25,6 +25,9 @@ import {
post, put, get, getList
} from 'src/api/common'
import _ from 'lodash'
import {
showGlobalError
} from 'src/helpers/ui'
const DEFAULT_RING_TIMEOUT = 60
const DEFAULT_PRIORITY = 0
@ -60,6 +63,7 @@ export async function loadMappingsFull ({ dispatch, commit, rootGetters }, subsc
}
export async function createMapping ({ dispatch, commit, state, rootGetters }, payload) {
try {
dispatch('wait/start', WAIT_IDENTIFIER, { root: true })
let type = payload.type
if (payload.type === 'cfu' && state.mappings.cft && state.mappings.cft.length > 0) {
@ -67,7 +71,7 @@ export async function createMapping ({ dispatch, commit, state, rootGetters }, p
}
const subscriberId = (payload.subscriberId) ? (payload.subscriberId) : rootGetters['user/getSubscriberId']
const mappings = _.cloneDeep(state.mappings[type])
const destinationSetId = await post({
const destinationSet = await post({
resource: 'cfdestinationsets',
body: {
name: 'csc-' + v4(),
@ -76,7 +80,7 @@ export async function createMapping ({ dispatch, commit, state, rootGetters }, p
}
})
mappings.push({
destinationset_id: destinationSetId
destinationset_id: destinationSet?.id
})
const res = await Promise.all([
patchReplaceFull({
@ -91,8 +95,12 @@ export async function createMapping ({ dispatch, commit, state, rootGetters }, p
mappings: res[0],
destinationSets: res[1].items
})
} catch (error) {
showGlobalError(error.message)
} finally {
dispatch('wait/end', WAIT_IDENTIFIER, { root: true })
}
}
export async function deleteMapping ({ dispatch, commit, state, rootGetters }, payload) {
dispatch('wait/start', WAIT_IDENTIFIER, { root: true })

Loading…
Cancel
Save