I’m trying to add a little tracking component that brings in a tracking number and carrier from an array. From there, it should add a url to the carrier website. I need to add an if statement or something so when it sees a specific carrier, it adds the url but I’m struggling.
renderTrackingNumbers() {
const { order: { tracking_info } } = this.props;
const trackingNumbers = tracking_info.map((tracking_info) => (
<div key={ tracking_info.id }>
<a href="{ tracking_url_should_be_added_here }">{ tracking_info.tracking_number }</a>
{ ' ' }
-
{ ' ' }
{ tracking_info.carrier_code }
</div>
));
return (
<div>
<h4>{ __('Tracking Numbers') }</h4>
<div>
{ trackingNumbers }
</div>
</div>
);
}
Here is the data I’m receiving from GraphQL:
[
{
"tracking_number": "231300687629630",
"carrier_code": "fedex"
},
{
"tracking_number": "1234567890",
"carrier_code": "dhl"
},
{
"tracking_number": "1Z12345E0305271640",
"carrier_code": "ups"
},
{
"tracking_number": "123465789123456",
"carrier_code": "usps"
}
]
Any help would be awesome.