@veloceapps/sdk 7.0.2-34 → 7.0.2-36

Sign up to get free protection for your applications and to get access to all the features.
@@ -1102,6 +1102,10 @@ class FlowHeaderComponent {
1102
1102
  date.setHours(0, 0, 0, 0);
1103
1103
  const now = date.getTime();
1104
1104
  const termParentIds = lineItems.map(li => li.rampInstanceId).filter(Boolean);
1105
+ const lineItemsRampInstanceIdMap = lineItems.reduce((acc, li) => {
1106
+ acc[li.rampInstanceId ?? ''] = li;
1107
+ return acc;
1108
+ }, {});
1105
1109
  return lineItems.reduce((result, li) => {
1106
1110
  // find main term line item
1107
1111
  if (li.rampInstanceId) {
@@ -1110,23 +1114,20 @@ class FlowHeaderComponent {
1110
1114
  // find current term line item
1111
1115
  let target = li;
1112
1116
  while (target && target.endDate && new Date(target.endDate).getTime() <= now) {
1113
- target = lineItems.find(sub => sub.rampInstanceId === li.id);
1117
+ target = lineItemsRampInstanceIdMap[li.id];
1114
1118
  }
1115
1119
  if (target && target.productId) {
1116
- return [
1117
- ...result,
1118
- {
1119
- id: target.id,
1120
- productId: target.productId,
1121
- name: target.name,
1122
- configurable: target.properties['#configurable'] === 'true',
1123
- deleted: target.actionCode === 'DELETE',
1124
- hasTerm: termParentIds.includes(target.id),
1125
- qty: target.qty,
1126
- mrr: this.formatMetric(target.properties.VDM_Total_MRR),
1127
- nrr: this.formatMetric(target.properties.VDM_Total_NRR),
1128
- },
1129
- ];
1120
+ result.push({
1121
+ id: target.id,
1122
+ productId: target.productId,
1123
+ name: target.name,
1124
+ configurable: target.properties['#configurable'] === 'true',
1125
+ deleted: target.actionCode === 'DELETE',
1126
+ hasTerm: termParentIds.includes(target.id),
1127
+ qty: target.qty,
1128
+ mrr: this.formatMetric(target.properties.VDM_Total_MRR),
1129
+ nrr: this.formatMetric(target.properties.VDM_Total_NRR),
1130
+ });
1130
1131
  }
1131
1132
  return result;
1132
1133
  }, []);