myOrder change logic

This commit is contained in:
hyunwoo93.cha
2024-07-03 11:24:11 +09:00
parent 14944f4694
commit 2ba260210f
5 changed files with 84 additions and 47 deletions

View File

@@ -89,6 +89,7 @@ export const types = {
CLEAR_PRODUCT_DETAIL: "CLEAR_PRODUCT_DETAIL",
CLEAR_SUB_CATEGORY: "CLEAR_SUB_CATEGORY",
CLEAR_SHOPNOW_INFO: "CLEAR_SHOPNOW_INFO",
// myPage actions
GET_MY_RECOMMANDED_KEYWORD: "GET_MY_RECOMMANDED_KEYWORD",
GET_MY_FAQ_INFO: "GET_MY_FAQ_INFO",
@@ -162,6 +163,7 @@ export const types = {
GET_MY_INFO_ORDER_SEARCH_CANCEL: "GET_MY_INFO_ORDER_SEARCH_CANCEL",
GET_MY_INFO_ORDER_DETAIL_SEARCH: "GET_MY_INFO_ORDER_DETAIL_SEARCH",
GET_MY_INFO_ORDER_SHIPPING_SEARCH: "GET_MY_INFO_ORDER_SHIPPING_SEARCH",
CLEAR_MY_INFO_ORDER_SEARCH: "CLEAR_MY_INFO_ORDER_SEARCH",
// play controller
GET_CHAT_LOG: "GET_CHAT_LOG",

View File

@@ -1,7 +1,10 @@
import { URLS } from "../api/apiConfig";
import { setTokenRefreshing, TAxios } from "../api/TAxios";
import { types } from "./actionTypes";
import { changeLocalSettings } from "./commonActions";
import { URLS } from '../api/apiConfig';
import {
setTokenRefreshing,
TAxios,
} from '../api/TAxios';
import { types } from './actionTypes';
import { changeLocalSettings } from './commonActions';
// IF-LGSP-000 인증코드 요청
export const getAuthenticationCode = () => (dispatch, getState) => {

View File

@@ -56,6 +56,7 @@ export const getMyinfoOrderSearch =
payload: response.data.data,
append: true,
startIndex: (orderInfoDataIdx - 1) * limitNum,
orderSearchParams: lastMyinfoOrderSearchParams,
});
}
@@ -113,6 +114,10 @@ export const continueGetMyinfoOrderSearch =
);
};
export const clearMyinfoOrderSearch = () => ({
type: types.CLEAR_MY_INFO_ORDER_SEARCH,
});
// 회원 주문 상세 정보 조회 (IF-LGSP-341)
export const getMyinfoOrderDetailSearch =
(params, callback) => (dispatch, getState) => {

View File

@@ -4,7 +4,7 @@ import { GET_MY_INFO_ORDER_SEARCH_LIMIT } from "../utils/Config";
const initialState = {
orderDetailData: {},
orderInfoData: {},
orderCancelData: {},
cancelOrderInfoData: {},
orderShippingData: {},
orderSearchParams: {
mbrNo: null,
@@ -25,30 +25,66 @@ export const orderReducer = (state = initialState, action) => {
case types.GET_MY_INFO_ORDER_SEARCH: {
const newResults = action.payload.orderInfo || [];
const orderInfoCount = action.payload.orderInfoCount;
const { cancelOrderYn } =
action.orderSearchParams || state.orderSearchParams;
if (action.append) {
const existingData = state.orderInfoData.orderInfo || [];
const combinedData = [...existingData, ...newResults];
console.log("chw", newResults, cancelOrderYn, action.payload);
return {
...state,
orderInfoData: {
...state.orderInfoData,
orderInfo: combinedData,
orderInfoCount,
},
};
if (cancelOrderYn === "Y") {
if (action.append) {
const existingData = state.cancelOrderInfoData.orderInfo || [];
const combinedData = [...existingData, ...newResults];
return {
...state,
cancelOrderInfoData: {
...state.cancelOrderInfoData,
orderInfo: combinedData,
orderInfoCount,
},
};
} else {
return {
...state,
cancelOrderInfoData: {
...action.payload,
},
orderSearchParams: action.orderSearchParams,
};
}
} else {
return {
...state,
orderInfoData: {
...action.payload,
},
orderSearchParams: action.orderSearchParams,
};
if (action.append) {
const existingData = state.orderInfoData.orderInfo || [];
const combinedData = [...existingData, ...newResults];
return {
...state,
orderInfoData: {
...state.orderInfoData,
orderInfo: combinedData,
orderInfoCount,
},
};
} else {
return {
...state,
orderInfoData: {
...action.payload,
},
orderSearchParams: action.orderSearchParams,
};
}
}
}
case types.CLEAR_MY_INFO_ORDER_SEARCH: {
return {
...state,
orderInfoData: {},
cancelOrderInfoData: {},
};
}
case types.GET_MY_INFO_ORDER_SEARCH_CANCEL:
return {
...state,

View File

@@ -35,6 +35,7 @@ import {
// getMyinfoOrderDetailSearch : 회원 주문 상세 정보 조회 - 디테일
// getMyinfoOrderShippingSearch : 회원 주문 배송 상세 정보 조회
import {
clearMyinfoOrderSearch,
continueGetMyinfoOrderSearch,
getMyinfoOrderDetailSearch,
getMyinfoOrderSearch,
@@ -122,35 +123,24 @@ export default function MyOrders({ title, panelInfo, isOnTop }) {
[]
);
const getSearchParams = useCallback((selectedTab, dropDownTab) => {
let cancelOrderYn = selectedTab === 1 ? "Y" : "N";
let srchMonth = dropDownTab === 1 ? 6 : 3;
return { cancelOrderYn, srchMonth };
}, []);
const reload = useCallback(() => {
const { cancelOrderYn, srchMonth } = getSearchParams(
tabRef.current,
dropDownTabRef.current
);
const params = { mbrNo: userNumber, srchMonth, cancelOrderYn };
const cancelOrderYn = tabRef.current === 0 ? "N" : "Y";
const srchMonth = dropDownTabRef.current === 0 ? 3 : 6;
if (
orderSearchParams.mbrNo !== params.mbrNo ||
orderSearchParams.srcMonth !== params.srchMonth ||
orderSearchParams.cancelOrderYn !== params.cancelOrderYn
orderSearchParams.srchMonth !== srchMonth ||
orderSearchParams.cancelOrderYn !== cancelOrderYn
) {
dispatch(getMyinfoOrderSearch(params));
dispatch(clearMyinfoOrderSearch());
dispatch(
getMyinfoOrderSearch({
mbrNo: userNumber,
srchMonth: srchMonth,
cancelOrderYn: cancelOrderYn,
})
);
}
}, [
getSearchParams,
userNumber,
orderSearchParams,
dispatch,
tabRef,
dropDownTabRef,
]);
}, [userNumber, orderSearchParams, selectedTab, dropDownTab, dispatch]);
useEffect(() => {
if (isOnTop) {
@@ -162,6 +152,7 @@ export default function MyOrders({ title, panelInfo, isOnTop }) {
setContainerLastFocusedElement(null, [
SpotlightIds.MY_PAGE_MY_ORDER_BOX,
]);
setSelectedTab(panelInfo.selectedTab ? panelInfo.selectedTab : 0);
Spotlight.focus("tab-" + panelInfo.selectedTab);
} else if (panelInfo.currentSpot) {