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

Loading…
Cancel
Save