MT#64739 Replace cfLoadMappingFull

* Following the backend changes, update the frontend
  to retrieve the details about relevant resources
  using the new parameter "expand: all".
* To avoid regression, add a method to normalize
  the response to match the store structure with maps
  for each resource and the general cfMapping object
* Simplify dataSucceeded mutation by storing only
  relevant data and moving normalization into
  dedicated methods
* Improve UX behaviour with a transition block for the
  csc-cf-add-form and transition ease of sticky-page

Change-Id: I1da6fd109dc951d469cfe59d313ebd2bdc8dced3
mr26.2
Debora Crescenzo 3 weeks ago committed by Crescenzo Debora
parent aa63503f13
commit d5c2e22400

@ -49,19 +49,12 @@ export async function cfLoadTimeSets (subscriberId) {
})
}
/* Note: It needs to retrieve all Sets (DestinationSets, SourceSets,
** TimeSets, and BNumberSets) without filtering by subscriberId
** because some sets might belong to the admin subscriber
** and would not appear in the seats/groups CF.
*/
export async function cfLoadMappingsFull (mappingId) {
return await Promise.all([
cfLoadMappings(mappingId),
cfLoadDestinationSets(),
cfLoadSourceSets(),
cfLoadTimeSets(),
cfLoadBNumberSets()
])
return get({
resource: 'cfmappings',
params: { expand: 'all' },
resourceId: mappingId
})
}
export async function cfLoadAnnouncements () {
@ -102,6 +95,7 @@ export async function cfRewriteDestination (payload) {
})
}
// Note this doesn't return any data in the response.
export async function cfUpdateDestinationSets (payload) {
return patchReplace({
resource: 'cfdestinationsets',

@ -1,6 +1,7 @@
<template>
<csc-page
:style="pageStyle"
class="sticky-page"
>
<q-page-sticky
ref="pageSticky"
@ -74,3 +75,8 @@ export default {
}
}
</script>
<style scoped>
.sticky-page {
transition: padding-top 250ms ease;
}
</style>

@ -22,19 +22,21 @@
</template>
</q-btn>
</q-item>
<q-item
class="row justify-center"
v-if="!isCfAddFormDisabled"
>
<div class="csc-cf-form-wrap">
<csc-cf-add-form
ref="addCfForm"
:loading="$wait.is('csc-cf-mappings-full')"
@save="createCf($event)"
@cancel="disableCfAddForm"
/>
</div>
</q-item>
<q-slide-transition>
<q-item
class="row justify-center"
v-if="!isCfAddFormDisabled"
>
<div class="csc-cf-form-wrap">
<csc-cf-add-form
ref="addCfForm"
:loading="$wait.is('csc-cf-mappings-full')"
@save="createCf($event)"
@cancel="disableCfAddForm"
/>
</div>
</q-item>
</q-slide-transition>
<q-item
class="row justify-center q-pt-lg"
>

@ -0,0 +1,49 @@
import { sortDestinationsByPriority } from 'src/helpers/call-forwarding-destinations'
import { MAPPING_TYPES } from 'src/store/call-forwarding/normalizers'
export function normalizeFullMappingsResponse (mappings) {
const destinationSetMap = {}
const sourceSetMap = {}
const timeSetMap = {}
const bNumberSetMap = {}
MAPPING_TYPES.forEach((type) => {
mappings[type]?.forEach((mapping) => {
if (mapping.destinationset_id_expand) {
destinationSetMap[mapping.destinationset_id] = {
...mapping.destinationset_id_expand,
destinations: sortDestinationsByPriority(
mapping.destinationset_id_expand.destinations
)
}
delete mapping.destinationset_id_expand
}
if (mapping.sourceset_id_expand) {
sourceSetMap[mapping.sourceset_id] =
mapping.sourceset_id_expand
delete mapping.sourceset_id_expand
}
if (mapping.timeset_id_expand) {
timeSetMap[mapping.timeset_id] =
mapping.timeset_id_expand
delete mapping.timeset_id_expand
}
if (mapping.bnumberset_id_expand) {
bNumberSetMap[mapping.bnumberset_id] =
mapping.bnumberset_id_expand
delete mapping.bnumberset_id_expand
}
})
})
return {
mappings,
destinationSetMap,
sourceSetMap,
timeSetMap,
bNumberSetMap
}
}

@ -24,17 +24,21 @@
</template>
</q-btn>
</template>
<template
#toolbar
>
<csc-cf-add-form
v-if="!isCfAddFormDisabled"
ref="addCfForm"
class="q-mb-md q-pa-md"
:loading="$wait.is('csc-cf-mappings-full')"
@save="createCf($event)"
@cancel="disableCfAddForm"
/>
<template #toolbar>
<q-slide-transition>
<div
v-if="!isCfAddFormDisabled"
class="q-mb-md"
>
<csc-cf-add-form
ref="addCfForm"
class="q-pa-md"
:loading="$wait.is('csc-cf-mappings-full')"
@save="createCf($event)"
@cancel="disableCfAddForm"
/>
</div>
</q-slide-transition>
</template>
<div
class="row justify-center q-pt-lg"

@ -13,7 +13,6 @@ import {
cfLoadAnnouncements,
cfLoadBNumberSets,
cfLoadDestinationSets,
cfLoadMappings,
cfLoadMappingsFull,
cfLoadSourceSets,
cfLoadTimeSets,
@ -31,7 +30,14 @@ import {
import { getSubscriberSeats } from 'src/api/subscriber'
import { i18n } from 'src/boot/i18n'
import { canMoveDestination, normalizePriorities } from 'src/helpers/call-forwarding-destinations'
import { normalizeFullMappingsResponse } from 'src/helpers/normalize-mappings-response'
import { showGlobalError, showGlobalWarning } from 'src/helpers/ui'
import {
buildBNumberSetMap,
buildDestinationMap,
buildSourceSetMap,
buildTimeSetMap
} from 'src/store/call-forwarding/normalizers'
const DEFAULT_RING_TIMEOUT = 60
const DEFAULT_PRIORITY = 0
@ -49,18 +55,12 @@ function createDefaultDestination (destination, defaultAnnouncementId, priority
return payload
}
export async function loadMappingsFull ({ dispatch, commit, rootGetters }, subscriberId) {
export async function loadMappingsFull ({ dispatch, commit }, subscriberId) {
dispatch('wait/start', WAIT_IDENTIFIER, { root: true })
try {
const mappingData = await cfLoadMappingsFull(subscriberId)
commit('dataSucceeded', {
mappings: mappingData[0],
destinationSets: mappingData[1].items,
sourceSets: mappingData[2].items,
timeSets: mappingData[3].items,
bNumberSets: mappingData[4].items
})
try {
const mappings = await cfLoadMappingsFull(subscriberId)
commit('dataSucceeded', normalizeFullMappingsResponse(mappings))
} catch (e) {
showGlobalError(e.message)
} finally {
@ -100,23 +100,19 @@ export async function createMapping ({ dispatch, commit, state, rootGetters }, p
destinations: [newDestination]
})
if (!destinationSet.id) {
if (!destinationSet || !destinationSet.id) {
throw new Error('Something went wrong. Please retry later')
}
const patchedMappings = await updateMapping(
await updateMapping(
subscriberId,
payload.type,
currentMappings,
destinationSet.id
)
const latestDestinationSets = await cfLoadDestinationSets()
commit('dataSucceeded', {
mappings: patchedMappings,
destinationSets: latestDestinationSets.items
})
const updatedMapping = await cfLoadMappingsFull(subscriberId)
commit('dataSucceeded', normalizeFullMappingsResponse(updatedMapping))
commit('cfCreationSucceeded')
} catch (e) {
showGlobalError(e.message)
@ -138,7 +134,7 @@ export async function deleteMapping ({ dispatch, commit, state, rootGetters }, p
currentMappings.cft_ringtimeout = DEFAULT_RING_TIMEOUT
}
const updatedMappings = await cfUpdateFullMapping({
await cfUpdateFullMapping({
subscriberId,
body: {
...currentMappings,
@ -146,9 +142,8 @@ export async function deleteMapping ({ dispatch, commit, state, rootGetters }, p
}
})
commit('dataSucceeded', {
mappings: updatedMappings
})
const newMappings = await cfLoadMappingsFull(subscriberId)
commit('dataSucceeded', normalizeFullMappingsResponse(newMappings))
} catch (e) {
showGlobalError(e.message)
} finally {
@ -167,15 +162,13 @@ export async function setMappingEnabled ({ dispatch, commit, state, rootGetters
enabled: !mappingsByType[payload.index].enabled
}
await cfUpdateMappingField({
const updatedMappings = await cfUpdateMappingField({
resource: 'cfmappings',
resourceId,
fieldPath: payload.type,
value: mappingsByType
})
const updatedMappings = await cfLoadMappings(resourceId)
commit('dataSucceeded', { mappings: updatedMappings })
} catch (e) {
showGlobalError(e.message)
@ -184,6 +177,10 @@ export async function setMappingEnabled ({ dispatch, commit, state, rootGetters
}
}
/**
* Helper function
*/
async function updateMapping (
subscriberId,
type,
@ -227,7 +224,7 @@ export async function updateDestination ({ dispatch, commit, state }, payload) {
const destinationSets = await cfLoadDestinationSets()
commit('dataSucceeded', {
destinationSets: destinationSets.items
destinationSetMap: buildDestinationMap(destinationSets.items)
})
} catch (e) {
showGlobalError(e.message)
@ -254,8 +251,9 @@ export async function addDestination ({ dispatch, commit, state }, payload) {
})
const destinationSets = await cfLoadDestinationSets()
commit('dataSucceeded', {
destinationSets: destinationSets.items
destinationSetMap: buildDestinationMap(destinationSets.items)
})
} catch (e) {
showGlobalError(e.message)
@ -291,7 +289,7 @@ export async function removeDestination ({ dispatch, commit, state }, payload) {
const destinationSets = await cfLoadDestinationSets()
commit('dataSucceeded', {
destinationSets: destinationSets.items
destinationSetMap: buildDestinationMap(destinationSets.items)
})
} catch (e) {
showGlobalError(e.message)
@ -328,7 +326,7 @@ export async function moveDestination ({ dispatch, commit, state }, payload) {
const destinationSets = await cfLoadDestinationSets()
commit('dataSucceeded', {
destinationSets: destinationSets.items
destinationSetMap: buildDestinationMap(destinationSets.items)
})
} catch (e) {
showGlobalError(e.message)
@ -354,7 +352,7 @@ export async function updateDestinationTimeout ({ dispatch, commit, state }, pay
}
const destinationSets = await cfLoadDestinationSets()
commit('dataSucceeded', {
destinationSets: destinationSets.items
destinationSetMap: buildDestinationMap(destinationSets.items)
})
dispatch('wait/end', WAIT_IDENTIFIER, { root: true })
}
@ -364,7 +362,7 @@ export async function loadSourceSets ({ dispatch, commit }) {
try {
const sourceSets = await cfLoadSourceSets()
commit('dataSucceeded', {
sourceSets: sourceSets.items
sourceSetMap: buildSourceSetMap(sourceSets.items)
})
} catch (e) {
showGlobalError(e.message)
@ -376,6 +374,7 @@ export async function loadSourceSets ({ dispatch, commit }) {
export async function createBNumberSet ({ dispatch, commit, rootGetters, state }, payload) {
try {
dispatch('wait/start', 'csc-cf-b-number-set-create', { root: true })
const resourceId = (payload.subscriberId) ? payload.subscriberId : rootGetters['user/getSubscriberId']
const bNumberSetId = await cfCreateBNumberSet(rootGetters['user/getSubscriberId'], payload)
const updatedMapping = [...state.mappings[payload.mapping.type]]
updatedMapping[payload.mapping.index] = {
@ -383,14 +382,15 @@ export async function createBNumberSet ({ dispatch, commit, rootGetters, state }
bnumberset_id: bNumberSetId
}
const updatedMappings = await cfUpdateMappingField({
resourceId: (payload.subscriberId) ? payload.subscriberId : rootGetters['user/getSubscriberId'],
resourceId,
fieldPath: payload.mapping.type,
value: updatedMapping
})
const bNumberSets = await cfLoadBNumberSets()
commit('dataSucceeded', {
mappings: updatedMappings,
bNumberSets: bNumberSets.items
bNumberSetMap: buildBNumberSetMap(bNumberSets.items)
})
} catch (e) {
showGlobalError(e.message)
@ -404,7 +404,7 @@ export async function loadBNumberSets ({ dispatch, commit }) {
try {
const bNumberSets = await cfLoadBNumberSets()
commit('dataSucceeded', {
bNumberSets: bNumberSets.items
bNumberSetMap: buildBNumberSetMap(bNumberSets.items)
})
} catch (e) {
showGlobalError(e.message)
@ -414,13 +414,13 @@ export async function loadBNumberSets ({ dispatch, commit }) {
}
export async function updateBNumberSet ({ dispatch, commit, rootGetters }, payload) {
dispatch('wait/start', 'csc-cf-b-number-set-create', { root: true })
try {
dispatch('wait/start', 'csc-cf-b-number-set-create', { root: true })
await cfUpdateBNumberSet(rootGetters['user/getSubscriberId'], payload)
const bNumberSets = await cfLoadBNumberSets()
commit('dataSucceeded', {
bNumberSets: bNumberSets.items
})
const subscriberId = rootGetters['user/getSubscriberId']
await cfUpdateBNumberSet(subscriberId, payload)
const updatedMapping = await cfLoadMappingsFull(subscriberId)
commit('dataSucceeded', normalizeFullMappingsResponse(updatedMapping))
} catch (e) {
if (e.code === 404 && e.message === 'Entity \'cfbnumberset\' not found.') {
// This happens when entity was set by Admin therefore current
@ -437,14 +437,15 @@ export async function updateBNumberSet ({ dispatch, commit, rootGetters }, paylo
export async function deleteBNumberSet ({ dispatch, commit, rootGetters, state }, payload) {
try {
dispatch('wait/start', 'csc-cf-b-number-set-create', { root: true })
const resourceId = (payload.subscriberId) ? payload.subscriberId : rootGetters['user/getSubscriberId']
const updatedMapping = [...state.mappings[payload.mapping.type]]
updatedMapping[payload.mapping.index] = {
...updatedMapping[payload.mapping.index],
bnumberset_id: null,
bnumberset: null
}
const updatedMappings = await cfUpdateMappingField({
resourceId: (payload.subscriberId) ? payload.subscriberId : rootGetters['user/getSubscriberId'],
await cfUpdateMappingField({
resourceId,
fieldPath: payload.mapping.type,
value: updatedMapping
})
@ -462,11 +463,8 @@ export async function deleteBNumberSet ({ dispatch, commit, rootGetters, state }
}
}
const bNumberSets = await cfLoadBNumberSets()
commit('dataSucceeded', {
mappings: updatedMappings,
bNumberSets: bNumberSets.items
})
const latestMappings = await cfLoadMappingsFull(resourceId)
commit('dataSucceeded', normalizeFullMappingsResponse(latestMappings))
} catch (e) {
showGlobalError(e.message)
} finally {
@ -534,7 +532,7 @@ export async function createSourceSet ({ dispatch, commit, rootGetters, state },
const sourceSets = await cfLoadSourceSets()
commit('dataSucceeded', {
mappings: updatedMappings,
sourceSets: sourceSets.items
sourceSetMap: buildSourceSetMap(sourceSets.items)
})
} catch (e) {
showGlobalError(e.message)
@ -549,7 +547,7 @@ export async function updateSourceSet ({ dispatch, commit, rootGetters }, payloa
await cfUpdateSourceSet(rootGetters['user/getSubscriberId'], payload)
const sourceSets = await cfLoadSourceSets()
commit('dataSucceeded', {
sourceSets: sourceSets.items
sourceSetMap: buildSourceSetMap(sourceSets.items)
})
} catch (e) {
if (e.code === 404 && e.message === 'Entity \'cfsourceset\' not found.') {
@ -567,13 +565,14 @@ export async function updateSourceSet ({ dispatch, commit, rootGetters }, payloa
export async function deleteSourceSet ({ dispatch, commit, rootGetters, state }, payload) {
try {
dispatch('wait/start', 'csc-cf-source-set-create', { root: true })
const resourceId = (payload.subscriberId) ? payload.subscriberId : rootGetters['user/getSubscriberId']
const updatedMapping = [...state.mappings[payload.mapping.type]]
updatedMapping[payload.mapping.index] = {
...updatedMapping[payload.mapping.index],
sourceset_id: null,
sourceset: null
}
const updatedMappings = await cfUpdateMappingField({
await cfUpdateMappingField({
resourceId: (payload.subscriberId) ? payload.subscriberId : rootGetters['user/getSubscriberId'],
fieldPath: payload.mapping.type,
value: updatedMapping
@ -593,11 +592,8 @@ export async function deleteSourceSet ({ dispatch, commit, rootGetters, state },
}
}
const sourceSets = await cfLoadSourceSets()
commit('dataSucceeded', {
mappings: updatedMappings,
sourceSets: sourceSets.items
})
const latestMappings = await cfLoadMappingsFull(resourceId)
commit('dataSucceeded', normalizeFullMappingsResponse(latestMappings))
} catch (e) {
showGlobalError(e.message)
} finally {
@ -664,7 +660,7 @@ export async function createTimeSetDate ({ dispatch, commit, rootGetters, state
const timeSets = await cfLoadTimeSets()
commit('dataSucceeded', {
mappings: updatedMappings,
timeSets: timeSets.items
timeSetMap: buildTimeSetMap(timeSets.items)
})
dispatch('wait/end', 'csc-cf-time-set-create', { root: true })
}
@ -675,7 +671,7 @@ export async function updateTimeSetDate ({ dispatch, commit }, payload) {
await cfUpdateTimeSetDate(payload.id, payload.date)
const timeSets = await cfLoadTimeSets()
commit('dataSucceeded', {
timeSets: timeSets.items
timeSetMap: buildTimeSetMap(timeSets.items)
})
} catch (e) {
showGlobalError(e.message)
@ -711,7 +707,7 @@ export async function deleteTimeSet ({ dispatch, commit, rootGetters, state }, p
const timeSets = await cfLoadTimeSets()
commit('dataSucceeded', {
mappings: updatedMappings,
timeSets: timeSets.items
timeSetMap: buildTimeSetMap(timeSets.items)
})
dispatch('wait/end', 'csc-cf-time-set-create', { root: true })
}
@ -743,7 +739,7 @@ export async function createTimeSetDateRange ({ dispatch, commit, rootGetters, s
const timeSets = await cfLoadTimeSets()
commit('dataSucceeded', {
mappings: updatedMappings,
timeSets: timeSets.items
timeSetMap: buildTimeSetMap(timeSets.items)
})
dispatch('wait/end', 'csc-cf-time-set-create', { root: true })
}
@ -764,7 +760,7 @@ export async function updateTimeSetDateRange ({ dispatch, commit }, payload) {
const timeSets = await cfLoadTimeSets()
commit('dataSucceeded', {
timeSets: timeSets.items
timeSetMap: buildTimeSetMap(timeSets.items)
})
dispatch('wait/end', 'csc-cf-time-set-create', { root: true })
}
@ -785,7 +781,7 @@ export async function createTimeSetWeekdays ({ dispatch, commit, rootGetters, st
const timeSets = await cfLoadTimeSets()
commit('dataSucceeded', {
mappings: updatedMappings,
timeSets: timeSets.items
timeSetMap: buildTimeSetMap(timeSets.items)
})
dispatch('wait/end', 'csc-cf-time-set-create', { root: true })
}
@ -806,7 +802,7 @@ export async function updateTimeSetWeekdays ({ dispatch, commit }, payload) {
const timeSets = await cfLoadTimeSets()
commit('dataSucceeded', {
timeSets: timeSets.items
timeSetMap: buildTimeSetMap(timeSets.items)
})
dispatch('wait/end', 'csc-cf-time-set-create', { root: true })
}
@ -834,7 +830,7 @@ export async function createOfficeHours ({ dispatch, commit, rootGetters, state
commit('dataSucceeded', {
mappings: updatedMappings,
timeSets: timeSets.items
timeSetMap: buildTimeSetMap(timeSets.items)
})
} catch (e) {
showGlobalError(e.message)
@ -853,7 +849,7 @@ export async function updateOfficeHours ({ dispatch, commit, rootGetters, state
const timeSets = await cfLoadTimeSets()
commit('dataSucceeded', {
timeSets: timeSets.items
timeSetMap: buildTimeSetMap(timeSets.items)
})
dispatch('wait/end', 'csc-cf-time-set-create', { root: true })
}
@ -899,7 +895,7 @@ export async function updateAnnouncement ({ dispatch, commit, state }, payload)
const destinationSets = await cfLoadDestinationSets()
commit('dataSucceeded', {
destinationSets: destinationSets.items
destinationSetMap: buildDestinationMap(destinationSets.items)
})
} catch (e) {
showGlobalError(e.message)

@ -1,4 +1,4 @@
import { normalizePrimaryNumber, sortDestinationsByPriority } from 'src/helpers/call-forwarding-destinations'
import { normalizePrimaryNumber } from 'src/helpers/call-forwarding-destinations'
import { CreationState } from 'src/store/common'
function getSeatPrimaryNumber (seat) {
@ -8,43 +8,25 @@ function getSeatPrimaryNumber (seat) {
return normalizePrimaryNumber(seat.primary_number)
}
export function dataSucceeded (state, res) {
if (res.bNumberSets) {
const bNumberSetMap = {}
res.bNumberSets.forEach((bNumberSet) => {
bNumberSetMap[bNumberSet.id] = bNumberSet
})
state.bNumberSetMap = bNumberSetMap
export function dataSucceeded (state, payload) {
if (payload.bNumberSetMap) {
state.bNumberSetMap = payload.bNumberSetMap
}
if (res.destinationSets) {
const destinationSetMap = {}
const orderedDestinationSets = res.destinationSets.map((destinationSet) => {
return {
...destinationSet,
destinations: sortDestinationsByPriority(destinationSet.destinations)
}
})
orderedDestinationSets.forEach((destinationSet) => {
destinationSetMap[destinationSet.id] = destinationSet
})
state.destinationSetMap = destinationSetMap
if (payload.destinationSetMap) {
state.destinationSetMap = payload.destinationSetMap
}
if (res.sourceSets) {
const sourceSetMap = {}
res.sourceSets.forEach((sourceSet) => {
sourceSetMap[sourceSet.id] = sourceSet
})
state.sourceSetMap = sourceSetMap
if (payload.sourceSetMap) {
state.sourceSetMap = payload.sourceSetMap
}
if (res.timeSets) {
const timeSetMap = {}
res.timeSets.forEach((timeSet) => {
timeSetMap[timeSet.id] = timeSet
})
state.timeSetMap = timeSetMap
if (payload.timeSetMap) {
state.timeSetMap = payload.timeSetMap
}
if (res.mappings) {
state.mappings = res.mappings
if (payload.mappings) {
state.mappings = payload.mappings
}
}

@ -0,0 +1,107 @@
import { sortDestinationsByPriority } from 'src/helpers/call-forwarding-destinations'
export const MAPPING_TYPES = [
'cfb',
'cfna',
'cfo',
'cfr',
'cfs',
'cfu',
'cft'
]
export function normalizeFullMappingsResponse (mappings) {
const destinationSetMap = {}
const sourceSetMap = {}
const timeSetMap = {}
const bNumberSetMap = {}
MAPPING_TYPES.forEach((type) => {
mappings[type]?.forEach((mapping) => {
if (mapping.destinationset_id_expand) {
destinationSetMap[mapping.destinationset_id] = {
...mapping.destinationset_id_expand,
destinations: sortDestinationsByPriority(
mapping.destinationset_id_expand.destinations
)
}
delete mapping.destinationset_id_expand
}
if (mapping.sourceset_id_expand) {
sourceSetMap[mapping.sourceset_id] =
mapping.sourceset_id_expand
delete mapping.sourceset_id_expand
}
if (mapping.timeset_id_expand) {
timeSetMap[mapping.timeset_id] =
mapping.timeset_id_expand
delete mapping.timeset_id_expand
}
if (mapping.bnumberset_id_expand) {
bNumberSetMap[mapping.bnumberset_id] =
mapping.bnumberset_id_expand
delete mapping.bnumberset_id_expand
}
})
})
return {
mappings,
destinationSetMap,
sourceSetMap,
timeSetMap,
bNumberSetMap
}
}
export function buildDestinationMap (destinationSets = []) {
return destinationSets.reduce((map, destinationSet) => {
map[destinationSet.id] = {
...destinationSet,
destinations: sortDestinationsByPriority(destinationSet.destinations)
}
return map
}, {})
}
export function buildSourceSetMap (sourceSets = []) {
return sourceSets.reduce((map, sourceSet) => {
map[sourceSet.id] = sourceSet
return map
}, {})
}
export function buildTimeSetMap (timeSets = []) {
return timeSets.reduce((map, timeSet) => {
map[timeSet.id] = timeSet
return map
}, {})
}
export function buildBNumberSetMap (bNumberSets = []) {
return bNumberSets.reduce((map, bNumberSet) => {
map[bNumberSet.id] = bNumberSet
return map
}, {})
}
export function normalizeApiResponse (res) {
return {
bNumberSetMap: res.bNumberSets
? buildBNumberSetMap(res.bNumberSets)
: undefined,
destinationSetMap: res.destinationSets
? buildDestinationMap(res.destinationSets)
: undefined,
sourceSetMap: res.sourceSets
? buildSourceSetMap(res.sourceSets)
: undefined,
timeSetMap: res.timeSets
? buildTimeSetMap(res.timeSets)
: undefined,
mappings: res.mappings
}
}
Loading…
Cancel
Save