@ -1,4 +1,5 @@
import {
import {
cfCreateDestinationSet ,
cfCreateOfficeHours ,
cfCreateOfficeHours ,
cfCreateSourceSet ,
cfCreateSourceSet ,
cfCreateTimeSetDate ,
cfCreateTimeSetDate ,
@ -7,6 +8,7 @@ import {
cfDeleteDestinationSet ,
cfDeleteDestinationSet ,
cfDeleteSourceSet ,
cfDeleteSourceSet ,
cfDeleteTimeSet ,
cfDeleteTimeSet ,
cfGetMostRecentDestinationSetByName ,
cfLoadDestinationSets ,
cfLoadDestinationSets ,
cfLoadMappingsFull ,
cfLoadMappingsFull ,
cfLoadSourceSets ,
cfLoadSourceSets ,
@ -61,22 +63,27 @@ 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 ) {
dispatch ( 'wait/start' , WAIT _IDENTIFIER , { root : true } )
dispatch ( 'wait/start' , WAIT _IDENTIFIER , { root : true } )
const name = 'csc-' + v4 ( )
const subscriberId = ( payload . subscriberId ) ? ( payload . subscriberId ) : rootGetters [ 'user/getSubscriberId' ]
await cfCreateDestinationSet ( {
name ,
subscriber _id : subscriberId ,
destinations : [ createDefaultDestination ( ) ]
} )
const destinationSet = await cfGetMostRecentDestinationSetByName ( {
name ,
subscriberId : subscriberId
} )
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 ) {
type = 'cft'
type = 'cft'
}
}
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 ( {
resource : 'cfdestinationsets' ,
body : {
name : 'csc-' + v4 ( ) ,
subscriber _id : subscriberId ,
destinations : [ createDefaultDestination ( ) ]
}
} )
mappings . push ( {
mappings . push ( {
destinationset _id : destinationSet I d
destinationset _id : destinationSet . id
} )
} )
const res = await Promise . all ( [
const res = await Promise . all ( [
patchReplaceFull ( {
patchReplaceFull ( {