@anker-in/campaign-ui 0.5.0-beta.17 → 0.5.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/memberPopup/MemberPopup.js +1 -1
- package/dist/cjs/components/memberPopup/MemberPopup.js.map +1 -1
- package/dist/cjs/components/memberPopup/context/provider.d.ts +3 -3
- package/dist/cjs/components/memberPopup/context/provider.js +1 -1
- package/dist/cjs/components/memberPopup/context/provider.js.map +2 -2
- package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.js +1 -1
- package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +2 -2
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.js +1 -1
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.js.map +3 -3
- package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js +1 -1
- package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js.map +3 -3
- package/dist/cjs/components/memberPopup/type.d.ts +5 -3
- package/dist/cjs/components/memberPopup/type.js +1 -1
- package/dist/cjs/components/memberPopup/type.js.map +1 -1
- package/dist/esm/components/memberPopup/MemberPopup.js +1 -1
- package/dist/esm/components/memberPopup/MemberPopup.js.map +1 -1
- package/dist/esm/components/memberPopup/context/provider.d.ts +3 -3
- package/dist/esm/components/memberPopup/context/provider.js +1 -1
- package/dist/esm/components/memberPopup/context/provider.js.map +2 -2
- package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js +1 -1
- package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +2 -2
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.js +1 -1
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.js.map +3 -3
- package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js +1 -1
- package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js.map +3 -3
- package/dist/esm/components/memberPopup/type.d.ts +5 -3
- package/dist/esm/components/memberPopup/type.js +1 -1
- package/dist/esm/components/memberPopup/type.js.map +1 -1
- package/package.json +1 -1
- package/src/components/memberPopup/MemberPopup.tsx +1 -1
- package/src/components/memberPopup/context/provider.tsx +2 -2
- package/src/components/memberPopup/panels/ActivitiesSubscribePanel.tsx +3 -3
- package/src/components/memberPopup/panels/ConsumeCredits/index.tsx +16 -9
- package/src/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.tsx +2 -1
- package/src/components/memberPopup/type.ts +6 -3
- package/dist/cjs/components/memberPopup/panels/Activity/SubscribeModal.d.ts +0 -10
- package/dist/cjs/components/memberPopup/panels/Activity/SubscribeModal.js +0 -2
- package/dist/cjs/components/memberPopup/panels/Activity/SubscribeModal.js.map +0 -7
- package/dist/cjs/components/memberPopup/panels/Activity/hooks/useActivitySubscribe.d.ts +0 -7
- package/dist/cjs/components/memberPopup/panels/Activity/hooks/useActivitySubscribe.js +0 -2
- package/dist/cjs/components/memberPopup/panels/Activity/hooks/useActivitySubscribe.js.map +0 -7
- package/dist/cjs/components/memberPopup/panels/Activity/index.d.ts +0 -7
- package/dist/cjs/components/memberPopup/panels/Activity/index.js +0 -2
- package/dist/cjs/components/memberPopup/panels/Activity/index.js.map +0 -7
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponModal.d.ts +0 -19
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponModal.js +0 -2
- package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponModal.js.map +0 -7
- package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.d.ts +0 -11
- package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js +0 -2
- package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js.map +0 -7
- package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeModal.d.ts +0 -10
- package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeModal.js +0 -2
- package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeModal.js.map +0 -7
- package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribePanel.d.ts +0 -9
- package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribePanel.js +0 -2
- package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribePanel.js.map +0 -7
- package/dist/cjs/components/memberPopup/panels/Referral/hooks/useReferralDashboard.d.ts +0 -13
- package/dist/cjs/components/memberPopup/panels/Referral/hooks/useReferralDashboard.js +0 -2
- package/dist/cjs/components/memberPopup/panels/Referral/hooks/useReferralDashboard.js.map +0 -7
- package/dist/esm/components/memberPopup/panels/Activity/SubscribeModal.d.ts +0 -10
- package/dist/esm/components/memberPopup/panels/Activity/SubscribeModal.js +0 -2
- package/dist/esm/components/memberPopup/panels/Activity/SubscribeModal.js.map +0 -7
- package/dist/esm/components/memberPopup/panels/Activity/hooks/useActivitySubscribe.d.ts +0 -7
- package/dist/esm/components/memberPopup/panels/Activity/hooks/useActivitySubscribe.js +0 -2
- package/dist/esm/components/memberPopup/panels/Activity/hooks/useActivitySubscribe.js.map +0 -7
- package/dist/esm/components/memberPopup/panels/Activity/index.d.ts +0 -7
- package/dist/esm/components/memberPopup/panels/Activity/index.js +0 -2
- package/dist/esm/components/memberPopup/panels/Activity/index.js.map +0 -7
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponModal.d.ts +0 -19
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponModal.js +0 -2
- package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponModal.js.map +0 -7
- package/dist/esm/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.d.ts +0 -11
- package/dist/esm/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js +0 -2
- package/dist/esm/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js.map +0 -7
- package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeModal.d.ts +0 -10
- package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeModal.js +0 -2
- package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeModal.js.map +0 -7
- package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribePanel.d.ts +0 -9
- package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribePanel.js +0 -2
- package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribePanel.js.map +0 -7
- package/dist/esm/components/memberPopup/panels/Referral/hooks/useReferralDashboard.d.ts +0 -13
- package/dist/esm/components/memberPopup/panels/Referral/hooks/useReferralDashboard.js +0 -2
- package/dist/esm/components/memberPopup/panels/Referral/hooks/useReferralDashboard.js.map +0 -7
- package/dist/index.d.mts +0 -1775
- package/dist/index.d.ts +0 -1775
- package/dist/index.js +0 -18542
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -18514
- package/dist/index.mjs.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";"use client";var R=Object.create;var h=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var B=(e,n)=>{for(var i in n)h(e,i,{get:n[i],enumerable:!0})},M=(e,n,i,d)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of H(n))!j.call(e,s)&&s!==i&&h(e,s,{get:()=>n[s],enumerable:!(d=z(n,s))||d.enumerable});return e};var x=(e,n,i)=>(i=e!=null?R(T(e)):{},M(n||!e||!e.__esModule?h(i,"default",{value:e,enumerable:!0}):i,e)),L=e=>M(h({},"__esModule",{value:!0}),e);var Z={};B(Z,{MemberPopup:()=>Q});module.exports=L(Z);var t=require("react/jsx-runtime"),r=require("react"),S=require("@anker-in/headless-ui"),b=require("@anker-in/lib"),o=require("./type"),I=require("./context/provider"),O=require("./context/provider"),_=require("./context/viewStack"),p=require("./icons"),A=require("../../constants");const D=(0,r.lazy)(()=>import("./panels/EarnCredits")),U=(0,r.lazy)(()=>import("./panels/ConsumeCredits")),F=(0,r.lazy)(()=>import("./panels/Referral")),W=(0,r.lazy)(()=>import("./panels/EarnCredits/CompleteProfilePanel")),q=(0,r.lazy)(()=>import("./panels/ActivitiesSubscribePanel")),G=(0,r.lazy)(()=>import("./panels/EarnCredits/SubscribeEmailPanel")),J=(0,r.lazy)(()=>import("./panels/EarnCredits/ActivatePanel")),K=(0,r.lazy)(()=>import("./panels/ConsumeCredits/RedeemCouponPanel"));function Q({copy:e,bottomOffset:n="24px",...i}){const[d,s]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{const c=e.pageConfig;if(!c){s(!0);return}const m=window.location.pathname,P=c.pages.some(C=>m===C||m.startsWith(C+"/"));switch(c.scope){case o.MemberPopupPageScope.Include:s(P);break;case o.MemberPopupPageScope.Exclude:s(!P);break;default:s(!0)}},[e.pageConfig]),d?(0,t.jsx)(I.MemberPopupProvider,{...i,earnCreditsCopy:e.earnCredits,children:(0,t.jsx)(X,{copy:e,bottomOffset:n})}):null}function X({copy:e,bottomOffset:n}){const{profile:i,openSignInPopup:d,openSignUpPopup:s}=(0,O.useMemberPopupContext)(),{brand:c}=(0,b.useHeadlessContext)(),m=A.ROUNDED_BRANDS.includes(c),P=!!i,[C,w]=(0,r.useState)(!1),[y,N]=(0,r.useState)([]),l=y[y.length-1]??null,v=(0,r.useCallback)(a=>{N(u=>[...u,a])},[]),f=(0,r.useCallback)(()=>{N(a=>a.slice(0,-1))},[]),E="Member Floating Window";function g(a,u){(0,b.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:a,button_name:u,info:E}})}function V(a,u){switch(a){case o.MemberPopupActionType.ExternalLink:u&&window.open(u,"_blank","noopener,noreferrer");break;case o.MemberPopupActionType.OpenEarnCredits:g("home","earn_credits"),v({type:o.MemberPopupPanelType.EarnCredits});break;case o.MemberPopupActionType.OpenConsumeCredits:g("home","consume_credits"),v({type:o.MemberPopupPanelType.ConsumeCredits});break;case o.MemberPopupActionType.OpenReferral:g("home","referral"),v({type:o.MemberPopupPanelType.Referral});break;case o.MemberPopupActionType.OpenSubscribe:g("home","subscribe"),v({type:o.MemberPopupPanelType.Subscribe});break}}function k(){w(!1),N([])}return(0,t.jsxs)(_.ViewStackContext.Provider,{value:{pushView:v,popView:f},children:[C&&(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-[
|
|
1
|
+
"use strict";"use client";var R=Object.create;var h=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var B=(e,n)=>{for(var i in n)h(e,i,{get:n[i],enumerable:!0})},M=(e,n,i,d)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of H(n))!j.call(e,s)&&s!==i&&h(e,s,{get:()=>n[s],enumerable:!(d=z(n,s))||d.enumerable});return e};var x=(e,n,i)=>(i=e!=null?R(T(e)):{},M(n||!e||!e.__esModule?h(i,"default",{value:e,enumerable:!0}):i,e)),L=e=>M(h({},"__esModule",{value:!0}),e);var Z={};B(Z,{MemberPopup:()=>Q});module.exports=L(Z);var t=require("react/jsx-runtime"),r=require("react"),S=require("@anker-in/headless-ui"),b=require("@anker-in/lib"),o=require("./type"),I=require("./context/provider"),O=require("./context/provider"),_=require("./context/viewStack"),p=require("./icons"),A=require("../../constants");const D=(0,r.lazy)(()=>import("./panels/EarnCredits")),U=(0,r.lazy)(()=>import("./panels/ConsumeCredits")),F=(0,r.lazy)(()=>import("./panels/Referral")),W=(0,r.lazy)(()=>import("./panels/EarnCredits/CompleteProfilePanel")),q=(0,r.lazy)(()=>import("./panels/ActivitiesSubscribePanel")),G=(0,r.lazy)(()=>import("./panels/EarnCredits/SubscribeEmailPanel")),J=(0,r.lazy)(()=>import("./panels/EarnCredits/ActivatePanel")),K=(0,r.lazy)(()=>import("./panels/ConsumeCredits/RedeemCouponPanel"));function Q({copy:e,bottomOffset:n="24px",...i}){const[d,s]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{const c=e.pageConfig;if(!c){s(!0);return}const m=window.location.pathname,P=c.pages.some(C=>m===C||m.startsWith(C+"/"));switch(c.scope){case o.MemberPopupPageScope.Include:s(P);break;case o.MemberPopupPageScope.Exclude:s(!P);break;default:s(!0)}},[e.pageConfig]),d?(0,t.jsx)(I.MemberPopupProvider,{...i,earnCreditsCopy:e.earnCredits,children:(0,t.jsx)(X,{copy:e,bottomOffset:n})}):null}function X({copy:e,bottomOffset:n}){const{profile:i,openSignInPopup:d,openSignUpPopup:s}=(0,O.useMemberPopupContext)(),{brand:c}=(0,b.useHeadlessContext)(),m=A.ROUNDED_BRANDS.includes(c),P=!!i,[C,w]=(0,r.useState)(!1),[y,N]=(0,r.useState)([]),l=y[y.length-1]??null,v=(0,r.useCallback)(a=>{N(u=>[...u,a])},[]),f=(0,r.useCallback)(()=>{N(a=>a.slice(0,-1))},[]),E="Member Floating Window";function g(a,u){(0,b.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:a,button_name:u,info:E}})}function V(a,u){switch(a){case o.MemberPopupActionType.ExternalLink:u&&window.open(u,"_blank","noopener,noreferrer");break;case o.MemberPopupActionType.OpenEarnCredits:g("home","earn_credits"),v({type:o.MemberPopupPanelType.EarnCredits});break;case o.MemberPopupActionType.OpenConsumeCredits:g("home","consume_credits"),v({type:o.MemberPopupPanelType.ConsumeCredits});break;case o.MemberPopupActionType.OpenReferral:g("home","referral"),v({type:o.MemberPopupPanelType.Referral});break;case o.MemberPopupActionType.OpenSubscribe:g("home","subscribe"),v({type:o.MemberPopupPanelType.Subscribe});break}}function k(){w(!1),N([])}return(0,t.jsxs)(_.ViewStackContext.Provider,{value:{pushView:v,popView:f},children:[C&&(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-[20px] md:flex-col md:items-end md:right-0 md:w-screen md:pr-0 md:pl-0",style:{bottom:n},children:[C&&(0,t.jsxs)("div",{className:(0,b.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]",m?"rounded-[12px]":"rounded-none"),style:{maxHeight:"min(80vh, 606px)"},onClick:a=>a.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:[l!==null&&(0,t.jsx)("button",{className:"mr-auto flex size-[24px] cursor-pointer items-center justify-center",onClick:f,"aria-label":"Back",children:(0,t.jsx)(p.IconSwitch,{})}),(0,t.jsx)("button",{className:"flex size-[24px] cursor-pointer items-center justify-center",onClick:()=>{g("floating_button","close"),k()},"aria-label":"Close",children:(0,t.jsx)(p.IconClose,{})})]}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]",children:[l===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((a,u)=>(0,t.jsx)(Y,{item:a,onAction:V,rounded:m},u))]}),l!==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:[l.type===o.MemberPopupPanelType.EarnCredits&&e.earnCredits&&(0,t.jsx)(D,{copy:e.earnCredits}),l.type===o.MemberPopupPanelType.ConsumeCredits&&e.consumeCredits&&(0,t.jsx)(U,{copy:e.consumeCredits}),l.type===o.MemberPopupPanelType.Referral&&e.referral&&(0,t.jsx)(F,{copy:e.referral,onClose:f}),l.type===o.MemberPopupPanelType.CompleteProfile&&e.earnCredits&&(0,t.jsx)(W,{copy:e.earnCredits.completeProfile,onClose:f}),l.type===o.MemberPopupPanelType.Subscribe&&e.activitiesSubscribe&&(0,t.jsx)(q,{copy:e.activitiesSubscribe,email:i?.email}),l.type===o.MemberPopupPanelType.SubscribeEmail&&e.earnCredits&&(0,t.jsx)(G,{copy:e.earnCredits.subscribe,email:i?.email,onClose:f}),l.type===o.MemberPopupPanelType.Activate&&e.earnCredits&&(0,t.jsx)(J,{copy:e.earnCredits.authCodeActivate,onClose:f}),l.type===o.MemberPopupPanelType.RedeemCoupon&&l.props&&e.consumeCredits&&(0,t.jsx)(K,{item:l.props,copy:e.consumeCredits,onClose:f})]})]}),e.footer&&!P&&(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:d,children:e.footer.loginLabel})]}),(0,t.jsx)("div",{className:"flex shrink-0 items-center gap-[8px]",children:(0,t.jsx)("button",{className:(0,b.classNames)("cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]",m?"rounded-[4px]":"rounded-none"),onClick:s,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:()=>{const a=!C;g("floating_button",a?"open":"close"),w(a)},"aria-label":e.triggerImg.alt??"Open member popup",children:(0,t.jsx)(S.Picture,{source:e.triggerImg.url,alt:e.triggerImg.alt??"",className:"size-[58px]"})})]})]})}function Y({item:e,onAction:n,rounded:i}){const d={[o.MemberPopupActionType.OpenEarnCredits]:p.IconCredit,[o.MemberPopupActionType.OpenConsumeCredits]:p.IconBag,[o.MemberPopupActionType.OpenReferral]:p.IconReferral,[o.MemberPopupActionType.OpenSubscribe]:p.IconSubscription};return(0,t.jsxs)("div",{className:(0,b.classNames)("flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]",i?"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((s,c)=>{const m=d[s.type];return(0,t.jsxs)("div",{children:[c>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:()=>n(s.type,s.url),children:[m&&(0,t.jsx)(m,{className:"size-[24px] shrink-0"}),(0,t.jsx)("span",{className:"flex-1 text-left text-[14px] font-[700] text-[#1e2024]",children:s.label}),(0,t.jsx)(p.IconArrow,{className:"size-[16px] shrink-0"})]})]},c)})})]})}
|
|
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, useEffect } from 'react'\nimport { Picture } from '@anker-in/headless-ui'\nimport { gaTrack, 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 CompleteProfilePanel = lazy(() => import('./panels/EarnCredits/CompleteProfilePanel'))\nconst ActivitiesSubscribePanel = lazy(() => import('./panels/ActivitiesSubscribePanel'))\nconst SubscribeEmailPanel = lazy(() => import('./panels/EarnCredits/SubscribeEmailPanel'))\nconst ActivatePanel = lazy(() => import('./panels/EarnCredits/ActivatePanel'))\nconst RedeemCouponPanel = 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 const [isVisible, setIsVisible] = useState(false)\n\n useEffect(() => {\n const config = copy.pageConfig\n if (!config) {\n setIsVisible(true)\n return\n }\n const pathname = window.location.pathname\n const matches = config.pages.some(page => pathname === page || pathname.startsWith(page + '/'))\n switch (config.scope) {\n case MemberPopupPageScope.Include:\n setIsVisible(matches)\n break\n case MemberPopupPageScope.Exclude:\n setIsVisible(!matches)\n break\n default:\n setIsVisible(true)\n }\n }, [copy.pageConfig])\n\n return isVisible ? (\n <MemberPopupProvider {...providerProps} earnCreditsCopy={copy.earnCredits}>\n <MemberPopupContent copy={copy} bottomOffset={bottomOffset} />\n </MemberPopupProvider>\n ) : null\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 } = 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\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 const MEMBER_POPUP_INFO = 'Member Floating Window'\n\n function trackLpButton(position: string, buttonName: string) {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position,\n button_name: buttonName,\n info: MEMBER_POPUP_INFO,\n },\n })\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 trackLpButton('home', 'earn_credits')\n pushView({ type: MemberPopupPanelType.EarnCredits })\n break\n case MemberPopupActionType.OpenConsumeCredits:\n trackLpButton('home', 'consume_credits')\n pushView({ type: MemberPopupPanelType.ConsumeCredits })\n break\n case MemberPopupActionType.OpenReferral:\n trackLpButton('home', 'referral')\n pushView({ type: MemberPopupPanelType.Referral })\n break\n case MemberPopupActionType.OpenSubscribe:\n trackLpButton('home', 'subscribe')\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 && <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={() => {\n trackLpButton('floating_button', 'close')\n handleClose()\n }}\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 copy={copy.earnCredits} />\n )}\n {currentView.type === MemberPopupPanelType.ConsumeCredits && copy.consumeCredits && (\n <ConsumeCredits copy={copy.consumeCredits} />\n )}\n {currentView.type === MemberPopupPanelType.Referral && copy.referral && (\n <Referral copy={copy.referral} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.CompleteProfile && copy.earnCredits && (\n <CompleteProfilePanel copy={copy.earnCredits.completeProfile} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.Subscribe && copy.activitiesSubscribe && (\n <ActivitiesSubscribePanel copy={copy.activitiesSubscribe} email={profile?.email} />\n )}\n {currentView.type === MemberPopupPanelType.SubscribeEmail && copy.earnCredits && (\n <SubscribeEmailPanel copy={copy.earnCredits.subscribe} email={profile?.email} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.Activate && copy.earnCredits && (\n <ActivatePanel copy={copy.earnCredits.authCodeActivate} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.RedeemCoupon &&\n currentView.props &&\n copy.consumeCredits && (\n <RedeemCouponPanel item={currentView.props as any} copy={copy.consumeCredits} onClose={popView} />\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={() => {\n const next = !isOpen\n trackLpButton('floating_button', next ? 'open' : 'close')\n setIsOpen(next)\n }}\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"],
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport { lazy, Suspense, useState, useCallback, useEffect } from 'react'\nimport { Picture } from '@anker-in/headless-ui'\nimport { gaTrack, 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 CompleteProfilePanel = lazy(() => import('./panels/EarnCredits/CompleteProfilePanel'))\nconst ActivitiesSubscribePanel = lazy(() => import('./panels/ActivitiesSubscribePanel'))\nconst SubscribeEmailPanel = lazy(() => import('./panels/EarnCredits/SubscribeEmailPanel'))\nconst ActivatePanel = lazy(() => import('./panels/EarnCredits/ActivatePanel'))\nconst RedeemCouponPanel = 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 const [isVisible, setIsVisible] = useState(false)\n\n useEffect(() => {\n const config = copy.pageConfig\n if (!config) {\n setIsVisible(true)\n return\n }\n const pathname = window.location.pathname\n const matches = config.pages.some(page => pathname === page || pathname.startsWith(page + '/'))\n switch (config.scope) {\n case MemberPopupPageScope.Include:\n setIsVisible(matches)\n break\n case MemberPopupPageScope.Exclude:\n setIsVisible(!matches)\n break\n default:\n setIsVisible(true)\n }\n }, [copy.pageConfig])\n\n return isVisible ? (\n <MemberPopupProvider {...providerProps} earnCreditsCopy={copy.earnCredits}>\n <MemberPopupContent copy={copy} bottomOffset={bottomOffset} />\n </MemberPopupProvider>\n ) : null\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 } = 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\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 const MEMBER_POPUP_INFO = 'Member Floating Window'\n\n function trackLpButton(position: string, buttonName: string) {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position,\n button_name: buttonName,\n info: MEMBER_POPUP_INFO,\n },\n })\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 trackLpButton('home', 'earn_credits')\n pushView({ type: MemberPopupPanelType.EarnCredits })\n break\n case MemberPopupActionType.OpenConsumeCredits:\n trackLpButton('home', 'consume_credits')\n pushView({ type: MemberPopupPanelType.ConsumeCredits })\n break\n case MemberPopupActionType.OpenReferral:\n trackLpButton('home', 'referral')\n pushView({ type: MemberPopupPanelType.Referral })\n break\n case MemberPopupActionType.OpenSubscribe:\n trackLpButton('home', 'subscribe')\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 && <div className=\"fixed inset-0 z-[998]\" onClick={handleClose} />}\n <div\n className=\"fixed right-0 z-[999] flex flex-row items-end pr-[20px] 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={() => {\n trackLpButton('floating_button', 'close')\n handleClose()\n }}\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 copy={copy.earnCredits} />\n )}\n {currentView.type === MemberPopupPanelType.ConsumeCredits && copy.consumeCredits && (\n <ConsumeCredits copy={copy.consumeCredits} />\n )}\n {currentView.type === MemberPopupPanelType.Referral && copy.referral && (\n <Referral copy={copy.referral} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.CompleteProfile && copy.earnCredits && (\n <CompleteProfilePanel copy={copy.earnCredits.completeProfile} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.Subscribe && copy.activitiesSubscribe && (\n <ActivitiesSubscribePanel copy={copy.activitiesSubscribe} email={profile?.email} />\n )}\n {currentView.type === MemberPopupPanelType.SubscribeEmail && copy.earnCredits && (\n <SubscribeEmailPanel copy={copy.earnCredits.subscribe} email={profile?.email} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.Activate && copy.earnCredits && (\n <ActivatePanel copy={copy.earnCredits.authCodeActivate} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.RedeemCoupon &&\n currentView.props &&\n copy.consumeCredits && (\n <RedeemCouponPanel item={currentView.props as any} copy={copy.consumeCredits} onClose={popView} />\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={() => {\n const next = !isOpen\n trackLpButton('floating_button', next ? 'open' : 'close')\n setIsOpen(next)\n }}\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
5
|
"mappings": "ukBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,IAAA,eAAAC,EAAAH,GA2DM,IAAAI,EAAA,6BAzDNC,EAAiE,iBACjEC,EAAwB,iCACxBC,EAAmF,yBACnFC,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,KAAuB,QAAK,IAAM,OAAO,2CAA2C,CAAC,EACrFC,KAA2B,QAAK,IAAM,OAAO,mCAAmC,CAAC,EACjFC,KAAsB,QAAK,IAAM,OAAO,0CAA0C,CAAC,EACnFC,KAAgB,QAAK,IAAM,OAAO,oCAAoC,CAAC,EACvEC,KAAoB,QAAK,IAAM,OAAO,2CAA2C,CAAC,EAQjF,SAASlB,EAAY,CAAE,KAAAmB,EAAM,aAAAC,EAAe,OAAQ,GAAGC,CAAc,EAAqB,CAC/F,KAAM,CAACC,EAAWC,CAAY,KAAI,YAAS,EAAK,EAEhD,sBAAU,IAAM,CACd,MAAMC,EAASL,EAAK,WACpB,GAAI,CAACK,EAAQ,CACXD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AAC,OAAI,UAAU,2BACZ,SAAAA,EAAK,MAAM,IAAI,CAACM,EAAML,IAAM,CAC3B,MAAMM,EAAgBF,EAAYC,EAAK,IAAI,EAC3C,SACE,QAAC,OACE,UAAAL,EAAI,MAAK,OAAC,OAAI,UAAU,8BAA8B,KACvD,QAAC,UACC,UAAU,qDACV,QAAS,IAAMG,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,IATQL,CAUV,CAEJ,CAAC,EACH,GACF,CAEJ",
|
|
6
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", "CompleteProfilePanel", "ActivitiesSubscribePanel", "SubscribeEmailPanel", "ActivatePanel", "RedeemCouponPanel", "copy", "bottomOffset", "providerProps", "isVisible", "setIsVisible", "config", "pathname", "matches", "page", "MemberPopupContent", "profile", "openSignInPopup", "openSignUpPopup", "brand", "rounded", "isLogin", "isOpen", "setIsOpen", "viewStack", "setViewStack", "currentView", "pushView", "view", "prev", "popView", "MEMBER_POPUP_INFO", "trackLpButton", "position", "buttonName", "handleAction", "type", "url", "handleClose", "cn", "e", "item", "i", "HomeCard", "next", "onAction", "ACTION_ICON", "link", "IconComponent"]
|
|
7
7
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { type HeadlessConfig } from '@anker-in/lib';
|
|
3
|
-
import type { EarnCreditsCopy, MemberPopupContextValue } from '../type';
|
|
4
|
-
export declare const MemberPopupContext: import("react").Context<
|
|
3
|
+
import type { EarnCreditsCopy, MemberPopupContextValue, MemberPopupInternalContextValue } from '../type';
|
|
4
|
+
export declare const MemberPopupContext: import("react").Context<MemberPopupInternalContextValue>;
|
|
5
5
|
type MemberPopupProviderProps = MemberPopupContextValue & {
|
|
6
6
|
headlessConfig: HeadlessConfig;
|
|
7
7
|
earnCreditsCopy?: EarnCreditsCopy;
|
|
8
8
|
};
|
|
9
9
|
export declare function MemberPopupProvider({ children, headlessConfig, earnCreditsCopy, ...contextValue }: PropsWithChildren<MemberPopupProviderProps>): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export declare function useMemberPopupContext():
|
|
10
|
+
export declare function useMemberPopupContext(): MemberPopupInternalContextValue;
|
|
11
11
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var v=(e,o)=>{for(var r in o)n(e,r,{get:o[r],enumerable:!0})},M=(e,o,r,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of b(o))!S.call(e,t)&&t!==r&&n(e,t,{get:()=>o[t],enumerable:!(i=m(o,t))||i.enumerable});return e};var x=e=>M(n({},"__esModule",{value:!0}),e);var h={};v(h,{MemberPopupContext:()=>u,MemberPopupProvider:()=>I,useMemberPopupContext:()=>g});module.exports=x(h);var p=require("react/jsx-runtime"),s=require("react"),c=require("@anker-in/lib"),a=require("../../registration");const u=(0,s.createContext)({profile:null,isLoadingProfile:!1,creditInfo:void 0,fetchCreditInfo:()=>{},openSignUpPopup:()=>{},openSignInPopup:()=>{},taskIdToTypeMapping:{},alpcConfig:{brand:"",locale:"",appName:""},isSubscribeSuccess:!1,setIsSubscribeSuccess:()=>{},isActivateSuccess:!1,setIsActivateSuccess:()=>{},isProfileCompleteSuccess:!1,setIsProfileCompleteSuccess:()=>{}});function I({children:e,headlessConfig:o,earnCreditsCopy:r,...i}){const[t,l]=(0,s.useState)(!1),[P,d]=(0,s.useState)(!1),[f,C]=(0,s.useState)(!1);return(0,p.jsx)(c.HeadlessProvider,{headlessConfig:o,children:(0,p.jsx)(a.RegistrationProvider,{email:i.profile?.email,copy:{authCodeActivate:r?.authCodeActivate},children:(0,p.jsx)(u.Provider,{value:{...i,isSubscribeSuccess:t,setIsSubscribeSuccess:l,isActivateSuccess:P,setIsActivateSuccess:d,isProfileCompleteSuccess:f,setIsProfileCompleteSuccess:C},children:e})})})}function g(){const e=(0,s.useContext)(u);if(!e)throw new Error("useMemberPopupContext must be used within a MemberPopupProvider");return e}
|
|
2
2
|
//# sourceMappingURL=provider.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/components/memberPopup/context/provider.tsx"],
|
|
4
|
-
"sourcesContent": ["import { createContext, PropsWithChildren, useContext, useState } from 'react'\nimport { HeadlessProvider, type HeadlessConfig } from '@anker-in/lib'\nimport { RegistrationProvider } from '../../registration'\nimport type { EarnCreditsCopy, MemberPopupContextValue } from '../type'\n\nexport const MemberPopupContext = createContext<
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,EAAA,wBAAAC,EAAA,0BAAAC,IAAA,eAAAC,EAAAL,GA+CQ,IAAAM,EAAA,6BA/CRC,EAAuE,iBACvEC,EAAsD,yBACtDC,EAAqC,8BAG9B,MAAMP,KAAqB,
|
|
4
|
+
"sourcesContent": ["import { createContext, PropsWithChildren, useContext, useState } from 'react'\nimport { HeadlessProvider, type HeadlessConfig } from '@anker-in/lib'\nimport { RegistrationProvider } from '../../registration'\nimport type { EarnCreditsCopy, MemberPopupContextValue, MemberPopupInternalContextValue } from '../type'\n\nexport const MemberPopupContext = createContext<MemberPopupInternalContextValue>({\n profile: null,\n isLoadingProfile: false,\n creditInfo: undefined,\n fetchCreditInfo: () => {},\n openSignUpPopup: () => {},\n openSignInPopup: () => {},\n taskIdToTypeMapping: {},\n alpcConfig: {\n brand: '',\n locale: '',\n appName: '',\n },\n isSubscribeSuccess: false,\n setIsSubscribeSuccess: () => {},\n isActivateSuccess: false,\n setIsActivateSuccess: () => {},\n isProfileCompleteSuccess: false,\n setIsProfileCompleteSuccess: () => {},\n})\n\ntype MemberPopupProviderProps = MemberPopupContextValue & {\n headlessConfig: HeadlessConfig\n earnCreditsCopy?: EarnCreditsCopy\n}\n\nexport function MemberPopupProvider({\n children,\n headlessConfig,\n earnCreditsCopy,\n ...contextValue\n}: PropsWithChildren<MemberPopupProviderProps>) {\n const [isSubscribeSuccess, setIsSubscribeSuccess] = useState(false)\n const [isActivateSuccess, setIsActivateSuccess] = useState(false)\n const [isProfileCompleteSuccess, setIsProfileCompleteSuccess] = useState(false)\n\n return (\n <HeadlessProvider headlessConfig={headlessConfig}>\n <RegistrationProvider\n email={contextValue.profile?.email}\n copy={{ authCodeActivate: earnCreditsCopy?.authCodeActivate }}\n >\n <MemberPopupContext.Provider\n value={{\n ...contextValue,\n isSubscribeSuccess,\n setIsSubscribeSuccess,\n isActivateSuccess,\n setIsActivateSuccess,\n isProfileCompleteSuccess,\n setIsProfileCompleteSuccess,\n }}\n >\n {children}\n </MemberPopupContext.Provider>\n </RegistrationProvider>\n </HeadlessProvider>\n )\n}\n\nexport function useMemberPopupContext() {\n const context = useContext(MemberPopupContext)\n if (!context) {\n throw new Error('useMemberPopupContext must be used within a MemberPopupProvider')\n }\n return context\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,EAAA,wBAAAC,EAAA,0BAAAC,IAAA,eAAAC,EAAAL,GA+CQ,IAAAM,EAAA,6BA/CRC,EAAuE,iBACvEC,EAAsD,yBACtDC,EAAqC,8BAG9B,MAAMP,KAAqB,iBAA+C,CAC/E,QAAS,KACT,iBAAkB,GAClB,WAAY,OACZ,gBAAiB,IAAM,CAAC,EACxB,gBAAiB,IAAM,CAAC,EACxB,gBAAiB,IAAM,CAAC,EACxB,oBAAqB,CAAC,EACtB,WAAY,CACV,MAAO,GACP,OAAQ,GACR,QAAS,EACX,EACA,mBAAoB,GACpB,sBAAuB,IAAM,CAAC,EAC9B,kBAAmB,GACnB,qBAAsB,IAAM,CAAC,EAC7B,yBAA0B,GAC1B,4BAA6B,IAAM,CAAC,CACtC,CAAC,EAOM,SAASC,EAAoB,CAClC,SAAAO,EACA,eAAAC,EACA,gBAAAC,EACA,GAAGC,CACL,EAAgD,CAC9C,KAAM,CAACC,EAAoBC,CAAqB,KAAI,YAAS,EAAK,EAC5D,CAACC,EAAmBC,CAAoB,KAAI,YAAS,EAAK,EAC1D,CAACC,EAA0BC,CAA2B,KAAI,YAAS,EAAK,EAE9E,SACE,OAAC,oBAAiB,eAAgBR,EAChC,mBAAC,wBACC,MAAOE,EAAa,SAAS,MAC7B,KAAM,CAAE,iBAAkBD,GAAiB,gBAAiB,EAE5D,mBAACV,EAAmB,SAAnB,CACC,MAAO,CACL,GAAGW,EACH,mBAAAC,EACA,sBAAAC,EACA,kBAAAC,EACA,qBAAAC,EACA,yBAAAC,EACA,4BAAAC,CACF,EAEC,SAAAT,EACH,EACF,EACF,CAEJ,CAEO,SAASN,GAAwB,CACtC,MAAMgB,KAAU,cAAWlB,CAAkB,EAC7C,GAAI,CAACkB,EACH,MAAM,IAAI,MAAM,iEAAiE,EAEnF,OAAOA,CACT",
|
|
6
6
|
"names": ["provider_exports", "__export", "MemberPopupContext", "MemberPopupProvider", "useMemberPopupContext", "__toCommonJS", "import_jsx_runtime", "import_react", "import_lib", "import_registration", "children", "headlessConfig", "earnCreditsCopy", "contextValue", "isSubscribeSuccess", "setIsSubscribeSuccess", "isActivateSuccess", "setIsActivateSuccess", "isProfileCompleteSuccess", "setIsProfileCompleteSuccess", "context"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var I=Object.create;var
|
|
1
|
+
"use strict";var I=Object.create;var m=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var H=(e,r)=>{for(var s in r)m(e,s,{get:r[s],enumerable:!0})},N=(e,r,s,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of U(r))!E.call(e,n)&&n!==s&&m(e,n,{get:()=>r[n],enumerable:!(d=O(r,n))||d.enumerable});return e};var q=(e,r,s)=>(s=e!=null?I(j(e)):{},N(r||!e||!e.__esModule?m(s,"default",{value:e,enumerable:!0}):s,e)),F=e=>N(m({},"__esModule",{value:!0}),e);var X={};H(X,{default:()=>y});module.exports=F(X);var t=require("react/jsx-runtime"),o=require("react"),a=require("@anker-in/headless-ui"),l=require("@anker-in/lib"),f=q(require("js-cookie")),C=require("query-string"),S=require("../../credits/context/utils"),M=require("../context/provider"),k=require("../../../constants");function J(){if(typeof window>"u")return{register_source:""};const{search:e,href:r}=window.location,s=(0,C.parse)(e);return{fbuy_ref_code:f.default.get("fbuy_ref_code"),ref:f.default.get("ref_ads"),inviter_code:s.ic??s.inviter_code??f.default.get("inviter_code"),register_source:s.redirect??f.default.get("reg_source")??r}}async function V(e){if(typeof window>"u"||!window?.grecaptcha?.execute||!e)return"";try{return await window.grecaptcha.execute(e,{action:"activity"})}catch{return""}}function y({copy:e,email:r}){const{alpcConfig:s,setIsSubscribeSuccess:d}=(0,M.useMemberPopupContext)(),{locale:n}=s,{brand:L,storeDomain:h,recaptchaSitekey:T}=(0,l.useHeadlessContext)(),p=k.ROUNDED_BRANDS.includes(L),[x,P]=(0,o.useState)(!1),[c,_]=(0,o.useState)(r??""),[b,i]=(0,o.useState)(""),[A,v]=(0,o.useState)(""),[B,w]=(0,o.useState)(!1);(0,o.useEffect)(()=>{r&&_(r)},[r]);const D=(0,o.useCallback)(async()=>{if(i(""),!c)return i("Please fill in your email");if(!(0,S.emailValidate)(c))return i("Invalid email address");if(!x)return i("Please agree to the policy");w(!0);const{register_source:u}=J(),R=await V(T||"");try{const g=await(await fetch("/api/multipass/rainbowbridge/activities",{method:"POST",headers:{"Content-Type":"application/json","current-language":n,"X-Recaptcha-Token":R},body:JSON.stringify({email:c,register_source:u,shopify_domain:h,single_brand_subscribe:e.single_brand_subscribe??!0,genre:e.genre??e.dealsType??"",sub_brand_type:e.sub_brand_type??""})})).json();g?.data?.is_new_subscribe?g?.data?.errors?i(g?.data?.errors??"Error occurred"):(v(e.successTips??"Subscribed successfully!"),d(!0)):v(e.subscribedLabel??"You've already subscribed!")}catch{i("Network error")}finally{w(!1)}},[c,x,n,h,e,d]);return(0,t.jsxs)("div",{className:"flex flex-col gap-[16px] text-center",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:c,onChange:u=>{i(""),_(u.target.value.trim())}}),(0,t.jsxs)("div",{className:"flex w-full items-start gap-[8px]",children:[(0,t.jsx)(a.Checkbox,{checked:x,onCheckedChange:()=>P(u=>!u),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:B,onClick:D,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:A})}),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
2
|
//# sourceMappingURL=ActivitiesSubscribePanel.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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 { gaTrack, 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 copy: SubscribeModalCopy\n email?: string\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({ copy, email: initialEmail }: Props) {\n const { alpcConfig, setIsSubscribeSuccess } = 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
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAgGM,IAAAI,EAAA,6BAhGNC,EAAiD,iBACjDC,EAAgD,iCAChDC,EAA8D,yBAC9DC,EAAoB,wBACpBC,EAAsB,wBACtBC,EAA8B,uCAC9BC,EAAsC,+BAEtCC,EAA+B,8BAO/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,MAAO,EACT,CACF,CAEe,SAARjB,EAA0C,CAAE,KAAAkB,EAAM,MAAOC,CAAa,EAAU,CACrF,KAAM,CAAE,WAAAC,EAAY,sBAAAC,CAAsB,KAAI,yBAAsB,EAC9D,CAAE,OAAAC,CAAO,EAAIF,EACb,CAAE,MAAOG,EAAe,YAAAC,EAAa,iBAAAC,CAAiB,KAAI,sBAAmB,EAC7EC,EAAU,iBAAe,SAASH,CAAa,EAC/C,CAACI,EAAQC,CAAS,KAAI,YAAS,EAAK,EACpC,CAACC,EAAOC,CAAQ,KAAI,YAASX,GAAgB,EAAE,EAC/C,CAACY,EAAcC,CAAe,KAAI,YAAS,EAAE,EAC7C,CAACC,EAAgBC,CAAiB,KAAI,YAAS,EAAE,EACjD,CAACC,EAASC,CAAU,KAAI,YAAS,EAAK,KAE5C,aAAU,IAAM,CACVjB,GAAcW,EAASX,CAAY,CACzC,EAAG,CAACA,CAAY,CAAC,EAEjB,MAAMkB,KAAe,eAAY,SAAY,CAE3C,GADAL,EAAgB,EAAE,EACd,CAACH,EAAO,OAAOG,EAAgB,2BAA2B,EAC9D,GAAI,IAAC,iBAAcH,CAAK,EAAG,OAAOG,EAAgB,uBAAuB,EACzE,GAAI,CAACL,EAAQ,OAAOK,EAAgB,4BAA4B,EAEhEI,EAAW,EAAI,EACf,KAAM,CAAE,gBAAAE,CAAgB,EAAI3B,EAAY,EAClC4B,EAAiB,MAAMvB,EAAkBS,GAAoB,EAAE,EACrE,GAAI,CAiBF,MAAMe,EAAS,MAhBE,MAAM,MAAM,0CAA2C,CACtE,OAAQ,OACR,QAAS,CACP,eAAgB,mBAChB,mBAAoBlB,EACpB,oBAAqBiB,CACvB,EACA,KAAM,KAAK,UAAU,CACnB,MAAAV,EACA,gBAAAS,EACA,eAAgBd,EAChB,uBAAwBN,EAAK,wBAA0B,GACvD,MAAOA,EAAK,OAASA,EAAK,WAAa,GACvC,eAAgBA,EAAK,gBAAkB,EACzC,CAAC,CACH,CAAC,GAC6B,KAAK,
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Button, Checkbox, Picture, Text } from '@anker-in/headless-ui'\nimport { gaTrack, 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 copy: SubscribeModalCopy\n email?: string\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({ copy, email: initialEmail }: Props) {\n const { alpcConfig, setIsSubscribeSuccess } = 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?.data?.is_new_subscribe) {\n setSuccessMessage(copy.subscribedLabel ?? \"You've already subscribed!\")\n } else if (!result?.data?.errors) {\n setSuccessMessage(copy.successTips ?? 'Subscribed successfully!')\n setIsSubscribeSuccess(true)\n } else {\n setErrorMessage(result?.data?.errors ?? 'Error occurred')\n }\n } catch {\n setErrorMessage('Network error')\n } finally {\n setLoading(false)\n }\n }, [email, policy, locale, storeDomain, copy, setIsSubscribeSuccess])\n\n return (\n <div className=\"flex flex-col gap-[16px] text-center\">\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 {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,GAgGM,IAAAI,EAAA,6BAhGNC,EAAiD,iBACjDC,EAAgD,iCAChDC,EAA8D,yBAC9DC,EAAoB,wBACpBC,EAAsB,wBACtBC,EAA8B,uCAC9BC,EAAsC,+BAEtCC,EAA+B,8BAO/B,SAASC,GAAc,CACrB,GAAI,OAAO,OAAW,IAAa,MAAO,CAAE,gBAAiB,EAAG,EAChE,KA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AC,YAAS,QAASf,EAAQ,gBAAiB,IAAMC,EAAUe,GAAK,CAACA,CAAC,EAAG,UAAU,mBAAmB,KACnG,OAAC,SACC,UAAU,kEACV,wBAAyB,CAAE,OAAQzB,EAAK,QAAU,EAAG,EACvD,GACF,KAEA,OAAC,UACC,aAAW,EAAAuB,YACT,qGACAf,EAAU,gBAAkB,cAC9B,EACA,SAAUS,EACV,QAASE,EAER,SAAAnB,EAAK,aAAe,YACvB,EAECa,MACC,OAAC,OAAI,UAAU,qDACb,mBAAC,QAAK,KAAMA,EAAc,EAC5B,KAEF,OAAC,OAAI,UAAU,qDACb,mBAAC,QAAK,KAAME,EAAgB,EAC9B,EAECf,EAAK,UACJ,QAAC,OAAI,UAAU,0BACb,qBAAC,OAAI,UAAU,0BACZ,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,EAAAuB,YAAG,yCAA0Cf,EAAU,gBAAkB,cAAc,EACpG,GAEJ,GAEJ,CAEJ",
|
|
6
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", "copy", "initialEmail", "alpcConfig", "setIsSubscribeSuccess", "locale", "headlessBrand", "storeDomain", "recaptchaSitekey", "rounded", "policy", "setPolicy", "email", "setEmail", "errorMessage", "setErrorMessage", "successMessage", "setSuccessMessage", "loading", "setLoading", "handleSubmit", "register_source", "recaptchaToken", "result", "cn", "e", "v"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var P=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var K=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var X=(n,a)=>{for(var d in a)P(n,d,{get:a[d],enumerable:!0})},Y=(n,a,d,x)=>{if(a&&typeof a=="object"||typeof a=="function")for(let o of K(a))!Q.call(n,o)&&o!==d&&P(n,o,{get:()=>a[o],enumerable:!(x=J(a,o))||x.enumerable});return n};var Z=n=>Y(P({},"__esModule",{value:!0}),n);var ne={};X(ne,{default:()=>te});module.exports=Z(ne);var t=require("react/jsx-runtime"),u=require("react"),N=require("@anker-in/headless-ui"),s=require("@anker-in/lib"),L=require("../../context/provider"),A=require("../../context/viewStack"),U=require("./hooks/useRedeemableList"),E=require("./hooks/useRedeemAndBuy"),l=require("../../type"),f=require("../../../credits/context/utils"),M=require("../../../../constants");function ee({copy:n}){const{profile:a,creditInfo:d,openSignUpPopup:x,alpcConfig:o,isActivateSuccess:F,fetchCreditInfo:$}=(0,L.useMemberPopupContext)(),{pushView:I}=(0,A.useViewStack)(),{brand:T}=(0,s.useHeadlessContext)(),_=M.ROUNDED_BRANDS.includes(T),[y,R]=(0,u.useState)(""),[z,k]=(0,u.useState)(null);(0,u.useEffect)(()=>{a?.user_id&&$(a.user_id)},[]);const c=!!a,{redeemableList:B,listLoading:H}=(0,U.useRedeemableList)(o),{trigger:O}=(0,E.useRedeemAndBuy)(o),V=n.list.map(e=>e.product?.handle).filter(Boolean),{data:S}=(0,s.useProductsByHandles)({handles:V}),j=(0,u.useMemo)(()=>n.list.map(e=>{const r=B.find(m=>String(m.id)===String(e.redeemId));if(!r)return null;const i=Number(d?.available_credit??0),p=r.consume_credits>i,v=r.is_limited&&(!r.remaining_inventory||r.remaining_inventory<=0),C=e.type===l.ConsumeCreditsItemType.RedeemAndBuy||e.type===l.ConsumeCreditsItemType.Product,b=S?.find(m=>m.handle===e.product?.handle),w=b?.variants?.find(m=>m.sku===e.product?.sku)??b?.variants?.[0];return C&&(!b||!w||!w?.availableForSale||v)?null:{...e,alpcData:r,insufficient:p,product:b,variant:w}}).filter(Boolean),[n.list,B,d,a,c,S]),g=a?.activated||F;function W(e){return!c||!g?n.unlockRewards:e.soldOut?n.soldOut:n.btnRedeem}function G(e){return!c||!g?!1:e.insufficient}function D(){return typeof window>"u"?"":window.location.pathname.replace(/^\//,"").replace(/\//g,"_")||"home"}function h(e){(0,s.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"redeem",info:"Member Floating Window"}})}async function q(e){if(!c){x();return}if(!g){I({type:l.MemberPopupPanelType.Activate});return}if(e.type===l.ConsumeCreditsItemType.GiftCard||e.type===l.ConsumeCreditsItemType.Product){if(n.creditsPage?.url){const r=n.creditsPage.redeemListSectionId??"creditsRedeemList",i=new URL(n.creditsPage.url,window.location.href);i.hash=r;const p=D();p&&i.searchParams.set("ref",`${p}_consume_credits`),h(e.title),window.open(i.toString(),"_blank","noopener,noreferrer")}return}if(e.type===l.ConsumeCreditsItemType.Coupon)h(e.title),I({type:l.MemberPopupPanelType.RedeemCoupon,props:{itemTitle:e.title,itemCredits:e.alpcData.consume_credits,itemImage:n.imageMapping?.[e.type]?{url:n.imageMapping[e.type].url,alt:e.image?.alt}:e.image,itemValue:e.value,itemRules:e.rules,redeemId:Number(e.redeemId),userId:a?.user_id,alpcConfig:o}});else{R(""),k(e.redeemId),h(e.title);try{await O({productVariant:e.variant,redeemId:Number(e.redeemId),userId:a?.user_id}),(0,s.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"redeem_success",info:"Member Floating Window"}})}catch(r){R(r?.message??n.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:[n.title&&(0,t.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:n.title}),n.subtitle&&(0,t.jsx)("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:n.subtitle})]}),c&&(0,t.jsxs)("div",{className:(0,s.classNames)("flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]",_?"rounded-[8px]":"rounded-none"),children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,t.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:n.balanceLabel??"AnkerCredits Balance"}),(0,t.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,t.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,f.numberFormat)(d?.available_credit||0)}),(0,t.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:n.creditUnit??"ankercredits"})]})]}),(0,t.jsx)("div",{className:"h-full w-px bg-[#dadce0]"}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,t.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:n.comingSoonLabel??"Coming Soon"}),(0,t.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,t.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,f.numberFormat)(d?.pending_credit||0)}),(0,t.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:n.creditUnit??"ankercredits"})]})]})]}),y&&(0,t.jsx)("div",{className:"text-[14px] font-[700] text-[#f84d4f]",children:y}),H?(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:j.map((e,r)=>{const i=!!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 p=n.imageMapping?.[e.type]?.url,v=i?e.variant?.image?.url??e.product?.images?.[0]?.url??e.image?.url:p??e.image?.url,C=i?e.variant?.image?.altText??e.product?.images?.[0]?.alt??e.image?.alt??"":e.image?.alt??"";return v?(0,t.jsxs)("div",{className:(0,s.classNames)("relative size-[64px] shrink-0 overflow-hidden",_?"rounded-[4px]":"rounded-none"),children:[(0,t.jsx)(N.Picture,{source:v,alt:C,className:"flex size-full items-center justify-center",imgClassName:i?"object-cover":"h-full w-auto object-contain"}),!i&&e.value&&(0,t.jsxs)("div",{className:"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white",children:[e.value," ",n.off]})]}):null})(),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("div",{className:"text-[16px] font-[700] text-[#1e2024] line-clamp-2",children:i&&e.product?.title?e.product.title:e.title}),(0,t.jsx)("div",{className:"mt-[4px] text-[14px] text-[#666]",children:i&&e.price!=null?`${(0,f.numberFormat)(e.alpcData.consume_credits)} ${n.creditUnit??""} + $${Number(e.price).toFixed(2)}`:`${(0,f.numberFormat)(e.alpcData.consume_credits)} ${n.creditUnit??""}`})]}),(0,t.jsxs)("div",{className:"relative group",children:[(0,t.jsx)(N.Button,{className:(0,s.classNames)("bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",_?"rounded-[4px]":"rounded-none"),disabled:G(e),loading:z===e.redeemId,onClick:()=>q(e),children:W(e)}),e.insufficient&&c&&g&&(0,t.jsx)("div",{className:"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block",children:(0,t.jsxs)("div",{className:"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow",children:[(0,t.jsx)("p",{className:"text-pretty tracking-[-0.02em] text-[14px]",children:n.insufficientCredits}),(0,t.jsx)("div",{className:"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]"})]})})]})]})]},r)})}),n.creditsPage?.url&&(0,t.jsx)("a",{href:(()=>{const e=D();if(!e)return n.creditsPage.url;const r=new URL(n.creditsPage.url,typeof window<"u"?window.location.href:void 0);return r.searchParams.set("ref",`${e}_consume_credits`),r.toString()})(),target:"_blank",rel:"noopener noreferrer",className:"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline",onClick:()=>(0,s.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"credits_page_link",info:"Member Floating Window"}}),children:n.creditsPage.label??"Go to Credits Page"})]})})}var te=ee;
|
|
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 { gaTrack, classNames as cn, useProductsByHandles, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useRedeemableList } from './hooks/useRedeemableList'\nimport { useRedeemAndBuy } from './hooks/useRedeemAndBuy'\nimport {\n ConsumeCreditsItemType,\n MemberPopupPanelType,\n type ConsumeCreditsopy,\n type ConsumeCreditsItem,\n} from '../../type'\nimport { numberFormat } from '../../../credits/context/utils'\nimport type { ConsumeCreditRuleResponse } from '../../../credits/context/response'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype EnrichedItem = ConsumeCreditsItem & {\n alpcData: ConsumeCreditRuleResponse\n insufficient: boolean\n soldOut: boolean\n disabled: boolean\n product?: any\n variant?: any\n}\n\ntype Props = {\n copy: ConsumeCreditsopy\n}\n\nfunction ConsumeCredits({ copy }: Props) {\n const { profile, creditInfo, openSignUpPopup, alpcConfig, isActivateSuccess } = 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 = alpcData.consume_credits > availableCredit\n const alpcSoldOut = alpcData.is_limited && (!alpcData.remaining_inventory || alpcData.remaining_inventory <= 0)\n\n let product\n let variant\n const isPhysicalProduct =\n item.type === ConsumeCreditsItemType.RedeemAndBuy || item.type === ConsumeCreditsItemType.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 ((isPhysicalProduct && (!product || !variant || !variant?.availableForSale)) || alpcSoldOut) {\n return null\n }\n return { ...item, alpcData, insufficient, product, variant }\n })\n .filter(Boolean) as EnrichedItem[]\n }, [copy.list, redeemableList, creditInfo, profile, isLogin, products])\n\n const isActivate = profile?.activated || isActivateSuccess\n\n function getButtonLabel(item: (typeof list)[number]) {\n if (!isLogin || !isActivate) {\n return copy.unlockRewards\n }\n if (item.soldOut) {\n return copy.soldOut\n }\n return copy.btnRedeem\n }\n\n function isDisabled(item: (typeof list)[number]) {\n if (!isLogin || !isActivate) {\n return false\n }\n return item.insufficient\n }\n\n function getPageHandle() {\n if (typeof window === 'undefined') return ''\n return window.location.pathname.replace(/^\\//, '').replace(/\\//g, '_') || 'home'\n }\n\n function trackRedeemButton(itemTitle: string) {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem',\n info: 'Member Floating Window',\n },\n })\n }\n\n async function handleRedeem(item: (typeof list)[number]) {\n if (!isLogin) {\n openSignUpPopup()\n return\n }\n if (!isActivate) {\n pushView({\n type: MemberPopupPanelType.Activate,\n })\n return\n }\n if (item.type === ConsumeCreditsItemType.GiftCard || item.type === ConsumeCreditsItemType.Product) {\n if (copy.creditsPage?.url) {\n const sectionId = copy.creditsPage.redeemListSectionId ?? 'creditsRedeemList'\n const targetUrl = new URL(copy.creditsPage.url, window.location.href)\n targetUrl.hash = sectionId\n const pageHandle = getPageHandle()\n if (pageHandle) {\n targetUrl.searchParams.set('ref', `${pageHandle}_consume_credits`)\n }\n trackRedeemButton(item.title)\n window.open(targetUrl.toString(), '_blank', 'noopener,noreferrer')\n }\n return\n }\n if (item.type === ConsumeCreditsItemType.Coupon) {\n trackRedeemButton(item.title)\n pushView({\n type: MemberPopupPanelType.RedeemCoupon,\n props: {\n itemTitle: item.title,\n itemCredits: item.alpcData.consume_credits,\n itemImage: copy.imageMapping?.[item.type]\n ? { url: copy.imageMapping[item.type]!.url, alt: item.image?.alt }\n : item.image,\n itemValue: item.value,\n itemRules: item.rules,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n alpcConfig,\n },\n })\n } else {\n setRedeemAndBuyError('')\n setLoadingId(item.redeemId)\n trackRedeemButton(item.title)\n try {\n await redeemAndBuy({\n productVariant: item.variant,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n })\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem_success',\n info: 'Member Floating Window',\n },\n })\n } catch (e: any) {\n setRedeemAndBuyError(e?.message ?? copy.redeemModal.commonError)\n } finally {\n setLoadingId(null)\n }\n }\n }\n\n return (\n <>\n <div className=\"flex flex-1 flex-col 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 ?? 'ankercredits'}\n </span>\n </div>\n </div>\n <div className=\"h-full w-px bg-[#dadce0]\" />\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.comingSoonLabel ?? 'Coming Soon'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.pending_credit || 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n </div>\n )}\n {redeemAndBuyError && <div className=\"text-[14px] 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.creditUnit ?? ''} + $${Number(item.price).toFixed(2)}`\n : `${numberFormat(item.alpcData.consume_credits)} ${copy.creditUnit ?? ''}`}\n </div>\n </div>\n <div className=\"relative group\">\n <Button\n className={cn(\n 'bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={isDisabled(item)}\n loading={loadingId === item.redeemId}\n onClick={() => handleRedeem(item)}\n >\n {getButtonLabel(item)}\n </Button>\n {item.insufficient && !item.soldOut && (\n <div className=\"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block\">\n <div className=\"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow\">\n <p className=\"text-pretty tracking-[-0.02em] text-[14px]\">{copy.insufficientCredits}</p>\n <div className=\"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]\" />\n </div>\n </div>\n )}\n </div>\n </div>\n </div>\n )\n })}\n </div>\n )}\n\n {copy.creditsPage?.url && (\n <a\n href={(() => {\n const pageHandle = getPageHandle()\n if (!pageHandle) return copy.creditsPage!.url\n const url = new URL(copy.creditsPage!.url, typeof window !== 'undefined' ? window.location.href : undefined)\n url.searchParams.set('ref', `${pageHandle}_consume_credits`)\n return url.toString()\n })()}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline\"\n onClick={() =>\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'credits_page_link',\n info: 'Member Floating Window',\n },\n })\n }\n >\n {copy.creditsPage.label ?? 'Go to Credits Page'}\n </a>\n )}\n </div>\n </>\n )\n}\n\nexport default ConsumeCredits\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["ConsumeCredits_exports", "__export", "ConsumeCredits_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_provider", "import_viewStack", "import_useRedeemableList", "import_useRedeemAndBuy", "import_type", "import_utils", "import_constants", "ConsumeCredits", "copy", "profile", "creditInfo", "openSignUpPopup", "alpcConfig", "isActivateSuccess", "pushView", "brand", "rounded", "redeemAndBuyError", "setRedeemAndBuyError", "loadingId", "setLoadingId", "isLogin", "redeemableList", "listLoading", "redeemAndBuy", "handles", "item", "products", "list", "alpcData", "r", "availableCredit", "insufficient", "alpcSoldOut", "
|
|
4
|
+
"sourcesContent": ["import { useEffect, useMemo, useState } from 'react'\nimport { Picture, Button } from '@anker-in/headless-ui'\nimport { gaTrack, classNames as cn, useProductsByHandles, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useRedeemableList } from './hooks/useRedeemableList'\nimport { useRedeemAndBuy } from './hooks/useRedeemAndBuy'\nimport {\n ConsumeCreditsItemType,\n MemberPopupPanelType,\n type ConsumeCreditsopy,\n type ConsumeCreditsItem,\n} from '../../type'\nimport { numberFormat } from '../../../credits/context/utils'\nimport type { ConsumeCreditRuleResponse } from '../../../credits/context/response'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype EnrichedItem = ConsumeCreditsItem & {\n alpcData: ConsumeCreditRuleResponse\n insufficient: boolean\n soldOut: boolean\n disabled: boolean\n product?: any\n variant?: any\n}\n\ntype Props = {\n copy: ConsumeCreditsopy\n}\n\nfunction ConsumeCredits({ copy }: Props) {\n const { profile, creditInfo, openSignUpPopup, alpcConfig, isActivateSuccess, fetchCreditInfo } =\n useMemberPopupContext()\n const { pushView } = useViewStack()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const [redeemAndBuyError, setRedeemAndBuyError] = useState('')\n const [loadingId, setLoadingId] = useState<string | number | null>(null)\n\n useEffect(() => {\n if (profile?.user_id) fetchCreditInfo(profile.user_id)\n }, [])\n\n const isLogin = !!profile\n const { redeemableList, listLoading } = useRedeemableList(alpcConfig)\n const { trigger: redeemAndBuy } = useRedeemAndBuy(alpcConfig)\n\n const handles = copy.list.map(item => item.product?.handle).filter(Boolean) as string[]\n const { data: products } = useProductsByHandles({ handles })\n\n const list = useMemo(() => {\n return copy.list\n .map(item => {\n const alpcData = redeemableList.find(r => String(r.id) === String(item.redeemId))\n if (!alpcData) return null\n\n const availableCredit = Number(creditInfo?.available_credit ?? 0)\n const insufficient = alpcData.consume_credits > availableCredit\n const alpcSoldOut = alpcData.is_limited && (!alpcData.remaining_inventory || alpcData.remaining_inventory <= 0)\n\n\n const isPhysicalProduct =\n item.type === ConsumeCreditsItemType.RedeemAndBuy || item.type === ConsumeCreditsItemType.Product\n const product = products?.find((p: any) => p.handle === item.product?.handle)\n const variant = product?.variants?.find((v: any) => v.sku === item.product?.sku) ?? product?.variants?.[0]\n if (isPhysicalProduct && (!product || !variant || !variant?.availableForSale || alpcSoldOut)) {\n return null\n }\n return { ...item, alpcData, insufficient, product, variant }\n })\n .filter(Boolean) as EnrichedItem[]\n }, [copy.list, redeemableList, creditInfo, profile, isLogin, products])\n\n const isActivate = profile?.activated || isActivateSuccess\n\n function getButtonLabel(item: (typeof list)[number]) {\n if (!isLogin || !isActivate) {\n return copy.unlockRewards\n }\n if (item.soldOut) {\n return copy.soldOut\n }\n return copy.btnRedeem\n }\n\n function isDisabled(item: (typeof list)[number]) {\n if (!isLogin || !isActivate) {\n return false\n }\n return item.insufficient\n }\n\n function getPageHandle() {\n if (typeof window === 'undefined') return ''\n return window.location.pathname.replace(/^\\//, '').replace(/\\//g, '_') || 'home'\n }\n\n function trackRedeemButton(itemTitle: string) {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem',\n info: 'Member Floating Window',\n },\n })\n }\n\n async function handleRedeem(item: (typeof list)[number]) {\n if (!isLogin) {\n openSignUpPopup()\n return\n }\n if (!isActivate) {\n pushView({\n type: MemberPopupPanelType.Activate,\n })\n return\n }\n if (item.type === ConsumeCreditsItemType.GiftCard || item.type === ConsumeCreditsItemType.Product) {\n if (copy.creditsPage?.url) {\n const sectionId = copy.creditsPage.redeemListSectionId ?? 'creditsRedeemList'\n const targetUrl = new URL(copy.creditsPage.url, window.location.href)\n targetUrl.hash = sectionId\n const pageHandle = getPageHandle()\n if (pageHandle) {\n targetUrl.searchParams.set('ref', `${pageHandle}_consume_credits`)\n }\n trackRedeemButton(item.title)\n window.open(targetUrl.toString(), '_blank', 'noopener,noreferrer')\n }\n return\n }\n if (item.type === ConsumeCreditsItemType.Coupon) {\n trackRedeemButton(item.title)\n pushView({\n type: MemberPopupPanelType.RedeemCoupon,\n props: {\n itemTitle: item.title,\n itemCredits: item.alpcData.consume_credits,\n itemImage: copy.imageMapping?.[item.type]\n ? { url: copy.imageMapping[item.type]!.url, alt: item.image?.alt }\n : item.image,\n itemValue: item.value,\n itemRules: item.rules,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n alpcConfig,\n },\n })\n } else {\n setRedeemAndBuyError('')\n setLoadingId(item.redeemId)\n trackRedeemButton(item.title)\n try {\n await redeemAndBuy({\n productVariant: item.variant,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n })\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem_success',\n info: 'Member Floating Window',\n },\n })\n } catch (e: any) {\n setRedeemAndBuyError(e?.message ?? copy.redeemModal.commonError)\n } finally {\n setLoadingId(null)\n }\n }\n }\n\n return (\n <>\n <div className=\"flex flex-1 flex-col 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 ?? 'ankercredits'}\n </span>\n </div>\n </div>\n <div className=\"h-full w-px bg-[#dadce0]\" />\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.comingSoonLabel ?? 'Coming Soon'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.pending_credit || 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n </div>\n )}\n {redeemAndBuyError && <div className=\"text-[14px] 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.creditUnit ?? ''} + $${Number(item.price).toFixed(2)}`\n : `${numberFormat(item.alpcData.consume_credits)} ${copy.creditUnit ?? ''}`}\n </div>\n </div>\n <div className=\"relative group\">\n <Button\n className={cn(\n 'bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={isDisabled(item)}\n loading={loadingId === item.redeemId}\n onClick={() => handleRedeem(item)}\n >\n {getButtonLabel(item)}\n </Button>\n {item.insufficient && isLogin && isActivate && (\n <div className=\"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block\">\n <div className=\"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow\">\n <p className=\"text-pretty tracking-[-0.02em] text-[14px]\">{copy.insufficientCredits}</p>\n <div className=\"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]\" />\n </div>\n </div>\n )}\n </div>\n </div>\n </div>\n )\n })}\n </div>\n )}\n\n {copy.creditsPage?.url && (\n <a\n href={(() => {\n const pageHandle = getPageHandle()\n if (!pageHandle) return copy.creditsPage!.url\n const url = new URL(\n copy.creditsPage!.url,\n typeof window !== 'undefined' ? window.location.href : undefined\n )\n url.searchParams.set('ref', `${pageHandle}_consume_credits`)\n return url.toString()\n })()}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline\"\n onClick={() =>\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'credits_page_link',\n info: 'Member Floating Window',\n },\n })\n }\n >\n {copy.creditsPage.label ?? 'Go to Credits Page'}\n </a>\n )}\n </div>\n </>\n )\n}\n\nexport default ConsumeCredits\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,eAAAC,EAAAH,IAoLI,IAAAI,EAAA,6BApLJC,EAA6C,iBAC7CC,EAAgC,iCAChCC,EAAoF,yBACpFC,EAAsC,kCACtCC,EAA6B,mCAC7BC,EAAkC,qCAClCC,EAAgC,mCAChCC,EAKO,sBACPC,EAA6B,0CAE7BC,EAA+B,iCAe/B,SAASC,GAAe,CAAE,KAAAC,CAAK,EAAU,CACvC,KAAM,CAAE,QAAAC,EAAS,WAAAC,EAAY,gBAAAC,EAAiB,WAAAC,EAAY,kBAAAC,EAAmB,gBAAAC,CAAgB,KAC3F,yBAAsB,EAClB,CAAE,SAAAC,CAAS,KAAI,gBAAa,EAC5B,CAAE,MAAAC,CAAM,KAAI,sBAAmB,EAC/BC,EAAU,iBAAe,SAASD,CAAK,EAEvC,CAACE,EAAmBC,CAAoB,KAAI,YAAS,EAAE,EACvD,CAACC,EAAWC,CAAY,KAAI,YAAiC,IAAI,KAEvE,aAAU,IAAM,CACVZ,GAAS,SAASK,EAAgBL,EAAQ,OAAO,CACvD,EAAG,CAAC,CAAC,EAEL,MAAMa,EAAU,CAAC,CAACb,EACZ,CAAE,eAAAc,EAAgB,YAAAC,CAAY,KAAI,qBAAkBZ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AAK,KAAK,EAAE,QAAQ,CAAC,CAAC,GAC3G,MAAG,gBAAaA,EAAK,SAAS,eAAe,CAAC,IAAInB,EAAK,YAAc,EAAE,GAC7E,GACF,KACA,QAAC,OAAI,UAAU,iBACb,oBAAC,UACC,aAAW,EAAA2C,YACT,6FACAlC,EAAU,gBAAkB,cAC9B,EACA,SAAUyB,EAAWf,CAAI,EACzB,QAASP,IAAcO,EAAK,SAC5B,QAAS,IAAMmB,EAAanB,CAAI,EAE/B,SAAAc,EAAed,CAAI,EACtB,EACCA,EAAK,cAAgBL,GAAWkB,MAC/B,OAAC,OAAI,UAAU,qGACb,oBAAC,OAAI,UAAU,0EACb,oBAAC,KAAE,UAAU,6CAA8C,SAAAhC,EAAK,oBAAoB,KACpF,OAAC,OAAI,UAAU,oGAAoG,GACrH,EACF,GAEJ,GACF,IAhEQ4C,CAiEV,CAEJ,CAAC,EACH,EAGD5C,EAAK,aAAa,QACjB,OAAC,KACC,MAAO,IAAM,CACX,MAAMyC,EAAaN,EAAc,EACjC,GAAI,CAACM,EAAY,OAAOzC,EAAK,YAAa,IAC1C,MAAMiD,EAAM,IAAI,IACdjD,EAAK,YAAa,IAClB,OAAO,OAAW,IAAc,OAAO,SAAS,KAAO,MACzD,EACA,OAAAiD,EAAI,aAAa,IAAI,MAAO,GAAGR,CAAU,kBAAkB,EACpDQ,EAAI,SAAS,CACtB,GAAG,EACH,OAAO,SACP,IAAI,sBACJ,UAAU,qEACV,QAAS,OACP,WAAQ,CACN,MAAO,WACP,WAAY,YACZ,iBAAkB,CAChB,SAAU,kBACV,YAAa,oBACb,KAAM,wBACR,CACF,CAAC,EAGF,SAAAjD,EAAK,YAAY,OAAS,qBAC7B,GAEJ,EACF,CAEJ,CAEA,IAAOd,GAAQa",
|
|
6
|
+
"names": ["ConsumeCredits_exports", "__export", "ConsumeCredits_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_provider", "import_viewStack", "import_useRedeemableList", "import_useRedeemAndBuy", "import_type", "import_utils", "import_constants", "ConsumeCredits", "copy", "profile", "creditInfo", "openSignUpPopup", "alpcConfig", "isActivateSuccess", "fetchCreditInfo", "pushView", "brand", "rounded", "redeemAndBuyError", "setRedeemAndBuyError", "loadingId", "setLoadingId", "isLogin", "redeemableList", "listLoading", "redeemAndBuy", "handles", "item", "products", "list", "alpcData", "r", "availableCredit", "insufficient", "alpcSoldOut", "isPhysicalProduct", "product", "p", "variant", "v", "isActivate", "getButtonLabel", "isDisabled", "getPageHandle", "trackRedeemButton", "itemTitle", "handleRedeem", "sectionId", "targetUrl", "pageHandle", "e", "cn", "idx", "hasProduct", "mappedImgUrl", "imgUrl", "imgAlt", "url"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var B=Object.create;var m=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var J=(e,t)=>{for(var s in t)m(e,s,{get:t[s],enumerable:!0})},k=(e,t,s,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of R(t))!q.call(e,i)&&i!==s&&m(e,i,{get:()=>t[i],enumerable:!(f=H(t,i))||f.enumerable});return e};var U=(e,t,s)=>(s=e!=null?B(j(e)):{},k(t||!e||!e.__esModule?m(s,"default",{value:e,enumerable:!0}):s,e)),V=e=>k(m({},"__esModule",{value:!0}),e);var F={};J(F,{default:()=>I});module.exports=V(F);var r=require("react/jsx-runtime"),o=require("react"),u=require("@anker-in/headless-ui"),a=require("@anker-in/lib"),d=U(require("js-cookie")),T=require("query-string"),M=require("../../../credits/context/utils"),P=require("../../context/provider"),E=require("../../../../constants");function z(){if(typeof window>"u")return{register_source:""};const{search:e,href:t}=window.location,s=(0,T.parse)(e);return{fbuy_ref_code:d.default.get("fbuy_ref_code"),ref:d.default.get("ref_ads"),inviter_code:s.ic??s.inviter_code??d.default.get("inviter_code"),register_source:s.redirect??d.default.get("reg_source")??t}}function I({copy:e,email:t,onClose:s}){const{alpcConfig:f,setIsSubscribeSuccess:i,fetchCreditInfo:L,profile:g}=(0,P.useMemberPopupContext)(),{brand:_,locale:v}=f,{brand:A}=(0,a.useHeadlessContext)(),h=E.ROUNDED_BRANDS.includes(A),[b,y]=(0,o.useState)(!1),[c,C]=(0,o.useState)(t??""),[p,n]=(0,o.useState)(""),[x,N]=(0,o.useState)(""),[D,w]=(0,o.useState)(!1);(0,o.useEffect)(()=>{t&&C(t)},[t]);const O=(0,o.useCallback)(async()=>{if(n(""),!c)return n("Please fill in your email");if(!(0,M.emailValidate)(c))return n("Invalid email address");if(!b)return n("Please agree to the policy");w(!0);const{register_source:l}=z();try{const S=await(await fetch("/api/multipass/subscribe/subscribe_emails",{method:"POST",headers:{"Content-Type":"application/json","current-language":v},body:JSON.stringify({email:c,register_source:l,brand:_,deals_type:e.dealsType??"vip_subscribe"})})).json();S.errors?n(S.errors??"Error occurred"):(N(e.successTips??"Subscribed successfully!"),i(!0),g?.user_id&&L(g.user_id),(0,a.gaTrack)({event:"ga4Event",event_name:"subscribe",event_parameters:{page_group:e.dealsType??"vip_subscribe",position:"member_floating_window"}}),(0,a.gaTrack)({event:"uaEvent",eventCategory:"subscribe",eventAction:e.dealsType??"vip_subscribe",eventLabel:"member_floating_window",nonInteraction:!1}),setTimeout(()=>{N(""),s()},3e3))}catch{n("Network error")}finally{w(!1)}},[c,b,v,_,e,s,i]);return(0,r.jsxs)("div",{className:"flex flex-col gap-[12px]",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-[8px]",children:[e.title&&(0,r.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:e.title}),e.desc&&(0,r.jsx)(u.Text,{className:"text-[16px] text-[#1e2024]",html:e.desc})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[(0,r.jsx)("input",{className:(0,a.classNames)("h-[46px] w-full border px-[14px] text-[16px] outline-none placeholder:text-[#999]",p?"border-[#f84d4f]":"border-[#d8d8d8]",h?"rounded-[4px]":"rounded-none"),placeholder:e.placeholder,value:c,onChange:l=>{n(""),C(l.target.value.trim())}}),(0,r.jsxs)("div",{className:"flex w-full items-start gap-[8px]",children:[(0,r.jsx)(u.Checkbox,{checked:b,onCheckedChange:()=>y(l=>!l),className:"mt-[2px] border-[#1d1d1f]"}),(0,r.jsx)("label",{className:"cursor-pointer text-left text-[14px] text-[#1e2024] [&_a]:underline",onClick:()=>y(l=>!l),dangerouslySetInnerHTML:{__html:e.policy??""}})]}),(p||x)&&(0,r.jsx)("div",{className:(0,a.classNames)("text-[14px] font-[700]",p&&"text-[#f84d4f]",x&&"text-[#52c41a]"),children:(0,r.jsx)(u.Text,{html:x||p})}),(0,r.jsx)("button",{className:(0,a.classNames)("w-full cursor-pointer bg-[#080a0f] py-[14px] text-[14px] font-[700] text-white disabled:opacity-60",h?"rounded-[4px]":"rounded-none"),disabled:D,onClick:O,children:e.buttonLabel??"Subscribe"})]})]})}
|
|
2
2
|
//# sourceMappingURL=SubscribeEmailPanel.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Checkbox, Text } from '@anker-in/headless-ui'\nimport { gaTrack, 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 copy: SubscribeModalCopy\n email?: string\n onClose: () => 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\nexport default function SubscribeEmailPanel({ copy, email: initialEmail, onClose }: Props) {\n const { alpcConfig, setIsSubscribeSuccess } = useMemberPopupContext()\n const { brand, locale } = alpcConfig\n const { brand: headlessBrand } = 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 try {\n const response = await fetch('/api/multipass/subscribe/subscribe_emails', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', 'current-language': locale },\n body: JSON.stringify({\n email,\n register_source,\n brand,\n deals_type: copy.dealsType ?? 'vip_subscribe',\n }),\n })\n const result = await response.json()\n if (!result.errors) {\n setSuccessMessage(copy.successTips ?? 'Subscribed successfully!')\n setIsSubscribeSuccess(true)\n gaTrack({\n event: 'ga4Event',\n event_name: 'subscribe',\n event_parameters: {\n page_group: copy.dealsType ?? 'vip_subscribe',\n position: 'member_floating_window',\n },\n })\n gaTrack({\n event: 'uaEvent',\n eventCategory: 'subscribe',\n eventAction: copy.dealsType ?? 'vip_subscribe',\n eventLabel: 'member_floating_window',\n nonInteraction: false,\n })\n setTimeout(() => {\n setSuccessMessage('')\n onClose()\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, brand, copy, onClose, setIsSubscribeSuccess])\n\n return (\n <div className=\"flex flex-col gap-[12px]\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && (\n <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>\n )}\n {copy.desc && (\n <Text className=\"text-[16px] text-[#1e2024]\" html={copy.desc} />\n )}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\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 => { setErrorMessage(''); setEmail(e.target.value.trim()) }}\n />\n\n <div className=\"flex w-full items-start gap-[8px]\">\n <Checkbox checked={policy} onCheckedChange={() => setPolicy(v => !v)} className=\"mt-[2px] border-[#1d1d1f]\" />\n <label\n className=\"cursor-pointer text-left text-[14px] text-[#1e2024] [&_a]:underline\"\n onClick={() => setPolicy(v => !v)}\n dangerouslySetInnerHTML={{ __html: copy.policy ?? '' }}\n />\n </div>\n\n {(errorMessage || successMessage) && (\n <div className={cn('text-[14px] font-[700]', errorMessage && 'text-[#f84d4f]', successMessage && 'text-[#52c41a]')}>\n <Text html={successMessage || errorMessage} />\n </div>\n )}\n\n <button\n className={cn('w-full cursor-pointer bg-[#080a0f] py-[14px] text-[14px] font-[700] text-white disabled:opacity-60', rounded ? 'rounded-[4px]' : 'rounded-none')}\n disabled={loading}\n onClick={handleSubmit}\n >\n {copy.buttonLabel ?? 'Subscribe'}\n </button>\n </div>\n </div>\n )\n}\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["SubscribeEmailPanel_exports", "__export", "SubscribeEmailPanel", "__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", "copy", "initialEmail", "onClose", "alpcConfig", "setIsSubscribeSuccess", "brand", "locale", "headlessBrand", "rounded", "policy", "setPolicy", "email", "setEmail", "errorMessage", "setErrorMessage", "successMessage", "setSuccessMessage", "loading", "setLoading", "handleSubmit", "register_source", "result", "cn", "e", "v"]
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Checkbox, Text } from '@anker-in/headless-ui'\nimport { gaTrack, 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 copy: SubscribeModalCopy\n email?: string\n onClose: () => 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\nexport default function SubscribeEmailPanel({ copy, email: initialEmail, onClose }: Props) {\n const { alpcConfig, setIsSubscribeSuccess, fetchCreditInfo, profile } = useMemberPopupContext()\n const { brand, locale } = alpcConfig\n const { brand: headlessBrand } = 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 try {\n const response = await fetch('/api/multipass/subscribe/subscribe_emails', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', 'current-language': locale },\n body: JSON.stringify({\n email,\n register_source,\n brand,\n deals_type: copy.dealsType ?? 'vip_subscribe',\n }),\n })\n const result = await response.json()\n if (!result.errors) {\n setSuccessMessage(copy.successTips ?? 'Subscribed successfully!')\n setIsSubscribeSuccess(true)\n if (profile?.user_id) fetchCreditInfo(profile.user_id)\n gaTrack({\n event: 'ga4Event',\n event_name: 'subscribe',\n event_parameters: {\n page_group: copy.dealsType ?? 'vip_subscribe',\n position: 'member_floating_window',\n },\n })\n gaTrack({\n event: 'uaEvent',\n eventCategory: 'subscribe',\n eventAction: copy.dealsType ?? 'vip_subscribe',\n eventLabel: 'member_floating_window',\n nonInteraction: false,\n })\n setTimeout(() => {\n setSuccessMessage('')\n onClose()\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, brand, copy, onClose, setIsSubscribeSuccess])\n\n return (\n <div className=\"flex flex-col gap-[12px]\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && (\n <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>\n )}\n {copy.desc && (\n <Text className=\"text-[16px] text-[#1e2024]\" html={copy.desc} />\n )}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\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 => { setErrorMessage(''); setEmail(e.target.value.trim()) }}\n />\n\n <div className=\"flex w-full items-start gap-[8px]\">\n <Checkbox checked={policy} onCheckedChange={() => setPolicy(v => !v)} className=\"mt-[2px] border-[#1d1d1f]\" />\n <label\n className=\"cursor-pointer text-left text-[14px] text-[#1e2024] [&_a]:underline\"\n onClick={() => setPolicy(v => !v)}\n dangerouslySetInnerHTML={{ __html: copy.policy ?? '' }}\n />\n </div>\n\n {(errorMessage || successMessage) && (\n <div className={cn('text-[14px] font-[700]', errorMessage && 'text-[#f84d4f]', successMessage && 'text-[#52c41a]')}>\n <Text html={successMessage || errorMessage} />\n </div>\n )}\n\n <button\n className={cn('w-full cursor-pointer bg-[#080a0f] py-[14px] text-[14px] font-[700] text-white disabled:opacity-60', rounded ? 'rounded-[4px]' : 'rounded-none')}\n disabled={loading}\n onClick={handleSubmit}\n >\n {copy.buttonLabel ?? 'Subscribe'}\n </button>\n </div>\n </div>\n )\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAkGM,IAAAI,EAAA,6BAlGNC,EAAiD,iBACjDC,EAA+B,iCAC/BC,EAA8D,yBAC9DC,EAAoB,wBACpBC,EAAsB,wBACtBC,EAA8B,0CAC9BC,EAAsC,kCAEtCC,EAA+B,iCAQ/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,YA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GAAkB,gBAAgB,EAC/G,mBAAC,QAAK,KAAMA,GAAkBF,EAAc,EAC9C,KAGF,OAAC,UACC,aAAW,EAAAS,YAAG,qGAAsGd,EAAU,gBAAkB,cAAc,EAC9J,SAAUS,EACV,QAASE,EAER,SAAArB,EAAK,aAAe,YACvB,GACF,GACF,CAEJ",
|
|
6
|
+
"names": ["SubscribeEmailPanel_exports", "__export", "SubscribeEmailPanel", "__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", "copy", "initialEmail", "onClose", "alpcConfig", "setIsSubscribeSuccess", "fetchCreditInfo", "profile", "brand", "locale", "headlessBrand", "rounded", "policy", "setPolicy", "email", "setEmail", "errorMessage", "setErrorMessage", "successMessage", "setSuccessMessage", "loading", "setLoading", "handleSubmit", "register_source", "result", "cn", "e", "v"]
|
|
7
7
|
}
|