JSFiddle - React, Tailwind, and code Playground

by Chandana Thota

HTML

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<pre id="resultPane"></pre>

JavaScript

CurrentDataFormat = [{
  "incentiveType": "COOP",
  "sapConfigNameId": 8,
  "sapConfigName": "PaymentCondition",
  "sapConfigTypeId": 3,
  "sapConfigType": "BeneficiaryBusinessPartner",
  "sapConfigValue": "M25"
}, {
  "incentiveType": "Rebate",
  "sapConfigNameId": 7,
  "sapConfigName": "PaymentCondition",
  "sapConfigTypeId": 3,
  "sapConfigType": "BeneficiaryBusinessPartner",
  "sapConfigValue": "S25"
}, {
  "incentiveType": "COOP",
  "sapConfigNameId": 6,
  "sapConfigName": "OfferingCode",
  "sapConfigTypeId": 5,
  "sapConfigType": "BillableItem",
  "sapConfigValue": "MRSLR"
}, {
  "incentiveType": "COOP",
  "sapConfigNameId": 14,
  "sapConfigName": "SAPProgramCode",
  "sapConfigTypeId": 5,
  "sapConfigType": "BillableItem",
  "sapConfigValue": "MRSLR"
}, {
  "incentiveType": "Rebate",
  "sapConfigNameId": 5,
  "sapConfigName": "OfferingCode",
  "sapConfigTypeId": 5,
  "sapConfigType": "BillableItem",
  "sapConfigValue": "MRSLR"
}, {
  "incentiveType": "Rebate",
  "sapConfigNameId": 13,
  "sapConfigName": "SAPProgramCode",
  "sapConfigTypeId": 5,
  "sapConfigType": "BillableItem",
  "sapConfigValue": "MRSLR"
}]

GroupByCompanyCodesData(CurrentDataFormat);

function GroupByCompanyCodesData(CurrentDataFormat) {
  var refinedArray = {};

  for (i = 0; i < CurrentDataFormat.length; i++) {
    refinedArray[CurrentDataFormat[i].incentiveType] = refinedArray[CurrentDataFormat[i].incentiveType] ? refinedArray[CurrentDataFormat[i].incentiveType] : {};

    refinedArray[CurrentDataFormat[i].incentiveType].name = CurrentDataFormat[i].incentiveType;

    refinedArray[CurrentDataFormat[i].incentiveType].CompanyCodeData = refinedArray[CurrentDataFormat[i].incentiveType].CompanyCodeData ? refinedArray[CurrentDataFormat[i].incentiveType].CompanyCodeData : [];
    refinedArray[CurrentDataFormat[i].incentiveType].CompanyCodeData.push({
      "sapConfigName": CurrentDataFormat[i].sapConfigName,
      "sapConfigValue": CurrentDataFormat[i].sapConfigValue
    });
  }

  var...