[카트, 체크아웃 수정]#1

- 금액 노출 및 나오는 값 수정중.
 - 체크박스 선택해서 주문 처리
 - 체크박스 선택시 금액 노출 처리.
This commit is contained in:
junghoon86.park
2025-11-14 14:41:56 +09:00
parent fdb9507024
commit 5d587dbdeb
11 changed files with 527 additions and 475 deletions

View File

@@ -9,6 +9,11 @@ const initialState = {
cartList: [],
totalCount: 0,
},
selectCart : {
cartList: [],
checkedItems: [], // ✅ 체크된 상품 정보 저장
totalCount: 0,
},
// 추가/수정/삭제 결과
lastAction: null,
error: null,
@@ -35,13 +40,43 @@ export const cartReducer = (state = initialState, action) => {
case types.INSERT_MY_INFO_CART:
return {
...state,
getMyinfoCartSearch: {
...state.getMyinfoCartSearch,
cartList: [...state.getMyinfoCartSearch.cartList, action.payload],
selectCart: {
...state.selectCart,
cartList: [...state.selectCart.cartList, action.payload],
totalCount: (state.getMyinfoCartSearch.totalCount || 0) + 1,
},
};
//체크박스 토글시 상품 처리
case types.TOGGLE_CHECK_CART: {
const checkedItem = action.payload.item;
const isChecked = action.payload.isChecked;
let updatedCheckedList = state.selectCart?.checkedItems || [];
if (isChecked) {
const itemExists = updatedCheckedList.some(
item => item.prodSno === checkedItem.prodSno
);
if (!itemExists) {
updatedCheckedList = [...updatedCheckedList, checkedItem];
}
} else {
updatedCheckedList = updatedCheckedList.filter(
item => item.prodSno !== checkedItem.prodSno
);
}
return {
...state,
selectCart: {
...state.selectCart,
checkedItems: updatedCheckedList,
totalCount: updatedCheckedList.length,
},
};
}
// 장바구니에서 상품 삭제
case types.DELETE_MY_INFO_CART:
return {