JSFiddle - React, Tailwind, and code Playground

by bilbobaggins

JavaScript

let content=[ { firstname: 'redlime',
    rolename: 'summerintern',
    accesstype: 'VO' },
    { firstname: 'redlime11',
    rolename: 'summerintern',
    accesstype: 'AA' }]
    
    
 let validationmap = [{
    inputtype: "textbox",
    inputCustomMapping: "firstname",
    inputname: "firstname",
    inputplaceholder: "Please enter name",
    fieldtypename: "STRING",
    fieldvalidatename: "string",
    fieldmaxlength: "80",
    inputisPrimary: false
  },
  {
    inputtype: "multiselect",
    inputtypemod: "role",
    inputtypeVal: "rolename",
    inputtypeID: "roleid",
    inputParent: "role",
    inputCustomMapping: "rolename",
    inputname: "roleid",
    selecttype: "singleselect",
    inputtextval: "rolename",
    inputplaceholder: "please enter rolename",
    fieldtypename: "INTEGER",
    fieldvalidatename: "number",
    fieldmaxlength: "80",
    inputisPrimary: false
  },
  {
    inputtype: "radio",
    inputtypemod: "accesstype",
    inputtypeVal: "accesstype",
    inputtypeID: "accesstype",
    inputParent: "accesstype",
    inputCustomMapping: "accesstype",
    inputname: "accesstype",
    inputtextval: "accesstype",
    inputplaceholder: "please enter basis",
    fieldtypename: "STRING",
    fieldvalidatename: "string",
    fieldmaxlength: "80",
    inputisPrimary: false,
    childcontent: [{
        val: "VO",
        text: "ViewOnly"
      },
      {
        val: "AA",
        text: "AllAccess"
      }
    ]
  }
];
let childStaticVariable=function(validateMap,content)
{
let col=validateMap.filter(x=>x.childcontent!=undefined)
if(col.length>=0)
{
let getMappingData=function(dt)
{
return (col[0].childcontent).filter(x=>x.val==dt)[0].text
}
content=content.map(function(x) {

  x[col[0].inputtypemod] = getMappingData(x[col[0].inputtypemod]); 
  return x
});
return content
}
}


console.log(childStaticVariable(validationmap,content))