import React, { memo, useCallback } from "react"; import classNames from "classnames"; import Spottable from "@enact/spotlight/Spottable"; import IcLiveShow from "../../../assets/images/tag/tag-liveshow.svg"; import usePriceInfo from "../../hooks/usePriceInfo"; import { $L } from "../../utils/helperMethods"; import CustomImage from "../CustomImage/CustomImage"; import css from "./TItemCard.module.less"; const SpottableComponent = Spottable("div"); const TYPES = { vertical: "vertical", horizontal: "horizontal", videoShow: "videoShow", }; const IMAGETYPES = { imgHorizontal: "imgHorizontal", imgVertical: "imgVertical", }; // @@pyh Todo, 추후 다국어 resource 추가 const STRING_CONF = { SOLD_OUT: $L("SOLD OUT"), TOP: $L("TOP"), }; export const removeDotAndColon = (string) => { return /[.:]/.test(string) ? string.replace(/[.:]/g, "") : string; }; export default memo(function TItemCard({ children, disabled, imageAlt, imageSource, imgType = IMAGETYPES.imgHorizontal, logo, logoDisplay = false, isBestSeller = false, isLive = false, onBlur, onClick, onFocus, priceInfo, productId, productName, rank, soldoutFlag, spotlightId, nonPosition = false, type = TYPES.vertical, ...rest }) { const { originalPrice, discountedPrice, discountRate } = usePriceInfo(priceInfo) || {}; const _onBlur = useCallback(() => { if (onBlur) { onBlur(); } }, [onBlur]); const _onClick = useCallback( (e) => { if (disabled) { e.stopPropagation(); return; } if (onClick) { onClick(e); } }, [onClick, disabled] ); const _onFocus = useCallback(() => { if (onFocus) { onFocus(); } }, [onFocus]); return (
{discountRate && {discountRate}} {soldoutFlag && soldoutFlag === "Y" && (
{STRING_CONF.SOLD_OUT}
)}

{productName}

{discountRate ? discountedPrice : originalPrice} {discountRate && {originalPrice}}

{isBestSeller && rank && (
{STRING_CONF.TOP} {rank}
)} {isLive && ( )}
); }); export { IMAGETYPES, TYPES };