[251101] fix: CheckOutPanel Mock-3

🕐 커밋 시간: 2025. 11. 01. 22:03:38

📊 변경 통계:
  • 총 파일: 7개
  • 추가: +484줄
  • 삭제: -162줄

📁 추가된 파일:
  + com.twin.app.shoptime/get_console_logs.js

📝 수정된 파일:
  ~ com.twin.app.shoptime/package-lock.json
  ~ com.twin.app.shoptime/package.json
  ~ com.twin.app.shoptime/src/utils/mockDataSafetyUtils.js
  ~ com.twin.app.shoptime/src/views/CheckOutPanel/CheckOutPanel.jsx
  ~ com.twin.app.shoptime/src/views/CheckOutPanel/container/SummaryContainerMock.jsx
  ~ com.twin.app.shoptime/src/views/DetailPanel/components/BuyOption.jsx

🔧 주요 변경 내용:
  • 프로젝트 의존성 관리 개선
  • 공통 유틸리티 함수 최적화
  • UI 컴포넌트 아키텍처 개선
  • 로깅 시스템 개선
  • 대규모 기능 개발
  • 모듈 구조 개선

BREAKING CHANGE: API 또는 설정 변경으로 인한 호환성 영향 가능
This commit is contained in:
2025-11-01 22:03:42 +09:00
parent 6292e84052
commit 830dc65871
7 changed files with 554 additions and 162 deletions

View File

