JSFiddle - React, Tailwind, and code Playground

by dougiei

JavaScript

const assocProductAccountPlan ={
    relrec : {relrecuuidname : "ProductAccountPlanRelUuid", value : "" },
    category : "AccountPlan" ,
    srcEntity :"Product",
    tgtEntity : "AccountPlan",
    tgtShortName :"",
    tgtName :
    optAttr : {key : "ProductAccountPlanRelType", value:""}
};

const testdata = {
    "ProductAccountPlanRelUuid": "4DA3B9FB979D7D242A4D39A1725B5D7E",
    "ProductAccountPlanRelInfo": {
        "ProductAccountPlanRelType": "Cash With Application",
        "ProductShortName": "Personal Savings",
        "AccountPlanUuid": "012723A2CE434859BA9DC1344CD84415",
        "ProductUuid": "83A3A2C666F892AD71B1BEE439ED5DC6",
        "AccountPlanShortName": "26feb_deom1122334"
    }
}

parseRelRec =function( template, data){

targetObj = Object.assign ( template)

console.log(template.relrec.relrecuuidname)
console.log(template.optAttr.key)

targetObj.relrec.value = data[template.relrec.relrecuuidname];
targetObj.optAttr.value =data["ProductAccountPlanRelInfo"][template.optAttr.key]

return targetObj
}

 
console.log (assocProductAccountPlan)

 

 

const rec1 = parseRelRec (assocProductAccountPlan, testdata)

console.log (rec1)