[상품 상세] 구매옵션 작업
- 품절표시 및 상품 이미지 노출 - 옵션 1개일때 처리
This commit is contained in:
@@ -40,7 +40,8 @@ import { $L } from '../../../utils/helperMethods';
|
||||
import FavoriteBtn from '../components/FavoriteBtn';
|
||||
import styles from './BuyOption.module.less';
|
||||
import BuyOptionPriceBlock from './BuyOptionPriceBlock';
|
||||
import CustomDropDown from './CustomDropDown';
|
||||
// import CustomDropDown from './CustomDropDown';
|
||||
import CustomDropDown from './CustomDropDown.new';
|
||||
import ProductQuantity from './ProductQuantity';
|
||||
|
||||
const Container = SpotlightContainerDecorator(
|
||||
@@ -473,15 +474,6 @@ const BuyOption = ({
|
||||
const selectedIndex = selected.selected;
|
||||
console.log('[BuyOption] Second option selected:', selectedIndex);
|
||||
|
||||
// "Select Option"이 선택된 경우 (index 0)
|
||||
if (selectedIndex === 0) {
|
||||
// 초기 상태로 리셋
|
||||
setSelectedOptionItemIndex(0);
|
||||
setSelectedOptions(undefined);
|
||||
setIsOptionValue(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// selectedOptionItemIndex는 UI 인덱스 그대로 저장
|
||||
setSelectedOptionItemIndex(selectedIndex);
|
||||
|
||||
@@ -490,15 +482,20 @@ const BuyOption = ({
|
||||
const secondOptionDataIndex = selectedIndex - 1; // 두 번째 옵션의 실제 데이터 인덱스
|
||||
|
||||
setSelectedOptions(
|
||||
productOptionInfos[firstOptionDataIndex]?.prdtOptDtl[
|
||||
secondOptionDataIndex
|
||||
]
|
||||
productOptionInfos.length > 1
|
||||
? productOptionInfos[firstOptionDataIndex]?.prdtOptDtl[
|
||||
secondOptionDataIndex
|
||||
]
|
||||
: productOptionInfos[0]?.prdtOptDtl[secondOptionDataIndex]
|
||||
);
|
||||
dispatch(
|
||||
getProductOptionId(
|
||||
productOptionInfos[firstOptionDataIndex]?.prdtOptDtl[
|
||||
secondOptionDataIndex
|
||||
]?.prodOptCdCval
|
||||
productOptionInfos.length > 1
|
||||
? productOptionInfos[firstOptionDataIndex]?.prdtOptDtl[
|
||||
secondOptionDataIndex
|
||||
]?.prodOptCdCval
|
||||
: productOptionInfos[0]?.prdtOptDtl[secondOptionDataIndex]
|
||||
?.prodOptCdCval
|
||||
)
|
||||
);
|
||||
setIsOptionValue(true);
|
||||
@@ -679,9 +676,15 @@ const BuyOption = ({
|
||||
options={[
|
||||
'Select Option',
|
||||
...(productOptionInfos[
|
||||
selectedBtnOptIdx - 1 // 데이터 인덱스 사용
|
||||
]?.prdtOptDtl.map((detail) => detail.prodOptCval) ||
|
||||
[]),
|
||||
productOptionInfos.length > 1
|
||||
? selectedBtnOptIdx - 1
|
||||
: selectedBtnOptIdx
|
||||
]?.prdtOptDtl.map((detail) => ({
|
||||
label: detail.prodOptCval,
|
||||
disabled: detail.optStkQty <= 0,
|
||||
imageUrl: detail.optImgUrl || null,
|
||||
price: detail.priceInfo.split('|')[1],
|
||||
})) || []),
|
||||
]}
|
||||
selectedIndex={selectedOptionItemIndex}
|
||||
onSelect={handleSecondOptionSelect}
|
||||
|
||||
Reference in New Issue
Block a user