@anker-in/campaign-ui 0.5.0-beta.7 → 0.5.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js +1 -1
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js.map +2 -2
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.js +1 -1
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.js.map +1 -1
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js +1 -1
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js.map +2 -2
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.js +1 -1
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var I=Object.create;var g=Object.defineProperty;var O=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})},k=(t,s,n,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of $(s))!z.call(t,r)&&r!==n&&g(t,r,{get:()=>s[r],enumerable:!(c=O(s,r))||c.enumerable});return t};var J=(t,s,n)=>(n=t!=null?I(q(t)):{},k(s||!t||!t.__esModule?g(n,"default",{value:t,enumerable:!0}):n,t)),K=t=>k(g({},"__esModule",{value:!0}),t);var Q={};G(Q,{default:()=>L});module.exports=K(Q);var e=require("react/jsx-runtime"),d=require("react"),i=require("@anker-in/headless-ui"),p=require("@anker-in/lib"),x=require("../../../credits/context/const"),D=require("./hooks/useRedeemCoupon"),S=J(require("../../../credits/context/hooks/useCopy")),T=require("../../../../constants");function L({onClose:t,itemTitle:s,itemCredits:n,itemImage:c,itemValue:r,itemOff:b,itemRules:C,redeemId:N,userId:h,copy:o,pointUnit:A="pts",alpcConfig:U,onError:w}){const[m,E]=(0,d.useState)(),[y,f]=(0,d.useState)(""),[_,u]=(0,d.useState)(!1),{copy:M,copied:B}=(0,S.default)(),{brand:P}=(0,p.useHeadlessContext)(),v=T.ROUNDED_BRANDS.includes(P),{isMutating:j,trigger:R}=(0,D.useRedeemCoupon)(U),F=(0,d.useCallback)(async()=>{f("");const{data:l}=await R({user_id:h,rule_id:N});if(!l){f(o.commonError);return}if(l.data?.success)E(l.data.coupon_code);else{let a=o.commonError;l.code===x.AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit?(a=o.redeemLimitError,u(!0)):l.code===x.AlpcErrorCode.CodeLpcRuleInventoryNotEnough?(a=o.inventoryNotEnough,u(!0)):l.code===x.AlpcErrorCode.CodeLpcNotEnoughCredits?(a=o.creditsNotEnough,u(!0)):l.code===x.AlpcErrorCode.CodeCrossSiteError&&(a=o.crossSiteError,u(!0)),f(a),w?.(l.code)}},[R,h,N,o,w]);(0,d.useEffect)(()=>{E(void 0),f(""),u(!1)},[N]);const H=C&&C.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:C?.map((l,a)=>(0,e.jsx)("li",{className:"list-disc",children:(0,e.jsx)(i.Text,{html:l,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,p.classNames)("relative mx-auto overflow-hidden",v?"rounded-[8px]":"rounded-none"),children:[(0,e.jsx)("img",{src:c.url,alt:c.alt??"",className:"mx-auto h-[140px] w-full object-cover"}),r&&(0,e.jsxs)("div",{className:"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white",children:[r,b?` ${b}`:""]})]})}),!m&&(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:[n," ",A]}),H]}),m&&(0,e.jsxs)("div",{className:"flex 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:m}),(0,e.jsx)("button",{className:"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none",disabled:B,onClick:()=>M(m),children:B?"Copied":"Copy"})]}),(0,e.jsx)(i.Text,{className:"text-[20px] font-[700]",html:o.successTitle}),(0,e.jsx)(i.Text,{className:"text-[14px] font-[700] text-[#6d6d6f]",html:o.successDesc}),(0,e.jsx)(i.Button,{className:(0,p.classNames)("w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]",v?"rounded-[4px]":"rounded-none"),onClick:()=>{o.successButtonUrl&&(window.location.href=o.successButtonUrl),t()},children:o.successButton})]}),!m&&(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)(i.Text,{className:"block text-[16px] font-[700] leading-[1.3]",html:o.confirmTitle}),(0,e.jsx)(i.Button,{className:(0,p.classNames)("w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]",v?"rounded-[4px]":"rounded-none"),disabled:_,loading:j,onClick:F,children:o.confirmButton})]}),y&&(0,e.jsx)(i.Text,{className:"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]",html:y})]})]})}
|
|
1
|
+
"use strict";var I=Object.create;var g=Object.defineProperty;var O=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})},k=(t,s,n,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of $(s))!z.call(t,r)&&r!==n&&g(t,r,{get:()=>s[r],enumerable:!(c=O(s,r))||c.enumerable});return t};var J=(t,s,n)=>(n=t!=null?I(q(t)):{},k(s||!t||!t.__esModule?g(n,"default",{value:t,enumerable:!0}):n,t)),K=t=>k(g({},"__esModule",{value:!0}),t);var Q={};G(Q,{default:()=>L});module.exports=K(Q);var e=require("react/jsx-runtime"),d=require("react"),i=require("@anker-in/headless-ui"),p=require("@anker-in/lib"),x=require("../../../credits/context/const"),D=require("./hooks/useRedeemCoupon"),S=J(require("../../../credits/context/hooks/useCopy")),T=require("../../../../constants");function L({onClose:t,itemTitle:s,itemCredits:n,itemImage:c,itemValue:r,itemOff:b,itemRules:C,redeemId:N,userId:h,copy:o,pointUnit:A="pts",alpcConfig:U,onError:w}){const[m,E]=(0,d.useState)(),[y,f]=(0,d.useState)(""),[_,u]=(0,d.useState)(!1),{copy:M,copied:B}=(0,S.default)(),{brand:P}=(0,p.useHeadlessContext)(),v=T.ROUNDED_BRANDS.includes(P),{isMutating:j,trigger:R}=(0,D.useRedeemCoupon)(U),F=(0,d.useCallback)(async()=>{f("");const{data:l}=await R({user_id:h,rule_id:N});if(!l){f(o.commonError);return}if(l.data?.success)E(l.data.coupon_code);else{let a=o.commonError;l.code===x.AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit?(a=o.redeemLimitError,u(!0)):l.code===x.AlpcErrorCode.CodeLpcRuleInventoryNotEnough?(a=o.inventoryNotEnough,u(!0)):l.code===x.AlpcErrorCode.CodeLpcNotEnoughCredits?(a=o.creditsNotEnough,u(!0)):l.code===x.AlpcErrorCode.CodeCrossSiteError&&(a=o.crossSiteError,u(!0)),f(a),w?.(l.code)}},[R,h,N,o,w]);(0,d.useEffect)(()=>{E(void 0),f(""),u(!1)},[N]);const H=C&&C.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:C?.map((l,a)=>(0,e.jsx)("li",{className:"list-disc",children:(0,e.jsx)(i.Text,{html:l,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,p.classNames)("relative mx-auto overflow-hidden",v?"rounded-[8px]":"rounded-none"),children:[(0,e.jsx)("img",{src:c.url,alt:c.alt??"",className:"mx-auto h-[140px] w-full object-cover"}),r&&(0,e.jsxs)("div",{className:"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white",children:[r,b?` ${b}`:""]})]})}),!m&&(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:[n," ",A]}),H]}),m&&(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:m}),(0,e.jsx)("button",{className:"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none",disabled:B,onClick:()=>M(m),children:B?"Copied":"Copy"})]}),(0,e.jsx)(i.Text,{className:"text-[20px] font-[700]",html:o.successTitle}),(0,e.jsx)(i.Text,{className:"text-[14px] font-[700] text-[#6d6d6f]",html:o.successDesc}),(0,e.jsx)(i.Button,{className:(0,p.classNames)("w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]",v?"rounded-[4px]":"rounded-none"),onClick:()=>{o.successButtonUrl&&(window.location.href=o.successButtonUrl),t()},children:o.successButton})]}),!m&&(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)(i.Text,{className:"block text-[16px] font-[700] leading-[1.3]",html:o.confirmTitle}),(0,e.jsx)(i.Button,{className:(0,p.classNames)("w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]",v?"rounded-[4px]":"rounded-none"),disabled:_,loading:j,onClick:F,children:o.confirmButton})]}),y&&(0,e.jsx)(i.Text,{className:"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]",html:y})]})]})}
|
|
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 { 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 { RedeemCouponModalCopy, AlpcConfig } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n onClose: () => void\n itemTitle: string\n itemCredits: number\n itemImage?: { url: string; alt?: string }\n itemValue?: string\n itemOff?: string\n itemRules?: string[]\n redeemId: number\n userId?: string\n copy: RedeemCouponModalCopy\n pointUnit?: string\n alpcConfig: AlpcConfig\n onError?: (code: number) => void\n}\n\nexport default function RedeemCouponPanel({\n onClose,\n itemTitle,\n itemCredits,\n itemImage,\n itemValue,\n itemOff,\n itemRules,\n redeemId,\n userId,\n copy,\n pointUnit = 'pts',\n alpcConfig,\n onError,\n}: Props) {\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(copy.commonError)\n return\n }\n if (data.data?.success) {\n setCouponCode(data.data.coupon_code)\n } else {\n let msg = copy.commonError\n if (data.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n msg = copy.redeemLimitError\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n msg = copy.inventoryNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n msg = copy.creditsNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeCrossSiteError) {\n msg = copy.crossSiteError\n setDisabled(true)\n }\n setErrorInfo(msg)\n onError?.(data.code)\n }\n }, [trigger, userId, redeemId, copy, 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 {itemOff ? ` ${itemOff}` : ''}\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 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={copy.successTitle} />\n <Text className=\"text-[14px] font-[700] text-[#6d6d6f]\" html={copy.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 (copy.successButtonUrl) window.location.href = copy.successButtonUrl\n onClose()\n }}\n >\n {copy.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={copy.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 {copy.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,EAAqD,yBACrDC,E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AMG,CAAO,CAAC,KAE7C,aAAU,IAAM,CACdE,EAAc,MAAS,EACvBE,EAAa,EAAE,EACfE,EAAY,EAAK,CACnB,EAAG,CAACX,CAAQ,CAAC,EAEb,MAAMsB,EAAevB,GAAaA,EAAU,OAAS,MACnD,OAAC,OAAI,UAAU,wFACb,mBAAC,MAAG,UAAU,oCACX,SAAAA,GAAW,IAAI,CAACwB,EAAMC,OACrB,OAAC,MAAG,UAAU,YACZ,mBAAC,QAAK,KAAMD,EAAM,UAAU,YAAY,GADXC,CAE/B,CACD,EACH,EACF,EAGF,SACE,QAAC,OAAI,UAAU,gBACZ,UAAA5B,GAAW,QACV,OAAC,OAAI,UAAU,4BACb,oBAAC,OAAI,aAAW,EAAA6B,YAAG,mCAAoCT,EAAU,gBAAkB,cAAc,EAC/F,oBAAC,OAAI,IAAKpB,EAAU,IAAK,IAAKA,EAAU,KAAO,GAAI,UAAU,wCAAwC,EACpGC,MACC,QAAC,OAAI,UAAU,oFACZ,UAAAA,EACAC,EAAU,IAAIA,CAAO,GAAK,IAC7B,GAEJ,EACF,EAGD,CAACQ,MACA,QAAC,OAAI,UAAU,+CACb,qBAAC,KAAE,UAAU,oDACV,UAAAX,EAAY,IAAEQ,GACjB,EACCmB,GACH,EAGDhB,MACC,QAAC,OAAI,UAAU,
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Text, Button } from '@anker-in/headless-ui'\nimport { 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 { RedeemCouponModalCopy, AlpcConfig } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n onClose: () => void\n itemTitle: string\n itemCredits: number\n itemImage?: { url: string; alt?: string }\n itemValue?: string\n itemOff?: string\n itemRules?: string[]\n redeemId: number\n userId?: string\n copy: RedeemCouponModalCopy\n pointUnit?: string\n alpcConfig: AlpcConfig\n onError?: (code: number) => void\n}\n\nexport default function RedeemCouponPanel({\n onClose,\n itemTitle,\n itemCredits,\n itemImage,\n itemValue,\n itemOff,\n itemRules,\n redeemId,\n userId,\n copy,\n pointUnit = 'pts',\n alpcConfig,\n onError,\n}: Props) {\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(copy.commonError)\n return\n }\n if (data.data?.success) {\n setCouponCode(data.data.coupon_code)\n } else {\n let msg = copy.commonError\n if (data.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n msg = copy.redeemLimitError\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n msg = copy.inventoryNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n msg = copy.creditsNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeCrossSiteError) {\n msg = copy.crossSiteError\n setDisabled(true)\n }\n setErrorInfo(msg)\n onError?.(data.code)\n }\n }, [trigger, userId, redeemId, copy, 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 {itemOff ? ` ${itemOff}` : ''}\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={copy.successTitle} />\n <Text className=\"text-[14px] font-[700] text-[#6d6d6f]\" html={copy.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 (copy.successButtonUrl) window.location.href = copy.successButtonUrl\n onClose()\n }}\n >\n {copy.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={copy.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 {copy.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,EAAqD,yBACrDC,EAA8B,0CAC9BC,EAAgC,mCAChCC,EAAoB,qDAEpBC,EAA+B,iCAkBhB,SAART,EAAmC,CACxC,QAAAU,EACA,UAAAC,EACA,YAAAC,EACA,UAAAC,EACA,UAAAC,EACA,QAAAC,EACA,UAAAC,EACA,SAAAC,EACA,OAAAC,EACA,KAAAC,EACA,UAAAC,EAAY,MACZ,WAAAC,EACA,QAAAC,CACF,EAAU,CACR,KAAM,CAACC,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,mBAAgBd,CAAU,EAE7De,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,EAAaP,EAAK,WAAW,EAC7B,MACF,CACA,GAAIkB,EAAK,MAAM,QACbb,EAAca,EAAK,KAAK,WAAW,MAC9B,CACL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,QAAK,UAAU,yBAA0B,SAAAA,EAAW,KACrD,OAAC,UACC,UAAU,+EACV,SAAUO,EACV,QAAS,IAAMD,EAASN,CAAU,EAEjC,SAAAO,EAAS,SAAW,OACvB,GACF,KACA,OAAC,QAAK,UAAU,yBAAyB,KAAMX,EAAK,aAAc,KAClE,OAAC,QAAK,UAAU,wCAAwC,KAAMA,EAAK,YAAa,KAChF,OAAC,UACC,aAAW,EAAAuB,YACT,kEACAT,EAAU,gBAAkB,cAC9B,EACA,QAAS,IAAM,CACTd,EAAK,mBAAkB,OAAO,SAAS,KAAOA,EAAK,kBACvDT,EAAQ,CACV,EAEC,SAAAS,EAAK,cACR,GACF,EAGD,CAACI,MACA,QAAC,OAAI,UAAU,+DACb,qBAAC,OAAI,UAAU,sCACb,oBAAC,QAAK,UAAU,6CAA6C,KAAMJ,EAAK,aAAc,KACtF,OAAC,UACC,aAAW,EAAAuB,YACT,sFACAT,EAAU,gBAAkB,cAC9B,EACA,SAAUN,EACV,QAASO,EACT,QAASE,EAER,SAAAjB,EAAK,cACR,GACF,EAECM,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", "itemTitle", "itemCredits", "itemImage", "itemValue", "itemOff", "itemRules", "redeemId", "userId", "copy", "pointUnit", "alpcConfig", "onError", "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 h=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var q=(t,s)=>{for(var a in s)h(t,a,{get:s[a],enumerable:!0})},J=(t,s,a,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of G(s))!H.call(t,o)&&o!==a&&h(t,o,{get:()=>s[o],enumerable:!(l=j(s,o))||l.enumerable});return t};var K=t=>J(h({},"__esModule",{value:!0}),t);var X={};q(X,{default:()=>W});module.exports=K(X);var r=require("react/jsx-runtime"),f=require("react"),v=require("@anker-in/headless-ui"),p=require("@anker-in/lib"),D=require("../../context/provider"),k=require("../../context/viewStack"),A=require("./hooks/useRedeemableList"),M=require("./hooks/useRedeemAndBuy"),n=require("../../type"),g=require("../../../credits/context/utils"),O=require("../../../../constants");function Q({copy:t,onClose:s}){const{profile:a,creditInfo:l,openSignUpPopup:o,alpcConfig:b}=(0,D.useMemberPopupContext)(),{pushView:y}=(0,k.useViewStack)(),{brand:U}=(0,p.useHeadlessContext)(),I=O.ROUNDED_BRANDS.includes(U),[P,R]=(0,f.useState)(""),[E,w]=(0,f.useState)(null),m=!!a,{redeemableList:_,listLoading:L}=(0,A.useRedeemableList)(b),{trigger:S}=(0,M.useRedeemAndBuy)(b),$=t.list.map(e=>e.product?.handle).filter(Boolean),{data:B}=(0,p.useProductsByHandles)({handles:$}),z=(0,f.useMemo)(()=>t.list.map(e=>{const i=_.find(c=>String(c.id)===String(e.redeemId));if(!i)return null;const d=Number(l?.available_credit??0),C=m&&!!a?.activated&&i.consume_credits>d,x=i.is_limited&&(!i.remaining_inventory||i.remaining_inventory<=0);let u,N;return(e.type===n.ConsumeCreditsItemType.RedeemAndBuy||e.type===n.ConsumeCreditsItemType.Product)&&e.product&&(u=B?.find(c=>c.handle===e.product.handle),N=u?.variants?.find(c=>c.sku===e.product.sku)??u?.variants?.[0],e.type===n.ConsumeCreditsItemType.RedeemAndBuy&&(!u||!N))?null:{...e,alpcData:i,insufficient:C,soldOut:x,product:u,variant:N}}).filter(Boolean),[t.list,_,l,a,m,B]);function F(e){return m?e.soldOut?t.soldOut:t.btnRedeem:t.unlockRewards}function T(e){return e.type===n.ConsumeCreditsItemType.GiftCard||e.type===n.ConsumeCreditsItemType.Product?e.insufficient:e.soldOut||e.insufficient}async function V(e){if(!m){o();return}if(!a?.activated){y({type:n.MemberPopupPanelType.Activate});return}if(e.type===n.ConsumeCreditsItemType.GiftCard||e.type===n.ConsumeCreditsItemType.Product){t.creditsPage?.url&&window.open(t.creditsPage.url,"_blank","noopener,noreferrer");return}if(e.type===n.ConsumeCreditsItemType.Coupon)y({type:n.MemberPopupPanelType.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,itemOff:t.off,itemRules:e.rules,redeemId:Number(e.redeemId),userId:a?.user_id,alpcConfig:b}});else{R(""),w(e.redeemId);try{await S({productVariant:e.variant,redeemId:Number(e.redeemId),userId:a?.user_id})}catch(i){R(i?.message??t.redeemModal.commonError)}finally{w(null)}}}return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"flex flex-1 flex-col gap-[12px]",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-[8px]",children:[t.title&&(0,r.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:t.title}),t.subtitle&&(0,r.jsx)("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:t.subtitle})]}),t.insufficientCredits&&l&&(0,r.jsxs)("div",{className:"text-[14px] font-[700] text-[#1d1d1f]",children:[t.insufficientCredits,": ",(0,g.numberFormat)(l.available_credit)," ",t.pointUnit]}),P&&(0,r.jsx)("div",{className:"text-[14px] font-[700] text-[#f84d4f]",children:P}),L?(0,r.jsx)("div",{className:"flex flex-1 items-center justify-center py-[32px]",children:(0,r.jsx)("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}):(0,r.jsx)("div",{className:"flex flex-col",children:z.map((e,i)=>{const d=!!e.product;return(0,r.jsxs)("div",{className:"relative py-[16px]",children:[i>0&&(0,r.jsx)("div",{className:"absolute inset-x-0 top-0 h-px bg-[#dadce0]"}),(0,r.jsxs)("div",{className:"flex items-center gap-[12px]",children:[(()=>{const C=t.imageMapping?.[e.type]?.url,x=d?e.variant?.image?.url??e.product?.images?.[0]?.url??e.image?.url:C??e.image?.url,u=d?e.variant?.image?.altText??e.product?.images?.[0]?.alt??e.image?.alt??"":e.image?.alt??"";return x?(0,r.jsxs)("div",{className:(0,p.classNames)("relative size-[64px] shrink-0 overflow-hidden",I?"rounded-[4px]":"rounded-none"),children:[(0,r.jsx)(v.Picture,{source:x,alt:u,className:"flex size-full items-center justify-center",imgClassName:d?"object-cover":"h-full w-auto object-contain"}),!d&&e.value&&(0,r.jsxs)("div",{className:"absolute bottom-[
|
|
1
|
+
"use strict";var h=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var H=Object.prototype.hasOwnProperty;var q=(t,s)=>{for(var a in s)h(t,a,{get:s[a],enumerable:!0})},J=(t,s,a,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of G(s))!H.call(t,o)&&o!==a&&h(t,o,{get:()=>s[o],enumerable:!(l=j(s,o))||l.enumerable});return t};var K=t=>J(h({},"__esModule",{value:!0}),t);var X={};q(X,{default:()=>W});module.exports=K(X);var r=require("react/jsx-runtime"),f=require("react"),v=require("@anker-in/headless-ui"),p=require("@anker-in/lib"),D=require("../../context/provider"),k=require("../../context/viewStack"),A=require("./hooks/useRedeemableList"),M=require("./hooks/useRedeemAndBuy"),n=require("../../type"),g=require("../../../credits/context/utils"),O=require("../../../../constants");function Q({copy:t,onClose:s}){const{profile:a,creditInfo:l,openSignUpPopup:o,alpcConfig:b}=(0,D.useMemberPopupContext)(),{pushView:y}=(0,k.useViewStack)(),{brand:U}=(0,p.useHeadlessContext)(),I=O.ROUNDED_BRANDS.includes(U),[P,R]=(0,f.useState)(""),[E,w]=(0,f.useState)(null),m=!!a,{redeemableList:_,listLoading:L}=(0,A.useRedeemableList)(b),{trigger:S}=(0,M.useRedeemAndBuy)(b),$=t.list.map(e=>e.product?.handle).filter(Boolean),{data:B}=(0,p.useProductsByHandles)({handles:$}),z=(0,f.useMemo)(()=>t.list.map(e=>{const i=_.find(c=>String(c.id)===String(e.redeemId));if(!i)return null;const d=Number(l?.available_credit??0),C=m&&!!a?.activated&&i.consume_credits>d,x=i.is_limited&&(!i.remaining_inventory||i.remaining_inventory<=0);let u,N;return(e.type===n.ConsumeCreditsItemType.RedeemAndBuy||e.type===n.ConsumeCreditsItemType.Product)&&e.product&&(u=B?.find(c=>c.handle===e.product.handle),N=u?.variants?.find(c=>c.sku===e.product.sku)??u?.variants?.[0],e.type===n.ConsumeCreditsItemType.RedeemAndBuy&&(!u||!N))?null:{...e,alpcData:i,insufficient:C,soldOut:x,product:u,variant:N}}).filter(Boolean),[t.list,_,l,a,m,B]);function F(e){return m?e.soldOut?t.soldOut:t.btnRedeem:t.unlockRewards}function T(e){return e.type===n.ConsumeCreditsItemType.GiftCard||e.type===n.ConsumeCreditsItemType.Product?e.insufficient:e.soldOut||e.insufficient}async function V(e){if(!m){o();return}if(!a?.activated){y({type:n.MemberPopupPanelType.Activate});return}if(e.type===n.ConsumeCreditsItemType.GiftCard||e.type===n.ConsumeCreditsItemType.Product){t.creditsPage?.url&&window.open(t.creditsPage.url,"_blank","noopener,noreferrer");return}if(e.type===n.ConsumeCreditsItemType.Coupon)y({type:n.MemberPopupPanelType.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,itemOff:t.off,itemRules:e.rules,redeemId:Number(e.redeemId),userId:a?.user_id,alpcConfig:b}});else{R(""),w(e.redeemId);try{await S({productVariant:e.variant,redeemId:Number(e.redeemId),userId:a?.user_id})}catch(i){R(i?.message??t.redeemModal.commonError)}finally{w(null)}}}return(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"flex flex-1 flex-col gap-[12px]",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-[8px]",children:[t.title&&(0,r.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:t.title}),t.subtitle&&(0,r.jsx)("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:t.subtitle})]}),t.insufficientCredits&&l&&(0,r.jsxs)("div",{className:"text-[14px] font-[700] text-[#1d1d1f]",children:[t.insufficientCredits,": ",(0,g.numberFormat)(l.available_credit)," ",t.pointUnit]}),P&&(0,r.jsx)("div",{className:"text-[14px] font-[700] text-[#f84d4f]",children:P}),L?(0,r.jsx)("div",{className:"flex flex-1 items-center justify-center py-[32px]",children:(0,r.jsx)("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}):(0,r.jsx)("div",{className:"flex flex-col",children:z.map((e,i)=>{const d=!!e.product;return(0,r.jsxs)("div",{className:"relative py-[16px]",children:[i>0&&(0,r.jsx)("div",{className:"absolute inset-x-0 top-0 h-px bg-[#dadce0]"}),(0,r.jsxs)("div",{className:"flex items-center gap-[12px]",children:[(()=>{const C=t.imageMapping?.[e.type]?.url,x=d?e.variant?.image?.url??e.product?.images?.[0]?.url??e.image?.url:C??e.image?.url,u=d?e.variant?.image?.altText??e.product?.images?.[0]?.alt??e.image?.alt??"":e.image?.alt??"";return x?(0,r.jsxs)("div",{className:(0,p.classNames)("relative size-[64px] shrink-0 overflow-hidden",I?"rounded-[4px]":"rounded-none"),children:[(0,r.jsx)(v.Picture,{source:x,alt:u,className:"flex size-full items-center justify-center",imgClassName:d?"object-cover":"h-full w-auto object-contain"}),!d&&e.value&&(0,r.jsxs)("div",{className:"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white",children:[e.value," ",t.off]})]}):null})(),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:"text-[16px] font-[700] text-[#1e2024] line-clamp-2",children:d&&e.product?.title?e.product.title:e.title}),(0,r.jsx)("div",{className:"mt-[4px] text-[14px] text-[#666]",children:d&&e.price!=null?`${(0,g.numberFormat)(e.alpcData.consume_credits)} ${t.pointUnit??""} + $${Number(e.price).toFixed(2)}`:`${(0,g.numberFormat)(e.alpcData.consume_credits)} ${t.pointUnit??""}`})]}),(0,r.jsxs)("div",{className:"relative group",children:[(0,r.jsx)(v.Button,{className:(0,p.classNames)("bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",I?"rounded-[4px]":"rounded-none"),disabled:T(e),loading:E===e.redeemId,onClick:()=>V(e),children:F(e)}),e.insufficient&&(0,r.jsx)("div",{className:"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block",children:(0,r.jsxs)("div",{className:"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow",children:[(0,r.jsx)("p",{className:"text-pretty tracking-[-0.02em] text-[14px]",children:t.insufficientCredits}),(0,r.jsx)("div",{className:"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]"})]})})]})]})]},i)})}),t.creditsPage?.url&&(0,r.jsx)("a",{href:t.creditsPage.url,target:"_blank",rel:"noopener noreferrer",className:"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline",children:t.creditsPage.label??"Go to Credits Page"})]})})}var W=Q;
|
|
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 { useMemo, useState } from 'react'\nimport { Picture, Button } from '@anker-in/headless-ui'\nimport { 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 product?: any\n variant?: any\n}\n\ntype Props = {\n copy: ConsumeCreditsopy\n onClose: () => void\n}\n\nfunction ConsumeCredits({ copy, onClose }: Props) {\n const { profile, creditInfo, openSignUpPopup, alpcConfig } = 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 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 = isLogin && !!profile?.activated && alpcData.consume_credits > availableCredit\n const soldOut = alpcData.is_limited && (!alpcData.remaining_inventory || alpcData.remaining_inventory <= 0)\n\n let product\n let variant\n if (\n (item.type === ConsumeCreditsItemType.RedeemAndBuy ||\n item.type === ConsumeCreditsItemType.Product) &&\n item.product\n ) {\n product = products?.find((p: any) => p.handle === item.product!.handle)\n variant = product?.variants?.find((v: any) => v.sku === item.product!.sku) ?? product?.variants?.[0]\n if (item.type === ConsumeCreditsItemType.RedeemAndBuy && (!product || !variant)) return null\n }\n\n return { ...item, alpcData, insufficient, soldOut, product, variant }\n })\n .filter(Boolean) as EnrichedItem[]\n }, [copy.list, redeemableList, creditInfo, profile, isLogin, products])\n\n function getButtonLabel(item: (typeof list)[number]) {\n if (!isLogin) return copy.unlockRewards\n if (item.soldOut) return copy.soldOut\n return copy.btnRedeem\n }\n\n function isDisabled(item: (typeof list)[number]) {\n if (\n item.type === ConsumeCreditsItemType.GiftCard ||\n item.type === ConsumeCreditsItemType.Product\n ) {\n return item.insufficient\n }\n return item.soldOut || item.insufficient\n }\n\n async function handleRedeem(item: (typeof list)[number]) {\n if (!isLogin) {\n openSignUpPopup()\n return\n }\n if (!profile?.activated) {\n pushView({ type: MemberPopupPanelType.Activate })\n return\n }\n if (\n item.type === ConsumeCreditsItemType.GiftCard ||\n item.type === ConsumeCreditsItemType.Product\n ) {\n if (copy.creditsPage?.url) {\n window.open(copy.creditsPage.url, '_blank', 'noopener,noreferrer')\n }\n return\n }\n if (item.type === ConsumeCreditsItemType.Coupon) {\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 itemOff: copy.off,\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 try {\n await redeemAndBuy({\n productVariant: item.variant,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\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 gap-[12px]\">\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 && <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>}\n </div>\n\n {copy.insufficientCredits && creditInfo && (\n <div className=\"text-[14px] font-[700] text-[#1d1d1f]\">\n {copy.insufficientCredits}: {numberFormat(creditInfo.available_credit)} {copy.pointUnit}\n </div>\n )}\n {redeemAndBuyError && <div className=\"text-[14px] 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 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 className={cn('relative size-[64px] shrink-0 overflow-hidden', rounded ? 'rounded-[4px]' : 'rounded-none')}>\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-[20px] left-[4px] text-[14px] 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\n ? item.product.title\n : 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.pointUnit ?? ''} + $${Number(item.price).toFixed(2)}`\n : `${numberFormat(item.alpcData.consume_credits)} ${copy.pointUnit ?? ''}`}\n </div>\n </div>\n <div className=\"relative group\">\n <Button\n className={cn('bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white', rounded ? 'rounded-[4px]' : 'rounded-none')}\n disabled={isDisabled(item)}\n loading={loadingId === item.redeemId}\n onClick={() => handleRedeem(item)}\n >\n {getButtonLabel(item)}\n </Button>\n {item.insufficient && (\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={copy.creditsPage.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline\"\n >\n {copy.creditsPage.label ?? 'Go to Credits Page'}\n </a>\n )}\n </div>\n </>\n )\n}\n\nexport default ConsumeCredits\n"],
|
|
4
|
+
"sourcesContent": ["import { useMemo, useState } from 'react'\nimport { Picture, Button } from '@anker-in/headless-ui'\nimport { 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 product?: any\n variant?: any\n}\n\ntype Props = {\n copy: ConsumeCreditsopy\n onClose: () => void\n}\n\nfunction ConsumeCredits({ copy, onClose }: Props) {\n const { profile, creditInfo, openSignUpPopup, alpcConfig } = 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 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 = isLogin && !!profile?.activated && alpcData.consume_credits > availableCredit\n const soldOut = alpcData.is_limited && (!alpcData.remaining_inventory || alpcData.remaining_inventory <= 0)\n\n let product\n let variant\n if (\n (item.type === ConsumeCreditsItemType.RedeemAndBuy ||\n item.type === ConsumeCreditsItemType.Product) &&\n item.product\n ) {\n product = products?.find((p: any) => p.handle === item.product!.handle)\n variant = product?.variants?.find((v: any) => v.sku === item.product!.sku) ?? product?.variants?.[0]\n if (item.type === ConsumeCreditsItemType.RedeemAndBuy && (!product || !variant)) return null\n }\n\n return { ...item, alpcData, insufficient, soldOut, product, variant }\n })\n .filter(Boolean) as EnrichedItem[]\n }, [copy.list, redeemableList, creditInfo, profile, isLogin, products])\n\n function getButtonLabel(item: (typeof list)[number]) {\n if (!isLogin) return copy.unlockRewards\n if (item.soldOut) return copy.soldOut\n return copy.btnRedeem\n }\n\n function isDisabled(item: (typeof list)[number]) {\n if (\n item.type === ConsumeCreditsItemType.GiftCard ||\n item.type === ConsumeCreditsItemType.Product\n ) {\n return item.insufficient\n }\n return item.soldOut || item.insufficient\n }\n\n async function handleRedeem(item: (typeof list)[number]) {\n if (!isLogin) {\n openSignUpPopup()\n return\n }\n if (!profile?.activated) {\n pushView({ type: MemberPopupPanelType.Activate })\n return\n }\n if (\n item.type === ConsumeCreditsItemType.GiftCard ||\n item.type === ConsumeCreditsItemType.Product\n ) {\n if (copy.creditsPage?.url) {\n window.open(copy.creditsPage.url, '_blank', 'noopener,noreferrer')\n }\n return\n }\n if (item.type === ConsumeCreditsItemType.Coupon) {\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 itemOff: copy.off,\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 try {\n await redeemAndBuy({\n productVariant: item.variant,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\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 gap-[12px]\">\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 && <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>}\n </div>\n\n {copy.insufficientCredits && creditInfo && (\n <div className=\"text-[14px] font-[700] text-[#1d1d1f]\">\n {copy.insufficientCredits}: {numberFormat(creditInfo.available_credit)} {copy.pointUnit}\n </div>\n )}\n {redeemAndBuyError && <div className=\"text-[14px] 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 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 className={cn('relative size-[64px] shrink-0 overflow-hidden', rounded ? 'rounded-[4px]' : 'rounded-none')}>\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\n ? item.product.title\n : 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.pointUnit ?? ''} + $${Number(item.price).toFixed(2)}`\n : `${numberFormat(item.alpcData.consume_credits)} ${copy.pointUnit ?? ''}`}\n </div>\n </div>\n <div className=\"relative group\">\n <Button\n className={cn('bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white', rounded ? 'rounded-[4px]' : 'rounded-none')}\n disabled={isDisabled(item)}\n loading={loadingId === item.redeemId}\n onClick={() => handleRedeem(item)}\n >\n {getButtonLabel(item)}\n </Button>\n {item.insufficient && (\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={copy.creditsPage.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline\"\n >\n {copy.creditsPage.label ?? 'Go to Credits Page'}\n </a>\n )}\n </div>\n </>\n )\n}\n\nexport default ConsumeCredits\n"],
|
|
5
5
|
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GA8II,IAAAI,EAAA,6BA9IJC,EAAkC,iBAClCC,EAAgC,iCAChCC,EAA2E,yBAC3EC,EAAsC,kCACtCC,EAA6B,mCAC7BC,EAAkC,qCAClCC,EAAgC,mCAChCC,EAKO,sBACPC,EAA6B,0CAE7BC,EAA+B,iCAe/B,SAASC,EAAe,CAAE,KAAAC,EAAM,QAAAC,CAAQ,EAAU,CAChD,KAAM,CAAE,QAAAC,E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|
|
6
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", "onClose", "profile", "creditInfo", "openSignUpPopup", "alpcConfig", "pushView", "brand", "rounded", "redeemAndBuyError", "setRedeemAndBuyError", "loadingId", "setLoadingId", "isLogin", "redeemableList", "listLoading", "redeemAndBuy", "handles", "item", "products", "list", "alpcData", "r", "availableCredit", "insufficient", "soldOut", "product", "variant", "p", "v", "getButtonLabel", "isDisabled", "handleRedeem", "e", "idx", "hasProduct", "mappedImgUrl", "imgUrl", "imgAlt", "cn"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as t,jsxs as s}from"react/jsx-runtime";import{useCallback as M,useEffect as P,useState as x}from"react";import{Text as r,Button as y}from"@anker-in/headless-ui";import{useHeadlessContext as j,classNames as f}from"@anker-in/lib";import{AlpcErrorCode as a}from"../../../credits/context/const";import{useRedeemCoupon as F}from"./hooks/useRedeemCoupon";import H from"../../../credits/context/hooks/useCopy";import{ROUNDED_BRANDS as I}from"../../../../constants";function O({onClose:B,itemTitle:$,itemCredits:R,itemImage:c,itemValue:g,itemOff:C,itemRules:p,redeemId:m,userId:N,copy:e,pointUnit:k="pts",alpcConfig:D,onError:v}){const[l,b]=x(),[h,d]=x(""),[S,i]=x(!1),{copy:T,copied:w}=H(),{brand:L}=j(),u=I.includes(L),{isMutating:A,trigger:E}=F(D),U=M(async()=>{d("");const{data:o}=await E({user_id:N,rule_id:m});if(!o){d(e.commonError);return}if(o.data?.success)b(o.data.coupon_code);else{let n=e.commonError;o.code===a.CodeLpcShopifyCouponRuleRedeemLimit?(n=e.redeemLimitError,i(!0)):o.code===a.CodeLpcRuleInventoryNotEnough?(n=e.inventoryNotEnough,i(!0)):o.code===a.CodeLpcNotEnoughCredits?(n=e.creditsNotEnough,i(!0)):o.code===a.CodeCrossSiteError&&(n=e.crossSiteError,i(!0)),d(n),v?.(o.code)}},[E,N,m,e,v]);P(()=>{b(void 0),d(""),i(!1)},[m]);const _=p&&p.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:p?.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:f("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"}),g&&s("div",{className:"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white",children:[g,C?` ${C}`:""]})]})}),!l&&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:[R," ",k]}),_]}),l&&s("div",{className:"flex 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:l}),t("button",{className:"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none",disabled:w,onClick:()=>T(l),children:w?"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(y,{className:f("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),B()},children:e.successButton})]}),!l&&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(y,{className:f("w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]",u?"rounded-[4px]":"rounded-none"),disabled:S,loading:A,onClick:U,children:e.confirmButton})]}),h&&t(r,{className:"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]",html:h})]})]})}export{O as default};
|
|
1
|
+
import{jsx as t,jsxs as s}from"react/jsx-runtime";import{useCallback as M,useEffect as P,useState as x}from"react";import{Text as r,Button as y}from"@anker-in/headless-ui";import{useHeadlessContext as j,classNames as f}from"@anker-in/lib";import{AlpcErrorCode as a}from"../../../credits/context/const";import{useRedeemCoupon as F}from"./hooks/useRedeemCoupon";import H from"../../../credits/context/hooks/useCopy";import{ROUNDED_BRANDS as I}from"../../../../constants";function O({onClose:B,itemTitle:$,itemCredits:R,itemImage:c,itemValue:g,itemOff:C,itemRules:p,redeemId:m,userId:N,copy:e,pointUnit:k="pts",alpcConfig:D,onError:v}){const[l,b]=x(),[h,d]=x(""),[S,i]=x(!1),{copy:T,copied:w}=H(),{brand:L}=j(),u=I.includes(L),{isMutating:A,trigger:E}=F(D),U=M(async()=>{d("");const{data:o}=await E({user_id:N,rule_id:m});if(!o){d(e.commonError);return}if(o.data?.success)b(o.data.coupon_code);else{let n=e.commonError;o.code===a.CodeLpcShopifyCouponRuleRedeemLimit?(n=e.redeemLimitError,i(!0)):o.code===a.CodeLpcRuleInventoryNotEnough?(n=e.inventoryNotEnough,i(!0)):o.code===a.CodeLpcNotEnoughCredits?(n=e.creditsNotEnough,i(!0)):o.code===a.CodeCrossSiteError&&(n=e.crossSiteError,i(!0)),d(n),v?.(o.code)}},[E,N,m,e,v]);P(()=>{b(void 0),d(""),i(!1)},[m]);const _=p&&p.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:p?.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:f("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"}),g&&s("div",{className:"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white",children:[g,C?` ${C}`:""]})]})}),!l&&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:[R," ",k]}),_]}),l&&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:l}),t("button",{className:"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none",disabled:w,onClick:()=>T(l),children:w?"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(y,{className:f("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),B()},children:e.successButton})]}),!l&&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(y,{className:f("w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]",u?"rounded-[4px]":"rounded-none"),disabled:S,loading:A,onClick:U,children:e.confirmButton})]}),h&&t(r,{className:"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]",html:h})]})]})}export{O 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 { 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 { RedeemCouponModalCopy, AlpcConfig } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n onClose: () => void\n itemTitle: string\n itemCredits: number\n itemImage?: { url: string; alt?: string }\n itemValue?: string\n itemOff?: string\n itemRules?: string[]\n redeemId: number\n userId?: string\n copy: RedeemCouponModalCopy\n pointUnit?: string\n alpcConfig: AlpcConfig\n onError?: (code: number) => void\n}\n\nexport default function RedeemCouponPanel({\n onClose,\n itemTitle,\n itemCredits,\n itemImage,\n itemValue,\n itemOff,\n itemRules,\n redeemId,\n userId,\n copy,\n pointUnit = 'pts',\n alpcConfig,\n onError,\n}: Props) {\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(copy.commonError)\n return\n }\n if (data.data?.success) {\n setCouponCode(data.data.coupon_code)\n } else {\n let msg = copy.commonError\n if (data.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n msg = copy.redeemLimitError\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n msg = copy.inventoryNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n msg = copy.creditsNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeCrossSiteError) {\n msg = copy.crossSiteError\n setDisabled(true)\n }\n setErrorInfo(msg)\n onError?.(data.code)\n }\n }, [trigger, userId, redeemId, copy, 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 {itemOff ? ` ${itemOff}` : ''}\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 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={copy.successTitle} />\n <Text className=\"text-[14px] font-[700] text-[#6d6d6f]\" html={copy.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 (copy.successButtonUrl) window.location.href = copy.successButtonUrl\n onClose()\n }}\n >\n {copy.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={copy.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 {copy.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,sBAAAC,EAAoB,cAAcC,MAAU,gBACrD,OAAS,iBAAAC,MAAqB,iCAC9B,OAAS,mBAAAC,MAAuB,0BAChC,OAAOC,MAAa,yCAEpB,OAAS,kBAAAC,MAAsB,wBAkBhB,SAARC,EAAmC,CACxC,QAAAC,EACA,UAAAC,EACA,YAAAC,EACA,UAAAC,EACA,UAAAC,EACA,QAAAC,EACA,UAAAC,EACA,SAAAC,EACA,OAAAC,EACA,KAAAC,EACA,UAAAC,EAAY,MACZ,WAAAC,EACA,QAAAC,CACF,EAAU,CACR,KAAM,CAACC,EAAYC,CAAa,EAAI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AACuB,EAAMC,IACrB5C,EAAC,MAAG,UAAU,YACZ,SAAAA,EAACK,EAAA,CAAK,KAAMsC,EAAM,UAAU,YAAY,GADXC,CAE/B,CACD,EACH,EACF,EAGF,OACE3C,EAAC,OAAI,UAAU,gBACZ,UAAAgB,GAAW,KACVjB,EAAC,OAAI,UAAU,4BACb,SAAAC,EAAC,OAAI,UAAWO,EAAG,mCAAoC4B,EAAU,gBAAkB,cAAc,EAC/F,UAAApC,EAAC,OAAI,IAAKiB,EAAU,IAAK,IAAKA,EAAU,KAAO,GAAI,UAAU,wCAAwC,EACpGC,GACCjB,EAAC,OAAI,UAAU,oFACZ,UAAAiB,EACAC,EAAU,IAAIA,CAAO,GAAK,IAC7B,GAEJ,EACF,EAGD,CAACQ,GACA1B,EAAC,OAAI,UAAU,+CACb,UAAAA,EAAC,KAAE,UAAU,oDACV,UAAAe,EAAY,IAAEQ,GACjB,EACCkB,GACH,EAGDf,GACC1B,EAAC,OAAI,UAAU,
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Text, Button } from '@anker-in/headless-ui'\nimport { 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 { RedeemCouponModalCopy, AlpcConfig } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n onClose: () => void\n itemTitle: string\n itemCredits: number\n itemImage?: { url: string; alt?: string }\n itemValue?: string\n itemOff?: string\n itemRules?: string[]\n redeemId: number\n userId?: string\n copy: RedeemCouponModalCopy\n pointUnit?: string\n alpcConfig: AlpcConfig\n onError?: (code: number) => void\n}\n\nexport default function RedeemCouponPanel({\n onClose,\n itemTitle,\n itemCredits,\n itemImage,\n itemValue,\n itemOff,\n itemRules,\n redeemId,\n userId,\n copy,\n pointUnit = 'pts',\n alpcConfig,\n onError,\n}: Props) {\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(copy.commonError)\n return\n }\n if (data.data?.success) {\n setCouponCode(data.data.coupon_code)\n } else {\n let msg = copy.commonError\n if (data.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n msg = copy.redeemLimitError\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n msg = copy.inventoryNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n msg = copy.creditsNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeCrossSiteError) {\n msg = copy.crossSiteError\n setDisabled(true)\n }\n setErrorInfo(msg)\n onError?.(data.code)\n }\n }, [trigger, userId, redeemId, copy, 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 {itemOff ? ` ${itemOff}` : ''}\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={copy.successTitle} />\n <Text className=\"text-[14px] font-[700] text-[#6d6d6f]\" html={copy.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 (copy.successButtonUrl) window.location.href = copy.successButtonUrl\n onClose()\n }}\n >\n {copy.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={copy.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 {copy.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 )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SAAA2B,EAAW,EACrD3B,EAAC,UACC,UAAU,+EACV,SAAUkC,EACV,QAAS,IAAMD,EAASN,CAAU,EAEjC,SAAAO,EAAS,SAAW,OACvB,GACF,EACAlC,EAACK,EAAA,CAAK,UAAU,yBAAyB,KAAMkB,EAAK,aAAc,EAClEvB,EAACK,EAAA,CAAK,UAAU,wCAAwC,KAAMkB,EAAK,YAAa,EAChFvB,EAACM,EAAA,CACC,UAAWE,EACT,kEACA4B,EAAU,gBAAkB,cAC9B,EACA,QAAS,IAAM,CACTb,EAAK,mBAAkB,OAAO,SAAS,KAAOA,EAAK,kBACvDT,EAAQ,CACV,EAEC,SAAAS,EAAK,cACR,GACF,EAGD,CAACI,GACA1B,EAAC,OAAI,UAAU,+DACb,UAAAA,EAAC,OAAI,UAAU,sCACb,UAAAD,EAACK,EAAA,CAAK,UAAU,6CAA6C,KAAMkB,EAAK,aAAc,EACtFvB,EAACM,EAAA,CACC,UAAWE,EACT,sFACA4B,EAAU,gBAAkB,cAC9B,EACA,SAAUL,EACV,QAASM,EACT,QAASE,EAER,SAAAhB,EAAK,cACR,GACF,EAECM,GACC7B,EAACK,EAAA,CAAK,UAAU,6DAA6D,KAAMwB,EAAW,GAElG,GAEJ,CAEJ",
|
|
6
6
|
"names": ["jsx", "jsxs", "useCallback", "useEffect", "useState", "Text", "Button", "useHeadlessContext", "cn", "AlpcErrorCode", "useRedeemCoupon", "useCopy", "ROUNDED_BRANDS", "RedeemCouponPanel", "onClose", "itemTitle", "itemCredits", "itemImage", "itemValue", "itemOff", "itemRules", "redeemId", "userId", "copy", "pointUnit", "alpcConfig", "onError", "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 K,jsx as r,jsxs as a}from"react/jsx-runtime";import{useMemo as S,useState as P}from"react";import{Picture as $,Button as z}from"@anker-in/headless-ui";import{classNames as R,useProductsByHandles as F,useHeadlessContext as T}from"@anker-in/lib";import{useMemberPopupContext as V}from"../../context/provider";import{useViewStack as j}from"../../context/viewStack";import{useRedeemableList as G}from"./hooks/useRedeemableList";import{useRedeemAndBuy as H}from"./hooks/useRedeemAndBuy";import{ConsumeCreditsItemType as s,MemberPopupPanelType as w}from"../../type";import{numberFormat as g}from"../../../credits/context/utils";import{ROUNDED_BRANDS as q}from"../../../../constants";function J({copy:t,onClose:Q}){const{profile:l,creditInfo:u,openSignUpPopup:_,alpcConfig:f}=V(),{pushView:v}=j(),{brand:B}=T(),b=q.includes(B),[C,N]=P(""),[D,h]=P(null),p=!!l,{redeemableList:y,listLoading:k}=G(f),{trigger:A}=H(f),M=t.list.map(e=>e.product?.handle).filter(Boolean),{data:I}=F({handles:M}),O=S(()=>t.list.map(e=>{const n=y.find(o=>String(o.id)===String(e.redeemId));if(!n)return null;const i=Number(u?.available_credit??0),m=p&&!!l?.activated&&n.consume_credits>i,c=n.is_limited&&(!n.remaining_inventory||n.remaining_inventory<=0);let d,x;return(e.type===s.RedeemAndBuy||e.type===s.Product)&&e.product&&(d=I?.find(o=>o.handle===e.product.handle),x=d?.variants?.find(o=>o.sku===e.product.sku)??d?.variants?.[0],e.type===s.RedeemAndBuy&&(!d||!x))?null:{...e,alpcData:n,insufficient:m,soldOut:c,product:d,variant:x}}).filter(Boolean),[t.list,y,u,l,p,I]);function U(e){return p?e.soldOut?t.soldOut:t.btnRedeem:t.unlockRewards}function E(e){return e.type===s.GiftCard||e.type===s.Product?e.insufficient:e.soldOut||e.insufficient}async function L(e){if(!p){_();return}if(!l?.activated){v({type:w.Activate});return}if(e.type===s.GiftCard||e.type===s.Product){t.creditsPage?.url&&window.open(t.creditsPage.url,"_blank","noopener,noreferrer");return}if(e.type===s.Coupon)v({type:w.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,itemOff:t.off,itemRules:e.rules,redeemId:Number(e.redeemId),userId:l?.user_id,alpcConfig:f}});else{N(""),h(e.redeemId);try{await A({productVariant:e.variant,redeemId:Number(e.redeemId),userId:l?.user_id})}catch(n){N(n?.message??t.redeemModal.commonError)}finally{h(null)}}}return r(K,{children:a("div",{className:"flex flex-1 flex-col gap-[12px]",children:[a("div",{className:"flex flex-col gap-[8px]",children:[t.title&&r("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:t.title}),t.subtitle&&r("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:t.subtitle})]}),t.insufficientCredits&&u&&a("div",{className:"text-[14px] font-[700] text-[#1d1d1f]",children:[t.insufficientCredits,": ",g(u.available_credit)," ",t.pointUnit]}),C&&r("div",{className:"text-[14px] font-[700] text-[#f84d4f]",children:C}),k?r("div",{className:"flex flex-1 items-center justify-center py-[32px]",children:r("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}):r("div",{className:"flex flex-col",children:O.map((e,n)=>{const i=!!e.product;return a("div",{className:"relative py-[16px]",children:[n>0&&r("div",{className:"absolute inset-x-0 top-0 h-px bg-[#dadce0]"}),a("div",{className:"flex items-center gap-[12px]",children:[(()=>{const m=t.imageMapping?.[e.type]?.url,c=i?e.variant?.image?.url??e.product?.images?.[0]?.url??e.image?.url:m??e.image?.url,d=i?e.variant?.image?.altText??e.product?.images?.[0]?.alt??e.image?.alt??"":e.image?.alt??"";return c?a("div",{className:R("relative size-[64px] shrink-0 overflow-hidden",b?"rounded-[4px]":"rounded-none"),children:[r($,{source:c,alt:d,className:"flex size-full items-center justify-center",imgClassName:i?"object-cover":"h-full w-auto object-contain"}),!i&&e.value&&a("div",{className:"absolute bottom-[
|
|
1
|
+
import{Fragment as K,jsx as r,jsxs as a}from"react/jsx-runtime";import{useMemo as S,useState as P}from"react";import{Picture as $,Button as z}from"@anker-in/headless-ui";import{classNames as R,useProductsByHandles as F,useHeadlessContext as T}from"@anker-in/lib";import{useMemberPopupContext as V}from"../../context/provider";import{useViewStack as j}from"../../context/viewStack";import{useRedeemableList as G}from"./hooks/useRedeemableList";import{useRedeemAndBuy as H}from"./hooks/useRedeemAndBuy";import{ConsumeCreditsItemType as s,MemberPopupPanelType as w}from"../../type";import{numberFormat as g}from"../../../credits/context/utils";import{ROUNDED_BRANDS as q}from"../../../../constants";function J({copy:t,onClose:Q}){const{profile:l,creditInfo:u,openSignUpPopup:_,alpcConfig:f}=V(),{pushView:v}=j(),{brand:B}=T(),b=q.includes(B),[C,N]=P(""),[D,h]=P(null),p=!!l,{redeemableList:y,listLoading:k}=G(f),{trigger:A}=H(f),M=t.list.map(e=>e.product?.handle).filter(Boolean),{data:I}=F({handles:M}),O=S(()=>t.list.map(e=>{const n=y.find(o=>String(o.id)===String(e.redeemId));if(!n)return null;const i=Number(u?.available_credit??0),m=p&&!!l?.activated&&n.consume_credits>i,c=n.is_limited&&(!n.remaining_inventory||n.remaining_inventory<=0);let d,x;return(e.type===s.RedeemAndBuy||e.type===s.Product)&&e.product&&(d=I?.find(o=>o.handle===e.product.handle),x=d?.variants?.find(o=>o.sku===e.product.sku)??d?.variants?.[0],e.type===s.RedeemAndBuy&&(!d||!x))?null:{...e,alpcData:n,insufficient:m,soldOut:c,product:d,variant:x}}).filter(Boolean),[t.list,y,u,l,p,I]);function U(e){return p?e.soldOut?t.soldOut:t.btnRedeem:t.unlockRewards}function E(e){return e.type===s.GiftCard||e.type===s.Product?e.insufficient:e.soldOut||e.insufficient}async function L(e){if(!p){_();return}if(!l?.activated){v({type:w.Activate});return}if(e.type===s.GiftCard||e.type===s.Product){t.creditsPage?.url&&window.open(t.creditsPage.url,"_blank","noopener,noreferrer");return}if(e.type===s.Coupon)v({type:w.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,itemOff:t.off,itemRules:e.rules,redeemId:Number(e.redeemId),userId:l?.user_id,alpcConfig:f}});else{N(""),h(e.redeemId);try{await A({productVariant:e.variant,redeemId:Number(e.redeemId),userId:l?.user_id})}catch(n){N(n?.message??t.redeemModal.commonError)}finally{h(null)}}}return r(K,{children:a("div",{className:"flex flex-1 flex-col gap-[12px]",children:[a("div",{className:"flex flex-col gap-[8px]",children:[t.title&&r("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:t.title}),t.subtitle&&r("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:t.subtitle})]}),t.insufficientCredits&&u&&a("div",{className:"text-[14px] font-[700] text-[#1d1d1f]",children:[t.insufficientCredits,": ",g(u.available_credit)," ",t.pointUnit]}),C&&r("div",{className:"text-[14px] font-[700] text-[#f84d4f]",children:C}),k?r("div",{className:"flex flex-1 items-center justify-center py-[32px]",children:r("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}):r("div",{className:"flex flex-col",children:O.map((e,n)=>{const i=!!e.product;return a("div",{className:"relative py-[16px]",children:[n>0&&r("div",{className:"absolute inset-x-0 top-0 h-px bg-[#dadce0]"}),a("div",{className:"flex items-center gap-[12px]",children:[(()=>{const m=t.imageMapping?.[e.type]?.url,c=i?e.variant?.image?.url??e.product?.images?.[0]?.url??e.image?.url:m??e.image?.url,d=i?e.variant?.image?.altText??e.product?.images?.[0]?.alt??e.image?.alt??"":e.image?.alt??"";return c?a("div",{className:R("relative size-[64px] shrink-0 overflow-hidden",b?"rounded-[4px]":"rounded-none"),children:[r($,{source:c,alt:d,className:"flex size-full items-center justify-center",imgClassName:i?"object-cover":"h-full w-auto object-contain"}),!i&&e.value&&a("div",{className:"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white",children:[e.value," ",t.off]})]}):null})(),a("div",{className:"min-w-0 flex-1",children:[r("div",{className:"text-[16px] font-[700] text-[#1e2024] line-clamp-2",children:i&&e.product?.title?e.product.title:e.title}),r("div",{className:"mt-[4px] text-[14px] text-[#666]",children:i&&e.price!=null?`${g(e.alpcData.consume_credits)} ${t.pointUnit??""} + $${Number(e.price).toFixed(2)}`:`${g(e.alpcData.consume_credits)} ${t.pointUnit??""}`})]}),a("div",{className:"relative group",children:[r(z,{className:R("bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",b?"rounded-[4px]":"rounded-none"),disabled:E(e),loading:D===e.redeemId,onClick:()=>L(e),children:U(e)}),e.insufficient&&r("div",{className:"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block",children:a("div",{className:"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow",children:[r("p",{className:"text-pretty tracking-[-0.02em] text-[14px]",children:t.insufficientCredits}),r("div",{className:"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]"})]})})]})]})]},n)})}),t.creditsPage?.url&&r("a",{href:t.creditsPage.url,target:"_blank",rel:"noopener noreferrer",className:"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline",children:t.creditsPage.label??"Go to Credits Page"})]})})}var se=J;export{se 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 { useMemo, useState } from 'react'\nimport { Picture, Button } from '@anker-in/headless-ui'\nimport { 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 product?: any\n variant?: any\n}\n\ntype Props = {\n copy: ConsumeCreditsopy\n onClose: () => void\n}\n\nfunction ConsumeCredits({ copy, onClose }: Props) {\n const { profile, creditInfo, openSignUpPopup, alpcConfig } = 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 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 = isLogin && !!profile?.activated && alpcData.consume_credits > availableCredit\n const soldOut = alpcData.is_limited && (!alpcData.remaining_inventory || alpcData.remaining_inventory <= 0)\n\n let product\n let variant\n if (\n (item.type === ConsumeCreditsItemType.RedeemAndBuy ||\n item.type === ConsumeCreditsItemType.Product) &&\n item.product\n ) {\n product = products?.find((p: any) => p.handle === item.product!.handle)\n variant = product?.variants?.find((v: any) => v.sku === item.product!.sku) ?? product?.variants?.[0]\n if (item.type === ConsumeCreditsItemType.RedeemAndBuy && (!product || !variant)) return null\n }\n\n return { ...item, alpcData, insufficient, soldOut, product, variant }\n })\n .filter(Boolean) as EnrichedItem[]\n }, [copy.list, redeemableList, creditInfo, profile, isLogin, products])\n\n function getButtonLabel(item: (typeof list)[number]) {\n if (!isLogin) return copy.unlockRewards\n if (item.soldOut) return copy.soldOut\n return copy.btnRedeem\n }\n\n function isDisabled(item: (typeof list)[number]) {\n if (\n item.type === ConsumeCreditsItemType.GiftCard ||\n item.type === ConsumeCreditsItemType.Product\n ) {\n return item.insufficient\n }\n return item.soldOut || item.insufficient\n }\n\n async function handleRedeem(item: (typeof list)[number]) {\n if (!isLogin) {\n openSignUpPopup()\n return\n }\n if (!profile?.activated) {\n pushView({ type: MemberPopupPanelType.Activate })\n return\n }\n if (\n item.type === ConsumeCreditsItemType.GiftCard ||\n item.type === ConsumeCreditsItemType.Product\n ) {\n if (copy.creditsPage?.url) {\n window.open(copy.creditsPage.url, '_blank', 'noopener,noreferrer')\n }\n return\n }\n if (item.type === ConsumeCreditsItemType.Coupon) {\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 itemOff: copy.off,\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 try {\n await redeemAndBuy({\n productVariant: item.variant,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\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 gap-[12px]\">\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 && <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>}\n </div>\n\n {copy.insufficientCredits && creditInfo && (\n <div className=\"text-[14px] font-[700] text-[#1d1d1f]\">\n {copy.insufficientCredits}: {numberFormat(creditInfo.available_credit)} {copy.pointUnit}\n </div>\n )}\n {redeemAndBuyError && <div className=\"text-[14px] 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 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 className={cn('relative size-[64px] shrink-0 overflow-hidden', rounded ? 'rounded-[4px]' : 'rounded-none')}>\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-[20px] left-[4px] text-[14px] 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\n ? item.product.title\n : 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.pointUnit ?? ''} + $${Number(item.price).toFixed(2)}`\n : `${numberFormat(item.alpcData.consume_credits)} ${copy.pointUnit ?? ''}`}\n </div>\n </div>\n <div className=\"relative group\">\n <Button\n className={cn('bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white', rounded ? 'rounded-[4px]' : 'rounded-none')}\n disabled={isDisabled(item)}\n loading={loadingId === item.redeemId}\n onClick={() => handleRedeem(item)}\n >\n {getButtonLabel(item)}\n </Button>\n {item.insufficient && (\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={copy.creditsPage.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline\"\n >\n {copy.creditsPage.label ?? 'Go to Credits Page'}\n </a>\n )}\n </div>\n </>\n )\n}\n\nexport default ConsumeCredits\n"],
|
|
4
|
+
"sourcesContent": ["import { useMemo, useState } from 'react'\nimport { Picture, Button } from '@anker-in/headless-ui'\nimport { 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 product?: any\n variant?: any\n}\n\ntype Props = {\n copy: ConsumeCreditsopy\n onClose: () => void\n}\n\nfunction ConsumeCredits({ copy, onClose }: Props) {\n const { profile, creditInfo, openSignUpPopup, alpcConfig } = 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 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 = isLogin && !!profile?.activated && alpcData.consume_credits > availableCredit\n const soldOut = alpcData.is_limited && (!alpcData.remaining_inventory || alpcData.remaining_inventory <= 0)\n\n let product\n let variant\n if (\n (item.type === ConsumeCreditsItemType.RedeemAndBuy ||\n item.type === ConsumeCreditsItemType.Product) &&\n item.product\n ) {\n product = products?.find((p: any) => p.handle === item.product!.handle)\n variant = product?.variants?.find((v: any) => v.sku === item.product!.sku) ?? product?.variants?.[0]\n if (item.type === ConsumeCreditsItemType.RedeemAndBuy && (!product || !variant)) return null\n }\n\n return { ...item, alpcData, insufficient, soldOut, product, variant }\n })\n .filter(Boolean) as EnrichedItem[]\n }, [copy.list, redeemableList, creditInfo, profile, isLogin, products])\n\n function getButtonLabel(item: (typeof list)[number]) {\n if (!isLogin) return copy.unlockRewards\n if (item.soldOut) return copy.soldOut\n return copy.btnRedeem\n }\n\n function isDisabled(item: (typeof list)[number]) {\n if (\n item.type === ConsumeCreditsItemType.GiftCard ||\n item.type === ConsumeCreditsItemType.Product\n ) {\n return item.insufficient\n }\n return item.soldOut || item.insufficient\n }\n\n async function handleRedeem(item: (typeof list)[number]) {\n if (!isLogin) {\n openSignUpPopup()\n return\n }\n if (!profile?.activated) {\n pushView({ type: MemberPopupPanelType.Activate })\n return\n }\n if (\n item.type === ConsumeCreditsItemType.GiftCard ||\n item.type === ConsumeCreditsItemType.Product\n ) {\n if (copy.creditsPage?.url) {\n window.open(copy.creditsPage.url, '_blank', 'noopener,noreferrer')\n }\n return\n }\n if (item.type === ConsumeCreditsItemType.Coupon) {\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 itemOff: copy.off,\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 try {\n await redeemAndBuy({\n productVariant: item.variant,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\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 gap-[12px]\">\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 && <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>}\n </div>\n\n {copy.insufficientCredits && creditInfo && (\n <div className=\"text-[14px] font-[700] text-[#1d1d1f]\">\n {copy.insufficientCredits}: {numberFormat(creditInfo.available_credit)} {copy.pointUnit}\n </div>\n )}\n {redeemAndBuyError && <div className=\"text-[14px] 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 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 className={cn('relative size-[64px] shrink-0 overflow-hidden', rounded ? 'rounded-[4px]' : 'rounded-none')}>\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\n ? item.product.title\n : 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.pointUnit ?? ''} + $${Number(item.price).toFixed(2)}`\n : `${numberFormat(item.alpcData.consume_credits)} ${copy.pointUnit ?? ''}`}\n </div>\n </div>\n <div className=\"relative group\">\n <Button\n className={cn('bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white', rounded ? 'rounded-[4px]' : 'rounded-none')}\n disabled={isDisabled(item)}\n loading={loadingId === item.redeemId}\n onClick={() => handleRedeem(item)}\n >\n {getButtonLabel(item)}\n </Button>\n {item.insufficient && (\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={copy.creditsPage.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline\"\n >\n {copy.creditsPage.label ?? 'Go to Credits Page'}\n </a>\n )}\n </div>\n </>\n )\n}\n\nexport default ConsumeCredits\n"],
|
|
5
5
|
"mappings": "AA8II,mBAAAA,EAGqB,OAAAC,EADjB,QAAAC,MAFJ,oBA9IJ,OAAS,WAAAC,EAAS,YAAAC,MAAgB,QAClC,OAAS,WAAAC,EAAS,UAAAC,MAAc,wBAChC,OAAS,cAAcC,EAAI,wBAAAC,EAAsB,sBAAAC,MAA0B,gBAC3E,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,MAAsB,wBAe/B,SAASC,EAAe,CAAE,KAAAC,EAAM,QAAAC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ClC,EAAK,aAAa,KACjBlB,EAAC,KACC,KAAMkB,EAAK,YAAY,IACvB,OAAO,SACP,IAAI,sBACJ,UAAU,qEAET,SAAAA,EAAK,YAAY,OAAS,qBAC7B,GAEJ,EACF,CAEJ,CAEA,IAAOuC,GAAQxC",
|
|
6
6
|
"names": ["Fragment", "jsx", "jsxs", "useMemo", "useState", "Picture", "Button", "cn", "useProductsByHandles", "useHeadlessContext", "useMemberPopupContext", "useViewStack", "useRedeemableList", "useRedeemAndBuy", "ConsumeCreditsItemType", "MemberPopupPanelType", "numberFormat", "ROUNDED_BRANDS", "ConsumeCredits", "copy", "onClose", "profile", "creditInfo", "openSignUpPopup", "alpcConfig", "pushView", "brand", "rounded", "redeemAndBuyError", "setRedeemAndBuyError", "loadingId", "setLoadingId", "isLogin", "redeemableList", "listLoading", "redeemAndBuy", "handles", "item", "products", "list", "alpcData", "r", "availableCredit", "insufficient", "soldOut", "product", "variant", "p", "v", "getButtonLabel", "isDisabled", "handleRedeem", "e", "idx", "hasProduct", "mappedImgUrl", "imgUrl", "imgAlt", "ConsumeCredits_default"]
|
|
7
7
|
}
|
package/package.json
CHANGED