2021-06-07 11:16:28 +00:00
|
|
|
import React from "react";
|
|
|
|
|
2021-06-07 17:09:30 +00:00
|
|
|
let capitalizeFirstLetter = (string) => string.charAt(0).toUpperCase() + string.slice(1)
|
|
|
|
|
2021-06-07 11:16:28 +00:00
|
|
|
export function DisplayElement({element}){
|
2021-10-06 10:18:23 +00:00
|
|
|
let otherkeys = Object.keys(element).filter(key => key!="name" && key!="url" && key != "id" && key != "isReferenceValue")
|
2021-06-07 17:09:30 +00:00
|
|
|
let othervalues = otherkeys.map(key => element[key])
|
|
|
|
let otherpairs = otherkeys.map((key,i) => ({key: capitalizeFirstLetter(key), value: othervalues[i]}))
|
2021-10-06 10:18:23 +00:00
|
|
|
|
|
|
|
if(element.url){
|
|
|
|
return(
|
|
|
|
<div>
|
|
|
|
{/*<a href={element.url} target="_blank">*/}
|
|
|
|
<h2>{`${element.name}`}</h2>
|
|
|
|
{/*</a>*/}
|
|
|
|
{otherpairs.map(pair => <p key={pair.value}>{`${pair.key}: ${pair.value}`}</p>)}
|
|
|
|
<p>
|
|
|
|
<a href={element.url} target="_blank">More info</a>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}else{
|
|
|
|
return(
|
|
|
|
<div>
|
2021-06-07 17:09:30 +00:00
|
|
|
<h2>{`${element.name}`}</h2>
|
2021-10-06 10:18:23 +00:00
|
|
|
{otherpairs.map(pair => <p key={pair.value}>{`${pair.key}: ${pair.value}`}</p>)}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-06-07 11:16:28 +00:00
|
|
|
}
|