{"version":3,"sources":["views/pages/VoucherView/components/Options/Options.js","views/pages/VoucherView/components/PriceInput/PriceInput.js","views/pages/VoucherView/components/SectionCard/SectionCard.js","views/common/component/SuggestedCoupons/components/CouponItem/CouponItem.js","views/common/component/SuggestedCoupons/SuggestedCoupons.js","views/pages/VoucherView/components/BriefInfo/BriefInfo.js","views/pages/VoucherView/components/index.js","views/pages/VoucherView/index.js"],"names":["Options","props","priceOptions","selectedPriceOptions","handleSelectPriceOption","handleChangeVoucherQuantity","quantity","currency","exchangeRate","className","minValue","maxValue","initialValue","onCommitChange","length","map","priceOption","type","classNames","productCode","disabled","onClick","toLowerCase","CURRENCY_TYPE","UTOP","name","toUTop","price","toVND","MAX_PRICE","PriceInput","forwardRef","ref","onCommitAmount","useState","value","setValue","useEffect","placeholder","Number","toLocaleString","min","max","inputMode","pattern","onInput","e","typedValue","target","replace","parsedValue","SectionCard","title","content","hasCollapse","customTitle","brandLogoUrl","brandName","show","setShow","data","LogoUtop","src","CouponItem","code","endDateTime","isAllocated","handleSave","handleClickContent","showBtnShowMore","handleShowMore","nameClassName","endDateClassName","moment","utc","local","format","SuggestedCoupons","isLoading","suggestedCouponList","handleSaveCoupon","handleGotoDetailCoupon","firstCoupon","showSuggestedCouponList","setShowSuggestedCouponList","couponId","couponCode","handleClose","showBtnClose","style","padding","lineHeight","coupon","marginTop","BriefInfo","isLoadingSuggestedCoupons","voucherType","VOUCHER_TYPES","GEN_VOUCHER_WITH_AMOUNT","voucherName","unitPrice","unitListPrice","tags","tag","MESSAGE_KEY","toastOptions","position","autoClose","hideProgressBar","closeOnClick","pauseOnHover","draggable","progress","undefined","checkIfPriceOptionNotAvailable","_outOfStockProductCodes","_currPriceOption","find","VoucherView","idVoucher","useQuery","get","history","useHistory","location","useLocation","dispatch","useDispatch","useSelector","state","TYPE","voucherInfo","shortLinkToShare","outOfStockProductCodes","userInfo","ROOT_TYPE","amountToBuy","selectedVoucherOptions","setSelectedVoucherOptions","showModalWarning","setShowModalWarning","showModalShouldReload","setShowModalShouldReload","showModalRequireLogin","setShowModalRequireLogin","amountInputRef","useRef","isSelectedPriceOptionNotAvailable","useMemo","console","log","cartDataOfThisVoucherFromLS","found","JSON","parse","localStorage","getItem","VOUCHER_CART_KEY","totalPrice","actions","GET_VOUCHER_INFO","request","id","currentChosenPriceOption","prices","expiredDate","listPrice","productName","dataToUpdate","prev","defaultPriceOption","default","CHECK_STOCK_OF_PRODUCT","handleCheckStockOfPriceOption","merchant","viewAsGuest","GET_SUGGESTED_COUPON_LIST","MerchantId","Feature","isOverExpirationDate","Date","getTime","now","useCallback","SAVE_SUGGESTED_COUPON","onSuccess","toast","success","toastId","onFailure","message","errMsgToToast","MESSAGES","error","warn","push","handleClickBtnBuyVoucher","a","current","focus","voucherCartDataToSave","couponToUse","appliedCoupon","setItem","stringify","handleCommitAmountToBuy","amount","handleTriggerWebShareAPI","_shortLinkToShare","navigator","share","text","vi","en","handleCloseModalWarning","prevPathname","goBack","handleCloseModalShouldReload","removeItem","CART_KEYS_MAP","VOUCHER_CART","LOCAL_STORAGE_KEY","window","reload","items","images","imgWrapperClassName","imgClassName","GET_SHORT_LINK_TO_SHARE","url","href","callbackFunction","currencies","idCoupon","mode","COUPON_DETAIL_PAGE_MODES","ALLOCATE","callbackUrl","pathname","search","prevPage","brand","iv","logoUrl","description","term","itemsCount","onClickButton","onClose","scrollable","centered","variant"],"mappings":"6JAAA,4EAwEeA,UAjEf,SAAiBC,GACf,IACEC,EAOED,EAPFC,aACAC,EAMEF,EANFE,qBAFF,EAQIF,EALFG,+BAHF,MAG4B,aAH5B,EAIEC,EAIEJ,EAJFI,4BACAC,EAGEL,EAHFK,SACAC,EAEEN,EAFFM,SACAC,EACEP,EADFO,aAGF,OACE,sBAAKC,UAAU,kBAAf,UACE,sBAAKA,UAAU,qBAAf,UACE,8BACE,sBAAMA,UAAU,QAAhB,uCAGF,cAAC,IAAD,CACEC,SAAU,EACVC,SAAU,GACVC,aAAcN,EACdO,eAAgBR,QAK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GACZwF,WAAY7G,GAAuBnI,SACnCiP,cAAenD,KAGjB,eAAC,IAAD,CACEhJ,MAAM,OACNM,KAAMiF,GACN6G,QAASlC,GACTmC,YAAY,EACZC,UAAQ,EALV,UAOE,cAAC,IAAD,CAAcjP,UAAU,WAAxB,SACE,sBAAMA,UAAU,UAAhB,oBAGF,cAAC,IAAD,CAAYA,UAAU,OAAtB,SACG0K,KACG,iDACA,oIAEN,eAAC,IAAD,CAAc1K,UAAU,WAAxB,UACoC,OAAjC,WAAAmH,GAASK,aAAT,iBAAgBsF,eACf,cAAC,IAAD,CACEoC,QAAQ,QACRtO,QAAS,WACPqG,GAAQyE,KAAK,MAHjB,qCASD,WAAAvE,GAASK,aAAT,iBAAgBsF,eACf,cAAC,IAAD,CAASoC,QAAQ,QAAQtO,QAASiM,GAAlC,iCAON,eAAC,IAAD,CACElK,MAAM,OACNM,KAAMmF,GACN2G,QAAS/B,GACTgC,YAAY,EACZC,UAAQ,EALV,UAOE,cAAC,IAAD,CAAcjP,UAAU,WAAxB,SACE,sBAAMA,UAAU,UAAhB,oBAEF,cAAC,IAAD,CAAYA,UAAU,OAAtB,6GAGA,cAAC,IAAD,CAAcA,UAAU,WAAxB,SACE,cAAC,IAAD,CAASkP,QAAQ,QAAQtO,QAASoM,GAAlC,0CAMJ,eAAC,IAAD,CACErK,MAAM,OACNM,KAAMqF,GACNyG,QAtM+B,WACnCxG,IAAyB,IAsMrByG,YAAY,EACZC,UAAQ,EALV,UAOE,cAAC,IAAD,CAAcjP,UAAU,WAAxB,SACE,sBAAMA,UAAU,UAAhB,4DAEF,cAAC,IAAD,CAAYA,UAAU,OAAtB,2JAGA,cAAC,IAAD,CAAcA,UAAU,WAAxB,SACE,cAAC,IAAD,CAASkP,QAAQ,QAAQtO,QA7MD,WAC9BqG,GAAQyE,KAAR,WA4MM","file":"static/js/29.315996e2.chunk.js","sourcesContent":["import classNames from \"classnames\";\r\nimport React from \"react\";\r\nimport { InputNumberV2 } from \"views/common/component\";\r\nimport { CURRENCY_TYPE } from \"constants/types\";\r\nimport { toVND, toUTop } from \"utils/currencyFormat\";\r\nimport \"./Options.scss\";\r\n\r\nfunction Options(props) {\r\n const {\r\n priceOptions,\r\n selectedPriceOptions,\r\n handleSelectPriceOption = () => {},\r\n handleChangeVoucherQuantity,\r\n quantity,\r\n currency,\r\n exchangeRate,\r\n } = props;\r\n\r\n return (\r\n
\r\n
\r\n
\r\n Số lượng\r\n
\r\n\r\n \r\n
\r\n\r\n {/* chỉ có 1 option thì không cần show */}\r\n {priceOptions?.length > 1 && (\r\n <>\r\n
\r\n\r\n
\r\n
\r\n Tùy chọn giá\r\n
\r\n\r\n
\r\n {priceOptions.map((priceOption) => (\r\n \r\n \r\n {currency?.toLowerCase() === CURRENCY_TYPE.UTOP.name\r\n ? toUTop(priceOption.price, exchangeRate)\r\n : toVND(priceOption.price)}\r\n \r\n \r\n ))}\r\n
\r\n
\r\n \r\n )}\r\n
\r\n );\r\n}\r\n\r\nexport default Options;\r\n","import React, { useState, useEffect, forwardRef } from \"react\";\r\nimport { CURRENCY_TYPE } from \"constants/types\";\r\nimport \"./PriceInput.scss\";\r\n\r\nconst MIN_PRICE = 0;\r\nconst MAX_PRICE = 20000;\r\n\r\nconst PriceInput = forwardRef((props, ref) => {\r\n const { onCommitAmount, initialValue } = props;\r\n const [value, setValue] = useState(\"\");\r\n\r\n const handleOnInput = (e) => {\r\n const typedValue = Number(e.target.value.replace(\".\", \"\"));\r\n\r\n if (!typedValue) {\r\n setValue(\"\");\r\n return;\r\n }\r\n\r\n const parsedValue = Number(typedValue) || MIN_PRICE;\r\n\r\n if (parsedValue < MIN_PRICE && parsedValue !== value) {\r\n setValue(MIN_PRICE);\r\n return;\r\n }\r\n\r\n if (parsedValue > MAX_PRICE && parsedValue !== value) {\r\n setValue(MAX_PRICE);\r\n return;\r\n }\r\n\r\n setValue(typedValue);\r\n };\r\n\r\n useEffect(() => {\r\n if (initialValue) {\r\n setValue(initialValue);\r\n }\r\n }, [initialValue]);\r\n\r\n useEffect(() => {\r\n onCommitAmount(value);\r\n }, [value]);\r\n\r\n return (\r\n
\r\n \r\n {props.currency?.toLowerCase() === CURRENCY_TYPE.UTOP.name\r\n ? \"Nhập số Utop\"\r\n : \" Nhập số tiền (đơn vị: Ngàn VND)\"}\r\n \r\n\r\n
\r\n \r\n\r\n \r\n {props.currency?.toLowerCase() === CURRENCY_TYPE.UTOP.name\r\n ? \"Utop\"\r\n : \".000đ\"}\r\n \r\n
\r\n
\r\n );\r\n});\r\n\r\nexport default PriceInput;\r\n","import React, { useState } from \"react\";\r\nimport classNames from \"classnames\";\r\nimport { CCollapse } from \"@coreui/react\";\r\nimport { ArrowDownIcon } from \"assets/svg\";\r\nimport { Markup } from \"interweave\";\r\nimport LogoUtop from \"assets/img/LogoUtop.jpg\";\r\nimport \"./SectionCard.scss\";\r\n\r\nfunction SectionCard(props) {\r\n const { title, content, hasCollapse, customTitle, brandLogoUrl, brandName } =\r\n props;\r\n const [show, setShow] = useState(true);\r\n\r\n const handleToggleShow = () => {\r\n setShow(!show);\r\n };\r\n\r\n return (\r\n
\r\n
\r\n {customTitle ? (\r\n
\r\n \r\n \r\n \r\n\r\n {brandName}\r\n
\r\n ) : (\r\n {title}\r\n )}\r\n\r\n {hasCollapse && (\r\n \r\n \r\n \r\n )}\r\n
\r\n\r\n {content && (\r\n \r\n
\r\n \r\n
\r\n
\r\n )}\r\n
\r\n );\r\n}\r\n\r\nexport default SectionCard;\r\n","import React from \"react\";\r\nimport { CouponIcon, ArrowRightYellowIcon } from \"assets/svg\";\r\nimport moment from \"moment\";\r\nimport classNames from \"classnames\";\r\nimport \"./CouponItem.scss\";\r\n\r\nconst CouponItem = (props) => {\r\n const {\r\n code,\r\n endDateTime,\r\n name,\r\n isAllocated,\r\n handleSave,\r\n handleClickContent,\r\n\r\n //\r\n showBtnShowMore,\r\n handleShowMore,\r\n nameClassName,\r\n endDateClassName,\r\n } = props;\r\n\r\n return (\r\n
\r\n \r\n \r\n \r\n\r\n \r\n
\r\n {name}\r\n
\r\n {endDateTime && (\r\n
\r\n \r\n Hết hạn:{\" \"}\r\n \r\n {moment.utc(endDateTime).local().format(\"DD/MM/YYYY\")}\r\n \r\n \r\n
\r\n )}\r\n
\r\n\r\n {showBtnShowMore ? (\r\n \r\n Xem thêm\r\n \r\n \r\n \r\n \r\n ) : (\r\n \r\n {isAllocated ? \"Đã lấy\" : \"Lấy mã\"}\r\n \r\n )}\r\n\r\n {/* \r\n Xem thêm\r\n \r\n \r\n \r\n */}\r\n
\r\n );\r\n};\r\n\r\nexport default CouponItem;\r\n","import React, { useState } from \"react\";\r\n// import Popup from \"../Popup\";\r\nimport { Dock, LoadingOverlay } from \"..\";\r\nimport { CouponItem } from \"./components\";\r\nimport \"./SuggestedCoupons.scss\";\r\n\r\nfunction SuggestedCoupons(props) {\r\n const {\r\n isLoading = false,\r\n suggestedCouponList,\r\n handleSaveCoupon,\r\n handleGotoDetailCoupon,\r\n } = props;\r\n const firstCoupon = suggestedCouponList?.[0];\r\n\r\n const [showSuggestedCouponList, setShowSuggestedCouponList] = useState(false);\r\n\r\n const handleClosePopupSuggestedCouponList = () => {\r\n setShowSuggestedCouponList(false);\r\n };\r\n\r\n const handleOpenPopupSuggestedCouponList = () => {\r\n setShowSuggestedCouponList(true);\r\n };\r\n\r\n return (\r\n <>\r\n
\r\n 1}\r\n handleShowMore={handleOpenPopupSuggestedCouponList}\r\n nameClassName=\"suggested-coupons-section__coupon-name\"\r\n endDateClassName=\"suggested-coupons-section__end-date\"\r\n />\r\n\r\n {suggestedCouponList?.length > 0 && (\r\n \r\n \r\n Ưu đãi hiện có\r\n
\r\n
\r\n {suggestedCouponList?.map((coupon) => (\r\n \r\n ))}\r\n
\r\n \r\n \r\n )}\r\n \r\n \r\n );\r\n}\r\n\r\nexport default SuggestedCoupons;\r\n","import React from \"react\";\r\n// import { IconList } from \"views/common/component\";\r\nimport { SuggestedCoupons } from \"views/common/component/SuggestedCoupons\";\r\n\r\nimport { VOUCHER_TYPES, CURRENCY_TYPE } from \"constants/types\";\r\nimport \"./BriefInfo.scss\";\r\nimport { toVND, toUTop } from \"utils/currencyFormat\";\r\n\r\nfunction BriefInfo(props) {\r\n const {\r\n isLoadingSuggestedCoupons = false,\r\n voucherType = VOUCHER_TYPES.GEN_VOUCHER_WITH_AMOUNT,\r\n voucherName = \"\",\r\n unitPrice,\r\n unitListPrice,\r\n tags = [],\r\n suggestedCouponList = [],\r\n handleSaveCoupon,\r\n handleGotoDetailCoupon,\r\n exchangeRate,\r\n currency,\r\n } = props;\r\n\r\n return (\r\n
\r\n
{voucherName}
\r\n\r\n {voucherType !== VOUCHER_TYPES.GEN_VOUCHER_WITH_AMOUNT && (\r\n <>\r\n {/*
\r\n \r\n 4.8\r\n
*/}\r\n\r\n
\r\n {Number(unitPrice) > 0 && (\r\n \r\n {currency?.toLowerCase() === CURRENCY_TYPE.UTOP.name\r\n ? toUTop(unitPrice, exchangeRate)\r\n : toVND(unitPrice)}\r\n \r\n )}\r\n {Number(unitListPrice) > 0 &&\r\n Number(unitListPrice) !== Number(unitPrice) && (\r\n \r\n {currency?.toLowerCase() === CURRENCY_TYPE.UTOP.name\r\n ? toUTop(unitListPrice, exchangeRate)\r\n : toVND(unitListPrice)}\r\n \r\n )}\r\n
\r\n\r\n {tags?.length > 0 && (\r\n
\r\n {tags?.map((tag) => (\r\n
\r\n {tag}\r\n
\r\n ))}\r\n
\r\n )}\r\n \r\n )}\r\n\r\n {suggestedCouponList?.length > 0 && (\r\n <>\r\n
\r\n\r\n \r\n \r\n )}\r\n
\r\n );\r\n}\r\n\r\nexport default BriefInfo;\r\n","export { default as BriefInfo } from \"./BriefInfo/BriefInfo\";\r\nexport { default as PriceInput } from \"./PriceInput/PriceInput\";\r\nexport { default as Options } from \"./Options/Options\";\r\nexport { default as SectionCard } from \"./SectionCard/SectionCard\";\r\n","import React, {\r\n useCallback,\r\n useEffect,\r\n useMemo,\r\n useRef,\r\n useState,\r\n} from \"react\";\r\nimport { useHistory, useLocation } from \"react-router-dom\";\r\nimport { useDispatch, useSelector } from \"react-redux\";\r\nimport {\r\n CButton,\r\n CModal,\r\n CModalBody,\r\n CModalFooter,\r\n CModalHeader,\r\n} from \"@coreui/react\";\r\nimport { toast } from \"react-toastify\";\r\nimport useQuery from \"assets/hooks/useQuery\";\r\nimport MESSAGES from \"constants/vi\";\r\nimport {\r\n CART_KEYS_MAP,\r\n COUPON_DETAIL_PAGE_MODES,\r\n CURRENCY_TYPE,\r\n VOUCHER_TYPES,\r\n} from \"constants/types\";\r\nimport { VOUCHER_CART_KEY } from \"constants/localStorageKeys\";\r\n\r\nimport { ArrowLeftWhiteIcon, ShareWhiteIcon } from \"assets/svg\";\r\n\r\nimport {\r\n CustomSlider,\r\n CartBottomBar,\r\n LoadingOverlay,\r\n} from \"views/common/component\";\r\n\r\nimport { TYPE as ROOT_TYPE } from \"views/common/store/constants/constants\";\r\nimport { TYPE } from \"./store/constants\";\r\nimport actions from \"./store/actions\";\r\n\r\nimport { BriefInfo, Options, PriceInput, SectionCard } from \"./components\";\r\n\r\nimport \"./VoucherView.scss\";\r\n\r\nconst MESSAGE_KEY = \"ConfirmPayment\"; // key của object chứa message\r\nconst UNKNOWN = \"unknown\";\r\nconst toastOptions = {\r\n position: \"top-center\",\r\n autoClose: 7000,\r\n hideProgressBar: false,\r\n closeOnClick: true,\r\n pauseOnHover: true,\r\n draggable: true,\r\n progress: undefined,\r\n};\r\n\r\n// cần tạo 1 biến ngoài scope của page để tránh bị cấp phát lại vùng nhớ mới khi rerender\r\n// nếu viết theo kiểu:\r\n// ;\r\n// thì prop \"settings\" sẽ được cấp phát lại vùng nhớ khi VoucherView rerender\r\n// vì lí do nào đó mà Slider (infinite-react-carousel) sẽ bị lỗi \"can not create array\"\r\n// có lẽ do đã khởi tạo settings 1 lần trước rồi mà giờ bị trùng lại nên somehow hàm tạo circular array nó không work được\r\n// => Khi cần truyền custom settings xuống Slider thì cần tạo ra biến chỉ được cấp phát vùng nhớ đúng 1 lần.\r\n// (maybe là do đang work với loadable, vì đã thử set up với context tương tự trên codesandbox nhwung không bị lỗi)\r\n\r\nfunction VoucherView() {\r\n const query = useQuery();\r\n const idVoucher = query.get(\"id\");\r\n const history = useHistory();\r\n const location = useLocation();\r\n const dispatch = useDispatch();\r\n const {\r\n voucherInfo,\r\n suggestedCouponList,\r\n shortLinkToShare,\r\n outOfStockProductCodes,\r\n isLoading,\r\n } = useSelector((state) => state[TYPE]);\r\n const { userInfo } = useSelector((state) => state[ROOT_TYPE]);\r\n const [selectedVoucherOptions, setSelectedVoucherOptions] = useState({\r\n quantity: 1,\r\n amountToBuy: 0,\r\n });\r\n const [showModalWarning, setShowModalWarning] = useState(false);\r\n const [showModalShouldReload, setShowModalShouldReload] = useState(false); // warning page will be reload\r\n const [showModalRequireLogin, setShowModalRequireLogin] = useState(false); // suggest login to buy voucher\r\n\r\n const amountInputRef = useRef();\r\n\r\n const isSelectedPriceOptionNotAvailable = useMemo(() => {\r\n console.log(\"outOfStockProductCodes\", outOfStockProductCodes);\r\n return checkIfPriceOptionNotAvailable(\r\n outOfStockProductCodes,\r\n selectedVoucherOptions?.priceOption\r\n );\r\n }, [outOfStockProductCodes, selectedVoucherOptions?.priceOption]);\r\n\r\n const cartDataOfThisVoucherFromLS = useMemo(() => {\r\n const found = JSON.parse(localStorage.getItem(VOUCHER_CART_KEY));\r\n\r\n if (found?.idVoucher === idVoucher) {\r\n return found;\r\n }\r\n\r\n return null;\r\n }, [idVoucher]);\r\n\r\n const totalPrice = useMemo(() => {\r\n if (\r\n !voucherInfo?.type?.[0] ||\r\n typeof selectedVoucherOptions?.priceOption?.price !== \"number\"\r\n ) {\r\n return 0;\r\n }\r\n\r\n if (voucherInfo?.type?.[0] === VOUCHER_TYPES.GEN_VOUCHER_WITH_AMOUNT) {\r\n return (\r\n selectedVoucherOptions.amountToBuy *\r\n selectedVoucherOptions.priceOption.price\r\n );\r\n }\r\n\r\n return (\r\n selectedVoucherOptions.quantity * selectedVoucherOptions.priceOption.price\r\n );\r\n }, [\r\n voucherInfo?.type?.[0],\r\n selectedVoucherOptions.quantity,\r\n selectedVoucherOptions.priceOption,\r\n selectedVoucherOptions.amountToBuy,\r\n ]);\r\n\r\n useEffect(() => {\r\n if (idVoucher) {\r\n dispatch(actions.GET_VOUCHER_INFO.request({ id: idVoucher }));\r\n }\r\n }, [idVoucher]);\r\n\r\n useEffect(() => {\r\n if (!idVoucher) {\r\n return;\r\n }\r\n\r\n if (!cartDataOfThisVoucherFromLS?.idVoucher === idVoucher) {\r\n return;\r\n }\r\n\r\n if (!cartDataOfThisVoucherFromLS) {\r\n return;\r\n }\r\n\r\n // so sánh thông tin đã lưu trong giỏ hàng & thông tin hiện tại\r\n // chỉ cần so priceOption đã chọn, cần so sánh những field có ảnh hưởng đến giá tiền & về mặt hiển thị\r\n // - expiredTimeRange\r\n // - listPrice\r\n // - price\r\n // - productName\r\n // - productCode: đã dùng để tìm ra priceOption từ api response nên ko cần so nữa\r\n\r\n const currentChosenPriceOption = voucherInfo?.prices?.find(\r\n (priceOption) =>\r\n priceOption.productCode ===\r\n cartDataOfThisVoucherFromLS.priceOption.productCode\r\n );\r\n\r\n if (\r\n !currentChosenPriceOption ||\r\n currentChosenPriceOption.expiredDate !==\r\n cartDataOfThisVoucherFromLS.priceOption.expiredDate ||\r\n currentChosenPriceOption.listPrice !==\r\n cartDataOfThisVoucherFromLS.priceOption.listPrice ||\r\n currentChosenPriceOption.price !==\r\n cartDataOfThisVoucherFromLS.priceOption.price ||\r\n currentChosenPriceOption.productName !==\r\n cartDataOfThisVoucherFromLS.priceOption.productName\r\n ) {\r\n setShowModalShouldReload(true); // ! data was changed/updated!\r\n return;\r\n }\r\n\r\n let dataToUpdate = {\r\n voucherInfo, // ? ko cần selectedVoucherOption.voucherInfo\r\n };\r\n\r\n // get quantity/amountToBuy\r\n if (cartDataOfThisVoucherFromLS?.quantity) {\r\n dataToUpdate = {\r\n ...dataToUpdate,\r\n quantity: cartDataOfThisVoucherFromLS.quantity,\r\n };\r\n }\r\n\r\n if (cartDataOfThisVoucherFromLS?.amountToBuy) {\r\n dataToUpdate = {\r\n ...dataToUpdate,\r\n amountToBuy: cartDataOfThisVoucherFromLS.amountToBuy,\r\n };\r\n }\r\n\r\n setSelectedVoucherOptions((prev) => ({\r\n ...prev,\r\n ...dataToUpdate,\r\n }));\r\n }, [idVoucher, voucherInfo, cartDataOfThisVoucherFromLS]);\r\n\r\n // get chosen price option if exists\r\n useEffect(() => {\r\n if (\r\n cartDataOfThisVoucherFromLS &&\r\n cartDataOfThisVoucherFromLS?.priceOption\r\n ) {\r\n handleSelectPriceOption(cartDataOfThisVoucherFromLS.priceOption)();\r\n return;\r\n }\r\n\r\n // select default price option by api response\r\n if (voucherInfo?.prices?.length > 0) {\r\n let defaultPriceOption = voucherInfo.prices.find(\r\n (priceOption) => priceOption.default === true\r\n );\r\n\r\n if (!defaultPriceOption) {\r\n defaultPriceOption = voucherInfo.prices?.[0];\r\n }\r\n\r\n handleSelectPriceOption(defaultPriceOption)();\r\n }\r\n }, [\r\n voucherInfo?.prices,\r\n cartDataOfThisVoucherFromLS,\r\n handleSelectPriceOption,\r\n ]);\r\n\r\n // check stock của price option được chọn\r\n useEffect(() => {\r\n const handleCheckStockOfPriceOption = () => {\r\n if (selectedVoucherOptions?.priceOption?.productCode) {\r\n dispatch(\r\n actions.CHECK_STOCK_OF_PRODUCT.request({\r\n productCode: selectedVoucherOptions.priceOption.productCode,\r\n })\r\n );\r\n }\r\n };\r\n\r\n if (userInfo) {\r\n handleCheckStockOfPriceOption();\r\n }\r\n }, [userInfo, selectedVoucherOptions?.priceOption]);\r\n\r\n // get suggested coupons\r\n useEffect(() => {\r\n if (voucherInfo?.merchant?.id) {\r\n let viewAsGuest = true;\r\n\r\n if (userInfo) {\r\n viewAsGuest = false;\r\n }\r\n\r\n dispatch(\r\n actions.GET_SUGGESTED_COUPON_LIST.request({\r\n MerchantId: voucherInfo.merchant.id,\r\n Feature: \"OrderGift\",\r\n viewAsGuest,\r\n })\r\n );\r\n }\r\n }, [voucherInfo?.merchant?.id, userInfo]);\r\n\r\n // check if expiration date is over to pop modal\r\n const isOverExpirationDate = () => {\r\n if (!voucherInfo?.expiredDate) return false;\r\n\r\n const expiredDate = new Date(voucherInfo.expiredDate).getTime();\r\n const now = Date.now();\r\n\r\n // quá hạn\r\n if (now > expiredDate) {\r\n return true;\r\n }\r\n return false; // còn hạn\r\n };\r\n\r\n useEffect(() => {\r\n if (isLoading.GET_VOUCHER_INFO) return;\r\n\r\n if (!voucherInfo || isOverExpirationDate()) {\r\n setShowModalWarning(true);\r\n }\r\n }, [isLoading.GET_VOUCHER_INFO, voucherInfo]);\r\n\r\n const handleGoBack = () => {\r\n // 2021/12/16: dùng useSrollMemory() auto gắn prevPage (e.g: prevPage: /search?id=1), prevPathname, prevSearch\r\n // hiện tại chưa có flow nào push về trang /voucherview\r\n // -> có thể dùng goBack\r\n if (location.state?.prevPathname) {\r\n history.goBack();\r\n return;\r\n }\r\n\r\n history.push(\"/\");\r\n };\r\n\r\n // lấy mã coupon được suggested\r\n const handleSaveCoupon = useCallback(\r\n (code) => () => {\r\n if (!userInfo) {\r\n toast.warn(\"Vui lòng đăng nhập để nhận ngay ưu đãi.\", {\r\n toastId: `${TYPE}_SAVE_SUGGESTED_COUPON__REQUIRE_LOGIN`,\r\n onClick: () => {\r\n history.push(\"/login\");\r\n },\r\n });\r\n\r\n return;\r\n }\r\n\r\n const onSuccessSaveCoupon = () => {\r\n toast.success(\"Lấy mã thành công!\", {\r\n toastId: `${TYPE}_SAVE_SUGGESTED_COUPON_SUCCESS`,\r\n ...toastOptions,\r\n });\r\n };\r\n\r\n const onFailureSaveCoupon = (message) => {\r\n const errMsgToToast =\r\n MESSAGES?.[MESSAGE_KEY]?.error?.[message] ||\r\n MESSAGES?.[MESSAGE_KEY]?.error?.[UNKNOWN];\r\n\r\n toast.error(errMsgToToast, {\r\n toastId: `${TYPE}_SAVE_SUGGESTED_COUPON_FAILURE_${message}`,\r\n ...toastOptions,\r\n });\r\n };\r\n\r\n dispatch(\r\n actions.SAVE_SUGGESTED_COUPON.request({\r\n code,\r\n onSuccess: onSuccessSaveCoupon,\r\n onFailure: onFailureSaveCoupon,\r\n })\r\n );\r\n },\r\n [userInfo]\r\n );\r\n\r\n const handleGotoDetailCoupon = (idCoupon, isAllocated) => () => {\r\n history.push(`/coupondetail?id=${idCoupon}`, {\r\n mode: COUPON_DETAIL_PAGE_MODES.ALLOCATE,\r\n callbackUrl: `${window.location.pathname}${window.location.search}`,\r\n prevPage: `${window.location.pathname}${window.location.search}`,\r\n isAllocated,\r\n });\r\n };\r\n\r\n // ** chỉ dành cho type !== GenVoucherWithAmount\r\n const handleSelectPriceOption = useCallback(\r\n (priceOption) => () => {\r\n setSelectedVoucherOptions((prev) => {\r\n return { ...prev, priceOption };\r\n });\r\n },\r\n []\r\n );\r\n\r\n const handleChangeVoucherQuantity = useCallback((quantity) => {\r\n setSelectedVoucherOptions((prev) => ({ ...prev, quantity }));\r\n }, []);\r\n\r\n const handleClickBtnBuyVoucher = async () => {\r\n if (!userInfo) {\r\n setShowModalRequireLogin(true);\r\n return;\r\n }\r\n\r\n if (!selectedVoucherOptions.priceOption) return;\r\n\r\n if (voucherInfo?.type?.[0] === VOUCHER_TYPES.GEN_VOUCHER_WITH_AMOUNT) {\r\n if (selectedVoucherOptions.amountToBuy === 0) {\r\n // pop keyboard\r\n if (amountInputRef.current) {\r\n amountInputRef.current.focus();\r\n }\r\n\r\n return;\r\n }\r\n }\r\n\r\n // lưu data lên localStorage\r\n let voucherCartDataToSave = {\r\n ...cartDataOfThisVoucherFromLS,\r\n quantity: selectedVoucherOptions.quantity,\r\n priceOption: selectedVoucherOptions.priceOption,\r\n voucherInfo,\r\n idVoucher,\r\n };\r\n\r\n if (voucherInfo?.type?.[0] === VOUCHER_TYPES.GEN_VOUCHER_WITH_AMOUNT) {\r\n voucherCartDataToSave = {\r\n ...voucherCartDataToSave,\r\n amountToBuy: selectedVoucherOptions.amountToBuy,\r\n };\r\n }\r\n\r\n /**\r\n * flow:\r\n * 1. /myvoucher: select a coupon\r\n * 2. /coupondetails: click 'Use' btn (Sử dụng)\r\n * 3. /applicablestores: click to go to store (fnb view) or voucherview\r\n * 4. /storedetail or /voucherview: click cart btn\r\n * end.\r\n */\r\n const couponToUse = location.state?.couponToUse;\r\n\r\n if (couponToUse) {\r\n voucherCartDataToSave = {\r\n ...voucherCartDataToSave,\r\n appliedCoupon: {\r\n code: couponToUse.code,\r\n name: couponToUse.name,\r\n },\r\n };\r\n }\r\n\r\n await localStorage.setItem(\r\n VOUCHER_CART_KEY,\r\n JSON.stringify(voucherCartDataToSave)\r\n );\r\n\r\n history.push(\"/vouchercart\");\r\n };\r\n\r\n const handleCommitAmountToBuy = useCallback((amount) => {\r\n setSelectedVoucherOptions((prev) => ({\r\n ...prev,\r\n amountToBuy: Number(amount) || 0,\r\n }));\r\n }, []);\r\n\r\n // * SHARE\r\n const handleTriggerWebShareAPI = async (_shortLinkToShare) => {\r\n if (navigator.share) {\r\n try {\r\n await navigator.share({\r\n title: \"Chia sẻ liên kết của voucher\",\r\n text: `Bạn được giới thiệu trải nghiệm ${\r\n voucherInfo?.name?.vi || voucherInfo?.name?.en\r\n } trên ứng dụng Utop. Nhấn link bên dưới để đăng ký và nhận ưu đãi.\\n${_shortLinkToShare}`,\r\n });\r\n } catch (err) {\r\n console.error(err);\r\n }\r\n } else {\r\n console.error(\"navigator.share is not available on this browser\");\r\n }\r\n };\r\n\r\n const handleGetShortLinkToShare = () => {\r\n if (!shortLinkToShare) {\r\n dispatch(\r\n actions.GET_SHORT_LINK_TO_SHARE.request({\r\n url: window.location.href,\r\n callbackFunction: handleTriggerWebShareAPI,\r\n })\r\n );\r\n\r\n return;\r\n }\r\n\r\n handleTriggerWebShareAPI(shortLinkToShare);\r\n };\r\n\r\n // * MODAL\r\n const handleCloseModalWarning = () => {\r\n if (\r\n // history.location.state?.prevPathname === \"/storeview\" || // click vao deal/voucher item\r\n // history.location.state?.prevPathname === \"/listdeal\" ||\r\n // history.location.state?.prevPathname === \"/\" ||\r\n // history.location.state?.prevPathname === \"/listfeed\" ||\r\n // history.location.state?.prevPathname === \"/search\"\r\n history.location.state?.prevPathname\r\n ) {\r\n history.goBack();\r\n return;\r\n }\r\n\r\n history.push(\"/\"); // cho trường hợp mở trực tiếp từ link share, gặp voucher ko còn khả dụng\r\n };\r\n\r\n const handleCloseModalShouldReload = () => {\r\n localStorage.removeItem(CART_KEYS_MAP.VOUCHER_CART.LOCAL_STORAGE_KEY);\r\n setShowModalShouldReload(false);\r\n window.location.reload(); // ? may need to forceReload by using a form then follow the code below\r\n // const form = document.createElement('form');\r\n // form.method = \"POST\";\r\n // form.action = location.href;\r\n // document.body.appendChild(form);\r\n // form.submit();\r\n };\r\n\r\n const handleCloseModalRequireLogin = () => {\r\n setShowModalRequireLogin(false);\r\n };\r\n\r\n const handleDirectToLoginPage = () => {\r\n history.push(`/login`);\r\n };\r\n\r\n return (\r\n
\r\n \r\n\r\n
\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n
\r\n\r\n \r\n\r\n {voucherInfo && (\r\n \r\n )}\r\n\r\n
\r\n {voucherInfo && (\r\n <>\r\n {voucherInfo?.type?.[0] ===\r\n VOUCHER_TYPES.GEN_VOUCHER_WITH_AMOUNT ? (\r\n \r\n ) : (\r\n \r\n )}\r\n \r\n )}\r\n\r\n {voucherInfo && (\r\n \r\n )}\r\n\r\n {voucherInfo?.term?.vi && (\r\n \r\n )}\r\n\r\n {(voucherInfo?.location?.vi || voucherInfo?.location?.en) && (\r\n \r\n )}\r\n
\r\n\r\n 0 ||\r\n (userInfo && isLoading.CHECK_STOCK_OF_PRODUCT)\r\n }\r\n exchangeRate={voucherInfo?.currencies?.[0]?.exchangeRate}\r\n currency={voucherInfo?.currencies?.[0]?.name}\r\n totalPrice={totalPrice}\r\n itemsCount={selectedVoucherOptions.quantity}\r\n onClickButton={handleClickBtnBuyVoucher}\r\n />\r\n\r\n \r\n \r\n UTOP\r\n \r\n\r\n \r\n {isOverExpirationDate()\r\n ? \"Sản phẩm không khả dụng\"\r\n : \"Cảm ơn bạn. Hiện tại Voucher chưa khả dụng. Bạn quay trở lại sau nhé.\"}\r\n \r\n \r\n {location.state?.prevPathname !== \"/\" && (\r\n {\r\n history.push(\"/\");\r\n }}\r\n >\r\n Về trang chủ\r\n \r\n )}\r\n {location.state?.prevPathname && (\r\n \r\n Quay lại\r\n \r\n )}\r\n \r\n \r\n\r\n \r\n \r\n UTOP\r\n \r\n \r\n Dữ liệu lưu trong giỏ hàng cần được làm mới!\r\n \r\n \r\n \r\n Tải lại trang\r\n \r\n \r\n \r\n\r\n \r\n \r\n Bạn chưa đăng nhập!\r\n \r\n \r\n Vui lòng đăng nhập để sử dụng đầy đủ các tính năng của Utop nhé.\r\n \r\n \r\n \r\n Đồng ý\r\n \r\n \r\n \r\n
\r\n );\r\n}\r\n\r\nconst checkIfPriceOptionNotAvailable = (\r\n _outOfStockProductCodes,\r\n _currPriceOption\r\n) => {\r\n return _outOfStockProductCodes.find(\r\n (productCode) => productCode === _currPriceOption?.productCode\r\n );\r\n};\r\n\r\nexport default VoucherView;\r\n"],"sourceRoot":""}