@anker-in/campaign-ui 0.4.3 → 0.4.4
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/creditsCash/CreditsCash.js +1 -1
- package/dist/cjs/components/credits/creditsCash/CreditsCash.js.map +2 -2
- package/dist/cjs/components/credits/creditsCash/RedeemableItem.js +1 -1
- package/dist/cjs/components/credits/creditsCash/RedeemableItem.js.map +3 -3
- package/dist/cjs/components/credits/creditsCash/type.d.ts +0 -2
- package/dist/cjs/components/credits/creditsCash/type.js +1 -1
- package/dist/cjs/components/credits/creditsCash/type.js.map +1 -1
- package/dist/cjs/components/credits/creditsMemberPrice/CreditsMemberPrice.js +1 -1
- package/dist/cjs/components/credits/creditsMemberPrice/CreditsMemberPrice.js.map +2 -2
- package/dist/cjs/components/credits/creditsMemberPrice/MemberPriceItem.js +1 -1
- package/dist/cjs/components/credits/creditsMemberPrice/MemberPriceItem.js.map +3 -3
- package/dist/cjs/components/credits/creditsMemberPrice/type.d.ts +0 -2
- package/dist/cjs/components/credits/creditsMemberPrice/type.js.map +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/CreditsRedeemList.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/CreditsRedeemList.js.map +2 -2
- package/dist/cjs/components/credits/creditsRedeemList/RedeemableItem.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/RedeemableItem.js.map +3 -3
- package/dist/cjs/components/credits/creditsRedeemList/type.d.ts +0 -1
- package/dist/cjs/components/credits/creditsRedeemList/type.js.map +1 -1
- package/dist/cjs/components/credits/type.d.ts +0 -1
- package/dist/cjs/components/credits/type.js.map +1 -1
- package/dist/esm/components/credits/creditsCash/CreditsCash.js +1 -1
- package/dist/esm/components/credits/creditsCash/CreditsCash.js.map +2 -2
- package/dist/esm/components/credits/creditsCash/RedeemableItem.js +1 -1
- package/dist/esm/components/credits/creditsCash/RedeemableItem.js.map +3 -3
- package/dist/esm/components/credits/creditsCash/type.d.ts +0 -2
- package/dist/esm/components/credits/creditsMemberPrice/CreditsMemberPrice.js +1 -1
- package/dist/esm/components/credits/creditsMemberPrice/CreditsMemberPrice.js.map +2 -2
- package/dist/esm/components/credits/creditsMemberPrice/MemberPriceItem.js +1 -1
- package/dist/esm/components/credits/creditsMemberPrice/MemberPriceItem.js.map +3 -3
- package/dist/esm/components/credits/creditsMemberPrice/type.d.ts +0 -2
- package/dist/esm/components/credits/creditsRedeemList/CreditsRedeemList.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/CreditsRedeemList.js.map +2 -2
- package/dist/esm/components/credits/creditsRedeemList/RedeemableItem.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/RedeemableItem.js.map +3 -3
- package/dist/esm/components/credits/creditsRedeemList/type.d.ts +0 -1
- package/dist/esm/components/credits/type.d.ts +0 -1
- package/package.json +19 -19
- package/src/components/credits/creditsCash/CreditsCash.tsx +0 -1
- package/src/components/credits/creditsCash/RedeemableItem.tsx +8 -7
- package/src/components/credits/creditsCash/type.ts +1 -2
- package/src/components/credits/creditsMemberPrice/CreditsMemberPrice.tsx +0 -1
- package/src/components/credits/creditsMemberPrice/MemberPriceItem.tsx +8 -10
- package/src/components/credits/creditsMemberPrice/type.ts +1 -2
- package/src/components/credits/creditsRedeemList/CreditsRedeemList.tsx +0 -1
- package/src/components/credits/creditsRedeemList/RedeemableItem.tsx +5 -7
- package/src/components/credits/creditsRedeemList/type.ts +0 -1
- package/src/components/credits/type.ts +0 -1
- package/dist/cjs/helpers/fetchResponse.d.ts +0 -14
- package/dist/cjs/helpers/fetchResponse.js +0 -2
- package/dist/cjs/helpers/fetchResponse.js.map +0 -7
- package/dist/cjs/helpers/fetcher.d.ts +0 -2
- package/dist/cjs/helpers/fetcher.js +0 -2
- package/dist/cjs/helpers/fetcher.js.map +0 -7
- package/dist/cjs/helpers/index.d.ts +0 -2
- package/dist/cjs/helpers/index.js +0 -2
- package/dist/cjs/helpers/index.js.map +0 -7
- package/dist/cjs/helpers/utils.d.ts +0 -3
- package/dist/cjs/helpers/utils.js +0 -2
- package/dist/cjs/helpers/utils.js.map +0 -7
- package/dist/cjs/tsconfig.tsbuildinfo +0 -1
- package/dist/esm/helpers/fetchResponse.d.ts +0 -14
- package/dist/esm/helpers/fetchResponse.js +0 -2
- package/dist/esm/helpers/fetchResponse.js.map +0 -7
- package/dist/esm/helpers/fetcher.d.ts +0 -2
- package/dist/esm/helpers/fetcher.js +0 -2
- package/dist/esm/helpers/fetcher.js.map +0 -7
- package/dist/esm/helpers/index.d.ts +0 -2
- package/dist/esm/helpers/index.js +0 -2
- package/dist/esm/helpers/index.js.map +0 -7
- package/dist/esm/helpers/utils.d.ts +0 -3
- package/dist/esm/helpers/utils.js +0 -2
- package/dist/esm/helpers/utils.js.map +0 -7
- package/dist/esm/tsconfig.tsbuildinfo +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/components/credits/creditsRedeemList/CreditsRedeemList.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Container, Heading, Tabs, TabsList, TabsTrigger } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport { useCallback, useMemo, useState } from 'react'\n\nimport RedeemCouponModal from './RedeemCouponModal'\nimport RedeemProductModal from './RedeemProductModal'\nimport RedeemVirtualProductModal from './RedeemVirtualProductModal'\nimport { useCreditsContext } from '../context/provider'\nimport useRedeemableList from '../context/hooks/useRedeemableList'\nimport { AlpcConsumeType, AlpcErrorCode, ConsumeType } from '../context/const'\nimport { useHeadlessContext, useProductsByHandles, gaTrack, classNames as cn } from '@anker-in/lib'\nimport type { RedeemableItem as RedeemableItemType } from '../type'\nimport { RedeemableItem } from './RedeemableItem'\nimport { ROUNDED_BRANDS } from '../../../constants'\nimport RulesModal from '../modal/RulesModal'\nimport { CreditsRedeemListCopy } from './type'\nimport { useRegistration } from '../../../components/registration'\nimport { numberFormat } from '../context/utils'\nimport useMyRewards from '../context/hooks/useMyRewards'\n\nexport const CreditsRedeemList = ({ copy, id }: { copy: CreditsRedeemListCopy; id?: string }) => {\n const {\n profile,\n openSignUpPopup,\n gtm: { pageGroup },\n pageCommon,\n creditInfo,\n } = useCreditsContext()\n const { authCodeActivate } = useRegistration()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const isLogin = Object.keys(profile || {}).length > 0\n\n const [activeTab, setActiveTab] = useState<string>(copy.list?.[0]?.label || '')\n\n const [popRedeemData, setPopRedeemData] = useState<RedeemableItemType | undefined>(undefined)\n\n const [rules, setRules] = useState<string | string[]>()\n\n const { listLoading, redeemableList, getRedeemableList } = useRedeemableList()\n\n // \u83B7\u53D6\u7528\u6237\u7684 ExternalProduct \u5151\u6362\u8BB0\u5F55\n const { myRewards } = useMyRewards({\n page: 1,\n pageSize: 100,\n consumeType: AlpcConsumeType.ExternalProduct,\n })\n\n // \u5408\u5E76 redeemModal \u6587\u6848\uFF0C\u4F18\u5148\u4F7F\u7528 copy.redeemModal\uFF0Cfallback \u5230 pageCommon.redeemModal\n const redeemModalCopy = useMemo(() => {\n return {\n ...(pageCommon?.redeemModal || {}),\n ...(copy.redeemModal || {}),\n }\n }, [copy.redeemModal, pageCommon?.redeemModal])\n\n const alpcList = useMemo(() => {\n return redeemableList.map(item => {\n return {\n id: item.id.toString(),\n title: item.name,\n consumeCredits: item.consume_credits,\n remainingInventory: item.remaining_inventory,\n isLimited: !!item.is_limited,\n consumeType: item.consume_type,\n handle: item.sku_handle,\n sku: item.goods_sku,\n image: item.goods_url,\n }\n })\n }, [copy.list, activeTab, redeemableList])\n\n const handles = alpcList.map(item => item.handle)\n const { data: products } = useProductsByHandles({ handles })\n\n const list = useMemo(() => {\n const currentList = copy.list?.find(item => item.label === activeTab)\n return (currentList?.list || [])\n .filter(item => alpcList.some(alpcItem => String(alpcItem.id) === String(item.id)))\n .map(item => {\n const alpcItem = alpcList.find(alpcItem => String(alpcItem.id) === String(item.id))\n const product = products?.find(product => product.handle === alpcItem?.handle)\n const variant = product?.variants.find(variant => variant.sku === alpcItem?.sku)\n // \u8FC7\u6EE4\u6389\u5E93\u5B58\u4E0D\u8DB3\u7684\u5546\u54C1\n if (alpcItem?.isLimited && (!alpcItem?.remainingInventory || alpcItem.remainingInventory <= 0)) return null\n if (alpcItem?.consumeType === AlpcConsumeType.Product && (!product || !variant)) return null\n\n // \u68C0\u67E5 GoGift \u662F\u5426\u5DF2\u7ECF\u5151\u6362\u8FC7\uFF08\u53EA\u6709 GoGift \u9650\u5236\u5151\u6362\u4E00\u6B21\uFF09\n const hasRedeemed = item.type === ConsumeType.GoGift &&\n isLogin &&\n myRewards.some(reward => reward.rule_id === Number(item.id))\n\n return {\n alpc: alpcList.find(alpcItem => String(alpcItem.id) === String(item.id)),\n config: item,\n product,\n variant,\n hasRedeemed,\n
|
|
5
|
-
"mappings": "skBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,uBAAAE,KAAA,eAAAC,GAAAH,
|
|
4
|
+
"sourcesContent": ["import { Container, Heading, Tabs, TabsList, TabsTrigger } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport { useCallback, useMemo, useState } from 'react'\n\nimport RedeemCouponModal from './RedeemCouponModal'\nimport RedeemProductModal from './RedeemProductModal'\nimport RedeemVirtualProductModal from './RedeemVirtualProductModal'\nimport { useCreditsContext } from '../context/provider'\nimport useRedeemableList from '../context/hooks/useRedeemableList'\nimport { AlpcConsumeType, AlpcErrorCode, ConsumeType } from '../context/const'\nimport { useHeadlessContext, useProductsByHandles, gaTrack, classNames as cn } from '@anker-in/lib'\nimport type { RedeemableItem as RedeemableItemType } from '../type'\nimport { RedeemableItem } from './RedeemableItem'\nimport { ROUNDED_BRANDS } from '../../../constants'\nimport RulesModal from '../modal/RulesModal'\nimport { CreditsRedeemListCopy } from './type'\nimport { useRegistration } from '../../../components/registration'\nimport { numberFormat } from '../context/utils'\nimport useMyRewards from '../context/hooks/useMyRewards'\n\nexport const CreditsRedeemList = ({ copy, id }: { copy: CreditsRedeemListCopy; id?: string }) => {\n const {\n profile,\n openSignUpPopup,\n gtm: { pageGroup },\n pageCommon,\n creditInfo,\n } = useCreditsContext()\n const { authCodeActivate } = useRegistration()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const isLogin = Object.keys(profile || {}).length > 0\n\n const [activeTab, setActiveTab] = useState<string>(copy.list?.[0]?.label || '')\n\n const [popRedeemData, setPopRedeemData] = useState<RedeemableItemType | undefined>(undefined)\n\n const [rules, setRules] = useState<string | string[]>()\n\n const { listLoading, redeemableList, getRedeemableList } = useRedeemableList()\n\n // \u83B7\u53D6\u7528\u6237\u7684 ExternalProduct \u5151\u6362\u8BB0\u5F55\n const { myRewards } = useMyRewards({\n page: 1,\n pageSize: 100,\n consumeType: AlpcConsumeType.ExternalProduct,\n })\n\n // \u5408\u5E76 redeemModal \u6587\u6848\uFF0C\u4F18\u5148\u4F7F\u7528 copy.redeemModal\uFF0Cfallback \u5230 pageCommon.redeemModal\n const redeemModalCopy = useMemo(() => {\n return {\n ...(pageCommon?.redeemModal || {}),\n ...(copy.redeemModal || {}),\n }\n }, [copy.redeemModal, pageCommon?.redeemModal])\n\n const alpcList = useMemo(() => {\n return redeemableList.map(item => {\n return {\n id: item.id.toString(),\n title: item.name,\n consumeCredits: item.consume_credits,\n remainingInventory: item.remaining_inventory,\n isLimited: !!item.is_limited,\n consumeType: item.consume_type,\n handle: item.sku_handle,\n sku: item.goods_sku,\n image: item.goods_url,\n }\n })\n }, [copy.list, activeTab, redeemableList])\n\n const handles = alpcList.map(item => item.handle)\n const { data: products } = useProductsByHandles({ handles })\n\n const list = useMemo(() => {\n const currentList = copy.list?.find(item => item.label === activeTab)\n return (currentList?.list || [])\n .filter(item => alpcList.some(alpcItem => String(alpcItem.id) === String(item.id)))\n .map(item => {\n const alpcItem = alpcList.find(alpcItem => String(alpcItem.id) === String(item.id))\n const product = products?.find(product => product.handle === alpcItem?.handle)\n const variant = product?.variants.find(variant => variant.sku === alpcItem?.sku)\n // \u8FC7\u6EE4\u6389\u5E93\u5B58\u4E0D\u8DB3\u7684\u5546\u54C1\n if (alpcItem?.isLimited && (!alpcItem?.remainingInventory || alpcItem.remainingInventory <= 0)) return null\n if (alpcItem?.consumeType === AlpcConsumeType.Product && (!product || !variant)) return null\n\n // \u68C0\u67E5 GoGift \u662F\u5426\u5DF2\u7ECF\u5151\u6362\u8FC7\uFF08\u53EA\u6709 GoGift \u9650\u5236\u5151\u6362\u4E00\u6B21\uFF09\n const hasRedeemed = item.type === ConsumeType.GoGift &&\n isLogin &&\n myRewards.some(reward => reward.rule_id === Number(item.id))\n\n return {\n alpc: alpcList.find(alpcItem => String(alpcItem.id) === String(item.id)),\n config: item,\n product,\n variant,\n hasRedeemed,\n }\n })\n .filter(item => item !== null) as unknown as RedeemableItemType[]\n }, [alpcList, products, isLogin, myRewards])\n\n const handleRedeemError = useCallback(\n (errorCode: AlpcErrorCode) => {\n if (errorCode === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n getRedeemableList()\n }\n },\n [getRedeemableList]\n )\n\n return (\n <Container id={id} className={classNames('relative bg-[#F5F5F7]')}>\n <Heading as=\"h2\" size=\"4\" html={copy.title} />\n\n {/* \u53EF\u7528\u79EF\u5206\u5C55\u793A */}\n {isLogin && copy.availableCredits && (\n <p className=\"mt-[12px] text-[20px] l-xxl:text-[18px] l:text-[16px] font-bold text-[#4A4C56]\">\n {copy.availableCredits.includes('$credits') ? (\n <>\n {copy.availableCredits.split('$credits')[0]}\n <span\n className={cn(\n 'text-brand-color-0',\n brand === 'ankersolix' &&\n 'bg-gradient-to-r from-[#2c7ed0] via-[#00a9e1] via-[43%] to-[#00db84] bg-clip-text text-transparent'\n )}\n >\n {numberFormat(creditInfo?.available_credit || 0).toString()}\n </span>\n {copy.availableCredits.split('$credits')[1] || ''}\n </>\n ) : (\n copy.availableCredits\n )}\n </p>\n )}\n\n <Tabs\n shape={rounded ? 'rounded' : 'square'}\n align=\"left\"\n className={classNames('py-[24px] md:justify-center')}\n value={activeTab.toString()}\n onValueChange={value => {\n setActiveTab(value)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_navigation',\n event_parameters: {\n navigation: value,\n page_group: pageGroup,\n },\n })\n }}\n >\n <TabsList>\n {(copy.list || []).map(item => (\n <TabsTrigger key={item.label} value={item.label}>\n {item.label}\n </TabsTrigger>\n ))}\n </TabsList>\n </Tabs>\n {/* PC\u7AEF */}\n {!!alpcList?.length && !listLoading && (\n <div\n className={classNames('relative grid grid-cols-4 gap-[16px] md:grid-cols-2 md:gap-[12px] md-xl:grid-cols-3')}\n >\n {list?.map(item => (\n <RedeemableItem\n key={item?.alpc?.id}\n copy={copy}\n item={item}\n onRedeem={(item: RedeemableItemType) => {\n if (!isLogin) {\n openSignUpPopup()\n } else if (!profile?.activated && !authCodeActivate.isActivateSuccess) {\n authCodeActivate.setAutoSendEmail(true)\n authCodeActivate.open()\n } else {\n setPopRedeemData(item)\n }\n }}\n onRulesOpen={setRules}\n />\n ))}\n </div>\n )}\n\n {(popRedeemData?.config?.type === ConsumeType.Coupon ||\n popRedeemData?.config?.type === ConsumeType.ShippingCoupon) &&\n redeemModalCopy?.coupon &&\n popRedeemData && (\n <RedeemCouponModal\n item={popRedeemData}\n copy={redeemModalCopy}\n onError={handleRedeemError}\n onClose={() => {\n setPopRedeemData(undefined)\n }}\n />\n )}\n {popRedeemData?.config?.type === ConsumeType.Product && redeemModalCopy?.product && popRedeemData && (\n <RedeemProductModal\n item={popRedeemData}\n copy={redeemModalCopy}\n onError={handleRedeemError}\n onClose={() => {\n setPopRedeemData(undefined)\n }}\n />\n )}\n {(popRedeemData?.config?.type === ConsumeType.GiftCard || popRedeemData?.config?.type === ConsumeType.GoGift) &&\n redeemModalCopy?.virtualProduct &&\n popRedeemData && (\n <RedeemVirtualProductModal\n item={popRedeemData}\n copy={redeemModalCopy}\n onError={handleRedeemError}\n onClose={() => {\n setPopRedeemData(undefined)\n }}\n />\n )}\n {rules && (\n <RulesModal\n overlayClassName=\"md:px-[16px] md:items-center\"\n className={cn('md:h-fit md:rounded-b-[16px]', !rounded && 'md:rounded-none')}\n isOpen={rules.length > 0}\n onClose={() => setRules([])}\n titleClassName=\"border-b-transparent h-[56px]\"\n rules={rules}\n scrollClassName=\"md:mt-[8px] md:mb-[24px] md:pt-0\"\n title={pageCommon?.ruleLabel}\n ruleClassName=\"text-[#1d1d1f] font-bold\"\n />\n )}\n </Container>\n )\n}\n"],
|
|
5
|
+
"mappings": "skBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,uBAAAE,KAAA,eAAAC,GAAAH,IAmHM,IAAAI,EAAA,6BAnHNC,EAAgE,iCAChEC,EAAuB,yBACvBC,EAA+C,iBAE/CC,EAA8B,kCAC9BC,EAA+B,mCAC/BC,EAAsC,0CACtCC,EAAkC,+BAClCC,EAA8B,iDAC9BC,EAA4D,4BAC5DC,EAAoF,yBAEpFC,EAA+B,4BAC/BC,EAA+B,8BAC/BC,EAAuB,kCAEvBC,EAAgC,4CAChCC,EAA6B,4BAC7BC,EAAyB,4CAElB,MAAMlB,GAAoB,CAAC,CAAE,KAAAmB,EAAM,GAAAC,CAAG,IAAoD,CAC/F,KAAM,CACJ,QAAAC,EACA,gBAAAC,EACA,IAAK,CAAE,UAAAC,CAAU,EACjB,WAAAC,EACA,WAAAC,CACF,KAAI,qBAAkB,EAChB,CAAE,iBAAAC,CAAiB,KAAI,mBAAgB,EACvC,CAAE,MAAAC,CAAM,KAAI,sBAAmB,EAC/BC,EAAU,iBAAe,SAASD,CAAK,EAEvCE,EAAU,OAAO,KAAKR,GAAW,CAAC,CAAC,EAAE,OAAS,EAE9C,CAACS,EAAWC,CAAY,KAAI,YAAiBZ,EAAK,OAAO,CAAC,GAAG,OAAS,EAAE,EAExE,CAACa,EAAeC,CAAgB,KAAI,YAAyC,MAAS,EAEtF,CAACC,EAAOC,CAAQ,KAAI,YAA4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AC,CAAC,EAC1B,eAAe,gCACf,MAAOD,EACP,gBAAgB,mCAChB,MAAOV,GAAY,UACnB,cAAc,2BAChB,GAEJ,CAEJ",
|
|
6
6
|
"names": ["CreditsRedeemList_exports", "__export", "CreditsRedeemList", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_classnames", "import_react", "import_RedeemCouponModal", "import_RedeemProductModal", "import_RedeemVirtualProductModal", "import_provider", "import_useRedeemableList", "import_const", "import_lib", "import_RedeemableItem", "import_constants", "import_RulesModal", "import_registration", "import_utils", "import_useMyRewards", "copy", "id", "profile", "openSignUpPopup", "pageGroup", "pageCommon", "creditInfo", "authCodeActivate", "brand", "rounded", "isLogin", "activeTab", "setActiveTab", "popRedeemData", "setPopRedeemData", "rules", "setRules", "listLoading", "redeemableList", "getRedeemableList", "useRedeemableList", "myRewards", "useMyRewards", "redeemModalCopy", "alpcList", "item", "handles", "products", "list", "alpcItem", "product", "variant", "hasRedeemed", "reward", "handleRedeemError", "errorCode", "classNames", "cn", "value", "RedeemCouponModal", "RedeemProductModal", "RedeemVirtualProductModal", "RulesModal"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var k=Object.create;var f=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)f(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&&f(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?f(e,"default",{value:t,enumerable:!0}):e,t)),F=t=>N(f({},"__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"),v=require("react"),g=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:b}=(0,u.useHeadlessContext)(),x=Object.keys(p||{}).length>0,w=T.ROUNDED_BRANDS.includes($),I=(0,v.useMemo)(()=>!!(e.hasRedeemed||e.alpc?.remainingInventory<=0&&e.alpc?.isLimited||e.alpc?.consumeType===i.AlpcConsumeType.Product&&!e.variant?.availableForSale||x&&p?.activated&&e.alpc?.consumeCredits>Number(h?.available_credit||0)),[e.hasRedeemed,e.alpc?.remainingInventory,e.alpc?.isLimited,e.alpc?.consumeType,e.alpc?.consumeCredits,x,p?.activated,h?.available_credit,e.variant?.availableForSale]),_=(0,v.useMemo)(()=>x?e.alpc?.consumeType===i.AlpcConsumeType.Product?e.variant?.availableForSale?t.btnRedeem:d?.soldOut||"Sold Out":t.btnRedeem:t.unlockRewards,[x,e.alpc?.consumeType,e.variant?.availableForSale,t.btnRedeem,t.unlockRewards,d?.soldOut]),P=(0,v.useMemo)(()=>{if(e.config?.type!==i.ConsumeType.Product||!e.product?.handle)return;const o=b==="us"?"":`/${b}`;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,b]);return(0,a.jsxs)("div",{className:(0,g.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,g.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,g.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)}`,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 } = 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.
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,
|
|
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", "isLogin", "rounded", "isDisabled", "redeemButtonText", "productUrl", "classNames", "e"]
|
|
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,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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OAAO,6FACT,KACA,OAAC,QACC,KAAM,MAAG,gBAAaP,EAAK,MAAM,cAAc,CAAC,GAChD,KAAM,EACN,GAAG,IACH,UAAU,wFACZ,GACF,KAEA,OAAC,UACC,SAAUY,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
|
+
"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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/components/credits/creditsRedeemList/type.ts"],
|
|
4
|
-
"sourcesContent": ["export type CreditsRedeemListCopy = {\n title: string\n availableCredits: string\n unlockRewards: string\n btnRedeem: string\n list: {\n label: string\n list: {\n id: string\n type: string\n value: string\n rules: string[]\n
|
|
4
|
+
"sourcesContent": ["export type CreditsRedeemListCopy = {\n title: string\n availableCredits: string\n unlockRewards: string\n btnRedeem: string\n list: {\n label: string\n list: {\n id: string\n type: string\n value: string\n rules: string[]\n }[]\n }[]\n redeemModal: {\n confirmTitle: string\n confirmButton: string\n commonError: string\n redeemLimitError: string\n inventoryNotEnough: string\n creditsNotEnough: string\n crossSiteError: string\n errorImageUrl: string\n coupon: {\n successDesc: string\n successTitle: string\n successButton: string\n successButtonUrl: string\n }\n virtualProduct: {\n successDesc: string\n successTitle: string\n successButton: string\n successButtonUrl: string\n stepTitle?: string\n steps?: {\n imageUrl: string\n title: string\n }[]\n }\n product: {\n required: string\n invalidEmail: string\n shippingAddress: string\n shippingProduct: string\n addressForm: {\n key: string\n type: string\n label: string\n isSelect: boolean\n required: boolean\n placeholder: string\n }[][]\n form: {\n key: string\n type: string\n isSelect: boolean\n required: boolean\n placeholder: string\n }[][]\n successDesc: string[]\n rules: string[]\n steps: {\n imageUrl: string\n title: string\n }[]\n quantityLabel: string\n totalPriceLabel: string\n variantLabel: string\n shippingFeeLabel: string\n paymentButton: string\n stepTitle: string\n }\n }\n}\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["type_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/credits/type.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Product, ProductVariant } from '@anker-in/lib'\nimport type { AlpcConsumeType, ConsumeType } from './context/const'\nimport { MyActivitiesMetafields } from './modal/ActivitiesModal'\nimport { RewardsCopy } from './modal/RewardsModal'\n\nexport interface Subscription {\n preference: {\n subscribe: boolean\n brand: string\n }[]\n}\n\nexport type RedeemableItem = {\n config: {\n title: string\n desc: string\n rules: string[]\n image: {\n url: string\n }\n type: ConsumeType\n value: string\n }\n alpc: {\n id: string\n consumeCredits: number\n remainingInventory: number\n isLimited: boolean\n consumeType: AlpcConsumeType\n showCredit: boolean\n title: string\n }\n product?: Product\n variant?: ProductVariant\n hasRedeemed?: boolean\n
|
|
4
|
+
"sourcesContent": ["import type { Product, ProductVariant } from '@anker-in/lib'\nimport type { AlpcConsumeType, ConsumeType } from './context/const'\nimport { MyActivitiesMetafields } from './modal/ActivitiesModal'\nimport { RewardsCopy } from './modal/RewardsModal'\n\nexport interface Subscription {\n preference: {\n subscribe: boolean\n brand: string\n }[]\n}\n\nexport type RedeemableItem = {\n config: {\n title: string\n desc: string\n rules: string[]\n image: {\n url: string\n }\n type: ConsumeType\n value: string\n }\n alpc: {\n id: string\n consumeCredits: number\n remainingInventory: number\n isLimited: boolean\n consumeType: AlpcConsumeType\n showCredit: boolean\n title: string\n }\n product?: Product\n variant?: ProductVariant\n hasRedeemed?: boolean\n}\n\nexport interface ShippingCountry {\n id: string\n name: string\n code: string\n provinces: {\n id: string\n name: string\n code: string\n }[]\n}\n\nexport interface ShippingZone {\n name: string\n countries: ShippingCountry[]\n}\n\nexport type RedeemModalCommon = {\n confirmTitle: string\n confirmButton: string\n commonError: string\n redeemLimitError: string\n inventoryNotEnough: string\n creditsNotEnough: string\n crossSiteError: string\n errorImageUrl: string\n coupon: {\n successDesc: string\n successTitle: string\n successButton: string\n successButtonUrl: string\n }\n virtualProduct: {\n successDesc: string\n successTitle: string\n successButton: string\n successButtonUrl: string\n stepTitle?: string\n steps?: {\n imageUrl: string\n title: string\n }[]\n }\n product: {\n required: string\n invalidEmail: string\n shippingAddress: string\n shippingProduct: string\n addressForm: {\n key: string\n type: string\n label: string\n isSelect: boolean\n required: boolean\n placeholder: string\n }[][]\n form: {\n key: string\n type: string\n isSelect: boolean\n required: boolean\n placeholder: string\n }[][]\n successDesc: string[]\n rules: string[]\n steps: {\n imageUrl: string\n title: string\n }[]\n quantityLabel: string\n totalPriceLabel: string\n variantLabel: string\n shippingFeeLabel: string\n paymentButton: string\n stepTitle: string\n }\n}\n\nexport type CreditsPageCommon = {\n pointUnit?: string\n infoIcon?: string\n ruleLabel?: string\n soldOut?: string\n redeemed?: string\n copied?: string\n off?: string\n copy?: string\n giftCardLabel?: string\n goGiftLabel?: string\n imageMapping?: {\n [key in ConsumeType]: {\n url: string\n }\n }\n activitiesModal?: MyActivitiesMetafields\n rewardsModal?: RewardsCopy\n redeemModal?: RedeemModalCommon\n insufficientCredits?: string\n validatorInfo?: {\n addressInfo: {\n name: string\n country: string\n province: string\n city: string\n address: string\n }\n }\n}\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["type_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as i,jsxs as
|
|
1
|
+
import{jsx as i,jsxs as B}from"react/jsx-runtime";import{Container as b,Heading as h}from"@anker-in/headless-ui";import{useMemo as y,useState as v}from"react";import N from"./RedeemableItem";import R from"../context/hooks/useRedeemableList";import D from"../modal/RulesModal";import{useProductsByHandles as I,useHeadlessContext as S}from"@anker-in/lib";import{classNames as c}from"@anker-in/lib";import{useCreditsContext as _}from"../context/provider";import{ROUNDED_BRANDS as k}from"../../../constants";const K=({copy:s,id:p})=>{const[a,d]=v(),{redeemableList:m}=R(),{pageCommon:u}=_(),{brand:f}=S(),C=k.includes(f),g=[],{data:o}=I({handles:s?.list?.map(e=>e.products?.[0]?.handle)||[],metafieldIdentifiers:{variant:g}}),x=y(()=>o?.map(e=>{const r=(s.list||[]).find(n=>n.products?.[0]?.handle===e.handle),t=m.find(n=>n.id?.toString()===r?.redeemId?.toString()),l=e.variants?.find(n=>n.sku===r?.products?.[0]?.sku)||e.variants?.[0];return!t||!l?null:{product:e,productVariant:l,alpcData:{id:t?.id,consumeCredits:t?.consume_credits,remainingInventory:t?.remaining_inventory,isLimited:t?.is_limited,consumeType:t?.consume_type,title:t?.name,desc:t?.note},config:r}}).filter(Boolean),[o,s.list,m]);return B(b,{id:p,className:c("bg-[#F5F5F5]"),children:[i(h,{as:"h2",size:"4",html:s.title}),i("div",{className:"relative mt-[24px] grid grid-cols-4 gap-[16px] l:gap-[12px] md:grid-cols-2 md-xl:grid-cols-3",children:x?.map((e,r)=>i(N,{copy:s,itemData:e,setRules:d,currencyCode:o?.[0]?.price.currencyCode||"USD"},r))}),a&&i(D,{overlayClassName:"md:px-[16px] md:items-center",className:c("md:h-fit md:rounded-b-[16px]",!C&&"md:rounded-none"),isOpen:a.length>0,onClose:()=>d([]),titleClassName:"border-b-transparent h-[56px]",rules:a,scrollClassName:"md:mt-[8px] md:mb-[24px] md:pt-0",title:u?.ruleLabel,ruleClassName:"text-[#1d1d1f] font-bold"})]})};export{K as CreditsCash};
|
|
2
2
|
//# sourceMappingURL=CreditsCash.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/components/credits/creditsCash/CreditsCash.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Container, Heading, Text } from '@anker-in/headless-ui'\nimport { useMemo, useState } from 'react'\n\nimport RedeemableItem from './RedeemableItem'\nimport useRedeemableList from '../context/hooks/useRedeemableList'\nimport RulesModal from '../modal/RulesModal'\nimport { useProductsByHandles, useHeadlessContext } from '@anker-in/lib'\nimport { CreditsCashCopy, RedeemItem } from './type'\nimport { Product, classNames as cn } from '@anker-in/lib'\nimport { useCreditsContext } from '../context/provider'\nimport { numberFormat } from '../context/utils'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\nexport const CreditsCash = ({ copy, id }: { copy: CreditsCashCopy; id?: string }) => {\n const [rules, setRules] = useState<string | string[]>()\n const { redeemableList } = useRedeemableList()\n const { pageCommon } = useCreditsContext()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const variantMetafieldIdentifiers: any[] = []\n\n const { data: productByHandles } = useProductsByHandles({\n handles: copy?.list?.map(item => item.products?.[0]?.handle) || [],\n metafieldIdentifiers: {\n variant: variantMetafieldIdentifiers,\n },\n })\n\n const list = useMemo(() => {\n return productByHandles\n ?.map((product: Product) => {\n const config = (copy.list || []).find(item => item.products?.[0]?.handle === product.handle)\n const alpcData = redeemableList.find(item => item.id?.toString() === config?.redeemId?.toString())\n const productVariant =\n product.variants?.find((variant: any) => variant.sku === config?.products?.[0]?.sku) || product.variants?.[0]\n if (!alpcData || !productVariant) return null\n return {\n product,\n productVariant,\n
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { Container, Heading, Text } from '@anker-in/headless-ui'\nimport { useMemo, useState } from 'react'\n\nimport RedeemableItem from './RedeemableItem'\nimport useRedeemableList from '../context/hooks/useRedeemableList'\nimport RulesModal from '../modal/RulesModal'\nimport { useProductsByHandles, useHeadlessContext } from '@anker-in/lib'\nimport { CreditsCashCopy, RedeemItem } from './type'\nimport { Product, classNames as cn } from '@anker-in/lib'\nimport { useCreditsContext } from '../context/provider'\nimport { numberFormat } from '../context/utils'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\nexport const CreditsCash = ({ copy, id }: { copy: CreditsCashCopy; id?: string }) => {\n const [rules, setRules] = useState<string | string[]>()\n const { redeemableList } = useRedeemableList()\n const { pageCommon } = useCreditsContext()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const variantMetafieldIdentifiers: any[] = []\n\n const { data: productByHandles } = useProductsByHandles({\n handles: copy?.list?.map(item => item.products?.[0]?.handle) || [],\n metafieldIdentifiers: {\n variant: variantMetafieldIdentifiers,\n },\n })\n\n const list = useMemo(() => {\n return productByHandles\n ?.map((product: Product) => {\n const config = (copy.list || []).find(item => item.products?.[0]?.handle === product.handle)\n const alpcData = redeemableList.find(item => item.id?.toString() === config?.redeemId?.toString())\n const productVariant =\n product.variants?.find((variant: any) => variant.sku === config?.products?.[0]?.sku) || product.variants?.[0]\n if (!alpcData || !productVariant) return null\n return {\n product,\n productVariant,\n alpcData: {\n id: alpcData?.id,\n consumeCredits: alpcData?.consume_credits,\n remainingInventory: alpcData?.remaining_inventory,\n isLimited: alpcData?.is_limited,\n consumeType: alpcData?.consume_type,\n title: alpcData?.name,\n desc: alpcData?.note,\n },\n config,\n }\n })\n .filter(Boolean) as unknown as RedeemItem[]\n }, [productByHandles, copy.list, redeemableList])\n\n return (\n <Container id={id} className={cn('bg-[#F5F5F5]')}>\n <Heading as=\"h2\" size=\"4\" html={copy.title} />\n\n <div className=\"relative mt-[24px] grid grid-cols-4 gap-[16px] l:gap-[12px] md:grid-cols-2 md-xl:grid-cols-3\">\n {list?.map((item, index: number) => (\n <RedeemableItem\n key={index}\n copy={copy}\n itemData={item}\n setRules={setRules}\n currencyCode={productByHandles?.[0]?.price.currencyCode || 'USD'}\n />\n ))}\n </div>\n\n {rules && (\n <RulesModal\n overlayClassName=\"md:px-[16px] md:items-center\"\n className={cn('md:h-fit md:rounded-b-[16px]', !rounded && 'md:rounded-none')}\n isOpen={rules.length > 0}\n onClose={() => setRules([])}\n titleClassName=\"border-b-transparent h-[56px]\"\n rules={rules}\n scrollClassName=\"md:mt-[8px] md:mb-[24px] md:pt-0\"\n title={pageCommon?.ruleLabel}\n ruleClassName=\"text-[#1d1d1f] font-bold\"\n />\n )}\n </Container>\n )\n}\n"],
|
|
5
|
+
"mappings": "AAwDI,OACE,OAAAA,EADF,QAAAC,MAAA,oBAxDJ,OAAS,aAAAC,EAAW,WAAAC,MAAqB,wBACzC,OAAS,WAAAC,EAAS,YAAAC,MAAgB,QAElC,OAAOC,MAAoB,mBAC3B,OAAOC,MAAuB,qCAC9B,OAAOC,MAAgB,sBACvB,OAAS,wBAAAC,EAAsB,sBAAAC,MAA0B,gBAEzD,OAAkB,cAAcC,MAAU,gBAC1C,OAAS,qBAAAC,MAAyB,sBAElC,OAAS,kBAAAC,MAAsB,qBAExB,MAAMC,EAAc,CAAC,CAAE,KAAAC,EAAM,GAAAC,CAAG,IAA8C,CACnF,KAAM,CAACC,EAAOC,CAAQ,EAAIb,EAA4B,EAChD,CAAE,eAAAc,CAAe,EAAIZ,EAAkB,EACvC,CAAE,WAAAa,CAAW,EAAIR,EAAkB,EACnC,CAAE,MAAAS,CAAM,EAAIX,EAAmB,EAC/BY,EAAUT,EAAe,SAASQ,CAAK,EAEvCE,EAAqC,CAAC,EAEtC,CAAE,KAAMC,CAAiB,EAAIf,E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E,OAAQL,EAAM,OAAS,EACvB,QAAS,IAAMC,EAAS,CAAC,CAAC,EAC1B,eAAe,gCACf,MAAOD,EACP,gBAAgB,mCAChB,MAAOG,GAAY,UACnB,cAAc,2BAChB,GAEJ,CAEJ",
|
|
6
6
|
"names": ["jsx", "jsxs", "Container", "Heading", "useMemo", "useState", "RedeemableItem", "useRedeemableList", "RulesModal", "useProductsByHandles", "useHeadlessContext", "cn", "useCreditsContext", "ROUNDED_BRANDS", "CreditsCash", "copy", "id", "rules", "setRules", "redeemableList", "pageCommon", "brand", "rounded", "variantMetafieldIdentifiers", "productByHandles", "item", "list", "product", "config", "alpcData", "productVariant", "variant", "index"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as t,jsxs as
|
|
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:n}}=P(),{authCodeActivate:m}=H(),{brand:z,locale:o}=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=o==="us"?"":`/${o}`;return S(e.productVariant?.id)?`${l}/products/${e.product.handle}?variant=${S(e.productVariant?.id)}${n?`&ref=${n}`:""}`:`${l}/products/${e.product.handle}${n?`?ref=${n}`:""}`},[e.productVariant?.id,e.product.handle,n,o]);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)} + ${_({amount:Number(e?.config?.price),currencyCode:e?.productVariant?.price.currencyCode||"USD",locale:o})}`,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:o}),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
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/components/credits/creditsCash/RedeemableItem.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Button, Text, Picture, Badge } from '@anker-in/headless-ui'\nimport { useMemo, useState } from 'react'\n\nimport { CreditsCashCopy, RedeemItem } from './type'\nimport { useCreditsContext } from '../context/provider'\nimport { useRedeemAndBuy } from '../context/hooks/useRedeemAndBuy'\nimport { formatPrice, numberFormat, extractVariantId } from '../context/utils'\nimport { gaTrack, classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport { useRegistration } from '../../../components/registration'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\nfunction RedeemableItem({\n copy,\n itemData,\n setRules,\n className,\n}: {\n copy: CreditsCashCopy\n itemData: RedeemItem\n className?: string\n setRules: (rules: string[]) => void\n currencyCode: string\n}) {\n const {\n creditInfo,\n profile,\n openSignUpPopup,\n pageCommon,\n gtm: { pageGroup, pageHandle },\n } = useCreditsContext()\n const { authCodeActivate } = useRegistration()\n const { brand, locale } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n const [error, setError] = useState<string | null>(null)\n const { trigger, isMutating } = useRedeemAndBuy(\n {},\n {\n onError: error => {\n setError(error.message)\n },\n }\n )\n\n const isLogin = useMemo(() => {\n return !!profile\n }, [profile?.activated])\n\n const inSufficientCredit = useMemo(() => {\n return (\n isLogin && profile?.activated && itemData.alpcData?.consumeCredits > Number(creditInfo?.available_credit || 0)\n )\n }, [isLogin, profile?.activated, itemData.alpcData?.consumeCredits, creditInfo?.available_credit])\n\n const isDisabled = useMemo(() => {\n // \u5151\u6362\u9650\u5236\n if (itemData.alpcData?.remainingInventory <= 0 && itemData.alpcData?.isLimited) {\n return true\n }\n\n // \u5546\u54C1\u5E93\u5B58\u9650\u5236\n if (!itemData.productVariant?.availableForSale) {\n return true\n }\n\n // \u79EF\u5206\u4E0D\u8DB3\n if (inSufficientCredit) {\n return true\n }\n return false\n }, [\n itemData.alpcData?.remainingInventory,\n itemData.alpcData?.isLimited,\n itemData.productVariant?.availableForSale,\n inSufficientCredit,\n ])\n\n const handleRedeem = () => {\n setError(null)\n if (!isLogin) {\n openSignUpPopup()\n } else if (!profile?.activated && !authCodeActivate.isActivateSuccess) {\n authCodeActivate.setAutoSendEmail(true)\n authCodeActivate.open()\n } else {\n trigger({\n productVariant: itemData?.productVariant,\n redeemId: itemData?.config?.redeemId,\n })\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: itemData?.alpcData?.id?.toString(),\n },\n })\n }\n }\n\n const redeemButtonText = useMemo(() => {\n // \u7F3A\u8D27\u6587\u6848\n if (!itemData.productVariant?.availableForSale) {\n return copy?.soldOut || 'Sold Out'\n } else if (!isLogin) {\n return copy.unlockRewards\n } else {\n return copy.btnRedeem\n }\n }, [isLogin, itemData.productVariant?.availableForSale, copy.btnRedeem, copy.unlockRewards, copy?.soldOut])\n\n return (\n <div\n className={cn(\n '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]',\n !rounded && 'rounded-none md:rounded-none',\n copy.badgeLabel ? 'pt-[48px] l:pt-[44px]' : 'pt-[24px] md-xl:pt-[16px] l:pt-[8px]',\n className\n )}\n >\n {/* Redeem \u6807\u7B7E Badge */}\n {copy.badgeLabel && (\n <Badge\n className=\"absolute left-[24px] l:left-[16px] !bg-gradient-brand top-[16px] z-10\"\n size=\"lg\"\n variant=\"promotional\"\n promotionalType=\"regular-member\"\n >\n {copy.badgeLabel}\n </Badge>\n )}\n\n <a\n href={
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["jsx", "jsxs", "Button", "Text", "Picture", "Badge", "useMemo", "useState", "useCreditsContext", "useRedeemAndBuy", "formatPrice", "numberFormat", "extractVariantId", "gaTrack", "cn", "useHeadlessContext", "useRegistration", "ROUNDED_BRANDS", "RedeemableItem", "copy", "itemData", "setRules", "className", "creditInfo", "profile", "openSignUpPopup", "pageCommon", "pageGroup", "pageHandle", "authCodeActivate", "brand", "locale", "rounded", "error", "setError", "trigger", "isMutating", "isLogin", "inSufficientCredit", "isDisabled", "handleRedeem", "redeemButtonText", "e", "RedeemableItem_default"]
|
|
4
|
+
"sourcesContent": ["import { Button, Text, Picture, Badge } from '@anker-in/headless-ui'\nimport { useMemo, useState } from 'react'\n\nimport { CreditsCashCopy, RedeemItem } from './type'\nimport { useCreditsContext } from '../context/provider'\nimport { useRedeemAndBuy } from '../context/hooks/useRedeemAndBuy'\nimport { formatPrice, numberFormat, extractVariantId } from '../context/utils'\nimport { gaTrack, classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport { useRegistration } from '../../../components/registration'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\nfunction RedeemableItem({\n copy,\n itemData,\n setRules,\n className,\n}: {\n copy: CreditsCashCopy\n itemData: RedeemItem\n className?: string\n setRules: (rules: string[]) => void\n currencyCode: string\n}) {\n const {\n creditInfo,\n profile,\n openSignUpPopup,\n pageCommon,\n gtm: { pageGroup, pageHandle },\n } = useCreditsContext()\n const { authCodeActivate } = useRegistration()\n const { brand, locale } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n const [error, setError] = useState<string | null>(null)\n const { trigger, isMutating } = useRedeemAndBuy(\n {},\n {\n onError: error => {\n setError(error.message)\n },\n }\n )\n\n const isLogin = useMemo(() => {\n return !!profile\n }, [profile?.activated])\n\n const inSufficientCredit = useMemo(() => {\n return (\n isLogin && profile?.activated && itemData.alpcData?.consumeCredits > Number(creditInfo?.available_credit || 0)\n )\n }, [isLogin, profile?.activated, itemData.alpcData?.consumeCredits, creditInfo?.available_credit])\n\n const isDisabled = useMemo(() => {\n // \u5151\u6362\u9650\u5236\n if (itemData.alpcData?.remainingInventory <= 0 && itemData.alpcData?.isLimited) {\n return true\n }\n\n // \u5546\u54C1\u5E93\u5B58\u9650\u5236\n if (!itemData.productVariant?.availableForSale) {\n return true\n }\n\n // \u79EF\u5206\u4E0D\u8DB3\n if (inSufficientCredit) {\n return true\n }\n return false\n }, [\n itemData.alpcData?.remainingInventory,\n itemData.alpcData?.isLimited,\n itemData.productVariant?.availableForSale,\n inSufficientCredit,\n ])\n\n const handleRedeem = () => {\n setError(null)\n if (!isLogin) {\n openSignUpPopup()\n } else if (!profile?.activated && !authCodeActivate.isActivateSuccess) {\n authCodeActivate.setAutoSendEmail(true)\n authCodeActivate.open()\n } else {\n trigger({\n productVariant: itemData?.productVariant,\n redeemId: itemData?.config?.redeemId,\n })\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: itemData?.alpcData?.id?.toString(),\n },\n })\n }\n }\n\n const redeemButtonText = useMemo(() => {\n // \u7F3A\u8D27\u6587\u6848\n if (!itemData.productVariant?.availableForSale) {\n return copy?.soldOut || 'Sold Out'\n } else if (!isLogin) {\n return copy.unlockRewards\n } else {\n return copy.btnRedeem\n }\n }, [isLogin, itemData.productVariant?.availableForSale, copy.btnRedeem, copy.unlockRewards, copy?.soldOut])\n\n const productUrl = useMemo(() => {\n const localePrefix = locale === 'us' ? '' : `/${locale}`\n return extractVariantId(itemData.productVariant?.id)\n ? `${localePrefix}/products/${itemData.product.handle}?variant=${extractVariantId(itemData.productVariant?.id)}${pageHandle ? `&ref=${pageHandle}` : ''}`\n : `${localePrefix}/products/${itemData.product.handle}${pageHandle ? `?ref=${pageHandle}` : ''}`\n }, [itemData.productVariant?.id, itemData.product.handle, pageHandle, locale])\n\n return (\n <div\n className={cn(\n '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]',\n !rounded && 'rounded-none md:rounded-none',\n copy.badgeLabel ? 'pt-[48px] l:pt-[44px]' : 'pt-[24px] md-xl:pt-[16px] l:pt-[8px]',\n className\n )}\n >\n {/* Redeem \u6807\u7B7E Badge */}\n {copy.badgeLabel && (\n <Badge\n className=\"absolute left-[24px] l:left-[16px] !bg-gradient-brand top-[16px] z-10\"\n size=\"lg\"\n variant=\"promotional\"\n promotionalType=\"regular-member\"\n >\n {copy.badgeLabel}\n </Badge>\n )}\n\n <a\n href={productUrl}\n className={cn('relative mx-auto h-[196px] w-fit md:h-[120px] md-xxl:h-[138px]')}\n >\n <Picture\n className=\"mx-auto h-full w-auto\"\n imgClassName=\"h-full object-contain\"\n source={\n itemData?.config?.image?.url ||\n itemData?.productVariant?.metafields?.global?.transparentImg ||\n itemData?.productVariant?.image?.url\n }\n ></Picture>\n </a>\n <div className={cn('mt-[10px] w-full xl:mt-[8px]')}>\n <Text\n html={itemData?.product?.title}\n title={itemData.config?.title || itemData.alpcData?.title || itemData.product?.title}\n size={2}\n 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]\"\n />\n {itemData?.config?.rules?.split('<br>')?.length > 0 && (\n <button\n type=\"button\"\n onClick={() => {\n setRules(itemData?.config?.rules?.split('<br>'))\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: itemData?.alpcData?.id?.toString(),\n },\n })\n }}\n className=\"mt-[8px] text-[16px] font-bold underline xxl:text-[14px]\"\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\n <div className=\"flex flex-wrap items-center l:mt-[12px] md:min-h-[46px] laptop:text-[16px] lg-desktop:text-[18px]\">\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(itemData?.alpcData?.consumeCredits)} + ${formatPrice({\n amount: Number(itemData?.config?.price),\n currencyCode: itemData?.productVariant?.price.currencyCode || 'USD',\n locale: locale,\n })}`}\n size={2}\n as=\"p\"\n className=\"ml-[4px] mt-[4px] font-bold leading-none text-[24px] l-xxl:text-[20px] l:text-[16px]\"\n />\n <Text\n html={formatPrice({\n amount: itemData?.productVariant?.price.amount,\n currencyCode: itemData?.productVariant?.price.currencyCode || 'USD',\n locale: locale,\n })}\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\"\n as=\"p\"\n />\n </div>\n\n <div className=\"group relative w-full mt-[8px]\">\n <Button\n disabled={isDisabled}\n variant=\"primary\"\n size=\"lg\"\n className=\"mt-[8px] md:px-[10px] l:w-full\"\n loading={isMutating}\n onClick={() => {\n handleRedeem()\n }}\n title={inSufficientCredit ? pageCommon.insufficientCredits : redeemButtonText}\n >\n {redeemButtonText}\n </Button>\n <div\n className={cn(\n '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]',\n inSufficientCredit ? 'block' : 'hidden'\n )}\n >\n <div\n className={cn(\n 'relative rounded-[10px] bg-[#6D6D6F] p-[16px] text-[14px] font-medium text-white shadow md:px-[10px] md:py-[8px]',\n !rounded && 'rounded-none'\n )}\n >\n <Text as=\"p\" size=\"2\" html={pageCommon?.insufficientCredits} className=\"text-[14px]\" />\n <div className=\"absolute -top-[10px] left-[48px] mb-2 size-[16px] origin-top-left rotate-45 transform rounded-[2px] bg-[#6D6D6F]\" />\n </div>\n </div>\n </div>\n </div>\n {error && <div className=\"mt-[8px] text-[14px] text-[#FF0000]\">{error}</div>}\n </div>\n )\n}\n\nexport default RedeemableItem\n"],
|
|
5
|
+
"mappings": "AAmIQ,cAAAA,EA4DA,QAAAC,MA5DA,oBAnIR,OAAS,UAAAC,EAAQ,QAAAC,EAAM,WAAAC,EAAS,SAAAC,MAAa,wBAC7C,OAAS,WAAAC,EAAS,YAAAC,MAAgB,QAGlC,OAAS,qBAAAC,MAAyB,sBAClC,OAAS,mBAAAC,MAAuB,mCAChC,OAAS,eAAAC,EAAa,gBAAAC,EAAc,oBAAAC,MAAwB,mBAC5D,OAAS,WAAAC,EAAS,cAAcC,EAAI,sBAAAC,MAA0B,gBAC9D,OAAS,mBAAAC,MAAuB,mCAChC,OAAS,kBAAAC,MAAsB,qBAE/B,SAASC,EAAe,CACtB,KAAAC,EACA,SAAAC,EACA,SAAAC,EACA,UAAAC,CACF,EAMG,CACD,KAAM,CACJ,WAAAC,EACA,QAAAC,EACA,gBAAAC,EACA,WAAAC,EACA,IAAK,CAAE,UAAAC,EAAW,WAAAC,CAAW,CAC/B,EAAIpB,EAAkB,EAChB,CAAE,iBAAAqB,CAAiB,EAAIb,EAAgB,EACvC,CAAE,MAAAc,EAAO,OAAAC,CAAO,EAAIhB,EAAmB,EACvCiB,EAAUf,EAAe,SAASa,CAAK,EACvC,CAACG,EAAOC,CAAQ,EAAI3B,EAAwB,IAAI,EAChD,CAAE,QAAA4B,EAAS,WAAAC,CAAW,EAAI3B,EAC9B,CAAC,EACD,CACE,QAASwB,GAAS,CAChBC,EAASD,EAAM,OAAO,CACxB,CACF,CACF,EAEMI,EAAU/B,EAAQ,I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AE,MAAQ,SAAWA,EAAE,MAAQ,MACjCA,EAAE,eAAe,CAErB,EAEC,SAAAlB,GAAY,UACf,EAGFzB,EAAC,OAAI,UAAU,oGACb,UAAAD,EAACI,EAAA,CACC,UAAU,gEACV,OAAO,6FACT,EACAJ,EAACG,EAAA,CACC,KAAM,GAAGQ,EAAaS,GAAU,UAAU,cAAc,CAAC,MAAMV,EAAY,CACzE,OAAQ,OAAOU,GAAU,QAAQ,KAAK,EACtC,aAAcA,GAAU,gBAAgB,MAAM,cAAgB,MAC9D,OAAQW,CACV,CAAC,CAAC,GACF,KAAM,EACN,GAAG,IACH,UAAU,uFACZ,EACA/B,EAACG,EAAA,CACC,KAAMO,EAAY,CAChB,OAAQU,GAAU,gBAAgB,MAAM,OACxC,aAAcA,GAAU,gBAAgB,MAAM,cAAgB,MAC9D,OAAQW,CACV,CAAC,EACD,UAAU,0HACV,GAAG,IACL,GACF,EAEA9B,EAAC,OAAI,UAAU,iCACb,UAAAD,EAACE,EAAA,CACC,SAAUqC,EACV,QAAQ,UACR,KAAK,KACL,UAAU,iCACV,QAASH,EACT,QAAS,IAAM,CACbI,EAAa,CACf,EACA,MAAOF,EAAqBZ,EAAW,oBAAsBe,EAE5D,SAAAA,EACH,EACAzC,EAAC,OACC,UAAWc,EACT,qJACAwB,EAAqB,QAAU,QACjC,EAEA,SAAArC,EAAC,OACC,UAAWa,EACT,mHACA,CAACkB,GAAW,cACd,EAEA,UAAAhC,EAACG,EAAA,CAAK,GAAG,IAAI,KAAK,IAAI,KAAMuB,GAAY,oBAAqB,UAAU,cAAc,EACrF1B,EAAC,OAAI,UAAU,mHAAmH,GACpI,EACF,GACF,GACF,EACCiC,GAASjC,EAAC,OAAI,UAAU,sCAAuC,SAAAiC,EAAM,GACxE,CAEJ,CAEA,IAAOY,GAAQ3B",
|
|
6
|
+
"names": ["jsx", "jsxs", "Button", "Text", "Picture", "Badge", "useMemo", "useState", "useCreditsContext", "useRedeemAndBuy", "formatPrice", "numberFormat", "extractVariantId", "gaTrack", "cn", "useHeadlessContext", "useRegistration", "ROUNDED_BRANDS", "RedeemableItem", "copy", "itemData", "setRules", "className", "creditInfo", "profile", "openSignUpPopup", "pageCommon", "pageGroup", "pageHandle", "authCodeActivate", "brand", "locale", "rounded", "error", "setError", "trigger", "isMutating", "isLogin", "inSufficientCredit", "isDisabled", "handleRedeem", "redeemButtonText", "productUrl", "localePrefix", "e", "RedeemableItem_default"]
|
|
7
7
|
}
|
|
@@ -20,7 +20,6 @@ export type CreditsCashCopy = {
|
|
|
20
20
|
products: {
|
|
21
21
|
handle: string;
|
|
22
22
|
sku: string;
|
|
23
|
-
href?: string;
|
|
24
23
|
}[];
|
|
25
24
|
})[];
|
|
26
25
|
soldOut: string;
|
|
@@ -32,7 +31,6 @@ export type CreditsCashCopy = {
|
|
|
32
31
|
export type RedeemItem = {
|
|
33
32
|
product: Product;
|
|
34
33
|
productVariant: ProductVariant;
|
|
35
|
-
productHref?: string;
|
|
36
34
|
alpcData: {
|
|
37
35
|
id: number;
|
|
38
36
|
consumeCredits: number;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Fragment as U,jsx as o,jsxs as P}from"react/jsx-runtime";import{Container as Z,Heading as $,Tabs as j,TabsList as ee,TabsTrigger as te}from"@anker-in/headless-ui";import{useMemo as u,useState as
|
|
1
|
+
import{Fragment as U,jsx as o,jsxs as P}from"react/jsx-runtime";import{Container as Z,Heading as $,Tabs as j,TabsList as ee,TabsTrigger as te}from"@anker-in/headless-ui";import{useMemo as u,useState as p,useEffect as B,useCallback as f,useRef as re}from"react";import D from"decimal.js";import ne from"./MemberPriceItem";import ae from"../creditsCash/RedeemableItem";import se from"../context/hooks/useRedeemableList";import ie from"../modal/RulesModal";import{Pagination as z}from"./Pagination";import{useProductsByHandles as G,useHeadlessContext as oe,gaTrack as le}from"@anker-in/lib";import{classNames as O}from"@anker-in/lib";import{useCreditsContext as me}from"../context/provider";import{FunctionDiscountType as w}from"../context/memberPriceConst";import{ROUNDED_BRANDS as ce}from"../../../constants";const Me=({copy:s,id:W})=>{const[b,q]=p(s.tabs[0]?.type||"memberPrice"),[v,k]=p(),[m,_]=p(1),[l,g]=p(9),{redeemableList:R}=se(),{pageCommon:J,memberPriceDiscount:h,profile:M,gtm:N}=me(),{brand:K}=oe(),Q=ce.includes(K),C=re(null),L=[{namespace:"global",key:"transparentImg"},{namespace:"__discountCodeApp",key:"data"}];B(()=>{const t=()=>{const r=window.innerWidth;r>=1440?g(12):r>=1024?g(9):r>=768?g(12):g(8)};return t(),window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[]),B(()=>{_(1)},[b,l]);const c=u(()=>!h||!s.memberPriceTab.memberPriceRuleId?null:h.find(t=>String(t.rule_id)===String(s.memberPriceTab.memberPriceRuleId)),[h,s.memberPriceTab.memberPriceRuleId]),X=u(()=>c?(c.result_detail?.member_discounts?.filter(e=>e.user_identity===1)||[]).flatMap(e=>e.main_products?.variants?.map(a=>a.handle)||[]):[],[c]),{data:T}=G({handles:X,metafieldIdentifiers:{variant:L}}),{data:x}=G({handles:s?.redeemTab?.list?.map(t=>t.products?.[0]?.handle)||[],metafieldIdentifiers:{variant:L}}),F=f(t=>{try{const r=t?.metafields?.__discountCodeApp?.data;if(!r)return 0;const e=r;if(!Array.isArray(e)||e.length===0)return 0;const a=new Date,n=e.find(i=>{const d=i.starts_at?new Date(i.starts_at):null,V=i.ends_at?new Date(i.ends_at):null;return!(d&&d>a||V&&V<a)});return n?.fixed_value?parseFloat(n.fixed_value):0}catch(r){return console.error("Failed to get coupon discount:",r),0}},[]),A=f((t,r,e)=>{const a=r?.discount_conf;if(!a)return null;let n=new D(t);switch(a.discount_type){case w.Percentage:n=n.mul(100-a.discount_value).div(100);break;case w.FixedAmount:n=n.sub(a.discount_value);break;case w.FixedPrice:n=new D(a.discount_value);break}if(e){const i=F(e);i>0&&(n=n.sub(i))}return n.lessThan(0)&&(n=new D(0)),{memberPrice:n.toNumber(),originalPrice:t}},[F]),y=u(()=>!c||!T?[]:(c.result_detail?.member_discounts?.filter(e=>e.user_identity===1)||[]).flatMap(e=>(e.main_products?.variants||[]).map(a=>({...a,discount:e}))).map(e=>{const a=T.find(d=>d.handle===e.handle);if(!a)return null;const n=a.variants?.find(d=>d.sku===e.sku)||a.variants?.[0];if(!n||!n.availableForSale)return null;const i=A(n.price.amount,e.discount,n);return i?{product:a,productVariant:n,memberPrice:i.memberPrice,originalPrice:i.originalPrice}:null})?.filter(Boolean)||[],[c,T,A]),I=u(()=>x?.map(t=>{const r=s.redeemTab.list.find(n=>n.products?.[0]?.handle===t.handle),e=R.find(n=>n.id?.toString()===r?.redeemId?.toString()),a=t.variants?.find(n=>n.sku===r?.products?.[0]?.sku)||t.variants?.[0];return!e||!a||!a.availableForSale||e.is_limited&&e.remaining_inventory<=0?null:{product:t,productVariant:a,alpcData:{id:e?.id,consumeCredits:e?.consume_credits,remainingInventory:e?.remaining_inventory,isLimited:e?.is_limited,consumeType:e?.consume_type,title:e?.name,desc:e?.note},config:r}}).filter(Boolean),[x,s.redeemTab.list,R]),S=u(()=>{const t=y?.length||0,r=Math.ceil(t/l),e=(m-1)*l,a=e+l,n=y?.slice(e,a)||[];return{totalPages:r,currentItems:n,showPagination:r>1}},[y,m,l]),E=u(()=>{const t=I?.length||0,r=Math.ceil(t/l),e=(m-1)*l,a=e+l,n=I?.slice(e,a)||[];return{totalPages:r,currentItems:n,showPagination:r>1}},[I,m,l]),H=f(t=>{if(_(t),C.current){const r=C.current.offsetTop;window.scrollTo({top:r-80,behavior:"smooth"})}},[_]),Y=f(t=>{const r=t;q(r);const a=s.tabs.find(n=>n.type===r)?.label||"";le({event:"ga4Event",event_name:"lp_button",member_active_status:M?.activated?"active":"not active",event_parameters:{page_group:N.pageGroup,position:s.title,button_name:a}})},[s.tabs,s.title,M?.activated,N.pageGroup]);return P(Z,{id:W,className:O("bg-[#F5F5F5]"),ref:C,children:[o($,{as:"h2",size:"4",html:s.title,className:"mx:px-[16px]"}),o(j,{align:"left",className:"mt-[24px]",value:b,onValueChange:Y,children:o(ee,{children:s.tabs.map((t,r)=>o(te,{value:t.type,children:t.label},r))})}),P("div",{className:"relative mt-[24px]",children:[b==="memberPrice"&&P(U,{children:[o("div",{className:"grid md:grid-cols-2 gap-[12px] grid-cols-4 md-xl:grid-cols-3 lg:gap-[16px]",children:S.currentItems?.map((t,r)=>o(ne,{itemData:t,copy:s.memberPriceTab},r))}),o(z,{currentPage:m,totalPages:S.totalPages,onPageChange:H})]}),b==="redeem"&&P(U,{children:[o("div",{className:"grid md:grid-cols-2 gap-[12px] grid-cols-4 md-xl:grid-cols-3 lg:gap-[16px]",children:E.currentItems?.map((t,r)=>o(ae,{copy:{title:s.title,...s.redeemTab},itemData:t,setRules:k,currencyCode:x?.[0]?.price.currencyCode||"USD"},r))}),o(z,{currentPage:m,totalPages:E.totalPages,onPageChange:H})]})]}),v&&o(ie,{overlayClassName:"md:px-[16px] md:items-center",className:O("md:h-fit md:rounded-b-[16px]",!Q&&"md:rounded-none"),isOpen:v.length>0,onClose:()=>k([]),titleClassName:"border-b-transparent h-[56px]",rules:v,scrollClassName:"md:mt-[8px] md:mb-[24px] md:pt-0",title:J?.ruleLabel,ruleClassName:"text-[#1d1d1f] font-bold"})]})};export{Me as CreditsMemberPrice};
|
|
2
2
|
//# sourceMappingURL=CreditsMemberPrice.js.map
|