Skip to content

Commit

Permalink
Chore: price locale string 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
gahyuun committed Jan 25, 2024
1 parent e21a569 commit c53b9f1
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/pages/home/accomodationItem/AccomodationItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ const AccommodationItem = ({ data }: { data: Accommodation }) => {
navigate(`/accommodation?id=${data.id}`);
};

const couponName = data.couponName;
let rateCouponName = couponName;

if (couponName.includes("원")) {
const index = couponName.indexOf("원");
const prefix = couponName.slice(0, index);
const parsedNumber = Number(prefix);
if (!isNaN(parsedNumber)) {
rateCouponName = parsedNumber.toLocaleString() + "원 할인";
}
}

return (
<div className="accomdationItem-container" onClick={navigateHandler}>
<div
Expand All @@ -20,7 +32,7 @@ const AccommodationItem = ({ data }: { data: Accommodation }) => {
>
{data.couponName && (
<div className="accomdationItem-container__coupon-box">
{data.couponName}
{rateCouponName}
</div>
)}
</div>
Expand All @@ -44,12 +56,10 @@ const AccommodationItem = ({ data }: { data: Accommodation }) => {

<div className="price-container">
{data.discountPrice !== data.lowestPrice && (
<div className="price">
{data.discountPrice.toLocaleString()}
</div>
<div className="price">{data.lowestPrice.toLocaleString()}</div>
)}
<div className="lowest-price">
{data.lowestPrice.toLocaleString()}
{data.discountPrice.toLocaleString()}
</div>
</div>
</div>
Expand Down

0 comments on commit c53b9f1

Please sign in to comment.