[feat] rounding price over $100
This commit is contained in:
@@ -16,6 +16,17 @@ const pokemon = await db.query.cards.findMany({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const formatPrice = (price:any) => {
|
||||||
|
if (price === null) {
|
||||||
|
return "N/A";
|
||||||
|
}
|
||||||
|
price = Number(price);
|
||||||
|
if (price >= 100) {
|
||||||
|
return `${Math.round(price)}`;
|
||||||
|
}
|
||||||
|
return `${price.toFixed(2)}`;
|
||||||
|
};
|
||||||
|
|
||||||
const order = ["Near Mint", "Lightly Played", "Moderately Played", "Heavily Played", "Damaged"];
|
const order = ["Near Mint", "Lightly Played", "Moderately Played", "Heavily Played", "Damaged"];
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -46,7 +57,7 @@ const order = ["Near Mint", "Lightly Played", "Moderately Played", "Heavily Play
|
|||||||
.map((price) => (
|
.map((price) => (
|
||||||
<div class="col p price-label">
|
<div class="col p price-label">
|
||||||
{price.condition.split(' ').map((w) => w[0]).join('')}
|
{price.condition.split(' ').map((w) => w[0]).join('')}
|
||||||
<br />${price.marketPrice}
|
<br />${formatPrice(price.marketPrice)}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user