[251104] fix: Review data validation - hide all review UI if API response is incomplete

데이터 일관성 문제 해결:
- API가 불완전한 응답을 주는 경우, 리뷰 관련 UI(버튼, 미리보기, ShowUserReviews)를 모두 숨김
- 미리보기만 표시되고 버튼이 없는 상황 방지로 프론트엔드 버그 오인 방지
- isReviewDataComplete 검증 로직 추가: hasReviews && previewReviews && stats.totalReviews 모두 확인

 - ProductAllSection.jsx
This commit is contained in:
2025-11-04 13:33:39 +09:00
parent 4e945980cb
commit 1554c82705

View File

@@ -174,7 +174,7 @@ export default function ProductAllSection({
const youmaylikeData = useSelector((state) => state.main.youmaylikeData);
// ProductVideo 버전 관리 (1: 기존 modal 방식, 2: 내장 방식 , 3: 비디오 생략)
const [productVideoVersion, setProductVideoVersion] = useState(3);
const [productVideoVersion, setProductVideoVersion] = useState(2);
// const [currentHeight, setCurrentHeight] = useState(0);
//하단부분까지 갔을때 체크용
@@ -315,6 +315,18 @@ export default function ProductAllSection({
// selectedReduxState: _debug?.reviewVersion === 1 ? 'reviewData' : 'reviewListData'
// });
// 리뷰 데이터 완전성 검증 - API가 불완전하면 모든 리뷰 UI를 숨김
const isReviewDataComplete = useMemo(() => {
return (
hasReviews &&
previewReviews &&
previewReviews.length > 0 &&
stats &&
stats.totalReviews !== undefined &&
stats.totalReviews > 0
);
}, [hasReviews, previewReviews, stats]);
// 별점 높은 순으로 정렬된 상위 5개 리뷰 (방법 2: useMemo 최적화)
const topRatedPreviewReviews = useMemo(() => {
if (!previewReviews || previewReviews.length === 0) {
@@ -866,7 +878,7 @@ export default function ProductAllSection({
>
{$L('PRODUCT DETAILS')}
</TButton>
{hasReviews && (
{isReviewDataComplete && (
<>
{/*
{console.log('[ProductAllSection_useReviewList] 🎯 버튼 렌더링:', {
@@ -1019,12 +1031,12 @@ export default function ProductAllSection({
>
<ProductDescription productInfo={productData} />
</div>
{/* 리뷰가 있을 때만 UserReviews 섹션 표시 */}
{/* 리뷰 데이터가 완전할 때만 UserReviews 섹션 표시 */}
<div
id="scroll-marker-user-reviews"
className={css.scrollMarker}
></div>
{hasReviews && (
{isReviewDataComplete && (
<div
id="user-reviews-section"
ref={reviewRef}