diff --git a/com.twin.app.shoptime/assets/images/btn/btn-quantity-decrease-dim@3x.png b/com.twin.app.shoptime/assets/images/btn/btn-quantity-decrease-dim@3x.png new file mode 100644 index 00000000..30f39ab0 Binary files /dev/null and b/com.twin.app.shoptime/assets/images/btn/btn-quantity-decrease-dim@3x.png differ diff --git a/com.twin.app.shoptime/assets/images/btn/btn-quantity-decrease-foc@3x.png b/com.twin.app.shoptime/assets/images/btn/btn-quantity-decrease-foc@3x.png new file mode 100644 index 00000000..45c58cd9 Binary files /dev/null and b/com.twin.app.shoptime/assets/images/btn/btn-quantity-decrease-foc@3x.png differ diff --git a/com.twin.app.shoptime/assets/images/btn/btn-quantity-decrease-nor@3x.png b/com.twin.app.shoptime/assets/images/btn/btn-quantity-decrease-nor@3x.png new file mode 100644 index 00000000..01860264 Binary files /dev/null and b/com.twin.app.shoptime/assets/images/btn/btn-quantity-decrease-nor@3x.png differ diff --git a/com.twin.app.shoptime/assets/images/btn/btn-quantity-increase-dim@3x.png b/com.twin.app.shoptime/assets/images/btn/btn-quantity-increase-dim@3x.png new file mode 100644 index 00000000..cba3c38f Binary files /dev/null and b/com.twin.app.shoptime/assets/images/btn/btn-quantity-increase-dim@3x.png differ diff --git a/com.twin.app.shoptime/assets/images/btn/btn-quantity-increase-foc@3x.png b/com.twin.app.shoptime/assets/images/btn/btn-quantity-increase-foc@3x.png new file mode 100644 index 00000000..2ac8d16e Binary files /dev/null and b/com.twin.app.shoptime/assets/images/btn/btn-quantity-increase-foc@3x.png differ diff --git a/com.twin.app.shoptime/assets/images/btn/btn-quantity-increase-nor@3x.png b/com.twin.app.shoptime/assets/images/btn/btn-quantity-increase-nor@3x.png new file mode 100644 index 00000000..eefc0a6f Binary files /dev/null and b/com.twin.app.shoptime/assets/images/btn/btn-quantity-increase-nor@3x.png differ diff --git a/com.twin.app.shoptime/assets/images/icons/ic-heart-nor@3x.png b/com.twin.app.shoptime/assets/images/icons/ic-heart-nor@3x.png new file mode 100644 index 00000000..831f623a Binary files /dev/null and b/com.twin.app.shoptime/assets/images/icons/ic-heart-nor@3x.png differ diff --git a/com.twin.app.shoptime/src/views/DetailPanel/components/optionTypes/OptionCommon.jsx b/com.twin.app.shoptime/src/views/DetailPanel/components/optionTypes/OptionCommon.jsx index c30c7885..f5b977ee 100644 --- a/com.twin.app.shoptime/src/views/DetailPanel/components/optionTypes/OptionCommon.jsx +++ b/com.twin.app.shoptime/src/views/DetailPanel/components/optionTypes/OptionCommon.jsx @@ -1,14 +1,21 @@ import React, { useCallback, useEffect, useState } from "react"; +import classNames from "classnames"; import { useDispatch, useSelector } from "react-redux"; import SpotlightContainerDecorator from "@enact/spotlight/SpotlightContainerDecorator"; import Spottable from "@enact/spotlight/Spottable"; +import { setHidePopup, setShowPopup } from "../../../../actions/commonActions"; +import { + getProductCouponInfo, + getProductCouponSearch, +} from "../../../../actions/couponActions"; import { getProductOption } from "../../../../actions/productActions"; import TButton from "../../../../components/TButton/TButton"; import TPopUp from "../../../../components/TPopUp/TPopUp"; import TScroller from "../../../../components/TScroller/TScroller"; +import usePriceInfo from "../../../../hooks/usePriceInfo"; import { $L } from "../../../../utils/helperMethods"; import css from "./OptionCommon.module.less"; @@ -17,64 +24,121 @@ const Container = SpotlightContainerDecorator( "div" ); +const ACTIVE_POPUP = { + options: "options", + favorite: "favorite", + coupon: "coupon", +}; + export default function OptionCommon({ selectedPatnrId, selectedPardtId }) { const dispatch = useDispatch(); const productOptionInfos = useSelector((state) => state.product.prdtOptInfo); - - const [selectedIndex, setSelectedIndex] = useState(0); - const [optionPopupOpen, setOptionPopupOpen] = useState(false); - const [secondOptionOpen, setSecondOptionOpen] = useState(false); - - useEffect(() => { - dispatch( - getProductOption({ - patnrId: selectedPatnrId, - prdtId: selectedPardtId, - }) - ); - }, [dispatch]); - - const handleClose = useCallback(() => { - setOptionPopupOpen(false); - }, [optionPopupOpen]); - - const handleOptionClick = useCallback( - (idx) => { - idx === 0 ? setOptionPopupOpen(true) : setSecondOptionOpen(true); - }, - [productOptionInfos] + const productInfos = useSelector((state) => state.main.productData); + const popupVisible = useSelector((state) => state.common.popupVisible); + const couponInfos = useSelector( + (state) => state.coupon.productCouponSearchData ); + const [selectedIndex, setSelectedIndex] = useState(0); + const [quantity, setQuantity] = useState(1); + const [activePopup, setActivePopup] = useState(null); + const [couponTypes, setCouponTypes] = useState(null); + + const { priceInfo, shippingCharge, favorYn } = productInfos; + const { originalPrice, discountedPrice, discountRate } = + usePriceInfo(priceInfo) || {}; + + const promotions = [$L("SHOPTIME PROMOTION"), $L("SPECIAL PROMOTION")]; + const promotionDesc = $L("Coupon only applicable to this product!"); + + useEffect(() => { + if (selectedPardtId && selectedPatnrId) { + dispatch( + getProductOption({ + patnrId: selectedPatnrId, + prdtId: selectedPardtId, + }) + ); + dispatch( + getProductCouponSearch({ + // patnrId: selectedPatnrId, + // prdtId: selectedPardtId, + patnrId: 11, + prdtId: 7280567, + }) + ); + dispatch( + getProductCouponInfo({ + patnrId: selectedPatnrId, + prdtId: selectedPardtId, + }) + ); + } + }, [dispatch, selectedPardtId, selectedPatnrId]); + + const handleOptionClick = useCallback(() => {}, []); + + const handleIncrement = useCallback(() => { + setQuantity(quantity + 1); + }, [quantity]); + + const handlDecrement = useCallback(() => { + if (quantity <= 1) setQuantity(1); + else setQuantity(quantity - 1); + }, [quantity]); + + const handleFavoriteClick = useCallback(() => { + // TODO : 찜 로직 + setActivePopup(ACTIVE_POPUP.favorite); + dispatch(setShowPopup()); + }, [dispatch]); + + const handleCouponClick = useCallback( + (idx) => { + setActivePopup(ACTIVE_POPUP.coupon); + setCouponTypes(idx); + dispatch(setShowPopup()); + }, + [dispatch] + ); + + const onClose = useCallback(() => { + dispatch(setHidePopup()); + setActivePopup(null); + }, [dispatch]); + + // console.log("#couponInfos", couponInfos); return ( - - - {productOptionInfos && - productOptionInfos.length > 0 && - productOptionInfos.map((option, idx) => { - const { - cntryCd, - concProdOptSno, - optNm, - patnrId, - prdtId, - prodOptSno, - prodOptTpCdCval, - prdtOptDtl, - } = option; - return ( -
- {$L(optNm.toUpperCase())} - { - handleOptionClick(idx); - }} - > - - {prdtOptDtl[0].prodOptCval} - - - + + + {productOptionInfos && + productOptionInfos.length > 0 && + productOptionInfos.map((option, idx) => { + const { + cntryCd, + concProdOptSno, + optNm, + patnrId, + prdtId, + prodOptSno, + prodOptTpCdCval, + prdtOptDtl, + } = option; + return ( +
+ {$L(optNm.toUpperCase())} + { + handleOptionClick(idx); + }} + > + + {prdtOptDtl[0].prodOptCval} + + + {/* -
- ); - })} -
-
-
- SHOPTIME PROMOTION - Coupon only applicable to this product! + /> */} +
+ ); + })} + {/* QUANTITY */} + + {$L("QUANTITY")} +
+ + {quantity} + +
+
+ + + {/* COUPON */} + {promotions.map((promotion, idx) => { + return ( + +
+ {promotion} + {promotionDesc} +
+ { + handleCouponClick(idx); + }} + > + {$L("COUPON")} + +
+ ); + })} + + {/* QVC Price */} + {originalPrice && discountedPrice && ( +
+ {$L("QVC Price")} +
+ {discountedPrice !== originalPrice && ( + {discountRate} + )} + {discountedPrice} + {discountedPrice !== originalPrice && ( + {originalPrice} + )} +
- COUPON -
-
- {$L("QVC Price")} - -
-
- {$L("Shipping Free")} - -
-
+ )} + {shippingCharge && ( +
+ {$L("Shipping Free")} + {shippingCharge} +
+ )} + {/* BYU NOW & FAVORITE */} + + {$L("BUY NOW")} + + + {/* COUPON POPUP */} + {activePopup && activePopup === "coupon" && ( + +
+
+
+
+ )} + {/* FAVORITE POPUP */} + {activePopup && activePopup === "favorite" && ( + + )} +
); } diff --git a/com.twin.app.shoptime/src/views/DetailPanel/components/optionTypes/OptionCommon.module.less b/com.twin.app.shoptime/src/views/DetailPanel/components/optionTypes/OptionCommon.module.less index d68f2812..a5c6c2f2 100644 --- a/com.twin.app.shoptime/src/views/DetailPanel/components/optionTypes/OptionCommon.module.less +++ b/com.twin.app.shoptime/src/views/DetailPanel/components/optionTypes/OptionCommon.module.less @@ -54,5 +54,176 @@ } } } + + // QUANTITY + .quantityLayer { + .flex(@justifyCenter:space-between); + .font(@baseFontBold,@fontSize:24px); + color: @COLOR_GRAY05; + margin-bottom: 20px; + .wrapper { + min-width: 560px; + .flex(@justifyCenter:space-between); + } + .quantityBtn { + min-width: 90px; + background-color: @COLOR_WHITE; + color: @COLOR_GRAY03; + position: relative; + + &:focus { + color: @PRIMARY_COLOR_RED; + &::after { + .focused(@boxShadow: 22px, @borderRadius: 12px); + .imgElement(42px, 42px, right 26px, center); + } + } + + &.increaseBtn { + background-image: url(../../../../../assets/images/btn/btn-quantity-increase-nor@3x.png); + .imgElement(90px, 90px, center, center); + &:focus { + background-image: url(../../../../../assets/images/btn/btn-quantity-increase-foc@3x.png); + .imgElement(90px, 90px, center, center); + } + } + + &.decreaseBtn { + background-image: url(../../../../../assets/images/btn/btn-quantity-decrease-nor@3x.png); + .imgElement(90px, 90px, center, center); + &:focus { + background-image: url(../../../../../assets/images/btn/btn-quantity-decrease-foc@3x.png); + .imgElement(90px, 90px, center, center); + } + } + + &.decreaseDimBtn { + background-image: url(../../../../../assets/images/btn/btn-quantity-decrease-dim@3x.png); + .imgElement(90px, 90px, center, center); + opacity: 0.3; + } + } + } + } + + // COUPON + .detailBottomLayer { + width: 100%; + margin-top: 27px; + .flex(@justifyCenter:space-between); + .leftLayer { + .flex(@direction:column, @justifyCenter:center,@alignCenter:flex-start); + .promotionName { + color: @COLOR_GRAY05; + .font(@baseFontBold,@fontSize:24px); + } + .promotionDesc { + color: @COLOR_GRAY03; + .font(@baseFont,@fontSize:24px); + } + } + .promotionBtn { + min-width: 144px; + height: 60px; + .font(@baseFontBold,@fontSize:24px); + line-height: 60px; + border-radius: 6px; + background: @COLOR_GRAY03; + position: relative; + &:focus { + background: @PRIMARY_COLOR_RED; + } + } + } + + .discountedPriceLayer { + .flex(@justifyCenter:space-between); + .font(@baseFontBold,@fontSize:36px); + color: @COLOR_GRAY07; + margin-top: 31px; + + .priceWrapper { + .flex(); + } + + .discountRateTag { + padding: 0 12px; + background: #f00; + color: @COLOR_WHITE; + .font(@baseFontBold,@fontSize:24px); + text-align: center; + border-radius: 6px; + height: 42px; + line-height: 42px; + } + + .discountedPrice { + .font(@baseFontBold,@fontSize:44px); + line-height: 1.14; + color: @PRIMARY_COLOR_RED; + margin-left: 12px; + } + + .originalPrice { + .font(@baseFont,@fontSize:24px); + color: @COLOR_GRAY03; + text-decoration: line-through; + margin-left: 9px; + } + } + + .notDiscountedPriceLayer { + .flex(@justifyCenter:space-between); + .font(@baseFontBold,@fontSize:36px); + color: @COLOR_GRAY07; + margin-top: 31px; + .priceWrapper { + .flex(); + } + .discountedPrice { + .font(@baseFontBold,@fontSize:44px); + line-height: 1.14; + color: @PRIMARY_COLOR_RED; + margin-left: 12px; + } + } + + .shippingLayer { + width: 100%; + .flex(@justifyCenter:space-between); + margin-top: 13px; + > span { + .font(@baseFont,@fontSize:24px); + line-height: 1.33; + color: @COLOR_GRAY03; + } + } + + .bottomBtnLayer { + margin-top: 24px; + position: relative; + .flex(@justifyCenter:space-between); + .buyNowBtn { + min-width: 756px; + height: 78px; + } + .favoriteBtn { + min-width: 78px; + height: 78px; + background-image: url(../../../../../assets/images/icons/ic-heart-nor@3x.png); + .imgElement(54px, 54px, center, center); + } + } + + .itemContainer { + background: #f00; + width: 440px; + height: 320px; + .couponItem { + width: 440px; + height: 320px; + position: relative; + background: yellow; + } } } diff --git a/com.twin.app.shoptime/src/views/DetailPanel/container/ProductOption.jsx b/com.twin.app.shoptime/src/views/DetailPanel/container/ProductOption.jsx index 70963a55..b37e1dcb 100644 --- a/com.twin.app.shoptime/src/views/DetailPanel/container/ProductOption.jsx +++ b/com.twin.app.shoptime/src/views/DetailPanel/container/ProductOption.jsx @@ -23,7 +23,7 @@ export default function ProductOption({ selectedPatnrId, selectedPardtId }) {
{$L(prdtNm)}
- {revwGrd && } +
{revwGrd && }