I am trying to render a React component that outputs content from an API endpoint.
I am successfully able to display the content, but now I want to add some computation to what is being displayed.
In this example, I want the Badge to be green success badge if the current object has a status of "Enabled", and I want the Badge to be a yellow warning badge if the current object has a status of "Paused".
It does not appear that I can simply use JavaScript here. Any ideas?
Thanks!
const renderInformation = data.map((item) => (
<Card
key={item.id}
title={item.name}
actions={[{ content: "Details" }]}
>
<Card.Section>
<Stack>
if (item.status == 'enabled') { // <---- THIS IS WHERE I WANT TO USE AN IF STATEMENT
<Badge status="success">Enabled</Badge>
}
if (item.status == 'paused') { // <---- THIS IS WHERE I WANT TO USE AN IF STATEMENT
<Badge status="attention">Paused</Badge>
}
</Stack>
</Card.Section>
</Card>
));