DetailPanel 쿠폰 기능 구현 (스타일 미완성)

This commit is contained in:
고동영
2024-04-15 20:09:11 +09:00
parent 13ac88ef29
commit 08d5fa869c
7 changed files with 118 additions and 28 deletions

View File

@@ -1,6 +1,6 @@
import { URLS } from '../api/apiConfig'; import { URLS } from "../api/apiConfig";
import { TAxios } from '../api/TAxios'; import { TAxios } from "../api/TAxios";
import { types } from './actionTypes'; import { types } from "./actionTypes";
// IF-LGSP-339 : 회원 다운로드 쿠폰 정보 조회 // IF-LGSP-339 : 회원 다운로드 쿠폰 정보 조회
export const getProductCouponInfo = (props) => (dispatch, getState) => { export const getProductCouponInfo = (props) => (dispatch, getState) => {
@@ -35,6 +35,7 @@ export const getProductCouponTotDownload = (props) => (dispatch, getState) => {
// 쿠폰 아이디 여러개 일 경우 쉼표로 구분 ex)80,81,82 // 쿠폰 아이디 여러개 일 경우 쉼표로 구분 ex)80,81,82
const { mbrNo, cpnSnoAll } = props; const { mbrNo, cpnSnoAll } = props;
console.log("#cpnSnoAll", cpnSnoAll);
const onSuccess = (response) => { const onSuccess = (response) => {
console.log("getProductCouponTotDownload onSuccess ", response.data); console.log("getProductCouponTotDownload onSuccess ", response.data);
@@ -53,8 +54,8 @@ export const getProductCouponTotDownload = (props) => (dispatch, getState) => {
getState, getState,
"post", "post",
URLS.GET_PRODUCT_COUPON_TOTDOWNLOAD, URLS.GET_PRODUCT_COUPON_TOTDOWNLOAD,
{ mbrNo, cpnSnoAll },
{}, {},
{ mbrNo, cpnSnoAll },
onSuccess, onSuccess,
onFail onFail
); );
@@ -63,11 +64,12 @@ export const getProductCouponTotDownload = (props) => (dispatch, getState) => {
export const getProductCouponDownload = (props) => (dispatch, getState) => { export const getProductCouponDownload = (props) => (dispatch, getState) => {
const { mbrNo, cpnSno } = props; const { mbrNo, cpnSno } = props;
console.log("#mbrNo , cpnSno", mbrNo, cpnSno);
const onSuccess = (response) => { const onSuccess = (response) => {
console.log("getProductCouponDownload onSuccess ", response.data); console.log("getProductCouponDownload onSuccess ", response.data);
dispatch({ dispatch({
type: types.GET_PRODUCT_COUPON_DONWLOAD, type: types.GET_PRODUCT_COUPON_DOWNLOAD,
payload: response.data.data, payload: response.data.data,
}); });
}; };
@@ -81,8 +83,8 @@ export const getProductCouponDownload = (props) => (dispatch, getState) => {
getState, getState,
"post", "post",
URLS.GET_PRODUCT_COUPON_DOWNLOAD, URLS.GET_PRODUCT_COUPON_DOWNLOAD,
{ mbrNo, cpnSno },
{}, {},
{ mbrNo, cpnSno },
onSuccess, onSuccess,
onFail onFail
); );

View File

@@ -1,4 +1,4 @@
import { types } from '../actions/actionTypes'; import { types } from "../actions/actionTypes";
const initialState = { const initialState = {
productCouponInfoData: {}, productCouponInfoData: {},

View File

@@ -20,8 +20,12 @@ export default function CheckOutPanel() {
const { userInfo } = useSelector( const { userInfo } = useSelector(
(state) => state.common.appStatus.loginUserData (state) => state.common.appStatus.loginUserData
); );
const panels = useSelector((state) => state.panels.panels);
const checkoutData = useSelector((state) => state.checkout?.checkoutData); const checkoutData = useSelector((state) => state.checkout?.checkoutData);
const testData = useSelector((state) => state); const testData = useSelector((state) => state);
console.log("#panels", panels);
useEffect(() => { useEffect(() => {
dispatch( dispatch(
getMyInfoCheckoutInfo({ getMyInfoCheckoutInfo({
@@ -31,7 +35,7 @@ export default function CheckOutPanel() {
{ {
patnrId: "11", patnrId: "11",
prdtId: "7280567", prdtId: "7280567",
prodOptCdCval: "7326492", prodOptCdCval: "7326490",
prodQty: 1, prodQty: 1,
}, },
], ],

View File

@@ -55,6 +55,7 @@ export default function ItemDetail() {
} }
}; };
console.log("#panels", panels);
useEffect(() => { useEffect(() => {
getPanelInfo(); getPanelInfo();

View File

@@ -8,7 +8,11 @@ import SpotlightContainerDecorator from "@enact/spotlight/SpotlightContainerDeco
import Spottable from "@enact/spotlight/Spottable"; import Spottable from "@enact/spotlight/Spottable";
import { setHidePopup, setShowPopup } from "../../../actions/commonActions"; import { setHidePopup, setShowPopup } from "../../../actions/commonActions";
import { getProductCouponSearch } from "../../../actions/couponActions"; import {
getProductCouponDownload,
getProductCouponSearch,
getProductCouponTotDownload,
} from "../../../actions/couponActions";
import { pushPanel } from "../../../actions/panelActions"; import { pushPanel } from "../../../actions/panelActions";
import { getProductOption } from "../../../actions/productActions"; import { getProductOption } from "../../../actions/productActions";
import TButton from "../../../components/TButton/TButton"; import TButton from "../../../components/TButton/TButton";
@@ -45,6 +49,9 @@ export default function SingleOption({
const { popupVisible, activePopup } = useSelector( const { popupVisible, activePopup } = useSelector(
(state) => state.common.popup (state) => state.common.popup
); );
const { userInfo } = useSelector(
(state) => state.common.appStatus.loginUserData
);
const { loginUserData } = useSelector((state) => state.common.appStatus); const { loginUserData } = useSelector((state) => state.common.appStatus);
const [promotions, setPromotions] = useState([]); const [promotions, setPromotions] = useState([]);
const [selectedBtnOptIdx, setSelectedBtnOptIdx] = useState(0); const [selectedBtnOptIdx, setSelectedBtnOptIdx] = useState(0);
@@ -53,11 +60,13 @@ export default function SingleOption({
const [selectedOptionIdx, setSelectedOptionsIdx] = useState([]); const [selectedOptionIdx, setSelectedOptionsIdx] = useState([]);
const [selectedOptions, setsSelectedOptions] = useState([]); const [selectedOptions, setsSelectedOptions] = useState([]);
const [couponTypes, setCouponTypes] = useState(null); const [couponTypes, setCouponTypes] = useState(null);
const [couponCodes, setCouponCodes] = useState("");
const [downloadCoupon, setDownloadCoupon] = useState();
const [downloadCouponArr, setDownloadCouponArr] = useState([]);
const { priceInfo, shippingCharge } = productInfo || productData; const { priceInfo, shippingCharge } = productInfo || productData;
const { originalPrice, discountedPrice, discountRate } = const { originalPrice, discountedPrice, discountRate } =
usePriceInfo(priceInfo) || {}; usePriceInfo(priceInfo) || {};
// let downloadCouponArr = [];
useEffect(() => { useEffect(() => {
const newPromotions = []; const newPromotions = [];
if (partnerCoupon && partnerCoupon.length > 0) { if (partnerCoupon && partnerCoupon.length > 0) {
@@ -70,9 +79,6 @@ export default function SingleOption({
setPromotions(newPromotions); setPromotions(newPromotions);
}, [partnerCoupon, shoptiemCoupon]); }, [partnerCoupon, shoptiemCoupon]);
// console.log("#coupon ", partnerCoupon, shoptiemCoupon);
// console.log("#selectedCoupon", selectedCoupon);
useEffect(() => { useEffect(() => {
dispatch( dispatch(
getProductOption({ getProductOption({
@@ -84,6 +90,7 @@ export default function SingleOption({
getProductCouponSearch({ getProductCouponSearch({
patnrId: 11, patnrId: 11,
prdtId: 1089323, prdtId: 1089323,
mbrNo: userInfo,
}) })
); );
}, [dispatch, selectedPatnrId]); }, [dispatch, selectedPatnrId]);
@@ -102,7 +109,6 @@ export default function SingleOption({
return updatedOptions; return updatedOptions;
}); });
console.log("#optionValidx", selectedBtnOptIdx);
Spotlight.focus(`optionBtn-${selectedBtnOptIdx}`); Spotlight.focus(`optionBtn-${selectedBtnOptIdx}`);
onClose(); onClose();
}, },
@@ -145,16 +151,24 @@ export default function SingleOption({
pushPanel({ pushPanel({
name: Config.panel_names.CHECKOUT_PANEL, name: Config.panel_names.CHECKOUT_PANEL,
panelInfo: { panelInfo: {
quantity: quantity, cartList: [
patnrId: selectedPatnrId, {
prdtId: selectedPrdtId, patnrId: selectedPatnrId,
price: discountedPrice ? discountedPrice : originalPrice, prdtId: selectedPrdtId,
selectedOption: selectedOptions, prodOptCdCval: selectedOptions[selectedBtnOptIdx].prodOptCdCval,
prodQty: quantity,
},
],
// quantity: quantity,
// patnrId: selectedPatnrId,
// prdtId: selectedPrdtId,
// price: discountedPrice ? discountedPrice : originalPrice,
// selectedOption: selectedOptions,
}, },
}) })
); );
} }
}, [dispatch, quantity, discountedPrice, originalPrice, selectedOptions]); }, [dispatch, quantity, discountedPrice, selectedBtnOptIdx, selectedOptions]);
const handleCouponClick = useCallback( const handleCouponClick = useCallback(
(idx) => { (idx) => {
@@ -169,10 +183,24 @@ export default function SingleOption({
[dispatch, popupVisible, promotions] [dispatch, popupVisible, promotions]
); );
const handleCouponTotDownload = useCallback(() => {
if (selectedCoupon && userInfo) {
setDownloadCouponArr((prevArr) => [...prevArr, parseInt(couponCodes)]);
dispatch(
getProductCouponTotDownload({ mbrNo: userInfo, cpnSnoAll: couponCodes })
);
}
}, [selectedCoupon, userInfo, couponCodes]);
const onClose = useCallback(() => { const onClose = useCallback(() => {
dispatch(setHidePopup()); dispatch(setHidePopup());
}, [dispatch]); }, [dispatch]);
useEffect(() => {
if (selectedCoupon) {
getCouponCode();
}
}, [selectedCoupon]);
useEffect(() => { useEffect(() => {
if (!isSpotlight) { if (!isSpotlight) {
return; return;
@@ -184,6 +212,16 @@ export default function SingleOption({
} }
}, [productOptionInfos, productData]); }, [productOptionInfos, productData]);
const getCouponCode = () => {
const snoArray = [];
for (let i = 0; i < selectedCoupon.length; i++) {
snoArray.push(selectedCoupon[i].cpnSno);
}
setCouponCodes(snoArray.join(", "));
};
const renderItem = useCallback( const renderItem = useCallback(
({ index, ...rest }) => { ({ index, ...rest }) => {
const { const {
@@ -193,12 +231,28 @@ export default function SingleOption({
cpnAplyMaxDcAmt, cpnAplyMaxDcAmt,
cpnAplyStrtDtt, cpnAplyStrtDtt,
cpnAplyEndDtt, cpnAplyEndDtt,
duplDwldYn,
downloadYn,
cpnSno,
} = selectedCoupon[index]; } = selectedCoupon[index];
const couponAplyStartDate = cpnAplyStrtDtt.split(" ")[0]; const couponAplyStartDate = cpnAplyStrtDtt.split(" ")[0];
const couponAplyEndDate = cpnAplyEndDtt.split(" ")[0]; const couponAplyEndDate = cpnAplyEndDtt.split(" ")[0];
const handleItemClick = () => {}; const handleItemClick = () => {
if (
(downloadCouponArr.length > 0 &&
downloadCouponArr.includes(cpnSno)) ||
downloadYn === "N"
) {
return;
}
setDownloadCouponArr((prevArr) => [...prevArr, cpnSno]);
dispatch(getProductCouponDownload({ mbrNo: userInfo, cpnSno: cpnSno }));
};
console.log("#downloadcoupon", downloadCouponArr);
return ( return (
<SpottableComponent <SpottableComponent
className={css.couponContainer} className={css.couponContainer}
@@ -216,12 +270,33 @@ export default function SingleOption({
<span className={classNames(css.content, css.date)}> <span className={classNames(css.content, css.date)}>
{$L(`${couponAplyStartDate}~${couponAplyEndDate}`)} {$L(`${couponAplyStartDate}~${couponAplyEndDate}`)}
</span> </span>
<TButton className={css.couponBtn}>{$L("DOWNLOAD")}</TButton> <TButton
className={classNames(
css.couponBtn,
downloadCouponArr.length > 0 &&
downloadCouponArr.includes(cpnSno) &&
css.disable,
downloadYn === "N" && css.disable
)}
onClick={handleItemClick}
spotlightDisabled={
(downloadCouponArr.length > 0 &&
downloadCouponArr.includes(cpnSno)) ||
downloadYn === "N"
}
>
{$L(
downloadCouponArr.length > 0 &&
downloadCouponArr.includes(cpnSno)
? "DOWNLOAD COMPLETED"
: "DOWNLOAD"
)}
</TButton>
</div> </div>
</SpottableComponent> </SpottableComponent>
); );
}, },
[selectedCoupon] [selectedCoupon, couponCodes, downloadCouponArr, dispatch]
); );
return ( return (
@@ -395,7 +470,8 @@ export default function SingleOption({
hasText hasText
title={couponTypes === 0 ? promotions[0] : promotions[1]} title={couponTypes === 0 ? promotions[0] : promotions[1]}
open={popupVisible} open={popupVisible}
onClose={onClose} onClick={onClose}
onClose={handleCouponTotDownload}
hasButton hasButton
button1Text={$L("CLOSE")} button1Text={$L("CLOSE")}
button2Text={$L("DOWNLOAD ALL")} button2Text={$L("DOWNLOAD ALL")}

View File

@@ -324,10 +324,16 @@
height: 60px; height: 60px;
border-radius: 6px; border-radius: 6px;
margin-top: 18px; margin-top: 18px;
z-index: 1;
> div { > div {
font-weight: bold; font-weight: bold;
font-size: 24px; font-size: 24px;
} }
&.disable {
background-color: #808080;
box-shadow: 0 0 0 0 rgba(0, 0, 0, 0.5);
}
} }
} }
} }

View File

@@ -12,7 +12,8 @@
.backIcon { .backIcon {
.size(@w: 60px, @h: 60px); .size(@w: 60px, @h: 60px);
background-size: contain; background-size: 60px 60px;
background-repeat: no-repeat;
background-image: url("../../../../assets/images/btn/btn-60-wh-back-nor@3x.png"); background-image: url("../../../../assets/images/btn/btn-60-wh-back-nor@3x.png");
&:focus { &:focus {
@@ -22,7 +23,8 @@
.liveIcon { .liveIcon {
margin: 6px 0 6px 30px; margin: 6px 0 6px 30px;
.size(@w: 108px, @h: 48px); .size(@w: 108px, @h: 48px);
background-size: contain; background-size: 108px 48px;
background-repeat: no-repeat;
background-image: url("../../../../assets/images/tag-liveshow.png"); background-image: url("../../../../assets/images/tag-liveshow.png");
vertical-align: top; vertical-align: top;
} }
@@ -42,7 +44,6 @@
margin-left: 14px; margin-left: 14px;
} }
.title { .title {
.elip(1);
display: flex; display: flex;
align-items: center; align-items: center;
font-size: 44px; font-size: 44px;