[구매 관련 수정]
- 옵션 노출에 따른 구매 정상적이지 않던 부분 수정. - 조건 추가 및 수정
This commit is contained in:
@@ -99,6 +99,9 @@ const BuyOption = ({
|
||||
const [hasProductOptionArray, setHasProductOptionArray] = useState(true);
|
||||
const [selectedOptionInfo, setSelectedOptionInfo] = useState();
|
||||
|
||||
const [selectFirstOptionIndex, setSelectFirstOptionIndex] = useState(0);
|
||||
const [selectSecondOptionIndex, setSelectSecondOptionIndex] = useState(0);
|
||||
|
||||
// 상품 정보 (props 우선, 없으면 productInfo에서)
|
||||
const selectedPatnrId = propsSelectedPatnrId || productInfo?.patnrId;
|
||||
const selectedPrdtId = propsSelectedPrdtId || productInfo?.prdtId;
|
||||
@@ -329,7 +332,8 @@ const BuyOption = ({
|
||||
return;
|
||||
}
|
||||
if (!userNumber || userNumber === '') {
|
||||
return dispatch(setShowPopup(Config.ACTIVE_POPUP.loginPopup));
|
||||
return;
|
||||
dispatch(setShowPopup(Config.ACTIVE_POPUP.loginPopup));
|
||||
}
|
||||
|
||||
// // 옵션 선택 검증 (SingleOption과 동일)
|
||||
@@ -343,16 +347,21 @@ const BuyOption = ({
|
||||
// }
|
||||
|
||||
//옵션 선택 안하면 구매 안돼도록.
|
||||
if (productOptionInfos.length > 1) {
|
||||
if (selectedBtnOptIdx === 0) {
|
||||
if (
|
||||
productOptionInfos &&
|
||||
productOptionInfos.length > 1 &&
|
||||
productInfo?.optProdYn === 'Y'
|
||||
) {
|
||||
if (selectFirstOptionIndex === 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (
|
||||
productOptionInfos[selectedBtnOptIdx]?.prdtOptDtl &&
|
||||
productOptionInfos[selectedBtnOptIdx]?.prdtOptDtl.length > 1
|
||||
productOptionInfos[selectedBtnOptIdx]?.prdtOptDtl.length > 1 &&
|
||||
productInfo?.optProdYn === 'Y'
|
||||
) {
|
||||
if (selectedOptionItemIndex === 0) {
|
||||
if (selectSecondOptionIndex === 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -493,6 +502,7 @@ const BuyOption = ({
|
||||
// "Select Option"이 선택된 경우 (index 0)
|
||||
if (selectedIndex === 0) {
|
||||
// 초기 상태로 리셋
|
||||
setSelectFirstOptionIndex(0);
|
||||
setSelectedBtnOptIdx(0);
|
||||
setSelectedOptionItemIndex(0);
|
||||
setSelectedOptions(undefined);
|
||||
@@ -503,7 +513,7 @@ const BuyOption = ({
|
||||
|
||||
// selectedBtnOptIdx는 UI 인덱스 그대로 저장 (드롭다운 표시용)
|
||||
setSelectedBtnOptIdx(selectedIndex);
|
||||
|
||||
setSelectFirstOptionIndex(selectedIndex);
|
||||
// 실제 데이터 접근 시에는 selectedIndex - 1 사용
|
||||
const dataIndex = selectedIndex - 1;
|
||||
setSelectedOptionItemIndex(0);
|
||||
@@ -518,7 +528,7 @@ const BuyOption = ({
|
||||
|
||||
// selectedOptionItemIndex는 UI 인덱스 그대로 저장
|
||||
setSelectedOptionItemIndex(selectedIndex);
|
||||
|
||||
setSelectSecondOptionIndex(selectedIndex);
|
||||
// 실제 데이터 접근 시에는 -1 적용
|
||||
const firstOptionDataIndex = selectedBtnOptIdx - 1; // 첫 번째 옵션의 실제 데이터 인덱스
|
||||
const secondOptionDataIndex = selectedIndex - 1; // 두 번째 옵션의 실제 데이터 인덱스
|
||||
@@ -703,7 +713,7 @@ const BuyOption = ({
|
||||
|
||||
{/* 두번째 옵션 (옵션 상세값들) */}
|
||||
{productOptionInfos[selectedBtnOptIdx]?.prdtOptDtl &&
|
||||
productOptionInfos[selectedBtnOptIdx]?.prdtOptDtl.length >
|
||||
productOptionInfos[selectedBtnOptIdx]?.prdtOptDtl?.length >
|
||||
1 && (
|
||||
<div className={styles.buy_option__option_row}>
|
||||
<div className={styles.buy_option__option_label}>
|
||||
|
||||
Reference in New Issue
Block a user