[WelcomeEventPanel]

- getEventIssuedStaus 이벤트 대상여부자 조회 후 action되도록 수정
This commit is contained in:
jiwon93.son
2024-06-14 18:49:46 +09:00
parent 0d097b88bb
commit ff30207a1b
4 changed files with 62 additions and 11 deletions

View File

@@ -131,6 +131,7 @@ export const types = {
CLEAR_EVENT_INFO: "CLEAR_EVENT_INFO",
SKIP_CLICK_INFO: "SKIP_CLICK_INFO",
CLEAR_CURATION_COUPON: "CLEAR_CURATION_COUPON",
CLEAR_EVENT_ISSUED_STATUS_SUCCEESS: "CLEAR_EVENT_ISSUED_STATUS_SUCCEESS",
// coupon actions
GET_PRODUCT_COUPON_INFO: "GET_PRODUCT_COUPON_INFO",

View File

@@ -68,6 +68,7 @@ export const getEventIssuedStaus = (params) => (dispatch, getState) => {
dispatch({
type: types.GET_EVENT_ISSUED_STATUS,
payload: response.data.data,
retCode: response.data.retCode,
});
};
@@ -131,3 +132,7 @@ export const clearEventInfo = () => ({
export const clearCurationCoupon = () => ({
type: types.CLEAR_CURATION_COUPON,
});
export const clearEventIssuedStatusSuccess = () => ({
type: types.CLEAR_EVENT_ISSUED_STATUS_SUCCEESS,
});

View File

@@ -4,6 +4,7 @@ const initialState = {
eventData: {},
eventClickSuccess: null,
curationCouponSuccess: undefined,
eventIssuedStatusSuccess: null,
};
export const eventReducer = (state = initialState, action) => {
@@ -24,6 +25,11 @@ export const eventReducer = (state = initialState, action) => {
...state,
curationCouponSuccess: action.retCode,
};
case types.GET_EVENT_ISSUED_STATUS:
return {
...state,
eventIssuedStatusSuccess: action.retCode,
};
case types.CLEAR_EVENT_INFO:
return {
...state,
@@ -35,6 +41,11 @@ export const eventReducer = (state = initialState, action) => {
...state,
curationCouponSuccess: undefined,
};
case types.CLEAR_EVENT_ISSUED_STATUS_SUCCEESS:
return {
...state,
eventIssuedStatusSuccess: null,
};
default:
return state;
}

View File

@@ -15,7 +15,11 @@ import {
clearGetProductCouponDownload,
getProductCouponDownload,
} from "../../actions/couponActions";
import { getWelcomeEventInfo } from "../../actions/eventActions";
import {
clearEventIssuedStatusSuccess,
getEventIssuedStaus,
getWelcomeEventInfo,
} from "../../actions/eventActions";
import { popPanel, pushPanel } from "../../actions/panelActions";
import { startVideoPlayer } from "../../actions/playActions";
import MobileSendPopUp from "../../components/MobileSend/MobileSendPopUp";
@@ -53,7 +57,9 @@ const WelcomeEventPanel = ({ spotlightId }) => {
const { popupVisible, activePopup } = useSelector(
(state) => state.common.popup
);
const eventIssuedStatusSuccess = useSelector(
(state) => state.event.eventIssuedStatusSuccess
);
const regDeviceInfoData = useSelector(
(state) => state.device.regDeviceInfoData
);
@@ -88,6 +94,7 @@ const WelcomeEventPanel = ({ spotlightId }) => {
const handleAgree = useCallback(() => {
if (eventDatas && evntTpCd === "EVT00106") {
// WELCOME + BILLING
if (!userNumber) {
dispatch(setShowPopup(Config.ACTIVE_POPUP.loginPopup));
} else {
@@ -100,6 +107,23 @@ const WelcomeEventPanel = ({ spotlightId }) => {
);
}
} else {
if (eventDatas && evntTpCd && evntId) {
dispatch(getEventIssuedStaus({ evntTpCd, evntId }));
}
}
}, [
billCpnSno,
dispatch,
eventDatas,
eventInfo,
evntTpCd,
sendLogShopByMobile,
userNumber,
eventIssuedStatusSuccess,
]);
useEffect(() => {
if (eventIssuedStatusSuccess === 0 && eventIssuedStatusSuccess !== null) {
dispatch(setShowPopup(Config.ACTIVE_POPUP.smsPopup));
const params = {
@@ -130,6 +154,11 @@ const WelcomeEventPanel = ({ spotlightId }) => {
sendLogShopByMobile(params);
shopByMobileLogRef.current = params;
} else if (
eventIssuedStatusSuccess !== null &&
eventIssuedStatusSuccess !== 0
) {
dispatch(setShowPopup(Config.ACTIVE_POPUP.alertPopup));
}
}, [
billCpnSno,
@@ -139,10 +168,12 @@ const WelcomeEventPanel = ({ spotlightId }) => {
evntTpCd,
sendLogShopByMobile,
userNumber,
eventIssuedStatusSuccess,
]);
const onClose = useCallback(() => {
dispatch(setHidePopup());
dispatch(clearEventIssuedStatusSuccess());
Spotlight.focus("agree");
}, [dispatch]);
@@ -290,14 +321,6 @@ const WelcomeEventPanel = ({ spotlightId }) => {
if (webOSVersion && Number(webOSVersion) >= 6) {
toastAlertMessage();
closePanelAndNavigate();
} else {
dispatch(setShowPopup(Config.ACTIVE_POPUP.alertPopup));
setTimeout(() => {
dispatch(setHidePopup());
if (activePopup === null) {
closePanelAndNavigate();
}
}, 3000);
}
}
}, [dispatch, couponDownloadSuccess, shptmLnkInfo, activePopup]);
@@ -316,6 +339,14 @@ const WelcomeEventPanel = ({ spotlightId }) => {
};
}, [dispatch]);
const getEvntErrorMsg = useMemo(() => {
if (eventIssuedStatusSuccess === 600) {
return $L("This device had received first time coupon.");
} else if (eventIssuedStatusSuccess === 601) {
return $L("There is no coupon.");
} else return;
}, [eventIssuedStatusSuccess]);
return (
<>
{eventDatas?.eventInfo && (
@@ -422,7 +453,10 @@ const WelcomeEventPanel = ({ spotlightId }) => {
kind="textPopup"
open={popupVisible}
hasText
text={$L("Downloading coupon complete.")}
text={getEvntErrorMsg}
onClick={onClose}
hasButton
button1Text={$L("OK")}
/>
)}
</>