[워닝제거] cartReducer 공백제거.
- 공백만 제거.
This commit is contained in:
@@ -23,7 +23,7 @@ const initialState = {
|
|||||||
* Cart Reducer
|
* Cart Reducer
|
||||||
* 장바구니 관련 상태를 관리합니다.
|
* 장바구니 관련 상태를 관리합니다.
|
||||||
*/
|
*/
|
||||||
export const cartReducer = (state = initialState, action) => {
|
export const cartReducer = (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
// 장바구니 조회 - API에서 가져온 전체 목록
|
// 장바구니 조회 - API에서 가져온 전체 목록
|
||||||
case types.GET_MY_INFO_CART_SEARCH:
|
case types.GET_MY_INFO_CART_SEARCH:
|
||||||
@@ -37,9 +37,9 @@ export const cartReducer = (state = initialState, action) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 장바구니에 상품 추가
|
// 장바구니에 상품 추가
|
||||||
case types.INSERT_MY_INFO_CART:
|
case types.INSERT_MY_INFO_CART:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
selectCart: {
|
selectCart: {
|
||||||
...state.selectCart,
|
...state.selectCart,
|
||||||
cartList: [...state.selectCart.cartList, action.payload],
|
cartList: [...state.selectCart.cartList, action.payload],
|
||||||
@@ -51,22 +51,22 @@ export const cartReducer = (state = initialState, action) => {
|
|||||||
case types.TOGGLE_CHECK_CART: {
|
case types.TOGGLE_CHECK_CART: {
|
||||||
const checkedItem = action.payload.item;
|
const checkedItem = action.payload.item;
|
||||||
const isChecked = action.payload.isChecked;
|
const isChecked = action.payload.isChecked;
|
||||||
|
|
||||||
let updatedCheckedList = state.selectCart?.checkedItems || [];
|
let updatedCheckedList = state.selectCart?.checkedItems || [];
|
||||||
|
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
const itemExists = updatedCheckedList.some(
|
const itemExists = updatedCheckedList.some(
|
||||||
item => item.prodSno === checkedItem.prodSno
|
item => item.prodSno === checkedItem.prodSno
|
||||||
);
|
);
|
||||||
if (!itemExists) {
|
if (!itemExists) {
|
||||||
updatedCheckedList = [...updatedCheckedList, checkedItem];
|
updatedCheckedList = [...updatedCheckedList, checkedItem];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
updatedCheckedList = updatedCheckedList.filter(
|
updatedCheckedList = updatedCheckedList.filter(
|
||||||
item => item.prodSno !== checkedItem.prodSno
|
item => item.prodSno !== checkedItem.prodSno
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
selectCart: {
|
selectCart: {
|
||||||
@@ -78,7 +78,7 @@ export const cartReducer = (state = initialState, action) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 장바구니에서 상품 삭제
|
// 장바구니에서 상품 삭제
|
||||||
case types.DELETE_MY_INFO_CART:
|
case types.DELETE_MY_INFO_CART:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
getMyinfoCartSearch: {
|
getMyinfoCartSearch: {
|
||||||
@@ -96,7 +96,7 @@ export const cartReducer = (state = initialState, action) => {
|
|||||||
getMyinfoCartSearch: {
|
getMyinfoCartSearch: {
|
||||||
...state.getMyinfoCartSearch,
|
...state.getMyinfoCartSearch,
|
||||||
cartList: (state.getMyinfoCartSearch.cartList || []).map(item =>
|
cartList: (state.getMyinfoCartSearch.cartList || []).map(item =>
|
||||||
item.prodSno === action.payload.prodSno
|
item.prodSno === action.payload.prodSno
|
||||||
? { ...item, ...action.payload }
|
? { ...item, ...action.payload }
|
||||||
: item
|
: item
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user