|
135 | 135 | * @param {number} significantDigits |
136 | 136 | * @returns {string} |
137 | 137 | */ |
138 | | - currencyFormatter: (n, significantDigits = 5) => { |
| 138 | + currencyFormatter: (n, significantDigits) => { |
| 139 | + const isWhole = Number.isInteger(n); |
139 | 140 | const options = { |
140 | 141 | style: "currency", |
141 | 142 | currency: "USD" |
142 | 143 | }; |
143 | | - |
144 | | - // Only add maximumSignificantDigits if significantDigits is provided and valid |
145 | | - if (significantDigits && significantDigits > 0) { |
| 144 | + if (significantDigits !== undefined) { |
146 | 145 | options.maximumSignificantDigits = significantDigits; |
| 146 | + } else { |
| 147 | + options.minimumFractionDigits = isWhole ? 0 : 2; |
| 148 | + options.maximumFractionDigits = isWhole ? 0 : 2; |
147 | 149 | } |
148 | | - |
149 | 150 | return new Intl.NumberFormat("en-US", options).format(n); |
150 | 151 | }, |
151 | 152 | }; |
|
334 | 335 |
|
335 | 336 | const tier = regionsTiers[tierKey].tier; |
336 | 337 |
|
337 | | - const formattedWithoutWAF = utils.currencyFormatter(tiersCosts[tier].withoutWAF); |
338 | | - const formattedWithWAF = utils.currencyFormatter(tiersCosts[tier].withWAF); |
339 | | - const formattedDeploymentWithoutWAF = utils.currencyFormatter(costs.deploymentFee[tier].withoutWAF); |
340 | | - const formattedDeploymentWithWAF = utils.currencyFormatter(costs.deploymentFee[tier].withWAF); |
| 338 | + const formattedWithoutWAF = utils.currencyFormatter(tiersCosts[tier].withoutWAF, 5); |
| 339 | + const formattedWithWAF = utils.currencyFormatter(tiersCosts[tier].withWAF, 5); |
| 340 | + const formattedDeploymentWithoutWAF = utils.currencyFormatter(costs.deploymentFee[tier].withoutWAF, 5); |
| 341 | + const formattedDeploymentWithWAF = utils.currencyFormatter(costs.deploymentFee[tier].withWAF, 5); |
341 | 342 |
|
342 | 343 | col1.innerText = `${regionsTiers[tierKey].label}`; |
343 | 344 | col2.innerText = `${tier}`; |
|
0 commit comments