@anker-in/campaign-ui 0.5.0-beta.1 → 0.5.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/credits/context/hooks/useCountries.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useCountries.js.map +3 -3
- package/dist/cjs/components/memberPopup/MemberPopup.js +1 -1
- package/dist/cjs/components/memberPopup/MemberPopup.js.map +3 -3
- package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.d.ts +10 -0
- package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.js +2 -0
- package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +7 -0
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.d.ts +2 -1
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js +1 -1
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js.map +3 -3
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.d.ts +2 -1
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.js +1 -1
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.js.map +3 -3
- package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.d.ts +11 -0
- package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js +2 -0
- package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js.map +7 -0
- package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfileModal.js +1 -1
- package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfileModal.js.map +2 -2
- package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js +1 -1
- package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js.map +2 -2
- package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeModal.js +1 -1
- package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeModal.js.map +2 -2
- package/dist/cjs/components/memberPopup/panels/EarnCredits/index.js +1 -1
- package/dist/cjs/components/memberPopup/panels/EarnCredits/index.js.map +2 -2
- package/dist/cjs/components/memberPopup/panels/Referral/index.js +1 -1
- package/dist/cjs/components/memberPopup/panels/Referral/index.js.map +2 -2
- package/dist/cjs/components/memberPopup/type.d.ts +32 -2
- package/dist/cjs/components/memberPopup/type.js +1 -1
- package/dist/cjs/components/memberPopup/type.js.map +3 -3
- package/dist/esm/components/credits/context/hooks/useCountries.js +1 -1
- package/dist/esm/components/credits/context/hooks/useCountries.js.map +3 -3
- package/dist/esm/components/memberPopup/MemberPopup.js +1 -1
- package/dist/esm/components/memberPopup/MemberPopup.js.map +3 -3
- package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.d.ts +10 -0
- package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js +2 -0
- package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +7 -0
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.d.ts +2 -1
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js +1 -1
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js.map +3 -3
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.d.ts +2 -1
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.js +1 -1
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.js.map +3 -3
- package/dist/esm/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.d.ts +11 -0
- package/dist/esm/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js +2 -0
- package/dist/esm/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js.map +7 -0
- package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfileModal.js +1 -1
- package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfileModal.js.map +2 -2
- package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js +1 -1
- package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js.map +2 -2
- package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeModal.js +1 -1
- package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeModal.js.map +2 -2
- package/dist/esm/components/memberPopup/panels/EarnCredits/index.js +1 -1
- package/dist/esm/components/memberPopup/panels/EarnCredits/index.js.map +2 -2
- package/dist/esm/components/memberPopup/panels/Referral/index.js +1 -1
- package/dist/esm/components/memberPopup/panels/Referral/index.js.map +2 -2
- package/dist/esm/components/memberPopup/type.d.ts +32 -2
- package/dist/esm/components/memberPopup/type.js +1 -1
- package/dist/esm/components/memberPopup/type.js.map +3 -3
- package/package.json +1 -1
- package/src/components/credits/context/hooks/useCountries.ts +4 -15
- package/src/components/memberPopup/MemberPopup.tsx +96 -44
- package/src/components/memberPopup/panels/ActivitiesSubscribePanel.tsx +194 -0
- package/src/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.tsx +61 -28
- package/src/components/memberPopup/panels/ConsumeCredits/index.tsx +124 -65
- package/src/components/memberPopup/panels/EarnCredits/CompleteProfileModal.tsx +6 -1
- package/src/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.tsx +6 -1
- package/src/components/memberPopup/panels/EarnCredits/index.tsx +95 -65
- package/src/components/memberPopup/panels/Referral/index.tsx +1 -1
- package/src/components/memberPopup/type.ts +31 -2
- package/src/components/memberPopup/panels/ConsumeCredits/RedeemCouponModal.tsx +0 -150
- package/src/components/memberPopup/panels/EarnCredits/SubscribeModal.tsx +0 -144
- package/src/components/memberPopup/panels/EarnCredits/SubscribePanel.tsx +0 -147
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var s in e)a(t,s,{get:e[s],enumerable:!0})},g=(t,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of m(e))!C.call(t,o)&&o!==s&&a(t,o,{get:()=>e[o],enumerable:!(n=h(e,o))||n.enumerable});return t};var d=t=>g(a({},"__esModule",{value:!0}),t);var x={};y(x,{default:()=>w});module.exports=d(x);var r=require("react"),p=require("@anker-in/lib");function S({shopifyStoreDomain:t}){const{locale:e=""}=(0,p.useHeadlessContext)(),[s,n]=(0,r.useState)(!1),[o,c]=(0,r.useState)([]);return(0,r.useEffect)(()=>{(async()=>{n(!0);try{let i=(await(await fetch("/api/multipass/account/countries",{headers:{"current-language":e}})).json())?.data?.data||[];i=i.sort((f,l)=>f.name.localeCompare(l.name)),console.log("fetch shipsToCountries",i),c(i)}catch(u){c([]),console.error(u)}finally{n(!1)}})()},[e]),{isLoading:s,countries:o}}var w=S;
|
|
2
2
|
//# sourceMappingURL=useCountries.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useCountries.ts"],
|
|
4
|
-
"sourcesContent": ["import { useEffect, useState } from 'react'\n\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { type ShippingCountry
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,iBAEpCC,EAAmC,yBAGnC,SAASC,EAAa,CAAE,mBAAAC,CAAmB,EAAmC,CAC5E,KAAM,CAAE,OAAAC,EAAS,EAAG,KAAI,sBAAmB,EAErC,CAACC,EAAWC,CAAU,KAAI,YAAS,EAAK,EACxC,CAACC,EAAWC,CAAY,KAAI,YAA4B,CAAC,CAAC,EAEhE,sBAAU,IAAM,EACS,SAAY,CACjCF,EAAW,EAAI,EACf,GAAI,
|
|
6
|
-
"names": ["useCountries_exports", "__export", "useCountries_default", "__toCommonJS", "import_react", "import_lib", "useCountries", "shopifyStoreDomain", "locale", "isLoading", "setLoading", "countries", "setCountries", "
|
|
4
|
+
"sourcesContent": ["import { useEffect, useState } from 'react'\n\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { type ShippingCountry } from '../../type'\n\nfunction useCountries({ shopifyStoreDomain }: { shopifyStoreDomain: string }) {\n const { locale = '' } = useHeadlessContext()\n\n const [isLoading, setLoading] = useState(false)\n const [countries, setCountries] = useState<ShippingCountry[]>([])\n\n useEffect(() => {\n const fetchCountries = async () => {\n setLoading(true)\n try {\n const response = await fetch('/api/multipass/account/countries', {\n headers: {\n 'current-language': locale,\n },\n })\n const res: any = await response.json()\n\n let shipsToCountries: ShippingCountry[] = res?.data?.data || []\n\n // \u5B57\u6BCD\u987A\u5E8F\u6392\u5E8F\n shipsToCountries = shipsToCountries.sort((a, b) => {\n return a.name.localeCompare(b.name)\n })\n\n console.log('fetch shipsToCountries', shipsToCountries)\n setCountries(shipsToCountries)\n } catch (e) {\n setCountries([])\n console.error(e)\n } finally {\n setLoading(false)\n }\n }\n\n fetchCountries()\n }, [locale])\n\n return {\n isLoading,\n countries,\n }\n}\n\nexport default useCountries\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,iBAEpCC,EAAmC,yBAGnC,SAASC,EAAa,CAAE,mBAAAC,CAAmB,EAAmC,CAC5E,KAAM,CAAE,OAAAC,EAAS,EAAG,KAAI,sBAAmB,EAErC,CAACC,EAAWC,CAAU,KAAI,YAAS,EAAK,EACxC,CAACC,EAAWC,CAAY,KAAI,YAA4B,CAAC,CAAC,EAEhE,sBAAU,IAAM,EACS,SAAY,CACjCF,EAAW,EAAI,EACf,GAAI,CAQF,IAAIG,GAFa,MALA,MAAM,MAAM,mCAAoC,CAC/D,QAAS,CACP,mBAAoBL,CACtB,CACF,CAAC,GAC+B,KAAK,IAEU,MAAM,MAAQ,CAAC,EAG9DK,EAAmBA,EAAiB,KAAK,CAACC,EAAGC,IACpCD,EAAE,KAAK,cAAcC,EAAE,IAAI,CACnC,EAED,QAAQ,IAAI,yBAA0BF,CAAgB,EACtDD,EAAaC,CAAgB,CAC/B,OAASG,EAAG,CACVJ,EAAa,CAAC,CAAC,EACf,QAAQ,MAAMI,CAAC,CACjB,QAAE,CACAN,EAAW,EAAK,CAClB,CACF,GAEe,CACjB,EAAG,CAACF,CAAM,CAAC,EAEJ,CACL,UAAAC,EACA,UAAAE,CACF,CACF,CAEA,IAAOT,EAAQI",
|
|
6
|
+
"names": ["useCountries_exports", "__export", "useCountries_default", "__toCommonJS", "import_react", "import_lib", "useCountries", "shopifyStoreDomain", "locale", "isLoading", "setLoading", "countries", "setCountries", "shipsToCountries", "a", "b", "e"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";"use client";var
|
|
1
|
+
"use strict";"use client";var W=Object.create;var g=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var Q=(e,i)=>{for(var n in i)g(e,n,{get:i[n],enumerable:!0})},O=(e,i,n,u)=>{if(i&&typeof i=="object"||typeof i=="function")for(let l of G(i))!K.call(e,l)&&l!==n&&g(e,l,{get:()=>i[l],enumerable:!(u=q(i,l))||u.enumerable});return e};var d=(e,i,n)=>(n=e!=null?W(J(e)):{},O(i||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),X=e=>O(g({},"__esModule",{value:!0}),e);var ae={};Q(ae,{MemberPopup:()=>ie});module.exports=X(ae);var t=require("react/jsx-runtime"),r=require("react"),V=require("@anker-in/headless-ui"),f=require("@anker-in/lib"),s=require("./type"),R=require("./context/provider"),H=require("./context/provider"),z=require("./context/viewStack"),a=require("./icons"),E=require("../../constants");const Y=(0,r.lazy)(()=>import("./panels/EarnCredits")),Z=(0,r.lazy)(()=>import("./panels/ConsumeCredits")),$=(0,r.lazy)(()=>import("./panels/Referral")),ee=(0,r.lazy)(()=>import("./panels/EarnCredits/CompleteProfilePanel")),te=(0,r.lazy)(()=>import("./panels/ActivitiesSubscribePanel")),se=(0,r.lazy)(()=>import("./panels/EarnCredits/SubscribeEmailPanel")),oe=(0,r.lazy)(()=>import("./panels/EarnCredits/ActivatePanel")),re=(0,r.lazy)(()=>import("./panels/ConsumeCredits/RedeemCouponPanel"));function ie({copy:e,bottomOffset:i="24px",...n}){return(0,t.jsx)(R.MemberPopupProvider,{...n,earnCreditsCopy:e.earnCredits,children:(0,t.jsx)(ne,{copy:e,bottomOffset:i})})}function ne({copy:e,bottomOffset:i}){const{profile:n,openSignInPopup:u,openSignUpPopup:l}=(0,H.useMemberPopupContext)(),{brand:x,storeDomain:C}=(0,f.useHeadlessContext)(),v=E.ROUNDED_BRANDS.includes(x),T=!!n,[P,w]=(0,r.useState)(!1),[h,S]=(0,r.useState)([]),[j,_]=(0,r.useState)(!1),[N,D]=(0,r.useState)(!1),[F,L]=(0,r.useState)(!1),[U,y]=(0,r.useState)(!1),o=h[h.length-1]??null,I=(0,r.useMemo)(()=>{const p=e.pageConfig;if(!p)return!0;const m=typeof window<"u"?window.location.pathname:"",M=p.pages.some(A=>m===A||m.startsWith(A+"/"));switch(p.scope){case s.MemberPopupPageScope.Include:return M;case s.MemberPopupPageScope.Exclude:return!M;default:return!0}},[e.pageConfig]),b=(0,r.useCallback)(p=>{S(m=>[...m,p])},[]),c=(0,r.useCallback)(()=>{S(p=>p.slice(0,-1))},[]);if(console.log("isVisible",I),!I)return null;function B(p,m){switch(p){case s.MemberPopupActionType.ExternalLink:m&&window.open(m,"_blank","noopener,noreferrer");break;case s.MemberPopupActionType.OpenEarnCredits:b({type:s.MemberPopupPanelType.EarnCredits});break;case s.MemberPopupActionType.OpenConsumeCredits:b({type:s.MemberPopupPanelType.ConsumeCredits});break;case s.MemberPopupActionType.OpenReferral:b({type:s.MemberPopupPanelType.Referral});break;case s.MemberPopupActionType.OpenSubscribe:b({type:s.MemberPopupPanelType.Subscribe});break}}function k(){w(!1),S([]),y(!1)}return(0,t.jsxs)(z.ViewStackContext.Provider,{value:{pushView:b,popView:c},children:[P&&(0,t.jsx)("div",{className:"fixed inset-0 z-[998]",onClick:k}),(0,t.jsxs)("div",{className:"fixed right-0 z-[999] flex flex-row items-end pr-[16px] md:flex-col md:items-end md:right-0 md:w-screen md:pr-0 md:pl-0",style:{bottom:i},children:[P&&(0,t.jsxs)("div",{className:(0,f.classNames)("relative mr-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[500px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] md:mr-0 md:mb-[8px] md:mx-[16px] md:w-[calc(100vw-32px)] md:max-w-[400px]",v?"rounded-[12px]":"rounded-none"),style:{maxHeight:"min(80vh, 606px)"},onClick:p=>p.stopPropagation(),children:[(0,t.jsx)("div",{className:"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white md:bottom-[-8px] md:left-auto md:right-[29px] md:top-auto md:border-x-8 md:border-b-transparent md:border-t-white"}),(0,t.jsxs)("div",{className:"flex items-center justify-end pl-[10px] pr-[16px] pb-[8px] pt-[16px]",children:[o!==null&&(0,t.jsx)("button",{className:"mr-auto flex size-[24px] cursor-pointer items-center justify-center",onClick:c,"aria-label":"Back",children:(0,t.jsx)(a.IconSwitch,{})}),(0,t.jsx)("button",{className:"flex size-[24px] cursor-pointer items-center justify-center",onClick:k,"aria-label":"Close",children:(0,t.jsx)(a.IconClose,{})})]}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]",children:[o===null&&(0,t.jsxs)(t.Fragment,{children:[(e.title||e.subtitle)&&(0,t.jsxs)("div",{className:"flex flex-col gap-[4px]",children:[e.title&&(0,t.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:e.title}),e.subtitle&&(0,t.jsx)("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:e.subtitle})]}),e.list.map((p,m)=>(0,t.jsx)(pe,{item:p,onAction:B,rounded:v},m))]}),o!==null&&(0,t.jsxs)(r.Suspense,{fallback:(0,t.jsx)("div",{className:"flex items-center justify-center py-[32px]",children:(0,t.jsx)("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}),children:[o.type===s.MemberPopupPanelType.EarnCredits&&e.earnCredits&&(0,t.jsx)(Y,{copy:e.earnCredits,onClose:c,isSubscribeSuccess:j,isActivateSuccess:N,isProfileCompleteSuccess:F,onSubscribeSuccess:()=>_(!0),onActivateSuccess:()=>D(!0),onProfileCompleteSuccess:()=>L(!0)}),o.type===s.MemberPopupPanelType.ConsumeCredits&&e.consumeCredits&&(0,t.jsx)(Z,{copy:e.consumeCredits,onClose:c,isActivateSuccess:N}),o.type===s.MemberPopupPanelType.Referral&&e.referral&&(0,t.jsx)($,{copy:e.referral,onClose:c}),o.type===s.MemberPopupPanelType.CompleteProfile&&e.earnCredits&&(0,t.jsx)(ee,{copy:e.earnCredits.completeProfile,shopifyStoreDomain:C,onClose:c,onSuccess:o.props?.onSuccess}),o.type===s.MemberPopupPanelType.Subscribe&&e.activitiesSubscribe&&(0,t.jsx)(te,{copy:e.activitiesSubscribe,email:n?.email,onSuccess:o.props?.onSuccess,hideForm:U,onHideForm:()=>y(!0)}),o.type===s.MemberPopupPanelType.SubscribeEmail&&e.earnCredits&&(0,t.jsx)(se,{copy:e.earnCredits.subscribe,email:n?.email,onClose:c,onSuccess:o.props?.onSuccess}),o.type===s.MemberPopupPanelType.Activate&&e.earnCredits&&(0,t.jsx)(oe,{copy:e.earnCredits.authCodeActivate,onClose:c,onSuccess:o.props?.onSuccess}),o.type===s.MemberPopupPanelType.RedeemCoupon&&o.props&&e.consumeCredits&&(0,t.jsx)(re,{itemTitle:o.props.itemTitle,itemCredits:o.props.itemCredits,itemImage:o.props.itemImage,itemValue:o.props.itemValue,itemOff:o.props.itemOff,itemRules:o.props.itemRules,redeemId:o.props.redeemId,userId:o.props.userId,alpcConfig:o.props.alpcConfig,copy:e.consumeCredits.redeemModal,pointUnit:e.consumeCredits.pointUnit,onClose:c})]})]}),e.footer&&!T&&(0,t.jsx)("div",{className:"border-t border-[#dadce0] p-[16px]",children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-[16px]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-[4px]",children:[(0,t.jsx)("span",{className:"text-[14px] font-[700] text-[#080a0f]",children:e.footer.loginHint}),(0,t.jsx)("button",{className:"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline",onClick:u,children:e.footer.loginLabel})]}),(0,t.jsx)("div",{className:"flex shrink-0 items-center gap-[8px]",children:(0,t.jsx)("button",{className:(0,f.classNames)("cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]",v?"rounded-[4px]":"rounded-none"),onClick:l,children:e.footer.joinLabel})})]})})]}),(0,t.jsx)("button",{className:"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg md:ml-auto md:mr-[16px]",onClick:()=>w(p=>!p),"aria-label":e.triggerImg.alt??"Open member popup",children:(0,t.jsx)(V.Picture,{source:e.triggerImg.url,alt:e.triggerImg.alt??"",className:"size-[58px]"})})]})]})}function pe({item:e,onAction:i,rounded:n}){const u={[s.MemberPopupActionType.OpenEarnCredits]:a.IconCredit,[s.MemberPopupActionType.OpenConsumeCredits]:a.IconBag,[s.MemberPopupActionType.OpenReferral]:a.IconReferral,[s.MemberPopupActionType.OpenSubscribe]:a.IconSubscription};return(0,t.jsxs)("div",{className:(0,f.classNames)("flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]",n?"rounded-[8px]":"rounded-none"),children:[(0,t.jsxs)("div",{className:"flex flex-col gap-[4px]",children:[(0,t.jsx)("h3",{className:"text-[20px] font-[700] leading-[1.2] text-[#1e2024]",children:e.title}),e.description&&(0,t.jsx)("p",{className:"text-[14px] font-[700] leading-[1.43] text-[#1e2024]",children:e.description})]}),(0,t.jsx)("div",{className:"flex flex-col gap-[16px]",children:e.links.map((l,x)=>{const C=u[l.type];return(0,t.jsxs)("div",{children:[x>0&&(0,t.jsx)("div",{className:"mb-[16px] h-px bg-[#dadce0]"}),(0,t.jsxs)("button",{className:"flex w-full cursor-pointer items-center gap-[12px]",onClick:()=>i(l.type,l.url),children:[C&&(0,t.jsx)(C,{className:"size-[24px] shrink-0"}),(0,t.jsx)("span",{className:"flex-1 text-left text-[14px] font-[700] text-[#1e2024]",children:l.label}),(0,t.jsx)(a.IconArrow,{className:"size-[16px] shrink-0"})]})]},x)})})]})}
|
|
2
2
|
//# sourceMappingURL=MemberPopup.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/components/memberPopup/MemberPopup.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport { lazy, Suspense, useState, useCallback } from 'react'\nimport { Picture } from '@anker-in/headless-ui'\nimport { type HeadlessConfig, useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport {\n MemberPopupActionType,\n MemberPopupPanelType,\n type MemberPopupCopy,\n type MemberPopupContextValue,\n type MemberPopupItem,\n} from './type'\nimport { MemberPopupProvider } from './context/provider'\nimport { useMemberPopupContext } from './context/provider'\nimport { ViewStackContext, type ViewPayload } from './context/viewStack'\nimport { IconClose, IconArrow, IconCredit, IconBag, IconReferral, IconSwitch, IconSubscription } from './icons'\nimport { ROUNDED_BRANDS } from '../../constants'\n\nconst EarnCredits = lazy(() => import('./panels/EarnCredits'))\nconst ConsumeCredits = lazy(() => import('./panels/ConsumeCredits'))\nconst Referral = lazy(() => import('./panels/Referral'))\nconst CompleteProfile = lazy(() => import('./panels/EarnCredits/CompleteProfilePanel'))\nconst Subscribe = lazy(() => import('./panels/EarnCredits/SubscribePanel'))\nconst SubscribeEmail = lazy(() => import('./panels/EarnCredits/SubscribeEmailPanel'))\nconst Activate = lazy(() => import('./panels/EarnCredits/ActivatePanel'))\nconst RedeemCoupon = lazy(() => import('./panels/ConsumeCredits/RedeemCouponPanel'))\n\ntype MemberPopupProps = MemberPopupContextValue & {\n headlessConfig: HeadlessConfig\n copy: MemberPopupCopy\n bottomOffset?: string\n}\n\nexport function MemberPopup({ copy, bottomOffset = '24px', ...providerProps }: MemberPopupProps) {\n return (\n <MemberPopupProvider {...providerProps} earnCreditsCopy={copy.earnCredits}>\n <MemberPopupContent copy={copy} bottomOffset={bottomOffset} />\n </MemberPopupProvider>\n )\n}\n\ntype MemberPopupContentProps = {\n copy: MemberPopupCopy\n bottomOffset: string\n}\n\nfunction MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {\n const { profile, openSignInPopup, openSignUpPopup } = useMemberPopupContext()\n const { brand, storeDomain } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n const isLogin = !!profile\n const [isOpen, setIsOpen] = useState(false)\n const [viewStack, setViewStack] = useState<ViewPayload[]>([])\n const [isSubscribeSuccess, setIsSubscribeSuccess] = useState(false)\n const [isActivateSuccess, setIsActivateSuccess] = useState(false)\n const [isProfileCompleteSuccess, setIsProfileCompleteSuccess] = useState(false)\n\n const currentView = viewStack[viewStack.length - 1] ?? null\n\n const pushView = useCallback((view: ViewPayload) => {\n setViewStack(prev => [...prev, view])\n }, [])\n\n const popView = useCallback(() => {\n setViewStack(prev => prev.slice(0, -1))\n }, [])\n\n function handleAction(type: MemberPopupActionType, url?: string) {\n switch (type) {\n case MemberPopupActionType.ExternalLink:\n if (url) window.open(url, '_blank', 'noopener,noreferrer')\n break\n case MemberPopupActionType.OpenEarnCredits:\n pushView({ type: MemberPopupPanelType.EarnCredits })\n break\n case MemberPopupActionType.OpenConsumeCredits:\n pushView({ type: MemberPopupPanelType.ConsumeCredits })\n break\n case MemberPopupActionType.OpenReferral:\n pushView({ type: MemberPopupPanelType.Referral })\n break\n case MemberPopupActionType.OpenSubscribe:\n pushView({ type: MemberPopupPanelType.Subscribe })\n break\n }\n }\n\n function handleClose() {\n setIsOpen(false)\n setViewStack([])\n }\n\n return (\n <ViewStackContext.Provider value={{ pushView, popView }}>\n {isOpen && (\n <div\n className=\"fixed inset-0 z-[998]\"\n onClick={handleClose}\n />\n )}\n <div className=\"fixed right-0 z-[999] flex flex-col items-end pr-[16px]\" style={{ bottom: bottomOffset }}>\n {isOpen && (\n <div\n className={cn('relative mb-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[600px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] cmp-md:w-[358px] cmp-sm:w-[258px]', rounded ? 'rounded-[12px]' : 'rounded-none')}\n onClick={e => e.stopPropagation()}\n >\n <div className=\"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white\" />\n <div className=\"flex items-center justify-between px-[16px] pb-[8px] pt-[16px]\">\n <button\n className=\"flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={popView}\n aria-label=\"Back\"\n >\n <IconSwitch />\n </button>\n <button\n className=\"flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={handleClose}\n aria-label=\"Close\"\n >\n <IconClose />\n </button>\n </div>\n\n <div\n className=\"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]\"\n style={{ maxHeight: 'min(calc(80vh - 118px), 606px)' }}\n >\n {currentView === null && (\n <>\n {(copy.title || copy.subtitle) && (\n <div className=\"flex flex-col gap-[4px]\">\n {copy.title && (\n <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>\n )}\n {copy.subtitle && (\n <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>\n )}\n </div>\n )}\n {copy.list.map((item, i) => (\n <HomeCard key={i} item={item} onAction={handleAction} rounded={rounded} />\n ))}\n </>\n )}\n\n {currentView !== null && (\n <Suspense\n fallback={\n <div className=\"flex 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 >\n {currentView.type === MemberPopupPanelType.EarnCredits && copy.earnCredits && (\n <EarnCredits\n copy={copy.earnCredits}\n onClose={popView}\n isSubscribeSuccess={isSubscribeSuccess}\n isActivateSuccess={isActivateSuccess}\n isProfileCompleteSuccess={isProfileCompleteSuccess}\n onSubscribeSuccess={() => setIsSubscribeSuccess(true)}\n onActivateSuccess={() => setIsActivateSuccess(true)}\n onProfileCompleteSuccess={() => setIsProfileCompleteSuccess(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.ConsumeCredits && copy.consumeCredits && (\n <ConsumeCredits copy={copy.consumeCredits} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.Referral && copy.referral && (\n <Referral copy={copy.referral} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.CompleteProfile && copy.earnCredits && (\n <CompleteProfile copy={copy.earnCredits.completeProfile} shopifyStoreDomain={storeDomain} onClose={popView} onSuccess={currentView.props?.onSuccess} />\n )}\n {currentView.type === MemberPopupPanelType.Subscribe && copy.subscribe && (\n <Subscribe copy={copy.subscribe} email={profile?.email} onClose={popView} onSuccess={currentView.props?.onSuccess} />\n )}\n {currentView.type === MemberPopupPanelType.SubscribeEmail && copy.earnCredits && (\n <SubscribeEmail copy={copy.earnCredits.subscribe} email={profile?.email} onClose={popView} onSuccess={currentView.props?.onSuccess} />\n )}\n {currentView.type === MemberPopupPanelType.Activate && copy.earnCredits && (\n <Activate copy={copy.earnCredits.authCodeActivate} onClose={popView} onSuccess={currentView.props?.onSuccess} />\n )}\n {currentView.type === MemberPopupPanelType.RedeemCoupon && currentView.props && copy.consumeCredits && (\n <RedeemCoupon\n itemTitle={currentView.props.itemTitle}\n itemCredits={currentView.props.itemCredits}\n itemImage={currentView.props.itemImage}\n itemValue={currentView.props.itemValue}\n itemOff={currentView.props.itemOff}\n redeemId={currentView.props.redeemId}\n userId={currentView.props.userId}\n alpcConfig={currentView.props.alpcConfig}\n copy={copy.consumeCredits.redeemModal}\n pointUnit={copy.consumeCredits.pointUnit}\n onClose={popView}\n />\n )}\n </Suspense>\n )}\n </div>\n\n {copy.footer && !isLogin && (\n <div className=\"border-t border-[#dadce0] p-[16px]\">\n <div className=\"flex items-center justify-between gap-[16px]\">\n <div className=\"flex items-center gap-[4px]\">\n <span className=\"text-[14px] font-[700] text-[#080a0f]\">{copy.footer.loginHint}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline\"\n onClick={openSignInPopup}\n >\n {copy.footer.loginLabel}\n </button>\n </div>\n <div className=\"flex shrink-0 items-center gap-[8px]\">\n <button\n className={cn('cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]', rounded ? 'rounded-[4px]' : 'rounded-none')}\n onClick={openSignUpPopup}\n >\n {copy.footer.joinLabel}\n </button>\n </div>\n </div>\n </div>\n )}\n </div>\n )}\n\n <button\n className=\"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg\"\n onClick={() => setIsOpen(prev => !prev)}\n aria-label={copy.triggerImg.alt ?? 'Open member popup'}\n >\n <Picture source={copy.triggerImg.url} alt={copy.triggerImg.alt ?? ''} className=\"size-[58px]\" />\n </button>\n </div>\n </ViewStackContext.Provider>\n )\n}\n\ntype HomeCardProps = {\n item: MemberPopupItem\n onAction: (type: MemberPopupActionType, url?: string) => void\n rounded: boolean\n}\n\nfunction HomeCard({ item, onAction, rounded }: HomeCardProps) {\n const ACTION_ICON: Partial<Record<MemberPopupActionType, typeof IconCredit>> = {\n [MemberPopupActionType.OpenEarnCredits]: IconCredit,\n [MemberPopupActionType.OpenConsumeCredits]: IconBag,\n [MemberPopupActionType.OpenReferral]: IconReferral,\n [MemberPopupActionType.OpenSubscribe]: IconSubscription,\n }\n\n return (\n <div className={cn('flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <div className=\"flex flex-col gap-[4px]\">\n <h3 className=\"text-[20px] font-[700] leading-[1.2] text-[#1e2024]\">{item.title}</h3>\n {item.description && <p className=\"text-[14px] font-[700] leading-[1.43] text-[#1e2024]\">{item.description}</p>}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n {item.links.map((link, i) => {\n const IconComponent = ACTION_ICON[link.type]\n return (\n <div key={i}>\n {i > 0 && <div className=\"mb-[16px] h-px bg-[#dadce0]\" />}\n <button\n className=\"flex w-full cursor-pointer items-center gap-[12px]\"\n onClick={() => onAction(link.type, link.url)}\n >\n {IconComponent && <IconComponent className=\"size-[24px] shrink-0\" />}\n <span className=\"flex-1 text-left text-[14px] font-[700] text-[#1e2024]\">{link.label}</span>\n <IconArrow className=\"size-[16px] shrink-0\" />\n </button>\n </div>\n )\n })}\n </div>\n </div>\n )\n}\n"],
|
|
5
|
-
"mappings": "ukBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,iBAAAE,KAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["MemberPopup_exports", "__export", "MemberPopup", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_type", "import_provider", "import_viewStack", "import_icons", "import_constants", "EarnCredits", "ConsumeCredits", "Referral", "CompleteProfile", "
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport { lazy, Suspense, useState, useCallback, useMemo } from 'react'\nimport { Picture } from '@anker-in/headless-ui'\nimport { type HeadlessConfig, useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport {\n MemberPopupActionType,\n MemberPopupPageScope,\n MemberPopupPanelType,\n type MemberPopupCopy,\n type MemberPopupContextValue,\n type MemberPopupItem,\n} from './type'\nimport { MemberPopupProvider } from './context/provider'\nimport { useMemberPopupContext } from './context/provider'\nimport { ViewStackContext, type ViewPayload } from './context/viewStack'\nimport { IconClose, IconArrow, IconCredit, IconBag, IconReferral, IconSwitch, IconSubscription } from './icons'\nimport { ROUNDED_BRANDS } from '../../constants'\n\nconst EarnCredits = lazy(() => import('./panels/EarnCredits'))\nconst ConsumeCredits = lazy(() => import('./panels/ConsumeCredits'))\nconst Referral = lazy(() => import('./panels/Referral'))\nconst CompleteProfile = lazy(() => import('./panels/EarnCredits/CompleteProfilePanel'))\nconst ActivitiesSubscribe = lazy(() => import('./panels/ActivitiesSubscribePanel'))\nconst SubscribeEmail = lazy(() => import('./panels/EarnCredits/SubscribeEmailPanel'))\nconst Activate = lazy(() => import('./panels/EarnCredits/ActivatePanel'))\nconst RedeemCoupon = lazy(() => import('./panels/ConsumeCredits/RedeemCouponPanel'))\n\ntype MemberPopupProps = MemberPopupContextValue & {\n headlessConfig: HeadlessConfig\n copy: MemberPopupCopy\n bottomOffset?: string\n}\n\nexport function MemberPopup({ copy, bottomOffset = '24px', ...providerProps }: MemberPopupProps) {\n return (\n <MemberPopupProvider {...providerProps} earnCreditsCopy={copy.earnCredits}>\n <MemberPopupContent copy={copy} bottomOffset={bottomOffset} />\n </MemberPopupProvider>\n )\n}\n\ntype MemberPopupContentProps = {\n copy: MemberPopupCopy\n bottomOffset: string\n}\n\nfunction MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {\n const { profile, openSignInPopup, openSignUpPopup } = useMemberPopupContext()\n const { brand, storeDomain } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n const isLogin = !!profile\n const [isOpen, setIsOpen] = useState(false)\n const [viewStack, setViewStack] = useState<ViewPayload[]>([])\n const [isSubscribeSuccess, setIsSubscribeSuccess] = useState(false)\n const [isActivateSuccess, setIsActivateSuccess] = useState(false)\n const [isProfileCompleteSuccess, setIsProfileCompleteSuccess] = useState(false)\n const [isSubscribeFormHidden, setIsSubscribeFormHidden] = useState(false)\n\n const currentView = viewStack[viewStack.length - 1] ?? null\n\n const isVisible = useMemo(() => {\n const config = copy.pageConfig\n if (!config) return true\n const pathname = typeof window !== 'undefined' ? window.location.pathname : ''\n const matches = config.pages.some(page => pathname === page || pathname.startsWith(page + '/'))\n switch (config.scope) {\n case MemberPopupPageScope.Include:\n return matches\n case MemberPopupPageScope.Exclude:\n return !matches\n default:\n return true\n }\n }, [copy.pageConfig])\n\n const pushView = useCallback((view: ViewPayload) => {\n setViewStack(prev => [...prev, view])\n }, [])\n\n const popView = useCallback(() => {\n setViewStack(prev => prev.slice(0, -1))\n }, [])\n\n console.log('isVisible', isVisible)\n if (!isVisible) return null\n\n function handleAction(type: MemberPopupActionType, url?: string) {\n switch (type) {\n case MemberPopupActionType.ExternalLink:\n if (url) window.open(url, '_blank', 'noopener,noreferrer')\n break\n case MemberPopupActionType.OpenEarnCredits:\n pushView({ type: MemberPopupPanelType.EarnCredits })\n break\n case MemberPopupActionType.OpenConsumeCredits:\n pushView({ type: MemberPopupPanelType.ConsumeCredits })\n break\n case MemberPopupActionType.OpenReferral:\n pushView({ type: MemberPopupPanelType.Referral })\n break\n case MemberPopupActionType.OpenSubscribe:\n pushView({ type: MemberPopupPanelType.Subscribe })\n break\n }\n }\n\n function handleClose() {\n setIsOpen(false)\n setViewStack([])\n setIsSubscribeFormHidden(false)\n }\n\n return (\n <ViewStackContext.Provider value={{ pushView, popView }}>\n {isOpen && <div className=\"fixed inset-0 z-[998]\" onClick={handleClose} />}\n <div\n className=\"fixed right-0 z-[999] flex flex-row items-end pr-[16px] md:flex-col md:items-end md:right-0 md:w-screen md:pr-0 md:pl-0\"\n style={{ bottom: bottomOffset }}\n >\n {isOpen && (\n <div\n className={cn(\n 'relative mr-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[500px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] md:mr-0 md:mb-[8px] md:mx-[16px] md:w-[calc(100vw-32px)] md:max-w-[400px]',\n rounded ? 'rounded-[12px]' : 'rounded-none'\n )}\n style={{ maxHeight: 'min(80vh, 606px)' }}\n onClick={e => e.stopPropagation()}\n >\n <div className=\"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white md:bottom-[-8px] md:left-auto md:right-[29px] md:top-auto md:border-x-8 md:border-b-transparent md:border-t-white\" />\n <div className=\"flex items-center justify-end pl-[10px] pr-[16px] pb-[8px] pt-[16px]\">\n {currentView !== null && (\n <button\n className=\"mr-auto flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={popView}\n aria-label=\"Back\"\n >\n <IconSwitch />\n </button>\n )}\n <button\n className=\"flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={handleClose}\n aria-label=\"Close\"\n >\n <IconClose />\n </button>\n </div>\n\n <div className=\"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]\">\n {currentView === null && (\n <>\n {(copy.title || copy.subtitle) && (\n <div className=\"flex flex-col gap-[4px]\">\n {copy.title && (\n <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>\n )}\n {copy.subtitle && (\n <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>\n )}\n </div>\n )}\n {copy.list.map((item, i) => (\n <HomeCard key={i} item={item} onAction={handleAction} rounded={rounded} />\n ))}\n </>\n )}\n\n {currentView !== null && (\n <Suspense\n fallback={\n <div className=\"flex 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 >\n {currentView.type === MemberPopupPanelType.EarnCredits && copy.earnCredits && (\n <EarnCredits\n copy={copy.earnCredits}\n onClose={popView}\n isSubscribeSuccess={isSubscribeSuccess}\n isActivateSuccess={isActivateSuccess}\n isProfileCompleteSuccess={isProfileCompleteSuccess}\n onSubscribeSuccess={() => setIsSubscribeSuccess(true)}\n onActivateSuccess={() => setIsActivateSuccess(true)}\n onProfileCompleteSuccess={() => setIsProfileCompleteSuccess(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.ConsumeCredits && copy.consumeCredits && (\n <ConsumeCredits\n copy={copy.consumeCredits}\n onClose={popView}\n isActivateSuccess={isActivateSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Referral && copy.referral && (\n <Referral copy={copy.referral} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.CompleteProfile && copy.earnCredits && (\n <CompleteProfile\n copy={copy.earnCredits.completeProfile}\n shopifyStoreDomain={storeDomain}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Subscribe && copy.activitiesSubscribe && (\n <ActivitiesSubscribe\n copy={copy.activitiesSubscribe}\n email={profile?.email}\n onSuccess={currentView.props?.onSuccess}\n hideForm={isSubscribeFormHidden}\n onHideForm={() => setIsSubscribeFormHidden(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.SubscribeEmail && copy.earnCredits && (\n <SubscribeEmail\n copy={copy.earnCredits.subscribe}\n email={profile?.email}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Activate && copy.earnCredits && (\n <Activate\n copy={copy.earnCredits.authCodeActivate}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.RedeemCoupon &&\n currentView.props &&\n copy.consumeCredits && (\n <RedeemCoupon\n itemTitle={currentView.props.itemTitle}\n itemCredits={currentView.props.itemCredits}\n itemImage={currentView.props.itemImage}\n itemValue={currentView.props.itemValue}\n itemOff={currentView.props.itemOff}\n itemRules={currentView.props.itemRules}\n redeemId={currentView.props.redeemId}\n userId={currentView.props.userId}\n alpcConfig={currentView.props.alpcConfig}\n copy={copy.consumeCredits.redeemModal}\n pointUnit={copy.consumeCredits.pointUnit}\n onClose={popView}\n />\n )}\n </Suspense>\n )}\n </div>\n\n {copy.footer && !isLogin && (\n <div className=\"border-t border-[#dadce0] p-[16px]\">\n <div className=\"flex items-center justify-between gap-[16px]\">\n <div className=\"flex items-center gap-[4px]\">\n <span className=\"text-[14px] font-[700] text-[#080a0f]\">{copy.footer.loginHint}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline\"\n onClick={openSignInPopup}\n >\n {copy.footer.loginLabel}\n </button>\n </div>\n <div className=\"flex shrink-0 items-center gap-[8px]\">\n <button\n className={cn(\n 'cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n onClick={openSignUpPopup}\n >\n {copy.footer.joinLabel}\n </button>\n </div>\n </div>\n </div>\n )}\n </div>\n )}\n\n <button\n className=\"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg md:ml-auto md:mr-[16px]\"\n onClick={() => setIsOpen(prev => !prev)}\n aria-label={copy.triggerImg.alt ?? 'Open member popup'}\n >\n <Picture source={copy.triggerImg.url} alt={copy.triggerImg.alt ?? ''} className=\"size-[58px]\" />\n </button>\n </div>\n </ViewStackContext.Provider>\n )\n}\n\ntype HomeCardProps = {\n item: MemberPopupItem\n onAction: (type: MemberPopupActionType, url?: string) => void\n rounded: boolean\n}\n\nfunction HomeCard({ item, onAction, rounded }: HomeCardProps) {\n const ACTION_ICON: Partial<Record<MemberPopupActionType, typeof IconCredit>> = {\n [MemberPopupActionType.OpenEarnCredits]: IconCredit,\n [MemberPopupActionType.OpenConsumeCredits]: IconBag,\n [MemberPopupActionType.OpenReferral]: IconReferral,\n [MemberPopupActionType.OpenSubscribe]: IconSubscription,\n }\n\n return (\n <div className={cn('flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <div className=\"flex flex-col gap-[4px]\">\n <h3 className=\"text-[20px] font-[700] leading-[1.2] text-[#1e2024]\">{item.title}</h3>\n {item.description && <p className=\"text-[14px] font-[700] leading-[1.43] text-[#1e2024]\">{item.description}</p>}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n {item.links.map((link, i) => {\n const IconComponent = ACTION_ICON[link.type]\n return (\n <div key={i}>\n {i > 0 && <div className=\"mb-[16px] h-px bg-[#dadce0]\" />}\n <button\n className=\"flex w-full cursor-pointer items-center gap-[12px]\"\n onClick={() => onAction(link.type, link.url)}\n >\n {IconComponent && <IconComponent className=\"size-[24px] shrink-0\" />}\n <span className=\"flex-1 text-left text-[14px] font-[700] text-[#1e2024]\">{link.label}</span>\n <IconArrow className=\"size-[16px] shrink-0\" />\n </button>\n </div>\n )\n })}\n </div>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": "ukBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,iBAAAE,KAAA,eAAAC,EAAAH,IAqCM,IAAAI,EAAA,6BAnCNC,EAA+D,iBAC/DC,EAAwB,iCACxBC,EAA0E,yBAC1EC,EAOO,kBACPC,EAAoC,8BACpCA,EAAsC,8BACtCC,EAAmD,+BACnDC,EAAsG,mBACtGC,EAA+B,2BAE/B,MAAMC,KAAc,QAAK,IAAM,OAAO,sBAAsB,CAAC,EACvDC,KAAiB,QAAK,IAAM,OAAO,yBAAyB,CAAC,EAC7DC,KAAW,QAAK,IAAM,OAAO,mBAAmB,CAAC,EACjDC,MAAkB,QAAK,IAAM,OAAO,2CAA2C,CAAC,EAChFC,MAAsB,QAAK,IAAM,OAAO,mCAAmC,CAAC,EAC5EC,MAAiB,QAAK,IAAM,OAAO,0CAA0C,CAAC,EAC9EC,MAAW,QAAK,IAAM,OAAO,oCAAoC,CAAC,EAClEC,MAAe,QAAK,IAAM,OAAO,2CAA2C,CAAC,EAQ5E,SAASlB,GAAY,CAAE,KAAAmB,EAAM,aAAAC,EAAe,OAAQ,GAAGC,CAAc,EAAqB,CAC/F,SACE,OAAC,uBAAqB,GAAGA,EAAe,gBAAiBF,EAAK,YAC5D,mBAACG,GAAA,CAAmB,KAAMH,EAAM,aAAcC,EAAc,EAC9D,CAEJ,CAOA,SAASE,GAAmB,CAAE,KAAAH,EA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wBAAsB,eAAe,EAAG,aACzC,CAAC,wBAAsB,kBAAkB,EAAG,UAC5C,CAAC,wBAAsB,YAAY,EAAG,eACtC,CAAC,wBAAsB,aAAa,EAAG,kBACzC,EAEA,SACE,QAAC,OAAI,aAAW,EAAAN,YAAG,iDAAkD5B,EAAU,gBAAkB,cAAc,EAC7G,qBAAC,OAAI,UAAU,0BACb,oBAAC,MAAG,UAAU,sDAAuD,SAAA8B,EAAK,MAAM,EAC/EA,EAAK,gBAAe,OAAC,KAAE,UAAU,uDAAwD,SAAAA,EAAK,YAAY,GAC7G,KAEA,OAAC,OAAI,UAAU,2BACZ,SAAAA,EAAK,MAAM,IAAI,CAACK,EAAMJ,IAAM,CAC3B,MAAMK,EAAgBF,EAAYC,EAAK,IAAI,EAC3C,SACE,QAAC,OACE,UAAAJ,EAAI,MAAK,OAAC,OAAI,UAAU,8BAA8B,KACvD,QAAC,UACC,UAAU,qDACV,QAAS,IAAME,EAASE,EAAK,KAAMA,EAAK,GAAG,EAE1C,UAAAC,MAAiB,OAACA,EAAA,CAAc,UAAU,uBAAuB,KAClE,OAAC,QAAK,UAAU,yDAA0D,SAAAD,EAAK,MAAM,KACrF,OAAC,aAAU,UAAU,uBAAuB,GAC9C,IATQJ,CAUV,CAEJ,CAAC,EACH,GACF,CAEJ",
|
|
6
|
+
"names": ["MemberPopup_exports", "__export", "MemberPopup", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_type", "import_provider", "import_viewStack", "import_icons", "import_constants", "EarnCredits", "ConsumeCredits", "Referral", "CompleteProfile", "ActivitiesSubscribe", "SubscribeEmail", "Activate", "RedeemCoupon", "copy", "bottomOffset", "providerProps", "MemberPopupContent", "profile", "openSignInPopup", "openSignUpPopup", "brand", "storeDomain", "rounded", "isLogin", "isOpen", "setIsOpen", "viewStack", "setViewStack", "isSubscribeSuccess", "setIsSubscribeSuccess", "isActivateSuccess", "setIsActivateSuccess", "isProfileCompleteSuccess", "setIsProfileCompleteSuccess", "isSubscribeFormHidden", "setIsSubscribeFormHidden", "currentView", "isVisible", "config", "pathname", "matches", "page", "pushView", "view", "prev", "popView", "handleAction", "type", "url", "handleClose", "cn", "e", "item", "i", "HomeCard", "onAction", "ACTION_ICON", "link", "IconComponent"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SubscribeModalCopy } from '../type';
|
|
2
|
+
type Props = {
|
|
3
|
+
onSuccess?: () => void;
|
|
4
|
+
copy: SubscribeModalCopy;
|
|
5
|
+
email?: string;
|
|
6
|
+
hideForm: boolean;
|
|
7
|
+
onHideForm: () => void;
|
|
8
|
+
};
|
|
9
|
+
export default function ActivitiesSubscribeModal({ onSuccess, copy, email: initialEmail, hideForm, onHideForm, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var j=Object.create;var m=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var q=(r,e)=>{for(var o in e)m(r,o,{get:e[o],enumerable:!0})},C=(r,e,o,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of F(e))!I.call(r,n)&&n!==o&&m(r,n,{get:()=>e[n],enumerable:!(u=E(e,n))||u.enumerable});return r};var J=(r,e,o)=>(o=r!=null?j(H(r)):{},C(e||!r||!r.__esModule?m(o,"default",{value:r,enumerable:!0}):o,r)),V=r=>C(m({},"__esModule",{value:!0}),r);var z={};q(z,{default:()=>T});module.exports=V(z);var t=require("react/jsx-runtime"),s=require("react"),a=require("@anker-in/headless-ui"),l=require("@anker-in/lib"),f=J(require("js-cookie")),M=require("query-string"),S=require("../../credits/context/utils"),k=require("../context/provider"),y=require("../../../constants");function X(){if(typeof window>"u")return{register_source:""};const{search:r,href:e}=window.location,o=(0,M.parse)(r);return{fbuy_ref_code:f.default.get("fbuy_ref_code"),ref:f.default.get("ref_ads"),inviter_code:o.ic??o.inviter_code??f.default.get("inviter_code"),register_source:o.redirect??f.default.get("reg_source")??e}}async function Z(r){if(typeof window>"u"||!window?.grecaptcha?.execute||!r)return"";try{return await window.grecaptcha.execute(r,{action:"activity"})}catch{return""}}function T({onSuccess:r,copy:e,email:o,hideForm:u,onHideForm:n}){const{alpcConfig:L}=(0,k.useMemberPopupContext)(),{locale:g}=L,{brand:P,storeDomain:h,recaptchaSitekey:A}=(0,l.useHeadlessContext)(),p=y.ROUNDED_BRANDS.includes(P),[x,B]=(0,s.useState)(!1),[d,v]=(0,s.useState)(o??""),[b,i]=(0,s.useState)(""),[D,_]=(0,s.useState)(""),[R,w]=(0,s.useState)(!1);(0,s.useEffect)(()=>{o&&v(o)},[o]);const O=(0,s.useCallback)(async()=>{if(i(""),!d)return i("Please fill in your email");if(!(0,S.emailValidate)(d))return i("Invalid email address");if(!x)return i("Please agree to the policy");w(!0);const{register_source:c}=X(),U=await Z(A||"");try{const N=await(await fetch("/api/multipass/rainbowbridge/activities",{method:"POST",headers:{"Content-Type":"application/json","current-language":g,"X-Recaptcha-Token":U},body:JSON.stringify({email:d,register_source:c,shopify_domain:h,single_brand_subscribe:e.single_brand_subscribe??!0,genre:e.genre??e.dealsType??"",sub_brand_type:e.sub_brand_type??""})})).json();N.errors?i(N.errors??"Error occurred"):(_(e.successTips??"Subscribed successfully!"),r?.(),setTimeout(()=>{n(),_("")},3e3))}catch{i("Network error")}finally{w(!1)}},[d,x,g,h,e,r,n]);return(0,t.jsxs)("div",{className:"flex flex-col gap-[16px] text-center",children:[!u&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(a.Text,{className:"text-[22px] font-bold",html:e.title}),e.desc&&(0,t.jsx)(a.Text,{className:"text-left text-[16px] font-semibold text-[#1f2021]",html:e.desc}),(0,t.jsx)("input",{className:(0,l.classNames)("h-[46px] w-full border px-[14px] text-[16px] outline-none placeholder:text-[#999]",b?"border-[#f84d4f]":"border-[#d8d8d8]",p?"rounded-[4px]":"rounded-none"),placeholder:e.placeholder,value:d,onChange:c=>{i(""),v(c.target.value.trim())}}),(0,t.jsxs)("div",{className:"flex w-full items-start gap-[8px]",children:[(0,t.jsx)(a.Checkbox,{checked:x,onCheckedChange:()=>B(c=>!c),className:"border-[#1d1d1f]"}),(0,t.jsx)("label",{className:"text-left text-[14px] font-semibold text-[#777] [&_a]:underline",dangerouslySetInnerHTML:{__html:e.policy??""}})]}),(0,t.jsx)("button",{className:(0,l.classNames)("w-full cursor-pointer bg-[#080a0f] py-[14px] text-[14px] font-[700] text-white disabled:opacity-60",p?"rounded-[4px]":"rounded-none"),disabled:R,onClick:O,children:e.buttonLabel??"Subscribe"}),b&&(0,t.jsx)("div",{className:"text-left text-[16px] font-semibold text-[#f84d4f]",children:(0,t.jsx)(a.Text,{html:b})}),(0,t.jsx)("div",{className:"text-left text-[16px] font-semibold text-[#52c41a]",children:(0,t.jsx)(a.Text,{html:D})})]}),e.promo&&(0,t.jsxs)("div",{className:"flex flex-col text-left",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-[8px]",children:[e.promo?.title&&(0,t.jsx)("h3",{className:"text-[20px] font-[700] leading-[1.2] text-[#080a0f]",children:e.promo?.title}),e.promo.description&&(0,t.jsx)("p",{className:"text-[14px] leading-[1.5] text-[#1e2024]",children:e.promo.description}),e.promo.learnMoreLabel&&e.promo.learnMoreUrl&&(0,t.jsxs)("a",{href:e.promo.learnMoreUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-[4px] text-[14px] font-[700] text-[#080a0f] underline",children:[e.promo.learnMoreLabel,(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:(0,t.jsx)("path",{d:"M5.52827 3.52876C5.78862 3.26841 6.21063 3.26841 6.47098 3.52876L10.471 7.52876C10.7313 7.78911 10.7313 8.21112 10.471 8.47147L6.47098 12.4715C6.21063 12.7318 5.78862 12.7318 5.52827 12.4715C5.26792 12.2111 5.26792 11.7891 5.52827 11.5288L9.05692 8.00011L5.52827 4.47147C5.26792 4.21112 5.26792 3.78911 5.52827 3.52876Z",fill:"#080A0F"})})]})]}),e.promo.image?.url&&(0,t.jsx)(a.Picture,{source:e.promo.image.url,alt:e.promo.image.alt??"",className:(0,l.classNames)("h-[100px] mt-[8px] w-full object-cover",p?"rounded-[8px]":"rounded-none")})]})]})}
|
|
2
|
+
//# sourceMappingURL=ActivitiesSubscribePanel.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/components/memberPopup/panels/ActivitiesSubscribePanel.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Button, Checkbox, Picture, Text } from '@anker-in/headless-ui'\nimport { classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport Cookies from 'js-cookie'\nimport { parse } from 'query-string'\nimport { emailValidate } from '../../credits/context/utils'\nimport { useMemberPopupContext } from '../context/provider'\nimport type { SubscribeModalCopy } from '../type'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\ntype Props = {\n onSuccess?: () => void\n copy: SubscribeModalCopy\n email?: string\n hideForm: boolean\n onHideForm: () => void\n}\n\nfunction getAdCookie() {\n if (typeof window === 'undefined') return { register_source: '' }\n const { search, href } = window.location\n const query = parse(search)\n return {\n fbuy_ref_code: Cookies.get('fbuy_ref_code'),\n ref: Cookies.get('ref_ads'),\n inviter_code: query.ic ?? query.inviter_code ?? Cookies.get('inviter_code'),\n register_source: query.redirect ?? Cookies.get('reg_source') ?? href,\n }\n}\n\nasync function getRecaptchaToken(sitekey: string): Promise<string> {\n if (typeof window === 'undefined' || !window?.grecaptcha?.execute) return ''\n if (!sitekey) return ''\n try {\n return await window.grecaptcha.execute(sitekey, { action: 'activity' })\n } catch {\n return ''\n }\n}\n\nexport default function ActivitiesSubscribeModal({\n onSuccess,\n copy,\n email: initialEmail,\n hideForm,\n onHideForm,\n}: Props) {\n const { alpcConfig } = useMemberPopupContext()\n const { locale } = alpcConfig\n const { brand: headlessBrand, storeDomain, recaptchaSitekey } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(headlessBrand)\n const [policy, setPolicy] = useState(false)\n const [email, setEmail] = useState(initialEmail ?? '')\n const [errorMessage, setErrorMessage] = useState('')\n const [successMessage, setSuccessMessage] = useState('')\n const [loading, setLoading] = useState(false)\n\n useEffect(() => {\n if (initialEmail) setEmail(initialEmail)\n }, [initialEmail])\n\n const handleSubmit = useCallback(async () => {\n setErrorMessage('')\n if (!email) return setErrorMessage('Please fill in your email')\n if (!emailValidate(email)) return setErrorMessage('Invalid email address')\n if (!policy) return setErrorMessage('Please agree to the policy')\n\n setLoading(true)\n const { register_source } = getAdCookie()\n const recaptchaToken = await getRecaptchaToken(recaptchaSitekey || '')\n try {\n const response = await fetch('/api/multipass/rainbowbridge/activities', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'current-language': locale,\n 'X-Recaptcha-Token': recaptchaToken,\n },\n body: JSON.stringify({\n email,\n register_source,\n shopify_domain: storeDomain,\n single_brand_subscribe: copy.single_brand_subscribe ?? true,\n genre: copy.genre ?? copy.dealsType ?? '',\n sub_brand_type: copy.sub_brand_type ?? '',\n }),\n })\n const result = await response.json()\n if (!result.errors) {\n setSuccessMessage(copy.successTips ?? 'Subscribed successfully!')\n onSuccess?.()\n setTimeout(() => {\n onHideForm()\n setSuccessMessage('')\n }, 3000)\n } else {\n setErrorMessage(result.errors ?? 'Error occurred')\n }\n } catch {\n setErrorMessage('Network error')\n } finally {\n setLoading(false)\n }\n }, [email, policy, locale, storeDomain, copy, onSuccess, onHideForm])\n\n return (\n <div className=\"flex flex-col gap-[16px] text-center\">\n {!hideForm && (\n <>\n <Text className=\"text-[22px] font-bold\" html={copy.title} />\n {copy.desc && <Text className=\"text-left text-[16px] font-semibold text-[#1f2021]\" html={copy.desc} />}\n\n <input\n className={cn(\n 'h-[46px] w-full border px-[14px] text-[16px] outline-none placeholder:text-[#999]',\n errorMessage ? 'border-[#f84d4f]' : 'border-[#d8d8d8]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n placeholder={copy.placeholder}\n value={email}\n onChange={e => {\n setErrorMessage('')\n setEmail(e.target.value.trim())\n }}\n />\n\n <div className=\"flex w-full items-start gap-[8px]\">\n <Checkbox checked={policy} onCheckedChange={() => setPolicy(v => !v)} className=\"border-[#1d1d1f]\" />\n <label\n className=\"text-left text-[14px] font-semibold text-[#777] [&_a]:underline\"\n dangerouslySetInnerHTML={{ __html: copy.policy ?? '' }}\n />\n </div>\n\n <button\n className={cn(\n 'w-full cursor-pointer bg-[#080a0f] py-[14px] text-[14px] font-[700] text-white disabled:opacity-60',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={loading}\n onClick={handleSubmit}\n >\n {copy.buttonLabel ?? 'Subscribe'}\n </button>\n\n {errorMessage && (\n <div className=\"text-left text-[16px] font-semibold text-[#f84d4f]\">\n <Text html={errorMessage} />\n </div>\n )}\n <div className=\"text-left text-[16px] font-semibold text-[#52c41a]\">\n <Text html={successMessage} />\n </div>\n </>\n )}\n\n {copy.promo && (\n <div className=\"flex flex-col text-left\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.promo?.title && (\n <h3 className=\"text-[20px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.promo?.title}</h3>\n )}\n {copy.promo.description && (\n <p className=\"text-[14px] leading-[1.5] text-[#1e2024]\">{copy.promo.description}</p>\n )}\n {copy.promo.learnMoreLabel && copy.promo.learnMoreUrl && (\n <a\n href={copy.promo.learnMoreUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"flex items-center gap-[4px] text-[14px] font-[700] text-[#080a0f] underline\"\n >\n {copy.promo.learnMoreLabel}\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\">\n <path\n d=\"M5.52827 3.52876C5.78862 3.26841 6.21063 3.26841 6.47098 3.52876L10.471 7.52876C10.7313 7.78911 10.7313 8.21112 10.471 8.47147L6.47098 12.4715C6.21063 12.7318 5.78862 12.7318 5.52827 12.4715C5.26792 12.2111 5.26792 11.7891 5.52827 11.5288L9.05692 8.00011L5.52827 4.47147C5.26792 4.21112 5.26792 3.78911 5.52827 3.52876Z\"\n fill=\"#080A0F\"\n />\n </svg>\n </a>\n )}\n </div>\n {copy.promo.image?.url && (\n <Picture\n source={copy.promo.image.url}\n alt={copy.promo.image.alt ?? ''}\n className={cn('h-[100px] mt-[8px] w-full object-cover', rounded ? 'rounded-[8px]' : 'rounded-none')}\n />\n )}\n </div>\n )}\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GA4GQ,IAAAI,EAAA,6BA5GRC,EAAiD,iBACjDC,EAAgD,iCAChDC,EAAqD,yBACrDC,EAAoB,wBACpBC,EAAsB,wBACtBC,EAA8B,uCAC9BC,EAAsC,+BAEtCC,EAA+B,8BAU/B,SAASC,GAAc,CACrB,GAAI,OAAO,OAAW,IAAa,MAAO,CAAE,gBAAiB,EAAG,EAChE,KAAM,CAAE,OAAAC,EAAQ,KAAAC,CAAK,EAAI,OAAO,SAC1BC,KAAQ,SAAMF,CAAM,EAC1B,MAAO,CACL,cAAe,EAAAG,QAAQ,IAAI,eAAe,EAC1C,IAAK,EAAAA,QAAQ,IAAI,SAAS,EAC1B,aAAcD,EAAM,IAAMA,EAAM,cAAgB,EAAAC,QAAQ,IAAI,cAAc,EAC1E,gBAAiBD,EAAM,UAAY,EAAAC,QAAQ,IAAI,YAAY,GAAKF,CAClE,CACF,CAEA,eAAeG,EAAkBC,EAAkC,CAEjE,GADI,OAAO,OAAW,KAAe,CAAC,QAAQ,YAAY,SACtD,CAACA,EAAS,MAAO,GACrB,GAAI,CACF,OAAO,MAAM,OAAO,WAAW,QAAQA,EAAS,CAAE,OAAQ,UAAW,CAAC,CACxE,MAAQ,CACN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ACZ,UAAAA,EAAK,OAAO,UACX,OAAC,MAAG,UAAU,sDAAuD,SAAAA,EAAK,OAAO,MAAM,EAExFA,EAAK,MAAM,gBACV,OAAC,KAAE,UAAU,2CAA4C,SAAAA,EAAK,MAAM,YAAY,EAEjFA,EAAK,MAAM,gBAAkBA,EAAK,MAAM,iBACvC,QAAC,KACC,KAAMA,EAAK,MAAM,aACjB,OAAO,SACP,IAAI,sBACJ,UAAU,8EAET,UAAAA,EAAK,MAAM,kBACZ,OAAC,OAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OACnD,mBAAC,QACC,EAAE,kUACF,KAAK,UACP,EACF,GACF,GAEJ,EACCA,EAAK,MAAM,OAAO,QACjB,OAAC,WACC,OAAQA,EAAK,MAAM,MAAM,IACzB,IAAKA,EAAK,MAAM,MAAM,KAAO,GAC7B,aAAW,EAAAwB,YAAG,yCAA0Cf,EAAU,gBAAkB,cAAc,EACpG,GAEJ,GAEJ,CAEJ",
|
|
6
|
+
"names": ["ActivitiesSubscribePanel_exports", "__export", "ActivitiesSubscribeModal", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_js_cookie", "import_query_string", "import_utils", "import_provider", "import_constants", "getAdCookie", "search", "href", "query", "Cookies", "getRecaptchaToken", "sitekey", "onSuccess", "copy", "initialEmail", "hideForm", "onHideForm", "alpcConfig", "locale", "headlessBrand", "storeDomain", "recaptchaSitekey", "rounded", "policy", "setPolicy", "email", "setEmail", "errorMessage", "setErrorMessage", "successMessage", "setSuccessMessage", "loading", "setLoading", "handleSubmit", "register_source", "recaptchaToken", "result", "cn", "e", "v"]
|
|
7
|
+
}
|
|
@@ -9,6 +9,7 @@ type Props = {
|
|
|
9
9
|
};
|
|
10
10
|
itemValue?: string;
|
|
11
11
|
itemOff?: string;
|
|
12
|
+
itemRules?: string[];
|
|
12
13
|
redeemId: number;
|
|
13
14
|
userId?: string;
|
|
14
15
|
copy: RedeemCouponModalCopy;
|
|
@@ -16,5 +17,5 @@ type Props = {
|
|
|
16
17
|
alpcConfig: AlpcConfig;
|
|
17
18
|
onError?: (code: number) => void;
|
|
18
19
|
};
|
|
19
|
-
export default function RedeemCouponPanel({ onClose, itemTitle, itemCredits, itemImage, itemValue, itemOff, redeemId, userId, copy, pointUnit, alpcConfig, onError, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
export default function RedeemCouponPanel({ onClose, itemTitle, itemCredits, itemImage, itemValue, itemOff, itemRules, redeemId, userId, copy, pointUnit, alpcConfig, onError, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
20
21
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
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 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 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
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,
|
|
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", "redeemId", "userId", "copy", "pointUnit", "alpcConfig", "onError", "couponCode", "setCouponCode", "errorInfo", "setErrorInfo", "disabled", "setDisabled", "copyText", "copied", "useCopy", "brand", "rounded", "loading", "trigger", "handleConfirm", "data", "msg", "cn"]
|
|
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,iCAC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,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
|
+
"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
|
}
|
|
@@ -2,6 +2,7 @@ import { type ConsumeCreditsopy } from '../../type';
|
|
|
2
2
|
type Props = {
|
|
3
3
|
copy: ConsumeCreditsopy;
|
|
4
4
|
onClose: () => void;
|
|
5
|
+
isActivateSuccess: boolean;
|
|
5
6
|
};
|
|
6
|
-
declare function ConsumeCredits({ copy, onClose }: Props): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
declare function ConsumeCredits({ copy, isActivateSuccess, onClose }: Props): import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export default ConsumeCredits;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var y=Object.defineProperty;var
|
|
1
|
+
"use strict";var y=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var J=(a,s)=>{for(var u in s)y(a,u,{get:s[u],enumerable:!0})},K=(a,s,u,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of H(s))!q.call(a,i)&&i!==u&&y(a,i,{get:()=>s[i],enumerable:!(l=G(s,i))||l.enumerable});return a};var Q=a=>K(y({},"__esModule",{value:!0}),a);var Y={};J(Y,{default:()=>X});module.exports=Q(Y);var t=require("react/jsx-runtime"),x=require("react"),v=require("@anker-in/headless-ui"),o=require("@anker-in/lib"),B=require("../../context/provider"),D=require("../../context/viewStack"),A=require("./hooks/useRedeemableList"),U=require("./hooks/useRedeemAndBuy"),n=require("../../type"),m=require("../../../credits/context/utils"),S=require("../../../../constants");function W({copy:a,isActivateSuccess:s,onClose:u}){const{profile:l,creditInfo:i,openSignUpPopup:L,alpcConfig:b}=(0,B.useMemberPopupContext)(),{pushView:I}=(0,D.useViewStack)(),{brand:M}=(0,o.useHeadlessContext)(),N=S.ROUNDED_BRANDS.includes(M),[P,R]=(0,x.useState)(""),[O,k]=(0,x.useState)(null),c=!!l,{redeemableList:w,listLoading:E}=(0,A.useRedeemableList)(b),{trigger:$}=(0,U.useRedeemAndBuy)(b),z=a.list.map(e=>e.product?.handle).filter(Boolean),{data:_}=(0,o.useProductsByHandles)({handles:z}),F=(0,x.useMemo)(()=>a.list.map(e=>{const r=w.find(f=>String(f.id)===String(e.redeemId));if(!r)return null;const d=Number(i?.available_credit??0),C=c&&!!l?.activated&&r.consume_credits>d,g=r.is_limited&&(!r.remaining_inventory||r.remaining_inventory<=0);let p,h;return(e.type===n.ConsumeCreditsItemType.RedeemAndBuy||e.type===n.ConsumeCreditsItemType.Product)&&e.product&&(p=_?.find(f=>f.handle===e.product.handle),h=p?.variants?.find(f=>f.sku===e.product.sku)??p?.variants?.[0],e.type===n.ConsumeCreditsItemType.RedeemAndBuy&&(!p||!h))?null:{...e,alpcData:r,insufficient:C,soldOut:g,product:p,variant:h}}).filter(Boolean),[a.list,w,i,l,c,_]);function T(e){return c?e.soldOut?a.soldOut:a.btnRedeem:a.unlockRewards}function V(e){return e.type===n.ConsumeCreditsItemType.GiftCard||e.type===n.ConsumeCreditsItemType.Product?e.insufficient:e.soldOut||e.insufficient}async function j(e){if(!c){L();return}if(!l?.activated&&!s){I({type:n.MemberPopupPanelType.Activate,props:{}});return}if(e.type===n.ConsumeCreditsItemType.GiftCard||e.type===n.ConsumeCreditsItemType.Product){a.creditsPage?.url&&window.open(a.creditsPage.url,"_blank","noopener,noreferrer");return}if(e.type===n.ConsumeCreditsItemType.Coupon)I({type:n.MemberPopupPanelType.RedeemCoupon,props:{itemTitle:e.title,itemCredits:e.alpcData.consume_credits,itemImage:a.imageMapping?.[e.type]?{url:a.imageMapping[e.type].url,alt:e.image?.alt}:e.image,itemValue:e.value,itemOff:a.off,itemRules:e.rules,redeemId:Number(e.redeemId),userId:l?.user_id,alpcConfig:b}});else{R(""),k(e.redeemId);try{await $({productVariant:e.variant,redeemId:Number(e.redeemId),userId:l?.user_id})}catch(r){R(r?.message??a.redeemModal.commonError)}finally{k(null)}}}return(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[12px]",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-[8px]",children:[a.title&&(0,t.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:a.title}),a.subtitle&&(0,t.jsx)("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:a.subtitle})]}),c&&(0,t.jsxs)("div",{className:(0,o.classNames)("flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]",N?"rounded-[8px]":"rounded-none"),children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,t.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:a.balanceLabel??"AnkerCredits Balance"}),(0,t.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,t.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,m.numberFormat)(i?.available_credit||0)}),(0,t.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:a.creditUnit??a.pointUnit??"ankercredits"})]})]}),(0,t.jsx)("div",{className:"h-full w-px bg-[#dadce0]"}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,t.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:a.comingSoonLabel??"Coming Soon"}),(0,t.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,t.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,m.numberFormat)(i?.pending_credit||0)}),(0,t.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:a.creditUnit??a.pointUnit??"ankercredits"}),(0,t.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:a.creditUnit??"ankercredits"})]})]})]}),P&&(0,t.jsx)("div",{className:"text-[14px] font-[700] text-[#f84d4f]",children:P}),E?(0,t.jsx)("div",{className:"flex flex-1 items-center justify-center py-[32px]",children:(0,t.jsx)("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}):(0,t.jsx)("div",{className:"flex flex-col",children:F.map((e,r)=>{const d=!!e.product;return(0,t.jsxs)("div",{className:"relative py-[16px]",children:[r>0&&(0,t.jsx)("div",{className:"absolute inset-x-0 top-0 h-px bg-[#dadce0]"}),(0,t.jsxs)("div",{className:"flex items-center gap-[12px]",children:[(()=>{const C=a.imageMapping?.[e.type]?.url,g=d?e.variant?.image?.url??e.product?.images?.[0]?.url??e.image?.url:C??e.image?.url,p=d?e.variant?.image?.altText??e.product?.images?.[0]?.alt??e.image?.alt??"":e.image?.alt??"";return g?(0,t.jsxs)("div",{className:(0,o.classNames)("relative size-[64px] shrink-0 overflow-hidden",N?"rounded-[4px]":"rounded-none"),children:[(0,t.jsx)(v.Picture,{source:g,alt:p,className:"flex size-full items-center justify-center",imgClassName:d?"object-cover":"h-full w-auto object-contain"}),!d&&e.value&&(0,t.jsxs)("div",{className:"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white",children:[e.value," ",a.off]})]}):null})(),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("div",{className:"text-[16px] font-[700] text-[#1e2024] line-clamp-2",children:d&&e.product?.title?e.product.title:e.title}),(0,t.jsx)("div",{className:"mt-[4px] text-[14px] text-[#666]",children:d&&e.price!=null?`${(0,m.numberFormat)(e.alpcData.consume_credits)} ${a.pointUnit??""} + $${Number(e.price).toFixed(2)}`:`${(0,m.numberFormat)(e.alpcData.consume_credits)} ${a.pointUnit??""}`})]}),(0,t.jsxs)("div",{className:"relative group",children:[(0,t.jsx)(v.Button,{className:(0,o.classNames)("bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",N?"rounded-[4px]":"rounded-none"),disabled:V(e),loading:O===e.redeemId,onClick:()=>j(e),children:T(e)}),e.insufficient&&(0,t.jsx)("div",{className:"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block",children:(0,t.jsxs)("div",{className:"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow",children:[(0,t.jsx)("p",{className:"text-pretty tracking-[-0.02em] text-[14px]",children:a.insufficientCredits}),(0,t.jsx)("div",{className:"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]"})]})})]})]})]},r)})}),a.creditsPage?.url&&(0,t.jsx)("a",{href:a.creditsPage.url,target:"_blank",rel:"noopener noreferrer",className:"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline",children:a.creditsPage.label??"Go to Credits Page"})]})})}var X=W;
|
|
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 (item.type === ConsumeCreditsItemType.RedeemAndBuy && item.product) {\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 (!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 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 (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 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 <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 isRedeemAndBuy = item.type === ConsumeCreditsItemType.RedeemAndBuy\n const mappedImgUrl = copy.imageMapping?.[item.type]?.url\n const imgUrl = isRedeemAndBuy\n ? (item.variant?.image?.url ?? item.product?.images?.[0]?.url ?? item.image?.url)\n : (mappedImgUrl ?? item.image?.url)\n const imgAlt = isRedeemAndBuy\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={isRedeemAndBuy ? 'object-cover' : 'h-full w-auto object-contain'}\n />\n {!isRedeemAndBuy && 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 {item.type === ConsumeCreditsItemType.RedeemAndBuy && item.product?.title\n ? item.product.title\n : item.title}\n </div>\n <div className=\"mt-[4px] text-[14px] text-[#666]\">\n {item.type === ConsumeCreditsItemType.RedeemAndBuy && 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 left-[48px] top-full mt-[10px] hidden -translate-x-1/2 group-hover:block\">\n <div className=\"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow md:px-[10px] md:py-[8px]\">\n <p className=\"text-pretty tracking-[-0.02em] text-[14px]\">{copy.insufficientCredits}</p>\n <div className=\"absolute -top-[8px] left-[48px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]\" />\n </div>\n </div>\n )}\n </div>\n </div>\n </div>\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
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,
|
|
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", "
|
|
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 isActivateSuccess: boolean\n}\n\nfunction ConsumeCredits({ copy, isActivateSuccess, 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 || 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 (item.type === ConsumeCreditsItemType.GiftCard || item.type === ConsumeCreditsItemType.Product) {\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 && !isActivateSuccess) {\n pushView({\n type: MemberPopupPanelType.Activate,\n props: {},\n })\n return\n }\n if (item.type === ConsumeCreditsItemType.GiftCard || item.type === ConsumeCreditsItemType.Product) {\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 {isLogin && (\n <div\n className={cn(\n 'flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]',\n rounded ? 'rounded-[8px]' : 'rounded-none'\n )}\n >\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.balanceLabel ?? 'AnkerCredits Balance'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.available_credit || 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? copy.pointUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n <div className=\"h-full w-px bg-[#dadce0]\" />\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.comingSoonLabel ?? 'Coming Soon'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.pending_credit || 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? copy.pointUnit ?? 'ankercredits'}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n </div>\n )}\n {redeemAndBuyError && <div className=\"text-[14px] 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\n className={cn(\n 'relative size-[64px] shrink-0 overflow-hidden',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n >\n <Picture\n source={imgUrl}\n alt={imgAlt}\n className=\"flex size-full items-center justify-center\"\n imgClassName={hasProduct ? 'object-cover' : 'h-full w-auto object-contain'}\n />\n {!hasProduct && item.value && (\n <div className=\"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white\">\n {item.value} {copy.off}\n </div>\n )}\n </div>\n )\n })()}\n <div className=\"min-w-0 flex-1\">\n <div className=\"text-[16px] font-[700] text-[#1e2024] line-clamp-2\">\n {hasProduct && item.product?.title ? item.product.title : item.title}\n </div>\n <div className=\"mt-[4px] text-[14px] text-[#666]\">\n {hasProduct && item.price != null\n ? `${numberFormat(item.alpcData.consume_credits)} ${copy.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(\n 'bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={isDisabled(item)}\n loading={loadingId === item.redeemId}\n onClick={() => handleRedeem(item)}\n >\n {getButtonLabel(item)}\n </Button>\n {item.insufficient && (\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
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GA2II,IAAAI,EAAA,6BA3IJC,EAAkC,iBAClCC,EAAgC,iCAChCC,EAA2E,yBAC3EC,EAAsC,kCACtCC,EAA6B,mCAC7BC,EAAkC,qCAClCC,EAAgC,mCAChCC,EAKO,sBACPC,EAA6B,0CAE7BC,EAA+B,iCAgB/B,SAASC,EAAe,CAAE,KAAAC,EAAM,kBAAAC,EAAmB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,WAAa,EAAE,GAC5E,GACF,KACA,QAAC,OAAI,UAAU,iBACb,oBAAC,UACC,aAAW,EAAAmC,YACT,6FACA1B,EAAU,gBAAkB,cAC9B,EACA,SAAUuB,EAAWb,CAAI,EACzB,QAASP,IAAcO,EAAK,SAC5B,QAAS,IAAMc,EAAad,CAAI,EAE/B,SAAAY,EAAeZ,CAAI,EACtB,EACCA,EAAK,iBACJ,OAAC,OAAI,UAAU,qGACb,oBAAC,OAAI,UAAU,0EACb,oBAAC,KAAE,UAAU,6CAA8C,SAAAnB,EAAK,oBAAoB,KACpF,OAAC,OAAI,UAAU,oGAAoG,GACrH,EACF,GAEJ,GACF,IAhEQoC,CAiEV,CAEJ,CAAC,EACH,EAGDpC,EAAK,aAAa,QACjB,OAAC,KACC,KAAMA,EAAK,YAAY,IACvB,OAAO,SACP,IAAI,sBACJ,UAAU,qEAET,SAAAA,EAAK,YAAY,OAAS,qBAC7B,GAEJ,EACF,CAEJ,CAEA,IAAOd,EAAQa",
|
|
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", "isActivateSuccess", "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", "cn", "idx", "hasProduct", "mappedImgUrl", "imgUrl", "imgAlt"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SubscribeModalCopy } from '../../type';
|
|
2
|
+
type Props = {
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
onSuccess?: () => void;
|
|
5
|
+
copy: SubscribeModalCopy;
|
|
6
|
+
email?: string;
|
|
7
|
+
hideForm: boolean;
|
|
8
|
+
onHideForm: () => void;
|
|
9
|
+
};
|
|
10
|
+
export default function ActivitiesSubscribeModal({ onClose, onSuccess, copy, email: initialEmail, hideForm, onHideForm }: Props): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|