I am currently mapping an array of objects called ProfileDetails in a table. At the bottom of the table, I have a button where you can decide to accept these details. I am attempting to do a ternary operator to have the button disabled unless ProfileDetails has a TransacationType End. TransactionType.Name === "End". I am getting TransactionType is null. Some users may have more or less than the 4 objects in an array.
Here is what I've tried:
<Grid item xs={2}>
<Grid
container
justify="center">
<Grid item>
{ProfileDetails
.TransactionType
.Name ===
"End" ? (
<Button
variant="contained"
color="primary"
onClick={
handleApprove
}>
Approve
</Button>
) : (
<Button
variant="contained"
color="primary"
disabled>
Approve
</Button>
)}
</Grid>
</Grid>
</Grid>
</Grid>
Example of one of the arrays:
(4) [{…}, {…}, {…}]
0: {ProfileID: 476, Location: Home, TransactionType: {Name: "LogIn", ShortName: null, ID: 1}
1: {ProfileID: 476, Location: Home, TransactionType: {Name: "LogOut", ShortName: null, ID: 1}
2: {ProfileID: 476, Location: Home, TransactionType: {Name: "Break", ShortName: null, ID: 1}
3: {ProfileID: 476, Location: Home, TransactionType: {Name: "End", ShortName: null, ID: 1}
"