I have the following set of data:
person:
person: { id:1
groups:[
{id:1 , name: john, permissions : [{id:1 , codename="can_edit"},{id:2,codename="can_write"},{id:3,codename="can_delete"}]} ,
]
}
What i wish to do is conduct some conditional rendering based on whether this user has a permission.
{ this.passtest()?
<Button type="primary" shape="circle" icon={<EditOutlined />}/>
:
null
}
This will then call the this.passtest() method which will contain the logic for checking if the user has the permission i require :
passtest(){
const passing = this.props.person.groups.forEach(function(group) {
// Not sure what logic I can put here to return true as long as the permission 'codename' field tallies
});
return passing
}
Would appreciate your help! Thanks!
forEachcall?