Skip to content

Commit 8c9bb53

Browse files
committed
fix: 리뷰 요약 모달 중복 조회 완화 및 섹션 렌더 정리
1 parent 61277b2 commit 8c9bb53

4 files changed

Lines changed: 24 additions & 5 deletions

File tree

src/components/product/review/review-item.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ export default function ReviewItem({
120120
const materialFeatures = normalizeToList(
121121
review.initialSecondAnswers?.materialFeatures,
122122
);
123+
const reviewTextByKey = {
124+
sizeReview: review.sizeReview?.[0],
125+
materialReview: review.materialReview?.[0],
126+
textReview: review.textReview,
127+
} as const;
123128

124129
return (
125130
<div className="border-b py-6 last:border-none">
@@ -201,10 +206,7 @@ export default function ReviewItem({
201206
<div className="mb-4 flex flex-col gap-4">
202207
{REVIEW_CONTENT_CONFIG.filter((item) => item.key !== 'textReview').map(
203208
({ label, key }) => {
204-
const text =
205-
key === 'sizeReview'
206-
? review.sizeReview?.[0]
207-
: review.materialReview?.[0];
209+
const text = reviewTextByKey[key];
208210

209211
return (
210212
<div key={key} className="flex flex-col gap-4 text-xl">

src/components/product/review/review-section.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ function createEmptyStats(oneMonthReviewCount: number): ReviewStatsData {
6767
};
6868
}
6969

70+
const REVIEW_FILTER_STICKY_TOP = 188;
71+
7072
/**
7173
* 상품 리뷰 섹션 컴포넌트, 리뷰 탭, 필터, 정렬, 리뷰 리스트 포함
7274
* 리뷰 관련 모든 UI와 상태 관리를 담당
@@ -181,7 +183,10 @@ export default function ProductReviewContent({
181183
/>
182184

183185
{/* Sticky 필터/정렬 바 */}
184-
<div className="sticky top-[188px] z-20 flex flex-col gap-3 bg-white px-4 py-3 transition-all">
186+
<div
187+
className="sticky z-20 flex flex-col gap-3 bg-white px-4 py-3 transition-all"
188+
style={{ top: REVIEW_FILTER_STICKY_TOP }}
189+
>
185190
{/* 내 사이즈 보기 스위치 */}
186191
<div className="flex justify-end space-x-2">
187192
<div className="flex items-center space-x-2">

src/components/product/review/review-summary-modal.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ interface ReviewSummaryModalProps {
3030
reviewType: 'INITIAL' | 'ONE_MONTH';
3131
recommendedSize?: string;
3232
stats?: ReviewStatsData | null;
33+
initialMonthSummaries?: ReviewCategorySummary[];
3334
availableOptions?: {
3435
sizes: string[];
3536
colors: string[];
@@ -43,6 +44,7 @@ export default function ReviewSummaryModal({
4344
reviewType,
4445
recommendedSize,
4546
stats,
47+
initialMonthSummaries,
4648
availableOptions = { sizes: [], colors: [] },
4749
}: ReviewSummaryModalProps) {
4850
const [api, setApi] = useState<CarouselApi>();
@@ -169,6 +171,14 @@ export default function ReviewSummaryModal({
169171
useEffect(() => {
170172
if (!isOpen || reviewType !== 'ONE_MONTH' || !stats) return;
171173

174+
if (initialMonthSummaries && initialMonthSummaries.length >= 2) {
175+
const [initialSizeSummary, initialColorSummary] = initialMonthSummaries;
176+
setBaseMonthSizeStat(initialSizeSummary);
177+
setBaseMonthColorStat(initialColorSummary);
178+
setIsColorLoading(false);
179+
return;
180+
}
181+
172182
let isMounted = true;
173183
setIsColorLoading(true);
174184

@@ -210,6 +220,7 @@ export default function ReviewSummaryModal({
210220
stats,
211221
sizeCategory,
212222
colorCategory,
223+
initialMonthSummaries,
213224
]);
214225

215226
useEffect(() => {

src/components/product/review/review-summary.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export default function ReviewSummarySection({
183183
reviewType={reviewType}
184184
recommendedSize={recommendedSize}
185185
stats={stats}
186+
initialMonthSummaries={monthQuestionSummaries ?? undefined}
186187
availableOptions={availableOptions}
187188
/>
188189
</div>

0 commit comments

Comments
 (0)