@@ -23,6 +23,7 @@ import {
showError,
} from '../../../actions/commonActions';
import { getProductCouponSearch } from '../../../actions/couponActions';
import { getSafeProductPrice } from '../../../utils/mockDataSafetyUtils';
import {
sendLogPaymentEntry,
sendLogTotalRecommend,
@@ -448,26 +449,58 @@ const BuyOption = ({
if (userNumber && selectedPatnrId && selectedPrdtId && quantity) {
const { prodOptCval, priceInfo } = selectedOptions || {};
const { patncNm, brndNm, catNm, prdtNm, prdtId } = productInfo;
console.log('[BuyOption] handleClickOrder - productInfo:', productInfo);
console.log('[BuyOption] handleClickOrder - selectedOptions:', selectedOptions);
console.log('[BuyOption] handleClickOrder - priceInfo:', priceInfo);
console.log('[BuyOption] handleClickOrder - logInfo:', logInfo);
// priceInfo 파싱 및 숫자 변환
let regularPrice = parseInt(priceInfo?.split('|')[0], 10) || 0;
let discountPrice = parseInt(priceInfo?.split('|')[1], 10) || 0;
// productInfo에서 직접 price2, price5 추출 (가장 신뢰할 수 있는 소스)
// price2 = 상품 가격 ("$ 521.66" 형식)
// price5 = 쿠폰 할인 ("$ 104.33" 형식)
const extractNumericPrice = (priceStr) => {
if (typeof priceStr === 'number') return priceStr;
if (typeof priceStr === 'string') {
const numMatch = priceStr.match(/[\d.]+/);
return numMatch ? parseFloat(numMatch[0]) : 0;
}
return 0;
};
const price2Value = extractNumericPrice(productInfo?.price2);
const price5Value = extractNumericPrice(productInfo?.price5);
console.log('[BuyOption] handleClickOrder - productInfo.price2:', productInfo?.price2, '-> extracted:', price2Value);
console.log('[BuyOption] handleClickOrder - productInfo.price5:', productInfo?.price5, '-> extracted:', price5Value);
// 가격 계산:
// discountPrice = price2 (상품 가격)
// regularPrice = price2 + price5 (상품 가격 + 할인액 = 원래 가격)
let discountPrice = price2Value > 0 ? price2Value : 0;
let regularPrice = price2Value + price5Value; // price2 + price5 = 원래 가격
const discountRate = priceInfo?.split('|')[4];
// selectedOptions가 없으면 logInfo에서 가격 추출
console.log('[BuyOption] handleClickOrder - Calculated prices - regularPrice:', regularPrice, 'discountPrice:', discountPrice);
// selectedOptions가 없고 logInfo가 있으면, logInfo의 가격도 고려
if (!selectedOptions && logInfo) {
console.log('[BuyOption] handleClickOrder - selectedOptions is undefined, using logInfo prices');
console.log('[BuyOption] handleClickOrder - selectedOptions is undefined, checking logInfo prices');
// logInfo의 dcBefPrc와 dcAftrPrc는 "$ 521.66" 형식이므로 숫자만 추출 (소수점 포함)
const dcBefPrcMatch = logInfo.dcBefPrc?.match(/[\d.]+/);
const dcAftrPrcMatch = logInfo.dcAftrPrc?.match(/[\d.]+/);
regularPrice = dcBefPrcMatch ? parseFloat(dcBefPrcMatch[0]) : 0;
discountPrice = dcAftrPrcMatch ? parseFloat(dcAftrPrcMatch[0]) : regularPrice;
console.log('[BuyOption] handleClickOrder - extracted from logInfo - dcBefPrc:', logInfo.dcBefPrc, 'dcAftrPrc:', logInfo.dcAftrPrc);
const logRegularPrice = dcBefPrcMatch ? parseFloat(dcBefPrcMatch[0]) : 0;
const logDiscountPrice = dcAftrPrcMatch ? parseFloat(dcAftrPrcMatch[0]) : logRegularPrice;
// logInfo의 가격이 있으면 우선
if (logRegularPrice > 0 || logDiscountPrice > 0) {
regularPrice = logRegularPrice > 0 ? logRegularPrice : regularPrice;
discountPrice = logDiscountPrice > 0 ? logDiscountPrice : discountPrice;
console.log('[BuyOption] handleClickOrder - Using logInfo prices - regularPrice:', regularPrice, 'discountPrice:', discountPrice);
}
}
console.log('[BuyOption] handleClickOrder - regularPrice:', regularPrice, 'discountPrice:', discountPrice, 'discountRate:', discountRate);
console.log('[BuyOption] handleClickOrder - Final prices - regularPrice:', regularPrice, 'discountPrice:', discountPrice, 'discountRate:', discountRate);
dispatch(
sendLogTotalRecommend({
@@ -538,22 +571,63 @@ const BuyOption = ({
imgUrl: imgUrl, // 상품 이미지 URL 추가
};
// 필수 데이터 검증
if (!productInfo || !productInfo.prdtId) {
console.error('%c[BuyOption] ❌ FAIL - productInfo is invalid:', 'background: red; color: white; font-weight: bold; padding: 5px;', productInfo);
dispatch(showError(null, 'Product information is missing', false, null, null));
return;
}
console.log('%c[BuyOption] ✅ SUCCESS - productInfo is valid:', 'background: green; color: white; font-weight: bold; padding: 5px;', productInfo.prdtId);
const checkoutPanelInfo = {
logInfo: { ...logInfo, cartTpSno: `MOCK_${Date.now()}` },
productInfo: productInfo,
productInfo: {
prdtId: productInfo.prdtId,
prdtNm: productInfo.prdtNm,
patnrId: selectedPatnrId,
patncNm: patncNm,
// calculateOrderSummaryFromProductInfo 함수가 필요한 필드들
// productInfo에서 직접 추출한 값을 전달
price2: price2Value, // Items (상품 가격)
price5: price5Value, // Coupon Savings (할인액)
finalPrice: discountPrice,
discount: price5Value,
origPrice: regularPrice,
discountPrice: discountPrice,
// 추가 가격 필드들 (fallback용)
price: discountPrice,
originalPrice: regularPrice,
// 이미지 정보
...(productInfo.imgList && { imgList: productInfo.imgList }),
...(productInfo.thumbnailUrl && { thumbnailUrl: productInfo.thumbnailUrl }),
...(productInfo.imgUrls && { imgUrls: productInfo.imgUrls }),
shippingCharge: 0, // 배송비
currSign: '$',
currSignLoc: 'left',
},
defaultPrice: discountPrice,
};
console.log('[BuyOption] Mock Mode - mockProductInfo:', mockProductInfo);
console.log('[BuyOption] Mock Mode - regularPrice(숫자):', regularPrice, 'discountPrice(숫자):', discountPrice);
console.log('[BuyOption] Mock Mode - checkoutPanelInfo.productInfo price fields:', {
price2: price2Value,
price5: price5Value,
finalPrice: discountPrice,
origPrice: regularPrice,
discountPrice: discountPrice,
});
console.log('[BuyOption] Mock Mode - checkoutPanelInfo:', checkoutPanelInfo);
console.log('[BuyOption] Mock Mode - regularPrice:', regularPrice, 'discountPrice:', discountPrice);
console.log('%c[BuyOption] ▶️ BEFORE pushPanel dispatch', 'background: orange; color: white; font-weight: bold; padding: 5px;');
dispatch(
pushPanel({
name: Config.panel_names.CHECKOUT_PANEL,
panelInfo: checkoutPanelInfo,
})
);
console.log('[BuyOption] pushPanel dispatch completed');
console.log('%c[BuyOption] ✅ AFTER pushPanel dispatch', 'background: orange; color: white; font-weight: bold; padding: 5px;');
}
}
dispatch(clearAllToasts());