import React from "react"; import { getPriceString, isValidSpecValue, validateSpecValue, } from "../../utils/functions"; import ColorChips from "../ColorChips"; import PickLabel from "../PickLabel"; import RankingLabel from "../RankingLabel"; import RingProgress from "../RingProgress"; import Link from "../shared/Link"; import { IProductV2Props } from "./ProductV2.types"; const NUMBER_OF_HIGHLIGHT_INDEX = 3; const NUMBER_OF_KEY_SPEC_PREVIEW = 4; const ProductV2 = ({ className = "", isMobile, index, parentCategory, category, productData, scoreInfoType = "totalScore", showIndex = false, NewTabLink, NextImage, }: IProductV2Props) => { const { thumbnailUrl, brandName, modelName, productName, colors, pickType, price, keySpec, totalScoreInfo, rankingScoreInfo, rankingRuleTagInfo, reviewAverage, reviewCount, } = { ...productData, brandName: productData.brandName ?? "", productName: productData.productName ?? "", }; const isHighLightedIndex = index !== undefined && index <= NUMBER_OF_HIGHLIGHT_INDEX; const showReviewAverageAndCount = reviewCount !== 0; const keySpecPreviewList = keySpec?.specList .filter((spec) => !spec.hiddenOnEmptyValue && isValidSpecValue(spec.value)) .slice(0, NUMBER_OF_KEY_SPEC_PREVIEW); const scoreInfo = scoreInfoType === "totalScore" ? totalScoreInfo : { ...rankingScoreInfo, title: "랭킹 점수" }; return (
{/* pc 제품 이미지 영역 */}
{index}
{NextImage ? ( ) : ( {modelName} )}
{/* mobile 컨텐츠 */}
{/* 제품 이미지 정보 */}
{index}
{NextImage ? ( ) : ( {modelName} )}
{/* 픽 라벨 / 제품명 / 가격 / 별점 및 후기 수 */}
{pickType !== "none" && (
{rankingRuleTagInfo && ( )}
)}
{validateSpecValue(brandName)} {validateSpecValue(modelName)}{" "} {validateSpecValue(productName)}
{getPriceString(price)}
{showReviewAverageAndCount && (
★ {reviewAverage} ({reviewCount})
)}
{/* 주요 스펙 */}
{keySpecPreviewList?.map((specItem) => { const { name, value } = specItem; return (
{name} {value}
); })}
{/* 랭킹 그룹 점수 */}
e.preventDefault()} >
{scoreInfo.title}
{scoreInfo.composedScoreList.map((composedScoreItem) => { const { title, score } = composedScoreItem; const ringProgressWidth = 45 * 0.125; const ringProgressSize = 45 + 45 * 0.25; return (
{title}
); })}
); }; export default ProductV2;