myOrder change ui / focus / api
This commit is contained in:
@@ -2,64 +2,117 @@ import axios from "axios";
|
||||
|
||||
import { URLS } from "../api/apiConfig";
|
||||
import { TAxios } from "../api/TAxios";
|
||||
import { GET_MY_INFO_ORDER_SEARCH_LIMIT } from "../utils/Config";
|
||||
import { types } from "./actionTypes";
|
||||
import { getTermsAgreeYn } from "./commonActions";
|
||||
import { changeAppStatus, getTermsAgreeYn } from "./commonActions";
|
||||
|
||||
// 회원 주문 정보 조회 (IF-LGSP-340)
|
||||
export const getMyinfoOrderSearch = (params) => (dispatch, getState) => {
|
||||
const {
|
||||
mbrNo,
|
||||
srchMonth,
|
||||
cancelOrderYn,
|
||||
keyword,
|
||||
limitNum,
|
||||
orderInfoDataIdx,
|
||||
orderInfo,
|
||||
orderInfoCount,
|
||||
} = params;
|
||||
let getMyinfoOrderSearchKey = null;
|
||||
let lastMyinfoOrderSearchParams = {};
|
||||
export const getMyinfoOrderSearch =
|
||||
(params, orderInfoDataIdx = 1, key, loading = true) =>
|
||||
(dispatch, getState) => {
|
||||
const { mbrNo, srchMonth, cancelOrderYn } = params;
|
||||
let limitNum = params.limitNum || GET_MY_INFO_ORDER_SEARCH_LIMIT;
|
||||
|
||||
const onSuccess = (response) => {
|
||||
console.log("getMyinfoOrderSearch onSuccess ", response.data);
|
||||
if (orderInfoDataIdx === 1) {
|
||||
if (
|
||||
JSON.stringify(lastMyinfoOrderSearchParams) === JSON.stringify(params)
|
||||
) {
|
||||
console.log("getMyinfoOrderSearch ignore patch");
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: types.GET_MY_INFO_ORDER_SEARCH,
|
||||
payload: response.data.data,
|
||||
});
|
||||
lastMyinfoOrderSearchParams = params;
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
dispatch(
|
||||
changeAppStatus({ showLoadingPanel: { show: true, type: "wait" } })
|
||||
);
|
||||
}
|
||||
|
||||
let currentKey = key;
|
||||
const onSuccess = (response) => {
|
||||
console.log("getMyinfoOrderSearch onSuccess ", response.data);
|
||||
|
||||
if (orderInfoDataIdx === 1) {
|
||||
getMyinfoOrderSearchKey = new Date();
|
||||
currentKey = getMyinfoOrderSearchKey;
|
||||
|
||||
dispatch({
|
||||
type: types.GET_MY_INFO_ORDER_SEARCH,
|
||||
payload: response.data.data,
|
||||
orderSearchParams: {
|
||||
mbrNo,
|
||||
srchMonth,
|
||||
cancelOrderYn,
|
||||
limitNum,
|
||||
},
|
||||
});
|
||||
} else if (getMyinfoOrderSearchKey === currentKey) {
|
||||
dispatch({
|
||||
type: types.GET_MY_INFO_ORDER_SEARCH,
|
||||
payload: response.data.data,
|
||||
append: true,
|
||||
startIndex: (orderInfoDataIdx - 1) * limitNum,
|
||||
});
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
dispatch(changeAppStatus({ showLoadingPanel: { show: false } }));
|
||||
}
|
||||
};
|
||||
|
||||
const onFail = (error) => {
|
||||
console.error("getMyinfoOrderSearch onFail ", error);
|
||||
if (loading) {
|
||||
dispatch(changeAppStatus({ showLoadingPanel: { show: false } }));
|
||||
}
|
||||
if (orderInfoDataIdx === 1) {
|
||||
lastMyinfoOrderSearchParams = {};
|
||||
}
|
||||
};
|
||||
|
||||
TAxios(
|
||||
dispatch,
|
||||
getState,
|
||||
"get",
|
||||
URLS.GET_MY_INFO_ORDER_SEARCH,
|
||||
{
|
||||
mbrNo,
|
||||
srchMonth,
|
||||
cancelOrderYn,
|
||||
limitNum,
|
||||
orderInfoDataIdx,
|
||||
},
|
||||
{},
|
||||
onSuccess,
|
||||
onFail
|
||||
);
|
||||
};
|
||||
|
||||
const onFail = (error) => {
|
||||
console.error("getMyinfoOrderSearch onFail ", error);
|
||||
export const continueGetMyinfoOrderSearch =
|
||||
(orderInfoDataIdx = 2) =>
|
||||
(dispatch, getState) => {
|
||||
const orderInfoData = getState().order.orderInfoData || {};
|
||||
const totalCount = orderInfoData.orderInfoCount ?? 0;
|
||||
const startIndex = GET_MY_INFO_ORDER_SEARCH_LIMIT * (orderInfoDataIdx - 1);
|
||||
|
||||
if (startIndex <= 1 || totalCount < startIndex) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(
|
||||
getMyinfoOrderSearch(
|
||||
{ ...lastMyinfoOrderSearchParams },
|
||||
orderInfoDataIdx,
|
||||
getMyinfoOrderSearchKey,
|
||||
false
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
let apiUrl;
|
||||
|
||||
if (cancelOrderYn === "Y") {
|
||||
apiUrl = URLS.GET_MY_INFO_ORDER_SEARCH_CANCEL;
|
||||
} else if (cancelOrderYn === "N") {
|
||||
apiUrl = URLS.GET_MY_INFO_ORDER_SEARCH;
|
||||
}
|
||||
|
||||
TAxios(
|
||||
dispatch,
|
||||
getState,
|
||||
"get",
|
||||
apiUrl,
|
||||
{
|
||||
mbrNo,
|
||||
srchMonth,
|
||||
cancelOrderYn,
|
||||
keyword,
|
||||
limitNum,
|
||||
orderInfoDataIdx,
|
||||
orderInfo,
|
||||
orderInfoCount,
|
||||
},
|
||||
{},
|
||||
onSuccess,
|
||||
onFail
|
||||
);
|
||||
};
|
||||
|
||||
// 회원 주문 상세 정보 조회 (IF-LGSP-341)
|
||||
export const getMyinfoOrderDetailSearch = (params) => (dispatch, getState) => {
|
||||
const { mbrNo, ordNo, prdtId } = params;
|
||||
|
||||
Reference in New Issue
Block a user