title: React - conditionally show certain prices based on an API value
body: <p>In our API we have MANY 'dealer-name' values. &quot;CATERPILLAR FINANCIAL SERVICES CORPORATION&quot; and everything else.</p>
  <p>I'm trying to do two things:</p>
  <ol>
  <li>If any other product comes back with the dealer-name of CATERPILLAR FINANCIAL SERVICES CORPORATION, put the conversion rate to 1.32.</li>
  <li>All other products will have a conversion rate of 0.74.</li>
  </ol>
  <p>There's logic in place that has the rate pricing already setup :</p>
  <pre><code>export function formatPrice(
    price,
    lang,
    inclCurTxt?: boolean,
    currency?: string
  ) {
    let formattedPrice = price;
  
    const usaRate = 0.74;
  
    const currencyText = inclCurTxt ? &quot; USD&quot; : &quot;&quot;;
      if (currency != null &amp;&amp; currency === &quot;US&quot;) {
        //USD
        formattedPrice =
          accounting.formatMoney(Number(price) * usaRate, &quot;$&quot;, 0) + currencyText;
      } else {
        //CAD
        formattedPrice = accounting.formatMoney(price, &quot;$&quot;, 0) + currencyText;
      }
    return formattedPrice;
  </code></pre>
  <p>I've written out an exportable getConversionRate function that goes through the logic I've explained at the top:</p>
  <pre><code>export function getConversionRate() {
    let usaRate = 0.74;
    if (isEnvironmentBFE()) {
      const catName = &quot;CATERPILLAR FINANCIAL SERVICES CORPORATION&quot;;
  
      // If it contains Cat Financial products, make US rate 1.32.
      if (detailsHtml.dealerId === catName) {
        usaRate = 1.32;
      }
    }
  }
  </code></pre>
  <p>I've imported the getConversionRate function into the file and placed some code into the rendered details of the product on the page, however it's not working:</p>
  <pre><code>&lt;div className=&quot;price-wrap&quot;&gt;
  &lt;img
     className=&quot;flagimg&quot;
     src={Constants.IMAGES.FLAG_CA}
     alt=&quot;CDN $&quot;/&gt;
     &lt;span className=&quot;data_price_cad&quot;&gt;{getConversionRate(detailsHtml.itemPriceCA)}&lt;/span&gt;
  &lt;/div&gt;
  &lt;div className=&quot;price-wrap&quot;&gt;
   &lt;img
     className=&quot;flagimg&quot;
     src={Constants.IMAGES.FLAG_US}
     alt=&quot;US $&quot;/&gt;
     &lt;span className=&quot;data_price_usd&quot;&gt;{getConversionRate(detailsHtml.itemPriceUS)}&lt;/span&gt;&lt;/div&gt;
  </code></pre>
  <p>Am I implementing the getConversionRate incorrectly?</p>