diff --git a/com.twin.app.shoptime/src/components/TItemCard/TItemCard.jsx b/com.twin.app.shoptime/src/components/TItemCard/TItemCard.jsx index d6b843ba..3cbe4918 100644 --- a/com.twin.app.shoptime/src/components/TItemCard/TItemCard.jsx +++ b/com.twin.app.shoptime/src/components/TItemCard/TItemCard.jsx @@ -4,6 +4,7 @@ import classNames from "classnames"; import Spottable from "@enact/spotlight/Spottable"; +import usePriceInfo from "../../hooks/usePriceInfo"; import { $L } from "../../utils/helperMethods"; import { SpotlightIds } from "../../utils/SpotlightIds"; import css from "./TItemCard.module.less"; @@ -30,6 +31,9 @@ export default memo(function TItemCard({ type = TYPE_VERTICAL, ...rest }) { + const { originalPrice, discountedPrice, discountRate } = + usePriceInfo(priceInfo); + const handleClick = useCallback( (productId) => { onCardClick && onCardClick(productId); @@ -37,34 +41,6 @@ export default memo(function TItemCard({ [onCardClick, productId] ); - const parsePriceInfo = useCallback( - (priceInfo) => { - const priceParts = priceInfo - .split("|") - .filter((part) => part !== "N") - .map((item) => item.trim()); - - let originalPrice, discountedPrice, discountRate; - - if (priceParts.length === 4) { - [originalPrice, discountedPrice, , discountRate] = priceParts; - } else if (priceParts.length === 2) { - [originalPrice, discountedPrice] = priceParts; - discountRate = null; - } else { - originalPrice = null; - discountedPrice = null; - discountRate = null; - } - - return { originalPrice, discountedPrice, discountRate }; - }, - [priceInfo] - ); - - const { originalPrice, discountedPrice, discountRate } = - parsePriceInfo(priceInfo); - return (