[251102] fix: CartPanel mock-2
🕐 커밋 시간: 2025. 11. 02. 11:04:08 📊 변경 통계: • 총 파일: 10개 • 추가: +453줄 • 삭제: -162줄 📝 수정된 파일: ~ com.twin.app.shoptime/src/actions/mockCartActions.js ~ com.twin.app.shoptime/src/reducers/mockCartReducer.js ~ com.twin.app.shoptime/src/utils/BuyNowDataManipulator.js ~ com.twin.app.shoptime/src/views/CartPanel/CartPanel.jsx ~ com.twin.app.shoptime/src/views/CartPanel/CartProduct.jsx ~ com.twin.app.shoptime/src/views/CartPanel/CartSidebar.jsx ~ 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 ~ com.twin.app.shoptime/src/views/MainView/MainView.jsx 🔧 주요 변경 내용: • 핵심 비즈니스 로직 개선 • 공통 유틸리티 함수 최적화 • UI 컴포넌트 아키텍처 개선 • 대규모 기능 개발 • 모듈 구조 개선
This commit is contained in:
@@ -823,9 +823,51 @@ const BuyOption = ({
|
||||
productInfo?.patncLogPath ||
|
||||
'/assets/images/img-thumb-empty-144@3x.png';
|
||||
|
||||
// 가격 정보 구성
|
||||
const regularPrice = productInfo?.regularPrice || 299.99;
|
||||
const discountPrice = productInfo?.discountPrice || regularPrice;
|
||||
// ✅ 정확한 가격 추출 (Mock Mode와 동일한 로직)
|
||||
console.log('[BuyOption] API Mode ADD TO CART - Extracting accurate prices from productInfo');
|
||||
console.log('[BuyOption] API Mode ADD TO CART - productInfo.price2:', productInfo?.price2);
|
||||
console.log('[BuyOption] API Mode ADD TO CART - productInfo.price5:', productInfo?.price5);
|
||||
console.log('[BuyOption] API Mode ADD TO CART - productInfo.priceInfo:', productInfo?.priceInfo);
|
||||
|
||||
// 정확한 가격 추출 로직
|
||||
const extractNumericPrice = (value) => {
|
||||
if (typeof value === 'number') return value;
|
||||
if (typeof value === 'string') {
|
||||
const numMatch = value.match(/[\d.]+/);
|
||||
return numMatch ? parseFloat(numMatch[0]) : 0;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
const price2Value = extractNumericPrice(productInfo?.price2);
|
||||
const price5Value = extractNumericPrice(productInfo?.price5);
|
||||
|
||||
console.log('[BuyOption] API Mode ADD TO CART - extracted price2Value:', price2Value);
|
||||
console.log('[BuyOption] API Mode ADD TO CART - extracted price5Value:', price5Value);
|
||||
|
||||
// 정확한 가격 계산 (ProductAllSection의 가격 정보 사용)
|
||||
let discountPrice = price2Value > 0 ? price2Value : 521.66; // ProductAllSection 가격 fallback
|
||||
let regularPrice = price2Value + price5Value;
|
||||
|
||||
// priceInfo에서 직접 가격 추출 시도
|
||||
if (productInfo?.priceInfo) {
|
||||
const priceParts = productInfo.priceInfo.split('|');
|
||||
if (priceParts.length >= 2) {
|
||||
const infoDiscountPrice = extractNumericPrice(priceParts[1]);
|
||||
const infoRegularPrice = extractNumericPrice(priceParts[0]);
|
||||
if (infoDiscountPrice > 0) {
|
||||
discountPrice = infoDiscountPrice;
|
||||
regularPrice = infoRegularPrice > 0 ? infoRegularPrice : discountPrice;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('[BuyOption] API Mode ADD TO CART - Final calculated prices:', {
|
||||
discountPrice,
|
||||
regularPrice,
|
||||
price2Value,
|
||||
price5Value
|
||||
});
|
||||
|
||||
const productInfoForCart = {
|
||||
// 기본 정보
|
||||
@@ -843,9 +885,15 @@ const BuyOption = ({
|
||||
imgUrls: productInfo?.imgUrls || [{ imgUrl: imgUrl }], // imgUrls 배열 구조 추가 (CheckOutPanel 호환성)
|
||||
imgUrls600: productInfo?.imgUrls600, // ✅ 고품질 이미지 배열 포함
|
||||
|
||||
// 가격 정보 (문자열 형식으로)
|
||||
price2: regularPrice.toFixed(2), // 원가
|
||||
price3: discountPrice.toFixed(2), // 할인가/판매가
|
||||
// 가격 정보 (정확한 가격 정보 - 문자열 형식으로)
|
||||
price2: regularPrice.toFixed(2), // 원가 (ProductAllSection 가격)
|
||||
price3: discountPrice.toFixed(2), // 할인가/판매가 (ProductAllSection 가격)
|
||||
// 추가 가격 필드들 (다양한 fallback 지원)
|
||||
finalPrice: discountPrice,
|
||||
discountPrice: discountPrice,
|
||||
origPrice: regularPrice,
|
||||
discount: Math.max(0, regularPrice - discountPrice),
|
||||
priceInfo: productInfo?.priceInfo, // 원본 priceInfo 보존
|
||||
|
||||
// 수량 정보
|
||||
prodQty: quantity,
|
||||
@@ -865,6 +913,11 @@ const BuyOption = ({
|
||||
price: productOptionInfos[0]?.prdtOptDtl[0]?.optPrc || '0.00'
|
||||
};
|
||||
|
||||
console.log('[BuyOption] 🛒 API Mode - Pushing CART_PANEL with name:', Config.panel_names.CART_PANEL);
|
||||
console.log('[BuyOption] 🛒 API Mode - productInfoForCart:', productInfoForCart);
|
||||
console.log('[BuyOption] 🛒 API Mode - optionInfoForCart:', optionInfoForCart);
|
||||
console.log('[BuyOption] 🛒 API Mode - quantity:', quantity);
|
||||
|
||||
dispatch(
|
||||
pushPanel({
|
||||
name: Config.panel_names.CART_PANEL,
|
||||
@@ -887,9 +940,51 @@ const BuyOption = ({
|
||||
productInfo?.patncLogPath ||
|
||||
'/assets/images/img-thumb-empty-144@3x.png';
|
||||
|
||||
// 가격 정보 구성 (CheckOutPanel과 동일한 방식)
|
||||
const regularPrice = productInfo?.regularPrice || 299.99;
|
||||
const discountPrice = productInfo?.discountPrice || regularPrice;
|
||||
// ✅ 정확한 가격 추출 (handleBuyNowClick와 동일한 로직 사용)
|
||||
console.log('[BuyOption] Mock Mode ADD TO CART - Extracting accurate prices from productInfo');
|
||||
console.log('[BuyOption] Mock Mode ADD TO CART - productInfo.price2:', productInfo?.price2);
|
||||
console.log('[BuyOption] Mock Mode ADD TO CART - productInfo.price5:', productInfo?.price5);
|
||||
console.log('[BuyOption] Mock Mode ADD TO CART - productInfo.priceInfo:', productInfo?.priceInfo);
|
||||
|
||||
// handleBuyNowClick의 가격 추출 로직과 동일하게 적용
|
||||
const extractNumericPrice = (value) => {
|
||||
if (typeof value === 'number') return value;
|
||||
if (typeof value === 'string') {
|
||||
const numMatch = value.match(/[\d.]+/);
|
||||
return numMatch ? parseFloat(numMatch[0]) : 0;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
const price2Value = extractNumericPrice(productInfo?.price2);
|
||||
const price5Value = extractNumericPrice(productInfo?.price5);
|
||||
|
||||
console.log('[BuyOption] Mock Mode ADD TO CART - extracted price2Value:', price2Value);
|
||||
console.log('[BuyOption] Mock Mode ADD TO CART - extracted price5Value:', price5Value);
|
||||
|
||||
// 정확한 가격 계산 (ProductAllSection의 가격 정보 사용)
|
||||
let discountPrice = price2Value > 0 ? price2Value : 521.66; // ProductAllSection 가격 fallback
|
||||
let regularPrice = price2Value + price5Value;
|
||||
|
||||
// priceInfo에서 직접 가격 추출 시도
|
||||
if (productInfo?.priceInfo) {
|
||||
const priceParts = productInfo.priceInfo.split('|');
|
||||
if (priceParts.length >= 2) {
|
||||
const infoDiscountPrice = extractNumericPrice(priceParts[1]);
|
||||
const infoRegularPrice = extractNumericPrice(priceParts[0]);
|
||||
if (infoDiscountPrice > 0) {
|
||||
discountPrice = infoDiscountPrice;
|
||||
regularPrice = infoRegularPrice > 0 ? infoRegularPrice : discountPrice;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('[BuyOption] Mock Mode ADD TO CART - Final calculated prices:', {
|
||||
discountPrice,
|
||||
regularPrice,
|
||||
price2Value,
|
||||
price5Value
|
||||
});
|
||||
|
||||
// Mock 상품 정보 구성 (CheckOutPanel 구조 참고)
|
||||
const mockProductInfo = {
|
||||
@@ -908,9 +1003,15 @@ const BuyOption = ({
|
||||
imgUrls: productInfo?.imgUrls || [{ imgUrl: imgUrl }], // imgUrls 배열 구조 추가 (CheckOutPanel 호환성)
|
||||
imgUrls600: productInfo?.imgUrls600, // ✅ 고품질 이미지 배열 포함
|
||||
|
||||
// 가격 정보 (문자열 형식으로)
|
||||
price2: regularPrice.toFixed(2), // 원가
|
||||
price3: discountPrice.toFixed(2), // 할인가/판매가
|
||||
// 가격 정보 (정확한 가격 정보 - 문자열 형식으로)
|
||||
price2: regularPrice.toFixed(2), // 원가 (ProductAllSection 가격)
|
||||
price3: discountPrice.toFixed(2), // 할인가/판매가 (ProductAllSection 가격)
|
||||
// 추가 가격 필드들 (다양한 fallback 지원)
|
||||
finalPrice: discountPrice,
|
||||
discountPrice: discountPrice,
|
||||
origPrice: regularPrice,
|
||||
discount: Math.max(0, regularPrice - discountPrice),
|
||||
priceInfo: productInfo?.priceInfo, // 원본 priceInfo 보존
|
||||
|
||||
// 수량 정보
|
||||
prodQty: quantity,
|
||||
@@ -933,6 +1034,11 @@ const BuyOption = ({
|
||||
};
|
||||
|
||||
// CartPanel로 이동 (productInfo 포함) - CartPanel에서 직접 상품 추가
|
||||
console.log('[BuyOption] 🛒 Pushing CART_PANEL with name:', Config.panel_names.CART_PANEL);
|
||||
console.log('[BuyOption] 🛒 mockProductInfo:', mockProductInfo);
|
||||
console.log('[BuyOption] 🛒 optionInfo:', optionInfo);
|
||||
console.log('[BuyOption] 🛒 quantity:', quantity);
|
||||
|
||||
dispatch(
|
||||
pushPanel({
|
||||
name: Config.panel_names.CART_PANEL,
|
||||
|
||||
Reference in New Issue
Block a user