@anker-in/campaign-ui 0.5.0-beta.24 → 0.5.0-beta.25

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.
@@ -1,2 +1,2 @@
1
- "use strict";var O=Object.create;var g=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var G=(t,s)=>{for(var n in s)g(t,n,{get:s[n],enumerable:!0})},_=(t,s,n,m)=>{if(s&&typeof s=="object"||typeof s=="function")for(let c of $(s))!z.call(t,c)&&c!==n&&g(t,c,{get:()=>s[c],enumerable:!(m=W(s,c))||m.enumerable});return t};var J=(t,s,n)=>(n=t!=null?O(q(t)):{},_(s||!t||!t.__esModule?g(n,"default",{value:t,enumerable:!0}):n,t)),K=t=>_(g({},"__esModule",{value:!0}),t);var Q={};G(Q,{default:()=>T});module.exports=K(Q);var e=require("react/jsx-runtime"),r=require("react"),l=require("@anker-in/headless-ui"),d=require("@anker-in/lib"),f=require("../../../credits/context/const"),k=require("./hooks/useRedeemCoupon"),B=J(require("../../../credits/context/hooks/useCopy")),D=require("../../../../constants");function T({onClose:t,item:s,copy:n,onError:m}){const{itemTitle:c,itemCredits:S,itemImage:C,itemValue:y,itemRules:v,redeemId:N,userId:h,alpcConfig:L}=s,{redeemModal:o,creditUnit:U}=n,A=U??"pts",[p,w]=(0,r.useState)(),[E,x]=(0,r.useState)(""),[M,u]=(0,r.useState)(!1),{copy:P,copied:I}=(0,B.default)(),{brand:F}=(0,d.useHeadlessContext)(),b=D.ROUNDED_BRANDS.includes(F),{isMutating:V,trigger:R}=(0,k.useRedeemCoupon)(L),j=(0,r.useCallback)(async()=>{x("");const{data:i}=await R({user_id:h,rule_id:N});if(!i){x(o.commonError);return}if(i.data?.success)w(i.data.coupon_code),(0,d.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"redeem_coupon_success",info:"Member Floating Window"}});else{let a=o.commonError;i.code===f.AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit?(a=o.redeemLimitError,u(!0)):i.code===f.AlpcErrorCode.CodeLpcRuleInventoryNotEnough?(a=o.inventoryNotEnough,u(!0)):i.code===f.AlpcErrorCode.CodeLpcNotEnoughCredits?(a=o.creditsNotEnough,u(!0)):i.code===f.AlpcErrorCode.CodeCrossSiteError&&(a=o.crossSiteError,u(!0)),x(a),m?.(i.code)}},[R,h,N,o,m]);(0,r.useEffect)(()=>{w(void 0),x(""),u(!1)},[N]);const H=v&&v.length>0&&(0,e.jsx)("div",{className:"w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]",children:(0,e.jsx)("ul",{className:"ml-4 grid grid-flow-row gap-[4px]",children:v?.map((i,a)=>(0,e.jsx)("li",{className:"list-disc",children:(0,e.jsx)(l.Text,{html:i,className:"font-bold"})},a))})});return(0,e.jsxs)("div",{className:"flex flex-col",children:[C?.url&&(0,e.jsx)("div",{className:"relative w-full px-[24px]",children:(0,e.jsxs)("div",{className:(0,d.classNames)("relative mx-auto overflow-hidden",b?"rounded-[8px]":"rounded-none"),children:[(0,e.jsx)("img",{src:C.url,alt:C.alt??"",className:"mx-auto h-[140px] w-full object-cover"}),y&&(0,e.jsxs)("div",{className:"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white",children:[y,o.off?` ${o.off}`:""]})]})}),!p&&(0,e.jsxs)("div",{className:"flex flex-col gap-[16px] px-[24px] py-[20px]",children:[(0,e.jsxs)("p",{className:"text-center text-[24px] font-[700] text-[#1d1d1f]",children:[S," ",A]}),H]}),p&&(0,e.jsxs)("div",{className:"flex mt-[16px] flex-col gap-[8px] text-center",children:[(0,e.jsxs)("div",{className:"flex items-center justify-center gap-[10px]",children:[(0,e.jsx)("span",{className:"text-[24px] font-[700]",children:p}),(0,e.jsx)("button",{className:"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none",disabled:I,onClick:()=>P(p),children:I?"Copied":"Copy"})]}),(0,e.jsx)(l.Text,{className:"text-[20px] font-[700]",html:o.successTitle}),(0,e.jsx)(l.Text,{className:"text-[14px] font-[700] text-[#6d6d6f]",html:o.successDesc}),(0,e.jsx)(l.Button,{className:(0,d.classNames)("w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]",b?"rounded-[4px]":"rounded-none"),onClick:()=>{o.successButtonUrl&&(window.location.href=o.successButtonUrl),t()},children:o.successButton})]}),!p&&(0,e.jsxs)("div",{className:"sticky bottom-0 bg-white border-t border-[#e5e5e5] pt-[10px]",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-[8px] text-center",children:[(0,e.jsx)(l.Text,{className:"block text-[16px] font-[700] leading-[1.3]",html:o.confirmTitle}),(0,e.jsx)(l.Button,{className:(0,d.classNames)("w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]",b?"rounded-[4px]":"rounded-none"),disabled:M,loading:V,onClick:j,children:o.confirmButton})]}),E&&(0,e.jsx)(l.Text,{className:"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]",html:E})]})]})}
1
+ "use strict";var O=Object.create;var g=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var G=(o,s)=>{for(var n in s)g(o,n,{get:s[n],enumerable:!0})},_=(o,s,n,m)=>{if(s&&typeof s=="object"||typeof s=="function")for(let c of $(s))!z.call(o,c)&&c!==n&&g(o,c,{get:()=>s[c],enumerable:!(m=W(s,c))||m.enumerable});return o};var J=(o,s,n)=>(n=o!=null?O(q(o)):{},_(s||!o||!o.__esModule?g(n,"default",{value:o,enumerable:!0}):n,o)),K=o=>_(g({},"__esModule",{value:!0}),o);var Q={};G(Q,{default:()=>L});module.exports=K(Q);var e=require("react/jsx-runtime"),r=require("react"),l=require("@anker-in/headless-ui"),d=require("@anker-in/lib"),f=require("../../../credits/context/const"),k=require("./hooks/useRedeemCoupon"),B=J(require("../../../credits/context/hooks/useCopy")),D=require("../../../../constants");function L({onClose:o,item:s,copy:n,onError:m}){const{itemTitle:c,itemCredits:T,itemImage:C,itemValue:y,itemRules:v,redeemId:b,userId:h,alpcConfig:S}=s,{redeemModal:t,creditUnit:U}=n,A=U??"pts",[p,w]=(0,r.useState)(),[E,x]=(0,r.useState)(""),[M,u]=(0,r.useState)(!1),{copy:P,copied:I}=(0,B.default)(),{brand:F}=(0,d.useHeadlessContext)(),N=D.ROUNDED_BRANDS.includes(F),{isMutating:V,trigger:R}=(0,k.useRedeemCoupon)(S),j=(0,r.useCallback)(async()=>{x("");const{data:i}=await R({user_id:h,rule_id:b});if(!i){x(t.commonError);return}if(i.data?.success)w(i.data.coupon_code),(0,d.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"redeem_coupon_success",info:"Member Floating Window"}});else{let a=t.commonError;i.code===f.AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit?(a=t.redeemLimitError,u(!0)):i.code===f.AlpcErrorCode.CodeLpcRuleInventoryNotEnough?(a=t.inventoryNotEnough,u(!0)):i.code===f.AlpcErrorCode.CodeLpcNotEnoughCredits?(a=t.creditsNotEnough,u(!0)):i.code===f.AlpcErrorCode.CodeCrossSiteError&&(a=t.crossSiteError,u(!0)),x(a),m?.(i.code)}},[R,h,b,t,m]);(0,r.useEffect)(()=>{w(void 0),x(""),u(!1)},[b]);const H=v&&v.length>0&&(0,e.jsx)("div",{className:"w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]",children:(0,e.jsx)("ul",{className:"ml-4 grid grid-flow-row gap-[4px]",children:v?.map((i,a)=>(0,e.jsx)("li",{className:"list-disc",children:(0,e.jsx)(l.Text,{html:i,className:"font-bold"})},a))})});return(0,e.jsxs)("div",{className:"flex flex-col",children:[C?.url&&(0,e.jsx)("div",{className:"relative w-full px-[24px]",children:(0,e.jsxs)("div",{className:(0,d.classNames)("relative mx-auto overflow-hidden",N?"rounded-[8px]":"rounded-none"),children:[(0,e.jsx)("img",{src:C.url,alt:C.alt??"",className:"mx-auto h-[140px] w-full object-cover"}),y&&(0,e.jsxs)("div",{className:"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white",children:[y,t.off?` ${t.off}`:""]})]})}),!p&&(0,e.jsxs)("div",{className:"flex flex-col gap-[16px] px-[24px] py-[20px]",children:[(0,e.jsxs)("p",{className:"text-center text-[24px] font-[700] text-[#1d1d1f]",children:[T," ",A]}),H]}),p&&(0,e.jsxs)("div",{className:"flex mt-[16px] flex-col gap-[8px] text-center",children:[(0,e.jsxs)("div",{className:"flex items-center justify-center gap-[10px]",children:[(0,e.jsx)("span",{className:"text-[24px] font-[700]",children:p}),(0,e.jsx)("button",{className:"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none",disabled:I,onClick:()=>P(p),children:I?t.copiedLabel??"Copied":t.copyLabel??"Copy"})]}),(0,e.jsx)(l.Text,{className:"text-[20px] font-[700]",html:t.successTitle}),(0,e.jsx)(l.Text,{className:"text-[14px] font-[700] text-[#6d6d6f]",html:t.successDesc}),(0,e.jsx)(l.Button,{className:(0,d.classNames)("w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]",N?"rounded-[4px]":"rounded-none"),onClick:()=>{t.successButtonUrl&&(window.location.href=t.successButtonUrl),o()},children:t.successButton})]}),!p&&(0,e.jsxs)("div",{className:"sticky bottom-0 bg-white border-t border-[#e5e5e5] pt-[10px]",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-[8px] text-center",children:[(0,e.jsx)(l.Text,{className:"block text-[16px] font-[700] leading-[1.3]",html:t.confirmTitle}),(0,e.jsx)(l.Button,{className:(0,d.classNames)("w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]",N?"rounded-[4px]":"rounded-none"),disabled:M,loading:V,onClick:j,children:t.confirmButton})]}),E&&(0,e.jsx)(l.Text,{className:"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]",html:E})]})]})}
2
2
  //# sourceMappingURL=RedeemCouponPanel.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.tsx"],
4
- "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Text, Button } from '@anker-in/headless-ui'\nimport { gaTrack, useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport { AlpcErrorCode } from '../../../credits/context/const'\nimport { useRedeemCoupon } from './hooks/useRedeemCoupon'\nimport useCopy from '../../../credits/context/hooks/useCopy'\nimport type { ConsumeCreditsopy, AlpcConfig } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype RedeemCouponItem = {\n itemTitle: string\n itemCredits: number\n itemImage?: { url: string; alt?: string }\n itemValue?: string\n itemRules?: string[]\n redeemId: number\n userId?: string\n alpcConfig: AlpcConfig\n}\n\ntype Props = {\n onClose: () => void\n item: RedeemCouponItem\n copy: ConsumeCreditsopy\n onError?: (code: number) => void\n}\n\nexport default function RedeemCouponPanel({ onClose, item, copy, onError }: Props) {\n const { itemTitle, itemCredits, itemImage, itemValue, itemRules, redeemId, userId, alpcConfig } = item\n const { redeemModal, creditUnit } = copy\n const pointUnit = creditUnit ?? 'pts'\n const [couponCode, setCouponCode] = useState<string>()\n const [errorInfo, setErrorInfo] = useState('')\n const [disabled, setDisabled] = useState(false)\n const { copy: copyText, copied } = useCopy()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const { isMutating: loading, trigger } = useRedeemCoupon(alpcConfig)\n\n const handleConfirm = useCallback(async () => {\n setErrorInfo('')\n const { data } = await trigger({ user_id: userId, rule_id: redeemId })\n if (!data) {\n setErrorInfo(redeemModal.commonError)\n return\n }\n if (data.data?.success) {\n setCouponCode(data.data.coupon_code)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem_coupon_success',\n info: 'Member Floating Window',\n },\n })\n } else {\n let msg = redeemModal.commonError\n if (data.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n msg = redeemModal.redeemLimitError\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n msg = redeemModal.inventoryNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n msg = redeemModal.creditsNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeCrossSiteError) {\n msg = redeemModal.crossSiteError\n setDisabled(true)\n }\n setErrorInfo(msg)\n onError?.(data.code)\n }\n }, [trigger, userId, redeemId, redeemModal, onError])\n\n useEffect(() => {\n setCouponCode(undefined)\n setErrorInfo('')\n setDisabled(false)\n }, [redeemId])\n\n const rulesSection = itemRules && itemRules.length > 0 && (\n <div className=\"w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]\">\n <ul className=\"ml-4 grid grid-flow-row gap-[4px]\">\n {itemRules?.map((text, index) => (\n <li className=\"list-disc\" key={index}>\n <Text html={text} className=\"font-bold\" />\n </li>\n ))}\n </ul>\n </div>\n )\n\n return (\n <div className=\"flex flex-col\">\n {itemImage?.url && (\n <div className=\"relative w-full px-[24px]\">\n <div className={cn('relative mx-auto overflow-hidden', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <img src={itemImage.url} alt={itemImage.alt ?? ''} className=\"mx-auto h-[140px] w-full object-cover\" />\n {itemValue && (\n <div className=\"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white\">\n {itemValue}\n {redeemModal.off ? ` ${redeemModal.off}` : ''}\n </div>\n )}\n </div>\n </div>\n )}\n\n {!couponCode && (\n <div className=\"flex flex-col gap-[16px] px-[24px] py-[20px]\">\n <p className=\"text-center text-[24px] font-[700] text-[#1d1d1f]\">\n {itemCredits} {pointUnit}\n </p>\n {rulesSection}\n </div>\n )}\n\n {couponCode && (\n <div className=\"flex mt-[16px] flex-col gap-[8px] text-center\">\n <div className=\"flex items-center justify-center gap-[10px]\">\n <span className=\"text-[24px] font-[700]\">{couponCode}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none\"\n disabled={copied}\n onClick={() => copyText(couponCode)}\n >\n {copied ? 'Copied' : 'Copy'}\n </button>\n </div>\n <Text className=\"text-[20px] font-[700]\" html={redeemModal.successTitle} />\n <Text className=\"text-[14px] font-[700] text-[#6d6d6f]\" html={redeemModal.successDesc} />\n <Button\n className={cn(\n 'w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n onClick={() => {\n if (redeemModal.successButtonUrl) window.location.href = redeemModal.successButtonUrl\n onClose()\n }}\n >\n {redeemModal.successButton}\n </Button>\n </div>\n )}\n\n {!couponCode && (\n <div className=\"sticky bottom-0 bg-white border-t border-[#e5e5e5] pt-[10px]\">\n <div className=\"flex flex-col gap-[8px] text-center\">\n <Text className=\"block text-[16px] font-[700] leading-[1.3]\" html={redeemModal.confirmTitle} />\n <Button\n className={cn(\n 'w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={disabled}\n loading={loading}\n onClick={handleConfirm}\n >\n {redeemModal.confirmButton}\n </Button>\n </div>\n\n {errorInfo && (\n <Text className=\"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]\" html={errorInfo} />\n )}\n </div>\n )}\n </div>\n )\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAyFY,IAAAI,EAAA,6BAzFZC,EAAiD,iBACjDC,EAA6B,iCAC7BC,EAA8D,yBAC9DC,EAA8B,0CAC9BC,EAAgC,mCAChCC,EAAoB,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wC,KAAMA,EAAY,YAAa,KACvF,OAAC,UACC,aAAW,EAAAsB,YACT,kEACAT,EAAU,gBAAkB,cAC9B,EACA,QAAS,IAAM,CACTb,EAAY,mBAAkB,OAAO,SAAS,KAAOA,EAAY,kBACrEZ,EAAQ,CACV,EAEC,SAAAY,EAAY,cACf,GACF,EAGD,CAACG,MACA,QAAC,OAAI,UAAU,+DACb,qBAAC,OAAI,UAAU,sCACb,oBAAC,QAAK,UAAU,6CAA6C,KAAMH,EAAY,aAAc,KAC7F,OAAC,UACC,aAAW,EAAAsB,YACT,sFACAT,EAAU,gBAAkB,cAC9B,EACA,SAAUN,EACV,QAASO,EACT,QAASE,EAER,SAAAhB,EAAY,cACf,GACF,EAECK,MACC,OAAC,QAAK,UAAU,6DAA6D,KAAMA,EAAW,GAElG,GAEJ,CAEJ",
4
+ "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Text, Button } from '@anker-in/headless-ui'\nimport { gaTrack, useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport { AlpcErrorCode } from '../../../credits/context/const'\nimport { useRedeemCoupon } from './hooks/useRedeemCoupon'\nimport useCopy from '../../../credits/context/hooks/useCopy'\nimport type { ConsumeCreditsopy, AlpcConfig } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype RedeemCouponItem = {\n itemTitle: string\n itemCredits: number\n itemImage?: { url: string; alt?: string }\n itemValue?: string\n itemRules?: string[]\n redeemId: number\n userId?: string\n alpcConfig: AlpcConfig\n}\n\ntype Props = {\n onClose: () => void\n item: RedeemCouponItem\n copy: ConsumeCreditsopy\n onError?: (code: number) => void\n}\n\nexport default function RedeemCouponPanel({ onClose, item, copy, onError }: Props) {\n const { itemTitle, itemCredits, itemImage, itemValue, itemRules, redeemId, userId, alpcConfig } = item\n const { redeemModal, creditUnit } = copy\n const pointUnit = creditUnit ?? 'pts'\n const [couponCode, setCouponCode] = useState<string>()\n const [errorInfo, setErrorInfo] = useState('')\n const [disabled, setDisabled] = useState(false)\n const { copy: copyText, copied } = useCopy()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const { isMutating: loading, trigger } = useRedeemCoupon(alpcConfig)\n\n const handleConfirm = useCallback(async () => {\n setErrorInfo('')\n const { data } = await trigger({ user_id: userId, rule_id: redeemId })\n if (!data) {\n setErrorInfo(redeemModal.commonError)\n return\n }\n if (data.data?.success) {\n setCouponCode(data.data.coupon_code)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem_coupon_success',\n info: 'Member Floating Window',\n },\n })\n } else {\n let msg = redeemModal.commonError\n if (data.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n msg = redeemModal.redeemLimitError\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n msg = redeemModal.inventoryNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n msg = redeemModal.creditsNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeCrossSiteError) {\n msg = redeemModal.crossSiteError\n setDisabled(true)\n }\n setErrorInfo(msg)\n onError?.(data.code)\n }\n }, [trigger, userId, redeemId, redeemModal, onError])\n\n useEffect(() => {\n setCouponCode(undefined)\n setErrorInfo('')\n setDisabled(false)\n }, [redeemId])\n\n const rulesSection = itemRules && itemRules.length > 0 && (\n <div className=\"w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]\">\n <ul className=\"ml-4 grid grid-flow-row gap-[4px]\">\n {itemRules?.map((text, index) => (\n <li className=\"list-disc\" key={index}>\n <Text html={text} className=\"font-bold\" />\n </li>\n ))}\n </ul>\n </div>\n )\n\n return (\n <div className=\"flex flex-col\">\n {itemImage?.url && (\n <div className=\"relative w-full px-[24px]\">\n <div className={cn('relative mx-auto overflow-hidden', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <img src={itemImage.url} alt={itemImage.alt ?? ''} className=\"mx-auto h-[140px] w-full object-cover\" />\n {itemValue && (\n <div className=\"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white\">\n {itemValue}\n {redeemModal.off ? ` ${redeemModal.off}` : ''}\n </div>\n )}\n </div>\n </div>\n )}\n\n {!couponCode && (\n <div className=\"flex flex-col gap-[16px] px-[24px] py-[20px]\">\n <p className=\"text-center text-[24px] font-[700] text-[#1d1d1f]\">\n {itemCredits} {pointUnit}\n </p>\n {rulesSection}\n </div>\n )}\n\n {couponCode && (\n <div className=\"flex mt-[16px] flex-col gap-[8px] text-center\">\n <div className=\"flex items-center justify-center gap-[10px]\">\n <span className=\"text-[24px] font-[700]\">{couponCode}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none\"\n disabled={copied}\n onClick={() => copyText(couponCode)}\n >\n {copied ? (redeemModal.copiedLabel ?? 'Copied') : (redeemModal.copyLabel ?? 'Copy')}\n </button>\n </div>\n <Text className=\"text-[20px] font-[700]\" html={redeemModal.successTitle} />\n <Text className=\"text-[14px] font-[700] text-[#6d6d6f]\" html={redeemModal.successDesc} />\n <Button\n className={cn(\n 'w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n onClick={() => {\n if (redeemModal.successButtonUrl) window.location.href = redeemModal.successButtonUrl\n onClose()\n }}\n >\n {redeemModal.successButton}\n </Button>\n </div>\n )}\n\n {!couponCode && (\n <div className=\"sticky bottom-0 bg-white border-t border-[#e5e5e5] pt-[10px]\">\n <div className=\"flex flex-col gap-[8px] text-center\">\n <Text className=\"block text-[16px] font-[700] leading-[1.3]\" html={redeemModal.confirmTitle} />\n <Button\n className={cn(\n 'w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={disabled}\n loading={loading}\n onClick={handleConfirm}\n >\n {redeemModal.confirmButton}\n </Button>\n </div>\n\n {errorInfo && (\n <Text className=\"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]\" html={errorInfo} />\n )}\n </div>\n )}\n </div>\n )\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAyFY,IAAAI,EAAA,6BAzFZC,EAAiD,iBACjDC,EAA6B,iCAC7BC,EAA8D,yBAC9DC,EAA8B,0CAC9BC,EAAgC,mCAChCC,EAAoB,qDAEpBC,EAA+B,iCAoBhB,SAART,EAAmC,CAAE,QAAAU,EAAS,KAAAC,EAAM,KAAAC,EAAM,QAAAC,CAAQ,EAAU,CACjF,KAAM,CAAE,UAAAC,EAAW,YAAAC,EAAa,UAAAC,EAAW,UAAAC,EAAW,UAAAC,EAAW,SAAAC,EAAU,OAAAC,EAAQ,WAAAC,CAAW,EAAIV,EAC5F,CAAE,YAAAW,EAAa,WAAAC,CAAW,EAAIX,EAC9BY,EAAYD,GAAc,MAC1B,CAACE,EAAYC,CAAa,KAAI,YAAiB,EAC/C,CAACC,EAAWC,CAAY,KAAI,YAAS,EAAE,EACvC,CAACC,EAAUC,CAAW,KAAI,YAAS,EAAK,EACxC,CAAE,KAAMC,EAAU,OAAAC,CAAO,KAAI,EAAAC,SAAQ,EACrC,CAAE,MAAAC,CAAM,KAAI,sBAAmB,EAC/BC,EAAU,iBAAe,SAASD,CAAK,EAEvC,CAAE,WAAYE,EAAS,QAAAC,CAAQ,KAAI,mBAAgBhB,CAAU,EAE7DiB,KAAgB,eAAY,SAAY,CAC5CV,EAAa,EAAE,EACf,KAAM,CAAE,KAAAW,CAAK,EAAI,MAAMF,EAAQ,CAAE,QAASjB,EAAQ,QAASD,CAAS,CAAC,EACrE,GAAI,CAACoB,EAAM,CACTX,EAAaN,EAAY,WAAW,EACpC,MACF,CACA,GAAIiB,EAAK,MAAM,QACbb,EAAca,EAAK,KAAK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+CACb,qBAAC,KAAE,UAAU,oDACV,UAAAV,EAAY,IAAES,GACjB,EACCiB,GACH,EAGDhB,MACC,QAAC,OAAI,UAAU,gDACb,qBAAC,OAAI,UAAU,8CACb,oBAAC,QAAK,UAAU,yBAA0B,SAAAA,EAAW,KACrD,OAAC,UACC,UAAU,+EACV,SAAUO,EACV,QAAS,IAAMD,EAASN,CAAU,EAEjC,SAAAO,EAAUV,EAAY,aAAe,SAAaA,EAAY,WAAa,OAC9E,GACF,KACA,OAAC,QAAK,UAAU,yBAAyB,KAAMA,EAAY,aAAc,KACzE,OAAC,QAAK,UAAU,wCAAwC,KAAMA,EAAY,YAAa,KACvF,OAAC,UACC,aAAW,EAAAsB,YACT,kEACAT,EAAU,gBAAkB,cAC9B,EACA,QAAS,IAAM,CACTb,EAAY,mBAAkB,OAAO,SAAS,KAAOA,EAAY,kBACrEZ,EAAQ,CACV,EAEC,SAAAY,EAAY,cACf,GACF,EAGD,CAACG,MACA,QAAC,OAAI,UAAU,+DACb,qBAAC,OAAI,UAAU,sCACb,oBAAC,QAAK,UAAU,6CAA6C,KAAMH,EAAY,aAAc,KAC7F,OAAC,UACC,aAAW,EAAAsB,YACT,sFACAT,EAAU,gBAAkB,cAC9B,EACA,SAAUN,EACV,QAASO,EACT,QAASE,EAER,SAAAhB,EAAY,cACf,GACF,EAECK,MACC,OAAC,QAAK,UAAU,6DAA6D,KAAMA,EAAW,GAElG,GAEJ,CAEJ",
6
6
  "names": ["RedeemCouponPanel_exports", "__export", "RedeemCouponPanel", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_const", "import_useRedeemCoupon", "import_useCopy", "import_constants", "onClose", "item", "copy", "onError", "itemTitle", "itemCredits", "itemImage", "itemValue", "itemRules", "redeemId", "userId", "alpcConfig", "redeemModal", "creditUnit", "pointUnit", "couponCode", "setCouponCode", "errorInfo", "setErrorInfo", "disabled", "setDisabled", "copyText", "copied", "useCopy", "brand", "rounded", "loading", "trigger", "handleConfirm", "data", "msg", "rulesSection", "text", "index", "cn"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var I=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var X=(n,a)=>{for(var l in a)I(n,l,{get:a[l],enumerable:!0})},Y=(n,a,l,f)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of K(a))!Q.call(n,d)&&d!==l&&I(n,d,{get:()=>a[d],enumerable:!(f=J(a,d))||f.enumerable});return n};var Z=n=>Y(I({},"__esModule",{value:!0}),n);var ne={};X(ne,{default:()=>te});module.exports=Z(ne);var t=require("react/jsx-runtime"),u=require("react"),N=require("@anker-in/headless-ui"),i=require("@anker-in/lib"),L=require("../../context/provider"),A=require("../../context/viewStack"),U=require("./hooks/useRedeemableList"),E=require("./hooks/useRedeemAndBuy"),o=require("../../type"),m=require("../../../credits/context/utils"),M=require("../../../../constants");function ee({copy:n}){const{profile:a,creditInfo:l,openSignUpPopup:f,alpcConfig:d,isActivateSuccess:F,fetchCreditInfo:$,pageHandle:x}=(0,L.useMemberPopupContext)(),{pushView:R}=(0,A.useViewStack)(),{brand:T}=(0,i.useHeadlessContext)(),_=M.ROUNDED_BRANDS.includes(T),[k,y]=(0,u.useState)(""),[z,B]=(0,u.useState)(null);(0,u.useEffect)(()=>{a?.user_id&&$(a.user_id)},[]);const c=!!a,{redeemableList:S,listLoading:O}=(0,U.useRedeemableList)(d),{trigger:V}=(0,E.useRedeemAndBuy)(d),j=n.list.map(e=>e.product?.handle).filter(Boolean),{data:D}=(0,i.useProductsByHandles)({handles:j}),H=(0,u.useMemo)(()=>n.list.map(e=>{const r=S.find(p=>String(p.id)===String(e.redeemId));if(!r)return null;const s=Number(l?.available_credit??0),C=r.consume_credits>s,v=r.is_limited&&(!r.remaining_inventory||r.remaining_inventory<=0),P=e.type===o.ConsumeCreditsItemType.RedeemAndBuy||e.type===o.ConsumeCreditsItemType.Product,b=D?.find(p=>p.handle===e.product?.handle),w=b?.variants?.find(p=>p.sku===e.product?.sku)??b?.variants?.[0];return P&&(!b||!w||!w?.availableForSale||v)?null:{...e,alpcData:r,insufficient:C,product:b,variant:w}}).filter(Boolean),[n.list,S,l,a,c,D]),g=a?.activated||F;function W(e){return!c||!g?n.unlockRewards:e.soldOut?n.soldOut:n.btnRedeem}function G(e){return!c||!g?!1:e.insufficient}function h(e){(0,i.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"redeem",info:"Member Floating Window"}})}async function q(e){if(!c){f();return}if(!g){R({type:o.MemberPopupPanelType.Activate});return}if(e.type===o.ConsumeCreditsItemType.GiftCard||e.type===o.ConsumeCreditsItemType.Product){if(n.creditsPage?.url){const r=n.creditsPage.redeemListSectionId??"creditsRedeemList",s=new URL(n.creditsPage.url,window.location.href);s.searchParams.set("section",r),s.hash=r,x&&s.searchParams.set("ref",`${x}_consume_credits`),h(e.title),window.open(s.toString(),"_blank","noopener,noreferrer")}return}if(e.type===o.ConsumeCreditsItemType.Coupon)h(e.title),R({type:o.MemberPopupPanelType.RedeemCoupon,props:{itemTitle:e.title,itemCredits:e.alpcData.consume_credits,itemImage:n.imageMapping?.[e.type]?{url:n.imageMapping[e.type].url,alt:e.image?.alt}:e.image,itemValue:e.value,itemRules:e.rules,redeemId:Number(e.redeemId),userId:a?.user_id,alpcConfig:d}});else{y(""),B(e.redeemId),h(e.title);try{await V({productVariant:e.variant,redeemId:Number(e.redeemId),userId:a?.user_id}),(0,i.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"redeem_success",info:"Member Floating Window"}})}catch(r){y(r?.message??n.redeemModal.commonError)}finally{B(null)}}}return(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("div",{className:"flex flex-1 flex-col",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-[8px]",children:[n.title&&(0,t.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:n.title}),n.subtitle&&(0,t.jsx)("p",{className:"text-[16px] mt-[8px] font-[700] leading-snug text-[#4a4c56]",children:n.subtitle})]}),c&&(0,t.jsxs)("div",{className:(0,i.classNames)("flex items-center mt-[16px] gap-[12px] bg-[#f5f6f7] p-[16px]",_?"rounded-[8px]":"rounded-none"),children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,t.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:n.balanceLabel??"AnkerCredits Balance"}),(0,t.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,t.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,m.numberFormat)(l?.available_credit||0)}),(0,t.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:n.creditUnit??"ankercredits"})]})]}),(0,t.jsx)("div",{className:"h-full w-px bg-[#dadce0]"}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,t.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:n.comingSoonLabel??"Coming Soon"}),(0,t.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,t.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,m.numberFormat)(l?.pending_credit||0)}),(0,t.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:n.creditUnit??"ankercredits"})]})]})]}),k&&(0,t.jsx)("div",{className:"text-[14px] mt-[8px] font-[700] text-[#f84d4f]",children:k}),O?(0,t.jsx)("div",{className:"flex flex-1 items-center justify-center py-[32px]",children:(0,t.jsx)("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}):(0,t.jsx)("div",{className:"flex mt-[16px] flex-col",children:H.map((e,r)=>{const s=!!e.product;return(0,t.jsxs)("div",{className:"relative py-[16px]",children:[r>0&&(0,t.jsx)("div",{className:"absolute inset-x-0 top-0 h-px bg-[#dadce0]"}),(0,t.jsxs)("div",{className:"flex items-center gap-[12px]",children:[(()=>{const C=n.imageMapping?.[e.type]?.url,v=s?e.variant?.image?.url??e.product?.images?.[0]?.url??e.image?.url:C??e.image?.url,P=s?e.variant?.image?.altText??e.product?.images?.[0]?.alt??e.image?.alt??"":e.image?.alt??"";return v?(0,t.jsxs)("div",{className:(0,i.classNames)("relative size-[64px] shrink-0 overflow-hidden",_?"rounded-[4px]":"rounded-none"),children:[(0,t.jsx)(N.Picture,{source:v,alt:P,className:"flex size-full items-center justify-center",imgClassName:s?"object-cover":"h-full w-auto object-contain"}),!s&&e.value&&(0,t.jsxs)("div",{className:"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white",children:[e.value," ",n.off]})]}):null})(),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("div",{className:"text-[16px] font-[700] text-[#1e2024] line-clamp-2",children:s&&e.product?.title?e.product.title:e.title}),(0,t.jsx)("div",{className:"mt-[4px] text-[14px] text-[#666]",children:s&&e.price!=null?`${(0,m.numberFormat)(e.alpcData.consume_credits)} ${n.creditUnit??""} + $${Number(e.price).toFixed(2)}`:`${(0,m.numberFormat)(e.alpcData.consume_credits)} ${n.creditUnit??""}`})]}),(0,t.jsxs)("div",{className:"relative group",children:[(0,t.jsx)(N.Button,{className:(0,i.classNames)("bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",_?"rounded-[4px]":"rounded-none"),disabled:G(e),loading:z===e.redeemId,onClick:()=>q(e),children:W(e)}),e.insufficient&&c&&g&&(0,t.jsx)("div",{className:"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block",children:(0,t.jsxs)("div",{className:"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow",children:[(0,t.jsx)("p",{className:"text-pretty tracking-[-0.02em] text-[14px]",children:n.insufficientCredits}),(0,t.jsx)("div",{className:"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]"})]})})]})]})]},r)})}),n.creditsPage?.url&&(0,t.jsx)("a",{href:(()=>{if(!x)return n.creditsPage.url;try{const e=new URL(n.creditsPage.url,window.location.href);return e.searchParams.set("ref",`${x}_consume_credits`),e.toString()}catch{return n.creditsPage.url}})(),target:"_blank",rel:"noopener noreferrer",className:"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline",onClick:()=>(0,i.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"credits_page_link",info:"Member Floating Window"}}),children:n.creditsPage.label??"Go to Credits Page"})]})})}var te=ee;
1
+ "use strict";var P=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var X=(a,n)=>{for(var l in n)P(a,l,{get:n[l],enumerable:!0})},Y=(a,n,l,f)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of K(n))!Q.call(a,o)&&o!==l&&P(a,o,{get:()=>n[o],enumerable:!(f=J(n,o))||f.enumerable});return a};var Z=a=>Y(P({},"__esModule",{value:!0}),a);var ae={};X(ae,{default:()=>te});module.exports=Z(ae);var t=require("react/jsx-runtime"),u=require("react"),N=require("@anker-in/headless-ui"),i=require("@anker-in/lib"),D=require("../../context/provider"),S=require("../../context/viewStack"),L=require("./hooks/useRedeemableList"),E=require("./hooks/useRedeemAndBuy"),r=require("../../type"),m=require("../../../credits/context/utils"),M=require("../../../../constants");function ee({copy:a}){const{profile:n,creditInfo:l,openSignUpPopup:f,alpcConfig:o,isActivateSuccess:U,fetchCreditInfo:$,pageHandle:x}=(0,D.useMemberPopupContext)(),{pushView:w}=(0,S.useViewStack)(),{brand:F}=(0,i.useHeadlessContext)(),h=M.ROUNDED_BRANDS.includes(F),[R,I]=(0,u.useState)(""),[T,k]=(0,u.useState)(null);(0,u.useEffect)(()=>{n?.user_id&&$(n.user_id)},[]);const c=!!n,{redeemableList:B,listLoading:z}=(0,L.useRedeemableList)(o),{trigger:O}=(0,E.useRedeemAndBuy)(o),G=a.list.map(e=>e.product?.handle).filter(Boolean),{data:A}=(0,i.useProductsByHandles)({handles:G}),V=(0,u.useMemo)(()=>a.list.map(e=>{const s=B.find(p=>String(p.id)===String(e.redeemId));if(!s)return null;const d=Number(l?.available_credit??0),g=s.consume_credits>d,C=s.is_limited&&(!s.remaining_inventory||s.remaining_inventory<=0),q=e.type===r.ConsumeCreditsItemType.RedeemAndBuy||e.type===r.ConsumeCreditsItemType.Product,b=A?.find(p=>p.handle===e.product?.handle),y=b?.variants?.find(p=>p.sku===e.product?.sku)??b?.variants?.[0];return q&&(!b||!y||!y?.availableForSale||C)||e.type===r.ConsumeCreditsItemType.RedeemAndBuy&&e.price==null?null:{...e,alpcData:s,insufficient:g,product:b,variant:y}}).filter(Boolean),[a.list,B,l,n,c,A]),v=n?.activated||U;function j(e){return!c||!v?a.unlockRewards:e.soldOut?a.soldOut:a.btnRedeem}function H(e){return!c||!v?!1:e.insufficient}function _(e){(0,i.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"redeem",info:"Member Floating Window"}})}async function W(e){if(!c){f();return}if(!v){w({type:r.MemberPopupPanelType.Activate});return}if(e.type===r.ConsumeCreditsItemType.GiftCard||e.type===r.ConsumeCreditsItemType.Product){if(a.creditsPage?.url){const s=a.creditsPage.redeemListSectionId??"creditsRedeemList",d=new URL(a.creditsPage.url,window.location.href);d.searchParams.set("section",s),d.hash=s,x&&d.searchParams.set("ref",`${x}_consume_credits`),_(e.title),window.open(d.toString(),"_blank","noopener,noreferrer")}return}if(e.type===r.ConsumeCreditsItemType.Coupon)_(e.title),w({type:r.MemberPopupPanelType.RedeemCoupon,props:{itemTitle:e.title,itemCredits:e.alpcData.consume_credits,itemImage:a.imageMapping?.[e.type]?{url:a.imageMapping[e.type].url,alt:e.image?.alt}:e.image,itemValue:e.value,itemRules:e.rules,redeemId:Number(e.redeemId),userId:n?.user_id,alpcConfig:o}});else{I(""),k(e.redeemId),_(e.title);try{await O({productVariant:e.variant,redeemId:Number(e.redeemId),userId:n?.user_id}),(0,i.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"redeem_success",info:"Member Floating Window"}})}catch(s){I(s?.message??a.redeemModal.commonError)}finally{k(null)}}}return(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("div",{className:"flex flex-1 flex-col",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-[8px]",children:[a.title&&(0,t.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:a.title}),a.subtitle&&(0,t.jsx)("p",{className:"text-[16px] mt-[8px] font-[700] leading-snug text-[#4a4c56]",children:a.subtitle})]}),c&&(0,t.jsxs)("div",{className:(0,i.classNames)("flex items-center mt-[16px] gap-[12px] bg-[#f5f6f7] p-[16px]",h?"rounded-[8px]":"rounded-none"),children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,t.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:a.balanceLabel??"AnkerCredits Balance"}),(0,t.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,t.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,m.numberFormat)(l?.available_credit||0)}),(0,t.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:a.creditUnit??"ankercredits"})]})]}),(0,t.jsx)("div",{className:"h-full w-px bg-[#dadce0]"}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,t.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:a.comingSoonLabel??"Coming Soon"}),(0,t.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,t.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,m.numberFormat)(l?.pending_credit||0)}),(0,t.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:a.creditUnit??"ankercredits"})]})]})]}),R&&(0,t.jsx)("div",{className:"text-[14px] mt-[8px] font-[700] text-[#f84d4f]",children:R}),z?(0,t.jsx)("div",{className:"flex flex-1 items-center justify-center py-[32px]",children:(0,t.jsx)("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}):(0,t.jsx)("div",{className:"flex mt-[16px] flex-col",children:V.map((e,s)=>(0,t.jsxs)("div",{className:"relative py-[16px]",children:[s>0&&(0,t.jsx)("div",{className:"absolute inset-x-0 top-0 h-px bg-[#dadce0]"}),(0,t.jsxs)("div",{className:"flex items-center gap-[12px]",children:[(()=>{const d=e.type===r.ConsumeCreditsItemType.Product||e.type===r.ConsumeCreditsItemType.RedeemAndBuy,g=d?e.variant?.image?.url??e.product?.images?.[0]?.url??e.image?.url:e.image?.url||a.imageMapping?.[e.type]?.url,C=d?e.variant?.image?.altText??e.product?.images?.[0]?.alt??e.image?.alt??"":e.image?.alt??"";return g?(0,t.jsxs)("div",{className:(0,i.classNames)("relative size-[64px] shrink-0 overflow-hidden",h?"rounded-[4px]":"rounded-none"),children:[(0,t.jsx)(N.Picture,{source:g,alt:C,className:"flex size-full items-center justify-center",imgClassName:d?"object-cover":"h-full w-auto object-contain"}),e.type===r.ConsumeCreditsItemType.Coupon&&e.value&&(0,t.jsx)("div",{className:"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white",children:e.value&&`${e.value} ${a.off}`}),e.type===r.ConsumeCreditsItemType.GiftCard&&e.value&&(0,t.jsx)("div",{className:"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white",children:e.value&&`${e.value} ${a.giftCard||"Gift Card"}`})]}):null})(),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("div",{className:"text-[16px] font-[700] text-[#1e2024] line-clamp-2",children:e.product.title??e.title??e.alpcData?.name}),(0,t.jsx)("div",{className:"mt-[4px] text-[14px] text-[#666]",children:e.type===r.ConsumeCreditsItemType.RedeemAndBuy?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{children:[(0,m.numberFormat)(e.alpcData.consume_credits)," ",a.creditUnit??""," + $",Number(e.price).toFixed(2)]}),e.variant?.price?.amount&&(0,t.jsxs)("div",{className:"text-[12px] text-[#999] line-through",children:["$",Number(e.variant.price.amount).toFixed(2)]})]}):`${(0,m.numberFormat)(e.alpcData.consume_credits)} ${a.creditUnit??""}`})]}),(0,t.jsxs)("div",{className:"relative group",children:[(0,t.jsx)(N.Button,{className:(0,i.classNames)("bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",h?"rounded-[4px]":"rounded-none"),disabled:H(e),loading:T===e.redeemId,onClick:()=>W(e),children:j(e)}),e.insufficient&&c&&v&&(0,t.jsx)("div",{className:"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block",children:(0,t.jsxs)("div",{className:"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow",children:[(0,t.jsx)("p",{className:"text-pretty tracking-[-0.02em] text-[14px]",children:a.insufficientCredits}),(0,t.jsx)("div",{className:"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]"})]})})]})]})]},s))}),a.creditsPage?.url&&(0,t.jsx)("a",{href:(()=>{if(!x)return a.creditsPage.url;try{const e=new URL(a.creditsPage.url,window.location.href);return e.searchParams.set("ref",`${x}_consume_credits`),e.toString()}catch{return a.creditsPage.url}})(),target:"_blank",rel:"noopener noreferrer",className:"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline",onClick:()=>(0,i.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"credits_page_link",info:"Member Floating Window"}}),children:a.creditsPage.label??"Go to Credits Page"})]})})}var te=ee;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/ConsumeCredits/index.tsx"],
4
- "sourcesContent": ["import { useEffect, useMemo, useState } from 'react'\nimport { Picture, Button } from '@anker-in/headless-ui'\nimport { gaTrack, classNames as cn, useProductsByHandles, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useRedeemableList } from './hooks/useRedeemableList'\nimport { useRedeemAndBuy } from './hooks/useRedeemAndBuy'\nimport {\n ConsumeCreditsItemType,\n MemberPopupPanelType,\n type ConsumeCreditsopy,\n type ConsumeCreditsItem,\n} from '../../type'\nimport { numberFormat } from '../../../credits/context/utils'\nimport type { ConsumeCreditRuleResponse } from '../../../credits/context/response'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype EnrichedItem = ConsumeCreditsItem & {\n alpcData: ConsumeCreditRuleResponse\n insufficient: boolean\n soldOut: boolean\n disabled: boolean\n product?: any\n variant?: any\n}\n\ntype Props = {\n copy: ConsumeCreditsopy\n}\n\nfunction ConsumeCredits({ copy }: Props) {\n const { profile, creditInfo, openSignUpPopup, alpcConfig, isActivateSuccess, fetchCreditInfo, pageHandle } =\n useMemberPopupContext()\n const { pushView } = useViewStack()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const [redeemAndBuyError, setRedeemAndBuyError] = useState('')\n const [loadingId, setLoadingId] = useState<string | number | null>(null)\n\n useEffect(() => {\n if (profile?.user_id) fetchCreditInfo(profile.user_id)\n }, [])\n\n const isLogin = !!profile\n const { redeemableList, listLoading } = useRedeemableList(alpcConfig)\n const { trigger: redeemAndBuy } = useRedeemAndBuy(alpcConfig)\n\n const handles = copy.list.map(item => item.product?.handle).filter(Boolean) as string[]\n const { data: products } = useProductsByHandles({ handles })\n\n const list = useMemo(() => {\n return copy.list\n .map(item => {\n const alpcData = redeemableList.find(r => String(r.id) === String(item.redeemId))\n if (!alpcData) return null\n\n const availableCredit = Number(creditInfo?.available_credit ?? 0)\n const insufficient = alpcData.consume_credits > availableCredit\n const alpcSoldOut = alpcData.is_limited && (!alpcData.remaining_inventory || alpcData.remaining_inventory <= 0)\n\n const isPhysicalProduct =\n item.type === ConsumeCreditsItemType.RedeemAndBuy || item.type === ConsumeCreditsItemType.Product\n const product = products?.find((p: any) => p.handle === item.product?.handle)\n const variant = product?.variants?.find((v: any) => v.sku === item.product?.sku) ?? product?.variants?.[0]\n if (isPhysicalProduct && (!product || !variant || !variant?.availableForSale || alpcSoldOut)) {\n return null\n }\n return { ...item, alpcData, insufficient, product, variant }\n })\n .filter(Boolean) as EnrichedItem[]\n }, [copy.list, redeemableList, creditInfo, profile, isLogin, products])\n\n const isActivate = profile?.activated || isActivateSuccess\n\n function getButtonLabel(item: (typeof list)[number]) {\n if (!isLogin || !isActivate) {\n return copy.unlockRewards\n }\n if (item.soldOut) {\n return copy.soldOut\n }\n return copy.btnRedeem\n }\n\n function isDisabled(item: (typeof list)[number]) {\n if (!isLogin || !isActivate) {\n return false\n }\n return item.insufficient\n }\n\n function trackRedeemButton(itemTitle: string) {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem',\n info: 'Member Floating Window',\n },\n })\n }\n\n async function handleRedeem(item: (typeof list)[number]) {\n if (!isLogin) {\n openSignUpPopup()\n return\n }\n if (!isActivate) {\n pushView({\n type: MemberPopupPanelType.Activate,\n })\n return\n }\n if (item.type === ConsumeCreditsItemType.GiftCard || item.type === ConsumeCreditsItemType.Product) {\n if (copy.creditsPage?.url) {\n const sectionId = copy.creditsPage.redeemListSectionId ?? 'creditsRedeemList'\n const targetUrl = new URL(copy.creditsPage.url, window.location.href)\n targetUrl.searchParams.set('section', sectionId)\n targetUrl.hash = sectionId\n if (pageHandle) {\n targetUrl.searchParams.set('ref', `${pageHandle}_consume_credits`)\n }\n trackRedeemButton(item.title)\n window.open(targetUrl.toString(), '_blank', 'noopener,noreferrer')\n }\n return\n }\n if (item.type === ConsumeCreditsItemType.Coupon) {\n trackRedeemButton(item.title)\n pushView({\n type: MemberPopupPanelType.RedeemCoupon,\n props: {\n itemTitle: item.title,\n itemCredits: item.alpcData.consume_credits,\n itemImage: copy.imageMapping?.[item.type]\n ? { url: copy.imageMapping[item.type]!.url, alt: item.image?.alt }\n : item.image,\n itemValue: item.value,\n itemRules: item.rules,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n alpcConfig,\n },\n })\n } else {\n setRedeemAndBuyError('')\n setLoadingId(item.redeemId)\n trackRedeemButton(item.title)\n try {\n await redeemAndBuy({\n productVariant: item.variant,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n })\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem_success',\n info: 'Member Floating Window',\n },\n })\n } catch (e: any) {\n setRedeemAndBuyError(e?.message ?? copy.redeemModal.commonError)\n } finally {\n setLoadingId(null)\n }\n }\n }\n\n return (\n <>\n <div className=\"flex flex-1 flex-col\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>}\n {copy.subtitle && (\n <p className=\"text-[16px] mt-[8px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>\n )}\n </div>\n\n {isLogin && (\n <div\n className={cn(\n 'flex items-center mt-[16px] gap-[12px] bg-[#f5f6f7] p-[16px]',\n rounded ? 'rounded-[8px]' : 'rounded-none'\n )}\n >\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.balanceLabel ?? 'AnkerCredits Balance'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.available_credit || 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n <div className=\"h-full w-px bg-[#dadce0]\" />\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.comingSoonLabel ?? 'Coming Soon'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.pending_credit || 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n </div>\n )}\n {redeemAndBuyError && <div className=\"text-[14px] mt-[8px] font-[700] text-[#f84d4f]\">{redeemAndBuyError}</div>}\n\n {listLoading ? (\n <div className=\"flex flex-1 items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n ) : (\n <div className=\"flex mt-[16px] flex-col\">\n {list.map((item, idx) => {\n const hasProduct = !!item.product\n return (\n <div key={idx} className=\"relative py-[16px]\">\n {idx > 0 && <div className=\"absolute inset-x-0 top-0 h-px bg-[#dadce0]\" />}\n <div className=\"flex items-center gap-[12px]\">\n {(() => {\n const mappedImgUrl = copy.imageMapping?.[item.type]?.url\n const imgUrl = hasProduct\n ? (item.variant?.image?.url ?? item.product?.images?.[0]?.url ?? item.image?.url)\n : (mappedImgUrl ?? item.image?.url)\n const imgAlt = hasProduct\n ? (item.variant?.image?.altText ?? item.product?.images?.[0]?.alt ?? item.image?.alt ?? '')\n : (item.image?.alt ?? '')\n if (!imgUrl) return null\n return (\n <div\n className={cn(\n 'relative size-[64px] shrink-0 overflow-hidden',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n >\n <Picture\n source={imgUrl}\n alt={imgAlt}\n className=\"flex size-full items-center justify-center\"\n imgClassName={hasProduct ? 'object-cover' : 'h-full w-auto object-contain'}\n />\n {!hasProduct && item.value && (\n <div className=\"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white\">\n {item.value} {copy.off}\n </div>\n )}\n </div>\n )\n })()}\n <div className=\"min-w-0 flex-1\">\n <div className=\"text-[16px] font-[700] text-[#1e2024] line-clamp-2\">\n {hasProduct && item.product?.title ? item.product.title : item.title}\n </div>\n <div className=\"mt-[4px] text-[14px] text-[#666]\">\n {hasProduct && item.price != null\n ? `${numberFormat(item.alpcData.consume_credits)} ${copy.creditUnit ?? ''} + $${Number(item.price).toFixed(2)}`\n : `${numberFormat(item.alpcData.consume_credits)} ${copy.creditUnit ?? ''}`}\n </div>\n </div>\n <div className=\"relative group\">\n <Button\n className={cn(\n 'bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={isDisabled(item)}\n loading={loadingId === item.redeemId}\n onClick={() => handleRedeem(item)}\n >\n {getButtonLabel(item)}\n </Button>\n {item.insufficient && isLogin && isActivate && (\n <div className=\"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block\">\n <div className=\"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow\">\n <p className=\"text-pretty tracking-[-0.02em] text-[14px]\">{copy.insufficientCredits}</p>\n <div className=\"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]\" />\n </div>\n </div>\n )}\n </div>\n </div>\n </div>\n )\n })}\n </div>\n )}\n\n {copy.creditsPage?.url && (\n <a\n href={(() => {\n if (!pageHandle) return copy.creditsPage!.url\n try {\n const url = new URL(copy.creditsPage!.url, window.location.href)\n url.searchParams.set('ref', `${pageHandle}_consume_credits`)\n return url.toString()\n } catch {\n return copy.creditsPage!.url\n }\n })()}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline\"\n onClick={() =>\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'credits_page_link',\n info: 'Member Floating Window',\n },\n })\n }\n >\n {copy.creditsPage.label ?? 'Go to Credits Page'}\n </a>\n )}\n </div>\n </>\n )\n}\n\nexport default ConsumeCredits\n"],
5
- "mappings": "yaAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,eAAAC,EAAAH,IA8KI,IAAAI,EAAA,6BA9KJC,EAA6C,iBAC7CC,EAAgC,iCAChCC,EAAoF,yBACpFC,EAAsC,kCACtCC,EAA6B,mCAC7BC,EAAkC,qCAClCC,EAAgC,mCAChCC,EAKO,sBACPC,EAA6B,0CAE7BC,EAA+B,iCAe/B,SAASC,GAAe,CAAE,KAAAC,CAAK,EAAU,CACvC,KAAM,CAAE,QAAAC,EAAS,WAAAC,EAAY,gBAAAC,EAAiB,WAAAC,EAAY,kBAAAC,EAAmB,gBAAAC,EAAiB,WAAAC,CAAW,KACvG,yBAAsB,EAClB,CAAE,SAAAC,CAAS,KAAI,gBAAa,EAC5B,CAAE,MAAAC,CAAM,KAAI,sBAAmB,EAC/BC,EAAU,iBAAe,SAASD,CAAK,EAEvC,CAACE,EAAmBC,CAAoB,KAAI,YAAS,EAAE,EACvD,CAACC,EAAWC,CAAY,KAAI,YAAiC,IAAI,KAEvE,aAAU,IAAM,CACVb,GAAS,SAASK,EAAgBL,EAAQ,OAAO,CACvD,EAAG,CAAC,CAAC,EAEL,MAAMc,EAAU,CAAC,CAACd,EACZ,CAAE,eAAAe,EAAgB,YAAAC,CAAY,KAAI,qBAAkBb,CAAU,EAC9D,CAAE,QAASc,CAAa,KAAI,mBAAgBd,CAAU,EAEtDe,EAAUnB,EAAK,KAAK,IAAIoB,GAAQA,EAAK,SAAS,MAAM,EAAE,OAAO,OAAO,EACpE,CAAE,KAAMC,CAAS,KAAI,wBAAqB,CAAE,QAAAF,CAAQ,CAAC,E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AAI,EACtB,EACCA,EAAK,cAAgBL,GAAWiB,MAC/B,OAAC,OAAI,UAAU,qGACb,oBAAC,OAAI,UAAU,0EACb,oBAAC,KAAE,UAAU,6CAA8C,SAAAhC,EAAK,oBAAoB,KACpF,OAAC,OAAI,UAAU,oGAAoG,GACrH,EACF,GAEJ,GACF,IAhEQ0C,CAiEV,CAEJ,CAAC,EACH,EAGD1C,EAAK,aAAa,QACjB,OAAC,KACC,MAAO,IAAM,CACX,GAAI,CAACO,EAAY,OAAOP,EAAK,YAAa,IAC1C,GAAI,CACF,MAAM+C,EAAM,IAAI,IAAI/C,EAAK,YAAa,IAAK,OAAO,SAAS,IAAI,EAC/D,OAAA+C,EAAI,aAAa,IAAI,MAAO,GAAGxC,CAAU,kBAAkB,EACpDwC,EAAI,SAAS,CACtB,MAAQ,CACN,OAAO/C,EAAK,YAAa,GAC3B,CACF,GAAG,EACH,OAAO,SACP,IAAI,sBACJ,UAAU,qEACV,QAAS,OACP,WAAQ,CACN,MAAO,WACP,WAAY,YACZ,iBAAkB,CAChB,SAAU,kBACV,YAAa,oBACb,KAAM,wBACR,CACF,CAAC,EAGF,SAAAA,EAAK,YAAY,OAAS,qBAC7B,GAEJ,EACF,CAEJ,CAEA,IAAOd,GAAQa",
6
- "names": ["ConsumeCredits_exports", "__export", "ConsumeCredits_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_provider", "import_viewStack", "import_useRedeemableList", "import_useRedeemAndBuy", "import_type", "import_utils", "import_constants", "ConsumeCredits", "copy", "profile", "creditInfo", "openSignUpPopup", "alpcConfig", "isActivateSuccess", "fetchCreditInfo", "pageHandle", "pushView", "brand", "rounded", "redeemAndBuyError", "setRedeemAndBuyError", "loadingId", "setLoadingId", "isLogin", "redeemableList", "listLoading", "redeemAndBuy", "handles", "item", "products", "list", "alpcData", "r", "availableCredit", "insufficient", "alpcSoldOut", "isPhysicalProduct", "product", "variant", "v", "isActivate", "getButtonLabel", "isDisabled", "trackRedeemButton", "itemTitle", "handleRedeem", "sectionId", "targetUrl", "e", "cn", "idx", "hasProduct", "mappedImgUrl", "imgUrl", "imgAlt", "url"]
4
+ "sourcesContent": ["import { useEffect, useMemo, useState } from 'react'\nimport { Picture, Button } from '@anker-in/headless-ui'\nimport { gaTrack, classNames as cn, useProductsByHandles, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useRedeemableList } from './hooks/useRedeemableList'\nimport { useRedeemAndBuy } from './hooks/useRedeemAndBuy'\nimport {\n ConsumeCreditsItemType,\n MemberPopupPanelType,\n type ConsumeCreditsopy,\n type ConsumeCreditsItem,\n} from '../../type'\nimport { numberFormat } from '../../../credits/context/utils'\nimport type { ConsumeCreditRuleResponse } from '../../../credits/context/response'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype EnrichedItem = ConsumeCreditsItem & {\n alpcData: ConsumeCreditRuleResponse\n insufficient: boolean\n soldOut: boolean\n disabled: boolean\n product?: any\n variant?: any\n}\n\ntype Props = {\n copy: ConsumeCreditsopy\n}\n\nfunction ConsumeCredits({ copy }: Props) {\n const { profile, creditInfo, openSignUpPopup, alpcConfig, isActivateSuccess, fetchCreditInfo, pageHandle } =\n useMemberPopupContext()\n const { pushView } = useViewStack()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const [redeemAndBuyError, setRedeemAndBuyError] = useState('')\n const [loadingId, setLoadingId] = useState<string | number | null>(null)\n\n useEffect(() => {\n if (profile?.user_id) fetchCreditInfo(profile.user_id)\n }, [])\n\n const isLogin = !!profile\n const { redeemableList, listLoading } = useRedeemableList(alpcConfig)\n const { trigger: redeemAndBuy } = useRedeemAndBuy(alpcConfig)\n\n const handles = copy.list.map(item => item.product?.handle).filter(Boolean) as string[]\n const { data: products } = useProductsByHandles({ handles })\n\n const list = useMemo(() => {\n return copy.list\n .map(item => {\n const alpcData = redeemableList.find(r => String(r.id) === String(item.redeemId))\n if (!alpcData) return null\n\n const availableCredit = Number(creditInfo?.available_credit ?? 0)\n const insufficient = alpcData.consume_credits > availableCredit\n const alpcSoldOut = alpcData.is_limited && (!alpcData.remaining_inventory || alpcData.remaining_inventory <= 0)\n\n const isPhysicalProduct =\n item.type === ConsumeCreditsItemType.RedeemAndBuy || item.type === ConsumeCreditsItemType.Product\n const product = products?.find((p: any) => p.handle === item.product?.handle)\n const variant = product?.variants?.find((v: any) => v.sku === item.product?.sku) ?? product?.variants?.[0]\n if (isPhysicalProduct && (!product || !variant || !variant?.availableForSale || alpcSoldOut)) {\n return null\n }\n if (item.type === ConsumeCreditsItemType.RedeemAndBuy && item.price == null) {\n return null\n }\n return { ...item, alpcData, insufficient, product, variant }\n })\n .filter(Boolean) as EnrichedItem[]\n }, [copy.list, redeemableList, creditInfo, profile, isLogin, products])\n\n const isActivate = profile?.activated || isActivateSuccess\n\n function getButtonLabel(item: (typeof list)[number]) {\n if (!isLogin || !isActivate) {\n return copy.unlockRewards\n }\n if (item.soldOut) {\n return copy.soldOut\n }\n return copy.btnRedeem\n }\n\n function isDisabled(item: (typeof list)[number]) {\n if (!isLogin || !isActivate) {\n return false\n }\n return item.insufficient\n }\n\n function trackRedeemButton(itemTitle: string) {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem',\n info: 'Member Floating Window',\n },\n })\n }\n\n async function handleRedeem(item: (typeof list)[number]) {\n if (!isLogin) {\n openSignUpPopup()\n return\n }\n if (!isActivate) {\n pushView({\n type: MemberPopupPanelType.Activate,\n })\n return\n }\n if (item.type === ConsumeCreditsItemType.GiftCard || item.type === ConsumeCreditsItemType.Product) {\n if (copy.creditsPage?.url) {\n const sectionId = copy.creditsPage.redeemListSectionId ?? 'creditsRedeemList'\n const targetUrl = new URL(copy.creditsPage.url, window.location.href)\n targetUrl.searchParams.set('section', sectionId)\n targetUrl.hash = sectionId\n if (pageHandle) {\n targetUrl.searchParams.set('ref', `${pageHandle}_consume_credits`)\n }\n trackRedeemButton(item.title)\n window.open(targetUrl.toString(), '_blank', 'noopener,noreferrer')\n }\n return\n }\n if (item.type === ConsumeCreditsItemType.Coupon) {\n trackRedeemButton(item.title)\n pushView({\n type: MemberPopupPanelType.RedeemCoupon,\n props: {\n itemTitle: item.title,\n itemCredits: item.alpcData.consume_credits,\n itemImage: copy.imageMapping?.[item.type]\n ? { url: copy.imageMapping[item.type]!.url, alt: item.image?.alt }\n : item.image,\n itemValue: item.value,\n itemRules: item.rules,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n alpcConfig,\n },\n })\n } else {\n setRedeemAndBuyError('')\n setLoadingId(item.redeemId)\n trackRedeemButton(item.title)\n try {\n await redeemAndBuy({\n productVariant: item.variant,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n })\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem_success',\n info: 'Member Floating Window',\n },\n })\n } catch (e: any) {\n setRedeemAndBuyError(e?.message ?? copy.redeemModal.commonError)\n } finally {\n setLoadingId(null)\n }\n }\n }\n\n return (\n <>\n <div className=\"flex flex-1 flex-col\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>}\n {copy.subtitle && (\n <p className=\"text-[16px] mt-[8px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>\n )}\n </div>\n\n {isLogin && (\n <div\n className={cn(\n 'flex items-center mt-[16px] gap-[12px] bg-[#f5f6f7] p-[16px]',\n rounded ? 'rounded-[8px]' : 'rounded-none'\n )}\n >\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.balanceLabel ?? 'AnkerCredits Balance'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.available_credit || 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n <div className=\"h-full w-px bg-[#dadce0]\" />\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.comingSoonLabel ?? 'Coming Soon'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.pending_credit || 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n </div>\n )}\n {redeemAndBuyError && <div className=\"text-[14px] mt-[8px] font-[700] text-[#f84d4f]\">{redeemAndBuyError}</div>}\n\n {listLoading ? (\n <div className=\"flex flex-1 items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n ) : (\n <div className=\"flex mt-[16px] flex-col\">\n {list.map((item, idx) => {\n return (\n <div key={idx} className=\"relative py-[16px]\">\n {idx > 0 && <div className=\"absolute inset-x-0 top-0 h-px bg-[#dadce0]\" />}\n <div className=\"flex items-center gap-[12px]\">\n {(() => {\n const phsicalProduct =\n item.type === ConsumeCreditsItemType.Product ||\n item.type === ConsumeCreditsItemType.RedeemAndBuy\n const imgUrl = phsicalProduct\n ? (item.variant?.image?.url ?? item.product?.images?.[0]?.url ?? item.image?.url)\n : item.image?.url || copy.imageMapping?.[item.type]?.url\n const imgAlt = phsicalProduct\n ? (item.variant?.image?.altText ?? item.product?.images?.[0]?.alt ?? item.image?.alt ?? '')\n : (item.image?.alt ?? '')\n if (!imgUrl) return null\n return (\n <div\n className={cn(\n 'relative size-[64px] shrink-0 overflow-hidden',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n >\n <Picture\n source={imgUrl}\n alt={imgAlt}\n className=\"flex size-full items-center justify-center\"\n imgClassName={phsicalProduct ? 'object-cover' : 'h-full w-auto object-contain'}\n />\n {item.type === ConsumeCreditsItemType.Coupon && item.value && (\n <div className=\"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white\">\n {item.value && `${item.value} ${copy.off}`}\n </div>\n )}\n {item.type === ConsumeCreditsItemType.GiftCard && item.value && (\n <div className=\"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white\">\n {item.value && `${item.value} ${copy.giftCard || 'Gift Card'}`}\n </div>\n )}\n </div>\n )\n })()}\n <div className=\"min-w-0 flex-1\">\n <div className=\"text-[16px] font-[700] text-[#1e2024] line-clamp-2\">\n {item.product.title ?? item.title ?? item.alpcData?.name}\n </div>\n <div className=\"mt-[4px] text-[14px] text-[#666]\">\n {item.type === ConsumeCreditsItemType.RedeemAndBuy ? (\n <>\n <div>\n {numberFormat(item.alpcData.consume_credits)} {copy.creditUnit ?? ''} + $\n {Number(item.price).toFixed(2)}\n </div>\n {item.variant?.price?.amount && (\n <div className=\"text-[12px] text-[#999] line-through\">\n ${Number(item.variant.price.amount).toFixed(2)}\n </div>\n )}\n </>\n ) : (\n `${numberFormat(item.alpcData.consume_credits)} ${copy.creditUnit ?? ''}`\n )}\n </div>\n </div>\n <div className=\"relative group\">\n <Button\n className={cn(\n 'bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={isDisabled(item)}\n loading={loadingId === item.redeemId}\n onClick={() => handleRedeem(item)}\n >\n {getButtonLabel(item)}\n </Button>\n {item.insufficient && isLogin && isActivate && (\n <div className=\"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block\">\n <div className=\"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow\">\n <p className=\"text-pretty tracking-[-0.02em] text-[14px]\">{copy.insufficientCredits}</p>\n <div className=\"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]\" />\n </div>\n </div>\n )}\n </div>\n </div>\n </div>\n )\n })}\n </div>\n )}\n\n {copy.creditsPage?.url && (\n <a\n href={(() => {\n if (!pageHandle) return copy.creditsPage!.url\n try {\n const url = new URL(copy.creditsPage!.url, window.location.href)\n url.searchParams.set('ref', `${pageHandle}_consume_credits`)\n return url.toString()\n } catch {\n return copy.creditsPage!.url\n }\n })()}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline\"\n onClick={() =>\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'credits_page_link',\n info: 'Member Floating Window',\n },\n })\n }\n >\n {copy.creditsPage.label ?? 'Go to Credits Page'}\n </a>\n )}\n </div>\n </>\n )\n}\n\nexport default ConsumeCredits\n"],
5
+ "mappings": "yaAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,eAAAC,EAAAH,IAmLQ,IAAAI,EAAA,6BAnLRC,EAA6C,iBAC7CC,EAAgC,iCAChCC,EAAoF,yBACpFC,EAAsC,kCACtCC,EAA6B,mCAC7BC,EAAkC,qCAClCC,EAAgC,mCAChCC,EAKO,sBACPC,EAA6B,0CAE7BC,EAA+B,iCAe/B,SAASC,GAAe,CAAE,KAAAC,CAAK,EAAU,CACvC,KAAM,CAAE,QAAAC,EAAS,WAAAC,EAAY,gBAAAC,EAAiB,WAAAC,EAAY,kBAAAC,EAAmB,gBAAAC,EAAiB,WAAAC,CAAW,KACvG,yBAAsB,EAClB,CAAE,SAAAC,CAAS,KAAI,gBAAa,EAC5B,CAAE,MAAAC,CAAM,KAAI,sBAAmB,EAC/BC,EAAU,iBAAe,SAASD,CAAK,EAEvC,CAACE,EAAmBC,CAAoB,KAAI,YAAS,E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CAAU,kBAAkB,EACpDuC,EAAI,SAAS,CACtB,MAAQ,CACN,OAAO9C,EAAK,YAAa,GAC3B,CACF,GAAG,EACH,OAAO,SACP,IAAI,sBACJ,UAAU,qEACV,QAAS,OACP,WAAQ,CACN,MAAO,WACP,WAAY,YACZ,iBAAkB,CAChB,SAAU,kBACV,YAAa,oBACb,KAAM,wBACR,CACF,CAAC,EAGF,SAAAA,EAAK,YAAY,OAAS,qBAC7B,GAEJ,EACF,CAEJ,CAEA,IAAOd,GAAQa",
6
+ "names": ["ConsumeCredits_exports", "__export", "ConsumeCredits_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_provider", "import_viewStack", "import_useRedeemableList", "import_useRedeemAndBuy", "import_type", "import_utils", "import_constants", "ConsumeCredits", "copy", "profile", "creditInfo", "openSignUpPopup", "alpcConfig", "isActivateSuccess", "fetchCreditInfo", "pageHandle", "pushView", "brand", "rounded", "redeemAndBuyError", "setRedeemAndBuyError", "loadingId", "setLoadingId", "isLogin", "redeemableList", "listLoading", "redeemAndBuy", "handles", "item", "products", "list", "alpcData", "r", "availableCredit", "insufficient", "alpcSoldOut", "isPhysicalProduct", "product", "variant", "v", "isActivate", "getButtonLabel", "isDisabled", "trackRedeemButton", "itemTitle", "handleRedeem", "sectionId", "targetUrl", "e", "cn", "idx", "phsicalProduct", "imgUrl", "imgAlt", "url"]
7
7
  }
@@ -147,6 +147,7 @@ export type ConsumeCreditsopy = {
147
147
  comingSoonLabel?: string;
148
148
  creditUnit?: string;
149
149
  off?: string;
150
+ giftCard?: string;
150
151
  imageMapping?: {
151
152
  [key in ConsumeCreditsItemType]?: {
152
153
  url: string;
@@ -190,6 +191,8 @@ export type RedeemCouponModalCopy = {
190
191
  successDesc: string;
191
192
  successButton: string;
192
193
  successButtonUrl?: string;
194
+ copyLabel?: string;
195
+ copiedLabel?: string;
193
196
  };
194
197
  export type ReferralCopy = {
195
198
  title?: string;
@@ -1,2 +1,2 @@
1
- "use strict";var g=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var m=(r,e)=>{for(var o in e)g(r,o,{get:e[o],enumerable:!0})},E=(r,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of C(e))!b.call(r,t)&&t!==o&&g(r,t,{get:()=>e[t],enumerable:!(s=d(e,t))||s.enumerable});return r};var f=r=>E(g({},"__esModule",{value:!0}),r);var L={};m(L,{ConsumeCreditsItemType:()=>p,EarnCreditsTaskType:()=>c,MemberPopupActionType:()=>a,MemberPopupPageScope:()=>u,MemberPopupPanelType:()=>l});module.exports=f(L);var l=(i=>(i.EarnCredits="EARN_CREDITS",i.ConsumeCredits="CONSUME_CREDITS",i.Referral="REFERRAL",i.CompleteProfile="COMPLETE_PROFILE",i.Subscribe="SUBSCRIBE",i.SubscribeEmail="SUBSCRIBE_EMAIL",i.RedeemCoupon="REDEEM_COUPON",i.Activate="ACTIVATE",i))(l||{}),a=(n=>(n.ExternalLink="EXTERNAL_LINK",n.OpenEarnCredits="OPEN_EARN_CREDITS",n.OpenConsumeCredits="OPEN_CONSUME_CREDITS",n.OpenReferral="OPEN_REFERRAL",n.OpenSubscribe="OPEN_SUBSCRIBE",n))(a||{}),c=(t=>(t.Activate="activate",t.CompleteProfile="completeProfile",t.Subscribe="subscribe",t.Shop="shop",t))(c||{}),p=(t=>(t.Coupon="COUPON",t.RedeemAndBuy="REDEEM_AND_BUY",t.GiftCard="GIFT_CARD",t.Product="PRODUCT",t))(p||{}),u=(s=>(s.Global="GLOBAL",s.Include="INCLUDE",s.Exclude="EXCLUDE",s))(u||{});
1
+ "use strict";var g=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var m=(r,e)=>{for(var o in e)g(r,o,{get:e[o],enumerable:!0})},E=(r,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of C(e))!b.call(r,t)&&t!==o&&g(r,t,{get:()=>e[t],enumerable:!(s=u(e,t))||s.enumerable});return r};var f=r=>E(g({},"__esModule",{value:!0}),r);var L={};m(L,{ConsumeCreditsItemType:()=>p,EarnCreditsTaskType:()=>c,MemberPopupActionType:()=>a,MemberPopupPageScope:()=>d,MemberPopupPanelType:()=>l});module.exports=f(L);var l=(i=>(i.EarnCredits="EARN_CREDITS",i.ConsumeCredits="CONSUME_CREDITS",i.Referral="REFERRAL",i.CompleteProfile="COMPLETE_PROFILE",i.Subscribe="SUBSCRIBE",i.SubscribeEmail="SUBSCRIBE_EMAIL",i.RedeemCoupon="REDEEM_COUPON",i.Activate="ACTIVATE",i))(l||{}),a=(n=>(n.ExternalLink="EXTERNAL_LINK",n.OpenEarnCredits="OPEN_EARN_CREDITS",n.OpenConsumeCredits="OPEN_CONSUME_CREDITS",n.OpenReferral="OPEN_REFERRAL",n.OpenSubscribe="OPEN_SUBSCRIBE",n))(a||{}),c=(t=>(t.Activate="activate",t.CompleteProfile="completeProfile",t.Subscribe="subscribe",t.Shop="shop",t))(c||{}),p=(t=>(t.Coupon="COUPON",t.RedeemAndBuy="REDEEM_AND_BUY",t.GiftCard="GIFT_CARD",t.Product="PRODUCT",t))(p||{}),d=(s=>(s.Global="GLOBAL",s.Include="INCLUDE",s.Exclude="EXCLUDE",s))(d||{});
2
2
  //# sourceMappingURL=type.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/memberPopup/type.ts"],
4
- "sourcesContent": ["import type { AuthCodeActivateCopy } from '../registration/authCodeActivate/type'\nimport type { CreditInfoResponse } from '../credits/context/response'\nimport type { DTC_TASK_TYPE } from '../credits/context/const'\n\nexport type { AuthCodeActivateCopy }\n\n// \u2500\u2500\u2500 \u9762\u677F\u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupPanelType {\n EarnCredits = 'EARN_CREDITS',\n ConsumeCredits = 'CONSUME_CREDITS',\n Referral = 'REFERRAL',\n CompleteProfile = 'COMPLETE_PROFILE',\n Subscribe = 'SUBSCRIBE',\n SubscribeEmail = 'SUBSCRIBE_EMAIL',\n RedeemCoupon = 'REDEEM_COUPON',\n Activate = 'ACTIVATE',\n}\n\n// \u2500\u2500\u2500 item action \u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupActionType {\n ExternalLink = 'EXTERNAL_LINK',\n OpenEarnCredits = 'OPEN_EARN_CREDITS',\n OpenConsumeCredits = 'OPEN_CONSUME_CREDITS',\n OpenReferral = 'OPEN_REFERRAL',\n OpenSubscribe = 'OPEN_SUBSCRIBE',\n}\n\n// \u2500\u2500\u2500 EarnCredits \u4EFB\u52A1\u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum EarnCreditsTaskType {\n Activate = 'activate',\n CompleteProfile = 'completeProfile',\n Subscribe = 'subscribe',\n Shop = 'shop',\n}\n\n// \u2500\u2500\u2500 ConsumeCredits item \u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum ConsumeCreditsItemType {\n Coupon = 'COUPON',\n RedeemAndBuy = 'REDEEM_AND_BUY',\n GiftCard = 'GIFT_CARD',\n Product = 'PRODUCT',\n}\n\n// \u2500\u2500\u2500 \u901A\u7528 link\uFF08\u7EDF\u4E00\u4E00\u79CD\u7C7B\u578B\uFF09 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type MemberPopupLink = {\n type: MemberPopupActionType\n label: string\n url?: string // \u4EC5 ExternalLink \u65F6\u4F7F\u7528\n}\n\n// \u2500\u2500\u2500 list item \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type MemberPopupItem = {\n title: string\n description?: string\n links: MemberPopupLink[]\n}\n\n// \u2500\u2500 \u4E3B\u7EC4\u4EF6 Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupPageScope {\n /** \u5168\u5C40\u5C55\u793A */\n Global = 'GLOBAL',\n /** \u4EC5\u5728\u7279\u5B9A\u9875\u9762\u5C55\u793A */\n Include = 'INCLUDE',\n /** \u5728\u7279\u5B9A\u9875\u9762\u4E0D\u5C55\u793A */\n Exclude = 'EXCLUDE',\n}\n\nexport type MemberPopupPageConfig = {\n scope: MemberPopupPageScope\n /** \u9875\u9762\u8DEF\u5F84\u5217\u8868\uFF0C\u652F\u6301\u7CBE\u786E\u5339\u914D\u548C\u524D\u7F00\u5339\u914D\uFF08\u5982 \"/products\" \u4F1A\u5339\u914D \"/products/xxx\"\uFF09 */\n pages: string[]\n}\n\nexport type MemberPopupCopy = {\n triggerImg: { url: string; alt?: string }\n title?: string\n subtitle?: string\n list: MemberPopupItem[]\n footer?: {\n loginHint: string\n loginLabel: string\n joinLabel: string\n shopLabel: string\n shopUrl?: string\n }\n activitiesSubscribe?: SubscribeModalCopy\n earnCredits?: EarnCreditsCopy\n consumeCredits?: ConsumeCreditsopy\n referral?: ReferralCopy\n /** \u9875\u9762\u8986\u76D6\u8303\u56F4\u914D\u7F6E\uFF0C\u9ED8\u8BA4\u5168\u5C40\u5C55\u793A */\n pageConfig?: MemberPopupPageConfig\n}\n\n// \u2500\u2500\u2500 EarnCredits Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type EarnCreditsCopy = {\n title?: string\n subtitle?: string\n balanceLabel?: string\n comingSoonLabel?: string\n creditUnit?: string\n joinNow: string\n completed: string\n activate: string\n completeProfileLabel: string\n subscribeLabel: string\n shopNow: string\n goShopLink?: string\n list: {\n id: EarnCreditsTaskType\n title: string\n credits?: string\n }[]\n // \u5B50\u5F39\u7A97\u6587\u6848\n authCodeActivate: AuthCodeActivateCopy\n completeProfile: CompleteProfileCopy\n subscribe: SubscribeModalCopy\n}\n\nexport type CompleteProfileCopy = {\n title: string\n subtitle?: string\n firstName: string\n lastName: string\n email: string\n phone: string\n birthday: string\n country: string\n save: string\n cancel: string\n edit: string\n required: string\n}\n\nexport type SubscribeModalCopy = {\n title: string\n desc?: string\n placeholder: string\n policy?: string\n policyDefaultChecked?: boolean\n successTips?: string\n subscribedLabel?: string\n dealsType?: string\n buttonLabel?: string\n single_brand_subscribe?: boolean\n genre?: string\n sub_brand_type?: string\n promo?: {\n title?: string\n description?: string\n learnMoreLabel?: string\n learnMoreUrl?: string\n image?: { url: string; alt?: string }\n }\n}\n\n// \u2500\u2500\u2500 ConsumeCredits Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type ConsumeCreditsopy = {\n title?: string\n subtitle?: string\n soldOut: string\n unlockRewards: string\n btnRedeem: string\n insufficientCredits?: string\n balanceLabel?: string\n comingSoonLabel?: string\n creditUnit?: string\n off?: string\n imageMapping?: {\n [key in ConsumeCreditsItemType]?: { url: string }\n }\n list: ConsumeCreditsItem[]\n redeemModal: RedeemCouponModalCopy\n creditsPage?: { label: string; url: string; redeemListSectionId?: string }\n}\n\nexport type ConsumeCreditsItem = {\n redeemId: string | number\n title: string\n description?: string\n image: { url: string; alt?: string }\n type: ConsumeCreditsItemType\n product?: { handle: string; sku: string }\n price?: number\n value?: string\n rules?: string[]\n}\n\nexport type RedeemCouponModalCopy = {\n confirmTitle: string\n confirmButton: string\n off?: string\n commonError: string\n redeemLimitError: string\n inventoryNotEnough: string\n creditsNotEnough: string\n crossSiteError: string\n successTitle: string\n successDesc: string\n successButton: string\n successButtonUrl?: string\n}\n\n// \u2500\u2500\u2500 Referral Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type ReferralCopy = {\n title?: string\n description?: string\n cashAvailableLabel: string\n cashPendingLabel: string\n creditUnit?: string\n referralLinksLabel?: string\n referralLinkBaseUrl?: string\n copyLabel?: string\n copiedLabel?: string\n howToTitle?: string\n howToDescription?: string\n learnMoreLabel?: string\n learnMoreUrl?: string\n image?: { url: string; alt?: string }\n ctaButton: string\n ctaUrl?: string\n loginTitle?: string\n loginDescription?: string\n loginCtaLabel?: string\n}\n\n// \u2500\u2500\u2500 Provider Context \u7C7B\u578B \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type AlpcConfig = {\n brand: string\n locale: string\n appName: string\n apiBaseUrl?: string\n}\n\nexport type MemberPopupContextValue = {\n profile: any\n isLoadingProfile: boolean\n creditInfo?: CreditInfoResponse\n fetchCreditInfo: (userId: string) => void\n openSignUpPopup: () => void\n openSignInPopup: () => void\n taskIdToTypeMapping?: Record<string, DTC_TASK_TYPE>\n alpcConfig: AlpcConfig\n pageHandle?: string\n}\n\nexport type MemberPopupInternalContextValue = MemberPopupContextValue & {\n isSubscribeSuccess: boolean\n setIsSubscribeSuccess: (v: boolean) => void\n isActivateSuccess: boolean\n setIsActivateSuccess: (v: boolean) => void\n isProfileCompleteSuccess: boolean\n setIsProfileCompleteSuccess: (v: boolean) => void\n}\n"],
4
+ "sourcesContent": ["import type { AuthCodeActivateCopy } from '../registration/authCodeActivate/type'\nimport type { CreditInfoResponse } from '../credits/context/response'\nimport type { DTC_TASK_TYPE } from '../credits/context/const'\n\nexport type { AuthCodeActivateCopy }\n\n// \u2500\u2500\u2500 \u9762\u677F\u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupPanelType {\n EarnCredits = 'EARN_CREDITS',\n ConsumeCredits = 'CONSUME_CREDITS',\n Referral = 'REFERRAL',\n CompleteProfile = 'COMPLETE_PROFILE',\n Subscribe = 'SUBSCRIBE',\n SubscribeEmail = 'SUBSCRIBE_EMAIL',\n RedeemCoupon = 'REDEEM_COUPON',\n Activate = 'ACTIVATE',\n}\n\n// \u2500\u2500\u2500 item action \u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupActionType {\n ExternalLink = 'EXTERNAL_LINK',\n OpenEarnCredits = 'OPEN_EARN_CREDITS',\n OpenConsumeCredits = 'OPEN_CONSUME_CREDITS',\n OpenReferral = 'OPEN_REFERRAL',\n OpenSubscribe = 'OPEN_SUBSCRIBE',\n}\n\n// \u2500\u2500\u2500 EarnCredits \u4EFB\u52A1\u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum EarnCreditsTaskType {\n Activate = 'activate',\n CompleteProfile = 'completeProfile',\n Subscribe = 'subscribe',\n Shop = 'shop',\n}\n\n// \u2500\u2500\u2500 ConsumeCredits item \u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum ConsumeCreditsItemType {\n Coupon = 'COUPON',\n RedeemAndBuy = 'REDEEM_AND_BUY',\n GiftCard = 'GIFT_CARD',\n Product = 'PRODUCT',\n}\n\n// \u2500\u2500\u2500 \u901A\u7528 link\uFF08\u7EDF\u4E00\u4E00\u79CD\u7C7B\u578B\uFF09 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type MemberPopupLink = {\n type: MemberPopupActionType\n label: string\n url?: string // \u4EC5 ExternalLink \u65F6\u4F7F\u7528\n}\n\n// \u2500\u2500\u2500 list item \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type MemberPopupItem = {\n title: string\n description?: string\n links: MemberPopupLink[]\n}\n\n// \u2500\u2500 \u4E3B\u7EC4\u4EF6 Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupPageScope {\n /** \u5168\u5C40\u5C55\u793A */\n Global = 'GLOBAL',\n /** \u4EC5\u5728\u7279\u5B9A\u9875\u9762\u5C55\u793A */\n Include = 'INCLUDE',\n /** \u5728\u7279\u5B9A\u9875\u9762\u4E0D\u5C55\u793A */\n Exclude = 'EXCLUDE',\n}\n\nexport type MemberPopupPageConfig = {\n scope: MemberPopupPageScope\n /** \u9875\u9762\u8DEF\u5F84\u5217\u8868\uFF0C\u652F\u6301\u7CBE\u786E\u5339\u914D\u548C\u524D\u7F00\u5339\u914D\uFF08\u5982 \"/products\" \u4F1A\u5339\u914D \"/products/xxx\"\uFF09 */\n pages: string[]\n}\n\nexport type MemberPopupCopy = {\n triggerImg: { url: string; alt?: string }\n title?: string\n subtitle?: string\n list: MemberPopupItem[]\n footer?: {\n loginHint: string\n loginLabel: string\n joinLabel: string\n shopLabel: string\n shopUrl?: string\n }\n activitiesSubscribe?: SubscribeModalCopy\n earnCredits?: EarnCreditsCopy\n consumeCredits?: ConsumeCreditsopy\n referral?: ReferralCopy\n /** \u9875\u9762\u8986\u76D6\u8303\u56F4\u914D\u7F6E\uFF0C\u9ED8\u8BA4\u5168\u5C40\u5C55\u793A */\n pageConfig?: MemberPopupPageConfig\n}\n\n// \u2500\u2500\u2500 EarnCredits Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type EarnCreditsCopy = {\n title?: string\n subtitle?: string\n balanceLabel?: string\n comingSoonLabel?: string\n creditUnit?: string\n joinNow: string\n completed: string\n activate: string\n completeProfileLabel: string\n subscribeLabel: string\n shopNow: string\n goShopLink?: string\n list: {\n id: EarnCreditsTaskType\n title: string\n credits?: string\n }[]\n // \u5B50\u5F39\u7A97\u6587\u6848\n authCodeActivate: AuthCodeActivateCopy\n completeProfile: CompleteProfileCopy\n subscribe: SubscribeModalCopy\n}\n\nexport type CompleteProfileCopy = {\n title: string\n subtitle?: string\n firstName: string\n lastName: string\n email: string\n phone: string\n birthday: string\n country: string\n save: string\n cancel: string\n edit: string\n required: string\n}\n\nexport type SubscribeModalCopy = {\n title: string\n desc?: string\n placeholder: string\n policy?: string\n policyDefaultChecked?: boolean\n successTips?: string\n subscribedLabel?: string\n dealsType?: string\n buttonLabel?: string\n single_brand_subscribe?: boolean\n genre?: string\n sub_brand_type?: string\n promo?: {\n title?: string\n description?: string\n learnMoreLabel?: string\n learnMoreUrl?: string\n image?: { url: string; alt?: string }\n }\n}\n\n// \u2500\u2500\u2500 ConsumeCredits Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type ConsumeCreditsopy = {\n title?: string\n subtitle?: string\n soldOut: string\n unlockRewards: string\n btnRedeem: string\n insufficientCredits?: string\n balanceLabel?: string\n comingSoonLabel?: string\n creditUnit?: string\n off?: string\n giftCard?: string\n imageMapping?: {\n [key in ConsumeCreditsItemType]?: { url: string }\n }\n list: ConsumeCreditsItem[]\n redeemModal: RedeemCouponModalCopy\n creditsPage?: { label: string; url: string; redeemListSectionId?: string }\n}\n\nexport type ConsumeCreditsItem = {\n redeemId: string | number\n title: string\n description?: string\n image: { url: string; alt?: string }\n type: ConsumeCreditsItemType\n product?: { handle: string; sku: string }\n price?: number\n value?: string\n rules?: string[]\n}\n\nexport type RedeemCouponModalCopy = {\n confirmTitle: string\n confirmButton: string\n off?: string\n commonError: string\n redeemLimitError: string\n inventoryNotEnough: string\n creditsNotEnough: string\n crossSiteError: string\n successTitle: string\n successDesc: string\n successButton: string\n successButtonUrl?: string\n copyLabel?: string\n copiedLabel?: string\n}\n\n// \u2500\u2500\u2500 Referral Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type ReferralCopy = {\n title?: string\n description?: string\n cashAvailableLabel: string\n cashPendingLabel: string\n creditUnit?: string\n referralLinksLabel?: string\n referralLinkBaseUrl?: string\n copyLabel?: string\n copiedLabel?: string\n howToTitle?: string\n howToDescription?: string\n learnMoreLabel?: string\n learnMoreUrl?: string\n image?: { url: string; alt?: string }\n ctaButton: string\n ctaUrl?: string\n loginTitle?: string\n loginDescription?: string\n loginCtaLabel?: string\n}\n\n// \u2500\u2500\u2500 Provider Context \u7C7B\u578B \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type AlpcConfig = {\n brand: string\n locale: string\n appName: string\n apiBaseUrl?: string\n}\n\nexport type MemberPopupContextValue = {\n profile: any\n isLoadingProfile: boolean\n creditInfo?: CreditInfoResponse\n fetchCreditInfo: (userId: string) => void\n openSignUpPopup: () => void\n openSignInPopup: () => void\n taskIdToTypeMapping?: Record<string, DTC_TASK_TYPE>\n alpcConfig: AlpcConfig\n pageHandle?: string\n}\n\nexport type MemberPopupInternalContextValue = MemberPopupContextValue & {\n isSubscribeSuccess: boolean\n setIsSubscribeSuccess: (v: boolean) => void\n isActivateSuccess: boolean\n setIsActivateSuccess: (v: boolean) => void\n isProfileCompleteSuccess: boolean\n setIsProfileCompleteSuccess: (v: boolean) => void\n}\n"],
5
5
  "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,EAAA,wBAAAC,EAAA,0BAAAC,EAAA,yBAAAC,EAAA,yBAAAC,IAAA,eAAAC,EAAAP,GAOO,IAAKM,OACVA,EAAA,YAAc,eACdA,EAAA,eAAiB,kBACjBA,EAAA,SAAW,WACXA,EAAA,gBAAkB,mBAClBA,EAAA,UAAY,YACZA,EAAA,eAAiB,kBACjBA,EAAA,aAAe,gBACfA,EAAA,SAAW,WARDA,OAAA,IAYAF,OACVA,EAAA,aAAe,gBACfA,EAAA,gBAAkB,oBAClBA,EAAA,mBAAqB,uBACrBA,EAAA,aAAe,gBACfA,EAAA,cAAgB,iBALNA,OAAA,IASAD,OACVA,EAAA,SAAW,WACXA,EAAA,gBAAkB,kBAClBA,EAAA,UAAY,YACZA,EAAA,KAAO,OAJGA,OAAA,IAQAD,OACVA,EAAA,OAAS,SACTA,EAAA,aAAe,iBACfA,EAAA,SAAW,YACXA,EAAA,QAAU,UAJAA,OAAA,IAsBAG,OAEVA,EAAA,OAAS,SAETA,EAAA,QAAU,UAEVA,EAAA,QAAU,UANAA,OAAA",
6
6
  "names": ["type_exports", "__export", "ConsumeCreditsItemType", "EarnCreditsTaskType", "MemberPopupActionType", "MemberPopupPageScope", "MemberPopupPanelType", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{jsx as t,jsxs as s}from"react/jsx-runtime";import{useCallback as P,useEffect as F,useState as f}from"react";import{Text as r,Button as w}from"@anker-in/headless-ui";import{gaTrack as V,useHeadlessContext as j,classNames as x}from"@anker-in/lib";import{AlpcErrorCode as a}from"../../../credits/context/const";import{useRedeemCoupon as H}from"./hooks/useRedeemCoupon";import O from"../../../credits/context/hooks/useCopy";import{ROUNDED_BRANDS as W}from"../../../../constants";function $({onClose:E,item:I,copy:R,onError:g}){const{itemTitle:q,itemCredits:_,itemImage:c,itemValue:C,itemRules:m,redeemId:p,userId:v,alpcConfig:k}=I,{redeemModal:e,creditUnit:B}=R,D=B??"pts",[i,N]=f(),[b,d]=f(""),[T,l]=f(!1),{copy:S,copied:y}=O(),{brand:L}=j(),u=W.includes(L),{isMutating:U,trigger:h}=H(k),A=P(async()=>{d("");const{data:o}=await h({user_id:v,rule_id:p});if(!o){d(e.commonError);return}if(o.data?.success)N(o.data.coupon_code),V({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"redeem_coupon_success",info:"Member Floating Window"}});else{let n=e.commonError;o.code===a.CodeLpcShopifyCouponRuleRedeemLimit?(n=e.redeemLimitError,l(!0)):o.code===a.CodeLpcRuleInventoryNotEnough?(n=e.inventoryNotEnough,l(!0)):o.code===a.CodeLpcNotEnoughCredits?(n=e.creditsNotEnough,l(!0)):o.code===a.CodeCrossSiteError&&(n=e.crossSiteError,l(!0)),d(n),g?.(o.code)}},[h,v,p,e,g]);F(()=>{N(void 0),d(""),l(!1)},[p]);const M=m&&m.length>0&&t("div",{className:"w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]",children:t("ul",{className:"ml-4 grid grid-flow-row gap-[4px]",children:m?.map((o,n)=>t("li",{className:"list-disc",children:t(r,{html:o,className:"font-bold"})},n))})});return s("div",{className:"flex flex-col",children:[c?.url&&t("div",{className:"relative w-full px-[24px]",children:s("div",{className:x("relative mx-auto overflow-hidden",u?"rounded-[8px]":"rounded-none"),children:[t("img",{src:c.url,alt:c.alt??"",className:"mx-auto h-[140px] w-full object-cover"}),C&&s("div",{className:"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white",children:[C,e.off?` ${e.off}`:""]})]})}),!i&&s("div",{className:"flex flex-col gap-[16px] px-[24px] py-[20px]",children:[s("p",{className:"text-center text-[24px] font-[700] text-[#1d1d1f]",children:[_," ",D]}),M]}),i&&s("div",{className:"flex mt-[16px] flex-col gap-[8px] text-center",children:[s("div",{className:"flex items-center justify-center gap-[10px]",children:[t("span",{className:"text-[24px] font-[700]",children:i}),t("button",{className:"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none",disabled:y,onClick:()=>S(i),children:y?"Copied":"Copy"})]}),t(r,{className:"text-[20px] font-[700]",html:e.successTitle}),t(r,{className:"text-[14px] font-[700] text-[#6d6d6f]",html:e.successDesc}),t(w,{className:x("w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]",u?"rounded-[4px]":"rounded-none"),onClick:()=>{e.successButtonUrl&&(window.location.href=e.successButtonUrl),E()},children:e.successButton})]}),!i&&s("div",{className:"sticky bottom-0 bg-white border-t border-[#e5e5e5] pt-[10px]",children:[s("div",{className:"flex flex-col gap-[8px] text-center",children:[t(r,{className:"block text-[16px] font-[700] leading-[1.3]",html:e.confirmTitle}),t(w,{className:x("w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]",u?"rounded-[4px]":"rounded-none"),disabled:T,loading:U,onClick:A,children:e.confirmButton})]}),b&&t(r,{className:"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]",html:b})]})]})}export{$ as default};
1
+ import{jsx as t,jsxs as s}from"react/jsx-runtime";import{useCallback as P,useEffect as F,useState as f}from"react";import{Text as r,Button as w}from"@anker-in/headless-ui";import{gaTrack as V,useHeadlessContext as j,classNames as x}from"@anker-in/lib";import{AlpcErrorCode as a}from"../../../credits/context/const";import{useRedeemCoupon as H}from"./hooks/useRedeemCoupon";import O from"../../../credits/context/hooks/useCopy";import{ROUNDED_BRANDS as W}from"../../../../constants";function $({onClose:E,item:I,copy:R,onError:g}){const{itemTitle:q,itemCredits:_,itemImage:c,itemValue:C,itemRules:m,redeemId:p,userId:v,alpcConfig:k}=I,{redeemModal:e,creditUnit:B}=R,D=B??"pts",[i,b]=f(),[N,d]=f(""),[L,l]=f(!1),{copy:T,copied:y}=O(),{brand:S}=j(),u=W.includes(S),{isMutating:U,trigger:h}=H(k),A=P(async()=>{d("");const{data:o}=await h({user_id:v,rule_id:p});if(!o){d(e.commonError);return}if(o.data?.success)b(o.data.coupon_code),V({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"redeem_coupon_success",info:"Member Floating Window"}});else{let n=e.commonError;o.code===a.CodeLpcShopifyCouponRuleRedeemLimit?(n=e.redeemLimitError,l(!0)):o.code===a.CodeLpcRuleInventoryNotEnough?(n=e.inventoryNotEnough,l(!0)):o.code===a.CodeLpcNotEnoughCredits?(n=e.creditsNotEnough,l(!0)):o.code===a.CodeCrossSiteError&&(n=e.crossSiteError,l(!0)),d(n),g?.(o.code)}},[h,v,p,e,g]);F(()=>{b(void 0),d(""),l(!1)},[p]);const M=m&&m.length>0&&t("div",{className:"w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]",children:t("ul",{className:"ml-4 grid grid-flow-row gap-[4px]",children:m?.map((o,n)=>t("li",{className:"list-disc",children:t(r,{html:o,className:"font-bold"})},n))})});return s("div",{className:"flex flex-col",children:[c?.url&&t("div",{className:"relative w-full px-[24px]",children:s("div",{className:x("relative mx-auto overflow-hidden",u?"rounded-[8px]":"rounded-none"),children:[t("img",{src:c.url,alt:c.alt??"",className:"mx-auto h-[140px] w-full object-cover"}),C&&s("div",{className:"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white",children:[C,e.off?` ${e.off}`:""]})]})}),!i&&s("div",{className:"flex flex-col gap-[16px] px-[24px] py-[20px]",children:[s("p",{className:"text-center text-[24px] font-[700] text-[#1d1d1f]",children:[_," ",D]}),M]}),i&&s("div",{className:"flex mt-[16px] flex-col gap-[8px] text-center",children:[s("div",{className:"flex items-center justify-center gap-[10px]",children:[t("span",{className:"text-[24px] font-[700]",children:i}),t("button",{className:"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none",disabled:y,onClick:()=>T(i),children:y?e.copiedLabel??"Copied":e.copyLabel??"Copy"})]}),t(r,{className:"text-[20px] font-[700]",html:e.successTitle}),t(r,{className:"text-[14px] font-[700] text-[#6d6d6f]",html:e.successDesc}),t(w,{className:x("w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]",u?"rounded-[4px]":"rounded-none"),onClick:()=>{e.successButtonUrl&&(window.location.href=e.successButtonUrl),E()},children:e.successButton})]}),!i&&s("div",{className:"sticky bottom-0 bg-white border-t border-[#e5e5e5] pt-[10px]",children:[s("div",{className:"flex flex-col gap-[8px] text-center",children:[t(r,{className:"block text-[16px] font-[700] leading-[1.3]",html:e.confirmTitle}),t(w,{className:x("w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]",u?"rounded-[4px]":"rounded-none"),disabled:L,loading:U,onClick:A,children:e.confirmButton})]}),N&&t(r,{className:"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]",html:N})]})]})}export{$ as default};
2
2
  //# sourceMappingURL=RedeemCouponPanel.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.tsx"],
4
- "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Text, Button } from '@anker-in/headless-ui'\nimport { gaTrack, useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport { AlpcErrorCode } from '../../../credits/context/const'\nimport { useRedeemCoupon } from './hooks/useRedeemCoupon'\nimport useCopy from '../../../credits/context/hooks/useCopy'\nimport type { ConsumeCreditsopy, AlpcConfig } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype RedeemCouponItem = {\n itemTitle: string\n itemCredits: number\n itemImage?: { url: string; alt?: string }\n itemValue?: string\n itemRules?: string[]\n redeemId: number\n userId?: string\n alpcConfig: AlpcConfig\n}\n\ntype Props = {\n onClose: () => void\n item: RedeemCouponItem\n copy: ConsumeCreditsopy\n onError?: (code: number) => void\n}\n\nexport default function RedeemCouponPanel({ onClose, item, copy, onError }: Props) {\n const { itemTitle, itemCredits, itemImage, itemValue, itemRules, redeemId, userId, alpcConfig } = item\n const { redeemModal, creditUnit } = copy\n const pointUnit = creditUnit ?? 'pts'\n const [couponCode, setCouponCode] = useState<string>()\n const [errorInfo, setErrorInfo] = useState('')\n const [disabled, setDisabled] = useState(false)\n const { copy: copyText, copied } = useCopy()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const { isMutating: loading, trigger } = useRedeemCoupon(alpcConfig)\n\n const handleConfirm = useCallback(async () => {\n setErrorInfo('')\n const { data } = await trigger({ user_id: userId, rule_id: redeemId })\n if (!data) {\n setErrorInfo(redeemModal.commonError)\n return\n }\n if (data.data?.success) {\n setCouponCode(data.data.coupon_code)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem_coupon_success',\n info: 'Member Floating Window',\n },\n })\n } else {\n let msg = redeemModal.commonError\n if (data.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n msg = redeemModal.redeemLimitError\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n msg = redeemModal.inventoryNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n msg = redeemModal.creditsNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeCrossSiteError) {\n msg = redeemModal.crossSiteError\n setDisabled(true)\n }\n setErrorInfo(msg)\n onError?.(data.code)\n }\n }, [trigger, userId, redeemId, redeemModal, onError])\n\n useEffect(() => {\n setCouponCode(undefined)\n setErrorInfo('')\n setDisabled(false)\n }, [redeemId])\n\n const rulesSection = itemRules && itemRules.length > 0 && (\n <div className=\"w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]\">\n <ul className=\"ml-4 grid grid-flow-row gap-[4px]\">\n {itemRules?.map((text, index) => (\n <li className=\"list-disc\" key={index}>\n <Text html={text} className=\"font-bold\" />\n </li>\n ))}\n </ul>\n </div>\n )\n\n return (\n <div className=\"flex flex-col\">\n {itemImage?.url && (\n <div className=\"relative w-full px-[24px]\">\n <div className={cn('relative mx-auto overflow-hidden', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <img src={itemImage.url} alt={itemImage.alt ?? ''} className=\"mx-auto h-[140px] w-full object-cover\" />\n {itemValue && (\n <div className=\"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white\">\n {itemValue}\n {redeemModal.off ? ` ${redeemModal.off}` : ''}\n </div>\n )}\n </div>\n </div>\n )}\n\n {!couponCode && (\n <div className=\"flex flex-col gap-[16px] px-[24px] py-[20px]\">\n <p className=\"text-center text-[24px] font-[700] text-[#1d1d1f]\">\n {itemCredits} {pointUnit}\n </p>\n {rulesSection}\n </div>\n )}\n\n {couponCode && (\n <div className=\"flex mt-[16px] flex-col gap-[8px] text-center\">\n <div className=\"flex items-center justify-center gap-[10px]\">\n <span className=\"text-[24px] font-[700]\">{couponCode}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none\"\n disabled={copied}\n onClick={() => copyText(couponCode)}\n >\n {copied ? 'Copied' : 'Copy'}\n </button>\n </div>\n <Text className=\"text-[20px] font-[700]\" html={redeemModal.successTitle} />\n <Text className=\"text-[14px] font-[700] text-[#6d6d6f]\" html={redeemModal.successDesc} />\n <Button\n className={cn(\n 'w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n onClick={() => {\n if (redeemModal.successButtonUrl) window.location.href = redeemModal.successButtonUrl\n onClose()\n }}\n >\n {redeemModal.successButton}\n </Button>\n </div>\n )}\n\n {!couponCode && (\n <div className=\"sticky bottom-0 bg-white border-t border-[#e5e5e5] pt-[10px]\">\n <div className=\"flex flex-col gap-[8px] text-center\">\n <Text className=\"block text-[16px] font-[700] leading-[1.3]\" html={redeemModal.confirmTitle} />\n <Button\n className={cn(\n 'w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={disabled}\n loading={loading}\n onClick={handleConfirm}\n >\n {redeemModal.confirmButton}\n </Button>\n </div>\n\n {errorInfo && (\n <Text className=\"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]\" html={errorInfo} />\n )}\n </div>\n )}\n </div>\n )\n}\n"],
5
- "mappings": "AAyFY,cAAAA,EAcE,QAAAC,MAdF,oBAzFZ,OAAS,eAAAC,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QACjD,OAAS,QAAAC,EAAM,UAAAC,MAAc,wBAC7B,OAAS,WAAAC,EAAS,sBAAAC,EAAoB,cAAcC,MAAU,gBAC9D,OAAS,iBAAAC,MAAqB,iCAC9B,OAAS,mBAAAC,MAAuB,0BAChC,OAAOC,MAAa,yCAEpB,OAAS,kBAAAC,MAAsB,wBAoBhB,SAARC,EAAmC,CAAE,QAAAC,EAAS,KAAAC,EAAM,KAAAC,EAAM,QAAAC,CAAQ,EAAU,CACjF,KAAM,CAAE,UAAAC,EAAW,YAAAC,EAAa,UAAAC,EAAW,UAAAC,EAAW,UAAAC,EAAW,SAAAC,EAAU,OAAAC,EAAQ,WAAAC,CAAW,EAAIV,EAC5F,CAAE,YAAAW,EAAa,WAAAC,CAAW,EAAIX,EAC9BY,EAAYD,GAAc,MAC1B,CAACE,EAAYC,CAAa,EAAI3B,EAAiB,EAC/C,CAAC4B,EAAWC,CAAY,EAAI7B,EAAS,EAAE,EACvC,CAAC8B,EAAUC,CAAW,EAAI/B,EAAS,EAAK,EACxC,CAAE,KAAMgC,EAAU,OAAAC,CAAO,EAAIzB,EAAQ,EACrC,CAAE,MAAA0B,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kB,cAC9B,EACA,SAAUL,EACV,QAASM,EACT,QAASE,EAER,SAAAf,EAAY,cACf,GACF,EAECK,GACChC,EAACK,EAAA,CAAK,UAAU,6DAA6D,KAAM2B,EAAW,GAElG,GAEJ,CAEJ",
4
+ "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Text, Button } from '@anker-in/headless-ui'\nimport { gaTrack, useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport { AlpcErrorCode } from '../../../credits/context/const'\nimport { useRedeemCoupon } from './hooks/useRedeemCoupon'\nimport useCopy from '../../../credits/context/hooks/useCopy'\nimport type { ConsumeCreditsopy, AlpcConfig } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype RedeemCouponItem = {\n itemTitle: string\n itemCredits: number\n itemImage?: { url: string; alt?: string }\n itemValue?: string\n itemRules?: string[]\n redeemId: number\n userId?: string\n alpcConfig: AlpcConfig\n}\n\ntype Props = {\n onClose: () => void\n item: RedeemCouponItem\n copy: ConsumeCreditsopy\n onError?: (code: number) => void\n}\n\nexport default function RedeemCouponPanel({ onClose, item, copy, onError }: Props) {\n const { itemTitle, itemCredits, itemImage, itemValue, itemRules, redeemId, userId, alpcConfig } = item\n const { redeemModal, creditUnit } = copy\n const pointUnit = creditUnit ?? 'pts'\n const [couponCode, setCouponCode] = useState<string>()\n const [errorInfo, setErrorInfo] = useState('')\n const [disabled, setDisabled] = useState(false)\n const { copy: copyText, copied } = useCopy()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const { isMutating: loading, trigger } = useRedeemCoupon(alpcConfig)\n\n const handleConfirm = useCallback(async () => {\n setErrorInfo('')\n const { data } = await trigger({ user_id: userId, rule_id: redeemId })\n if (!data) {\n setErrorInfo(redeemModal.commonError)\n return\n }\n if (data.data?.success) {\n setCouponCode(data.data.coupon_code)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem_coupon_success',\n info: 'Member Floating Window',\n },\n })\n } else {\n let msg = redeemModal.commonError\n if (data.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n msg = redeemModal.redeemLimitError\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n msg = redeemModal.inventoryNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n msg = redeemModal.creditsNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeCrossSiteError) {\n msg = redeemModal.crossSiteError\n setDisabled(true)\n }\n setErrorInfo(msg)\n onError?.(data.code)\n }\n }, [trigger, userId, redeemId, redeemModal, onError])\n\n useEffect(() => {\n setCouponCode(undefined)\n setErrorInfo('')\n setDisabled(false)\n }, [redeemId])\n\n const rulesSection = itemRules && itemRules.length > 0 && (\n <div className=\"w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]\">\n <ul className=\"ml-4 grid grid-flow-row gap-[4px]\">\n {itemRules?.map((text, index) => (\n <li className=\"list-disc\" key={index}>\n <Text html={text} className=\"font-bold\" />\n </li>\n ))}\n </ul>\n </div>\n )\n\n return (\n <div className=\"flex flex-col\">\n {itemImage?.url && (\n <div className=\"relative w-full px-[24px]\">\n <div className={cn('relative mx-auto overflow-hidden', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <img src={itemImage.url} alt={itemImage.alt ?? ''} className=\"mx-auto h-[140px] w-full object-cover\" />\n {itemValue && (\n <div className=\"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white\">\n {itemValue}\n {redeemModal.off ? ` ${redeemModal.off}` : ''}\n </div>\n )}\n </div>\n </div>\n )}\n\n {!couponCode && (\n <div className=\"flex flex-col gap-[16px] px-[24px] py-[20px]\">\n <p className=\"text-center text-[24px] font-[700] text-[#1d1d1f]\">\n {itemCredits} {pointUnit}\n </p>\n {rulesSection}\n </div>\n )}\n\n {couponCode && (\n <div className=\"flex mt-[16px] flex-col gap-[8px] text-center\">\n <div className=\"flex items-center justify-center gap-[10px]\">\n <span className=\"text-[24px] font-[700]\">{couponCode}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none\"\n disabled={copied}\n onClick={() => copyText(couponCode)}\n >\n {copied ? (redeemModal.copiedLabel ?? 'Copied') : (redeemModal.copyLabel ?? 'Copy')}\n </button>\n </div>\n <Text className=\"text-[20px] font-[700]\" html={redeemModal.successTitle} />\n <Text className=\"text-[14px] font-[700] text-[#6d6d6f]\" html={redeemModal.successDesc} />\n <Button\n className={cn(\n 'w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n onClick={() => {\n if (redeemModal.successButtonUrl) window.location.href = redeemModal.successButtonUrl\n onClose()\n }}\n >\n {redeemModal.successButton}\n </Button>\n </div>\n )}\n\n {!couponCode && (\n <div className=\"sticky bottom-0 bg-white border-t border-[#e5e5e5] pt-[10px]\">\n <div className=\"flex flex-col gap-[8px] text-center\">\n <Text className=\"block text-[16px] font-[700] leading-[1.3]\" html={redeemModal.confirmTitle} />\n <Button\n className={cn(\n 'w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={disabled}\n loading={loading}\n onClick={handleConfirm}\n >\n {redeemModal.confirmButton}\n </Button>\n </div>\n\n {errorInfo && (\n <Text className=\"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]\" html={errorInfo} />\n )}\n </div>\n )}\n </div>\n )\n}\n"],
5
+ "mappings": "AAyFY,cAAAA,EAcE,QAAAC,MAdF,oBAzFZ,OAAS,eAAAC,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QACjD,OAAS,QAAAC,EAAM,UAAAC,MAAc,wBAC7B,OAAS,WAAAC,EAAS,sBAAAC,EAAoB,cAAcC,MAAU,gBAC9D,OA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AW,EACrD9B,EAAC,UACC,UAAU,+EACV,SAAUqC,EACV,QAAS,IAAMD,EAASN,CAAU,EAEjC,SAAAO,EAAUV,EAAY,aAAe,SAAaA,EAAY,WAAa,OAC9E,GACF,EACA3B,EAACK,EAAA,CAAK,UAAU,yBAAyB,KAAMsB,EAAY,aAAc,EACzE3B,EAACK,EAAA,CAAK,UAAU,wCAAwC,KAAMsB,EAAY,YAAa,EACvF3B,EAACM,EAAA,CACC,UAAWG,EACT,kEACA8B,EAAU,gBAAkB,cAC9B,EACA,QAAS,IAAM,CACTZ,EAAY,mBAAkB,OAAO,SAAS,KAAOA,EAAY,kBACrEZ,EAAQ,CACV,EAEC,SAAAY,EAAY,cACf,GACF,EAGD,CAACG,GACA7B,EAAC,OAAI,UAAU,+DACb,UAAAA,EAAC,OAAI,UAAU,sCACb,UAAAD,EAACK,EAAA,CAAK,UAAU,6CAA6C,KAAMsB,EAAY,aAAc,EAC7F3B,EAACM,EAAA,CACC,UAAWG,EACT,sFACA8B,EAAU,gBAAkB,cAC9B,EACA,SAAUL,EACV,QAASM,EACT,QAASE,EAER,SAAAf,EAAY,cACf,GACF,EAECK,GACChC,EAACK,EAAA,CAAK,UAAU,6DAA6D,KAAM2B,EAAW,GAElG,GAEJ,CAEJ",
6
6
  "names": ["jsx", "jsxs", "useCallback", "useEffect", "useState", "Text", "Button", "gaTrack", "useHeadlessContext", "cn", "AlpcErrorCode", "useRedeemCoupon", "useCopy", "ROUNDED_BRANDS", "RedeemCouponPanel", "onClose", "item", "copy", "onError", "itemTitle", "itemCredits", "itemImage", "itemValue", "itemRules", "redeemId", "userId", "alpcConfig", "redeemModal", "creditUnit", "pointUnit", "couponCode", "setCouponCode", "errorInfo", "setErrorInfo", "disabled", "setDisabled", "copyText", "copied", "brand", "rounded", "loading", "trigger", "handleConfirm", "data", "msg", "rulesSection", "text", "index"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{Fragment as ne,jsx as n,jsxs as r}from"react/jsx-runtime";import{useEffect as H,useMemo as W,useState as S}from"react";import{Picture as G,Button as q}from"@anker-in/headless-ui";import{gaTrack as C,classNames as P,useProductsByHandles as J,useHeadlessContext as K}from"@anker-in/lib";import{useMemberPopupContext as Q}from"../../context/provider";import{useViewStack as X}from"../../context/viewStack";import{useRedeemableList as Y}from"./hooks/useRedeemableList";import{useRedeemAndBuy as Z}from"./hooks/useRedeemAndBuy";import{ConsumeCreditsItemType as o,MemberPopupPanelType as D}from"../../type";import{numberFormat as x}from"../../../credits/context/utils";import{ROUNDED_BRANDS as ee}from"../../../../constants";function te({copy:t}){const{profile:i,creditInfo:u,openSignUpPopup:L,alpcConfig:g,isActivateSuccess:A,fetchCreditInfo:U,pageHandle:c}=Q(),{pushView:w}=X(),{brand:E}=K(),v=ee.includes(E),[I,R]=S(""),[M,k]=S(null);H(()=>{i?.user_id&&U(i.user_id)},[]);const l=!!i,{redeemableList:y,listLoading:F}=Y(g),{trigger:$}=Z(g),T=t.list.map(e=>e.product?.handle).filter(Boolean),{data:B}=J({handles:T}),z=W(()=>t.list.map(e=>{const a=y.find(d=>String(d.id)===String(e.redeemId));if(!a)return null;const s=Number(u?.available_credit??0),N=a.consume_credits>s,m=a.is_limited&&(!a.remaining_inventory||a.remaining_inventory<=0),_=e.type===o.RedeemAndBuy||e.type===o.Product,f=B?.find(d=>d.handle===e.product?.handle),h=f?.variants?.find(d=>d.sku===e.product?.sku)??f?.variants?.[0];return _&&(!f||!h||!h?.availableForSale||m)?null:{...e,alpcData:a,insufficient:N,product:f,variant:h}}).filter(Boolean),[t.list,y,u,i,l,B]),p=i?.activated||A;function O(e){return!l||!p?t.unlockRewards:e.soldOut?t.soldOut:t.btnRedeem}function V(e){return!l||!p?!1:e.insufficient}function b(e){C({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"redeem",info:"Member Floating Window"}})}async function j(e){if(!l){L();return}if(!p){w({type:D.Activate});return}if(e.type===o.GiftCard||e.type===o.Product){if(t.creditsPage?.url){const a=t.creditsPage.redeemListSectionId??"creditsRedeemList",s=new URL(t.creditsPage.url,window.location.href);s.searchParams.set("section",a),s.hash=a,c&&s.searchParams.set("ref",`${c}_consume_credits`),b(e.title),window.open(s.toString(),"_blank","noopener,noreferrer")}return}if(e.type===o.Coupon)b(e.title),w({type:D.RedeemCoupon,props:{itemTitle:e.title,itemCredits:e.alpcData.consume_credits,itemImage:t.imageMapping?.[e.type]?{url:t.imageMapping[e.type].url,alt:e.image?.alt}:e.image,itemValue:e.value,itemRules:e.rules,redeemId:Number(e.redeemId),userId:i?.user_id,alpcConfig:g}});else{R(""),k(e.redeemId),b(e.title);try{await $({productVariant:e.variant,redeemId:Number(e.redeemId),userId:i?.user_id}),C({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"redeem_success",info:"Member Floating Window"}})}catch(a){R(a?.message??t.redeemModal.commonError)}finally{k(null)}}}return n(ne,{children:r("div",{className:"flex flex-1 flex-col",children:[r("div",{className:"flex flex-col gap-[8px]",children:[t.title&&n("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:t.title}),t.subtitle&&n("p",{className:"text-[16px] mt-[8px] font-[700] leading-snug text-[#4a4c56]",children:t.subtitle})]}),l&&r("div",{className:P("flex items-center mt-[16px] gap-[12px] bg-[#f5f6f7] p-[16px]",v?"rounded-[8px]":"rounded-none"),children:[r("div",{className:"flex flex-1 flex-col gap-[4px]",children:[n("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:t.balanceLabel??"AnkerCredits Balance"}),r("div",{className:"flex items-end gap-[4px]",children:[n("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:x(u?.available_credit||0)}),n("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:t.creditUnit??"ankercredits"})]})]}),n("div",{className:"h-full w-px bg-[#dadce0]"}),r("div",{className:"flex flex-1 flex-col gap-[4px]",children:[n("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:t.comingSoonLabel??"Coming Soon"}),r("div",{className:"flex items-end gap-[4px]",children:[n("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:x(u?.pending_credit||0)}),n("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:t.creditUnit??"ankercredits"})]})]})]}),I&&n("div",{className:"text-[14px] mt-[8px] font-[700] text-[#f84d4f]",children:I}),F?n("div",{className:"flex flex-1 items-center justify-center py-[32px]",children:n("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}):n("div",{className:"flex mt-[16px] flex-col",children:z.map((e,a)=>{const s=!!e.product;return r("div",{className:"relative py-[16px]",children:[a>0&&n("div",{className:"absolute inset-x-0 top-0 h-px bg-[#dadce0]"}),r("div",{className:"flex items-center gap-[12px]",children:[(()=>{const N=t.imageMapping?.[e.type]?.url,m=s?e.variant?.image?.url??e.product?.images?.[0]?.url??e.image?.url:N??e.image?.url,_=s?e.variant?.image?.altText??e.product?.images?.[0]?.alt??e.image?.alt??"":e.image?.alt??"";return m?r("div",{className:P("relative size-[64px] shrink-0 overflow-hidden",v?"rounded-[4px]":"rounded-none"),children:[n(G,{source:m,alt:_,className:"flex size-full items-center justify-center",imgClassName:s?"object-cover":"h-full w-auto object-contain"}),!s&&e.value&&r("div",{className:"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white",children:[e.value," ",t.off]})]}):null})(),r("div",{className:"min-w-0 flex-1",children:[n("div",{className:"text-[16px] font-[700] text-[#1e2024] line-clamp-2",children:s&&e.product?.title?e.product.title:e.title}),n("div",{className:"mt-[4px] text-[14px] text-[#666]",children:s&&e.price!=null?`${x(e.alpcData.consume_credits)} ${t.creditUnit??""} + $${Number(e.price).toFixed(2)}`:`${x(e.alpcData.consume_credits)} ${t.creditUnit??""}`})]}),r("div",{className:"relative group",children:[n(q,{className:P("bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",v?"rounded-[4px]":"rounded-none"),disabled:V(e),loading:M===e.redeemId,onClick:()=>j(e),children:O(e)}),e.insufficient&&l&&p&&n("div",{className:"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block",children:r("div",{className:"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow",children:[n("p",{className:"text-pretty tracking-[-0.02em] text-[14px]",children:t.insufficientCredits}),n("div",{className:"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]"})]})})]})]})]},a)})}),t.creditsPage?.url&&n("a",{href:(()=>{if(!c)return t.creditsPage.url;try{const e=new URL(t.creditsPage.url,window.location.href);return e.searchParams.set("ref",`${c}_consume_credits`),e.toString()}catch{return t.creditsPage.url}})(),target:"_blank",rel:"noopener noreferrer",className:"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline",onClick:()=>C({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"credits_page_link",info:"Member Floating Window"}}),children:t.creditsPage.label??"Go to Credits Page"})]})})}var me=te;export{me as default};
1
+ import{Fragment as D,jsx as a,jsxs as n}from"react/jsx-runtime";import{useEffect as H,useMemo as W,useState as B}from"react";import{Picture as q,Button as J}from"@anker-in/headless-ui";import{gaTrack as _,classNames as C,useProductsByHandles as K,useHeadlessContext as Q}from"@anker-in/lib";import{useMemberPopupContext as X}from"../../context/provider";import{useViewStack as Y}from"../../context/viewStack";import{useRedeemableList as Z}from"./hooks/useRedeemableList";import{useRedeemAndBuy as ee}from"./hooks/useRedeemAndBuy";import{ConsumeCreditsItemType as s,MemberPopupPanelType as A}from"../../type";import{numberFormat as x}from"../../../credits/context/utils";import{ROUNDED_BRANDS as te}from"../../../../constants";function ae({copy:t}){const{profile:d,creditInfo:u,openSignUpPopup:S,alpcConfig:v,isActivateSuccess:L,fetchCreditInfo:E,pageHandle:c}=X(),{pushView:y}=Y(),{brand:M}=Q(),g=te.includes(M),[P,w]=B(""),[U,R]=B(null);H(()=>{d?.user_id&&E(d.user_id)},[]);const l=!!d,{redeemableList:I,listLoading:$}=Z(v),{trigger:F}=ee(v),T=t.list.map(e=>e.product?.handle).filter(Boolean),{data:k}=K({handles:T}),z=W(()=>t.list.map(e=>{const r=I.find(o=>String(o.id)===String(e.redeemId));if(!r)return null;const i=Number(u?.available_credit??0),m=r.consume_credits>i,N=r.is_limited&&(!r.remaining_inventory||r.remaining_inventory<=0),j=e.type===s.RedeemAndBuy||e.type===s.Product,f=k?.find(o=>o.handle===e.product?.handle),h=f?.variants?.find(o=>o.sku===e.product?.sku)??f?.variants?.[0];return j&&(!f||!h||!h?.availableForSale||N)||e.type===s.RedeemAndBuy&&e.price==null?null:{...e,alpcData:r,insufficient:m,product:f,variant:h}}).filter(Boolean),[t.list,I,u,d,l,k]),p=d?.activated||L;function O(e){return!l||!p?t.unlockRewards:e.soldOut?t.soldOut:t.btnRedeem}function G(e){return!l||!p?!1:e.insufficient}function b(e){_({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"redeem",info:"Member Floating Window"}})}async function V(e){if(!l){S();return}if(!p){y({type:A.Activate});return}if(e.type===s.GiftCard||e.type===s.Product){if(t.creditsPage?.url){const r=t.creditsPage.redeemListSectionId??"creditsRedeemList",i=new URL(t.creditsPage.url,window.location.href);i.searchParams.set("section",r),i.hash=r,c&&i.searchParams.set("ref",`${c}_consume_credits`),b(e.title),window.open(i.toString(),"_blank","noopener,noreferrer")}return}if(e.type===s.Coupon)b(e.title),y({type:A.RedeemCoupon,props:{itemTitle:e.title,itemCredits:e.alpcData.consume_credits,itemImage:t.imageMapping?.[e.type]?{url:t.imageMapping[e.type].url,alt:e.image?.alt}:e.image,itemValue:e.value,itemRules:e.rules,redeemId:Number(e.redeemId),userId:d?.user_id,alpcConfig:v}});else{w(""),R(e.redeemId),b(e.title);try{await F({productVariant:e.variant,redeemId:Number(e.redeemId),userId:d?.user_id}),_({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"redeem_success",info:"Member Floating Window"}})}catch(r){w(r?.message??t.redeemModal.commonError)}finally{R(null)}}}return a(D,{children:n("div",{className:"flex flex-1 flex-col",children:[n("div",{className:"flex flex-col gap-[8px]",children:[t.title&&a("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:t.title}),t.subtitle&&a("p",{className:"text-[16px] mt-[8px] font-[700] leading-snug text-[#4a4c56]",children:t.subtitle})]}),l&&n("div",{className:C("flex items-center mt-[16px] gap-[12px] bg-[#f5f6f7] p-[16px]",g?"rounded-[8px]":"rounded-none"),children:[n("div",{className:"flex flex-1 flex-col gap-[4px]",children:[a("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:t.balanceLabel??"AnkerCredits Balance"}),n("div",{className:"flex items-end gap-[4px]",children:[a("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:x(u?.available_credit||0)}),a("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:t.creditUnit??"ankercredits"})]})]}),a("div",{className:"h-full w-px bg-[#dadce0]"}),n("div",{className:"flex flex-1 flex-col gap-[4px]",children:[a("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:t.comingSoonLabel??"Coming Soon"}),n("div",{className:"flex items-end gap-[4px]",children:[a("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:x(u?.pending_credit||0)}),a("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:t.creditUnit??"ankercredits"})]})]})]}),P&&a("div",{className:"text-[14px] mt-[8px] font-[700] text-[#f84d4f]",children:P}),$?a("div",{className:"flex flex-1 items-center justify-center py-[32px]",children:a("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}):a("div",{className:"flex mt-[16px] flex-col",children:z.map((e,r)=>n("div",{className:"relative py-[16px]",children:[r>0&&a("div",{className:"absolute inset-x-0 top-0 h-px bg-[#dadce0]"}),n("div",{className:"flex items-center gap-[12px]",children:[(()=>{const i=e.type===s.Product||e.type===s.RedeemAndBuy,m=i?e.variant?.image?.url??e.product?.images?.[0]?.url??e.image?.url:e.image?.url||t.imageMapping?.[e.type]?.url,N=i?e.variant?.image?.altText??e.product?.images?.[0]?.alt??e.image?.alt??"":e.image?.alt??"";return m?n("div",{className:C("relative size-[64px] shrink-0 overflow-hidden",g?"rounded-[4px]":"rounded-none"),children:[a(q,{source:m,alt:N,className:"flex size-full items-center justify-center",imgClassName:i?"object-cover":"h-full w-auto object-contain"}),e.type===s.Coupon&&e.value&&a("div",{className:"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white",children:e.value&&`${e.value} ${t.off}`}),e.type===s.GiftCard&&e.value&&a("div",{className:"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white",children:e.value&&`${e.value} ${t.giftCard||"Gift Card"}`})]}):null})(),n("div",{className:"min-w-0 flex-1",children:[a("div",{className:"text-[16px] font-[700] text-[#1e2024] line-clamp-2",children:e.product.title??e.title??e.alpcData?.name}),a("div",{className:"mt-[4px] text-[14px] text-[#666]",children:e.type===s.RedeemAndBuy?n(D,{children:[n("div",{children:[x(e.alpcData.consume_credits)," ",t.creditUnit??""," + $",Number(e.price).toFixed(2)]}),e.variant?.price?.amount&&n("div",{className:"text-[12px] text-[#999] line-through",children:["$",Number(e.variant.price.amount).toFixed(2)]})]}):`${x(e.alpcData.consume_credits)} ${t.creditUnit??""}`})]}),n("div",{className:"relative group",children:[a(J,{className:C("bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",g?"rounded-[4px]":"rounded-none"),disabled:G(e),loading:U===e.redeemId,onClick:()=>V(e),children:O(e)}),e.insufficient&&l&&p&&a("div",{className:"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block",children:n("div",{className:"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow",children:[a("p",{className:"text-pretty tracking-[-0.02em] text-[14px]",children:t.insufficientCredits}),a("div",{className:"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]"})]})})]})]})]},r))}),t.creditsPage?.url&&a("a",{href:(()=>{if(!c)return t.creditsPage.url;try{const e=new URL(t.creditsPage.url,window.location.href);return e.searchParams.set("ref",`${c}_consume_credits`),e.toString()}catch{return t.creditsPage.url}})(),target:"_blank",rel:"noopener noreferrer",className:"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline",onClick:()=>_({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"credits_page_link",info:"Member Floating Window"}}),children:t.creditsPage.label??"Go to Credits Page"})]})})}var me=ae;export{me as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/ConsumeCredits/index.tsx"],
4
- "sourcesContent": ["import { useEffect, useMemo, useState } from 'react'\nimport { Picture, Button } from '@anker-in/headless-ui'\nimport { gaTrack, classNames as cn, useProductsByHandles, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useRedeemableList } from './hooks/useRedeemableList'\nimport { useRedeemAndBuy } from './hooks/useRedeemAndBuy'\nimport {\n ConsumeCreditsItemType,\n MemberPopupPanelType,\n type ConsumeCreditsopy,\n type ConsumeCreditsItem,\n} from '../../type'\nimport { numberFormat } from '../../../credits/context/utils'\nimport type { ConsumeCreditRuleResponse } from '../../../credits/context/response'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype EnrichedItem = ConsumeCreditsItem & {\n alpcData: ConsumeCreditRuleResponse\n insufficient: boolean\n soldOut: boolean\n disabled: boolean\n product?: any\n variant?: any\n}\n\ntype Props = {\n copy: ConsumeCreditsopy\n}\n\nfunction ConsumeCredits({ copy }: Props) {\n const { profile, creditInfo, openSignUpPopup, alpcConfig, isActivateSuccess, fetchCreditInfo, pageHandle } =\n useMemberPopupContext()\n const { pushView } = useViewStack()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const [redeemAndBuyError, setRedeemAndBuyError] = useState('')\n const [loadingId, setLoadingId] = useState<string | number | null>(null)\n\n useEffect(() => {\n if (profile?.user_id) fetchCreditInfo(profile.user_id)\n }, [])\n\n const isLogin = !!profile\n const { redeemableList, listLoading } = useRedeemableList(alpcConfig)\n const { trigger: redeemAndBuy } = useRedeemAndBuy(alpcConfig)\n\n const handles = copy.list.map(item => item.product?.handle).filter(Boolean) as string[]\n const { data: products } = useProductsByHandles({ handles })\n\n const list = useMemo(() => {\n return copy.list\n .map(item => {\n const alpcData = redeemableList.find(r => String(r.id) === String(item.redeemId))\n if (!alpcData) return null\n\n const availableCredit = Number(creditInfo?.available_credit ?? 0)\n const insufficient = alpcData.consume_credits > availableCredit\n const alpcSoldOut = alpcData.is_limited && (!alpcData.remaining_inventory || alpcData.remaining_inventory <= 0)\n\n const isPhysicalProduct =\n item.type === ConsumeCreditsItemType.RedeemAndBuy || item.type === ConsumeCreditsItemType.Product\n const product = products?.find((p: any) => p.handle === item.product?.handle)\n const variant = product?.variants?.find((v: any) => v.sku === item.product?.sku) ?? product?.variants?.[0]\n if (isPhysicalProduct && (!product || !variant || !variant?.availableForSale || alpcSoldOut)) {\n return null\n }\n return { ...item, alpcData, insufficient, product, variant }\n })\n .filter(Boolean) as EnrichedItem[]\n }, [copy.list, redeemableList, creditInfo, profile, isLogin, products])\n\n const isActivate = profile?.activated || isActivateSuccess\n\n function getButtonLabel(item: (typeof list)[number]) {\n if (!isLogin || !isActivate) {\n return copy.unlockRewards\n }\n if (item.soldOut) {\n return copy.soldOut\n }\n return copy.btnRedeem\n }\n\n function isDisabled(item: (typeof list)[number]) {\n if (!isLogin || !isActivate) {\n return false\n }\n return item.insufficient\n }\n\n function trackRedeemButton(itemTitle: string) {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem',\n info: 'Member Floating Window',\n },\n })\n }\n\n async function handleRedeem(item: (typeof list)[number]) {\n if (!isLogin) {\n openSignUpPopup()\n return\n }\n if (!isActivate) {\n pushView({\n type: MemberPopupPanelType.Activate,\n })\n return\n }\n if (item.type === ConsumeCreditsItemType.GiftCard || item.type === ConsumeCreditsItemType.Product) {\n if (copy.creditsPage?.url) {\n const sectionId = copy.creditsPage.redeemListSectionId ?? 'creditsRedeemList'\n const targetUrl = new URL(copy.creditsPage.url, window.location.href)\n targetUrl.searchParams.set('section', sectionId)\n targetUrl.hash = sectionId\n if (pageHandle) {\n targetUrl.searchParams.set('ref', `${pageHandle}_consume_credits`)\n }\n trackRedeemButton(item.title)\n window.open(targetUrl.toString(), '_blank', 'noopener,noreferrer')\n }\n return\n }\n if (item.type === ConsumeCreditsItemType.Coupon) {\n trackRedeemButton(item.title)\n pushView({\n type: MemberPopupPanelType.RedeemCoupon,\n props: {\n itemTitle: item.title,\n itemCredits: item.alpcData.consume_credits,\n itemImage: copy.imageMapping?.[item.type]\n ? { url: copy.imageMapping[item.type]!.url, alt: item.image?.alt }\n : item.image,\n itemValue: item.value,\n itemRules: item.rules,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n alpcConfig,\n },\n })\n } else {\n setRedeemAndBuyError('')\n setLoadingId(item.redeemId)\n trackRedeemButton(item.title)\n try {\n await redeemAndBuy({\n productVariant: item.variant,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n })\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem_success',\n info: 'Member Floating Window',\n },\n })\n } catch (e: any) {\n setRedeemAndBuyError(e?.message ?? copy.redeemModal.commonError)\n } finally {\n setLoadingId(null)\n }\n }\n }\n\n return (\n <>\n <div className=\"flex flex-1 flex-col\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>}\n {copy.subtitle && (\n <p className=\"text-[16px] mt-[8px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>\n )}\n </div>\n\n {isLogin && (\n <div\n className={cn(\n 'flex items-center mt-[16px] gap-[12px] bg-[#f5f6f7] p-[16px]',\n rounded ? 'rounded-[8px]' : 'rounded-none'\n )}\n >\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.balanceLabel ?? 'AnkerCredits Balance'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.available_credit || 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n <div className=\"h-full w-px bg-[#dadce0]\" />\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.comingSoonLabel ?? 'Coming Soon'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.pending_credit || 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n </div>\n )}\n {redeemAndBuyError && <div className=\"text-[14px] mt-[8px] font-[700] text-[#f84d4f]\">{redeemAndBuyError}</div>}\n\n {listLoading ? (\n <div className=\"flex flex-1 items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n ) : (\n <div className=\"flex mt-[16px] flex-col\">\n {list.map((item, idx) => {\n const hasProduct = !!item.product\n return (\n <div key={idx} className=\"relative py-[16px]\">\n {idx > 0 && <div className=\"absolute inset-x-0 top-0 h-px bg-[#dadce0]\" />}\n <div className=\"flex items-center gap-[12px]\">\n {(() => {\n const mappedImgUrl = copy.imageMapping?.[item.type]?.url\n const imgUrl = hasProduct\n ? (item.variant?.image?.url ?? item.product?.images?.[0]?.url ?? item.image?.url)\n : (mappedImgUrl ?? item.image?.url)\n const imgAlt = hasProduct\n ? (item.variant?.image?.altText ?? item.product?.images?.[0]?.alt ?? item.image?.alt ?? '')\n : (item.image?.alt ?? '')\n if (!imgUrl) return null\n return (\n <div\n className={cn(\n 'relative size-[64px] shrink-0 overflow-hidden',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n >\n <Picture\n source={imgUrl}\n alt={imgAlt}\n className=\"flex size-full items-center justify-center\"\n imgClassName={hasProduct ? 'object-cover' : 'h-full w-auto object-contain'}\n />\n {!hasProduct && item.value && (\n <div className=\"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white\">\n {item.value} {copy.off}\n </div>\n )}\n </div>\n )\n })()}\n <div className=\"min-w-0 flex-1\">\n <div className=\"text-[16px] font-[700] text-[#1e2024] line-clamp-2\">\n {hasProduct && item.product?.title ? item.product.title : item.title}\n </div>\n <div className=\"mt-[4px] text-[14px] text-[#666]\">\n {hasProduct && item.price != null\n ? `${numberFormat(item.alpcData.consume_credits)} ${copy.creditUnit ?? ''} + $${Number(item.price).toFixed(2)}`\n : `${numberFormat(item.alpcData.consume_credits)} ${copy.creditUnit ?? ''}`}\n </div>\n </div>\n <div className=\"relative group\">\n <Button\n className={cn(\n 'bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={isDisabled(item)}\n loading={loadingId === item.redeemId}\n onClick={() => handleRedeem(item)}\n >\n {getButtonLabel(item)}\n </Button>\n {item.insufficient && isLogin && isActivate && (\n <div className=\"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block\">\n <div className=\"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow\">\n <p className=\"text-pretty tracking-[-0.02em] text-[14px]\">{copy.insufficientCredits}</p>\n <div className=\"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]\" />\n </div>\n </div>\n )}\n </div>\n </div>\n </div>\n )\n })}\n </div>\n )}\n\n {copy.creditsPage?.url && (\n <a\n href={(() => {\n if (!pageHandle) return copy.creditsPage!.url\n try {\n const url = new URL(copy.creditsPage!.url, window.location.href)\n url.searchParams.set('ref', `${pageHandle}_consume_credits`)\n return url.toString()\n } catch {\n return copy.creditsPage!.url\n }\n })()}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline\"\n onClick={() =>\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'credits_page_link',\n info: 'Member Floating Window',\n },\n })\n }\n >\n {copy.creditsPage.label ?? 'Go to Credits Page'}\n </a>\n )}\n </div>\n </>\n )\n}\n\nexport default ConsumeCredits\n"],
5
- "mappings": "AA8KI,mBAAAA,GAGqB,OAAAC,EADjB,QAAAC,MAFJ,oBA9KJ,OAAS,aAAAC,EAAW,WAAAC,EAAS,YAAAC,MAAgB,QAC7C,OAAS,WAAAC,EAAS,UAAAC,MAAc,wBAChC,OAAS,WAAAC,EAAS,cAAcC,EAAI,wBAAAC,EAAsB,sBAAAC,MAA0B,gBACpF,OAAS,yBAAAC,MAA6B,yBACtC,OAAS,gBAAAC,MAAoB,0BAC7B,OAAS,qBAAAC,MAAyB,4BAClC,OAAS,mBAAAC,MAAuB,0BAChC,OACE,0BAAAC,EACA,wBAAAC,MAGK,aACP,OAAS,gBAAAC,MAAoB,iCAE7B,OAAS,kBAAAC,OAAsB,wBAe/B,SAASC,GAAe,CAAE,KAAAC,CAAK,EAAU,CACvC,KAAM,CAAE,QAAAC,EAAS,WAAAC,EAAY,g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,IAAI,IAAI/C,EAAK,YAAa,IAAK,OAAO,SAAS,IAAI,EAC/D,OAAA+C,EAAI,aAAa,IAAI,MAAO,GAAGxC,CAAU,kBAAkB,EACpDwC,EAAI,SAAS,CACtB,MAAQ,CACN,OAAO/C,EAAK,YAAa,GAC3B,CACF,GAAG,EACH,OAAO,SACP,IAAI,sBACJ,UAAU,qEACV,QAAS,IACPb,EAAQ,CACN,MAAO,WACP,WAAY,YACZ,iBAAkB,CAChB,SAAU,kBACV,YAAa,oBACb,KAAM,wBACR,CACF,CAAC,EAGF,SAAAa,EAAK,YAAY,OAAS,qBAC7B,GAEJ,EACF,CAEJ,CAEA,IAAOgD,GAAQjD",
6
- "names": ["Fragment", "jsx", "jsxs", "useEffect", "useMemo", "useState", "Picture", "Button", "gaTrack", "cn", "useProductsByHandles", "useHeadlessContext", "useMemberPopupContext", "useViewStack", "useRedeemableList", "useRedeemAndBuy", "ConsumeCreditsItemType", "MemberPopupPanelType", "numberFormat", "ROUNDED_BRANDS", "ConsumeCredits", "copy", "profile", "creditInfo", "openSignUpPopup", "alpcConfig", "isActivateSuccess", "fetchCreditInfo", "pageHandle", "pushView", "brand", "rounded", "redeemAndBuyError", "setRedeemAndBuyError", "loadingId", "setLoadingId", "isLogin", "redeemableList", "listLoading", "redeemAndBuy", "handles", "item", "products", "list", "alpcData", "r", "availableCredit", "insufficient", "alpcSoldOut", "isPhysicalProduct", "product", "p", "variant", "v", "isActivate", "getButtonLabel", "isDisabled", "trackRedeemButton", "itemTitle", "handleRedeem", "sectionId", "targetUrl", "e", "idx", "hasProduct", "mappedImgUrl", "imgUrl", "imgAlt", "url", "ConsumeCredits_default"]
4
+ "sourcesContent": ["import { useEffect, useMemo, useState } from 'react'\nimport { Picture, Button } from '@anker-in/headless-ui'\nimport { gaTrack, classNames as cn, useProductsByHandles, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useRedeemableList } from './hooks/useRedeemableList'\nimport { useRedeemAndBuy } from './hooks/useRedeemAndBuy'\nimport {\n ConsumeCreditsItemType,\n MemberPopupPanelType,\n type ConsumeCreditsopy,\n type ConsumeCreditsItem,\n} from '../../type'\nimport { numberFormat } from '../../../credits/context/utils'\nimport type { ConsumeCreditRuleResponse } from '../../../credits/context/response'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype EnrichedItem = ConsumeCreditsItem & {\n alpcData: ConsumeCreditRuleResponse\n insufficient: boolean\n soldOut: boolean\n disabled: boolean\n product?: any\n variant?: any\n}\n\ntype Props = {\n copy: ConsumeCreditsopy\n}\n\nfunction ConsumeCredits({ copy }: Props) {\n const { profile, creditInfo, openSignUpPopup, alpcConfig, isActivateSuccess, fetchCreditInfo, pageHandle } =\n useMemberPopupContext()\n const { pushView } = useViewStack()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const [redeemAndBuyError, setRedeemAndBuyError] = useState('')\n const [loadingId, setLoadingId] = useState<string | number | null>(null)\n\n useEffect(() => {\n if (profile?.user_id) fetchCreditInfo(profile.user_id)\n }, [])\n\n const isLogin = !!profile\n const { redeemableList, listLoading } = useRedeemableList(alpcConfig)\n const { trigger: redeemAndBuy } = useRedeemAndBuy(alpcConfig)\n\n const handles = copy.list.map(item => item.product?.handle).filter(Boolean) as string[]\n const { data: products } = useProductsByHandles({ handles })\n\n const list = useMemo(() => {\n return copy.list\n .map(item => {\n const alpcData = redeemableList.find(r => String(r.id) === String(item.redeemId))\n if (!alpcData) return null\n\n const availableCredit = Number(creditInfo?.available_credit ?? 0)\n const insufficient = alpcData.consume_credits > availableCredit\n const alpcSoldOut = alpcData.is_limited && (!alpcData.remaining_inventory || alpcData.remaining_inventory <= 0)\n\n const isPhysicalProduct =\n item.type === ConsumeCreditsItemType.RedeemAndBuy || item.type === ConsumeCreditsItemType.Product\n const product = products?.find((p: any) => p.handle === item.product?.handle)\n const variant = product?.variants?.find((v: any) => v.sku === item.product?.sku) ?? product?.variants?.[0]\n if (isPhysicalProduct && (!product || !variant || !variant?.availableForSale || alpcSoldOut)) {\n return null\n }\n if (item.type === ConsumeCreditsItemType.RedeemAndBuy && item.price == null) {\n return null\n }\n return { ...item, alpcData, insufficient, product, variant }\n })\n .filter(Boolean) as EnrichedItem[]\n }, [copy.list, redeemableList, creditInfo, profile, isLogin, products])\n\n const isActivate = profile?.activated || isActivateSuccess\n\n function getButtonLabel(item: (typeof list)[number]) {\n if (!isLogin || !isActivate) {\n return copy.unlockRewards\n }\n if (item.soldOut) {\n return copy.soldOut\n }\n return copy.btnRedeem\n }\n\n function isDisabled(item: (typeof list)[number]) {\n if (!isLogin || !isActivate) {\n return false\n }\n return item.insufficient\n }\n\n function trackRedeemButton(itemTitle: string) {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem',\n info: 'Member Floating Window',\n },\n })\n }\n\n async function handleRedeem(item: (typeof list)[number]) {\n if (!isLogin) {\n openSignUpPopup()\n return\n }\n if (!isActivate) {\n pushView({\n type: MemberPopupPanelType.Activate,\n })\n return\n }\n if (item.type === ConsumeCreditsItemType.GiftCard || item.type === ConsumeCreditsItemType.Product) {\n if (copy.creditsPage?.url) {\n const sectionId = copy.creditsPage.redeemListSectionId ?? 'creditsRedeemList'\n const targetUrl = new URL(copy.creditsPage.url, window.location.href)\n targetUrl.searchParams.set('section', sectionId)\n targetUrl.hash = sectionId\n if (pageHandle) {\n targetUrl.searchParams.set('ref', `${pageHandle}_consume_credits`)\n }\n trackRedeemButton(item.title)\n window.open(targetUrl.toString(), '_blank', 'noopener,noreferrer')\n }\n return\n }\n if (item.type === ConsumeCreditsItemType.Coupon) {\n trackRedeemButton(item.title)\n pushView({\n type: MemberPopupPanelType.RedeemCoupon,\n props: {\n itemTitle: item.title,\n itemCredits: item.alpcData.consume_credits,\n itemImage: copy.imageMapping?.[item.type]\n ? { url: copy.imageMapping[item.type]!.url, alt: item.image?.alt }\n : item.image,\n itemValue: item.value,\n itemRules: item.rules,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n alpcConfig,\n },\n })\n } else {\n setRedeemAndBuyError('')\n setLoadingId(item.redeemId)\n trackRedeemButton(item.title)\n try {\n await redeemAndBuy({\n productVariant: item.variant,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n })\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem_success',\n info: 'Member Floating Window',\n },\n })\n } catch (e: any) {\n setRedeemAndBuyError(e?.message ?? copy.redeemModal.commonError)\n } finally {\n setLoadingId(null)\n }\n }\n }\n\n return (\n <>\n <div className=\"flex flex-1 flex-col\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>}\n {copy.subtitle && (\n <p className=\"text-[16px] mt-[8px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>\n )}\n </div>\n\n {isLogin && (\n <div\n className={cn(\n 'flex items-center mt-[16px] gap-[12px] bg-[#f5f6f7] p-[16px]',\n rounded ? 'rounded-[8px]' : 'rounded-none'\n )}\n >\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.balanceLabel ?? 'AnkerCredits Balance'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.available_credit || 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n <div className=\"h-full w-px bg-[#dadce0]\" />\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.comingSoonLabel ?? 'Coming Soon'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.pending_credit || 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n </div>\n )}\n {redeemAndBuyError && <div className=\"text-[14px] mt-[8px] font-[700] text-[#f84d4f]\">{redeemAndBuyError}</div>}\n\n {listLoading ? (\n <div className=\"flex flex-1 items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n ) : (\n <div className=\"flex mt-[16px] flex-col\">\n {list.map((item, idx) => {\n return (\n <div key={idx} className=\"relative py-[16px]\">\n {idx > 0 && <div className=\"absolute inset-x-0 top-0 h-px bg-[#dadce0]\" />}\n <div className=\"flex items-center gap-[12px]\">\n {(() => {\n const phsicalProduct =\n item.type === ConsumeCreditsItemType.Product ||\n item.type === ConsumeCreditsItemType.RedeemAndBuy\n const imgUrl = phsicalProduct\n ? (item.variant?.image?.url ?? item.product?.images?.[0]?.url ?? item.image?.url)\n : item.image?.url || copy.imageMapping?.[item.type]?.url\n const imgAlt = phsicalProduct\n ? (item.variant?.image?.altText ?? item.product?.images?.[0]?.alt ?? item.image?.alt ?? '')\n : (item.image?.alt ?? '')\n if (!imgUrl) return null\n return (\n <div\n className={cn(\n 'relative size-[64px] shrink-0 overflow-hidden',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n >\n <Picture\n source={imgUrl}\n alt={imgAlt}\n className=\"flex size-full items-center justify-center\"\n imgClassName={phsicalProduct ? 'object-cover' : 'h-full w-auto object-contain'}\n />\n {item.type === ConsumeCreditsItemType.Coupon && item.value && (\n <div className=\"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white\">\n {item.value && `${item.value} ${copy.off}`}\n </div>\n )}\n {item.type === ConsumeCreditsItemType.GiftCard && item.value && (\n <div className=\"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white\">\n {item.value && `${item.value} ${copy.giftCard || 'Gift Card'}`}\n </div>\n )}\n </div>\n )\n })()}\n <div className=\"min-w-0 flex-1\">\n <div className=\"text-[16px] font-[700] text-[#1e2024] line-clamp-2\">\n {item.product.title ?? item.title ?? item.alpcData?.name}\n </div>\n <div className=\"mt-[4px] text-[14px] text-[#666]\">\n {item.type === ConsumeCreditsItemType.RedeemAndBuy ? (\n <>\n <div>\n {numberFormat(item.alpcData.consume_credits)} {copy.creditUnit ?? ''} + $\n {Number(item.price).toFixed(2)}\n </div>\n {item.variant?.price?.amount && (\n <div className=\"text-[12px] text-[#999] line-through\">\n ${Number(item.variant.price.amount).toFixed(2)}\n </div>\n )}\n </>\n ) : (\n `${numberFormat(item.alpcData.consume_credits)} ${copy.creditUnit ?? ''}`\n )}\n </div>\n </div>\n <div className=\"relative group\">\n <Button\n className={cn(\n 'bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={isDisabled(item)}\n loading={loadingId === item.redeemId}\n onClick={() => handleRedeem(item)}\n >\n {getButtonLabel(item)}\n </Button>\n {item.insufficient && isLogin && isActivate && (\n <div className=\"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block\">\n <div className=\"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow\">\n <p className=\"text-pretty tracking-[-0.02em] text-[14px]\">{copy.insufficientCredits}</p>\n <div className=\"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]\" />\n </div>\n </div>\n )}\n </div>\n </div>\n </div>\n )\n })}\n </div>\n )}\n\n {copy.creditsPage?.url && (\n <a\n href={(() => {\n if (!pageHandle) return copy.creditsPage!.url\n try {\n const url = new URL(copy.creditsPage!.url, window.location.href)\n url.searchParams.set('ref', `${pageHandle}_consume_credits`)\n return url.toString()\n } catch {\n return copy.creditsPage!.url\n }\n })()}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline\"\n onClick={() =>\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'credits_page_link',\n info: 'Member Floating Window',\n },\n })\n }\n >\n {copy.creditsPage.label ?? 'Go to Credits Page'}\n </a>\n )}\n </div>\n </>\n )\n}\n\nexport default ConsumeCredits\n"],
5
+ "mappings": "AAmLQ,OA+FkB,YAAAA,EA9FD,OAAAC,EADjB,QAAAC,MAAA,oBAnLR,OAAS,aAAAC,EAAW,WAAAC,EAAS,YAAAC,MAAgB,QAC7C,OAAS,WAAAC,EAAS,UAAAC,MAAc,wBAChC,OAAS,WAAAC,EAAS,cAAcC,EAAI,wBAAAC,EAAsB,sBAAAC,MAA0B,gBACpF,OAAS,yBAAAC,MAA6B,yBACtC,OAAS,gBAAAC,MAAoB,0BAC7B,OAAS,qBAAAC,MAAyB,4BAClC,OAAS,mBAAAC,OAAuB,0BAChC,OACE,0BAAAC,EACA,wBAAAC,MAGK,aACP,OAAS,gBAAAC,MAAoB,iCAE7B,OAAS,kBAAAC,OAAsB,wBAe/B,SAASC,GAAe,CAAE,KAAAC,CAAK,EAAU,CACvC,KAAM,CAAE,QAAAC,EAAS,WAAAC,EAAY,gBAAAC,EAAiB,WAAAC,EAAY,kBAAAC,EAAmB,gBAAAC,EAAiB,WAAAC,CAAW,EACvGhB,EAAsB,EAClB,CAAE,SAAAiB,CAAS,EAAIhB,EAAa,EAC5B,CAAE,MAAAiB,CAAM,EAAInB,EAAmB,EAC/BoB,EAAUZ,GAAe,SAASW,CAAK,EAEvC,CAACE,EAAmBC,CAAoB,EAAI5B,EAAS,EAAE,EACvD,CAAC6B,EAAWC,CAAY,EAAI9B,EAAiC,IAAI,EAEvEF,EAAU,IAAM,CACVmB,GAAS,SAASK,EAAgBL,EAA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IAC1C,GAAI,CACF,MAAM8C,EAAM,IAAI,IAAI9C,EAAK,YAAa,IAAK,OAAO,SAAS,IAAI,EAC/D,OAAA8C,EAAI,aAAa,IAAI,MAAO,GAAGvC,CAAU,kBAAkB,EACpDuC,EAAI,SAAS,CACtB,MAAQ,CACN,OAAO9C,EAAK,YAAa,GAC3B,CACF,GAAG,EACH,OAAO,SACP,IAAI,sBACJ,UAAU,qEACV,QAAS,IACPb,EAAQ,CACN,MAAO,WACP,WAAY,YACZ,iBAAkB,CAChB,SAAU,kBACV,YAAa,oBACb,KAAM,wBACR,CACF,CAAC,EAGF,SAAAa,EAAK,YAAY,OAAS,qBAC7B,GAEJ,EACF,CAEJ,CAEA,IAAO+C,GAAQhD",
6
+ "names": ["Fragment", "jsx", "jsxs", "useEffect", "useMemo", "useState", "Picture", "Button", "gaTrack", "cn", "useProductsByHandles", "useHeadlessContext", "useMemberPopupContext", "useViewStack", "useRedeemableList", "useRedeemAndBuy", "ConsumeCreditsItemType", "MemberPopupPanelType", "numberFormat", "ROUNDED_BRANDS", "ConsumeCredits", "copy", "profile", "creditInfo", "openSignUpPopup", "alpcConfig", "isActivateSuccess", "fetchCreditInfo", "pageHandle", "pushView", "brand", "rounded", "redeemAndBuyError", "setRedeemAndBuyError", "loadingId", "setLoadingId", "isLogin", "redeemableList", "listLoading", "redeemAndBuy", "handles", "item", "products", "list", "alpcData", "r", "availableCredit", "insufficient", "alpcSoldOut", "isPhysicalProduct", "product", "p", "variant", "v", "isActivate", "getButtonLabel", "isDisabled", "trackRedeemButton", "itemTitle", "handleRedeem", "sectionId", "targetUrl", "e", "idx", "phsicalProduct", "imgUrl", "imgAlt", "url", "ConsumeCredits_default"]
7
7
  }
@@ -147,6 +147,7 @@ export type ConsumeCreditsopy = {
147
147
  comingSoonLabel?: string;
148
148
  creditUnit?: string;
149
149
  off?: string;
150
+ giftCard?: string;
150
151
  imageMapping?: {
151
152
  [key in ConsumeCreditsItemType]?: {
152
153
  url: string;
@@ -190,6 +191,8 @@ export type RedeemCouponModalCopy = {
190
191
  successDesc: string;
191
192
  successButton: string;
192
193
  successButtonUrl?: string;
194
+ copyLabel?: string;
195
+ copiedLabel?: string;
193
196
  };
194
197
  export type ReferralCopy = {
195
198
  title?: string;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/memberPopup/type.ts"],
4
- "sourcesContent": ["import type { AuthCodeActivateCopy } from '../registration/authCodeActivate/type'\nimport type { CreditInfoResponse } from '../credits/context/response'\nimport type { DTC_TASK_TYPE } from '../credits/context/const'\n\nexport type { AuthCodeActivateCopy }\n\n// \u2500\u2500\u2500 \u9762\u677F\u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupPanelType {\n EarnCredits = 'EARN_CREDITS',\n ConsumeCredits = 'CONSUME_CREDITS',\n Referral = 'REFERRAL',\n CompleteProfile = 'COMPLETE_PROFILE',\n Subscribe = 'SUBSCRIBE',\n SubscribeEmail = 'SUBSCRIBE_EMAIL',\n RedeemCoupon = 'REDEEM_COUPON',\n Activate = 'ACTIVATE',\n}\n\n// \u2500\u2500\u2500 item action \u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupActionType {\n ExternalLink = 'EXTERNAL_LINK',\n OpenEarnCredits = 'OPEN_EARN_CREDITS',\n OpenConsumeCredits = 'OPEN_CONSUME_CREDITS',\n OpenReferral = 'OPEN_REFERRAL',\n OpenSubscribe = 'OPEN_SUBSCRIBE',\n}\n\n// \u2500\u2500\u2500 EarnCredits \u4EFB\u52A1\u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum EarnCreditsTaskType {\n Activate = 'activate',\n CompleteProfile = 'completeProfile',\n Subscribe = 'subscribe',\n Shop = 'shop',\n}\n\n// \u2500\u2500\u2500 ConsumeCredits item \u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum ConsumeCreditsItemType {\n Coupon = 'COUPON',\n RedeemAndBuy = 'REDEEM_AND_BUY',\n GiftCard = 'GIFT_CARD',\n Product = 'PRODUCT',\n}\n\n// \u2500\u2500\u2500 \u901A\u7528 link\uFF08\u7EDF\u4E00\u4E00\u79CD\u7C7B\u578B\uFF09 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type MemberPopupLink = {\n type: MemberPopupActionType\n label: string\n url?: string // \u4EC5 ExternalLink \u65F6\u4F7F\u7528\n}\n\n// \u2500\u2500\u2500 list item \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type MemberPopupItem = {\n title: string\n description?: string\n links: MemberPopupLink[]\n}\n\n// \u2500\u2500 \u4E3B\u7EC4\u4EF6 Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupPageScope {\n /** \u5168\u5C40\u5C55\u793A */\n Global = 'GLOBAL',\n /** \u4EC5\u5728\u7279\u5B9A\u9875\u9762\u5C55\u793A */\n Include = 'INCLUDE',\n /** \u5728\u7279\u5B9A\u9875\u9762\u4E0D\u5C55\u793A */\n Exclude = 'EXCLUDE',\n}\n\nexport type MemberPopupPageConfig = {\n scope: MemberPopupPageScope\n /** \u9875\u9762\u8DEF\u5F84\u5217\u8868\uFF0C\u652F\u6301\u7CBE\u786E\u5339\u914D\u548C\u524D\u7F00\u5339\u914D\uFF08\u5982 \"/products\" \u4F1A\u5339\u914D \"/products/xxx\"\uFF09 */\n pages: string[]\n}\n\nexport type MemberPopupCopy = {\n triggerImg: { url: string; alt?: string }\n title?: string\n subtitle?: string\n list: MemberPopupItem[]\n footer?: {\n loginHint: string\n loginLabel: string\n joinLabel: string\n shopLabel: string\n shopUrl?: string\n }\n activitiesSubscribe?: SubscribeModalCopy\n earnCredits?: EarnCreditsCopy\n consumeCredits?: ConsumeCreditsopy\n referral?: ReferralCopy\n /** \u9875\u9762\u8986\u76D6\u8303\u56F4\u914D\u7F6E\uFF0C\u9ED8\u8BA4\u5168\u5C40\u5C55\u793A */\n pageConfig?: MemberPopupPageConfig\n}\n\n// \u2500\u2500\u2500 EarnCredits Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type EarnCreditsCopy = {\n title?: string\n subtitle?: string\n balanceLabel?: string\n comingSoonLabel?: string\n creditUnit?: string\n joinNow: string\n completed: string\n activate: string\n completeProfileLabel: string\n subscribeLabel: string\n shopNow: string\n goShopLink?: string\n list: {\n id: EarnCreditsTaskType\n title: string\n credits?: string\n }[]\n // \u5B50\u5F39\u7A97\u6587\u6848\n authCodeActivate: AuthCodeActivateCopy\n completeProfile: CompleteProfileCopy\n subscribe: SubscribeModalCopy\n}\n\nexport type CompleteProfileCopy = {\n title: string\n subtitle?: string\n firstName: string\n lastName: string\n email: string\n phone: string\n birthday: string\n country: string\n save: string\n cancel: string\n edit: string\n required: string\n}\n\nexport type SubscribeModalCopy = {\n title: string\n desc?: string\n placeholder: string\n policy?: string\n policyDefaultChecked?: boolean\n successTips?: string\n subscribedLabel?: string\n dealsType?: string\n buttonLabel?: string\n single_brand_subscribe?: boolean\n genre?: string\n sub_brand_type?: string\n promo?: {\n title?: string\n description?: string\n learnMoreLabel?: string\n learnMoreUrl?: string\n image?: { url: string; alt?: string }\n }\n}\n\n// \u2500\u2500\u2500 ConsumeCredits Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type ConsumeCreditsopy = {\n title?: string\n subtitle?: string\n soldOut: string\n unlockRewards: string\n btnRedeem: string\n insufficientCredits?: string\n balanceLabel?: string\n comingSoonLabel?: string\n creditUnit?: string\n off?: string\n imageMapping?: {\n [key in ConsumeCreditsItemType]?: { url: string }\n }\n list: ConsumeCreditsItem[]\n redeemModal: RedeemCouponModalCopy\n creditsPage?: { label: string; url: string; redeemListSectionId?: string }\n}\n\nexport type ConsumeCreditsItem = {\n redeemId: string | number\n title: string\n description?: string\n image: { url: string; alt?: string }\n type: ConsumeCreditsItemType\n product?: { handle: string; sku: string }\n price?: number\n value?: string\n rules?: string[]\n}\n\nexport type RedeemCouponModalCopy = {\n confirmTitle: string\n confirmButton: string\n off?: string\n commonError: string\n redeemLimitError: string\n inventoryNotEnough: string\n creditsNotEnough: string\n crossSiteError: string\n successTitle: string\n successDesc: string\n successButton: string\n successButtonUrl?: string\n}\n\n// \u2500\u2500\u2500 Referral Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type ReferralCopy = {\n title?: string\n description?: string\n cashAvailableLabel: string\n cashPendingLabel: string\n creditUnit?: string\n referralLinksLabel?: string\n referralLinkBaseUrl?: string\n copyLabel?: string\n copiedLabel?: string\n howToTitle?: string\n howToDescription?: string\n learnMoreLabel?: string\n learnMoreUrl?: string\n image?: { url: string; alt?: string }\n ctaButton: string\n ctaUrl?: string\n loginTitle?: string\n loginDescription?: string\n loginCtaLabel?: string\n}\n\n// \u2500\u2500\u2500 Provider Context \u7C7B\u578B \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type AlpcConfig = {\n brand: string\n locale: string\n appName: string\n apiBaseUrl?: string\n}\n\nexport type MemberPopupContextValue = {\n profile: any\n isLoadingProfile: boolean\n creditInfo?: CreditInfoResponse\n fetchCreditInfo: (userId: string) => void\n openSignUpPopup: () => void\n openSignInPopup: () => void\n taskIdToTypeMapping?: Record<string, DTC_TASK_TYPE>\n alpcConfig: AlpcConfig\n pageHandle?: string\n}\n\nexport type MemberPopupInternalContextValue = MemberPopupContextValue & {\n isSubscribeSuccess: boolean\n setIsSubscribeSuccess: (v: boolean) => void\n isActivateSuccess: boolean\n setIsActivateSuccess: (v: boolean) => void\n isProfileCompleteSuccess: boolean\n setIsProfileCompleteSuccess: (v: boolean) => void\n}\n"],
4
+ "sourcesContent": ["import type { AuthCodeActivateCopy } from '../registration/authCodeActivate/type'\nimport type { CreditInfoResponse } from '../credits/context/response'\nimport type { DTC_TASK_TYPE } from '../credits/context/const'\n\nexport type { AuthCodeActivateCopy }\n\n// \u2500\u2500\u2500 \u9762\u677F\u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupPanelType {\n EarnCredits = 'EARN_CREDITS',\n ConsumeCredits = 'CONSUME_CREDITS',\n Referral = 'REFERRAL',\n CompleteProfile = 'COMPLETE_PROFILE',\n Subscribe = 'SUBSCRIBE',\n SubscribeEmail = 'SUBSCRIBE_EMAIL',\n RedeemCoupon = 'REDEEM_COUPON',\n Activate = 'ACTIVATE',\n}\n\n// \u2500\u2500\u2500 item action \u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupActionType {\n ExternalLink = 'EXTERNAL_LINK',\n OpenEarnCredits = 'OPEN_EARN_CREDITS',\n OpenConsumeCredits = 'OPEN_CONSUME_CREDITS',\n OpenReferral = 'OPEN_REFERRAL',\n OpenSubscribe = 'OPEN_SUBSCRIBE',\n}\n\n// \u2500\u2500\u2500 EarnCredits \u4EFB\u52A1\u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum EarnCreditsTaskType {\n Activate = 'activate',\n CompleteProfile = 'completeProfile',\n Subscribe = 'subscribe',\n Shop = 'shop',\n}\n\n// \u2500\u2500\u2500 ConsumeCredits item \u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum ConsumeCreditsItemType {\n Coupon = 'COUPON',\n RedeemAndBuy = 'REDEEM_AND_BUY',\n GiftCard = 'GIFT_CARD',\n Product = 'PRODUCT',\n}\n\n// \u2500\u2500\u2500 \u901A\u7528 link\uFF08\u7EDF\u4E00\u4E00\u79CD\u7C7B\u578B\uFF09 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type MemberPopupLink = {\n type: MemberPopupActionType\n label: string\n url?: string // \u4EC5 ExternalLink \u65F6\u4F7F\u7528\n}\n\n// \u2500\u2500\u2500 list item \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type MemberPopupItem = {\n title: string\n description?: string\n links: MemberPopupLink[]\n}\n\n// \u2500\u2500 \u4E3B\u7EC4\u4EF6 Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupPageScope {\n /** \u5168\u5C40\u5C55\u793A */\n Global = 'GLOBAL',\n /** \u4EC5\u5728\u7279\u5B9A\u9875\u9762\u5C55\u793A */\n Include = 'INCLUDE',\n /** \u5728\u7279\u5B9A\u9875\u9762\u4E0D\u5C55\u793A */\n Exclude = 'EXCLUDE',\n}\n\nexport type MemberPopupPageConfig = {\n scope: MemberPopupPageScope\n /** \u9875\u9762\u8DEF\u5F84\u5217\u8868\uFF0C\u652F\u6301\u7CBE\u786E\u5339\u914D\u548C\u524D\u7F00\u5339\u914D\uFF08\u5982 \"/products\" \u4F1A\u5339\u914D \"/products/xxx\"\uFF09 */\n pages: string[]\n}\n\nexport type MemberPopupCopy = {\n triggerImg: { url: string; alt?: string }\n title?: string\n subtitle?: string\n list: MemberPopupItem[]\n footer?: {\n loginHint: string\n loginLabel: string\n joinLabel: string\n shopLabel: string\n shopUrl?: string\n }\n activitiesSubscribe?: SubscribeModalCopy\n earnCredits?: EarnCreditsCopy\n consumeCredits?: ConsumeCreditsopy\n referral?: ReferralCopy\n /** \u9875\u9762\u8986\u76D6\u8303\u56F4\u914D\u7F6E\uFF0C\u9ED8\u8BA4\u5168\u5C40\u5C55\u793A */\n pageConfig?: MemberPopupPageConfig\n}\n\n// \u2500\u2500\u2500 EarnCredits Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type EarnCreditsCopy = {\n title?: string\n subtitle?: string\n balanceLabel?: string\n comingSoonLabel?: string\n creditUnit?: string\n joinNow: string\n completed: string\n activate: string\n completeProfileLabel: string\n subscribeLabel: string\n shopNow: string\n goShopLink?: string\n list: {\n id: EarnCreditsTaskType\n title: string\n credits?: string\n }[]\n // \u5B50\u5F39\u7A97\u6587\u6848\n authCodeActivate: AuthCodeActivateCopy\n completeProfile: CompleteProfileCopy\n subscribe: SubscribeModalCopy\n}\n\nexport type CompleteProfileCopy = {\n title: string\n subtitle?: string\n firstName: string\n lastName: string\n email: string\n phone: string\n birthday: string\n country: string\n save: string\n cancel: string\n edit: string\n required: string\n}\n\nexport type SubscribeModalCopy = {\n title: string\n desc?: string\n placeholder: string\n policy?: string\n policyDefaultChecked?: boolean\n successTips?: string\n subscribedLabel?: string\n dealsType?: string\n buttonLabel?: string\n single_brand_subscribe?: boolean\n genre?: string\n sub_brand_type?: string\n promo?: {\n title?: string\n description?: string\n learnMoreLabel?: string\n learnMoreUrl?: string\n image?: { url: string; alt?: string }\n }\n}\n\n// \u2500\u2500\u2500 ConsumeCredits Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type ConsumeCreditsopy = {\n title?: string\n subtitle?: string\n soldOut: string\n unlockRewards: string\n btnRedeem: string\n insufficientCredits?: string\n balanceLabel?: string\n comingSoonLabel?: string\n creditUnit?: string\n off?: string\n giftCard?: string\n imageMapping?: {\n [key in ConsumeCreditsItemType]?: { url: string }\n }\n list: ConsumeCreditsItem[]\n redeemModal: RedeemCouponModalCopy\n creditsPage?: { label: string; url: string; redeemListSectionId?: string }\n}\n\nexport type ConsumeCreditsItem = {\n redeemId: string | number\n title: string\n description?: string\n image: { url: string; alt?: string }\n type: ConsumeCreditsItemType\n product?: { handle: string; sku: string }\n price?: number\n value?: string\n rules?: string[]\n}\n\nexport type RedeemCouponModalCopy = {\n confirmTitle: string\n confirmButton: string\n off?: string\n commonError: string\n redeemLimitError: string\n inventoryNotEnough: string\n creditsNotEnough: string\n crossSiteError: string\n successTitle: string\n successDesc: string\n successButton: string\n successButtonUrl?: string\n copyLabel?: string\n copiedLabel?: string\n}\n\n// \u2500\u2500\u2500 Referral Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type ReferralCopy = {\n title?: string\n description?: string\n cashAvailableLabel: string\n cashPendingLabel: string\n creditUnit?: string\n referralLinksLabel?: string\n referralLinkBaseUrl?: string\n copyLabel?: string\n copiedLabel?: string\n howToTitle?: string\n howToDescription?: string\n learnMoreLabel?: string\n learnMoreUrl?: string\n image?: { url: string; alt?: string }\n ctaButton: string\n ctaUrl?: string\n loginTitle?: string\n loginDescription?: string\n loginCtaLabel?: string\n}\n\n// \u2500\u2500\u2500 Provider Context \u7C7B\u578B \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type AlpcConfig = {\n brand: string\n locale: string\n appName: string\n apiBaseUrl?: string\n}\n\nexport type MemberPopupContextValue = {\n profile: any\n isLoadingProfile: boolean\n creditInfo?: CreditInfoResponse\n fetchCreditInfo: (userId: string) => void\n openSignUpPopup: () => void\n openSignInPopup: () => void\n taskIdToTypeMapping?: Record<string, DTC_TASK_TYPE>\n alpcConfig: AlpcConfig\n pageHandle?: string\n}\n\nexport type MemberPopupInternalContextValue = MemberPopupContextValue & {\n isSubscribeSuccess: boolean\n setIsSubscribeSuccess: (v: boolean) => void\n isActivateSuccess: boolean\n setIsActivateSuccess: (v: boolean) => void\n isProfileCompleteSuccess: boolean\n setIsProfileCompleteSuccess: (v: boolean) => void\n}\n"],
5
5
  "mappings": "AAOO,IAAKA,OACVA,EAAA,YAAc,eACdA,EAAA,eAAiB,kBACjBA,EAAA,SAAW,WACXA,EAAA,gBAAkB,mBAClBA,EAAA,UAAY,YACZA,EAAA,eAAiB,kBACjBA,EAAA,aAAe,gBACfA,EAAA,SAAW,WARDA,OAAA,IAYAC,OACVA,EAAA,aAAe,gBACfA,EAAA,gBAAkB,oBAClBA,EAAA,mBAAqB,uBACrBA,EAAA,aAAe,gBACfA,EAAA,cAAgB,iBALNA,OAAA,IASAC,OACVA,EAAA,SAAW,WACXA,EAAA,gBAAkB,kBAClBA,EAAA,UAAY,YACZA,EAAA,KAAO,OAJGA,OAAA,IAQAC,OACVA,EAAA,OAAS,SACTA,EAAA,aAAe,iBACfA,EAAA,SAAW,YACXA,EAAA,QAAU,UAJAA,OAAA,IAsBAC,OAEVA,EAAA,OAAS,SAETA,EAAA,QAAU,UAEVA,EAAA,QAAU,UANAA,OAAA",
6
6
  "names": ["MemberPopupPanelType", "MemberPopupActionType", "EarnCreditsTaskType", "ConsumeCreditsItemType", "MemberPopupPageScope"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anker-in/campaign-ui",
3
- "version": "0.5.0-beta.24",
3
+ "version": "0.5.0-beta.25",
4
4
  "description": "Campaign UI components and utilities for Anker projects",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -62,6 +62,7 @@
62
62
  "typescript": "^5.0.0"
63
63
  },
64
64
  "peerDependencies": {
65
+ "@anker-in/headless-ui": ">=1.0.0",
65
66
  "crypto-js": "^4.1.1"
66
67
  },
67
68
  "dependencies": {
@@ -128,7 +128,7 @@ export default function RedeemCouponPanel({ onClose, item, copy, onError }: Prop
128
128
  disabled={copied}
129
129
  onClick={() => copyText(couponCode)}
130
130
  >
131
- {copied ? 'Copied' : 'Copy'}
131
+ {copied ? (redeemModal.copiedLabel ?? 'Copied') : (redeemModal.copyLabel ?? 'Copy')}
132
132
  </button>
133
133
  </div>
134
134
  <Text className="text-[20px] font-[700]" html={redeemModal.successTitle} />
@@ -66,6 +66,9 @@ function ConsumeCredits({ copy }: Props) {
66
66
  if (isPhysicalProduct && (!product || !variant || !variant?.availableForSale || alpcSoldOut)) {
67
67
  return null
68
68
  }
69
+ if (item.type === ConsumeCreditsItemType.RedeemAndBuy && item.price == null) {
70
+ return null
71
+ }
69
72
  return { ...item, alpcData, insufficient, product, variant }
70
73
  })
71
74
  .filter(Boolean) as EnrichedItem[]
@@ -222,17 +225,18 @@ function ConsumeCredits({ copy }: Props) {
222
225
  ) : (
223
226
  <div className="flex mt-[16px] flex-col">
224
227
  {list.map((item, idx) => {
225
- const hasProduct = !!item.product
226
228
  return (
227
229
  <div key={idx} className="relative py-[16px]">
228
230
  {idx > 0 && <div className="absolute inset-x-0 top-0 h-px bg-[#dadce0]" />}
229
231
  <div className="flex items-center gap-[12px]">
230
232
  {(() => {
231
- const mappedImgUrl = copy.imageMapping?.[item.type]?.url
232
- const imgUrl = hasProduct
233
+ const phsicalProduct =
234
+ item.type === ConsumeCreditsItemType.Product ||
235
+ item.type === ConsumeCreditsItemType.RedeemAndBuy
236
+ const imgUrl = phsicalProduct
233
237
  ? (item.variant?.image?.url ?? item.product?.images?.[0]?.url ?? item.image?.url)
234
- : (mappedImgUrl ?? item.image?.url)
235
- const imgAlt = hasProduct
238
+ : item.image?.url || copy.imageMapping?.[item.type]?.url
239
+ const imgAlt = phsicalProduct
236
240
  ? (item.variant?.image?.altText ?? item.product?.images?.[0]?.alt ?? item.image?.alt ?? '')
237
241
  : (item.image?.alt ?? '')
238
242
  if (!imgUrl) return null
@@ -247,11 +251,16 @@ function ConsumeCredits({ copy }: Props) {
247
251
  source={imgUrl}
248
252
  alt={imgAlt}
249
253
  className="flex size-full items-center justify-center"
250
- imgClassName={hasProduct ? 'object-cover' : 'h-full w-auto object-contain'}
254
+ imgClassName={phsicalProduct ? 'object-cover' : 'h-full w-auto object-contain'}
251
255
  />
252
- {!hasProduct && item.value && (
256
+ {item.type === ConsumeCreditsItemType.Coupon && item.value && (
253
257
  <div className="absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white">
254
- {item.value} {copy.off}
258
+ {item.value && `${item.value} ${copy.off}`}
259
+ </div>
260
+ )}
261
+ {item.type === ConsumeCreditsItemType.GiftCard && item.value && (
262
+ <div className="absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white">
263
+ {item.value && `${item.value} ${copy.giftCard || 'Gift Card'}`}
255
264
  </div>
256
265
  )}
257
266
  </div>
@@ -259,12 +268,24 @@ function ConsumeCredits({ copy }: Props) {
259
268
  })()}
260
269
  <div className="min-w-0 flex-1">
261
270
  <div className="text-[16px] font-[700] text-[#1e2024] line-clamp-2">
262
- {hasProduct && item.product?.title ? item.product.title : item.title}
271
+ {item.product.title ?? item.title ?? item.alpcData?.name}
263
272
  </div>
264
273
  <div className="mt-[4px] text-[14px] text-[#666]">
265
- {hasProduct && item.price != null
266
- ? `${numberFormat(item.alpcData.consume_credits)} ${copy.creditUnit ?? ''} + $${Number(item.price).toFixed(2)}`
267
- : `${numberFormat(item.alpcData.consume_credits)} ${copy.creditUnit ?? ''}`}
274
+ {item.type === ConsumeCreditsItemType.RedeemAndBuy ? (
275
+ <>
276
+ <div>
277
+ {numberFormat(item.alpcData.consume_credits)} {copy.creditUnit ?? ''} + $
278
+ {Number(item.price).toFixed(2)}
279
+ </div>
280
+ {item.variant?.price?.amount && (
281
+ <div className="text-[12px] text-[#999] line-through">
282
+ ${Number(item.variant.price.amount).toFixed(2)}
283
+ </div>
284
+ )}
285
+ </>
286
+ ) : (
287
+ `${numberFormat(item.alpcData.consume_credits)} ${copy.creditUnit ?? ''}`
288
+ )}
268
289
  </div>
269
290
  </div>
270
291
  <div className="relative group">
@@ -165,6 +165,7 @@ export type ConsumeCreditsopy = {
165
165
  comingSoonLabel?: string
166
166
  creditUnit?: string
167
167
  off?: string
168
+ giftCard?: string
168
169
  imageMapping?: {
169
170
  [key in ConsumeCreditsItemType]?: { url: string }
170
171
  }
@@ -198,6 +199,8 @@ export type RedeemCouponModalCopy = {
198
199
  successDesc: string
199
200
  successButton: string
200
201
  successButtonUrl?: string
202
+ copyLabel?: string
203
+ copiedLabel?: string
201
204
  }
202
205
 
203
206
  // ─── Referral Copy ───────────────────────────────────