@@ -4,9 +4,10 @@ import { addComma } from "@/shared/utils/add-comma";
44import { MEMBERSHIP_DATA , PAY_BENEFITS_DATA } from "@/shared/constants/benefit" ;
55import { PayBenefit } from "@/shared/components/benefit/pay-benefit" ;
66import { MoreBenefit } from "@/shared/components/benefit/more-benefit" ;
7- import { ChevronRightRounded , Share , Star } from "@/assets/svg" ;
7+ import { ChevronRightRounded , Share } from "@/assets/svg" ;
88import { Text } from "../text/text" ;
9- interface ProductMainInfoProps {
9+ import { getProductStatsList } from "../../utils/get-product-stats" ;
10+ export interface ProductMainInfoProps {
1011 authorName : string ;
1112 productName : string ;
1213 originalPrice : number ;
@@ -18,6 +19,8 @@ interface ProductMainInfoProps {
1819}
1920
2021export const ProductMainInfo = ( { data } : { data : ProductMainInfoProps } ) => {
22+ const statsList = getProductStatsList ( data ) ; // 제품 부가정보 데이터 포맷팅 함수
23+
2124 return (
2225 < div className = { styles . container } >
2326 { /** 제품 메인 정보 */ }
@@ -80,28 +83,20 @@ export const ProductMainInfo = ({ data }: { data: ProductMainInfoProps }) => {
8083 { /** 제품 부가 정보 */ }
8184 < div className = { styles . extraInfo } >
8285 < div className = { styles . flexRow } >
83- < div className = { styles . extraInfoItem } >
84- < Star />
85- < Text type = "caption" color = "black-200" >
86- { data . averageScore }
87- </ Text >
88- </ div >
89- < div className = { styles . extraInfoItem } >
90- < Text type = "caption" color = "gray-300" >
91- 후기
92- </ Text >
93- < Text type = "caption" color = "gray-100" >
94- { addComma ( String ( data . reviewCount ) ) }
95- </ Text >
96- </ div >
97- < div className = { styles . extraInfoItem } >
98- < Text type = "caption" color = "gray-300" >
99- 구매
100- </ Text >
101- < Text type = "caption" color = "gray-100" >
102- { addComma ( String ( data . salesCount ) ) }
103- </ Text >
104- </ div >
86+ { statsList . map ( ( stat , index ) => (
87+ < div key = { index } className = { styles . extraInfoItem } >
88+ { typeof stat . label === "string" ? (
89+ < Text type = "caption" color = "gray-300" >
90+ { stat . label }
91+ </ Text >
92+ ) : (
93+ stat . label
94+ ) }
95+ < Text type = "caption" color = { stat . color } >
96+ { stat . value }
97+ </ Text >
98+ </ div >
99+ ) ) }
105100 </ div >
106101 < button type = "button" aria-label = "공유하기" >
107102 < Share />
0 commit comments