@anker-in/campaign-ui 0.5.2 → 0.5.3-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/credits/context/const.js +1 -1
- package/dist/cjs/components/credits/context/const.js.map +2 -2
- package/dist/cjs/components/credits/context/utils.d.ts +1 -1
- package/dist/cjs/components/credits/context/utils.js +1 -1
- package/dist/cjs/components/credits/context/utils.js.map +3 -3
- package/dist/cjs/components/credits/creditsCash/RedeemableItem.js +1 -1
- package/dist/cjs/components/credits/creditsCash/RedeemableItem.js.map +2 -2
- package/dist/cjs/components/credits/creditsInfoCard/index.js +1 -1
- package/dist/cjs/components/credits/creditsInfoCard/index.js.map +3 -3
- package/dist/cjs/components/credits/creditsRedeemList/CreditsRedeemList.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/CreditsRedeemList.js.map +3 -3
- package/dist/cjs/components/credits/creditsRedeemList/RedeemCouponModal/CouponInit.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/RedeemCouponModal/CouponInit.js.map +3 -3
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Init.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Init.js.map +3 -3
- package/dist/cjs/components/credits/creditsRedeemList/RedeemVirtualProductModal/VirtualProductInit.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/RedeemVirtualProductModal/VirtualProductInit.js.map +3 -3
- package/dist/cjs/components/credits/creditsRedeemList/RedeemableItem.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/RedeemableItem.js.map +2 -2
- package/dist/cjs/components/credits/modal/ModalContainer.js +1 -1
- package/dist/cjs/components/credits/modal/ModalContainer.js.map +2 -2
- package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfileModal.d.ts +10 -0
- package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfileModal.js +2 -0
- package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfileModal.js.map +7 -0
- package/dist/esm/components/credits/context/const.js +1 -1
- package/dist/esm/components/credits/context/const.js.map +2 -2
- package/dist/esm/components/credits/context/utils.d.ts +1 -1
- package/dist/esm/components/credits/context/utils.js +1 -1
- package/dist/esm/components/credits/context/utils.js.map +3 -3
- package/dist/esm/components/credits/creditsCash/RedeemableItem.js +1 -1
- package/dist/esm/components/credits/creditsCash/RedeemableItem.js.map +2 -2
- package/dist/esm/components/credits/creditsInfoCard/index.js +1 -1
- package/dist/esm/components/credits/creditsInfoCard/index.js.map +3 -3
- package/dist/esm/components/credits/creditsRedeemList/CreditsRedeemList.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/CreditsRedeemList.js.map +3 -3
- package/dist/esm/components/credits/creditsRedeemList/RedeemCouponModal/CouponInit.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/RedeemCouponModal/CouponInit.js.map +3 -3
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Init.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Init.js.map +3 -3
- package/dist/esm/components/credits/creditsRedeemList/RedeemVirtualProductModal/VirtualProductInit.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/RedeemVirtualProductModal/VirtualProductInit.js.map +3 -3
- package/dist/esm/components/credits/creditsRedeemList/RedeemableItem.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/RedeemableItem.js.map +2 -2
- package/dist/esm/components/credits/modal/ModalContainer.js +1 -1
- package/dist/esm/components/credits/modal/ModalContainer.js.map +2 -2
- package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfileModal.d.ts +10 -0
- package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfileModal.js +2 -0
- package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfileModal.js.map +7 -0
- package/package.json +1 -1
- package/src/components/credits/context/const.ts +3 -0
- package/src/components/credits/context/utils.ts +15 -2
- package/src/components/credits/creditsCash/RedeemableItem.tsx +1 -1
- package/src/components/credits/creditsInfoCard/index.tsx +3 -3
- package/src/components/credits/creditsRedeemList/CreditsRedeemList.tsx +2 -2
- package/src/components/credits/creditsRedeemList/RedeemCouponModal/CouponInit.tsx +3 -1
- package/src/components/credits/creditsRedeemList/RedeemProductModal/Init.tsx +3 -1
- package/src/components/credits/creditsRedeemList/RedeemVirtualProductModal/VirtualProductInit.tsx +3 -1
- package/src/components/credits/creditsRedeemList/RedeemableItem.tsx +1 -1
- package/src/components/credits/modal/ModalContainer.tsx +1 -1
- package/dist/cjs/stories/CartCard.stories.d.ts +0 -33
- package/dist/cjs/stories/CartCard.stories.js +0 -21
- package/dist/cjs/stories/CartCard.stories.js.map +0 -7
- package/dist/esm/stories/CartCard.stories.d.ts +0 -33
- package/dist/esm/stories/CartCard.stories.js +0 -21
- package/dist/esm/stories/CartCard.stories.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/creditsRedeemList/RedeemProductModal/Init.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Button, Picture, Text } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport { Fragment, useMemo } from 'react'\nimport { numberFormat } from '../../context/utils'\nimport type { RedeemableItem as RedeemableItemType, RedeemModalCommon } from '../../type'\nimport { ConsumeType } from '../../context/const'\nimport { NoneProductValue } from './NonProductValue'\nimport { useCreditsContext } from '../../context/provider'\n\ntype InitProps = {\n copy: RedeemModalCommon\n item: RedeemableItemType\n loading: boolean\n disabled: boolean\n setStatus: (status: 'address' | 'init' | 'success' | 'error') => void\n}\n\nexport const Init = ({ copy, item, loading, disabled, setStatus }: InitProps) => {\n const { pageCommon } = useCreditsContext()\n const rules = useMemo(() => {\n if (item.config.rules?.length) {\n return item.config.rules\n }\n const descriptions = item.config.desc?.split('<br>') || []\n return [...descriptions, ...(copy.product.rules || [])]\n }, [item.config.rules, item.config.desc, copy.product.rules])\n\n return (\n <div className=\"flex flex-col\">\n <div\n className={classNames(\n 'max-h-[500px] overflow-y-auto bg-[#F5F5F7] px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]'\n )}\n >\n <>\n <div className=\"relative mx-auto h-[164px] w-fit\">\n <Picture\n source={\n item.config?.type === ConsumeType.Product\n ? item.product?.images[0]?.url\n : pageCommon?.imageMapping?.[item.config.type]?.url || item.config.image?.url\n }\n className=\"h-full w-auto [&_img]:h-full [&_img]:w-auto [&_img]:object-contain\"\n ></Picture>\n {/* \u793C\u54C1\u5361\u5C55\u793A */}\n <div className=\"absolute bottom-[8px] left-[16px] font-extrabold text-white\">\n {item.config.value && <NoneProductValue item={item} />}\n </div>\n </div>\n <div className=\"mt-[30px] md:mt-[18px]\">\n {item.config.type === 'product' && (\n <div\n className={classNames(\n 'mb-[4px] text-center text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]'\n )}\n >\n {item.config.title}\n </div>\n )}\n <Text\n as=\"p\"\n className={classNames(' text-center text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]')}\n >\n {numberFormat(item.alpc?.consumeCredits)} {pageCommon?.pointUnit}\n </Text>\n </div>\n <div className=\"mt-[16px] w-full text-[14px] font-semibold text-[#777] md:mt-[12px]\">\n <div className=\"text-[16px] font-bold leading-[1.4]\">{copy.product.stepTitle}</div>\n <div className=\"mt-[4px] flex items-center justify-center\">\n {copy.product.steps?.map((item, index) => (\n <Fragment key={index}>\n <div className=\"flex w-[76px] flex-col items-center text-center md:h-[94px] min-l:w-[130px]\">\n <Picture source={item.imageUrl} className=\"mb-[4px] h-[58px] w-[58px]\"></Picture>\n <div className=\"min-h-[34px] text-[14px] font-bold text-[#777] md:min-h-[28px] md:text-[12px]\">\n {item.title}\n </div>\n </div>\n {index !== copy.product.steps.length - 1 && (\n <Picture\n source=\"https://cdn.shopify.com/s/files/1/0517/6767/3016/files/step-arrow.png?v=1690458150\"\n className=\"mb-[20px] h-[10px] w-[20px] md:mb-[30px] md:h-[5px] md:w-[12px]\"\n ></Picture>\n )}\n </Fragment>\n ))}\n </div>\n <div className=\"overflow-auto\">\n {rules?.length && (\n <ul className=\"ml-[18px] mt-[16px] grid grid-flow-row gap-[4px] text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px]\">\n {rules.map((text, index) => (\n <li className=\"list-disc\" key={index}>\n <Text as=\"div\" html={text} className=\"font-bold\" />\n </li>\n ))}\n </ul>\n )}\n </div>\n </div>\n </>\n </div>\n <div className=\"flex-1 bg-white px-[48px] py-[24px] text-center md:px-[16px]\">\n <Text\n as=\"p\"\n className=\"block text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]\"\n html={copy.confirmTitle}\n ></Text>\n <Button\n loading={loading}\n disabled={disabled}\n variant=\"primary\"\n size=\"lg\"\n className=\"mt-[16px] w-full md:mt-[12px]\"\n onClick={() => {\n setStatus('address')\n }}\n >\n {copy.confirmButton}\n </Button>\n </div>\n </div>\n )\n}\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,UAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["Init_exports", "__export", "Init", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_classnames", "import_react", "import_utils", "import_const", "import_NonProductValue", "import_provider", "copy", "item", "loading", "disabled", "setStatus", "pageCommon", "rules", "classNames", "index", "text"]
|
|
4
|
+
"sourcesContent": ["import { Button, Picture, Text } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport { Fragment, useMemo } from 'react'\nimport { numberFormat } from '../../context/utils'\nimport type { RedeemableItem as RedeemableItemType, RedeemModalCommon } from '../../type'\nimport { ConsumeType } from '../../context/const'\nimport { NoneProductValue } from './NonProductValue'\nimport { useCreditsContext } from '../../context/provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\ntype InitProps = {\n copy: RedeemModalCommon\n item: RedeemableItemType\n loading: boolean\n disabled: boolean\n setStatus: (status: 'address' | 'init' | 'success' | 'error') => void\n}\n\nexport const Init = ({ copy, item, loading, disabled, setStatus }: InitProps) => {\n const { pageCommon } = useCreditsContext()\n const { locale } = useHeadlessContext()\n const rules = useMemo(() => {\n if (item.config.rules?.length) {\n return item.config.rules\n }\n const descriptions = item.config.desc?.split('<br>') || []\n return [...descriptions, ...(copy.product.rules || [])]\n }, [item.config.rules, item.config.desc, copy.product.rules])\n\n return (\n <div className=\"flex flex-col\">\n <div\n className={classNames(\n 'max-h-[500px] overflow-y-auto bg-[#F5F5F7] px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]'\n )}\n >\n <>\n <div className=\"relative mx-auto h-[164px] w-fit\">\n <Picture\n source={\n item.config?.type === ConsumeType.Product\n ? item.product?.images[0]?.url\n : pageCommon?.imageMapping?.[item.config.type]?.url || item.config.image?.url\n }\n className=\"h-full w-auto [&_img]:h-full [&_img]:w-auto [&_img]:object-contain\"\n ></Picture>\n {/* \u793C\u54C1\u5361\u5C55\u793A */}\n <div className=\"absolute bottom-[8px] left-[16px] font-extrabold text-white\">\n {item.config.value && <NoneProductValue item={item} />}\n </div>\n </div>\n <div className=\"mt-[30px] md:mt-[18px]\">\n {item.config.type === 'product' && (\n <div\n className={classNames(\n 'mb-[4px] text-center text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]'\n )}\n >\n {item.config.title}\n </div>\n )}\n <Text\n as=\"p\"\n className={classNames(' text-center text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]')}\n >\n {numberFormat(item.alpc?.consumeCredits, locale)} {pageCommon?.pointUnit}\n </Text>\n </div>\n <div className=\"mt-[16px] w-full text-[14px] font-semibold text-[#777] md:mt-[12px]\">\n <div className=\"text-[16px] font-bold leading-[1.4]\">{copy.product.stepTitle}</div>\n <div className=\"mt-[4px] flex items-center justify-center\">\n {copy.product.steps?.map((item, index) => (\n <Fragment key={index}>\n <div className=\"flex w-[76px] flex-col items-center text-center md:h-[94px] min-l:w-[130px]\">\n <Picture source={item.imageUrl} className=\"mb-[4px] h-[58px] w-[58px]\"></Picture>\n <div className=\"min-h-[34px] text-[14px] font-bold text-[#777] md:min-h-[28px] md:text-[12px]\">\n {item.title}\n </div>\n </div>\n {index !== copy.product.steps.length - 1 && (\n <Picture\n source=\"https://cdn.shopify.com/s/files/1/0517/6767/3016/files/step-arrow.png?v=1690458150\"\n className=\"mb-[20px] h-[10px] w-[20px] md:mb-[30px] md:h-[5px] md:w-[12px]\"\n ></Picture>\n )}\n </Fragment>\n ))}\n </div>\n <div className=\"overflow-auto\">\n {rules?.length && (\n <ul className=\"ml-[18px] mt-[16px] grid grid-flow-row gap-[4px] text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px]\">\n {rules.map((text, index) => (\n <li className=\"list-disc\" key={index}>\n <Text as=\"div\" html={text} className=\"font-bold\" />\n </li>\n ))}\n </ul>\n )}\n </div>\n </div>\n </>\n </div>\n <div className=\"flex-1 bg-white px-[48px] py-[24px] text-center md:px-[16px]\">\n <Text\n as=\"p\"\n className=\"block text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]\"\n html={copy.confirmTitle}\n ></Text>\n <Button\n loading={loading}\n disabled={disabled}\n variant=\"primary\"\n size=\"lg\"\n className=\"mt-[16px] w-full md:mt-[12px]\"\n onClick={() => {\n setStatus('address')\n }}\n >\n {copy.confirmButton}\n </Button>\n </div>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,UAAAE,IAAA,eAAAC,EAAAH,GAoCQ,IAAAI,EAAA,6BApCRC,EAAsC,iCACtCC,EAAuB,yBACvBC,EAAkC,iBAClCC,EAA6B,+BAE7BC,EAA4B,+BAC5BC,EAAiC,6BACjCC,EAAkC,kCAClCC,EAAmC,yBAU5B,MAAMV,EAAO,CAAC,CAAE,KAAAW,EAAM,KAAAC,EAAM,QAAAC,EAAS,SAAAC,EAAU,UAAAC,CAAU,IAAiB,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UAAU,gFACZ,SAAAA,EAAK,MACR,GACF,EACCQ,IAAUT,EAAK,QAAQ,MAAM,OAAS,MACrC,OAAC,WACC,OAAO,qFACP,UAAU,kEACX,IAXUS,CAaf,CACD,EACH,KACA,OAAC,OAAI,UAAU,gBACZ,SAAAF,GAAO,WACN,OAAC,MAAG,UAAU,mHACX,SAAAA,EAAM,IAAI,CAACG,EAAMD,OAChB,OAAC,MAAG,UAAU,YACZ,mBAAC,QAAK,GAAG,MAAM,KAAMC,EAAM,UAAU,YAAY,GADpBD,CAE/B,CACD,EACH,EAEJ,GACF,GACF,EACF,KACA,QAAC,OAAI,UAAU,+DACb,oBAAC,QACC,GAAG,IACH,UAAU,4EACV,KAAMT,EAAK,aACZ,KACD,OAAC,UACC,QAASE,EACT,SAAUC,EACV,QAAQ,UACR,KAAK,KACL,UAAU,gCACV,QAAS,IAAM,CACbC,EAAU,SAAS,CACrB,EAEC,SAAAJ,EAAK,cACR,GACF,GACF,CAEJ",
|
|
6
|
+
"names": ["Init_exports", "__export", "Init", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_classnames", "import_react", "import_utils", "import_const", "import_NonProductValue", "import_provider", "import_lib", "copy", "item", "loading", "disabled", "setStatus", "pageCommon", "locale", "rules", "classNames", "index", "text"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var h=Object.create;var x=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var y=(e,l)=>{for(var a in l)x(e,a,{get:l[a],enumerable:!0})},n=(e,l,a,o)=>{if(l&&typeof l=="object"||typeof l=="function")for(let i of w(l))!C.call(e,i)&&i!==a&&x(e,i,{get:()=>l[i],enumerable:!(o=N(l,i))||o.enumerable});return e};var F=(e,l,a)=>(a=e!=null?h(P(e)):{},n(l||!e||!e.__esModule?x(a,"default",{value:e,enumerable:!0}):a,e)),T=e=>n(x({},"__esModule",{value:!0}),e);var R={};y(R,{VirtualProductInit:()=>I});module.exports=T(R);var t=require("react/jsx-runtime"),m=require("@anker-in/headless-ui"),r=F(require("classnames")),c=require("react"),u=require("../../context/utils"),f=require("../RedeemProductModal/NonProductValue"),v=require("../../context/provider"),g=require("@anker-in/lib");const I=({item:e,copy:l,loading:a,disabled:o,onConfirm:i})=>{const{pageCommon:p}=(0,v.useCreditsContext)(),{locale:b}=(0,g.useHeadlessContext)();return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:(0,r.default)("max-h-[500px] overflow-y-auto bg-[#F5F5F7] px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]"),children:[(0,t.jsxs)("div",{className:"relative mx-auto h-[164px] w-[324px]",children:[p?.imageMapping?.[e.config?.type]?.url&&(0,t.jsx)(m.Picture,{source:p.imageMapping[e.config.type].url,className:"h-full [&_img]:h-full"}),(0,t.jsx)("div",{className:"absolute bottom-[8px] left-[16px] font-extrabold text-white",children:e.config.value?(0,t.jsx)(f.NoneProductValue,{item:e}):(0,t.jsx)(m.Text,{size:3,html:e.alpc?.title})})]}),(0,t.jsxs)(m.Text,{as:"p",className:(0,r.default)("mt-[30px] text-center text-[24px] font-bold leading-[1.2] md:mt-[18px] md:text-[20px] md:leading-[1.2]"),children:[(0,u.numberFormat)(e.alpc?.consumeCredits,b)," ",p?.pointUnit]}),l?.virtualProduct?.steps&&l.virtualProduct.steps.length>0&&(0,t.jsxs)("div",{className:"mt-[16px] w-full text-[14px] font-semibold text-[#777] md:mt-[12px]",children:[(0,t.jsx)("div",{className:"text-[16px] font-bold leading-[1.4]",children:l.virtualProduct.stepTitle}),(0,t.jsx)("div",{className:"mt-[4px] flex items-center justify-center",children:l.virtualProduct.steps.map((s,d)=>(0,t.jsxs)(c.Fragment,{children:[(0,t.jsxs)("div",{className:"flex w-[76px] flex-col items-center text-center md:h-[94px] min-l:w-[130px]",children:[(0,t.jsx)(m.Picture,{source:s.imageUrl,className:"mb-[4px] h-[58px] w-[58px]"}),(0,t.jsx)("div",{className:"min-h-[34px] text-[14px] font-bold text-[#777] md:min-h-[28px] md:text-[12px]",children:s.title})]}),d!==l.virtualProduct.steps.length-1&&(0,t.jsx)(m.Picture,{source:"https://cdn.shopify.com/s/files/1/0517/6767/3016/files/step-arrow.png?v=1690458150",className:"mb-[20px] h-[10px] w-[20px] md:mb-[30px] md:h-[5px] md:w-[12px]"})]},d))})]}),e.config?.rules?.length>0&&(0,t.jsxs)("div",{className:"mt-[18px] w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]",children:[(0,t.jsxs)("div",{className:"mb-[4px]",children:[p?.ruleLabel,":"]}),(0,t.jsx)("ul",{className:"ml-4 grid grid-flow-row gap-[4px]",children:e.config?.rules?.map((s,d)=>(0,t.jsx)("li",{className:"list-disc",children:(0,t.jsx)(m.Text,{html:s})},d))})]})]}),(0,t.jsxs)("div",{className:"bg-white px-[48px] pt-[24px] text-center md:px-[16px]",children:[(0,t.jsx)(m.Text,{className:"block text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]",html:l.confirmTitle}),(0,t.jsx)(m.Button,{loading:a,variant:"primary",size:"lg",className:"mt-[16px] w-full",onClick:i,disabled:o,children:l.confirmButton})]})]})};
|
|
2
2
|
//# sourceMappingURL=VirtualProductInit.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/creditsRedeemList/RedeemVirtualProductModal/VirtualProductInit.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Button, Picture, Text } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport { Fragment } from 'react'\nimport { numberFormat } from '../../context/utils'\nimport type { RedeemableItem as RedeemableItemType, RedeemModalCommon } from '../../type'\nimport { NoneProductValue } from '../RedeemProductModal/NonProductValue'\nimport { useCreditsContext } from '../../context/provider'\n\ntype VirtualProductInitProps = {\n item: RedeemableItemType\n copy: RedeemModalCommon\n loading: boolean\n disabled: boolean\n onConfirm: () => void\n}\n\nexport const VirtualProductInit = ({ item, copy, loading, disabled, onConfirm }: VirtualProductInitProps) => {\n const { pageCommon } = useCreditsContext()\n\n return (\n <>\n <div\n className={classNames(\n 'max-h-[500px] overflow-y-auto bg-[#F5F5F7] px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]'\n )}\n >\n <div className=\"relative mx-auto h-[164px] w-[324px]\">\n {pageCommon?.imageMapping?.[item.config?.type]?.url && (\n <Picture source={pageCommon.imageMapping[item.config.type].url} className=\"h-full [&_img]:h-full\" />\n )}\n <div className=\"absolute bottom-[8px] left-[16px] font-extrabold text-white\">\n {item.config.value ? (\n <NoneProductValue item={item} />\n ) : (\n <Text size={3} html={item.alpc?.title} />\n )}\n </div>\n </div>\n <Text\n as=\"p\"\n className={classNames(\n 'mt-[30px] text-center text-[24px] font-bold leading-[1.2] md:mt-[18px] md:text-[20px] md:leading-[1.2]'\n )}\n >\n {numberFormat(item.alpc?.consumeCredits)} {pageCommon?.pointUnit}\n </Text>\n {copy?.virtualProduct?.steps && copy.virtualProduct.steps.length > 0 && (\n <div className=\"mt-[16px] w-full text-[14px] font-semibold text-[#777] md:mt-[12px]\">\n <div className=\"text-[16px] font-bold leading-[1.4]\">{copy.virtualProduct.stepTitle}</div>\n <div className=\"mt-[4px] flex items-center justify-center\">\n {copy.virtualProduct.steps.map((step, index) => (\n <Fragment key={index}>\n <div className=\"flex w-[76px] flex-col items-center text-center md:h-[94px] min-l:w-[130px]\">\n <Picture source={step.imageUrl} className=\"mb-[4px] h-[58px] w-[58px]\"></Picture>\n <div className=\"min-h-[34px] text-[14px] font-bold text-[#777] md:min-h-[28px] md:text-[12px]\">\n {step.title}\n </div>\n </div>\n {index !== copy.virtualProduct.steps!.length - 1 && (\n <Picture\n source=\"https://cdn.shopify.com/s/files/1/0517/6767/3016/files/step-arrow.png?v=1690458150\"\n className=\"mb-[20px] h-[10px] w-[20px] md:mb-[30px] md:h-[5px] md:w-[12px]\"\n ></Picture>\n )}\n </Fragment>\n ))}\n </div>\n </div>\n )}\n {item.config?.rules?.length > 0 && (\n <div className=\"mt-[18px] w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]\">\n <div className=\"mb-[4px]\">{pageCommon?.ruleLabel}:</div>\n <ul className=\"ml-4 grid grid-flow-row gap-[4px]\">\n {item.config?.rules?.map((text, index) => (\n <li className=\"list-disc\" key={index}>\n <Text html={text} />\n </li>\n ))}\n </ul>\n </div>\n )}\n </div>\n <div className=\"bg-white px-[48px] pt-[24px] text-center md:px-[16px]\">\n <Text\n className=\"block text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]\"\n html={copy.confirmTitle}\n ></Text>\n <Button\n loading={loading}\n variant=\"primary\"\n size=\"lg\"\n className=\"mt-[16px] w-full\"\n onClick={onConfirm}\n disabled={disabled}\n >\n {copy.confirmButton}\n </Button>\n </div>\n </>\n )\n}\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["VirtualProductInit_exports", "__export", "VirtualProductInit", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_classnames", "import_react", "import_utils", "import_NonProductValue", "import_provider", "item", "copy", "loading", "disabled", "onConfirm", "pageCommon", "classNames", "step", "index", "text"]
|
|
4
|
+
"sourcesContent": ["import { Button, Picture, Text } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport { Fragment } from 'react'\nimport { numberFormat } from '../../context/utils'\nimport type { RedeemableItem as RedeemableItemType, RedeemModalCommon } from '../../type'\nimport { NoneProductValue } from '../RedeemProductModal/NonProductValue'\nimport { useCreditsContext } from '../../context/provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\ntype VirtualProductInitProps = {\n item: RedeemableItemType\n copy: RedeemModalCommon\n loading: boolean\n disabled: boolean\n onConfirm: () => void\n}\n\nexport const VirtualProductInit = ({ item, copy, loading, disabled, onConfirm }: VirtualProductInitProps) => {\n const { pageCommon } = useCreditsContext()\n const { locale } = useHeadlessContext()\n\n return (\n <>\n <div\n className={classNames(\n 'max-h-[500px] overflow-y-auto bg-[#F5F5F7] px-[48px] pb-[24px] md:max-h-[400px] md:px-[16px]'\n )}\n >\n <div className=\"relative mx-auto h-[164px] w-[324px]\">\n {pageCommon?.imageMapping?.[item.config?.type]?.url && (\n <Picture source={pageCommon.imageMapping[item.config.type].url} className=\"h-full [&_img]:h-full\" />\n )}\n <div className=\"absolute bottom-[8px] left-[16px] font-extrabold text-white\">\n {item.config.value ? (\n <NoneProductValue item={item} />\n ) : (\n <Text size={3} html={item.alpc?.title} />\n )}\n </div>\n </div>\n <Text\n as=\"p\"\n className={classNames(\n 'mt-[30px] text-center text-[24px] font-bold leading-[1.2] md:mt-[18px] md:text-[20px] md:leading-[1.2]'\n )}\n >\n {numberFormat(item.alpc?.consumeCredits, locale)} {pageCommon?.pointUnit}\n </Text>\n {copy?.virtualProduct?.steps && copy.virtualProduct.steps.length > 0 && (\n <div className=\"mt-[16px] w-full text-[14px] font-semibold text-[#777] md:mt-[12px]\">\n <div className=\"text-[16px] font-bold leading-[1.4]\">{copy.virtualProduct.stepTitle}</div>\n <div className=\"mt-[4px] flex items-center justify-center\">\n {copy.virtualProduct.steps.map((step, index) => (\n <Fragment key={index}>\n <div className=\"flex w-[76px] flex-col items-center text-center md:h-[94px] min-l:w-[130px]\">\n <Picture source={step.imageUrl} className=\"mb-[4px] h-[58px] w-[58px]\"></Picture>\n <div className=\"min-h-[34px] text-[14px] font-bold text-[#777] md:min-h-[28px] md:text-[12px]\">\n {step.title}\n </div>\n </div>\n {index !== copy.virtualProduct.steps!.length - 1 && (\n <Picture\n source=\"https://cdn.shopify.com/s/files/1/0517/6767/3016/files/step-arrow.png?v=1690458150\"\n className=\"mb-[20px] h-[10px] w-[20px] md:mb-[30px] md:h-[5px] md:w-[12px]\"\n ></Picture>\n )}\n </Fragment>\n ))}\n </div>\n </div>\n )}\n {item.config?.rules?.length > 0 && (\n <div className=\"mt-[18px] w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]\">\n <div className=\"mb-[4px]\">{pageCommon?.ruleLabel}:</div>\n <ul className=\"ml-4 grid grid-flow-row gap-[4px]\">\n {item.config?.rules?.map((text, index) => (\n <li className=\"list-disc\" key={index}>\n <Text html={text} />\n </li>\n ))}\n </ul>\n </div>\n )}\n </div>\n <div className=\"bg-white px-[48px] pt-[24px] text-center md:px-[16px]\">\n <Text\n className=\"block text-[24px] font-bold leading-[1.2] md:text-[20px] md:leading-[1.2]\"\n html={copy.confirmTitle}\n ></Text>\n <Button\n loading={loading}\n variant=\"primary\"\n size=\"lg\"\n className=\"mt-[16px] w-full\"\n onClick={onConfirm}\n disabled={disabled}\n >\n {copy.confirmButton}\n </Button>\n </div>\n </>\n )\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,IAAA,eAAAC,EAAAH,GAsBI,IAAAI,EAAA,6BAtBJC,EAAsC,iCACtCC,EAAuB,yBACvBC,EAAyB,iBACzBC,EAA6B,+BAE7BC,EAAiC,iDACjCC,EAAkC,kCAClCC,EAAmC,yBAU5B,MAAMT,EAAqB,CAAC,CAAE,KAAAU,EAAM,KAAAC,EAAM,QAAAC,EAAS,SAAAC,EAAU,UAAAC,CAAU,IAA+B,CAC3G,KAAM,CAAE,WAAAC,CAAW,KAAI,qBAAkB,EACnC,CAAE,OAAAC,CAAO,KAAI,sBAAmB,EAEtC,SACE,oBACE,qBAAC,OACC,aAAW,EAAAC,SACT,8FACF,EAEA,qBAAC,OAAI,UAAU,uCACZ,UAAAF,GAAY,eAAeL,EAAK,QAAQ,IAAI,GAAG,QAC9C,OAAC,WAAQ,OAAQK,EAAW,aAAaL,EAAK,OAAO,IAAI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",
|
|
6
|
+
"names": ["VirtualProductInit_exports", "__export", "VirtualProductInit", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_classnames", "import_react", "import_utils", "import_NonProductValue", "import_provider", "import_lib", "item", "copy", "loading", "disabled", "onConfirm", "pageCommon", "locale", "classNames", "step", "index", "text"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var k=Object.create;var
|
|
1
|
+
"use strict";var k=Object.create;var v=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var D=(t,l)=>{for(var e in l)v(t,e,{get:l[e],enumerable:!0})},N=(t,l,e,m)=>{if(l&&typeof l=="object"||typeof l=="function")for(let r of z(l))!L.call(t,r)&&r!==e&&v(t,r,{get:()=>l[r],enumerable:!(m=S(l,r))||m.enumerable});return t};var O=(t,l,e)=>(e=t!=null?k(E(t)):{},N(l||!t||!t.__esModule?v(e,"default",{value:t,enumerable:!0}):e,t)),F=t=>N(v({},"__esModule",{value:!0}),t);var B={};D(B,{RedeemableItem:()=>A});module.exports=F(B);var a=require("react/jsx-runtime"),n=require("@anker-in/headless-ui"),g=require("react"),b=O(require("classnames")),R=require("../context/provider"),i=require("../context/const"),c=require("../context/utils"),u=require("@anker-in/lib"),C=require("./NonProductValue"),T=require("../../../constants");function A({copy:t,className:l,item:e,onRulesOpen:m,onRedeem:r}){const{creditInfo:h,profile:p,gtm:{pageGroup:y,pageHandle:s},pageCommon:d}=(0,R.useCreditsContext)(),{brand:$,locale:x}=(0,u.useHeadlessContext)(),f=Object.keys(p||{}).length>0,w=T.ROUNDED_BRANDS.includes($),I=(0,g.useMemo)(()=>!!(e.hasRedeemed||e.alpc?.remainingInventory<=0&&e.alpc?.isLimited||e.alpc?.consumeType===i.AlpcConsumeType.Product&&!e.variant?.availableForSale||f&&p?.activated&&e.alpc?.consumeCredits>Number(h?.available_credit||0)),[e.hasRedeemed,e.alpc?.remainingInventory,e.alpc?.isLimited,e.alpc?.consumeType,e.alpc?.consumeCredits,f,p?.activated,h?.available_credit,e.variant?.availableForSale]),_=(0,g.useMemo)(()=>f?e.alpc?.consumeType===i.AlpcConsumeType.Product?e.variant?.availableForSale?t.btnRedeem:d?.soldOut||"Sold Out":t.btnRedeem:t.unlockRewards,[f,e.alpc?.consumeType,e.variant?.availableForSale,t.btnRedeem,t.unlockRewards,d?.soldOut]),P=(0,g.useMemo)(()=>{if(e.config?.type!==i.ConsumeType.Product||!e.product?.handle)return;const o=x==="us"?"":`/${x}`;return(0,c.extractVariantId)(e.variant?.id)?`${o}/products/${e.product.handle}?variant=${(0,c.extractVariantId)(e.variant?.id)}${s?`&ref=${s}`:""}`:`${o}/products/${e.product.handle}${s?`?ref=${s}`:""}`},[e.config?.type,e.product?.handle,e.variant?.id,s,x]);return(0,a.jsxs)("div",{className:(0,b.default)("flex flex-col items-center rounded-[16px] bg-[#EAEAEC] p-[24px] md:rounded-[12px] md:px-[8px] xl:py-[16px] md-xl:px-[16px]",!w&&"rounded-none md:rounded-none",l),children:[e.config?.type===i.ConsumeType.Product?(0,a.jsx)("a",{href:P,className:(0,b.default)("relative mx-auto h-[224px] w-fit md:my-[10px] l:h-[120px] l-xxl:h-[138px]"),children:(0,a.jsx)(n.Picture,{className:"h-full w-auto [&_img]:h-full [&_img]:object-contain",source:e.config?.image?.url||e.product?.images?.[0]?.url})}):(0,a.jsxs)("div",{className:"relative mx-auto my-[30px] h-[164px] md:my-0 md:h-[66px] l-xxl:h-[138px] md-l:h-[80px]",children:[(0,a.jsx)(n.Picture,{source:d?.imageMapping?.[e.config?.type]?.url,className:"h-full [&_img]:h-full [&_img]:w-auto [&_img]:object-contain"}),(0,a.jsx)(C.NoneProductValue,{item:e})]}),(0,a.jsxs)("div",{className:(0,b.default)("mt-[10px] xl:mt-[8px] flex w-full flex-1 flex-col justify-between"),children:[(0,a.jsx)(n.Text,{html:e.config?.title||e.alpc?.title,title:e.config?.title||e.alpc?.title,size:2,className:"line-clamp-2 h-[58px] text-[24px] leading-[1.2] l:h-[40px] l:text-[16px] l-xxl:h-[48px] l-xxl:text-[20px]"}),e.config?.rules?.length>0&&(0,a.jsx)("button",{type:"button",onClick:()=>{m(e.config?.rules||[]),(0,u.gaTrack)({event:"ga4Event",event_name:"lp_button",member_active_status:p?.activated?"active":"not active",event_parameters:{page_group:y,position:t.title,button_name:d?.ruleLabel,info:e.alpc?.id?.toString()}})},className:"mt-[8px] w-fit text-[16px] font-bold underline md:text-[14px] l:mt-0",tabIndex:0,onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&o.preventDefault()},children:d?.ruleLabel}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"mt-[26px] flex items-center l:mt-[12px] l-xl:mt-[16px]",children:[(0,a.jsx)(n.Picture,{className:"size-[24px] l-xxl:size-[22px] md-l:size-[18px] md:size-[16px]",source:"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/icon_hire_purchase.png?v=1757496783"}),(0,a.jsx)(n.Text,{html:`${(0,c.numberFormat)(e.alpc?.consumeCredits,x)}`,size:2,as:"p",className:"ml-[4px] text-[24px] font-bold mt-[4px] leading-none l-xxl:text-[20px] l:text-[16px] "})]}),(0,a.jsx)(n.Button,{disabled:I,variant:"primary",size:"lg",className:"mt-[8px] md:px-[8px] l:w-full",onClick:()=>{r(e),(0,u.gaTrack)({event:"ga4Event",event_name:"lp_button",member_active_status:p?.activated?"active":"not active",event_parameters:{page_group:y,position:t.title,button_name:_,info:e.alpc?.id?.toString()}})},children:_})]})]})]})}
|
|
2
2
|
//# sourceMappingURL=RedeemableItem.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/components/credits/creditsRedeemList/RedeemableItem.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Button, Text, Picture } from '@anker-in/headless-ui'\n\nimport { useMemo } from 'react'\n\nimport classNames from 'classnames'\nimport { useCreditsContext } from '../context/provider'\nimport type { RedeemableItem as RedeemableItemType } from '../type'\nimport { AlpcConsumeType, ConsumeType } from '../context/const'\nimport { numberFormat, extractVariantId } from '../context/utils'\nimport type { CreditsRedeemListCopy } from './type'\nimport { gaTrack, useHeadlessContext } from '@anker-in/lib'\nimport { NoneProductValue } from './NonProductValue'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\nexport function RedeemableItem({\n copy,\n className,\n item,\n onRulesOpen,\n onRedeem,\n}: {\n copy: CreditsRedeemListCopy\n className?: string\n item: RedeemableItemType\n onRulesOpen: (rules: string[]) => void\n onRedeem: (item: RedeemableItemType) => void\n}) {\n const {\n creditInfo,\n profile,\n gtm: { pageGroup, pageHandle },\n pageCommon,\n } = useCreditsContext()\n const { brand, locale } = useHeadlessContext()\n const isLogin = Object.keys(profile || {}).length > 0\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const isDisabled = useMemo(() => {\n if (item.hasRedeemed) {\n return true\n }\n\n if (item.alpc?.remainingInventory <= 0 && item.alpc?.isLimited) {\n // \u6709\u5E93\u5B58\u9650\u5236\n return true\n }\n\n if (item.alpc?.consumeType === AlpcConsumeType.Product) {\n if (!item.variant?.availableForSale) {\n return true\n }\n }\n if (isLogin && profile?.activated && item.alpc?.consumeCredits > Number(creditInfo?.available_credit || 0)) {\n return true\n }\n return false\n }, [\n item.hasRedeemed,\n item.alpc?.remainingInventory,\n item.alpc?.isLimited,\n item.alpc?.consumeType,\n item.alpc?.consumeCredits,\n isLogin,\n profile?.activated,\n creditInfo?.available_credit,\n item.variant?.availableForSale,\n ])\n\n const redeemButtonText = useMemo(() => {\n if (!isLogin) {\n return copy.unlockRewards\n }\n\n // \u7F3A\u8D27\u6587\u6848\n if (item.alpc?.consumeType === AlpcConsumeType.Product) {\n return item.variant?.availableForSale ? copy.btnRedeem : pageCommon?.soldOut || 'Sold Out'\n }\n return copy.btnRedeem\n }, [\n isLogin,\n item.alpc?.consumeType,\n item.variant?.availableForSale,\n copy.btnRedeem,\n copy.unlockRewards,\n pageCommon?.soldOut,\n ])\n\n // \u751F\u6210\u4EA7\u54C1 listing \u9875\u9762\u94FE\u63A5\n const productUrl = useMemo(() => {\n if (item.config?.type !== ConsumeType.Product || !item.product?.handle) {\n return undefined\n }\n const localePrefix = locale === 'us' ? '' : `/${locale}`\n return extractVariantId(item.variant?.id)\n ? `${localePrefix}/products/${item.product.handle}?variant=${extractVariantId(item.variant?.id)}${pageHandle ? `&ref=${pageHandle}` : ''}`\n : `${localePrefix}/products/${item.product.handle}${pageHandle ? `?ref=${pageHandle}` : ''}`\n }, [item.config?.type, item.product?.handle, item.variant?.id, pageHandle, locale])\n\n return (\n <div\n className={classNames(\n 'flex flex-col items-center rounded-[16px] bg-[#EAEAEC] p-[24px] md:rounded-[12px] md:px-[8px] xl:py-[16px] md-xl:px-[16px]',\n !rounded && 'rounded-none md:rounded-none',\n className\n )}\n >\n {item.config?.type === ConsumeType.Product ? (\n <a\n href={productUrl}\n className={classNames('relative mx-auto h-[224px] w-fit md:my-[10px] l:h-[120px] l-xxl:h-[138px]')}\n >\n <Picture\n className=\"h-full w-auto [&_img]:h-full [&_img]:object-contain\"\n source={item.config?.image?.url || item.product?.images?.[0]?.url}\n ></Picture>\n </a>\n ) : (\n <div className=\"relative mx-auto my-[30px] h-[164px] md:my-0 md:h-[66px] l-xxl:h-[138px] md-l:h-[80px]\">\n <Picture\n source={pageCommon?.imageMapping?.[item.config?.type]?.url}\n className=\"h-full [&_img]:h-full [&_img]:w-auto [&_img]:object-contain\"\n ></Picture>\n\n <NoneProductValue item={item} />\n </div>\n )}\n <div className={classNames('mt-[10px] xl:mt-[8px] flex w-full flex-1 flex-col justify-between')}>\n <Text\n html={item.config?.title || item.alpc?.title}\n title={item.config?.title || item.alpc?.title}\n size={2}\n className=\"line-clamp-2 h-[58px] text-[24px] leading-[1.2] l:h-[40px] l:text-[16px] l-xxl:h-[48px] l-xxl:text-[20px]\"\n />\n {item.config?.rules?.length > 0 && (\n <button\n type=\"button\"\n onClick={() => {\n onRulesOpen(item.config?.rules || [])\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: pageGroup,\n position: copy.title,\n button_name: pageCommon?.ruleLabel,\n info: item.alpc?.id?.toString(),\n },\n })\n }}\n className=\"mt-[8px] w-fit text-[16px] font-bold underline md:text-[14px] l:mt-0\"\n tabIndex={0}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n }\n }}\n >\n {pageCommon?.ruleLabel}\n </button>\n )}\n <div>\n <div className=\"mt-[26px] flex items-center l:mt-[12px] l-xl:mt-[16px]\">\n <Picture\n className=\"size-[24px] l-xxl:size-[22px] md-l:size-[18px] md:size-[16px]\"\n source=\"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/icon_hire_purchase.png?v=1757496783\"\n />\n <Text\n html={`${numberFormat(item.alpc?.consumeCredits)}`}\n size={2}\n as=\"p\"\n className=\"ml-[4px] text-[24px] font-bold mt-[4px] leading-none l-xxl:text-[20px] l:text-[16px] \"\n />\n </div>\n\n <Button\n disabled={isDisabled}\n variant=\"primary\"\n size=\"lg\"\n className=\"mt-[8px] md:px-[8px] l:w-full\"\n onClick={() => {\n onRedeem(item)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: pageGroup,\n position: copy.title,\n button_name: redeemButtonText,\n info: item.alpc?.id?.toString(),\n },\n })\n }}\n >\n {redeemButtonText}\n </Button>\n </div>\n </div>\n </div>\n )\n}\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GA+GU,IAAAI,EAAA,6BA/GVC,EAAsC,iCAEtCC,EAAwB,iBAExBC,EAAuB,yBACvBC,EAAkC,+BAElCC,EAA6C,4B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V,UAAWiB,GAAK,EACVA,EAAE,MAAQ,SAAWA,EAAE,MAAQ,MACjCA,EAAE,eAAe,CAErB,EAEC,SAAAV,GAAY,UACf,KAEF,QAAC,OACC,qBAAC,OAAI,UAAU,yDACb,oBAAC,WACC,UAAU,gEACV,OAAO,6FACT,KACA,OAAC,QACC,KAAM,MAAG,gBAAaP,EAAK,MAAM,
|
|
4
|
+
"sourcesContent": ["import { Button, Text, Picture } from '@anker-in/headless-ui'\n\nimport { useMemo } from 'react'\n\nimport classNames from 'classnames'\nimport { useCreditsContext } from '../context/provider'\nimport type { RedeemableItem as RedeemableItemType } from '../type'\nimport { AlpcConsumeType, ConsumeType } from '../context/const'\nimport { numberFormat, extractVariantId } from '../context/utils'\nimport type { CreditsRedeemListCopy } from './type'\nimport { gaTrack, useHeadlessContext } from '@anker-in/lib'\nimport { NoneProductValue } from './NonProductValue'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\nexport function RedeemableItem({\n copy,\n className,\n item,\n onRulesOpen,\n onRedeem,\n}: {\n copy: CreditsRedeemListCopy\n className?: string\n item: RedeemableItemType\n onRulesOpen: (rules: string[]) => void\n onRedeem: (item: RedeemableItemType) => void\n}) {\n const {\n creditInfo,\n profile,\n gtm: { pageGroup, pageHandle },\n pageCommon,\n } = useCreditsContext()\n const { brand, locale } = useHeadlessContext()\n const isLogin = Object.keys(profile || {}).length > 0\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const isDisabled = useMemo(() => {\n if (item.hasRedeemed) {\n return true\n }\n\n if (item.alpc?.remainingInventory <= 0 && item.alpc?.isLimited) {\n // \u6709\u5E93\u5B58\u9650\u5236\n return true\n }\n\n if (item.alpc?.consumeType === AlpcConsumeType.Product) {\n if (!item.variant?.availableForSale) {\n return true\n }\n }\n if (isLogin && profile?.activated && item.alpc?.consumeCredits > Number(creditInfo?.available_credit || 0)) {\n return true\n }\n return false\n }, [\n item.hasRedeemed,\n item.alpc?.remainingInventory,\n item.alpc?.isLimited,\n item.alpc?.consumeType,\n item.alpc?.consumeCredits,\n isLogin,\n profile?.activated,\n creditInfo?.available_credit,\n item.variant?.availableForSale,\n ])\n\n const redeemButtonText = useMemo(() => {\n if (!isLogin) {\n return copy.unlockRewards\n }\n\n // \u7F3A\u8D27\u6587\u6848\n if (item.alpc?.consumeType === AlpcConsumeType.Product) {\n return item.variant?.availableForSale ? copy.btnRedeem : pageCommon?.soldOut || 'Sold Out'\n }\n return copy.btnRedeem\n }, [\n isLogin,\n item.alpc?.consumeType,\n item.variant?.availableForSale,\n copy.btnRedeem,\n copy.unlockRewards,\n pageCommon?.soldOut,\n ])\n\n // \u751F\u6210\u4EA7\u54C1 listing \u9875\u9762\u94FE\u63A5\n const productUrl = useMemo(() => {\n if (item.config?.type !== ConsumeType.Product || !item.product?.handle) {\n return undefined\n }\n const localePrefix = locale === 'us' ? '' : `/${locale}`\n return extractVariantId(item.variant?.id)\n ? `${localePrefix}/products/${item.product.handle}?variant=${extractVariantId(item.variant?.id)}${pageHandle ? `&ref=${pageHandle}` : ''}`\n : `${localePrefix}/products/${item.product.handle}${pageHandle ? `?ref=${pageHandle}` : ''}`\n }, [item.config?.type, item.product?.handle, item.variant?.id, pageHandle, locale])\n\n return (\n <div\n className={classNames(\n 'flex flex-col items-center rounded-[16px] bg-[#EAEAEC] p-[24px] md:rounded-[12px] md:px-[8px] xl:py-[16px] md-xl:px-[16px]',\n !rounded && 'rounded-none md:rounded-none',\n className\n )}\n >\n {item.config?.type === ConsumeType.Product ? (\n <a\n href={productUrl}\n className={classNames('relative mx-auto h-[224px] w-fit md:my-[10px] l:h-[120px] l-xxl:h-[138px]')}\n >\n <Picture\n className=\"h-full w-auto [&_img]:h-full [&_img]:object-contain\"\n source={item.config?.image?.url || item.product?.images?.[0]?.url}\n ></Picture>\n </a>\n ) : (\n <div className=\"relative mx-auto my-[30px] h-[164px] md:my-0 md:h-[66px] l-xxl:h-[138px] md-l:h-[80px]\">\n <Picture\n source={pageCommon?.imageMapping?.[item.config?.type]?.url}\n className=\"h-full [&_img]:h-full [&_img]:w-auto [&_img]:object-contain\"\n ></Picture>\n\n <NoneProductValue item={item} />\n </div>\n )}\n <div className={classNames('mt-[10px] xl:mt-[8px] flex w-full flex-1 flex-col justify-between')}>\n <Text\n html={item.config?.title || item.alpc?.title}\n title={item.config?.title || item.alpc?.title}\n size={2}\n className=\"line-clamp-2 h-[58px] text-[24px] leading-[1.2] l:h-[40px] l:text-[16px] l-xxl:h-[48px] l-xxl:text-[20px]\"\n />\n {item.config?.rules?.length > 0 && (\n <button\n type=\"button\"\n onClick={() => {\n onRulesOpen(item.config?.rules || [])\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: pageGroup,\n position: copy.title,\n button_name: pageCommon?.ruleLabel,\n info: item.alpc?.id?.toString(),\n },\n })\n }}\n className=\"mt-[8px] w-fit text-[16px] font-bold underline md:text-[14px] l:mt-0\"\n tabIndex={0}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n }\n }}\n >\n {pageCommon?.ruleLabel}\n </button>\n )}\n <div>\n <div className=\"mt-[26px] flex items-center l:mt-[12px] l-xl:mt-[16px]\">\n <Picture\n className=\"size-[24px] l-xxl:size-[22px] md-l:size-[18px] md:size-[16px]\"\n source=\"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/icon_hire_purchase.png?v=1757496783\"\n />\n <Text\n html={`${numberFormat(item.alpc?.consumeCredits, locale)}`}\n size={2}\n as=\"p\"\n className=\"ml-[4px] text-[24px] font-bold mt-[4px] leading-none l-xxl:text-[20px] l:text-[16px] \"\n />\n </div>\n\n <Button\n disabled={isDisabled}\n variant=\"primary\"\n size=\"lg\"\n className=\"mt-[8px] md:px-[8px] l:w-full\"\n onClick={() => {\n onRedeem(item)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: pageGroup,\n position: copy.title,\n button_name: redeemButtonText,\n info: item.alpc?.id?.toString(),\n },\n })\n }}\n >\n {redeemButtonText}\n </Button>\n </div>\n </div>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GA+GU,IAAAI,EAAA,6BA/GVC,EAAsC,iCAEtCC,EAAwB,iBAExBC,EAAuB,yBACvBC,EAAkC,+BAElCC,EAA6C,4BAC7CC,EAA+C,4BAE/CC,EAA4C,yBAC5CC,EAAiC,6BACjCC,EAA+B,8BAExB,SAASX,EAAe,CAC7B,KAAAY,EACA,UAAAC,EACA,KAAAC,EACA,YAAAC,EACA,SAAAC,CACF,EAMG,CACD,KAAM,CACJ,WAAAC,EACA,QAAAC,EACA,IAAK,CAAE,UAAAC,EAAW,WAAAC,CAAW,EAC7B,WAAAC,CACF,KAAI,qBAAkB,EAChB,CAAE,MAAAC,EAAO,OAAAC,CAAO,KAAI,sBAAmB,EACvCC,EAAU,OAAO,KAAKN,GAAW,CAAC,CAAC,EAAE,OAAS,EAC9CO,EAAU,iBAAe,SAASH,CAAK,EAEvCI,KAAa,WAAQ,IACrB,GAAAZ,EAAK,aAILA,EAAK,MAAM,oBAAsB,GAAKA,EAAK,MAAM,WAKjDA,EAAK,MAAM,cAAgB,kBAAgB,SACzC,CAACA,EAAK,SAAS,kBAIjBU,GAAWN,GAAS,WAAaJ,EAAK,MAAM,eAAiB,OAAOG,GAAY,kBAAoB,CAAC,GAIxG,CACDH,EAAK,YACLA,EAAK,MAAM,mBACXA,EAAK,MAAM,UACXA,EAAK,MAAM,YACXA,EAAK,MAAM,eACXU,EACAN,GAAS,UACTD,GAAY,iBACZH,EAAK,SAAS,gBAChB,CAAC,EAEKa,KAAmB,WAAQ,IAC1BH,EAKDV,EAAK,MAAM,cAAgB,kBAAgB,QACtCA,EAAK,SAAS,iBAAmBF,EAAK,UAAYS,GAAY,SAAW,W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,OAAO,OAAS,MAC5B,OAAC,UACC,KAAK,SACL,QAAS,IAAM,CACbC,EAAYD,EAAK,QAAQ,OAAS,CAAC,CAAC,KACpC,WAAQ,CACN,MAAO,WACP,WAAY,YACZ,qBAAsBI,GAAS,UAAY,SAAW,aACtD,iBAAkB,CAChB,WAAYC,EACZ,SAAUP,EAAK,MACf,YAAaS,GAAY,UACzB,KAAMP,EAAK,MAAM,IAAI,SAAS,CAChC,CACF,CAAC,CACH,EACA,UAAU,uEACV,SAAU,EACV,UAAWiB,GAAK,EACVA,EAAE,MAAQ,SAAWA,EAAE,MAAQ,MACjCA,EAAE,eAAe,CAErB,EAEC,SAAAV,GAAY,UACf,KAEF,QAAC,OACC,qBAAC,OAAI,UAAU,yDACb,oBAAC,WACC,UAAU,gEACV,OAAO,6FACT,KACA,OAAC,QACC,KAAM,MAAG,gBAAaP,EAAK,MAAM,eAAgBS,CAAM,CAAC,GACxD,KAAM,EACN,GAAG,IACH,UAAU,wFACZ,GACF,KAEA,OAAC,UACC,SAAUG,EACV,QAAQ,UACR,KAAK,KACL,UAAU,gCACV,QAAS,IAAM,CACbV,EAASF,CAAI,KACb,WAAQ,CACN,MAAO,WACP,WAAY,YACZ,qBAAsBI,GAAS,UAAY,SAAW,aACtD,iBAAkB,CAChB,WAAYC,EACZ,SAAUP,EAAK,MACf,YAAae,EACb,KAAMb,EAAK,MAAM,IAAI,SAAS,CAChC,CACF,CAAC,CACH,EAEC,SAAAa,EACH,GACF,GACF,GACF,CAEJ",
|
|
6
6
|
"names": ["RedeemableItem_exports", "__export", "RedeemableItem", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_react", "import_classnames", "import_provider", "import_const", "import_utils", "import_lib", "import_NonProductValue", "import_constants", "copy", "className", "item", "onRulesOpen", "onRedeem", "creditInfo", "profile", "pageGroup", "pageHandle", "pageCommon", "brand", "locale", "isLogin", "rounded", "isDisabled", "redeemButtonText", "productUrl", "localePrefix", "classNames", "e"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var M=Object.create;var d=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var k=(e,t)=>{for(var n in t)d(e,n,{get:t[n],enumerable:!0})},
|
|
1
|
+
"use strict";var M=Object.create;var d=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var k=(e,t)=>{for(var n in t)d(e,n,{get:t[n],enumerable:!0})},f=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of R(t))!H.call(e,l)&&l!==n&&d(e,l,{get:()=>t[l],enumerable:!(r=E(t,l))||r.enumerable});return e};var S=(e,t,n)=>(n=e!=null?M(D(e)):{},f(t||!e||!e.__esModule?d(n,"default",{value:e,enumerable:!0}):n,e)),Z=e=>f(d({},"__esModule",{value:!0}),e);var I={};k(I,{CreditsModalContainer:()=>A});module.exports=Z(I);var o=require("react/jsx-runtime"),i=require("@anker-in/lib"),m=require("react"),C=S(require("react-modal")),v=require("../../../constants");const A=({isOpen:e,title:t,className:n="",overlayClassName:r="",scrollClassName:l="",onClose:c,onScrollEnd:p,children:u,useAnimation:x,animationClassName:h,titleClassName:L="",...g})=>{const[b,w]=(0,m.useState)(!1);(0,m.useEffect)(()=>{x&&requestAnimationFrame(()=>{w(e??!1)})},[e,x]);const{brand:N}=(0,i.useHeadlessContext)(),y=v.ROUNDED_BRANDS.includes(N);return(0,o.jsxs)(C.default,{isOpen:e,overlayClassName:(0,i.classNames)("fixed inset-0 z-[999] flex items-center justify-center bg-black/70 leading-[1.2] md:items-end",r),className:(0,i.classNames)("min-md:max-h-[calc(100vh-96px)] relative flex min-h-[200px] flex-col overflow-hidden rounded-[16px] bg-white outline-none transition-all duration-300 md:h-[88.27vh] md:w-full md:rounded-b-none",!y&&"rounded-none",b?"":h,n),onRequestClose:c,...g,children:[(0,o.jsxs)("div",{className:(0,i.classNames)("flex w-full shrink-0 items-center justify-between",t?"min-l:px-[32px] h-[70px] border-b border-[#e2e2e2] px-[24px]":"h-[48px] px-[16px]",L),children:[(0,o.jsx)("div",{className:"text-[18px] font-bold",children:t}),(0,o.jsx)("div",{className:"size-[22px] cursor-pointer",onClick:c,onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),c?.())},role:"button",tabIndex:0,children:(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"22",viewBox:"0 0 22 22",fill:"none",children:(0,o.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.8525 5.31015C16.4558 4.91337 15.8125 4.91338 15.4157 5.31015L11.1268 9.5991L6.83815 5.31049C6.44138 4.91372 5.79808 4.91372 5.40131 5.31049C5.00454 5.70726 5.00455 6.35055 5.40131 6.74732L9.68993 11.0359L5.40105 15.3248C5.00428 15.7216 5.00428 16.3649 5.40105 16.7616C5.79782 17.1584 6.44111 17.1584 6.83788 16.7616L11.1268 12.4728L15.416 16.762C15.8128 17.1588 16.456 17.1588 16.8528 16.762C17.2496 16.3652 17.2496 15.7219 16.8528 15.3252L12.5636 11.0359L16.8525 6.74698C17.2493 6.35021 17.2493 5.70692 16.8525 5.31015ZM16.921 6.02856C16.921 6.22992 16.8441 6.43127 16.6905 6.5849L14.465 8.8104L12.2395 11.0359L12.2395 11.0359L16.6905 6.58493C16.8441 6.43129 16.921 6.22993 16.921 6.02856ZM5.34966 6.19087C5.37992 6.3354 5.45115 6.47307 5.56336 6.58528L10.014 11.0359L10.014 11.0359L5.56336 6.58524C5.45116 6.47304 5.37992 6.33539 5.34966 6.19087ZM5.35087 16.2121C5.38193 16.3541 5.45267 16.4891 5.56309 16.5996C5.87037 16.9068 6.36856 16.9068 6.67583 16.5996L11.1268 12.1486L15.578 16.5999C15.8853 16.9072 16.3835 16.9072 16.6908 16.5999C16.8498 16.4409 16.9265 16.2307 16.9209 16.0223C16.9265 16.2307 16.8498 16.4409 16.6908 16.5999C16.3835 16.9072 15.8853 16.9072 15.578 16.5999L11.1268 12.1487L6.67583 16.5996C6.36856 16.9069 5.87037 16.9069 5.56309 16.5996C5.45267 16.4892 5.38192 16.3541 5.35087 16.2121Z",fill:"#333333"})})})]}),(0,o.jsx)("div",{className:(0,i.classNames)("my-[32px] flex-1 flex flex-col overflow-auto overscroll-contain px-[24px] md:mb-[48px]",!t&&"mt-0","min-l:px-[32px]",l),onScroll:s=>{const a=s.target;a.scrollHeight<=a.clientHeight||a.scrollTop+a.clientHeight>=a.scrollHeight-50&&p&&p(s)},children:u})]})};
|
|
2
2
|
//# sourceMappingURL=ModalContainer.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/components/credits/modal/ModalContainer.tsx"],
|
|
4
|
-
"sourcesContent": ["import { classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport { useEffect, useState, type UIEvent } from 'react'\nimport ReactModal from 'react-modal'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\nexport type ModalContainerProps = {\n overlayClassName?: string\n className?: string\n scrollClassName?: string\n title?: string\n titleClassName?: string\n useAnimation?: boolean // \u4F7F\u7528\u52A8\u753B\u5C55\u793A\n animationClassName?: string // \u52A8\u753B\u5C55\u793A\u63A7\u5236\u7684classname\n isOpen: boolean\n children?: any\n onClose: () => void\n onScrollEnd?: (event: UIEvent<HTMLDivElement>) => void\n}\n\nexport const CreditsModalContainer = ({\n isOpen,\n title,\n className = '',\n overlayClassName = '',\n scrollClassName = '',\n onClose,\n onScrollEnd,\n children,\n useAnimation,\n animationClassName,\n titleClassName = '',\n ...props\n}: ModalContainerProps): React.ReactElement => {\n const [animationShow, setAnimationShow] = useState(false)\n\n useEffect(() => {\n if (!useAnimation) {\n return\n }\n requestAnimationFrame(() => {\n setAnimationShow(isOpen ?? false)\n })\n }, [isOpen, useAnimation])\n\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n return (\n <ReactModal\n isOpen={isOpen}\n overlayClassName={cn(\n 'fixed inset-0 z-[999] flex items-center justify-center bg-black/70 leading-[1.2] md:items-end',\n overlayClassName\n )}\n className={cn(\n 'min-md:max-h-[calc(100vh-96px)] relative flex min-h-[200px] flex-col overflow-hidden rounded-[16px] bg-white outline-none transition-all duration-300 md:h-[88.27vh] md:w-full md:rounded-b-none',\n !rounded && 'rounded-none',\n animationShow ? '' : animationClassName,\n className\n )}\n onRequestClose={onClose}\n {...props}\n >\n <div\n className={cn(\n 'flex w-full shrink-0 items-center justify-between',\n title ? 'min-l:px-[32px] h-[70px] border-b border-[#e2e2e2] px-[24px]' : 'h-[48px] px-[16px]',\n titleClassName\n )}\n >\n <div className=\"text-[18px] font-bold\">{title}</div>\n <div\n className=\"size-[22px] cursor-pointer\"\n onClick={onClose}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n onClose?.()\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"22\" height=\"22\" viewBox=\"0 0 22 22\" fill=\"none\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M16.8525 5.31015C16.4558 4.91337 15.8125 4.91338 15.4157 5.31015L11.1268 9.5991L6.83815 5.31049C6.44138 4.91372 5.79808 4.91372 5.40131 5.31049C5.00454 5.70726 5.00455 6.35055 5.40131 6.74732L9.68993 11.0359L5.40105 15.3248C5.00428 15.7216 5.00428 16.3649 5.40105 16.7616C5.79782 17.1584 6.44111 17.1584 6.83788 16.7616L11.1268 12.4728L15.416 16.762C15.8128 17.1588 16.456 17.1588 16.8528 16.762C17.2496 16.3652 17.2496 15.7219 16.8528 15.3252L12.5636 11.0359L16.8525 6.74698C17.2493 6.35021 17.2493 5.70692 16.8525 5.31015ZM16.921 6.02856C16.921 6.22992 16.8441 6.43127 16.6905 6.5849L14.465 8.8104L12.2395 11.0359L12.2395 11.0359L16.6905 6.58493C16.8441 6.43129 16.921 6.22993 16.921 6.02856ZM5.34966 6.19087C5.37992 6.3354 5.45115 6.47307 5.56336 6.58528L10.014 11.0359L10.014 11.0359L5.56336 6.58524C5.45116 6.47304 5.37992 6.33539 5.34966 6.19087ZM5.35087 16.2121C5.38193 16.3541 5.45267 16.4891 5.56309 16.5996C5.87037 16.9068 6.36856 16.9068 6.67583 16.5996L11.1268 12.1486L15.578 16.5999C15.8853 16.9072 16.3835 16.9072 16.6908 16.5999C16.8498 16.4409 16.9265 16.2307 16.9209 16.0223C16.9265 16.2307 16.8498 16.4409 16.6908 16.5999C16.3835 16.9072 15.8853 16.9072 15.578 16.5999L11.1268 12.1487L6.67583 16.5996C6.36856 16.9069 5.87037 16.9069 5.56309 16.5996C5.45267 16.4892 5.38192 16.3541 5.35087 16.2121Z\"\n fill=\"#333333\"\n />\n </svg>\n </div>\n </div>\n <div\n className={cn(\n 'my-[32px] flex-1 overflow-auto overscroll-contain px-[24px] md:mb-[48px]',\n !title && 'mt-0',\n 'min-l:px-[32px]',\n scrollClassName\n )}\n onScroll={event => {\n const targetElement = event.target as HTMLDivElement\n\n if (targetElement.scrollHeight <= targetElement.clientHeight) {\n return\n }\n\n if (targetElement.scrollTop + targetElement.clientHeight >= targetElement.scrollHeight - 50) {\n onScrollEnd && onScrollEnd(event)\n }\n }}\n >\n {children}\n </div>\n </ReactModal>\n )\n}\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,IAAA,eAAAC,EAAAH,GA+DM,IAAAI,EAAA,6BA/DNC,EAAqD,yBACrDC,EAAkD,iBAClDC,EAAuB,0BACvBC,EAA+B,8BAgBxB,MAAMN,EAAwB,CAAC,CACpC,OAAAO,EACA,MAAAC,EACA,UAAAC,EAAY,GACZ,iBAAAC,EAAmB,GACnB,gBAAAC,EAAkB,GAClB,QAAAC,EACA,YAAAC,EACA,SAAAC,EACA,aAAAC,EACA,mBAAAC,EACA,eAAAC,EAAiB,GACjB,GAAGC,CACL,IAA+C,CAC7C,KAAM,CAACC,EAAeC,CAAgB,KAAI,YAAS,EAAK,KAExD,aAAU,IAAM,CACTL,GAGL,sBAAsB,IAAM,CAC1BK,EAAiBb,GAAU,EAAK,CAClC,CAAC,CACH,EAAG,CAACA,EAAQQ,CAAY,CAAC,EAEzB,KAAM,CAAE,MAAAM,CAAM,KAAI,sBAAmB,EAC/BC,EAAU,iBAAe,SAASD,CAAK,EAE7C,SACE,QAAC,EAAAE,QAAA,CACC,OAAQhB,EACR,oBAAkB,EAAAiB,YAChB,gGACAd,CACF,EACA,aAAW,EAAAc,YACT,mMACA,CAACF,GAAW,eACZH,EAAgB,GAAKH,EACrBP,CACF,EACA,eAAgBG,EACf,GAAGM,EAEJ,qBAAC,OACC,aAAW,EAAAM,YACT,oDACAhB,EAAQ,+DAAiE,qBACzES,CACF,EAEA,oBAAC,OAAI,UAAU,wBAAyB,SAAAT,EAAM,KAC9C,OAAC,OACC,UAAU,6BACV,QAASI,EACT,UAAWa,GAAK,EACVA,EAAE,MAAQ,SAAWA,EAAE,MAAQ,OACjCA,EAAE,eAAe,EACjBb,IAAU,EAEd,EACA,KAAK,SACL,SAAU,EAEV,mBAAC,OAAI,MAAM,6BAA6B,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OACtF,mBAAC,QACC,SAAS,UACT,SAAS,UACT,EAAE,syCACF,KAAK,UACP,EACF,EACF,GACF,KACA,OAAC,OACC,aAAW,EAAAY,YACT,
|
|
4
|
+
"sourcesContent": ["import { classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport { useEffect, useState, type UIEvent } from 'react'\nimport ReactModal from 'react-modal'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\nexport type ModalContainerProps = {\n overlayClassName?: string\n className?: string\n scrollClassName?: string\n title?: string\n titleClassName?: string\n useAnimation?: boolean // \u4F7F\u7528\u52A8\u753B\u5C55\u793A\n animationClassName?: string // \u52A8\u753B\u5C55\u793A\u63A7\u5236\u7684classname\n isOpen: boolean\n children?: any\n onClose: () => void\n onScrollEnd?: (event: UIEvent<HTMLDivElement>) => void\n}\n\nexport const CreditsModalContainer = ({\n isOpen,\n title,\n className = '',\n overlayClassName = '',\n scrollClassName = '',\n onClose,\n onScrollEnd,\n children,\n useAnimation,\n animationClassName,\n titleClassName = '',\n ...props\n}: ModalContainerProps): React.ReactElement => {\n const [animationShow, setAnimationShow] = useState(false)\n\n useEffect(() => {\n if (!useAnimation) {\n return\n }\n requestAnimationFrame(() => {\n setAnimationShow(isOpen ?? false)\n })\n }, [isOpen, useAnimation])\n\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n return (\n <ReactModal\n isOpen={isOpen}\n overlayClassName={cn(\n 'fixed inset-0 z-[999] flex items-center justify-center bg-black/70 leading-[1.2] md:items-end',\n overlayClassName\n )}\n className={cn(\n 'min-md:max-h-[calc(100vh-96px)] relative flex min-h-[200px] flex-col overflow-hidden rounded-[16px] bg-white outline-none transition-all duration-300 md:h-[88.27vh] md:w-full md:rounded-b-none',\n !rounded && 'rounded-none',\n animationShow ? '' : animationClassName,\n className\n )}\n onRequestClose={onClose}\n {...props}\n >\n <div\n className={cn(\n 'flex w-full shrink-0 items-center justify-between',\n title ? 'min-l:px-[32px] h-[70px] border-b border-[#e2e2e2] px-[24px]' : 'h-[48px] px-[16px]',\n titleClassName\n )}\n >\n <div className=\"text-[18px] font-bold\">{title}</div>\n <div\n className=\"size-[22px] cursor-pointer\"\n onClick={onClose}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n onClose?.()\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"22\" height=\"22\" viewBox=\"0 0 22 22\" fill=\"none\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M16.8525 5.31015C16.4558 4.91337 15.8125 4.91338 15.4157 5.31015L11.1268 9.5991L6.83815 5.31049C6.44138 4.91372 5.79808 4.91372 5.40131 5.31049C5.00454 5.70726 5.00455 6.35055 5.40131 6.74732L9.68993 11.0359L5.40105 15.3248C5.00428 15.7216 5.00428 16.3649 5.40105 16.7616C5.79782 17.1584 6.44111 17.1584 6.83788 16.7616L11.1268 12.4728L15.416 16.762C15.8128 17.1588 16.456 17.1588 16.8528 16.762C17.2496 16.3652 17.2496 15.7219 16.8528 15.3252L12.5636 11.0359L16.8525 6.74698C17.2493 6.35021 17.2493 5.70692 16.8525 5.31015ZM16.921 6.02856C16.921 6.22992 16.8441 6.43127 16.6905 6.5849L14.465 8.8104L12.2395 11.0359L12.2395 11.0359L16.6905 6.58493C16.8441 6.43129 16.921 6.22993 16.921 6.02856ZM5.34966 6.19087C5.37992 6.3354 5.45115 6.47307 5.56336 6.58528L10.014 11.0359L10.014 11.0359L5.56336 6.58524C5.45116 6.47304 5.37992 6.33539 5.34966 6.19087ZM5.35087 16.2121C5.38193 16.3541 5.45267 16.4891 5.56309 16.5996C5.87037 16.9068 6.36856 16.9068 6.67583 16.5996L11.1268 12.1486L15.578 16.5999C15.8853 16.9072 16.3835 16.9072 16.6908 16.5999C16.8498 16.4409 16.9265 16.2307 16.9209 16.0223C16.9265 16.2307 16.8498 16.4409 16.6908 16.5999C16.3835 16.9072 15.8853 16.9072 15.578 16.5999L11.1268 12.1487L6.67583 16.5996C6.36856 16.9069 5.87037 16.9069 5.56309 16.5996C5.45267 16.4892 5.38192 16.3541 5.35087 16.2121Z\"\n fill=\"#333333\"\n />\n </svg>\n </div>\n </div>\n <div\n className={cn(\n 'my-[32px] flex-1 flex flex-col overflow-auto overscroll-contain px-[24px] md:mb-[48px]',\n !title && 'mt-0',\n 'min-l:px-[32px]',\n scrollClassName\n )}\n onScroll={event => {\n const targetElement = event.target as HTMLDivElement\n\n if (targetElement.scrollHeight <= targetElement.clientHeight) {\n return\n }\n\n if (targetElement.scrollTop + targetElement.clientHeight >= targetElement.scrollHeight - 50) {\n onScrollEnd && onScrollEnd(event)\n }\n }}\n >\n {children}\n </div>\n </ReactModal>\n )\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,IAAA,eAAAC,EAAAH,GA+DM,IAAAI,EAAA,6BA/DNC,EAAqD,yBACrDC,EAAkD,iBAClDC,EAAuB,0BACvBC,EAA+B,8BAgBxB,MAAMN,EAAwB,CAAC,CACpC,OAAAO,EACA,MAAAC,EACA,UAAAC,EAAY,GACZ,iBAAAC,EAAmB,GACnB,gBAAAC,EAAkB,GAClB,QAAAC,EACA,YAAAC,EACA,SAAAC,EACA,aAAAC,EACA,mBAAAC,EACA,eAAAC,EAAiB,GACjB,GAAGC,CACL,IAA+C,CAC7C,KAAM,CAACC,EAAeC,CAAgB,KAAI,YAAS,EAAK,KAExD,aAAU,IAAM,CACTL,GAGL,sBAAsB,IAAM,CAC1BK,EAAiBb,GAAU,EAAK,CAClC,CAAC,CACH,EAAG,CAACA,EAAQQ,CAAY,CAAC,EAEzB,KAAM,CAAE,MAAAM,CAAM,KAAI,sBAAmB,EAC/BC,EAAU,iBAAe,SAASD,CAAK,EAE7C,SACE,QAAC,EAAAE,QAAA,CACC,OAAQhB,EACR,oBAAkB,EAAAiB,YAChB,gGACAd,CACF,EACA,aAAW,EAAAc,YACT,mMACA,CAACF,GAAW,eACZH,EAAgB,GAAKH,EACrBP,CACF,EACA,eAAgBG,EACf,GAAGM,EAEJ,qBAAC,OACC,aAAW,EAAAM,YACT,oDACAhB,EAAQ,+DAAiE,qBACzES,CACF,EAEA,oBAAC,OAAI,UAAU,wBAAyB,SAAAT,EAAM,KAC9C,OAAC,OACC,UAAU,6BACV,QAASI,EACT,UAAWa,GAAK,EACVA,EAAE,MAAQ,SAAWA,EAAE,MAAQ,OACjCA,EAAE,eAAe,EACjBb,IAAU,EAEd,EACA,KAAK,SACL,SAAU,EAEV,mBAAC,OAAI,MAAM,6BAA6B,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OACtF,mBAAC,QACC,SAAS,UACT,SAAS,UACT,EAAE,syCACF,KAAK,UACP,EACF,EACF,GACF,KACA,OAAC,OACC,aAAW,EAAAY,YACT,yFACA,CAAChB,GAAS,OACV,kBACAG,CACF,EACA,SAAUe,GAAS,CACjB,MAAMC,EAAgBD,EAAM,OAExBC,EAAc,cAAgBA,EAAc,cAI5CA,EAAc,UAAYA,EAAc,cAAgBA,EAAc,aAAe,IACvFd,GAAeA,EAAYa,CAAK,CAEpC,EAEC,SAAAZ,EACH,GACF,CAEJ",
|
|
6
6
|
"names": ["ModalContainer_exports", "__export", "CreditsModalContainer", "__toCommonJS", "import_jsx_runtime", "import_lib", "import_react", "import_react_modal", "import_constants", "isOpen", "title", "className", "overlayClassName", "scrollClassName", "onClose", "onScrollEnd", "children", "useAnimation", "animationClassName", "titleClassName", "props", "animationShow", "setAnimationShow", "brand", "rounded", "ReactModal", "cn", "e", "event", "targetElement"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CompleteProfileCopy } from '../../type';
|
|
2
|
+
type Props = {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
onSuccess?: () => void;
|
|
6
|
+
copy: CompleteProfileCopy;
|
|
7
|
+
shopifyStoreDomain?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function CompleteProfileModal({ isOpen, onClose, onSuccess, copy, shopifyStoreDomain }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var T=Object.create;var u=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var K=(l,s)=>{for(var r in s)u(l,r,{get:s[r],enumerable:!0})},L=(l,s,r,a)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of G(s))!J.call(l,i)&&i!==r&&u(l,i,{get:()=>s[i],enumerable:!(a=U(s,i))||a.enumerable});return l};var Q=(l,s,r)=>(r=l!=null?T(H(l)):{},L(s||!l||!l.__esModule?u(r,"default",{value:l,enumerable:!0}):r,l)),R=l=>L(u({},"__esModule",{value:!0}),l);var W={};K(W,{CompleteProfileModal:()=>V});module.exports=R(W);var e=require("react/jsx-runtime"),o=require("react"),n=require("@anker-in/headless-ui"),k=require("@anker-in/lib"),S=require("../../../credits/modal/ModalContainer"),z=require("./hooks/useUpdateProfile"),F=Q(require("../../../credits/context/hooks/useCountries")),O=require("../../context/provider");function V({isOpen:l,onClose:s,onSuccess:r,copy:a,shopifyStoreDomain:i=""}){const{profile:d,fetchCreditInfo:P,alpcConfig:w}=(0,O.useMemberPopupContext)(),{locale:A}=w,[m,y]=(0,o.useState)(""),[p,_]=(0,o.useState)(""),[b,E]=(0,o.useState)(""),[c,B]=(0,o.useState)(""),[x,N]=(0,o.useState)(""),[v,h]=(0,o.useState)(""),[C,g]=(0,o.useState)(""),{updateProfile:M,isLoading:q}=(0,z.useUpdateProfile)({locale:A,appName:w.appName}),{countries:f}=(0,F.default)({shopifyStoreDomain:i});(0,o.useEffect)(()=>{d&&(y(d.first_name??""),_(d.last_name??""),E(d.phone_number??""),B(d.dob??""),N(d.country?.id??""))},[d]),(0,o.useEffect)(()=>{f.length>0&&!x&&N(f[0].id)},[f]);const D=(0,o.useCallback)(()=>{let t=!1;return m.trim()?h(""):(h(a.required),t=!0),p.trim()?g(""):(g(a.required),t=!0),t},[m,p,a.required]),I=(0,o.useCallback)(async()=>{if(D())return;await M({first_name:m.trim(),last_name:p.trim(),phone_number:b,country:x,dob:c})&&(P(d?.user_id),r?.(),s())},[D,M,m,p,b,x,c,P,d,r,s]);return(0,e.jsx)(S.CreditsModalContainer,{isOpen:l,onClose:s,title:a.title,titleClassName:"!h-auto !border-b-0 !pb-0",className:"w-[540px] md:h-auto",useAnimation:!0,animationClassName:"md:translate-y-[100vh]",children:(0,e.jsxs)("div",{className:"flex flex-col gap-[20px]",children:[a.subtitle&&(0,e.jsx)(n.Text,{className:"text-[14px] text-[#1d1d1f]",html:a.subtitle}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-semibold text-[#1d1d1f]",children:a.email}),(0,e.jsx)("input",{className:"mt-[8px] h-[46px] w-full rounded-[4px] border border-[#d8d8d8] bg-[#f5f5f5] px-[12px] text-[14px] text-[#999]",value:d?.email??"",disabled:!0})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{className:"block text-[14px] font-semibold text-[#1d1d1f]",children:[a.firstName," ",(0,e.jsx)("span",{className:"text-[#f84d4f]",children:"*"})]}),(0,e.jsx)("input",{className:(0,k.classNames)("mt-[8px] h-[46px] w-full rounded-[4px] border px-[12px] text-[14px] outline-none",v?"border-[#f84d4f]":"border-[#d8d8d8]"),value:m,onChange:t=>{y(t.target.value),h("")}}),v&&(0,e.jsx)(n.Text,{className:"mt-[4px] text-[12px] text-[#f84d4f]",html:v})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{className:"block text-[14px] font-semibold text-[#1d1d1f]",children:[a.lastName," ",(0,e.jsx)("span",{className:"text-[#f84d4f]",children:"*"})]}),(0,e.jsx)("input",{className:(0,k.classNames)("mt-[8px] h-[46px] w-full rounded-[4px] border px-[12px] text-[14px] outline-none",C?"border-[#f84d4f]":"border-[#d8d8d8]"),value:p,onChange:t=>{_(t.target.value),g("")}}),C&&(0,e.jsx)(n.Text,{className:"mt-[4px] text-[12px] text-[#f84d4f]",html:C})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-semibold text-[#1d1d1f]",children:a.birthday}),(0,e.jsx)("input",{className:"mt-[8px] h-[46px] w-full rounded-[4px] border border-[#d8d8d8] px-[12px] text-[14px] outline-none",type:"date",value:c,onChange:t=>B(t.target.value)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-semibold text-[#1d1d1f]",children:a.phone}),(0,e.jsx)("input",{className:"mt-[8px] h-[46px] w-full rounded-[4px] border border-[#d8d8d8] px-[12px] text-[14px] outline-none",value:b,onChange:t=>E(t.target.value)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-semibold text-[#1d1d1f]",children:a.country}),(0,e.jsx)("select",{className:"mt-[8px] h-[46px] w-full rounded-[4px] border border-[#d8d8d8] px-[12px] text-[14px] outline-none",value:x,onChange:t=>N(t.target.value),children:f.map(t=>(0,e.jsx)("option",{value:t.id,children:t.name},t.id))})]}),(0,e.jsxs)("div",{className:"flex gap-[12px]",children:[(0,e.jsx)(n.Button,{variant:"secondary",size:"lg",className:"flex-1",onClick:s,disabled:q,children:a.cancel}),(0,e.jsx)(n.Button,{variant:"primary",size:"lg",className:"flex-1",loading:q,onClick:I,children:a.save})]})]})})}
|
|
2
|
+
//# sourceMappingURL=CompleteProfileModal.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../src/components/memberPopup/panels/EarnCredits/CompleteProfileModal.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Button, Text } from '@anker-in/headless-ui'\nimport { classNames as cn } from '@anker-in/lib'\nimport { CreditsModalContainer } from '../../../credits/modal/ModalContainer'\nimport type { CompleteProfileCopy } from '../../type'\nimport { useUpdateProfile } from './hooks/useUpdateProfile'\nimport useCountries from '../../../credits/context/hooks/useCountries'\nimport { useMemberPopupContext } from '../../context/provider'\n\ntype Props = {\n isOpen: boolean\n onClose: () => void\n onSuccess?: () => void\n copy: CompleteProfileCopy\n shopifyStoreDomain?: string\n}\n\nexport function CompleteProfileModal({ isOpen, onClose, onSuccess, copy, shopifyStoreDomain = '' }: Props) {\n const { profile, fetchCreditInfo, alpcConfig } = useMemberPopupContext()\n const { locale } = alpcConfig\n\n const [firstName, setFirstName] = useState('')\n const [lastName, setLastName] = useState('')\n const [phone, setPhone] = useState('')\n const [birthDay, setBirthDay] = useState('')\n const [country, setCountry] = useState('')\n const [firstNameError, setFirstNameError] = useState('')\n const [lastNameError, setLastNameError] = useState('')\n\n const { updateProfile, isLoading } = useUpdateProfile({ locale, appName: alpcConfig.appName })\n const { countries } = useCountries({ shopifyStoreDomain })\n\n useEffect(() => {\n if (profile) {\n setFirstName(profile.first_name ?? '')\n setLastName(profile.last_name ?? '')\n setPhone(profile.phone_number ?? '')\n setBirthDay(profile.dob ?? '')\n setCountry(profile.country?.id ?? '')\n }\n }, [profile])\n\n useEffect(() => {\n if (countries.length > 0 && !country) {\n setCountry(countries[0].id)\n }\n }, [countries])\n\n const validate = useCallback(() => {\n let hasError = false\n if (!firstName.trim()) {\n setFirstNameError(copy.required)\n hasError = true\n } else {\n setFirstNameError('')\n }\n if (!lastName.trim()) {\n setLastNameError(copy.required)\n hasError = true\n } else {\n setLastNameError('')\n }\n return hasError\n }, [firstName, lastName, copy.required])\n\n const handleSubmit = useCallback(async () => {\n if (validate()) return\n const success = await updateProfile({\n first_name: firstName.trim(),\n last_name: lastName.trim(),\n phone_number: phone,\n country,\n dob: birthDay,\n })\n if (success) {\n fetchCreditInfo(profile?.user_id)\n onSuccess?.()\n onClose()\n }\n }, [validate, updateProfile, firstName, lastName, phone, country, birthDay, fetchCreditInfo, profile, onSuccess, onClose])\n\n return (\n <CreditsModalContainer\n isOpen={isOpen}\n onClose={onClose}\n title={copy.title}\n titleClassName=\"!h-auto !border-b-0 !pb-0\"\n className=\"w-[540px] md:h-auto\"\n useAnimation\n animationClassName=\"md:translate-y-[100vh]\"\n >\n <div className=\"flex flex-col gap-[20px]\">\n {copy.subtitle && (\n <Text className=\"text-[14px] text-[#1d1d1f]\" html={copy.subtitle} />\n )}\n\n <div>\n <label className=\"block text-[14px] font-semibold text-[#1d1d1f]\">{copy.email}</label>\n <input\n className=\"mt-[8px] h-[46px] w-full rounded-[4px] border border-[#d8d8d8] bg-[#f5f5f5] px-[12px] text-[14px] text-[#999]\"\n value={profile?.email ?? ''}\n disabled\n />\n </div>\n\n <div>\n <label className=\"block text-[14px] font-semibold text-[#1d1d1f]\">\n {copy.firstName} <span className=\"text-[#f84d4f]\">*</span>\n </label>\n <input\n className={cn(\n 'mt-[8px] h-[46px] w-full rounded-[4px] border px-[12px] text-[14px] outline-none',\n firstNameError ? 'border-[#f84d4f]' : 'border-[#d8d8d8]'\n )}\n value={firstName}\n onChange={e => { setFirstName(e.target.value); setFirstNameError('') }}\n />\n {firstNameError && <Text className=\"mt-[4px] text-[12px] text-[#f84d4f]\" html={firstNameError} />}\n </div>\n\n <div>\n <label className=\"block text-[14px] font-semibold text-[#1d1d1f]\">\n {copy.lastName} <span className=\"text-[#f84d4f]\">*</span>\n </label>\n <input\n className={cn(\n 'mt-[8px] h-[46px] w-full rounded-[4px] border px-[12px] text-[14px] outline-none',\n lastNameError ? 'border-[#f84d4f]' : 'border-[#d8d8d8]'\n )}\n value={lastName}\n onChange={e => { setLastName(e.target.value); setLastNameError('') }}\n />\n {lastNameError && <Text className=\"mt-[4px] text-[12px] text-[#f84d4f]\" html={lastNameError} />}\n </div>\n\n <div>\n <label className=\"block text-[14px] font-semibold text-[#1d1d1f]\">{copy.birthday}</label>\n <input\n className=\"mt-[8px] h-[46px] w-full rounded-[4px] border border-[#d8d8d8] px-[12px] text-[14px] outline-none\"\n type=\"date\"\n value={birthDay}\n onChange={e => setBirthDay(e.target.value)}\n />\n </div>\n\n <div>\n <label className=\"block text-[14px] font-semibold text-[#1d1d1f]\">{copy.phone}</label>\n <input\n className=\"mt-[8px] h-[46px] w-full rounded-[4px] border border-[#d8d8d8] px-[12px] text-[14px] outline-none\"\n value={phone}\n onChange={e => setPhone(e.target.value)}\n />\n </div>\n\n <div>\n <label className=\"block text-[14px] font-semibold text-[#1d1d1f]\">{copy.country}</label>\n <select\n className=\"mt-[8px] h-[46px] w-full rounded-[4px] border border-[#d8d8d8] px-[12px] text-[14px] outline-none\"\n value={country}\n onChange={e => setCountry(e.target.value)}\n >\n {countries.map((c: { id: string; name: string }) => (\n <option key={c.id} value={c.id}>{c.name}</option>\n ))}\n </select>\n </div>\n\n <div className=\"flex gap-[12px]\">\n <Button\n variant=\"secondary\"\n size=\"lg\"\n className=\"flex-1\"\n onClick={onClose}\n disabled={isLoading}\n >\n {copy.cancel}\n </Button>\n <Button\n variant=\"primary\"\n size=\"lg\"\n className=\"flex-1\"\n loading={isLoading}\n onClick={handleSubmit}\n >\n {copy.save}\n </Button>\n </div>\n </div>\n </CreditsModalContainer>\n )\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,0BAAAE,IAAA,eAAAC,EAAAH,GA6FU,IAAAI,EAAA,6BA7FVC,EAAiD,iBACjDC,EAA6B,iCAC7BC,EAAiC,yBACjCC,EAAsC,iDAEtCC,EAAiC,oCACjCC,EAAyB,0DACzBC,EAAsC,kCAU/B,SAAST,EAAqB,CAAE,OAAAU,EAAQ,QAAAC,EAAS,UAAAC,EAAW,KAAAC,EAAM,mBAAAC,EAAqB,EAAG,EAAU,CACzG,KAAM,CAAE,QAAAC,EAAS,gBAAAC,EAAiB,WAAAC,CAAW,KAAI,yBAAsB,EACjE,CAAE,OAAAC,CAAO,EAAID,EAEb,CAACE,EAAWC,CAAY,KAAI,YAAS,EAAE,EACvC,CAACC,EAAUC,CAAW,KAAI,YAAS,EAAE,EACrC,CAACC,EAAOC,CAAQ,KAAI,YAAS,EAAE,EAC/B,CAACC,EAAUC,CAAW,KAAI,YAAS,EAAE,EACrC,CAACC,EAASC,CAAU,KAAI,YAAS,EAAE,EACnC,CAACC,EAAgBC,CAAiB,KAAI,YAAS,EAAE,EACjD,CAACC,EAAeC,CAAgB,KAAI,YAAS,EAAE,EAE/C,CAAE,cAAAC,EAAe,UAAAC,CAAU,KAAI,oBAAiB,CAAE,OAAAhB,E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A5B,EAAK,QAAQ,KAChF,OAAC,UACC,UAAU,oGACV,MAAOc,EACP,SAAUc,GAAKb,EAAWa,EAAE,OAAO,KAAK,EAEvC,SAAAN,EAAU,IAAKO,MACd,OAAC,UAAkB,MAAOA,EAAE,GAAK,SAAAA,EAAE,MAAtBA,EAAE,EAAyB,CACzC,EACH,GACF,KAEA,QAAC,OAAI,UAAU,kBACb,oBAAC,UACC,QAAQ,YACR,KAAK,KACL,UAAU,SACV,QAAS/B,EACT,SAAUuB,EAET,SAAArB,EAAK,OACR,KACA,OAAC,UACC,QAAQ,UACR,KAAK,KACL,UAAU,SACV,QAASqB,EACT,QAASK,EAER,SAAA1B,EAAK,KACR,GACF,GACF,EACF,CAEJ",
|
|
6
|
+
"names": ["CompleteProfileModal_exports", "__export", "CompleteProfileModal", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_ModalContainer", "import_useUpdateProfile", "import_useCountries", "import_provider", "isOpen", "onClose", "onSuccess", "copy", "shopifyStoreDomain", "profile", "fetchCreditInfo", "alpcConfig", "locale", "firstName", "setFirstName", "lastName", "setLastName", "phone", "setPhone", "birthDay", "setBirthDay", "country", "setCountry", "firstNameError", "setFirstNameError", "lastNameError", "setLastNameError", "updateProfile", "isLoading", "countries", "useCountries", "validate", "hasError", "handleSubmit", "cn", "e", "c"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var c=(g=>(g[g.All=0]="All",g[g.Earned=1]="Earned",g[g.Deducted=2]="Deducted",g[g.Expired=3]="Expired",g))(c||{}),u=(f=>(f.Coupon="coupon",f.GiftCard="giftCard",f.GoGift="goGift",f.Product="product",f.ShippingCoupon="shippingCoupon",f))(u||{}),P=(t=>(t[t.Coupon=1]="Coupon",t[t.Product=2]="Product",t[t.ExternalProduct=5]="ExternalProduct",t))(P||{}),h=(t=>(t[t.Program=1]="Program",t[t.Operation=2]="Operation",t[t.Redeem=3]="Redeem",t))(h||{}),G=(t=>(t.FirstPurchase="firstPurchase",t.UploadReceipt="uploadReceipt",t.Shopping="shopping",t))(G||{}),L=(o=>(o[o.Activation=1]="Activation",o[o.UpdateName=2]="UpdateName",o[o.UpdatePhone=3]="UpdatePhone",o[o.UpdateBirthday=4]="UpdateBirthday",o[o.Subscription=5]="Subscription",o[o.UpadteAppName=7]="UpadteAppName",o[o.Refund=3e3]="Refund",o[o.ProductUnApproved=5e3]="ProductUnApproved",o))(L||{}),U=(x=>(x.FixedMount="fixed_amount",x.Percent="percent",x))(U||{}),m=(n=>(n[n.Received=0]="Received",n[n.Pending=1]="Pending",n[n.ApproveSuccess=2]="ApproveSuccess",n[n.ApproveFail=3]="ApproveFail",n[n.Unfulfilled=4]="Unfulfilled",n[n.Fulfilled=5]="Fulfilled",n[n.Failed=6]="Failed",n[n.GogiftPending=7]="GogiftPending",n[n.GogiftApproved=8]="GogiftApproved",n[n.GogiftSecondConfirm=9]="GogiftSecondConfirm",n[n.GogiftRejected=10]="GogiftRejected",n[n.GogiftCallbackPending=11]="GogiftCallbackPending",n[n.GogiftCallbackSuccess=12]="GogiftCallbackSuccess",n[n.GogiftCallbackTimeout=13]="GogiftCallbackTimeout",n))(m||{}),F=(i=>(i[i.CodeLpcRedeemFailed=180001]="CodeLpcRedeemFailed",i[i.CodeLpcUserNotFound=180002]="CodeLpcUserNotFound",i[i.CodeLpcCreditRuleNotFound=180003]="CodeLpcCreditRuleNotFound",i[i.CodeLpcUnknownError=180004]="CodeLpcUnknownError",i[i.CodeLpcNotEnoughCredits=180005]="CodeLpcNotEnoughCredits",i[i.CodeLpcUserMigrate=180006]="CodeLpcUserMigrate",i[i.CodeLpcRuleInventoryNotEnough=180007]="CodeLpcRuleInventoryNotEnough",i[i.CodeLpcShopifyCouponRuleRedeemLimit=180009]="CodeLpcShopifyCouponRuleRedeemLimit",i[i.CodeCrossSiteError=180011]="CodeCrossSiteError",i))(F||{});const M=new Map([["eu-en","eu"],["eu-de","de"],["eu-fr","fr"]]);var N=(g=>(g[g.Pending=0]="Pending",g[g.Success=1]="Success",g[g.Failed=2]="Failed",g[g.DoubleConfirm=3]="DoubleConfirm",g))(N||{});const $={us:"$",uk:"\xA3",ca:"$",eu:"\u20AC",pl:"z\u0142",fr:"\u20AC",de:"\u20AC",vn:"\u20AB",cl:"$",sg:"$",ae:"AED",es:"\u20AC"};export{M as ALPC_COUNTRY_MAP,P as AlpcConsumeType,F as AlpcErrorCode,N as ApprovalStatus,u as ConsumeType,U as CouponType,c as CreditType,G as DTC_TASK_TYPE,$ as PRICE_SYMBOL,m as RewardType,L as TaskSubType,h as TaskType};
|
|
1
|
+
var c=(g=>(g[g.All=0]="All",g[g.Earned=1]="Earned",g[g.Deducted=2]="Deducted",g[g.Expired=3]="Expired",g))(c||{}),u=(f=>(f.Coupon="coupon",f.GiftCard="giftCard",f.GoGift="goGift",f.Product="product",f.ShippingCoupon="shippingCoupon",f))(u||{}),P=(t=>(t[t.Coupon=1]="Coupon",t[t.Product=2]="Product",t[t.ExternalProduct=5]="ExternalProduct",t))(P||{}),h=(t=>(t[t.Program=1]="Program",t[t.Operation=2]="Operation",t[t.Redeem=3]="Redeem",t))(h||{}),G=(t=>(t.FirstPurchase="firstPurchase",t.UploadReceipt="uploadReceipt",t.Shopping="shopping",t))(G||{}),L=(o=>(o[o.Activation=1]="Activation",o[o.UpdateName=2]="UpdateName",o[o.UpdatePhone=3]="UpdatePhone",o[o.UpdateBirthday=4]="UpdateBirthday",o[o.Subscription=5]="Subscription",o[o.UpadteAppName=7]="UpadteAppName",o[o.Refund=3e3]="Refund",o[o.ProductUnApproved=5e3]="ProductUnApproved",o))(L||{}),U=(x=>(x.FixedMount="fixed_amount",x.Percent="percent",x))(U||{}),m=(n=>(n[n.Received=0]="Received",n[n.Pending=1]="Pending",n[n.ApproveSuccess=2]="ApproveSuccess",n[n.ApproveFail=3]="ApproveFail",n[n.Unfulfilled=4]="Unfulfilled",n[n.Fulfilled=5]="Fulfilled",n[n.Failed=6]="Failed",n[n.GogiftPending=7]="GogiftPending",n[n.GogiftApproved=8]="GogiftApproved",n[n.GogiftSecondConfirm=9]="GogiftSecondConfirm",n[n.GogiftRejected=10]="GogiftRejected",n[n.GogiftCallbackPending=11]="GogiftCallbackPending",n[n.GogiftCallbackSuccess=12]="GogiftCallbackSuccess",n[n.GogiftCallbackTimeout=13]="GogiftCallbackTimeout",n))(m||{}),F=(i=>(i[i.CodeLpcRedeemFailed=180001]="CodeLpcRedeemFailed",i[i.CodeLpcUserNotFound=180002]="CodeLpcUserNotFound",i[i.CodeLpcCreditRuleNotFound=180003]="CodeLpcCreditRuleNotFound",i[i.CodeLpcUnknownError=180004]="CodeLpcUnknownError",i[i.CodeLpcNotEnoughCredits=180005]="CodeLpcNotEnoughCredits",i[i.CodeLpcUserMigrate=180006]="CodeLpcUserMigrate",i[i.CodeLpcRuleInventoryNotEnough=180007]="CodeLpcRuleInventoryNotEnough",i[i.CodeLpcShopifyCouponRuleRedeemLimit=180009]="CodeLpcShopifyCouponRuleRedeemLimit",i[i.CodeCrossSiteError=180011]="CodeCrossSiteError",i))(F||{});const M=new Map([["eu-en","eu"],["eu-de","de"],["eu-fr","fr"],["eu-es","es"],["eu-it","it"],["sg-en","sg"]]);var N=(g=>(g[g.Pending=0]="Pending",g[g.Success=1]="Success",g[g.Failed=2]="Failed",g[g.DoubleConfirm=3]="DoubleConfirm",g))(N||{});const $={us:"$",uk:"\xA3",ca:"$",eu:"\u20AC",pl:"z\u0142",fr:"\u20AC",de:"\u20AC",vn:"\u20AB",cl:"$",sg:"$",ae:"AED",es:"\u20AC"};export{M as ALPC_COUNTRY_MAP,P as AlpcConsumeType,F as AlpcErrorCode,N as ApprovalStatus,u as ConsumeType,U as CouponType,c as CreditType,G as DTC_TASK_TYPE,$ as PRICE_SYMBOL,m as RewardType,L as TaskSubType,h as TaskType};
|
|
2
2
|
//# sourceMappingURL=const.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/components/credits/context/const.ts"],
|
|
4
|
-
"sourcesContent": ["export enum CreditType {\n All = 0,\n Earned = 1,\n Deducted = 2,\n Expired = 3,\n}\n\nexport enum ConsumeType {\n Coupon = 'coupon',\n GiftCard = 'giftCard',\n GoGift = 'goGift',\n Product = 'product',\n ShippingCoupon = 'shippingCoupon',\n}\n\nexport enum AlpcConsumeType {\n Coupon = 1,\n Product = 2,\n ExternalProduct = 5,\n}\n\nexport enum TaskType {\n Program = 1,\n Operation = 2,\n Redeem = 3,\n}\n\nexport enum DTC_TASK_TYPE {\n FirstPurchase = 'firstPurchase',\n UploadReceipt = 'uploadReceipt',\n Shopping = 'shopping',\n}\n\nexport enum TaskSubType {\n Activation = 1, // \u6FC0\u6D3B\u4E8B\u4EF6\n UpdateName = 2, // \u5B8C\u5584\u59D3\u540D\n UpdatePhone = 3, // \u66F4\u65B0\u624B\u673A\u53F7\n UpdateBirthday = 4, // \u66F4\u65B0\u751F\u65E5\n Subscription = 5, // \u8BA2\u9605\n UpadteAppName = 7, // \u5B8C\u5584APP\u59D3\u540D\n Refund = 3000, // \u8D2D\u7269\u9001\u79EF\u5206\u4EFB\u52A1\u9000\u6B3E\n ProductUnApproved = 5000, // \u5151\u6362\u5546\u54C1\u5BA1\u6838\u4E0D\u901A\u8FC7\n}\n\nexport enum CouponType {\n FixedMount = 'fixed_amount',\n Percent = 'percent',\n}\n\nexport enum RewardType {\n Received = 0,\n Pending = 1,\n ApproveSuccess = 2,\n ApproveFail = 3,\n Unfulfilled = 4,\n Fulfilled = 5,\n Failed = 6,\n GogiftPending = 7,\n GogiftApproved = 8,\n GogiftSecondConfirm = 9,\n GogiftRejected = 10,\n GogiftCallbackPending = 11,\n GogiftCallbackSuccess = 12,\n GogiftCallbackTimeout = 13,\n}\n\nexport enum AlpcErrorCode {\n CodeLpcRedeemFailed = 180001,\n //user not found\n CodeLpcUserNotFound = 180002,\n //credit rule not found\n CodeLpcCreditRuleNotFound = 180003,\n //unknown error\n CodeLpcUnknownError = 180004,\n // not enough credits\n CodeLpcNotEnoughCredits = 180005,\n // user migrate\n CodeLpcUserMigrate = 180006,\n // \u5E93\u5B58\u4E0D\u8DB3\n CodeLpcRuleInventoryNotEnough = 180007,\n // \u5151\u6362\u6B21\u6570\u9650\u5236\n CodeLpcShopifyCouponRuleRedeemLimit = 180009,\n // \u8DE8\u533A\u5151\u6362\u9519\u8BEF\uFF08\u975E\u6B27\u5151\u6362\u6B27\u6D32\u7684\uFF09\n CodeCrossSiteError = 180011,\n}\n\nexport const ALPC_COUNTRY_MAP = new Map<string, string>([\n ['eu-en', 'eu'],\n ['eu-de', 'de'],\n ['eu-fr', 'fr'],\n])\n\nexport enum ApprovalStatus {\n Pending = 0,\n Success = 1,\n Failed = 2,\n DoubleConfirm = 3,\n}\n\nexport const PRICE_SYMBOL = {\n us: '$',\n uk: '\u00A3',\n ca: '$',\n eu: '\u20AC',\n pl: 'z\u0142',\n fr: '\u20AC',\n de: '\u20AC',\n vn: '\u20AB',\n cl: '$',\n sg: '$',\n ae: 'AED',\n es: '\u20AC',\n}\n"],
|
|
5
|
-
"mappings": "AAAO,IAAKA,OACVA,IAAA,IAAM,GAAN,MACAA,IAAA,OAAS,GAAT,SACAA,IAAA,SAAW,GAAX,WACAA,IAAA,QAAU,GAAV,UAJUA,OAAA,IAOAC,OACVA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,OAAS,SACTA,EAAA,QAAU,UACVA,EAAA,eAAiB,iBALPA,OAAA,IAQAC,OACVA,IAAA,OAAS,GAAT,SACAA,IAAA,QAAU,GAAV,UACAA,IAAA,gBAAkB,GAAlB,kBAHUA,OAAA,IAMAC,OACVA,IAAA,QAAU,GAAV,UACAA,IAAA,UAAY,GAAZ,YACAA,IAAA,OAAS,GAAT,SAHUA,OAAA,IAMAC,OACVA,EAAA,cAAgB,gBAChBA,EAAA,cAAgB,gBAChBA,EAAA,SAAW,WAHDA,OAAA,IAMAC,OACVA,IAAA,W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,GAAI,IACJ,GAAI,SACJ,GAAI,UACJ,GAAI,SACJ,GAAI,SACJ,GAAI,SACJ,GAAI,IACJ,GAAI,IACJ,GAAI,MACJ,GAAI,QACN",
|
|
4
|
+
"sourcesContent": ["export enum CreditType {\n All = 0,\n Earned = 1,\n Deducted = 2,\n Expired = 3,\n}\n\nexport enum ConsumeType {\n Coupon = 'coupon',\n GiftCard = 'giftCard',\n GoGift = 'goGift',\n Product = 'product',\n ShippingCoupon = 'shippingCoupon',\n}\n\nexport enum AlpcConsumeType {\n Coupon = 1,\n Product = 2,\n ExternalProduct = 5,\n}\n\nexport enum TaskType {\n Program = 1,\n Operation = 2,\n Redeem = 3,\n}\n\nexport enum DTC_TASK_TYPE {\n FirstPurchase = 'firstPurchase',\n UploadReceipt = 'uploadReceipt',\n Shopping = 'shopping',\n}\n\nexport enum TaskSubType {\n Activation = 1, // \u6FC0\u6D3B\u4E8B\u4EF6\n UpdateName = 2, // \u5B8C\u5584\u59D3\u540D\n UpdatePhone = 3, // \u66F4\u65B0\u624B\u673A\u53F7\n UpdateBirthday = 4, // \u66F4\u65B0\u751F\u65E5\n Subscription = 5, // \u8BA2\u9605\n UpadteAppName = 7, // \u5B8C\u5584APP\u59D3\u540D\n Refund = 3000, // \u8D2D\u7269\u9001\u79EF\u5206\u4EFB\u52A1\u9000\u6B3E\n ProductUnApproved = 5000, // \u5151\u6362\u5546\u54C1\u5BA1\u6838\u4E0D\u901A\u8FC7\n}\n\nexport enum CouponType {\n FixedMount = 'fixed_amount',\n Percent = 'percent',\n}\n\nexport enum RewardType {\n Received = 0,\n Pending = 1,\n ApproveSuccess = 2,\n ApproveFail = 3,\n Unfulfilled = 4,\n Fulfilled = 5,\n Failed = 6,\n GogiftPending = 7,\n GogiftApproved = 8,\n GogiftSecondConfirm = 9,\n GogiftRejected = 10,\n GogiftCallbackPending = 11,\n GogiftCallbackSuccess = 12,\n GogiftCallbackTimeout = 13,\n}\n\nexport enum AlpcErrorCode {\n CodeLpcRedeemFailed = 180001,\n //user not found\n CodeLpcUserNotFound = 180002,\n //credit rule not found\n CodeLpcCreditRuleNotFound = 180003,\n //unknown error\n CodeLpcUnknownError = 180004,\n // not enough credits\n CodeLpcNotEnoughCredits = 180005,\n // user migrate\n CodeLpcUserMigrate = 180006,\n // \u5E93\u5B58\u4E0D\u8DB3\n CodeLpcRuleInventoryNotEnough = 180007,\n // \u5151\u6362\u6B21\u6570\u9650\u5236\n CodeLpcShopifyCouponRuleRedeemLimit = 180009,\n // \u8DE8\u533A\u5151\u6362\u9519\u8BEF\uFF08\u975E\u6B27\u5151\u6362\u6B27\u6D32\u7684\uFF09\n CodeCrossSiteError = 180011,\n}\n\nexport const ALPC_COUNTRY_MAP = new Map<string, string>([\n ['eu-en', 'eu'],\n ['eu-de', 'de'],\n ['eu-fr', 'fr'],\n ['eu-es', 'es'],\n ['eu-it', 'it'],\n ['sg-en', 'sg'],\n])\n\nexport enum ApprovalStatus {\n Pending = 0,\n Success = 1,\n Failed = 2,\n DoubleConfirm = 3,\n}\n\nexport const PRICE_SYMBOL = {\n us: '$',\n uk: '\u00A3',\n ca: '$',\n eu: '\u20AC',\n pl: 'z\u0142',\n fr: '\u20AC',\n de: '\u20AC',\n vn: '\u20AB',\n cl: '$',\n sg: '$',\n ae: 'AED',\n es: '\u20AC',\n}\n"],
|
|
5
|
+
"mappings": "AAAO,IAAKA,OACVA,IAAA,IAAM,GAAN,MACAA,IAAA,OAAS,GAAT,SACAA,IAAA,SAAW,GAAX,WACAA,IAAA,QAAU,GAAV,UAJUA,OAAA,IAOAC,OACVA,EAAA,OAAS,SACTA,EAAA,SAAW,WACXA,EAAA,OAAS,SACTA,EAAA,QAAU,UACVA,EAAA,eAAiB,iBALPA,OAAA,IAQAC,OACVA,IAAA,OAAS,GAAT,SACAA,IAAA,QAAU,GAAV,UACAA,IAAA,gBAAkB,GAAlB,kBAHUA,OAAA,IAMAC,OACVA,IAAA,QAAU,GAAV,UACAA,IAAA,UAAY,GAAZ,YAC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,CAAC,QAAS,IAAI,CAChB,CAAC,EAEM,IAAKC,OACVA,IAAA,QAAU,GAAV,UACAA,IAAA,QAAU,GAAV,UACAA,IAAA,OAAS,GAAT,SACAA,IAAA,cAAgB,GAAhB,gBAJUA,OAAA,IAOL,MAAMC,EAAe,CAC1B,GAAI,IACJ,GAAI,OACJ,GAAI,IACJ,GAAI,SACJ,GAAI,UACJ,GAAI,SACJ,GAAI,SACJ,GAAI,SACJ,GAAI,IACJ,GAAI,IACJ,GAAI,MACJ,GAAI,QACN",
|
|
6
6
|
"names": ["CreditType", "ConsumeType", "AlpcConsumeType", "TaskType", "DTC_TASK_TYPE", "TaskSubType", "CouponType", "RewardType", "AlpcErrorCode", "ALPC_COUNTRY_MAP", "ApprovalStatus", "PRICE_SYMBOL"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function getAlpcPath(locale?: string, apiBaseUrl?: string): string;
|
|
2
|
-
export declare function numberFormat(num?: number): string | number;
|
|
2
|
+
export declare function numberFormat(num?: number, locale?: string): string | number;
|
|
3
3
|
export declare const emailValidate: (email: any) => boolean;
|
|
4
4
|
export declare const languageTerritory: (locale: string) => string;
|
|
5
5
|
export declare function formatPrice({ amount, currencyCode, locale, maximumFractionDigits, minimumFractionDigits, removeTrailingZeros, }: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import g from"js-cookie";import{PRICE_SYMBOL as a}from"./const";function $(e="",
|
|
1
|
+
import g from"js-cookie";import{PRICE_SYMBOL as a}from"./const";function $(e="",r){let n=!1;const t=g.get("alpcEU");return t===void 0||t===""?["de","eu-de","eu","eu-en","uk","fr","fra"].includes(e)&&(n=!0):Number(t)&&(n=!0),r?n?`${r}/api/multipass/alpc-eu`:`${r}/api/multipass/alpc`:n?"/api/multipass/alpc-eu":"/api/multipass/alpc"}function I(e=0,r){if(typeof Intl>"u")return e;const n=new Intl.NumberFormat(o(r||"")||r).format(e);return r&&["fr","eu-fr","fra"].includes(r)?n.replace(/[\u202f\u00a0]/g," "):n}const P=e=>/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e),o=e=>({us:"en-us",uk:"en-gb",ca:"en-ca",au:"en-au",nz:"en-nz",eu:"en-eu",pl:"pl-pl",fr:"fr-fr","eu-fr":"fr-fr",fra:"fr-fr",de:"de-de",vn:"vi-vn",sg:"en-sg","ae-en":"en-ae",plus:"en-us",cl:"es-cl",es:"es-es",se:"en-se",dk:"en-dk",is:"en-is",no:"en-no",fi:"en-fi"})[e]||"";function c({amount:e,currencyCode:r,locale:n,maximumFractionDigits:t,minimumFractionDigits:u,removeTrailingZeros:f=!1}){let i=new Intl.NumberFormat(o(n)||n,{style:"currency",currency:r||"USD",minimumFractionDigits:t===0?0:u,maximumFractionDigits:t}).format(e);return["eu-de","eu-en","de","eu"].includes(n)&&(i=i?.toString()?.replace(/[\s]/g,"")),["fr","eu-fr","fra"].includes(n)&&(i=i?.toString()?.replace(/[\u202f\u00a0]/g," ")),f&&(i=i.replace(/(\.\d*?[1-9])0+\b/,"$1").replace(/\.0+\b/,"").replace(/(\,\d*?[1-9])0+\b/,"$1").replace(/\,0+\b/,"")),i}function S({amount:e,baseAmount:r,currencyCode:n,locale:t,maximumFractionDigits:u,minimumFractionDigits:f,removeTrailingZeros:s}){if(typeof Intl>"u")return{price:`${a[t]}${e}`,basePrice:`${a[t]}${r}`,discount:`${a[t]}${r-e||0}`};const i=r>e,p=new Intl.NumberFormat(o(t),{style:"percent"}),m=i?p.format((r-e)/r):null,l=c({amount:e,currencyCode:n,locale:t,removeTrailingZeros:s}),d=i?c({amount:r,currencyCode:n,locale:t,maximumFractionDigits:u,minimumFractionDigits:f,removeTrailingZeros:s}):void 0;return{price:l,basePrice:d,discount:m}}function k(e){return e?(typeof e=="number"?e.toString():e).replace("gid://shopify/ProductVariant/",""):null}export{P as emailValidate,k as extractVariantId,c as formatPrice,S as formatVariantPrice,$ as getAlpcPath,o as languageTerritory,I as numberFormat};
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/components/credits/context/utils.ts"],
|
|
4
|
-
"sourcesContent": ["import Cookies from 'js-cookie'\nimport { PRICE_SYMBOL } from './const'\n\nexport function getAlpcPath(locale = '', apiBaseUrl?: string) {\n let isEU = false\n const alpcEUCookie = Cookies.get('alpcEU')\n if (alpcEUCookie === undefined || alpcEUCookie === '') {\n if (['de', 'eu-de', 'eu', 'eu-en', 'uk', 'fr', 'fra'].includes(locale)) {\n isEU = true\n }\n } else {\n let alpcEU = Number(alpcEUCookie)\n if (alpcEU) {\n isEU = true\n }\n }\n\n // \u5982\u679C\u63D0\u4F9B\u4E86\u81EA\u5B9A\u4E49\u7684 apiBaseUrl\uFF0C\u62FC\u63A5\u5BF9\u5E94\u7684\u8DEF\u5F84\n if (apiBaseUrl) {\n return isEU ? `${apiBaseUrl}/api/multipass/alpc-eu` : `${apiBaseUrl}/api/multipass/alpc`\n }\n\n if (isEU) {\n return '/api/multipass/alpc-eu'\n }\n\n return '/api/multipass/alpc'\n}\n\nexport function numberFormat(num: number = 0) {\n if (typeof Intl === 'undefined') {\n return num\n }\n\n
|
|
5
|
-
"mappings": "AAAA,OAAOA,MAAa,YACpB,OAAS,gBAAAC,MAAoB,UAEtB,SAASC,EAAYC,EAAS,GAAIC,EAAqB,CAC5D,IAAIC,EAAO,GACX,MAAMC,EAAeN,EAAQ,IAAI,QAAQ,EAazC,OAZIM,IAAiB,QAAaA,IAAiB,GAC7C,CAAC,KAAM,QAAS,KAAM,QAAS,KAAM,KAAM,KAAK,EAAE,SAASH,CAAM,IACnEE,EAAO,IAGI,OAAOC,CAAY,IAE9BD,EAAO,IAKPD,EACKC,EAAO,GAAGD,CAAU,yBAA2B,GAAGA,CAAU,sBAGjEC,EACK,yBAGF,qBACT,CAEO,SAASE,EAAaC,EAAc,
|
|
6
|
-
"names": ["Cookies", "PRICE_SYMBOL", "getAlpcPath", "locale", "apiBaseUrl", "isEU", "alpcEUCookie", "numberFormat", "num", "
|
|
4
|
+
"sourcesContent": ["import Cookies from 'js-cookie'\nimport { PRICE_SYMBOL } from './const'\n\nexport function getAlpcPath(locale = '', apiBaseUrl?: string) {\n let isEU = false\n const alpcEUCookie = Cookies.get('alpcEU')\n if (alpcEUCookie === undefined || alpcEUCookie === '') {\n if (['de', 'eu-de', 'eu', 'eu-en', 'uk', 'fr', 'fra'].includes(locale)) {\n isEU = true\n }\n } else {\n let alpcEU = Number(alpcEUCookie)\n if (alpcEU) {\n isEU = true\n }\n }\n\n // \u5982\u679C\u63D0\u4F9B\u4E86\u81EA\u5B9A\u4E49\u7684 apiBaseUrl\uFF0C\u62FC\u63A5\u5BF9\u5E94\u7684\u8DEF\u5F84\n if (apiBaseUrl) {\n return isEU ? `${apiBaseUrl}/api/multipass/alpc-eu` : `${apiBaseUrl}/api/multipass/alpc`\n }\n\n if (isEU) {\n return '/api/multipass/alpc-eu'\n }\n\n return '/api/multipass/alpc'\n}\n\nexport function numberFormat(num: number = 0, locale?: string) {\n if (typeof Intl === 'undefined') {\n return num\n }\n\n const formatted = new Intl.NumberFormat(languageTerritory(locale || '') || locale).format(num)\n\n if (locale && ['fr', 'eu-fr', 'fra'].includes(locale)) {\n return formatted.replace(/[\\u202f\\u00a0]/g, ' ')\n }\n\n return formatted\n}\n\nexport const emailValidate = (email: any) => {\n return /^(([^<>()\\[\\]\\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/.test(\n email\n )\n}\n\nexport const languageTerritory = (locale: string) =>\n // https://unicode-org.github.io/cldr-staging/charts/37/supplemental/language_territory_information.html\n ({\n us: 'en-us',\n uk: 'en-gb',\n ca: 'en-ca',\n au: 'en-au',\n nz: 'en-nz',\n eu: 'en-eu',\n pl: 'pl-pl',\n fr: 'fr-fr',\n 'eu-fr': 'fr-fr',\n fra: 'fr-fr',\n de: 'de-de',\n vn: 'vi-vn',\n sg: 'en-sg',\n 'ae-en': 'en-ae',\n plus: 'en-us',\n cl: 'es-cl',\n es: 'es-es',\n // Nordic countries\n se: 'en-se',\n dk: 'en-dk',\n is: 'en-is',\n no: 'en-no',\n fi: 'en-fi',\n })[locale] || ''\n\nexport function formatPrice({\n amount,\n currencyCode,\n locale,\n maximumFractionDigits,\n minimumFractionDigits,\n removeTrailingZeros = false,\n}: {\n amount: number\n currencyCode: string\n locale: string\n maximumFractionDigits?: number\n minimumFractionDigits?: number\n removeTrailingZeros?: boolean\n}) {\n const formatCurrency = new Intl.NumberFormat(languageTerritory(locale) || locale, {\n style: 'currency',\n currency: currencyCode || 'USD',\n minimumFractionDigits: maximumFractionDigits === 0 ? 0 : minimumFractionDigits,\n maximumFractionDigits,\n })\n\n let formattedValue = formatCurrency.format(amount)\n\n if (['eu-de', 'eu-en', 'de', 'eu'].includes(locale)) {\n formattedValue = formattedValue?.toString()?.replace(/[\\s]/g, '')\n }\n\n if (['fr', 'eu-fr', 'fra'].includes(locale)) {\n // Intl \u8F93\u51FA\u7684\u5343\u4F4D\u5206\u9694\u7B26\u662F\u7A84\u4E0D\u6362\u884C\u7A7A\u683C(U+202F)/\u4E0D\u6362\u884C\u7A7A\u683C(U+00A0)\uFF0C\u7EDF\u4E00\u66FF\u6362\u4E3A\u666E\u901A\u7A7A\u683C\n formattedValue = formattedValue?.toString()?.replace(/[\\u202f\\u00a0]/g, ' ')\n }\n\n if (removeTrailingZeros) {\n // Adjust the regex to match comma as decimal separator\n formattedValue = formattedValue\n .replace(/(\\.\\d*?[1-9])0+\\b/, '$1')\n .replace(/\\.0+\\b/, '')\n .replace(/(\\,\\d*?[1-9])0+\\b/, '$1')\n .replace(/\\,0+\\b/, '')\n }\n\n return formattedValue\n}\n\nexport function formatVariantPrice({\n amount,\n baseAmount,\n currencyCode,\n locale,\n maximumFractionDigits,\n minimumFractionDigits,\n removeTrailingZeros,\n}: {\n baseAmount: number\n amount: number\n currencyCode: string\n locale: string\n maximumFractionDigits?: number\n minimumFractionDigits?: number\n removeTrailingZeros?: boolean\n}) {\n if (typeof Intl === 'undefined') {\n return {\n price: `${PRICE_SYMBOL[locale as keyof typeof PRICE_SYMBOL]}${amount}`,\n basePrice: `${PRICE_SYMBOL[locale as keyof typeof PRICE_SYMBOL]}${baseAmount}`,\n discount: `${PRICE_SYMBOL[locale as keyof typeof PRICE_SYMBOL]}${baseAmount - amount || 0}`,\n }\n }\n\n const hasDiscount = baseAmount > amount\n const formatDiscount = new Intl.NumberFormat(languageTerritory(locale), {\n style: 'percent',\n })\n const discount = hasDiscount ? formatDiscount.format((baseAmount - amount) / baseAmount) : null\n\n const price = formatPrice({ amount, currencyCode, locale, removeTrailingZeros })\n const basePrice = hasDiscount\n ? formatPrice({\n amount: baseAmount,\n currencyCode,\n locale,\n maximumFractionDigits,\n minimumFractionDigits,\n removeTrailingZeros,\n })\n : undefined\n\n return { price, basePrice, discount }\n}\n\n/**\n * \u63D0\u53D6 variant id\uFF0C\u53BB\u6389 gid://shopify/ProductVariant/ \u524D\u7F00\n */\nexport function extractVariantId(id: string | number | undefined): string | null {\n if (!id) return null\n const idStr = typeof id === 'number' ? id.toString() : id\n return idStr.replace('gid://shopify/ProductVariant/', '')\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAAa,YACpB,OAAS,gBAAAC,MAAoB,UAEtB,SAASC,EAAYC,EAAS,GAAIC,EAAqB,CAC5D,IAAIC,EAAO,GACX,MAAMC,EAAeN,EAAQ,IAAI,QAAQ,EAazC,OAZIM,IAAiB,QAAaA,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BOL", "getAlpcPath", "locale", "apiBaseUrl", "isEU", "alpcEUCookie", "numberFormat", "num", "formatted", "languageTerritory", "emailValidate", "email", "formatPrice", "amount", "currencyCode", "maximumFractionDigits", "minimumFractionDigits", "removeTrailingZeros", "formattedValue", "formatVariantPrice", "baseAmount", "hasDiscount", "formatDiscount", "discount", "price", "basePrice", "extractVariantId", "id"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as t,jsxs as d}from"react/jsx-runtime";import{Button as A,Text as x,Picture as N,Badge as L}from"@anker-in/headless-ui";import{useMemo as p,useState as B}from"react";import{useCreditsContext as P}from"../context/provider";import{useRedeemAndBuy as U}from"../context/hooks/useRedeemAndBuy";import{formatPrice as _,numberFormat as O,extractVariantId as S}from"../context/utils";import{gaTrack as V,classNames as s,useHeadlessContext as T}from"@anker-in/lib";import{useRegistration as H}from"../../../components/registration";import{ROUNDED_BRANDS as M}from"../../../constants";function G({copy:r,itemData:e,setRules:w,className:y}){const{creditInfo:g,profile:a,openSignUpPopup:R,pageCommon:c,gtm:{pageGroup:b,pageHandle:
|
|
1
|
+
import{jsx as t,jsxs as d}from"react/jsx-runtime";import{Button as A,Text as x,Picture as N,Badge as L}from"@anker-in/headless-ui";import{useMemo as p,useState as B}from"react";import{useCreditsContext as P}from"../context/provider";import{useRedeemAndBuy as U}from"../context/hooks/useRedeemAndBuy";import{formatPrice as _,numberFormat as O,extractVariantId as S}from"../context/utils";import{gaTrack as V,classNames as s,useHeadlessContext as T}from"@anker-in/lib";import{useRegistration as H}from"../../../components/registration";import{ROUNDED_BRANDS as M}from"../../../constants";function G({copy:r,itemData:e,setRules:w,className:y}){const{creditInfo:g,profile:a,openSignUpPopup:R,pageCommon:c,gtm:{pageGroup:b,pageHandle:o}}=P(),{authCodeActivate:m}=H(),{brand:z,locale:n}=T(),v=M.includes(z),[h,C]=B(null),{trigger:$,isMutating:I}=U({},{onError:l=>{C(l.message)}}),i=p(()=>!!a,[a?.activated]),u=p(()=>i&&a?.activated&&e.alpcData?.consumeCredits>Number(g?.available_credit||0),[i,a?.activated,e.alpcData?.consumeCredits,g?.available_credit]),k=p(()=>!!(e.alpcData?.remainingInventory<=0&&e.alpcData?.isLimited||!e.productVariant?.availableForSale||u),[e.alpcData?.remainingInventory,e.alpcData?.isLimited,e.productVariant?.availableForSale,u]),E=()=>{C(null),i?!a?.activated&&!m.isActivateSuccess?(m.setAutoSendEmail(!0),m.open()):($({productVariant:e?.productVariant,redeemId:e?.config?.redeemId}),V({event:"ga4Event",event_name:"lp_button",member_active_status:a?.activated?"active":"not active",event_parameters:{page_group:b,position:r.title,button_name:f,info:e?.alpcData?.id?.toString()}})):R()},f=p(()=>e.productVariant?.availableForSale?i?r.btnRedeem:r.unlockRewards:r?.soldOut||"Sold Out",[i,e.productVariant?.availableForSale,r.btnRedeem,r.unlockRewards,r?.soldOut]),F=p(()=>{const l=n==="us"?"":`/${n}`;return S(e.productVariant?.id)?`${l}/products/${e.product.handle}?variant=${S(e.productVariant?.id)}${o?`&ref=${o}`:""}`:`${l}/products/${e.product.handle}${o?`?ref=${o}`:""}`},[e.productVariant?.id,e.product.handle,o,n]);return d("div",{className:s("relative flex flex-col items-center rounded-[16px] bg-[#EAEAEC] md:rounded-[12px] px-[24px] pb-[24px] l:px-[8px] l:pb-[8px] md-xl:px-[16px] md-xl:pb-[16px]",!v&&"rounded-none md:rounded-none",r.badgeLabel?"pt-[48px] l:pt-[44px]":"pt-[24px] md-xl:pt-[16px] l:pt-[8px]",y),children:[r.badgeLabel&&t(L,{className:"absolute left-[24px] l:left-[16px] !bg-gradient-brand top-[16px] z-10",size:"lg",variant:"promotional",promotionalType:"regular-member",children:r.badgeLabel}),t("a",{href:F,className:s("relative mx-auto h-[196px] w-fit md:h-[120px] md-xxl:h-[138px]"),children:t(N,{className:"mx-auto h-full w-auto",imgClassName:"h-full object-contain",source:e?.config?.image?.url||e?.productVariant?.metafields?.global?.transparentImg||e?.productVariant?.image?.url})}),d("div",{className:s("mt-[10px] w-full xl:mt-[8px]"),children:[t(x,{html:e?.product?.title,title:e.config?.title||e.alpcData?.title||e.product?.title,size:2,className:"line-clamp-2 h-[58px] text-[24px] l-xxl:text-[20px] l:text-[16px] leading-[1.2] l:h-[38px] l-xxl:h-[48px]"}),e?.config?.rules?.split("<br>")?.length>0&&t("button",{type:"button",onClick:()=>{w(e?.config?.rules?.split("<br>")),V({event:"ga4Event",event_name:"lp_button",member_active_status:a?.activated?"active":"not active",event_parameters:{page_group:b,position:r.title,button_name:c?.ruleLabel,info:e?.alpcData?.id?.toString()}})},className:"mt-[8px] text-[16px] font-bold underline xxl:text-[14px]",tabIndex:0,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&l.preventDefault()},children:c?.ruleLabel}),d("div",{className:"flex flex-wrap items-center l:mt-[12px] md:min-h-[46px] laptop:text-[16px] lg-desktop:text-[18px]",children:[t(N,{className:"size-[24px] l-xxl:size-[22px] md-l:size-[18px] md:size-[16px]",source:"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/icon_hire_purchase.png?v=1757496783"}),t(x,{html:`${O(e?.alpcData?.consumeCredits,n)} + ${_({amount:Number(e?.config?.price),currencyCode:e?.productVariant?.price.currencyCode||"USD",locale:n})}`,size:2,as:"p",className:"ml-[4px] mt-[4px] font-bold leading-none text-[24px] l-xxl:text-[20px] l:text-[16px]"}),t(x,{html:_({amount:e?.productVariant?.price.amount,currencyCode:e?.productVariant?.price.currencyCode||"USD",locale:n}),className:"l-xxl:text-[20px] mt-[4px] l:text-[16px] ml-[4px] font-bold leading-[1.2] tracking-[-0.8px] text-[#4A4C56] line-through",as:"p"})]}),d("div",{className:"group relative w-full mt-[8px]",children:[t(A,{disabled:k,variant:"primary",size:"lg",className:"mt-[8px] md:px-[10px] l:w-full",loading:I,onClick:()=>{E()},title:u?c.insufficientCredits:f,children:f}),t("div",{className:s("absolute -bottom-[20px] left-0 z-10 w-[300px] translate-y-full opacity-0 transition-opacity group-hover:opacity-100 md:-bottom-[14px] md:w-[160px]",u?"block":"hidden"),children:d("div",{className:s("relative rounded-[10px] bg-[#6D6D6F] p-[16px] text-[14px] font-medium text-white shadow md:px-[10px] md:py-[8px]",!v&&"rounded-none"),children:[t(x,{as:"p",size:"2",html:c?.insufficientCredits,className:"text-[14px]"}),t("div",{className:"absolute -top-[10px] left-[48px] mb-2 size-[16px] origin-top-left rotate-45 transform rounded-[2px] bg-[#6D6D6F]"})]})})]})]}),h&&t("div",{className:"mt-[8px] text-[14px] text-[#FF0000]",children:h})]})}var te=G;export{te as default};
|
|
2
2
|
//# sourceMappingURL=RedeemableItem.js.map
|