docs: function setIndexesForSegments(
    segmentsObject = null,
    serviceSegmentsObject = null
  ) {
    const segments = segmentsObject
      ? Object.keys(segmentsObject).map(k => segmentsObject[k])
      : null;
  
    const serviceSegments = serviceSegmentsObject
      ? Object.keys(serviceSegmentsObject).map(k => serviceSegmentsObject[k])
      : null;
  
    if (segments === null && serviceSegments === null) {
      return { segments, serviceSegments };
    }
  
    if (segments !== null && serviceSegments === null) {
      const segmentsNew = segments.map((segment, key) => ({
        ...segment,
        index: key + 1,
      }));
      return { segments: segmentsNew, serviceSegments };
    }
  
    if (segments === null && serviceSegments !== null) {
      const serviceSegmentsNew = serviceSegments.map(
        (segment, key) => ({
          ...segment,
          index: key + 1,
        })
      );
      return { segments, serviceSegments: serviceSegmentsNew };
    }
  
    const maxSegmentsTravelOrder = segments.reduce(travelOrderReducer, 0);
    const maxServiceSegmentsTravelOrder = serviceSegments.reduce(travelOrderReducer, 0);
  
    const maxOrder = Math.max(
      maxSegmentsTravelOrder,
      maxServiceSegmentsTravelOrder
    );
  
    const allSegments = [];
  
    for (let i = 1; i <= maxOrder; i += 1) {
      segments.forEach(s => (Number(s.TravelOrder) === i ? allSegments.push(s) : null));
      serviceSegments.forEach(s => (Number(s.TravelOrder) === i ? allSegments.push(s) : null));
    }
  
    const indexedSegments = allSegments.map((s, k) => ({ ...s, index: k + 1 }));
  
    return {
      segments: indexedSegments.filter(s => s.SegmentType === undefined),
      serviceSegments: indexedSegments.filter(s => s.SegmentType === 'Service'),
    };
  }