@anker-in/campaign-ui 0.5.0-beta.1 → 0.5.0-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/cjs/components/credits/context/hooks/useCountries.js +1 -1
  2. package/dist/cjs/components/credits/context/hooks/useCountries.js.map +3 -3
  3. package/dist/cjs/components/memberPopup/MemberPopup.js +1 -1
  4. package/dist/cjs/components/memberPopup/MemberPopup.js.map +3 -3
  5. package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.d.ts +10 -0
  6. package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.js +2 -0
  7. package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +7 -0
  8. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.d.ts +2 -1
  9. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js +1 -1
  10. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js.map +3 -3
  11. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.d.ts +2 -1
  12. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.js +1 -1
  13. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.js.map +3 -3
  14. package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.d.ts +11 -0
  15. package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js +2 -0
  16. package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js.map +7 -0
  17. package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfileModal.js +1 -1
  18. package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfileModal.js.map +2 -2
  19. package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js +1 -1
  20. package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js.map +2 -2
  21. package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeModal.js +1 -1
  22. package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeModal.js.map +2 -2
  23. package/dist/cjs/components/memberPopup/panels/EarnCredits/index.js +1 -1
  24. package/dist/cjs/components/memberPopup/panels/EarnCredits/index.js.map +2 -2
  25. package/dist/cjs/components/memberPopup/panels/Referral/index.js +1 -1
  26. package/dist/cjs/components/memberPopup/panels/Referral/index.js.map +2 -2
  27. package/dist/cjs/components/memberPopup/type.d.ts +32 -2
  28. package/dist/cjs/components/memberPopup/type.js +1 -1
  29. package/dist/cjs/components/memberPopup/type.js.map +3 -3
  30. package/dist/esm/components/credits/context/hooks/useCountries.js +1 -1
  31. package/dist/esm/components/credits/context/hooks/useCountries.js.map +3 -3
  32. package/dist/esm/components/memberPopup/MemberPopup.js +1 -1
  33. package/dist/esm/components/memberPopup/MemberPopup.js.map +3 -3
  34. package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.d.ts +10 -0
  35. package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js +2 -0
  36. package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +7 -0
  37. package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.d.ts +2 -1
  38. package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js +1 -1
  39. package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js.map +3 -3
  40. package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.d.ts +2 -1
  41. package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.js +1 -1
  42. package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.js.map +3 -3
  43. package/dist/esm/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.d.ts +11 -0
  44. package/dist/esm/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js +2 -0
  45. package/dist/esm/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js.map +7 -0
  46. package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfileModal.js +1 -1
  47. package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfileModal.js.map +2 -2
  48. package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js +1 -1
  49. package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js.map +2 -2
  50. package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeModal.js +1 -1
  51. package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeModal.js.map +2 -2
  52. package/dist/esm/components/memberPopup/panels/EarnCredits/index.js +1 -1
  53. package/dist/esm/components/memberPopup/panels/EarnCredits/index.js.map +2 -2
  54. package/dist/esm/components/memberPopup/panels/Referral/index.js +1 -1
  55. package/dist/esm/components/memberPopup/panels/Referral/index.js.map +2 -2
  56. package/dist/esm/components/memberPopup/type.d.ts +32 -2
  57. package/dist/esm/components/memberPopup/type.js +1 -1
  58. package/dist/esm/components/memberPopup/type.js.map +3 -3
  59. package/package.json +1 -1
  60. package/src/components/credits/context/hooks/useCountries.ts +4 -15
  61. package/src/components/memberPopup/MemberPopup.tsx +96 -44
  62. package/src/components/memberPopup/panels/ActivitiesSubscribePanel.tsx +194 -0
  63. package/src/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.tsx +61 -28
  64. package/src/components/memberPopup/panels/ConsumeCredits/index.tsx +124 -65
  65. package/src/components/memberPopup/panels/EarnCredits/CompleteProfileModal.tsx +6 -1
  66. package/src/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.tsx +6 -1
  67. package/src/components/memberPopup/panels/EarnCredits/index.tsx +95 -65
  68. package/src/components/memberPopup/panels/Referral/index.tsx +1 -1
  69. package/src/components/memberPopup/type.ts +31 -2
  70. package/src/components/memberPopup/panels/ConsumeCredits/RedeemCouponModal.tsx +0 -150
  71. package/src/components/memberPopup/panels/EarnCredits/SubscribeModal.tsx +0 -144
  72. package/src/components/memberPopup/panels/EarnCredits/SubscribePanel.tsx +0 -147
@@ -1,2 +1,2 @@
1
- "use strict";var p=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var S=(o,e)=>{for(var t in e)p(o,t,{get:e[t],enumerable:!0})},m=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of y(e))!C.call(o,s)&&s!==t&&p(o,s,{get:()=>e[s],enumerable:!(n=g(e,s))||n.enumerable});return o};var w=o=>m(p({},"__esModule",{value:!0}),o);var x={};S(x,{default:()=>b});module.exports=w(x);var a=require("react"),d=require("@anker-in/lib");function E({shopifyStoreDomain:o}){const{locale:e=""}=(0,d.useHeadlessContext)(),[t,n]=(0,a.useState)(!1),[s,u]=(0,a.useState)([]);return(0,a.useEffect)(()=>{(async()=>{n(!0);try{const f=await(await fetch(`/api/multipass/rainbowbridge/uc/shop/shipping_zones?shop=${o}`,{headers:{"current-language":e}})).json();let i=[];const l=new Set;(f?.data?.data||f?.data||[]).forEach(c=>{c.countries.forEach(r=>{l.has(r.code)||(l.add(r.code),i.push(r))})}),i=i.sort((c,r)=>c.code.localeCompare(r.code)),console.log("fetch shipsToCountries",i),u(i)}catch(h){u([]),console.error(h)}finally{n(!1)}})()},[e]),{isLoading:t,countries:s}}var b=E;
1
+ "use strict";var a=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var y=(t,e)=>{for(var s in e)a(t,s,{get:e[s],enumerable:!0})},g=(t,e,s,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of m(e))!C.call(t,o)&&o!==s&&a(t,o,{get:()=>e[o],enumerable:!(n=h(e,o))||n.enumerable});return t};var d=t=>g(a({},"__esModule",{value:!0}),t);var x={};y(x,{default:()=>w});module.exports=d(x);var r=require("react"),p=require("@anker-in/lib");function S({shopifyStoreDomain:t}){const{locale:e=""}=(0,p.useHeadlessContext)(),[s,n]=(0,r.useState)(!1),[o,c]=(0,r.useState)([]);return(0,r.useEffect)(()=>{(async()=>{n(!0);try{let i=(await(await fetch("/api/multipass/account/countries",{headers:{"current-language":e}})).json())?.data?.data||[];i=i.sort((f,l)=>f.name.localeCompare(l.name)),console.log("fetch shipsToCountries",i),c(i)}catch(u){c([]),console.error(u)}finally{n(!1)}})()},[e]),{isLoading:s,countries:o}}var w=S;
2
2
  //# sourceMappingURL=useCountries.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/credits/context/hooks/useCountries.ts"],
4
- "sourcesContent": ["import { useEffect, useState } from 'react'\n\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { type ShippingCountry, type ShippingZone } from '../../type'\n\nfunction useCountries({ shopifyStoreDomain }: { shopifyStoreDomain: string }) {\n const { locale = '' } = useHeadlessContext()\n\n const [isLoading, setLoading] = useState(false)\n const [countries, setCountries] = useState<ShippingCountry[]>([])\n\n useEffect(() => {\n const fetchCountries = async () => {\n setLoading(true)\n try {\n const response = await fetch(`/api/multipass/rainbowbridge/uc/shop/shipping_zones?shop=${shopifyStoreDomain}`, {\n headers: {\n 'current-language': locale,\n },\n })\n const res: any = await response.json()\n\n // \u56FD\u5BB6\u8FC7\u6EE4\n let shipsToCountries: ShippingCountry[] = []\n const countrySet = new Set()\n const shippingZones = res?.data?.data || res?.data || []\n shippingZones.forEach((shippingZoneItem: ShippingZone) => {\n shippingZoneItem.countries.forEach(shippingZoneCountryItem => {\n if (!countrySet.has(shippingZoneCountryItem.code)) {\n countrySet.add(shippingZoneCountryItem.code)\n shipsToCountries.push(shippingZoneCountryItem)\n }\n })\n })\n\n // \u5B57\u6BCD\u987A\u5E8F\u6392\u5E8F\n shipsToCountries = shipsToCountries.sort((a, b) => {\n return a.code.localeCompare(b.code)\n })\n\n console.log('fetch shipsToCountries', shipsToCountries)\n setCountries(shipsToCountries)\n } catch (e) {\n setCountries([])\n console.error(e)\n } finally {\n setLoading(false)\n }\n }\n\n fetchCountries()\n }, [locale])\n\n return {\n isLoading,\n countries,\n }\n}\n\nexport default useCountries\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,iBAEpCC,EAAmC,yBAGnC,SAASC,EAAa,CAAE,mBAAAC,CAAmB,EAAmC,CAC5E,KAAM,CAAE,OAAAC,EAAS,EAAG,KAAI,sBAAmB,EAErC,CAACC,EAAWC,CAAU,KAAI,YAAS,EAAK,EACxC,CAACC,EAAWC,CAAY,KAAI,YAA4B,CAAC,CAAC,EAEhE,sBAAU,IAAM,EACS,SAAY,CACjCF,EAAW,EAAI,EACf,GAAI,CAMF,MAAMG,EAAW,MALA,MAAM,MAAM,4DAA4DN,CAAkB,GAAI,CAC7G,QAAS,CACP,mBAAoBC,CACtB,CACF,CAAC,GAC+B,KAAK,EAGrC,IAAIM,EAAsC,CAAC,EAC3C,MAAMC,EAAa,IAAI,KACDF,GAAK,MAAM,MAAQA,GAAK,MAAQ,CAAC,GACzC,QAASG,GAAmC,CACxDA,EAAiB,UAAU,QAAQC,GAA2B,CACvDF,EAAW,IAAIE,EAAwB,IAAI,IAC9CF,EAAW,IAAIE,EAAwB,IAAI,EAC3CH,EAAiB,KAAKG,CAAuB,EAEjD,CAAC,CACH,CAAC,EAGDH,EAAmBA,EAAiB,KAAK,CAACI,EAAGC,IACpCD,EAAE,KAAK,cAAcC,EAAE,IAAI,CACnC,EAED,QAAQ,IAAI,yBAA0BL,CAAgB,EACtDF,EAAaE,CAAgB,CAC/B,OAASM,EAAG,CACVR,EAAa,CAAC,CAAC,EACf,QAAQ,MAAMQ,CAAC,CACjB,QAAE,CACAV,EAAW,EAAK,CAClB,CACF,GAEe,CACjB,EAAG,CAACF,CAAM,CAAC,EAEJ,CACL,UAAAC,EACA,UAAAE,CACF,CACF,CAEA,IAAOT,EAAQI",
6
- "names": ["useCountries_exports", "__export", "useCountries_default", "__toCommonJS", "import_react", "import_lib", "useCountries", "shopifyStoreDomain", "locale", "isLoading", "setLoading", "countries", "setCountries", "res", "shipsToCountries", "countrySet", "shippingZoneItem", "shippingZoneCountryItem", "a", "b", "e"]
4
+ "sourcesContent": ["import { useEffect, useState } from 'react'\n\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { type ShippingCountry } from '../../type'\n\nfunction useCountries({ shopifyStoreDomain }: { shopifyStoreDomain: string }) {\n const { locale = '' } = useHeadlessContext()\n\n const [isLoading, setLoading] = useState(false)\n const [countries, setCountries] = useState<ShippingCountry[]>([])\n\n useEffect(() => {\n const fetchCountries = async () => {\n setLoading(true)\n try {\n const response = await fetch('/api/multipass/account/countries', {\n headers: {\n 'current-language': locale,\n },\n })\n const res: any = await response.json()\n\n let shipsToCountries: ShippingCountry[] = res?.data?.data || []\n\n // \u5B57\u6BCD\u987A\u5E8F\u6392\u5E8F\n shipsToCountries = shipsToCountries.sort((a, b) => {\n return a.name.localeCompare(b.name)\n })\n\n console.log('fetch shipsToCountries', shipsToCountries)\n setCountries(shipsToCountries)\n } catch (e) {\n setCountries([])\n console.error(e)\n } finally {\n setLoading(false)\n }\n }\n\n fetchCountries()\n }, [locale])\n\n return {\n isLoading,\n countries,\n }\n}\n\nexport default useCountries\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,iBAEpCC,EAAmC,yBAGnC,SAASC,EAAa,CAAE,mBAAAC,CAAmB,EAAmC,CAC5E,KAAM,CAAE,OAAAC,EAAS,EAAG,KAAI,sBAAmB,EAErC,CAACC,EAAWC,CAAU,KAAI,YAAS,EAAK,EACxC,CAACC,EAAWC,CAAY,KAAI,YAA4B,CAAC,CAAC,EAEhE,sBAAU,IAAM,EACS,SAAY,CACjCF,EAAW,EAAI,EACf,GAAI,CAQF,IAAIG,GAFa,MALA,MAAM,MAAM,mCAAoC,CAC/D,QAAS,CACP,mBAAoBL,CACtB,CACF,CAAC,GAC+B,KAAK,IAEU,MAAM,MAAQ,CAAC,EAG9DK,EAAmBA,EAAiB,KAAK,CAACC,EAAGC,IACpCD,EAAE,KAAK,cAAcC,EAAE,IAAI,CACnC,EAED,QAAQ,IAAI,yBAA0BF,CAAgB,EACtDD,EAAaC,CAAgB,CAC/B,OAASG,EAAG,CACVJ,EAAa,CAAC,CAAC,EACf,QAAQ,MAAMI,CAAC,CACjB,QAAE,CACAN,EAAW,EAAK,CAClB,CACF,GAEe,CACjB,EAAG,CAACF,CAAM,CAAC,EAEJ,CACL,UAAAC,EACA,UAAAE,CACF,CACF,CAEA,IAAOT,EAAQI",
6
+ "names": ["useCountries_exports", "__export", "useCountries_default", "__toCommonJS", "import_react", "import_lib", "useCountries", "shopifyStoreDomain", "locale", "isLoading", "setLoading", "countries", "setCountries", "shipsToCountries", "a", "b", "e"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";"use client";var D=Object.create;var g=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var F=(e,i)=>{for(var n in i)g(e,n,{get:i[n],enumerable:!0})},h=(e,i,n,u)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of U(i))!q.call(e,a)&&a!==n&&g(e,a,{get:()=>i[a],enumerable:!(u=L(i,a))||u.enumerable});return e};var m=(e,i,n)=>(n=e!=null?D(B(e)):{},h(i||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),G=e=>h(g({},"__esModule",{value:!0}),e);var oe={};F(oe,{MemberPopup:()=>ee});module.exports=G(oe);var t=require("react/jsx-runtime"),r=require("react"),I=require("@anker-in/headless-ui"),f=require("@anker-in/lib"),o=require("./type"),k=require("./context/provider"),M=require("./context/provider"),O=require("./context/viewStack"),p=require("./icons"),A=require("../../constants");const J=(0,r.lazy)(()=>import("./panels/EarnCredits")),K=(0,r.lazy)(()=>import("./panels/ConsumeCredits")),Q=(0,r.lazy)(()=>import("./panels/Referral")),W=(0,r.lazy)(()=>import("./panels/EarnCredits/CompleteProfilePanel")),X=(0,r.lazy)(()=>import("./panels/EarnCredits/SubscribePanel")),Y=(0,r.lazy)(()=>import("./panels/EarnCredits/SubscribeEmailPanel")),Z=(0,r.lazy)(()=>import("./panels/EarnCredits/ActivatePanel")),$=(0,r.lazy)(()=>import("./panels/ConsumeCredits/RedeemCouponPanel"));function ee({copy:e,bottomOffset:i="24px",...n}){return(0,t.jsx)(k.MemberPopupProvider,{...n,earnCreditsCopy:e.earnCredits,children:(0,t.jsx)(te,{copy:e,bottomOffset:i})})}function te({copy:e,bottomOffset:i}){const{profile:n,openSignInPopup:u,openSignUpPopup:a}=(0,M.useMemberPopupContext)(),{brand:x,storeDomain:C}=(0,f.useHeadlessContext)(),v=A.ROUNDED_BRANDS.includes(x),V=!!n,[S,N]=(0,r.useState)(!1),[y,P]=(0,r.useState)([]),[R,z]=(0,r.useState)(!1),[E,H]=(0,r.useState)(!1),[T,j]=(0,r.useState)(!1),s=y[y.length-1]??null,b=(0,r.useCallback)(l=>{P(d=>[...d,l])},[]),c=(0,r.useCallback)(()=>{P(l=>l.slice(0,-1))},[]);function _(l,d){switch(l){case o.MemberPopupActionType.ExternalLink:d&&window.open(d,"_blank","noopener,noreferrer");break;case o.MemberPopupActionType.OpenEarnCredits:b({type:o.MemberPopupPanelType.EarnCredits});break;case o.MemberPopupActionType.OpenConsumeCredits:b({type:o.MemberPopupPanelType.ConsumeCredits});break;case o.MemberPopupActionType.OpenReferral:b({type:o.MemberPopupPanelType.Referral});break;case o.MemberPopupActionType.OpenSubscribe:b({type:o.MemberPopupPanelType.Subscribe});break}}function w(){N(!1),P([])}return(0,t.jsxs)(O.ViewStackContext.Provider,{value:{pushView:b,popView:c},children:[S&&(0,t.jsx)("div",{className:"fixed inset-0 z-[998]",onClick:w}),(0,t.jsxs)("div",{className:"fixed right-0 z-[999] flex flex-col items-end pr-[16px]",style:{bottom:i},children:[S&&(0,t.jsxs)("div",{className:(0,f.classNames)("relative mb-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[600px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] cmp-md:w-[358px] cmp-sm:w-[258px]",v?"rounded-[12px]":"rounded-none"),onClick:l=>l.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"}),(0,t.jsxs)("div",{className:"flex items-center justify-between px-[16px] pb-[8px] pt-[16px]",children:[(0,t.jsx)("button",{className:"flex size-[24px] cursor-pointer items-center justify-center",onClick:c,"aria-label":"Back",children:(0,t.jsx)(p.IconSwitch,{})}),(0,t.jsx)("button",{className:"flex size-[24px] cursor-pointer items-center justify-center",onClick:w,"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]",style:{maxHeight:"min(calc(80vh - 118px), 606px)"},children:[s===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((l,d)=>(0,t.jsx)(se,{item:l,onAction:_,rounded:v},d))]}),s!==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:[s.type===o.MemberPopupPanelType.EarnCredits&&e.earnCredits&&(0,t.jsx)(J,{copy:e.earnCredits,onClose:c,isSubscribeSuccess:R,isActivateSuccess:E,isProfileCompleteSuccess:T,onSubscribeSuccess:()=>z(!0),onActivateSuccess:()=>H(!0),onProfileCompleteSuccess:()=>j(!0)}),s.type===o.MemberPopupPanelType.ConsumeCredits&&e.consumeCredits&&(0,t.jsx)(K,{copy:e.consumeCredits,onClose:c}),s.type===o.MemberPopupPanelType.Referral&&e.referral&&(0,t.jsx)(Q,{copy:e.referral,onClose:c}),s.type===o.MemberPopupPanelType.CompleteProfile&&e.earnCredits&&(0,t.jsx)(W,{copy:e.earnCredits.completeProfile,shopifyStoreDomain:C,onClose:c,onSuccess:s.props?.onSuccess}),s.type===o.MemberPopupPanelType.Subscribe&&e.subscribe&&(0,t.jsx)(X,{copy:e.subscribe,email:n?.email,onClose:c,onSuccess:s.props?.onSuccess}),s.type===o.MemberPopupPanelType.SubscribeEmail&&e.earnCredits&&(0,t.jsx)(Y,{copy:e.earnCredits.subscribe,email:n?.email,onClose:c,onSuccess:s.props?.onSuccess}),s.type===o.MemberPopupPanelType.Activate&&e.earnCredits&&(0,t.jsx)(Z,{copy:e.earnCredits.authCodeActivate,onClose:c,onSuccess:s.props?.onSuccess}),s.type===o.MemberPopupPanelType.RedeemCoupon&&s.props&&e.consumeCredits&&(0,t.jsx)($,{itemTitle:s.props.itemTitle,itemCredits:s.props.itemCredits,itemImage:s.props.itemImage,itemValue:s.props.itemValue,itemOff:s.props.itemOff,redeemId:s.props.redeemId,userId:s.props.userId,alpcConfig:s.props.alpcConfig,copy:e.consumeCredits.redeemModal,pointUnit:e.consumeCredits.pointUnit,onClose:c})]})]}),e.footer&&!V&&(0,t.jsx)("div",{className:"border-t border-[#dadce0] p-[16px]",children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-[16px]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-[4px]",children:[(0,t.jsx)("span",{className:"text-[14px] font-[700] text-[#080a0f]",children:e.footer.loginHint}),(0,t.jsx)("button",{className:"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline",onClick:u,children:e.footer.loginLabel})]}),(0,t.jsx)("div",{className:"flex shrink-0 items-center gap-[8px]",children:(0,t.jsx)("button",{className:(0,f.classNames)("cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]",v?"rounded-[4px]":"rounded-none"),onClick:a,children:e.footer.joinLabel})})]})})]}),(0,t.jsx)("button",{className:"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg",onClick:()=>N(l=>!l),"aria-label":e.triggerImg.alt??"Open member popup",children:(0,t.jsx)(I.Picture,{source:e.triggerImg.url,alt:e.triggerImg.alt??"",className:"size-[58px]"})})]})]})}function se({item:e,onAction:i,rounded:n}){const u={[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,f.classNames)("flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]",n?"rounded-[8px]":"rounded-none"),children:[(0,t.jsxs)("div",{className:"flex flex-col gap-[4px]",children:[(0,t.jsx)("h3",{className:"text-[20px] font-[700] leading-[1.2] text-[#1e2024]",children:e.title}),e.description&&(0,t.jsx)("p",{className:"text-[14px] font-[700] leading-[1.43] text-[#1e2024]",children:e.description})]}),(0,t.jsx)("div",{className:"flex flex-col gap-[16px]",children:e.links.map((a,x)=>{const C=u[a.type];return(0,t.jsxs)("div",{children:[x>0&&(0,t.jsx)("div",{className:"mb-[16px] h-px bg-[#dadce0]"}),(0,t.jsxs)("button",{className:"flex w-full cursor-pointer items-center gap-[12px]",onClick:()=>i(a.type,a.url),children:[C&&(0,t.jsx)(C,{className:"size-[24px] shrink-0"}),(0,t.jsx)("span",{className:"flex-1 text-left text-[14px] font-[700] text-[#1e2024]",children:a.label}),(0,t.jsx)(p.IconArrow,{className:"size-[16px] shrink-0"})]})]},x)})})]})}
1
+ "use strict";"use client";var W=Object.create;var g=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var Q=(e,i)=>{for(var n in i)g(e,n,{get:i[n],enumerable:!0})},O=(e,i,n,u)=>{if(i&&typeof i=="object"||typeof i=="function")for(let l of G(i))!K.call(e,l)&&l!==n&&g(e,l,{get:()=>i[l],enumerable:!(u=q(i,l))||u.enumerable});return e};var d=(e,i,n)=>(n=e!=null?W(J(e)):{},O(i||!e||!e.__esModule?g(n,"default",{value:e,enumerable:!0}):n,e)),X=e=>O(g({},"__esModule",{value:!0}),e);var ae={};Q(ae,{MemberPopup:()=>ie});module.exports=X(ae);var t=require("react/jsx-runtime"),r=require("react"),V=require("@anker-in/headless-ui"),f=require("@anker-in/lib"),s=require("./type"),R=require("./context/provider"),H=require("./context/provider"),z=require("./context/viewStack"),a=require("./icons"),E=require("../../constants");const Y=(0,r.lazy)(()=>import("./panels/EarnCredits")),Z=(0,r.lazy)(()=>import("./panels/ConsumeCredits")),$=(0,r.lazy)(()=>import("./panels/Referral")),ee=(0,r.lazy)(()=>import("./panels/EarnCredits/CompleteProfilePanel")),te=(0,r.lazy)(()=>import("./panels/ActivitiesSubscribePanel")),se=(0,r.lazy)(()=>import("./panels/EarnCredits/SubscribeEmailPanel")),oe=(0,r.lazy)(()=>import("./panels/EarnCredits/ActivatePanel")),re=(0,r.lazy)(()=>import("./panels/ConsumeCredits/RedeemCouponPanel"));function ie({copy:e,bottomOffset:i="24px",...n}){return(0,t.jsx)(R.MemberPopupProvider,{...n,earnCreditsCopy:e.earnCredits,children:(0,t.jsx)(ne,{copy:e,bottomOffset:i})})}function ne({copy:e,bottomOffset:i}){const{profile:n,openSignInPopup:u,openSignUpPopup:l}=(0,H.useMemberPopupContext)(),{brand:x,storeDomain:C}=(0,f.useHeadlessContext)(),v=E.ROUNDED_BRANDS.includes(x),T=!!n,[P,w]=(0,r.useState)(!1),[h,S]=(0,r.useState)([]),[j,_]=(0,r.useState)(!1),[N,D]=(0,r.useState)(!1),[F,L]=(0,r.useState)(!1),[U,y]=(0,r.useState)(!1),o=h[h.length-1]??null,I=(0,r.useMemo)(()=>{const p=e.pageConfig;if(!p)return!0;const m=typeof window<"u"?window.location.pathname:"",M=p.pages.some(A=>m===A||m.startsWith(A+"/"));switch(p.scope){case s.MemberPopupPageScope.Include:return M;case s.MemberPopupPageScope.Exclude:return!M;default:return!0}},[e.pageConfig]),b=(0,r.useCallback)(p=>{S(m=>[...m,p])},[]),c=(0,r.useCallback)(()=>{S(p=>p.slice(0,-1))},[]);if(console.log("isVisible",I),!I)return null;function B(p,m){switch(p){case s.MemberPopupActionType.ExternalLink:m&&window.open(m,"_blank","noopener,noreferrer");break;case s.MemberPopupActionType.OpenEarnCredits:b({type:s.MemberPopupPanelType.EarnCredits});break;case s.MemberPopupActionType.OpenConsumeCredits:b({type:s.MemberPopupPanelType.ConsumeCredits});break;case s.MemberPopupActionType.OpenReferral:b({type:s.MemberPopupPanelType.Referral});break;case s.MemberPopupActionType.OpenSubscribe:b({type:s.MemberPopupPanelType.Subscribe});break}}function k(){w(!1),S([]),y(!1)}return(0,t.jsxs)(z.ViewStackContext.Provider,{value:{pushView:b,popView:c},children:[P&&(0,t.jsx)("div",{className:"fixed inset-0 z-[998]",onClick:k}),(0,t.jsxs)("div",{className:"fixed right-0 z-[999] flex flex-row items-end pr-[16px] md:flex-col md:items-end md:right-0 md:w-screen md:pr-0 md:pl-0",style:{bottom:i},children:[P&&(0,t.jsxs)("div",{className:(0,f.classNames)("relative mr-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[500px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] md:mr-0 md:mb-[8px] md:mx-[16px] md:w-[calc(100vw-32px)] md:max-w-[400px]",v?"rounded-[12px]":"rounded-none"),style:{maxHeight:"min(80vh, 606px)"},onClick:p=>p.stopPropagation(),children:[(0,t.jsx)("div",{className:"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white md:bottom-[-8px] md:left-auto md:right-[29px] md:top-auto md:border-x-8 md:border-b-transparent md:border-t-white"}),(0,t.jsxs)("div",{className:"flex items-center justify-end pl-[10px] pr-[16px] pb-[8px] pt-[16px]",children:[o!==null&&(0,t.jsx)("button",{className:"mr-auto flex size-[24px] cursor-pointer items-center justify-center",onClick:c,"aria-label":"Back",children:(0,t.jsx)(a.IconSwitch,{})}),(0,t.jsx)("button",{className:"flex size-[24px] cursor-pointer items-center justify-center",onClick:k,"aria-label":"Close",children:(0,t.jsx)(a.IconClose,{})})]}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]",children:[o===null&&(0,t.jsxs)(t.Fragment,{children:[(e.title||e.subtitle)&&(0,t.jsxs)("div",{className:"flex flex-col gap-[4px]",children:[e.title&&(0,t.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:e.title}),e.subtitle&&(0,t.jsx)("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:e.subtitle})]}),e.list.map((p,m)=>(0,t.jsx)(pe,{item:p,onAction:B,rounded:v},m))]}),o!==null&&(0,t.jsxs)(r.Suspense,{fallback:(0,t.jsx)("div",{className:"flex items-center justify-center py-[32px]",children:(0,t.jsx)("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}),children:[o.type===s.MemberPopupPanelType.EarnCredits&&e.earnCredits&&(0,t.jsx)(Y,{copy:e.earnCredits,onClose:c,isSubscribeSuccess:j,isActivateSuccess:N,isProfileCompleteSuccess:F,onSubscribeSuccess:()=>_(!0),onActivateSuccess:()=>D(!0),onProfileCompleteSuccess:()=>L(!0)}),o.type===s.MemberPopupPanelType.ConsumeCredits&&e.consumeCredits&&(0,t.jsx)(Z,{copy:e.consumeCredits,onClose:c,isActivateSuccess:N}),o.type===s.MemberPopupPanelType.Referral&&e.referral&&(0,t.jsx)($,{copy:e.referral,onClose:c}),o.type===s.MemberPopupPanelType.CompleteProfile&&e.earnCredits&&(0,t.jsx)(ee,{copy:e.earnCredits.completeProfile,shopifyStoreDomain:C,onClose:c,onSuccess:o.props?.onSuccess}),o.type===s.MemberPopupPanelType.Subscribe&&e.activitiesSubscribe&&(0,t.jsx)(te,{copy:e.activitiesSubscribe,email:n?.email,onSuccess:o.props?.onSuccess,hideForm:U,onHideForm:()=>y(!0)}),o.type===s.MemberPopupPanelType.SubscribeEmail&&e.earnCredits&&(0,t.jsx)(se,{copy:e.earnCredits.subscribe,email:n?.email,onClose:c,onSuccess:o.props?.onSuccess}),o.type===s.MemberPopupPanelType.Activate&&e.earnCredits&&(0,t.jsx)(oe,{copy:e.earnCredits.authCodeActivate,onClose:c,onSuccess:o.props?.onSuccess}),o.type===s.MemberPopupPanelType.RedeemCoupon&&o.props&&e.consumeCredits&&(0,t.jsx)(re,{itemTitle:o.props.itemTitle,itemCredits:o.props.itemCredits,itemImage:o.props.itemImage,itemValue:o.props.itemValue,itemOff:o.props.itemOff,itemRules:o.props.itemRules,redeemId:o.props.redeemId,userId:o.props.userId,alpcConfig:o.props.alpcConfig,copy:e.consumeCredits.redeemModal,pointUnit:e.consumeCredits.pointUnit,onClose:c})]})]}),e.footer&&!T&&(0,t.jsx)("div",{className:"border-t border-[#dadce0] p-[16px]",children:(0,t.jsxs)("div",{className:"flex items-center justify-between gap-[16px]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-[4px]",children:[(0,t.jsx)("span",{className:"text-[14px] font-[700] text-[#080a0f]",children:e.footer.loginHint}),(0,t.jsx)("button",{className:"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline",onClick:u,children:e.footer.loginLabel})]}),(0,t.jsx)("div",{className:"flex shrink-0 items-center gap-[8px]",children:(0,t.jsx)("button",{className:(0,f.classNames)("cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]",v?"rounded-[4px]":"rounded-none"),onClick:l,children:e.footer.joinLabel})})]})})]}),(0,t.jsx)("button",{className:"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg md:ml-auto md:mr-[16px]",onClick:()=>w(p=>!p),"aria-label":e.triggerImg.alt??"Open member popup",children:(0,t.jsx)(V.Picture,{source:e.triggerImg.url,alt:e.triggerImg.alt??"",className:"size-[58px]"})})]})]})}function pe({item:e,onAction:i,rounded:n}){const u={[s.MemberPopupActionType.OpenEarnCredits]:a.IconCredit,[s.MemberPopupActionType.OpenConsumeCredits]:a.IconBag,[s.MemberPopupActionType.OpenReferral]:a.IconReferral,[s.MemberPopupActionType.OpenSubscribe]:a.IconSubscription};return(0,t.jsxs)("div",{className:(0,f.classNames)("flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]",n?"rounded-[8px]":"rounded-none"),children:[(0,t.jsxs)("div",{className:"flex flex-col gap-[4px]",children:[(0,t.jsx)("h3",{className:"text-[20px] font-[700] leading-[1.2] text-[#1e2024]",children:e.title}),e.description&&(0,t.jsx)("p",{className:"text-[14px] font-[700] leading-[1.43] text-[#1e2024]",children:e.description})]}),(0,t.jsx)("div",{className:"flex flex-col gap-[16px]",children:e.links.map((l,x)=>{const C=u[l.type];return(0,t.jsxs)("div",{children:[x>0&&(0,t.jsx)("div",{className:"mb-[16px] h-px bg-[#dadce0]"}),(0,t.jsxs)("button",{className:"flex w-full cursor-pointer items-center gap-[12px]",onClick:()=>i(l.type,l.url),children:[C&&(0,t.jsx)(C,{className:"size-[24px] shrink-0"}),(0,t.jsx)("span",{className:"flex-1 text-left text-[14px] font-[700] text-[#1e2024]",children:l.label}),(0,t.jsx)(a.IconArrow,{className:"size-[16px] shrink-0"})]})]},x)})})]})}
2
2
  //# sourceMappingURL=MemberPopup.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/memberPopup/MemberPopup.tsx"],
4
- "sourcesContent": ["'use client'\n\nimport { lazy, Suspense, useState, useCallback } from 'react'\nimport { Picture } from '@anker-in/headless-ui'\nimport { type HeadlessConfig, useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport {\n MemberPopupActionType,\n MemberPopupPanelType,\n type MemberPopupCopy,\n type MemberPopupContextValue,\n type MemberPopupItem,\n} from './type'\nimport { MemberPopupProvider } from './context/provider'\nimport { useMemberPopupContext } from './context/provider'\nimport { ViewStackContext, type ViewPayload } from './context/viewStack'\nimport { IconClose, IconArrow, IconCredit, IconBag, IconReferral, IconSwitch, IconSubscription } from './icons'\nimport { ROUNDED_BRANDS } from '../../constants'\n\nconst EarnCredits = lazy(() => import('./panels/EarnCredits'))\nconst ConsumeCredits = lazy(() => import('./panels/ConsumeCredits'))\nconst Referral = lazy(() => import('./panels/Referral'))\nconst CompleteProfile = lazy(() => import('./panels/EarnCredits/CompleteProfilePanel'))\nconst Subscribe = lazy(() => import('./panels/EarnCredits/SubscribePanel'))\nconst SubscribeEmail = lazy(() => import('./panels/EarnCredits/SubscribeEmailPanel'))\nconst Activate = lazy(() => import('./panels/EarnCredits/ActivatePanel'))\nconst RedeemCoupon = lazy(() => import('./panels/ConsumeCredits/RedeemCouponPanel'))\n\ntype MemberPopupProps = MemberPopupContextValue & {\n headlessConfig: HeadlessConfig\n copy: MemberPopupCopy\n bottomOffset?: string\n}\n\nexport function MemberPopup({ copy, bottomOffset = '24px', ...providerProps }: MemberPopupProps) {\n return (\n <MemberPopupProvider {...providerProps} earnCreditsCopy={copy.earnCredits}>\n <MemberPopupContent copy={copy} bottomOffset={bottomOffset} />\n </MemberPopupProvider>\n )\n}\n\ntype MemberPopupContentProps = {\n copy: MemberPopupCopy\n bottomOffset: string\n}\n\nfunction MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {\n const { profile, openSignInPopup, openSignUpPopup } = useMemberPopupContext()\n const { brand, storeDomain } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n const isLogin = !!profile\n const [isOpen, setIsOpen] = useState(false)\n const [viewStack, setViewStack] = useState<ViewPayload[]>([])\n const [isSubscribeSuccess, setIsSubscribeSuccess] = useState(false)\n const [isActivateSuccess, setIsActivateSuccess] = useState(false)\n const [isProfileCompleteSuccess, setIsProfileCompleteSuccess] = useState(false)\n\n const currentView = viewStack[viewStack.length - 1] ?? null\n\n const pushView = useCallback((view: ViewPayload) => {\n setViewStack(prev => [...prev, view])\n }, [])\n\n const popView = useCallback(() => {\n setViewStack(prev => prev.slice(0, -1))\n }, [])\n\n function handleAction(type: MemberPopupActionType, url?: string) {\n switch (type) {\n case MemberPopupActionType.ExternalLink:\n if (url) window.open(url, '_blank', 'noopener,noreferrer')\n break\n case MemberPopupActionType.OpenEarnCredits:\n pushView({ type: MemberPopupPanelType.EarnCredits })\n break\n case MemberPopupActionType.OpenConsumeCredits:\n pushView({ type: MemberPopupPanelType.ConsumeCredits })\n break\n case MemberPopupActionType.OpenReferral:\n pushView({ type: MemberPopupPanelType.Referral })\n break\n case MemberPopupActionType.OpenSubscribe:\n pushView({ type: MemberPopupPanelType.Subscribe })\n break\n }\n }\n\n function handleClose() {\n setIsOpen(false)\n setViewStack([])\n }\n\n return (\n <ViewStackContext.Provider value={{ pushView, popView }}>\n {isOpen && (\n <div\n className=\"fixed inset-0 z-[998]\"\n onClick={handleClose}\n />\n )}\n <div className=\"fixed right-0 z-[999] flex flex-col items-end pr-[16px]\" style={{ bottom: bottomOffset }}>\n {isOpen && (\n <div\n className={cn('relative mb-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[600px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] cmp-md:w-[358px] cmp-sm:w-[258px]', rounded ? 'rounded-[12px]' : 'rounded-none')}\n onClick={e => e.stopPropagation()}\n >\n <div className=\"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white\" />\n <div className=\"flex items-center justify-between px-[16px] pb-[8px] pt-[16px]\">\n <button\n className=\"flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={popView}\n aria-label=\"Back\"\n >\n <IconSwitch />\n </button>\n <button\n className=\"flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={handleClose}\n aria-label=\"Close\"\n >\n <IconClose />\n </button>\n </div>\n\n <div\n className=\"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]\"\n style={{ maxHeight: 'min(calc(80vh - 118px), 606px)' }}\n >\n {currentView === null && (\n <>\n {(copy.title || copy.subtitle) && (\n <div className=\"flex flex-col gap-[4px]\">\n {copy.title && (\n <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>\n )}\n {copy.subtitle && (\n <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>\n )}\n </div>\n )}\n {copy.list.map((item, i) => (\n <HomeCard key={i} item={item} onAction={handleAction} rounded={rounded} />\n ))}\n </>\n )}\n\n {currentView !== null && (\n <Suspense\n fallback={\n <div className=\"flex items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n }\n >\n {currentView.type === MemberPopupPanelType.EarnCredits && copy.earnCredits && (\n <EarnCredits\n copy={copy.earnCredits}\n onClose={popView}\n isSubscribeSuccess={isSubscribeSuccess}\n isActivateSuccess={isActivateSuccess}\n isProfileCompleteSuccess={isProfileCompleteSuccess}\n onSubscribeSuccess={() => setIsSubscribeSuccess(true)}\n onActivateSuccess={() => setIsActivateSuccess(true)}\n onProfileCompleteSuccess={() => setIsProfileCompleteSuccess(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.ConsumeCredits && copy.consumeCredits && (\n <ConsumeCredits copy={copy.consumeCredits} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.Referral && copy.referral && (\n <Referral copy={copy.referral} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.CompleteProfile && copy.earnCredits && (\n <CompleteProfile copy={copy.earnCredits.completeProfile} shopifyStoreDomain={storeDomain} onClose={popView} onSuccess={currentView.props?.onSuccess} />\n )}\n {currentView.type === MemberPopupPanelType.Subscribe && copy.subscribe && (\n <Subscribe copy={copy.subscribe} email={profile?.email} onClose={popView} onSuccess={currentView.props?.onSuccess} />\n )}\n {currentView.type === MemberPopupPanelType.SubscribeEmail && copy.earnCredits && (\n <SubscribeEmail copy={copy.earnCredits.subscribe} email={profile?.email} onClose={popView} onSuccess={currentView.props?.onSuccess} />\n )}\n {currentView.type === MemberPopupPanelType.Activate && copy.earnCredits && (\n <Activate copy={copy.earnCredits.authCodeActivate} onClose={popView} onSuccess={currentView.props?.onSuccess} />\n )}\n {currentView.type === MemberPopupPanelType.RedeemCoupon && currentView.props && copy.consumeCredits && (\n <RedeemCoupon\n itemTitle={currentView.props.itemTitle}\n itemCredits={currentView.props.itemCredits}\n itemImage={currentView.props.itemImage}\n itemValue={currentView.props.itemValue}\n itemOff={currentView.props.itemOff}\n redeemId={currentView.props.redeemId}\n userId={currentView.props.userId}\n alpcConfig={currentView.props.alpcConfig}\n copy={copy.consumeCredits.redeemModal}\n pointUnit={copy.consumeCredits.pointUnit}\n onClose={popView}\n />\n )}\n </Suspense>\n )}\n </div>\n\n {copy.footer && !isLogin && (\n <div className=\"border-t border-[#dadce0] p-[16px]\">\n <div className=\"flex items-center justify-between gap-[16px]\">\n <div className=\"flex items-center gap-[4px]\">\n <span className=\"text-[14px] font-[700] text-[#080a0f]\">{copy.footer.loginHint}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline\"\n onClick={openSignInPopup}\n >\n {copy.footer.loginLabel}\n </button>\n </div>\n <div className=\"flex shrink-0 items-center gap-[8px]\">\n <button\n className={cn('cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]', rounded ? 'rounded-[4px]' : 'rounded-none')}\n onClick={openSignUpPopup}\n >\n {copy.footer.joinLabel}\n </button>\n </div>\n </div>\n </div>\n )}\n </div>\n )}\n\n <button\n className=\"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg\"\n onClick={() => setIsOpen(prev => !prev)}\n aria-label={copy.triggerImg.alt ?? 'Open member popup'}\n >\n <Picture source={copy.triggerImg.url} alt={copy.triggerImg.alt ?? ''} className=\"size-[58px]\" />\n </button>\n </div>\n </ViewStackContext.Provider>\n )\n}\n\ntype HomeCardProps = {\n item: MemberPopupItem\n onAction: (type: MemberPopupActionType, url?: string) => void\n rounded: boolean\n}\n\nfunction HomeCard({ item, onAction, rounded }: HomeCardProps) {\n const ACTION_ICON: Partial<Record<MemberPopupActionType, typeof IconCredit>> = {\n [MemberPopupActionType.OpenEarnCredits]: IconCredit,\n [MemberPopupActionType.OpenConsumeCredits]: IconBag,\n [MemberPopupActionType.OpenReferral]: IconReferral,\n [MemberPopupActionType.OpenSubscribe]: IconSubscription,\n }\n\n return (\n <div className={cn('flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <div className=\"flex flex-col gap-[4px]\">\n <h3 className=\"text-[20px] font-[700] leading-[1.2] text-[#1e2024]\">{item.title}</h3>\n {item.description && <p className=\"text-[14px] font-[700] leading-[1.43] text-[#1e2024]\">{item.description}</p>}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n {item.links.map((link, i) => {\n const IconComponent = ACTION_ICON[link.type]\n return (\n <div key={i}>\n {i > 0 && <div className=\"mb-[16px] h-px bg-[#dadce0]\" />}\n <button\n className=\"flex w-full cursor-pointer items-center gap-[12px]\"\n onClick={() => onAction(link.type, link.url)}\n >\n {IconComponent && <IconComponent className=\"size-[24px] shrink-0\" />}\n <span className=\"flex-1 text-left text-[14px] font-[700] text-[#1e2024]\">{link.label}</span>\n <IconArrow className=\"size-[16px] shrink-0\" />\n </button>\n </div>\n )\n })}\n </div>\n </div>\n )\n}\n"],
5
- "mappings": "ukBAAA,IAAAA,GAAA,GAAAC,EA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AK,WAAW,KAAO,oBAEnC,mBAAC,WAAQ,OAAQA,EAAK,WAAW,IAAK,IAAKA,EAAK,WAAW,KAAO,GAAI,UAAU,cAAc,EAChG,GACF,GACF,CAEJ,CAQA,SAASkC,GAAS,CAAE,KAAAF,EAAM,SAAAG,EAAU,QAAA1B,CAAQ,EAAkB,CAC5D,MAAM2B,EAAyE,CAC7E,CAAC,wBAAsB,eAAe,EAAG,aACzC,CAAC,wBAAsB,kBAAkB,EAAG,UAC5C,CAAC,wBAAsB,YAAY,EAAG,eACtC,CAAC,wBAAsB,aAAa,EAAG,kBACzC,EAEA,SACE,QAAC,OAAI,aAAW,EAAAN,YAAG,iDAAkDrB,EAAU,gBAAkB,cAAc,EAC7G,qBAAC,OAAI,UAAU,0BACb,oBAAC,MAAG,UAAU,sDAAuD,SAAAuB,EAAK,MAAM,EAC/EA,EAAK,gBAAe,OAAC,KAAE,UAAU,uDAAwD,SAAAA,EAAK,YAAY,GAC7G,KAEA,OAAC,OAAI,UAAU,2BACZ,SAAAA,EAAK,MAAM,IAAI,CAACK,EAAMJ,IAAM,CAC3B,MAAMK,EAAgBF,EAAYC,EAAK,IAAI,EAC3C,SACE,QAAC,OACE,UAAAJ,EAAI,MAAK,OAAC,OAAI,UAAU,8BAA8B,KACvD,QAAC,UACC,UAAU,qDACV,QAAS,IAAME,EAASE,EAAK,KAAMA,EAAK,GAAG,EAE1C,UAAAC,MAAiB,OAACA,EAAA,CAAc,UAAU,uBAAuB,KAClE,OAAC,QAAK,UAAU,yDAA0D,SAAAD,EAAK,MAAM,KACrF,OAAC,aAAU,UAAU,uBAAuB,GAC9C,IATQJ,CAUV,CAEJ,CAAC,EACH,GACF,CAEJ",
6
- "names": ["MemberPopup_exports", "__export", "MemberPopup", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_type", "import_provider", "import_viewStack", "import_icons", "import_constants", "EarnCredits", "ConsumeCredits", "Referral", "CompleteProfile", "Subscribe", "SubscribeEmail", "Activate", "RedeemCoupon", "copy", "bottomOffset", "providerProps", "MemberPopupContent", "profile", "openSignInPopup", "openSignUpPopup", "brand", "storeDomain", "rounded", "isLogin", "isOpen", "setIsOpen", "viewStack", "setViewStack", "isSubscribeSuccess", "setIsSubscribeSuccess", "isActivateSuccess", "setIsActivateSuccess", "isProfileCompleteSuccess", "setIsProfileCompleteSuccess", "currentView", "pushView", "view", "prev", "popView", "handleAction", "type", "url", "handleClose", "cn", "e", "item", "i", "HomeCard", "onAction", "ACTION_ICON", "link", "IconComponent"]
4
+ "sourcesContent": ["'use client'\n\nimport { lazy, Suspense, useState, useCallback, useMemo } from 'react'\nimport { Picture } from '@anker-in/headless-ui'\nimport { type HeadlessConfig, useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport {\n MemberPopupActionType,\n MemberPopupPageScope,\n MemberPopupPanelType,\n type MemberPopupCopy,\n type MemberPopupContextValue,\n type MemberPopupItem,\n} from './type'\nimport { MemberPopupProvider } from './context/provider'\nimport { useMemberPopupContext } from './context/provider'\nimport { ViewStackContext, type ViewPayload } from './context/viewStack'\nimport { IconClose, IconArrow, IconCredit, IconBag, IconReferral, IconSwitch, IconSubscription } from './icons'\nimport { ROUNDED_BRANDS } from '../../constants'\n\nconst EarnCredits = lazy(() => import('./panels/EarnCredits'))\nconst ConsumeCredits = lazy(() => import('./panels/ConsumeCredits'))\nconst Referral = lazy(() => import('./panels/Referral'))\nconst CompleteProfile = lazy(() => import('./panels/EarnCredits/CompleteProfilePanel'))\nconst ActivitiesSubscribe = lazy(() => import('./panels/ActivitiesSubscribePanel'))\nconst SubscribeEmail = lazy(() => import('./panels/EarnCredits/SubscribeEmailPanel'))\nconst Activate = lazy(() => import('./panels/EarnCredits/ActivatePanel'))\nconst RedeemCoupon = lazy(() => import('./panels/ConsumeCredits/RedeemCouponPanel'))\n\ntype MemberPopupProps = MemberPopupContextValue & {\n headlessConfig: HeadlessConfig\n copy: MemberPopupCopy\n bottomOffset?: string\n}\n\nexport function MemberPopup({ copy, bottomOffset = '24px', ...providerProps }: MemberPopupProps) {\n return (\n <MemberPopupProvider {...providerProps} earnCreditsCopy={copy.earnCredits}>\n <MemberPopupContent copy={copy} bottomOffset={bottomOffset} />\n </MemberPopupProvider>\n )\n}\n\ntype MemberPopupContentProps = {\n copy: MemberPopupCopy\n bottomOffset: string\n}\n\nfunction MemberPopupContent({ copy, bottomOffset }: MemberPopupContentProps) {\n const { profile, openSignInPopup, openSignUpPopup } = useMemberPopupContext()\n const { brand, storeDomain } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n const isLogin = !!profile\n const [isOpen, setIsOpen] = useState(false)\n const [viewStack, setViewStack] = useState<ViewPayload[]>([])\n const [isSubscribeSuccess, setIsSubscribeSuccess] = useState(false)\n const [isActivateSuccess, setIsActivateSuccess] = useState(false)\n const [isProfileCompleteSuccess, setIsProfileCompleteSuccess] = useState(false)\n const [isSubscribeFormHidden, setIsSubscribeFormHidden] = useState(false)\n\n const currentView = viewStack[viewStack.length - 1] ?? null\n\n const isVisible = useMemo(() => {\n const config = copy.pageConfig\n if (!config) return true\n const pathname = typeof window !== 'undefined' ? window.location.pathname : ''\n const matches = config.pages.some(page => pathname === page || pathname.startsWith(page + '/'))\n switch (config.scope) {\n case MemberPopupPageScope.Include:\n return matches\n case MemberPopupPageScope.Exclude:\n return !matches\n default:\n return true\n }\n }, [copy.pageConfig])\n\n const pushView = useCallback((view: ViewPayload) => {\n setViewStack(prev => [...prev, view])\n }, [])\n\n const popView = useCallback(() => {\n setViewStack(prev => prev.slice(0, -1))\n }, [])\n\n console.log('isVisible', isVisible)\n if (!isVisible) return null\n\n function handleAction(type: MemberPopupActionType, url?: string) {\n switch (type) {\n case MemberPopupActionType.ExternalLink:\n if (url) window.open(url, '_blank', 'noopener,noreferrer')\n break\n case MemberPopupActionType.OpenEarnCredits:\n pushView({ type: MemberPopupPanelType.EarnCredits })\n break\n case MemberPopupActionType.OpenConsumeCredits:\n pushView({ type: MemberPopupPanelType.ConsumeCredits })\n break\n case MemberPopupActionType.OpenReferral:\n pushView({ type: MemberPopupPanelType.Referral })\n break\n case MemberPopupActionType.OpenSubscribe:\n pushView({ type: MemberPopupPanelType.Subscribe })\n break\n }\n }\n\n function handleClose() {\n setIsOpen(false)\n setViewStack([])\n setIsSubscribeFormHidden(false)\n }\n\n return (\n <ViewStackContext.Provider value={{ pushView, popView }}>\n {isOpen && <div className=\"fixed inset-0 z-[998]\" onClick={handleClose} />}\n <div\n className=\"fixed right-0 z-[999] flex flex-row items-end pr-[16px] md:flex-col md:items-end md:right-0 md:w-screen md:pr-0 md:pl-0\"\n style={{ bottom: bottomOffset }}\n >\n {isOpen && (\n <div\n className={cn(\n 'relative mr-[8px] flex w-[420px] max-w-[calc(100vw-32px)] min-h-[500px] flex-col overflow-hidden bg-white shadow-[0_8px_32px_rgba(0,0,0,0.16)] md:mr-0 md:mb-[8px] md:mx-[16px] md:w-[calc(100vw-32px)] md:max-w-[400px]',\n rounded ? 'rounded-[12px]' : 'rounded-none'\n )}\n style={{ maxHeight: 'min(80vh, 606px)' }}\n onClick={e => e.stopPropagation()}\n >\n <div className=\"absolute right-[-8px] top-[24px] size-0 border-y-8 border-l-8 border-y-transparent border-l-white md:bottom-[-8px] md:left-auto md:right-[29px] md:top-auto md:border-x-8 md:border-b-transparent md:border-t-white\" />\n <div className=\"flex items-center justify-end pl-[10px] pr-[16px] pb-[8px] pt-[16px]\">\n {currentView !== null && (\n <button\n className=\"mr-auto flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={popView}\n aria-label=\"Back\"\n >\n <IconSwitch />\n </button>\n )}\n <button\n className=\"flex size-[24px] cursor-pointer items-center justify-center\"\n onClick={handleClose}\n aria-label=\"Close\"\n >\n <IconClose />\n </button>\n </div>\n\n <div className=\"flex flex-1 flex-col gap-[12px] overflow-y-auto p-[16px]\">\n {currentView === null && (\n <>\n {(copy.title || copy.subtitle) && (\n <div className=\"flex flex-col gap-[4px]\">\n {copy.title && (\n <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>\n )}\n {copy.subtitle && (\n <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>\n )}\n </div>\n )}\n {copy.list.map((item, i) => (\n <HomeCard key={i} item={item} onAction={handleAction} rounded={rounded} />\n ))}\n </>\n )}\n\n {currentView !== null && (\n <Suspense\n fallback={\n <div className=\"flex items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n }\n >\n {currentView.type === MemberPopupPanelType.EarnCredits && copy.earnCredits && (\n <EarnCredits\n copy={copy.earnCredits}\n onClose={popView}\n isSubscribeSuccess={isSubscribeSuccess}\n isActivateSuccess={isActivateSuccess}\n isProfileCompleteSuccess={isProfileCompleteSuccess}\n onSubscribeSuccess={() => setIsSubscribeSuccess(true)}\n onActivateSuccess={() => setIsActivateSuccess(true)}\n onProfileCompleteSuccess={() => setIsProfileCompleteSuccess(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.ConsumeCredits && copy.consumeCredits && (\n <ConsumeCredits\n copy={copy.consumeCredits}\n onClose={popView}\n isActivateSuccess={isActivateSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Referral && copy.referral && (\n <Referral copy={copy.referral} onClose={popView} />\n )}\n {currentView.type === MemberPopupPanelType.CompleteProfile && copy.earnCredits && (\n <CompleteProfile\n copy={copy.earnCredits.completeProfile}\n shopifyStoreDomain={storeDomain}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Subscribe && copy.activitiesSubscribe && (\n <ActivitiesSubscribe\n copy={copy.activitiesSubscribe}\n email={profile?.email}\n onSuccess={currentView.props?.onSuccess}\n hideForm={isSubscribeFormHidden}\n onHideForm={() => setIsSubscribeFormHidden(true)}\n />\n )}\n {currentView.type === MemberPopupPanelType.SubscribeEmail && copy.earnCredits && (\n <SubscribeEmail\n copy={copy.earnCredits.subscribe}\n email={profile?.email}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.Activate && copy.earnCredits && (\n <Activate\n copy={copy.earnCredits.authCodeActivate}\n onClose={popView}\n onSuccess={currentView.props?.onSuccess}\n />\n )}\n {currentView.type === MemberPopupPanelType.RedeemCoupon &&\n currentView.props &&\n copy.consumeCredits && (\n <RedeemCoupon\n itemTitle={currentView.props.itemTitle}\n itemCredits={currentView.props.itemCredits}\n itemImage={currentView.props.itemImage}\n itemValue={currentView.props.itemValue}\n itemOff={currentView.props.itemOff}\n itemRules={currentView.props.itemRules}\n redeemId={currentView.props.redeemId}\n userId={currentView.props.userId}\n alpcConfig={currentView.props.alpcConfig}\n copy={copy.consumeCredits.redeemModal}\n pointUnit={copy.consumeCredits.pointUnit}\n onClose={popView}\n />\n )}\n </Suspense>\n )}\n </div>\n\n {copy.footer && !isLogin && (\n <div className=\"border-t border-[#dadce0] p-[16px]\">\n <div className=\"flex items-center justify-between gap-[16px]\">\n <div className=\"flex items-center gap-[4px]\">\n <span className=\"text-[14px] font-[700] text-[#080a0f]\">{copy.footer.loginHint}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] text-[#080a0f] underline\"\n onClick={openSignInPopup}\n >\n {copy.footer.loginLabel}\n </button>\n </div>\n <div className=\"flex shrink-0 items-center gap-[8px]\">\n <button\n className={cn(\n 'cursor-pointer border-[1.6px] border-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n onClick={openSignUpPopup}\n >\n {copy.footer.joinLabel}\n </button>\n </div>\n </div>\n </div>\n )}\n </div>\n )}\n\n <button\n className=\"flex cursor-pointer items-center justify-center rounded-full bg-white shadow-lg md:ml-auto md:mr-[16px]\"\n onClick={() => setIsOpen(prev => !prev)}\n aria-label={copy.triggerImg.alt ?? 'Open member popup'}\n >\n <Picture source={copy.triggerImg.url} alt={copy.triggerImg.alt ?? ''} className=\"size-[58px]\" />\n </button>\n </div>\n </ViewStackContext.Provider>\n )\n}\n\ntype HomeCardProps = {\n item: MemberPopupItem\n onAction: (type: MemberPopupActionType, url?: string) => void\n rounded: boolean\n}\n\nfunction HomeCard({ item, onAction, rounded }: HomeCardProps) {\n const ACTION_ICON: Partial<Record<MemberPopupActionType, typeof IconCredit>> = {\n [MemberPopupActionType.OpenEarnCredits]: IconCredit,\n [MemberPopupActionType.OpenConsumeCredits]: IconBag,\n [MemberPopupActionType.OpenReferral]: IconReferral,\n [MemberPopupActionType.OpenSubscribe]: IconSubscription,\n }\n\n return (\n <div className={cn('flex flex-col gap-[16px] bg-[#f5f6f7] p-[16px]', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <div className=\"flex flex-col gap-[4px]\">\n <h3 className=\"text-[20px] font-[700] leading-[1.2] text-[#1e2024]\">{item.title}</h3>\n {item.description && <p className=\"text-[14px] font-[700] leading-[1.43] text-[#1e2024]\">{item.description}</p>}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n {item.links.map((link, i) => {\n const IconComponent = ACTION_ICON[link.type]\n return (\n <div key={i}>\n {i > 0 && <div className=\"mb-[16px] h-px bg-[#dadce0]\" />}\n <button\n className=\"flex w-full cursor-pointer items-center gap-[12px]\"\n onClick={() => onAction(link.type, link.url)}\n >\n {IconComponent && <IconComponent className=\"size-[24px] shrink-0\" />}\n <span className=\"flex-1 text-left text-[14px] font-[700] text-[#1e2024]\">{link.label}</span>\n <IconArrow className=\"size-[16px] shrink-0\" />\n </button>\n </div>\n )\n })}\n </div>\n </div>\n )\n}\n"],
5
+ "mappings": "ukBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,iBAAAE,KAAA,eAAAC,EAAAH,IAqCM,IAAAI,EAAA,6BAnCNC,EAA+D,iBAC/DC,EAAwB,iCACxBC,EAA0E,yBAC1EC,EAOO,kBACPC,EAAoC,8BACpCA,E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AC,UACC,UAAU,qDACV,QAAS,IAAME,EAASE,EAAK,KAAMA,EAAK,GAAG,EAE1C,UAAAC,MAAiB,OAACA,EAAA,CAAc,UAAU,uBAAuB,KAClE,OAAC,QAAK,UAAU,yDAA0D,SAAAD,EAAK,MAAM,KACrF,OAAC,aAAU,UAAU,uBAAuB,GAC9C,IATQJ,CAUV,CAEJ,CAAC,EACH,GACF,CAEJ",
6
+ "names": ["MemberPopup_exports", "__export", "MemberPopup", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_type", "import_provider", "import_viewStack", "import_icons", "import_constants", "EarnCredits", "ConsumeCredits", "Referral", "CompleteProfile", "ActivitiesSubscribe", "SubscribeEmail", "Activate", "RedeemCoupon", "copy", "bottomOffset", "providerProps", "MemberPopupContent", "profile", "openSignInPopup", "openSignUpPopup", "brand", "storeDomain", "rounded", "isLogin", "isOpen", "setIsOpen", "viewStack", "setViewStack", "isSubscribeSuccess", "setIsSubscribeSuccess", "isActivateSuccess", "setIsActivateSuccess", "isProfileCompleteSuccess", "setIsProfileCompleteSuccess", "isSubscribeFormHidden", "setIsSubscribeFormHidden", "currentView", "isVisible", "config", "pathname", "matches", "page", "pushView", "view", "prev", "popView", "handleAction", "type", "url", "handleClose", "cn", "e", "item", "i", "HomeCard", "onAction", "ACTION_ICON", "link", "IconComponent"]
7
7
  }
@@ -0,0 +1,10 @@
1
+ import type { SubscribeModalCopy } from '../type';
2
+ type Props = {
3
+ onSuccess?: () => void;
4
+ copy: SubscribeModalCopy;
5
+ email?: string;
6
+ hideForm: boolean;
7
+ onHideForm: () => void;
8
+ };
9
+ export default function ActivitiesSubscribeModal({ onSuccess, copy, email: initialEmail, hideForm, onHideForm, }: Props): import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";var j=Object.create;var m=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var q=(r,e)=>{for(var o in e)m(r,o,{get:e[o],enumerable:!0})},C=(r,e,o,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of F(e))!I.call(r,n)&&n!==o&&m(r,n,{get:()=>e[n],enumerable:!(u=E(e,n))||u.enumerable});return r};var J=(r,e,o)=>(o=r!=null?j(H(r)):{},C(e||!r||!r.__esModule?m(o,"default",{value:r,enumerable:!0}):o,r)),V=r=>C(m({},"__esModule",{value:!0}),r);var z={};q(z,{default:()=>T});module.exports=V(z);var t=require("react/jsx-runtime"),s=require("react"),a=require("@anker-in/headless-ui"),l=require("@anker-in/lib"),f=J(require("js-cookie")),M=require("query-string"),S=require("../../credits/context/utils"),k=require("../context/provider"),y=require("../../../constants");function X(){if(typeof window>"u")return{register_source:""};const{search:r,href:e}=window.location,o=(0,M.parse)(r);return{fbuy_ref_code:f.default.get("fbuy_ref_code"),ref:f.default.get("ref_ads"),inviter_code:o.ic??o.inviter_code??f.default.get("inviter_code"),register_source:o.redirect??f.default.get("reg_source")??e}}async function Z(r){if(typeof window>"u"||!window?.grecaptcha?.execute||!r)return"";try{return await window.grecaptcha.execute(r,{action:"activity"})}catch{return""}}function T({onSuccess:r,copy:e,email:o,hideForm:u,onHideForm:n}){const{alpcConfig:L}=(0,k.useMemberPopupContext)(),{locale:g}=L,{brand:P,storeDomain:h,recaptchaSitekey:A}=(0,l.useHeadlessContext)(),p=y.ROUNDED_BRANDS.includes(P),[x,B]=(0,s.useState)(!1),[d,v]=(0,s.useState)(o??""),[b,i]=(0,s.useState)(""),[D,_]=(0,s.useState)(""),[R,w]=(0,s.useState)(!1);(0,s.useEffect)(()=>{o&&v(o)},[o]);const O=(0,s.useCallback)(async()=>{if(i(""),!d)return i("Please fill in your email");if(!(0,S.emailValidate)(d))return i("Invalid email address");if(!x)return i("Please agree to the policy");w(!0);const{register_source:c}=X(),U=await Z(A||"");try{const N=await(await fetch("/api/multipass/rainbowbridge/activities",{method:"POST",headers:{"Content-Type":"application/json","current-language":g,"X-Recaptcha-Token":U},body:JSON.stringify({email:d,register_source:c,shopify_domain:h,single_brand_subscribe:e.single_brand_subscribe??!0,genre:e.genre??e.dealsType??"",sub_brand_type:e.sub_brand_type??""})})).json();N.errors?i(N.errors??"Error occurred"):(_(e.successTips??"Subscribed successfully!"),r?.(),setTimeout(()=>{n(),_("")},3e3))}catch{i("Network error")}finally{w(!1)}},[d,x,g,h,e,r,n]);return(0,t.jsxs)("div",{className:"flex flex-col gap-[16px] text-center",children:[!u&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(a.Text,{className:"text-[22px] font-bold",html:e.title}),e.desc&&(0,t.jsx)(a.Text,{className:"text-left text-[16px] font-semibold text-[#1f2021]",html:e.desc}),(0,t.jsx)("input",{className:(0,l.classNames)("h-[46px] w-full border px-[14px] text-[16px] outline-none placeholder:text-[#999]",b?"border-[#f84d4f]":"border-[#d8d8d8]",p?"rounded-[4px]":"rounded-none"),placeholder:e.placeholder,value:d,onChange:c=>{i(""),v(c.target.value.trim())}}),(0,t.jsxs)("div",{className:"flex w-full items-start gap-[8px]",children:[(0,t.jsx)(a.Checkbox,{checked:x,onCheckedChange:()=>B(c=>!c),className:"border-[#1d1d1f]"}),(0,t.jsx)("label",{className:"text-left text-[14px] font-semibold text-[#777] [&_a]:underline",dangerouslySetInnerHTML:{__html:e.policy??""}})]}),(0,t.jsx)("button",{className:(0,l.classNames)("w-full cursor-pointer bg-[#080a0f] py-[14px] text-[14px] font-[700] text-white disabled:opacity-60",p?"rounded-[4px]":"rounded-none"),disabled:R,onClick:O,children:e.buttonLabel??"Subscribe"}),b&&(0,t.jsx)("div",{className:"text-left text-[16px] font-semibold text-[#f84d4f]",children:(0,t.jsx)(a.Text,{html:b})}),(0,t.jsx)("div",{className:"text-left text-[16px] font-semibold text-[#52c41a]",children:(0,t.jsx)(a.Text,{html:D})})]}),e.promo&&(0,t.jsxs)("div",{className:"flex flex-col text-left",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-[8px]",children:[e.promo?.title&&(0,t.jsx)("h3",{className:"text-[20px] font-[700] leading-[1.2] text-[#080a0f]",children:e.promo?.title}),e.promo.description&&(0,t.jsx)("p",{className:"text-[14px] leading-[1.5] text-[#1e2024]",children:e.promo.description}),e.promo.learnMoreLabel&&e.promo.learnMoreUrl&&(0,t.jsxs)("a",{href:e.promo.learnMoreUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-[4px] text-[14px] font-[700] text-[#080a0f] underline",children:[e.promo.learnMoreLabel,(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:(0,t.jsx)("path",{d:"M5.52827 3.52876C5.78862 3.26841 6.21063 3.26841 6.47098 3.52876L10.471 7.52876C10.7313 7.78911 10.7313 8.21112 10.471 8.47147L6.47098 12.4715C6.21063 12.7318 5.78862 12.7318 5.52827 12.4715C5.26792 12.2111 5.26792 11.7891 5.52827 11.5288L9.05692 8.00011L5.52827 4.47147C5.26792 4.21112 5.26792 3.78911 5.52827 3.52876Z",fill:"#080A0F"})})]})]}),e.promo.image?.url&&(0,t.jsx)(a.Picture,{source:e.promo.image.url,alt:e.promo.image.alt??"",className:(0,l.classNames)("h-[100px] mt-[8px] w-full object-cover",p?"rounded-[8px]":"rounded-none")})]})]})}
2
+ //# sourceMappingURL=ActivitiesSubscribePanel.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/components/memberPopup/panels/ActivitiesSubscribePanel.tsx"],
4
+ "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Button, Checkbox, Picture, Text } from '@anker-in/headless-ui'\nimport { classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport Cookies from 'js-cookie'\nimport { parse } from 'query-string'\nimport { emailValidate } from '../../credits/context/utils'\nimport { useMemberPopupContext } from '../context/provider'\nimport type { SubscribeModalCopy } from '../type'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\ntype Props = {\n onSuccess?: () => void\n copy: SubscribeModalCopy\n email?: string\n hideForm: boolean\n onHideForm: () => void\n}\n\nfunction getAdCookie() {\n if (typeof window === 'undefined') return { register_source: '' }\n const { search, href } = window.location\n const query = parse(search)\n return {\n fbuy_ref_code: Cookies.get('fbuy_ref_code'),\n ref: Cookies.get('ref_ads'),\n inviter_code: query.ic ?? query.inviter_code ?? Cookies.get('inviter_code'),\n register_source: query.redirect ?? Cookies.get('reg_source') ?? href,\n }\n}\n\nasync function getRecaptchaToken(sitekey: string): Promise<string> {\n if (typeof window === 'undefined' || !window?.grecaptcha?.execute) return ''\n if (!sitekey) return ''\n try {\n return await window.grecaptcha.execute(sitekey, { action: 'activity' })\n } catch {\n return ''\n }\n}\n\nexport default function ActivitiesSubscribeModal({\n onSuccess,\n copy,\n email: initialEmail,\n hideForm,\n onHideForm,\n}: Props) {\n const { alpcConfig } = useMemberPopupContext()\n const { locale } = alpcConfig\n const { brand: headlessBrand, storeDomain, recaptchaSitekey } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(headlessBrand)\n const [policy, setPolicy] = useState(false)\n const [email, setEmail] = useState(initialEmail ?? '')\n const [errorMessage, setErrorMessage] = useState('')\n const [successMessage, setSuccessMessage] = useState('')\n const [loading, setLoading] = useState(false)\n\n useEffect(() => {\n if (initialEmail) setEmail(initialEmail)\n }, [initialEmail])\n\n const handleSubmit = useCallback(async () => {\n setErrorMessage('')\n if (!email) return setErrorMessage('Please fill in your email')\n if (!emailValidate(email)) return setErrorMessage('Invalid email address')\n if (!policy) return setErrorMessage('Please agree to the policy')\n\n setLoading(true)\n const { register_source } = getAdCookie()\n const recaptchaToken = await getRecaptchaToken(recaptchaSitekey || '')\n try {\n const response = await fetch('/api/multipass/rainbowbridge/activities', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'current-language': locale,\n 'X-Recaptcha-Token': recaptchaToken,\n },\n body: JSON.stringify({\n email,\n register_source,\n shopify_domain: storeDomain,\n single_brand_subscribe: copy.single_brand_subscribe ?? true,\n genre: copy.genre ?? copy.dealsType ?? '',\n sub_brand_type: copy.sub_brand_type ?? '',\n }),\n })\n const result = await response.json()\n if (!result.errors) {\n setSuccessMessage(copy.successTips ?? 'Subscribed successfully!')\n onSuccess?.()\n setTimeout(() => {\n onHideForm()\n setSuccessMessage('')\n }, 3000)\n } else {\n setErrorMessage(result.errors ?? 'Error occurred')\n }\n } catch {\n setErrorMessage('Network error')\n } finally {\n setLoading(false)\n }\n }, [email, policy, locale, storeDomain, copy, onSuccess, onHideForm])\n\n return (\n <div className=\"flex flex-col gap-[16px] text-center\">\n {!hideForm && (\n <>\n <Text className=\"text-[22px] font-bold\" html={copy.title} />\n {copy.desc && <Text className=\"text-left text-[16px] font-semibold text-[#1f2021]\" html={copy.desc} />}\n\n <input\n className={cn(\n 'h-[46px] w-full border px-[14px] text-[16px] outline-none placeholder:text-[#999]',\n errorMessage ? 'border-[#f84d4f]' : 'border-[#d8d8d8]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n placeholder={copy.placeholder}\n value={email}\n onChange={e => {\n setErrorMessage('')\n setEmail(e.target.value.trim())\n }}\n />\n\n <div className=\"flex w-full items-start gap-[8px]\">\n <Checkbox checked={policy} onCheckedChange={() => setPolicy(v => !v)} className=\"border-[#1d1d1f]\" />\n <label\n className=\"text-left text-[14px] font-semibold text-[#777] [&_a]:underline\"\n dangerouslySetInnerHTML={{ __html: copy.policy ?? '' }}\n />\n </div>\n\n <button\n className={cn(\n 'w-full cursor-pointer bg-[#080a0f] py-[14px] text-[14px] font-[700] text-white disabled:opacity-60',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={loading}\n onClick={handleSubmit}\n >\n {copy.buttonLabel ?? 'Subscribe'}\n </button>\n\n {errorMessage && (\n <div className=\"text-left text-[16px] font-semibold text-[#f84d4f]\">\n <Text html={errorMessage} />\n </div>\n )}\n <div className=\"text-left text-[16px] font-semibold text-[#52c41a]\">\n <Text html={successMessage} />\n </div>\n </>\n )}\n\n {copy.promo && (\n <div className=\"flex flex-col text-left\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.promo?.title && (\n <h3 className=\"text-[20px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.promo?.title}</h3>\n )}\n {copy.promo.description && (\n <p className=\"text-[14px] leading-[1.5] text-[#1e2024]\">{copy.promo.description}</p>\n )}\n {copy.promo.learnMoreLabel && copy.promo.learnMoreUrl && (\n <a\n href={copy.promo.learnMoreUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"flex items-center gap-[4px] text-[14px] font-[700] text-[#080a0f] underline\"\n >\n {copy.promo.learnMoreLabel}\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\">\n <path\n d=\"M5.52827 3.52876C5.78862 3.26841 6.21063 3.26841 6.47098 3.52876L10.471 7.52876C10.7313 7.78911 10.7313 8.21112 10.471 8.47147L6.47098 12.4715C6.21063 12.7318 5.78862 12.7318 5.52827 12.4715C5.26792 12.2111 5.26792 11.7891 5.52827 11.5288L9.05692 8.00011L5.52827 4.47147C5.26792 4.21112 5.26792 3.78911 5.52827 3.52876Z\"\n fill=\"#080A0F\"\n />\n </svg>\n </a>\n )}\n </div>\n {copy.promo.image?.url && (\n <Picture\n source={copy.promo.image.url}\n alt={copy.promo.image.alt ?? ''}\n className={cn('h-[100px] mt-[8px] w-full object-cover', rounded ? 'rounded-[8px]' : 'rounded-none')}\n />\n )}\n </div>\n )}\n </div>\n )\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GA4GQ,IAAAI,EAAA,6BA5GRC,EAAiD,iBACjDC,EAAgD,iCAChDC,EAAqD,yBACrDC,EAAoB,wBACpBC,EAAsB,wBACtBC,EAA8B,uCAC9BC,EAAsC,+BAEtCC,EAA+B,8BAU/B,SAASC,GAAc,CACrB,GAAI,OAAO,OAAW,IAAa,MAAO,CAAE,gBAAiB,EA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AEA,QAAC,OAAI,UAAU,oCACb,oBAAC,YAAS,QAASf,EAAQ,gBAAiB,IAAMC,EAAUe,GAAK,CAACA,CAAC,EAAG,UAAU,mBAAmB,KACnG,OAAC,SACC,UAAU,kEACV,wBAAyB,CAAE,OAAQ1B,EAAK,QAAU,EAAG,EACvD,GACF,KAEA,OAAC,UACC,aAAW,EAAAwB,YACT,qGACAf,EAAU,gBAAkB,cAC9B,EACA,SAAUS,EACV,QAASE,EAER,SAAApB,EAAK,aAAe,YACvB,EAECc,MACC,OAAC,OAAI,UAAU,qDACb,mBAAC,QAAK,KAAMA,EAAc,EAC5B,KAEF,OAAC,OAAI,UAAU,qDACb,mBAAC,QAAK,KAAME,EAAgB,EAC9B,GACF,EAGDhB,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,EAAAwB,YAAG,yCAA0Cf,EAAU,gBAAkB,cAAc,EACpG,GAEJ,GAEJ,CAEJ",
6
+ "names": ["ActivitiesSubscribePanel_exports", "__export", "ActivitiesSubscribeModal", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_js_cookie", "import_query_string", "import_utils", "import_provider", "import_constants", "getAdCookie", "search", "href", "query", "Cookies", "getRecaptchaToken", "sitekey", "onSuccess", "copy", "initialEmail", "hideForm", "onHideForm", "alpcConfig", "locale", "headlessBrand", "storeDomain", "recaptchaSitekey", "rounded", "policy", "setPolicy", "email", "setEmail", "errorMessage", "setErrorMessage", "successMessage", "setSuccessMessage", "loading", "setLoading", "handleSubmit", "register_source", "recaptchaToken", "result", "cn", "e", "v"]
7
+ }
@@ -9,6 +9,7 @@ type Props = {
9
9
  };
10
10
  itemValue?: string;
11
11
  itemOff?: string;
12
+ itemRules?: string[];
12
13
  redeemId: number;
13
14
  userId?: string;
14
15
  copy: RedeemCouponModalCopy;
@@ -16,5 +17,5 @@ type Props = {
16
17
  alpcConfig: AlpcConfig;
17
18
  onError?: (code: number) => void;
18
19
  };
19
- export default function RedeemCouponPanel({ onClose, itemTitle, itemCredits, itemImage, itemValue, itemOff, redeemId, userId, copy, pointUnit, alpcConfig, onError, }: Props): import("react/jsx-runtime").JSX.Element;
20
+ export default function RedeemCouponPanel({ onClose, itemTitle, itemCredits, itemImage, itemValue, itemOff, itemRules, redeemId, userId, copy, pointUnit, alpcConfig, onError, }: Props): import("react/jsx-runtime").JSX.Element;
20
21
  export {};
@@ -1,2 +1,2 @@
1
- "use strict";var H=Object.create;var x=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var $=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var z=(t,n)=>{for(var s in n)x(t,s,{get:n[s],enumerable:!0})},T=(t,n,s,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of O(n))!q.call(t,r)&&r!==s&&x(t,r,{get:()=>n[r],enumerable:!(a=I(n,r))||a.enumerable});return t};var F=(t,n,s)=>(s=t!=null?H($(t)):{},T(n||!t||!t.__esModule?x(s,"default",{value:t,enumerable:!0}):s,t)),G=t=>T(x({},"__esModule",{value:!0}),t);var J={};z(J,{default:()=>L});module.exports=G(J);var e=require("react/jsx-runtime"),d=require("react"),l=require("@anker-in/headless-ui"),c=require("@anker-in/lib"),f=require("../../../credits/context/const"),k=require("./hooks/useRedeemCoupon"),y=F(require("../../../credits/context/hooks/useCopy")),D=require("../../../../constants");function L({onClose:t,itemTitle:n,itemCredits:s,itemImage:a,itemValue:r,itemOff:b,redeemId:C,userId:v,copy:o,pointUnit:S="pts",alpcConfig:A,onError:h}){const[g,E]=(0,d.useState)(),[w,m]=(0,d.useState)(""),[U,u]=(0,d.useState)(!1),{copy:_,copied:R}=(0,y.default)(),{brand:M}=(0,c.useHeadlessContext)(),N=D.ROUNDED_BRANDS.includes(M),{isMutating:P,trigger:B}=(0,k.useRedeemCoupon)(A),j=(0,d.useCallback)(async()=>{m("");const{data:i}=await B({user_id:v,rule_id:C});if(!i){m(o.commonError);return}if(i.data?.success)E(i.data.coupon_code);else{let p=o.commonError;i.code===f.AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit?(p=o.redeemLimitError,u(!0)):i.code===f.AlpcErrorCode.CodeLpcRuleInventoryNotEnough?(p=o.inventoryNotEnough,u(!0)):i.code===f.AlpcErrorCode.CodeLpcNotEnoughCredits?(p=o.creditsNotEnough,u(!0)):i.code===f.AlpcErrorCode.CodeCrossSiteError&&(p=o.crossSiteError,u(!0)),m(p),h?.(i.code)}},[B,v,C,o,h]);return(0,d.useEffect)(()=>{E(void 0),m(""),u(!1)},[C]),(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[a?.url&&(0,e.jsxs)("div",{className:(0,c.classNames)("relative overflow-hidden w-fit mx-auto",N?"rounded-[8px]":"rounded-none"),children:[(0,e.jsx)("img",{src:a.url,alt:a.alt??"",className:"mx-auto h-[140px] object-contain"}),r&&(0,e.jsxs)("div",{className:"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white",children:[r,b?` ${b}`:""]})]}),(0,e.jsxs)("p",{className:"text-center text-[24px] font-[700] text-[#1d1d1f]",children:[s," ",S]}),g?(0,e.jsxs)("div",{className:"flex flex-col gap-[12px] text-center",children:[(0,e.jsxs)("div",{className:"flex items-center justify-center gap-[10px]",children:[(0,e.jsx)("span",{className:"text-[24px] font-[700]",children:g}),(0,e.jsx)("button",{className:"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none",disabled:R,onClick:()=>_(g),children:R?"Copied":"Copy"})]}),(0,e.jsx)(l.Text,{className:"text-[20px] font-[700]",html:o.successTitle}),(0,e.jsx)(l.Text,{className:"text-[14px] font-[700] text-[#6d6d6f]",html:o.successDesc}),(0,e.jsx)(l.Button,{className:(0,c.classNames)("w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]",N?"rounded-[4px]":"rounded-none"),onClick:()=>{o.successButtonUrl&&(window.location.href=o.successButtonUrl),t()},children:o.successButton})]}):(0,e.jsxs)("div",{className:"flex flex-col gap-[12px] text-center",children:[(0,e.jsx)(l.Text,{className:"block text-[20px] font-[700]",html:o.confirmTitle}),(0,e.jsx)(l.Button,{className:(0,c.classNames)("w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]",N?"rounded-[4px]":"rounded-none"),disabled:U,loading:P,onClick:j,children:o.confirmButton})]}),w&&(0,e.jsx)(l.Text,{className:"text-center text-[14px] font-[700] text-[#ff0000]",html:w})]})}
1
+ "use strict";var I=Object.create;var g=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var G=(t,s)=>{for(var n in s)g(t,n,{get:s[n],enumerable:!0})},k=(t,s,n,c)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of $(s))!z.call(t,r)&&r!==n&&g(t,r,{get:()=>s[r],enumerable:!(c=O(s,r))||c.enumerable});return t};var J=(t,s,n)=>(n=t!=null?I(q(t)):{},k(s||!t||!t.__esModule?g(n,"default",{value:t,enumerable:!0}):n,t)),K=t=>k(g({},"__esModule",{value:!0}),t);var Q={};G(Q,{default:()=>L});module.exports=K(Q);var e=require("react/jsx-runtime"),d=require("react"),i=require("@anker-in/headless-ui"),p=require("@anker-in/lib"),x=require("../../../credits/context/const"),D=require("./hooks/useRedeemCoupon"),S=J(require("../../../credits/context/hooks/useCopy")),T=require("../../../../constants");function L({onClose:t,itemTitle:s,itemCredits:n,itemImage:c,itemValue:r,itemOff:b,itemRules:C,redeemId:N,userId:h,copy:o,pointUnit:A="pts",alpcConfig:U,onError:w}){const[m,E]=(0,d.useState)(),[y,f]=(0,d.useState)(""),[_,u]=(0,d.useState)(!1),{copy:M,copied:B}=(0,S.default)(),{brand:P}=(0,p.useHeadlessContext)(),v=T.ROUNDED_BRANDS.includes(P),{isMutating:j,trigger:R}=(0,D.useRedeemCoupon)(U),F=(0,d.useCallback)(async()=>{f("");const{data:l}=await R({user_id:h,rule_id:N});if(!l){f(o.commonError);return}if(l.data?.success)E(l.data.coupon_code);else{let a=o.commonError;l.code===x.AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit?(a=o.redeemLimitError,u(!0)):l.code===x.AlpcErrorCode.CodeLpcRuleInventoryNotEnough?(a=o.inventoryNotEnough,u(!0)):l.code===x.AlpcErrorCode.CodeLpcNotEnoughCredits?(a=o.creditsNotEnough,u(!0)):l.code===x.AlpcErrorCode.CodeCrossSiteError&&(a=o.crossSiteError,u(!0)),f(a),w?.(l.code)}},[R,h,N,o,w]);(0,d.useEffect)(()=>{E(void 0),f(""),u(!1)},[N]);const H=C&&C.length>0&&(0,e.jsx)("div",{className:"w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]",children:(0,e.jsx)("ul",{className:"ml-4 grid grid-flow-row gap-[4px]",children:C?.map((l,a)=>(0,e.jsx)("li",{className:"list-disc",children:(0,e.jsx)(i.Text,{html:l,className:"font-bold"})},a))})});return(0,e.jsxs)("div",{className:"flex flex-col",children:[c?.url&&(0,e.jsx)("div",{className:"relative w-full px-[24px]",children:(0,e.jsxs)("div",{className:(0,p.classNames)("relative mx-auto overflow-hidden",v?"rounded-[8px]":"rounded-none"),children:[(0,e.jsx)("img",{src:c.url,alt:c.alt??"",className:"mx-auto h-[140px] w-full object-cover"}),r&&(0,e.jsxs)("div",{className:"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white",children:[r,b?` ${b}`:""]})]})}),!m&&(0,e.jsxs)("div",{className:"flex flex-col gap-[16px] px-[24px] py-[20px]",children:[(0,e.jsxs)("p",{className:"text-center text-[24px] font-[700] text-[#1d1d1f]",children:[n," ",A]}),H]}),m&&(0,e.jsxs)("div",{className:"flex mt-[16px] flex-col gap-[8px] text-center",children:[(0,e.jsxs)("div",{className:"flex items-center justify-center gap-[10px]",children:[(0,e.jsx)("span",{className:"text-[24px] font-[700]",children:m}),(0,e.jsx)("button",{className:"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none",disabled:B,onClick:()=>M(m),children:B?"Copied":"Copy"})]}),(0,e.jsx)(i.Text,{className:"text-[20px] font-[700]",html:o.successTitle}),(0,e.jsx)(i.Text,{className:"text-[14px] font-[700] text-[#6d6d6f]",html:o.successDesc}),(0,e.jsx)(i.Button,{className:(0,p.classNames)("w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]",v?"rounded-[4px]":"rounded-none"),onClick:()=>{o.successButtonUrl&&(window.location.href=o.successButtonUrl),t()},children:o.successButton})]}),!m&&(0,e.jsxs)("div",{className:"sticky bottom-0 bg-white border-t border-[#e5e5e5] pt-[10px]",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-[8px] text-center",children:[(0,e.jsx)(i.Text,{className:"block text-[16px] font-[700] leading-[1.3]",html:o.confirmTitle}),(0,e.jsx)(i.Button,{className:(0,p.classNames)("w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]",v?"rounded-[4px]":"rounded-none"),disabled:_,loading:j,onClick:F,children:o.confirmButton})]}),y&&(0,e.jsx)(i.Text,{className:"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]",html:y})]})]})}
2
2
  //# sourceMappingURL=RedeemCouponPanel.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.tsx"],
4
- "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Text, Button } from '@anker-in/headless-ui'\nimport { useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport { AlpcErrorCode } from '../../../credits/context/const'\nimport { useRedeemCoupon } from './hooks/useRedeemCoupon'\nimport useCopy from '../../../credits/context/hooks/useCopy'\nimport type { RedeemCouponModalCopy, AlpcConfig } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n onClose: () => void\n itemTitle: string\n itemCredits: number\n itemImage?: { url: string; alt?: string }\n itemValue?: string\n itemOff?: string\n redeemId: number\n userId?: string\n copy: RedeemCouponModalCopy\n pointUnit?: string\n alpcConfig: AlpcConfig\n onError?: (code: number) => void\n}\n\nexport default function RedeemCouponPanel({\n onClose,\n itemTitle,\n itemCredits,\n itemImage,\n itemValue,\n itemOff,\n redeemId,\n userId,\n copy,\n pointUnit = 'pts',\n alpcConfig,\n onError,\n}: Props) {\n const [couponCode, setCouponCode] = useState<string>()\n const [errorInfo, setErrorInfo] = useState('')\n const [disabled, setDisabled] = useState(false)\n const { copy: copyText, copied } = useCopy()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const { isMutating: loading, trigger } = useRedeemCoupon(alpcConfig)\n\n const handleConfirm = useCallback(async () => {\n setErrorInfo('')\n const { data } = await trigger({ user_id: userId, rule_id: redeemId })\n if (!data) {\n setErrorInfo(copy.commonError)\n return\n }\n if (data.data?.success) {\n setCouponCode(data.data.coupon_code)\n } else {\n let msg = copy.commonError\n if (data.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n msg = copy.redeemLimitError\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n msg = copy.inventoryNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n msg = copy.creditsNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeCrossSiteError) {\n msg = copy.crossSiteError\n setDisabled(true)\n }\n setErrorInfo(msg)\n onError?.(data.code)\n }\n }, [trigger, userId, redeemId, copy, onError])\n\n useEffect(() => {\n setCouponCode(undefined)\n setErrorInfo('')\n setDisabled(false)\n }, [redeemId])\n\n return (\n <div className=\"flex flex-col gap-[16px]\">\n {itemImage?.url && (\n <div className={cn('relative overflow-hidden w-fit mx-auto', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <img src={itemImage.url} alt={itemImage.alt ?? ''} className=\"mx-auto h-[140px] object-contain\" />\n {itemValue && (\n <div className=\"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white\">\n {itemValue}\n {itemOff ? ` ${itemOff}` : ''}\n </div>\n )}\n </div>\n )}\n\n <p className=\"text-center text-[24px] font-[700] text-[#1d1d1f]\">\n {itemCredits} {pointUnit}\n </p>\n\n {!couponCode ? (\n <div className=\"flex flex-col gap-[12px] text-center\">\n <Text className=\"block text-[20px] font-[700]\" html={copy.confirmTitle} />\n <Button\n className={cn('w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]', rounded ? 'rounded-[4px]' : 'rounded-none')}\n disabled={disabled}\n loading={loading}\n onClick={handleConfirm}\n >\n {copy.confirmButton}\n </Button>\n </div>\n ) : (\n <div className=\"flex flex-col gap-[12px] text-center\">\n <div className=\"flex items-center justify-center gap-[10px]\">\n <span className=\"text-[24px] font-[700]\">{couponCode}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none\"\n disabled={copied}\n onClick={() => copyText(couponCode)}\n >\n {copied ? 'Copied' : 'Copy'}\n </button>\n </div>\n <Text className=\"text-[20px] font-[700]\" html={copy.successTitle} />\n <Text className=\"text-[14px] font-[700] text-[#6d6d6f]\" html={copy.successDesc} />\n <Button\n className={cn('w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]', rounded ? 'rounded-[4px]' : 'rounded-none')}\n onClick={() => {\n if (copy.successButtonUrl) window.location.href = copy.successButtonUrl\n onClose()\n }}\n >\n {copy.successButton}\n </Button>\n </div>\n )}\n\n {errorInfo && <Text className=\"text-center text-[14px] font-[700] text-[#ff0000]\" html={errorInfo} />}\n </div>\n )\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAsFU,IAAAI,EAAA,6BAtFVC,EAAiD,iBACjDC,EAA6B,iCAC7BC,EAAqD,yBACrDC,EAA8B,0CAC9BC,EAAgC,mCAChCC,EAAoB,qDAEpBC,EAA+B,iCAiBhB,SAART,EAAmC,CACxC,QAAAU,EACA,UAAAC,EACA,YAAAC,EACA,UAAAC,EACA,UAAAC,EACA,QAAAC,EACA,SAAAC,EACA,OAAAC,EACA,KAAAC,EACA,UAAAC,EAAY,MACZ,WAAAC,EACA,QAAAC,CACF,EAAU,CACR,KAAM,CAACC,EAAYC,CAAa,KAAI,YAAiB,EAC/C,CAACC,EAAWC,CAAY,KAAI,YAAS,EAAE,EACvC,CAACC,EAAUC,CAAW,KAAI,YAAS,EAAK,EACxC,CAAE,KAAMC,EAAU,OAAAC,CAAO,KAAI,EAAAC,SAAQ,EACrC,CAAE,MAAAC,CAAM,KAAI,sBAAmB,EAC/BC,EAAU,iBAAe,SAASD,CAAK,EAEvC,CAAE,WAAYE,EAAS,QAAAC,CAAQ,KAAI,mBAAgBd,CAAU,EAE7De,KAAgB,eAAY,SAAY,CAC5CV,EAAa,EAAE,EACf,KAAM,CAAE,KAAAW,CAAK,EAAI,MAAMF,EAAQ,CAAE,QAASjB,EAAQ,QAASD,CAAS,CAAC,EACrE,GAAI,CAACoB,EAAM,CACTX,EAAaP,EAAK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A,EAAK,YAAa,KAChF,OAAC,UACC,aAAW,EAAAoB,YAAG,kEAAmEN,EAAU,gBAAkB,cAAc,EAC3H,QAAS,IAAM,CACTd,EAAK,mBAAkB,OAAO,SAAS,KAAOA,EAAK,kBACvDR,EAAQ,CACV,EAEC,SAAAQ,EAAK,cACR,GACF,KAlCA,QAAC,OAAI,UAAU,uCACb,oBAAC,QAAK,UAAU,+BAA+B,KAAMA,EAAK,aAAc,KACxE,OAAC,UACC,aAAW,EAAAoB,YAAG,sFAAuFN,EAAU,gBAAkB,cAAc,EAC/I,SAAUN,EACV,QAASO,EACT,QAASE,EAER,SAAAjB,EAAK,cACR,GACF,EA2BDM,MAAa,OAAC,QAAK,UAAU,oDAAoD,KAAMA,EAAW,GACrG,CAEJ",
6
- "names": ["RedeemCouponPanel_exports", "__export", "RedeemCouponPanel", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_const", "import_useRedeemCoupon", "import_useCopy", "import_constants", "onClose", "itemTitle", "itemCredits", "itemImage", "itemValue", "itemOff", "redeemId", "userId", "copy", "pointUnit", "alpcConfig", "onError", "couponCode", "setCouponCode", "errorInfo", "setErrorInfo", "disabled", "setDisabled", "copyText", "copied", "useCopy", "brand", "rounded", "loading", "trigger", "handleConfirm", "data", "msg", "cn"]
4
+ "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Text, Button } from '@anker-in/headless-ui'\nimport { useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport { AlpcErrorCode } from '../../../credits/context/const'\nimport { useRedeemCoupon } from './hooks/useRedeemCoupon'\nimport useCopy from '../../../credits/context/hooks/useCopy'\nimport type { RedeemCouponModalCopy, AlpcConfig } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n onClose: () => void\n itemTitle: string\n itemCredits: number\n itemImage?: { url: string; alt?: string }\n itemValue?: string\n itemOff?: string\n itemRules?: string[]\n redeemId: number\n userId?: string\n copy: RedeemCouponModalCopy\n pointUnit?: string\n alpcConfig: AlpcConfig\n onError?: (code: number) => void\n}\n\nexport default function RedeemCouponPanel({\n onClose,\n itemTitle,\n itemCredits,\n itemImage,\n itemValue,\n itemOff,\n itemRules,\n redeemId,\n userId,\n copy,\n pointUnit = 'pts',\n alpcConfig,\n onError,\n}: Props) {\n const [couponCode, setCouponCode] = useState<string>()\n const [errorInfo, setErrorInfo] = useState('')\n const [disabled, setDisabled] = useState(false)\n const { copy: copyText, copied } = useCopy()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const { isMutating: loading, trigger } = useRedeemCoupon(alpcConfig)\n\n const handleConfirm = useCallback(async () => {\n setErrorInfo('')\n const { data } = await trigger({ user_id: userId, rule_id: redeemId })\n if (!data) {\n setErrorInfo(copy.commonError)\n return\n }\n if (data.data?.success) {\n setCouponCode(data.data.coupon_code)\n } else {\n let msg = copy.commonError\n if (data.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n msg = copy.redeemLimitError\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n msg = copy.inventoryNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n msg = copy.creditsNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeCrossSiteError) {\n msg = copy.crossSiteError\n setDisabled(true)\n }\n setErrorInfo(msg)\n onError?.(data.code)\n }\n }, [trigger, userId, redeemId, copy, onError])\n\n useEffect(() => {\n setCouponCode(undefined)\n setErrorInfo('')\n setDisabled(false)\n }, [redeemId])\n\n const rulesSection = itemRules && itemRules.length > 0 && (\n <div className=\"w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]\">\n <ul className=\"ml-4 grid grid-flow-row gap-[4px]\">\n {itemRules?.map((text, index) => (\n <li className=\"list-disc\" key={index}>\n <Text html={text} className=\"font-bold\" />\n </li>\n ))}\n </ul>\n </div>\n )\n\n return (\n <div className=\"flex flex-col\">\n {itemImage?.url && (\n <div className=\"relative w-full px-[24px]\">\n <div className={cn('relative mx-auto overflow-hidden', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <img src={itemImage.url} alt={itemImage.alt ?? ''} className=\"mx-auto h-[140px] w-full object-cover\" />\n {itemValue && (\n <div className=\"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white\">\n {itemValue}\n {itemOff ? ` ${itemOff}` : ''}\n </div>\n )}\n </div>\n </div>\n )}\n\n {!couponCode && (\n <div className=\"flex flex-col gap-[16px] px-[24px] py-[20px]\">\n <p className=\"text-center text-[24px] font-[700] text-[#1d1d1f]\">\n {itemCredits} {pointUnit}\n </p>\n {rulesSection}\n </div>\n )}\n\n {couponCode && (\n <div className=\"flex mt-[16px] flex-col gap-[8px] text-center\">\n <div className=\"flex items-center justify-center gap-[10px]\">\n <span className=\"text-[24px] font-[700]\">{couponCode}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none\"\n disabled={copied}\n onClick={() => copyText(couponCode)}\n >\n {copied ? 'Copied' : 'Copy'}\n </button>\n </div>\n <Text className=\"text-[20px] font-[700]\" html={copy.successTitle} />\n <Text className=\"text-[14px] font-[700] text-[#6d6d6f]\" html={copy.successDesc} />\n <Button\n className={cn(\n 'w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n onClick={() => {\n if (copy.successButtonUrl) window.location.href = copy.successButtonUrl\n onClose()\n }}\n >\n {copy.successButton}\n </Button>\n </div>\n )}\n\n {!couponCode && (\n <div className=\"sticky bottom-0 bg-white border-t border-[#e5e5e5] pt-[10px]\">\n <div className=\"flex flex-col gap-[8px] text-center\">\n <Text className=\"block text-[16px] font-[700] leading-[1.3]\" html={copy.confirmTitle} />\n <Button\n className={cn(\n 'w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={disabled}\n loading={loading}\n onClick={handleConfirm}\n >\n {copy.confirmButton}\n </Button>\n </div>\n\n {errorInfo && (\n <Text className=\"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]\" html={errorInfo} />\n )}\n </div>\n )}\n </div>\n )\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAyFY,IAAAI,EAAA,6BAzFZC,EAAiD,iBACjDC,EAA6B,iCAC7BC,EAAqD,yBACrDC,EAA8B,0CAC9BC,EAAgC,mCAChCC,EAAoB,qDAEpBC,EAA+B,iCAkBhB,SAART,EAAmC,CACxC,QAAAU,EACA,UAAAC,EACA,YAAAC,EACA,UAAAC,EACA,UAAAC,EACA,QAAAC,EACA,UAAAC,EACA,SAAAC,EACA,OAAAC,EACA,KAAAC,EACA,UAAAC,EAAY,MACZ,WAAAC,EACA,QAAAC,CACF,EAAU,CACR,KAAM,CAACC,EAAYC,CAAa,KAAI,YAAiB,EAC/C,CAACC,EAAWC,CAAY,KAAI,YAAS,EAAE,EACvC,CAACC,EAAUC,CAAW,KAAI,YAAS,EAAK,EACxC,CAAE,KAAMC,EAAU,OAAAC,CAAO,KAAI,EAAAC,SAAQ,EACrC,CAAE,MAAAC,CAAM,KAAI,sBAAmB,EAC/BC,EAAU,iBAAe,SAASD,CAAK,EAEvC,CAAE,WAAYE,EAAS,QAAAC,CAAQ,KAAI,mBAAgBd,CAAU,EAE7De,KAAgB,eAAY,SAAY,CAC5CV,EAAa,EAAE,EACf,KAAM,CAAE,KAAAW,CAAK,EAAI,MAAMF,EAAQ,CAAE,QAASjB,EAAQ,QAASD,CAAS,CAAC,EACrE,GAAI,CAACoB,EAAM,CACTX,EAAaP,EAAK,WAAW,EAC7B,MACF,CACA,GAAIkB,EAAK,MAAM,QACbb,EAAca,EAAK,KAAK,WAAW,MAC9B,CACL,IAAIC,EAAM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yBAA0B,SAAAA,EAAW,KACrD,OAAC,UACC,UAAU,+EACV,SAAUO,EACV,QAAS,IAAMD,EAASN,CAAU,EAEjC,SAAAO,EAAS,SAAW,OACvB,GACF,KACA,OAAC,QAAK,UAAU,yBAAyB,KAAMX,EAAK,aAAc,KAClE,OAAC,QAAK,UAAU,wCAAwC,KAAMA,EAAK,YAAa,KAChF,OAAC,UACC,aAAW,EAAAuB,YACT,kEACAT,EAAU,gBAAkB,cAC9B,EACA,QAAS,IAAM,CACTd,EAAK,mBAAkB,OAAO,SAAS,KAAOA,EAAK,kBACvDT,EAAQ,CACV,EAEC,SAAAS,EAAK,cACR,GACF,EAGD,CAACI,MACA,QAAC,OAAI,UAAU,+DACb,qBAAC,OAAI,UAAU,sCACb,oBAAC,QAAK,UAAU,6CAA6C,KAAMJ,EAAK,aAAc,KACtF,OAAC,UACC,aAAW,EAAAuB,YACT,sFACAT,EAAU,gBAAkB,cAC9B,EACA,SAAUN,EACV,QAASO,EACT,QAASE,EAER,SAAAjB,EAAK,cACR,GACF,EAECM,MACC,OAAC,QAAK,UAAU,6DAA6D,KAAMA,EAAW,GAElG,GAEJ,CAEJ",
6
+ "names": ["RedeemCouponPanel_exports", "__export", "RedeemCouponPanel", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_const", "import_useRedeemCoupon", "import_useCopy", "import_constants", "onClose", "itemTitle", "itemCredits", "itemImage", "itemValue", "itemOff", "itemRules", "redeemId", "userId", "copy", "pointUnit", "alpcConfig", "onError", "couponCode", "setCouponCode", "errorInfo", "setErrorInfo", "disabled", "setDisabled", "copyText", "copied", "useCopy", "brand", "rounded", "loading", "trigger", "handleConfirm", "data", "msg", "rulesSection", "text", "index", "cn"]
7
7
  }
@@ -2,6 +2,7 @@ import { type ConsumeCreditsopy } from '../../type';
2
2
  type Props = {
3
3
  copy: ConsumeCreditsopy;
4
4
  onClose: () => void;
5
+ isActivateSuccess: boolean;
5
6
  };
6
- declare function ConsumeCredits({ copy, onClose }: Props): import("react/jsx-runtime").JSX.Element;
7
+ declare function ConsumeCredits({ copy, isActivateSuccess, onClose }: Props): import("react/jsx-runtime").JSX.Element;
7
8
  export default ConsumeCredits;
@@ -1,2 +1,2 @@
1
- "use strict";var y=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var q=(t,r)=>{for(var s in r)y(t,s,{get:r[s],enumerable:!0})},J=(t,r,s,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let l of H(r))!G.call(t,l)&&l!==s&&y(t,l,{get:()=>r[l],enumerable:!(d=j(r,l))||d.enumerable});return t};var K=t=>J(y({},"__esModule",{value:!0}),t);var X={};q(X,{default:()=>W});module.exports=K(X);var n=require("react/jsx-runtime"),c=require("react"),g=require("@anker-in/headless-ui"),u=require("@anker-in/lib"),P=require("../../context/provider"),w=require("../../context/viewStack"),A=require("./hooks/useRedeemableList"),k=require("./hooks/useRedeemAndBuy"),i=require("../../type"),v=require("../../../credits/context/utils"),M=require("../../../../constants");function Q({copy:t,onClose:r}){const{profile:s,creditInfo:d,openSignUpPopup:l,alpcConfig:b}=(0,P.useMemberPopupContext)(),{pushView:O}=(0,w.useViewStack)(),{brand:U}=(0,u.useHeadlessContext)(),h=M.ROUNDED_BRANDS.includes(U),[I,R]=(0,c.useState)(""),[E,B]=(0,c.useState)(null),f=!!s,{redeemableList:D,listLoading:L}=(0,A.useRedeemableList)(b),{trigger:S}=(0,k.useRedeemAndBuy)(b),$=t.list.map(e=>e.product?.handle).filter(Boolean),{data:_}=(0,u.useProductsByHandles)({handles:$}),z=(0,c.useMemo)(()=>t.list.map(e=>{const a=D.find(m=>String(m.id)===String(e.redeemId));if(!a)return null;const p=Number(d?.available_credit??0),N=f&&!!s?.activated&&a.consume_credits>p,x=a.is_limited&&(!a.remaining_inventory||a.remaining_inventory<=0);let o,C;return e.type===i.ConsumeCreditsItemType.RedeemAndBuy&&e.product&&(o=_?.find(m=>m.handle===e.product.handle),C=o?.variants?.find(m=>m.sku===e.product.sku)??o?.variants?.[0],!o||!C)?null:{...e,alpcData:a,insufficient:N,soldOut:x,product:o,variant:C}}).filter(Boolean),[t.list,D,d,s,f,_]);function F(e){return f?e.soldOut?t.soldOut:t.btnRedeem:t.unlockRewards}function T(e){return e.soldOut||e.insufficient}async function V(e){if(!f){l();return}if(e.type===i.ConsumeCreditsItemType.Coupon)O({type:i.MemberPopupPanelType.RedeemCoupon,props:{itemTitle:e.title,itemCredits:e.alpcData.consume_credits,itemImage:t.imageMapping?.[e.type]?{url:t.imageMapping[e.type].url,alt:e.image?.alt}:e.image,itemValue:e.value,itemOff:t.off,redeemId:Number(e.redeemId),userId:s?.user_id,alpcConfig:b}});else{R(""),B(e.redeemId);try{await S({productVariant:e.variant,redeemId:Number(e.redeemId),userId:s?.user_id})}catch(a){R(a?.message??t.redeemModal.commonError)}finally{B(null)}}}return(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{className:"flex flex-1 flex-col gap-[12px]",children:[(0,n.jsxs)("div",{className:"flex flex-col gap-[8px]",children:[t.title&&(0,n.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:t.title}),t.subtitle&&(0,n.jsx)("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:t.subtitle})]}),t.insufficientCredits&&d&&(0,n.jsxs)("div",{className:"text-[14px] font-[700] text-[#1d1d1f]",children:[t.insufficientCredits,": ",(0,v.numberFormat)(d.available_credit)," ",t.pointUnit]}),I&&(0,n.jsx)("div",{className:"text-[14px] font-[700] text-[#f84d4f]",children:I}),L?(0,n.jsx)("div",{className:"flex flex-1 items-center justify-center py-[32px]",children:(0,n.jsx)("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}):(0,n.jsx)("div",{className:"flex flex-col",children:z.map((e,a)=>(0,n.jsxs)("div",{className:"relative py-[16px]",children:[a>0&&(0,n.jsx)("div",{className:"absolute inset-x-0 top-0 h-px bg-[#dadce0]"}),(0,n.jsxs)("div",{className:"flex items-center gap-[12px]",children:[(()=>{const p=e.type===i.ConsumeCreditsItemType.RedeemAndBuy,N=t.imageMapping?.[e.type]?.url,x=p?e.variant?.image?.url??e.product?.images?.[0]?.url??e.image?.url:N??e.image?.url,o=p?e.variant?.image?.altText??e.product?.images?.[0]?.alt??e.image?.alt??"":e.image?.alt??"";return x?(0,n.jsxs)("div",{className:(0,u.classNames)("relative size-[64px] shrink-0 overflow-hidden",h?"rounded-[4px]":"rounded-none"),children:[(0,n.jsx)(g.Picture,{source:x,alt:o,className:"flex size-full items-center justify-center",imgClassName:p?"object-cover":"h-full w-auto object-contain"}),!p&&e.value&&(0,n.jsxs)("div",{className:"absolute bottom-[20px] left-[4px] text-[14px] font-[800] leading-none text-white",children:[e.value," ",t.off]})]}):null})(),(0,n.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,n.jsx)("div",{className:"text-[16px] font-[700] text-[#1e2024] line-clamp-2",children:e.type===i.ConsumeCreditsItemType.RedeemAndBuy&&e.product?.title?e.product.title:e.title}),(0,n.jsx)("div",{className:"mt-[4px] text-[14px] text-[#666]",children:e.type===i.ConsumeCreditsItemType.RedeemAndBuy&&e.price!=null?`${(0,v.numberFormat)(e.alpcData.consume_credits)} ${t.pointUnit??""} + $${Number(e.price).toFixed(2)}`:`${(0,v.numberFormat)(e.alpcData.consume_credits)} ${t.pointUnit??""}`})]}),(0,n.jsxs)("div",{className:"relative group",children:[(0,n.jsx)(g.Button,{className:(0,u.classNames)("bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",h?"rounded-[4px]":"rounded-none"),disabled:T(e),loading:E===e.redeemId,onClick:()=>V(e),children:F(e)}),e.insufficient&&(0,n.jsx)("div",{className:"pointer-events-none absolute left-[48px] top-full mt-[10px] hidden -translate-x-1/2 group-hover:block",children:(0,n.jsxs)("div",{className:"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow md:px-[10px] md:py-[8px]",children:[(0,n.jsx)("p",{className:"text-pretty tracking-[-0.02em] text-[14px]",children:t.insufficientCredits}),(0,n.jsx)("div",{className:"absolute -top-[8px] left-[48px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]"})]})})]})]})]},a))}),t.creditsPage?.url&&(0,n.jsx)("a",{href:t.creditsPage.url,target:"_blank",rel:"noopener noreferrer",className:"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline",children:t.creditsPage.label??"Go to Credits Page"})]})})}var W=Q;
1
+ "use strict";var y=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var q=Object.prototype.hasOwnProperty;var J=(a,s)=>{for(var u in s)y(a,u,{get:s[u],enumerable:!0})},K=(a,s,u,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of H(s))!q.call(a,i)&&i!==u&&y(a,i,{get:()=>s[i],enumerable:!(l=G(s,i))||l.enumerable});return a};var Q=a=>K(y({},"__esModule",{value:!0}),a);var Y={};J(Y,{default:()=>X});module.exports=Q(Y);var t=require("react/jsx-runtime"),x=require("react"),v=require("@anker-in/headless-ui"),o=require("@anker-in/lib"),B=require("../../context/provider"),D=require("../../context/viewStack"),A=require("./hooks/useRedeemableList"),U=require("./hooks/useRedeemAndBuy"),n=require("../../type"),m=require("../../../credits/context/utils"),S=require("../../../../constants");function W({copy:a,isActivateSuccess:s,onClose:u}){const{profile:l,creditInfo:i,openSignUpPopup:L,alpcConfig:b}=(0,B.useMemberPopupContext)(),{pushView:I}=(0,D.useViewStack)(),{brand:M}=(0,o.useHeadlessContext)(),N=S.ROUNDED_BRANDS.includes(M),[P,R]=(0,x.useState)(""),[O,k]=(0,x.useState)(null),c=!!l,{redeemableList:w,listLoading:E}=(0,A.useRedeemableList)(b),{trigger:$}=(0,U.useRedeemAndBuy)(b),z=a.list.map(e=>e.product?.handle).filter(Boolean),{data:_}=(0,o.useProductsByHandles)({handles:z}),F=(0,x.useMemo)(()=>a.list.map(e=>{const r=w.find(f=>String(f.id)===String(e.redeemId));if(!r)return null;const d=Number(i?.available_credit??0),C=c&&!!l?.activated&&r.consume_credits>d,g=r.is_limited&&(!r.remaining_inventory||r.remaining_inventory<=0);let p,h;return(e.type===n.ConsumeCreditsItemType.RedeemAndBuy||e.type===n.ConsumeCreditsItemType.Product)&&e.product&&(p=_?.find(f=>f.handle===e.product.handle),h=p?.variants?.find(f=>f.sku===e.product.sku)??p?.variants?.[0],e.type===n.ConsumeCreditsItemType.RedeemAndBuy&&(!p||!h))?null:{...e,alpcData:r,insufficient:C,soldOut:g,product:p,variant:h}}).filter(Boolean),[a.list,w,i,l,c,_]);function T(e){return c?e.soldOut?a.soldOut:a.btnRedeem:a.unlockRewards}function V(e){return e.type===n.ConsumeCreditsItemType.GiftCard||e.type===n.ConsumeCreditsItemType.Product?e.insufficient:e.soldOut||e.insufficient}async function j(e){if(!c){L();return}if(!l?.activated&&!s){I({type:n.MemberPopupPanelType.Activate,props:{}});return}if(e.type===n.ConsumeCreditsItemType.GiftCard||e.type===n.ConsumeCreditsItemType.Product){a.creditsPage?.url&&window.open(a.creditsPage.url,"_blank","noopener,noreferrer");return}if(e.type===n.ConsumeCreditsItemType.Coupon)I({type:n.MemberPopupPanelType.RedeemCoupon,props:{itemTitle:e.title,itemCredits:e.alpcData.consume_credits,itemImage:a.imageMapping?.[e.type]?{url:a.imageMapping[e.type].url,alt:e.image?.alt}:e.image,itemValue:e.value,itemOff:a.off,itemRules:e.rules,redeemId:Number(e.redeemId),userId:l?.user_id,alpcConfig:b}});else{R(""),k(e.redeemId);try{await $({productVariant:e.variant,redeemId:Number(e.redeemId),userId:l?.user_id})}catch(r){R(r?.message??a.redeemModal.commonError)}finally{k(null)}}}return(0,t.jsx)(t.Fragment,{children:(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[12px]",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-[8px]",children:[a.title&&(0,t.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:a.title}),a.subtitle&&(0,t.jsx)("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:a.subtitle})]}),c&&(0,t.jsxs)("div",{className:(0,o.classNames)("flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]",N?"rounded-[8px]":"rounded-none"),children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,t.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:a.balanceLabel??"AnkerCredits Balance"}),(0,t.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,t.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,m.numberFormat)(i?.available_credit||0)}),(0,t.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:a.creditUnit??a.pointUnit??"ankercredits"})]})]}),(0,t.jsx)("div",{className:"h-full w-px bg-[#dadce0]"}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,t.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:a.comingSoonLabel??"Coming Soon"}),(0,t.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,t.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,m.numberFormat)(i?.pending_credit||0)}),(0,t.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:a.creditUnit??a.pointUnit??"ankercredits"}),(0,t.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:a.creditUnit??"ankercredits"})]})]})]}),P&&(0,t.jsx)("div",{className:"text-[14px] font-[700] text-[#f84d4f]",children:P}),E?(0,t.jsx)("div",{className:"flex flex-1 items-center justify-center py-[32px]",children:(0,t.jsx)("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}):(0,t.jsx)("div",{className:"flex flex-col",children:F.map((e,r)=>{const d=!!e.product;return(0,t.jsxs)("div",{className:"relative py-[16px]",children:[r>0&&(0,t.jsx)("div",{className:"absolute inset-x-0 top-0 h-px bg-[#dadce0]"}),(0,t.jsxs)("div",{className:"flex items-center gap-[12px]",children:[(()=>{const C=a.imageMapping?.[e.type]?.url,g=d?e.variant?.image?.url??e.product?.images?.[0]?.url??e.image?.url:C??e.image?.url,p=d?e.variant?.image?.altText??e.product?.images?.[0]?.alt??e.image?.alt??"":e.image?.alt??"";return g?(0,t.jsxs)("div",{className:(0,o.classNames)("relative size-[64px] shrink-0 overflow-hidden",N?"rounded-[4px]":"rounded-none"),children:[(0,t.jsx)(v.Picture,{source:g,alt:p,className:"flex size-full items-center justify-center",imgClassName:d?"object-cover":"h-full w-auto object-contain"}),!d&&e.value&&(0,t.jsxs)("div",{className:"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white",children:[e.value," ",a.off]})]}):null})(),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("div",{className:"text-[16px] font-[700] text-[#1e2024] line-clamp-2",children:d&&e.product?.title?e.product.title:e.title}),(0,t.jsx)("div",{className:"mt-[4px] text-[14px] text-[#666]",children:d&&e.price!=null?`${(0,m.numberFormat)(e.alpcData.consume_credits)} ${a.pointUnit??""} + $${Number(e.price).toFixed(2)}`:`${(0,m.numberFormat)(e.alpcData.consume_credits)} ${a.pointUnit??""}`})]}),(0,t.jsxs)("div",{className:"relative group",children:[(0,t.jsx)(v.Button,{className:(0,o.classNames)("bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",N?"rounded-[4px]":"rounded-none"),disabled:V(e),loading:O===e.redeemId,onClick:()=>j(e),children:T(e)}),e.insufficient&&(0,t.jsx)("div",{className:"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block",children:(0,t.jsxs)("div",{className:"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow",children:[(0,t.jsx)("p",{className:"text-pretty tracking-[-0.02em] text-[14px]",children:a.insufficientCredits}),(0,t.jsx)("div",{className:"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]"})]})})]})]})]},r)})}),a.creditsPage?.url&&(0,t.jsx)("a",{href:a.creditsPage.url,target:"_blank",rel:"noopener noreferrer",className:"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline",children:a.creditsPage.label??"Go to Credits Page"})]})})}var X=W;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/ConsumeCredits/index.tsx"],
4
- "sourcesContent": ["import { useMemo, useState } from 'react'\nimport { Picture, Button } from '@anker-in/headless-ui'\nimport { classNames as cn, useProductsByHandles, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useRedeemableList } from './hooks/useRedeemableList'\nimport { useRedeemAndBuy } from './hooks/useRedeemAndBuy'\nimport {\n ConsumeCreditsItemType,\n MemberPopupPanelType,\n type ConsumeCreditsopy,\n type ConsumeCreditsItem,\n} from '../../type'\nimport { numberFormat } from '../../../credits/context/utils'\nimport type { ConsumeCreditRuleResponse } from '../../../credits/context/response'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype EnrichedItem = ConsumeCreditsItem & {\n alpcData: ConsumeCreditRuleResponse\n insufficient: boolean\n soldOut: boolean\n product?: any\n variant?: any\n}\n\ntype Props = {\n copy: ConsumeCreditsopy\n onClose: () => void\n}\n\nfunction ConsumeCredits({ copy, onClose }: Props) {\n const { profile, creditInfo, openSignUpPopup, alpcConfig } = useMemberPopupContext()\n const { pushView } = useViewStack()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const [redeemAndBuyError, setRedeemAndBuyError] = useState('')\n const [loadingId, setLoadingId] = useState<string | number | null>(null)\n\n const isLogin = !!profile\n const { redeemableList, listLoading } = useRedeemableList(alpcConfig)\n const { trigger: redeemAndBuy } = useRedeemAndBuy(alpcConfig)\n\n const handles = copy.list.map(item => item.product?.handle).filter(Boolean) as string[]\n const { data: products } = useProductsByHandles({ handles })\n\n const list = useMemo(() => {\n return copy.list\n .map(item => {\n const alpcData = redeemableList.find(r => String(r.id) === String(item.redeemId))\n if (!alpcData) return null\n\n const availableCredit = Number(creditInfo?.available_credit ?? 0)\n const insufficient = isLogin && !!profile?.activated && alpcData.consume_credits > availableCredit\n const soldOut = alpcData.is_limited && (!alpcData.remaining_inventory || alpcData.remaining_inventory <= 0)\n\n let product\n let variant\n if (item.type === ConsumeCreditsItemType.RedeemAndBuy && item.product) {\n product = products?.find((p: any) => p.handle === item.product!.handle)\n variant = product?.variants?.find((v: any) => v.sku === item.product!.sku) ?? product?.variants?.[0]\n if (!product || !variant) return null\n }\n\n return { ...item, alpcData, insufficient, soldOut, product, variant }\n })\n .filter(Boolean) as EnrichedItem[]\n }, [copy.list, redeemableList, creditInfo, profile, isLogin, products])\n\n function getButtonLabel(item: (typeof list)[number]) {\n if (!isLogin) return copy.unlockRewards\n if (item.soldOut) return copy.soldOut\n return copy.btnRedeem\n }\n\n function isDisabled(item: (typeof list)[number]) {\n return item.soldOut || item.insufficient\n }\n\n async function handleRedeem(item: (typeof list)[number]) {\n if (!isLogin) {\n openSignUpPopup()\n return\n }\n if (item.type === ConsumeCreditsItemType.Coupon) {\n pushView({\n type: MemberPopupPanelType.RedeemCoupon,\n props: {\n itemTitle: item.title,\n itemCredits: item.alpcData.consume_credits,\n itemImage: copy.imageMapping?.[item.type]\n ? { url: copy.imageMapping[item.type]!.url, alt: item.image?.alt }\n : item.image,\n itemValue: item.value,\n itemOff: copy.off,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n alpcConfig,\n },\n })\n } else {\n setRedeemAndBuyError('')\n setLoadingId(item.redeemId)\n try {\n await redeemAndBuy({\n productVariant: item.variant,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n })\n } catch (e: any) {\n setRedeemAndBuyError(e?.message ?? copy.redeemModal.commonError)\n } finally {\n setLoadingId(null)\n }\n }\n }\n\n return (\n <>\n <div className=\"flex flex-1 flex-col gap-[12px]\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>}\n {copy.subtitle && <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>}\n </div>\n\n {copy.insufficientCredits && creditInfo && (\n <div className=\"text-[14px] font-[700] text-[#1d1d1f]\">\n {copy.insufficientCredits}: {numberFormat(creditInfo.available_credit)} {copy.pointUnit}\n </div>\n )}\n {redeemAndBuyError && <div className=\"text-[14px] font-[700] text-[#f84d4f]\">{redeemAndBuyError}</div>}\n\n {listLoading ? (\n <div className=\"flex flex-1 items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n ) : (\n <div className=\"flex flex-col\">\n {list.map((item, idx) => (\n <div key={idx} className=\"relative py-[16px]\">\n {idx > 0 && <div className=\"absolute inset-x-0 top-0 h-px bg-[#dadce0]\" />}\n <div className=\"flex items-center gap-[12px]\">\n {(() => {\n const isRedeemAndBuy = item.type === ConsumeCreditsItemType.RedeemAndBuy\n const mappedImgUrl = copy.imageMapping?.[item.type]?.url\n const imgUrl = isRedeemAndBuy\n ? (item.variant?.image?.url ?? item.product?.images?.[0]?.url ?? item.image?.url)\n : (mappedImgUrl ?? item.image?.url)\n const imgAlt = isRedeemAndBuy\n ? (item.variant?.image?.altText ?? item.product?.images?.[0]?.alt ?? item.image?.alt ?? '')\n : (item.image?.alt ?? '')\n if (!imgUrl) return null\n return (\n <div className={cn('relative size-[64px] shrink-0 overflow-hidden', rounded ? 'rounded-[4px]' : 'rounded-none')}>\n <Picture\n source={imgUrl}\n alt={imgAlt}\n className=\"flex size-full items-center justify-center\"\n imgClassName={isRedeemAndBuy ? 'object-cover' : 'h-full w-auto object-contain'}\n />\n {!isRedeemAndBuy && item.value && (\n <div className=\"absolute bottom-[20px] left-[4px] text-[14px] font-[800] leading-none text-white\">\n {item.value} {copy.off}\n </div>\n )}\n </div>\n )\n })()}\n <div className=\"min-w-0 flex-1\">\n <div className=\"text-[16px] font-[700] text-[#1e2024] line-clamp-2\">\n {item.type === ConsumeCreditsItemType.RedeemAndBuy && item.product?.title\n ? item.product.title\n : item.title}\n </div>\n <div className=\"mt-[4px] text-[14px] text-[#666]\">\n {item.type === ConsumeCreditsItemType.RedeemAndBuy && item.price != null\n ? `${numberFormat(item.alpcData.consume_credits)} ${copy.pointUnit ?? ''} + $${Number(item.price).toFixed(2)}`\n : `${numberFormat(item.alpcData.consume_credits)} ${copy.pointUnit ?? ''}`}\n </div>\n </div>\n <div className=\"relative group\">\n <Button\n className={cn('bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white', rounded ? 'rounded-[4px]' : 'rounded-none')}\n disabled={isDisabled(item)}\n loading={loadingId === item.redeemId}\n onClick={() => handleRedeem(item)}\n >\n {getButtonLabel(item)}\n </Button>\n {item.insufficient && (\n <div className=\"pointer-events-none absolute left-[48px] top-full mt-[10px] hidden -translate-x-1/2 group-hover:block\">\n <div className=\"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow md:px-[10px] md:py-[8px]\">\n <p className=\"text-pretty tracking-[-0.02em] text-[14px]\">{copy.insufficientCredits}</p>\n <div className=\"absolute -top-[8px] left-[48px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]\" />\n </div>\n </div>\n )}\n </div>\n </div>\n </div>\n ))}\n </div>\n )}\n\n {copy.creditsPage?.url && (\n <a\n href={copy.creditsPage.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"mt-auto self-start text-[14px] font-[700] text-[#080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,UAAU,qEAET,SAAAA,EAAK,YAAY,OAAS,qBAC7B,GAEJ,EACF,CAEJ,CAEA,IAAOd,EAAQa",
6
- "names": ["ConsumeCredits_exports", "__export", "ConsumeCredits_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_provider", "import_viewStack", "import_useRedeemableList", "import_useRedeemAndBuy", "import_type", "import_utils", "import_constants", "ConsumeCredits", "copy", "onClose", "profile", "creditInfo", "openSignUpPopup", "alpcConfig", "pushView", "brand", "rounded", "redeemAndBuyError", "setRedeemAndBuyError", "loadingId", "setLoadingId", "isLogin", "redeemableList", "listLoading", "redeemAndBuy", "handles", "item", "products", "list", "alpcData", "r", "availableCredit", "insufficient", "soldOut", "product", "variant", "p", "v", "getButtonLabel", "isDisabled", "handleRedeem", "e", "idx", "isRedeemAndBuy", "mappedImgUrl", "imgUrl", "imgAlt", "cn"]
4
+ "sourcesContent": ["import { useMemo, useState } from 'react'\nimport { Picture, Button } from '@anker-in/headless-ui'\nimport { classNames as cn, useProductsByHandles, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useRedeemableList } from './hooks/useRedeemableList'\nimport { useRedeemAndBuy } from './hooks/useRedeemAndBuy'\nimport {\n ConsumeCreditsItemType,\n MemberPopupPanelType,\n type ConsumeCreditsopy,\n type ConsumeCreditsItem,\n} from '../../type'\nimport { numberFormat } from '../../../credits/context/utils'\nimport type { ConsumeCreditRuleResponse } from '../../../credits/context/response'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype EnrichedItem = ConsumeCreditsItem & {\n alpcData: ConsumeCreditRuleResponse\n insufficient: boolean\n soldOut: boolean\n product?: any\n variant?: any\n}\n\ntype Props = {\n copy: ConsumeCreditsopy\n onClose: () => void\n isActivateSuccess: boolean\n}\n\nfunction ConsumeCredits({ copy, isActivateSuccess, onClose }: Props) {\n const { profile, creditInfo, openSignUpPopup, alpcConfig } = useMemberPopupContext()\n const { pushView } = useViewStack()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const [redeemAndBuyError, setRedeemAndBuyError] = useState('')\n const [loadingId, setLoadingId] = useState<string | number | null>(null)\n\n const isLogin = !!profile\n const { redeemableList, listLoading } = useRedeemableList(alpcConfig)\n const { trigger: redeemAndBuy } = useRedeemAndBuy(alpcConfig)\n\n const handles = copy.list.map(item => item.product?.handle).filter(Boolean) as string[]\n const { data: products } = useProductsByHandles({ handles })\n\n const list = useMemo(() => {\n return copy.list\n .map(item => {\n const alpcData = redeemableList.find(r => String(r.id) === String(item.redeemId))\n if (!alpcData) return null\n\n const availableCredit = Number(creditInfo?.available_credit ?? 0)\n const insufficient = isLogin && !!profile?.activated && alpcData.consume_credits > availableCredit\n const soldOut = alpcData.is_limited && (!alpcData.remaining_inventory || alpcData.remaining_inventory <= 0)\n\n let product\n let variant\n if (\n (item.type === ConsumeCreditsItemType.RedeemAndBuy || item.type === ConsumeCreditsItemType.Product) &&\n item.product\n ) {\n product = products?.find((p: any) => p.handle === item.product!.handle)\n variant = product?.variants?.find((v: any) => v.sku === item.product!.sku) ?? product?.variants?.[0]\n if (item.type === ConsumeCreditsItemType.RedeemAndBuy && (!product || !variant)) return null\n }\n\n return { ...item, alpcData, insufficient, soldOut, product, variant }\n })\n .filter(Boolean) as EnrichedItem[]\n }, [copy.list, redeemableList, creditInfo, profile, isLogin, products])\n\n function getButtonLabel(item: (typeof list)[number]) {\n if (!isLogin) return copy.unlockRewards\n if (item.soldOut) return copy.soldOut\n return copy.btnRedeem\n }\n\n function isDisabled(item: (typeof list)[number]) {\n if (item.type === ConsumeCreditsItemType.GiftCard || item.type === ConsumeCreditsItemType.Product) {\n return item.insufficient\n }\n return item.soldOut || item.insufficient\n }\n\n async function handleRedeem(item: (typeof list)[number]) {\n if (!isLogin) {\n openSignUpPopup()\n return\n }\n if (!profile?.activated && !isActivateSuccess) {\n pushView({\n type: MemberPopupPanelType.Activate,\n props: {},\n })\n return\n }\n if (item.type === ConsumeCreditsItemType.GiftCard || item.type === ConsumeCreditsItemType.Product) {\n if (copy.creditsPage?.url) {\n window.open(copy.creditsPage.url, '_blank', 'noopener,noreferrer')\n }\n return\n }\n if (item.type === ConsumeCreditsItemType.Coupon) {\n pushView({\n type: MemberPopupPanelType.RedeemCoupon,\n props: {\n itemTitle: item.title,\n itemCredits: item.alpcData.consume_credits,\n itemImage: copy.imageMapping?.[item.type]\n ? { url: copy.imageMapping[item.type]!.url, alt: item.image?.alt }\n : item.image,\n itemValue: item.value,\n itemOff: copy.off,\n itemRules: item.rules,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n alpcConfig,\n },\n })\n } else {\n setRedeemAndBuyError('')\n setLoadingId(item.redeemId)\n try {\n await redeemAndBuy({\n productVariant: item.variant,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n })\n } catch (e: any) {\n setRedeemAndBuyError(e?.message ?? copy.redeemModal.commonError)\n } finally {\n setLoadingId(null)\n }\n }\n }\n\n return (\n <>\n <div className=\"flex flex-1 flex-col gap-[12px]\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>}\n {copy.subtitle && <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>}\n </div>\n\n {isLogin && (\n <div\n className={cn(\n 'flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]',\n rounded ? 'rounded-[8px]' : 'rounded-none'\n )}\n >\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.balanceLabel ?? 'AnkerCredits Balance'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.available_credit || 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? copy.pointUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n <div className=\"h-full w-px bg-[#dadce0]\" />\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.comingSoonLabel ?? 'Coming Soon'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.pending_credit || 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? copy.pointUnit ?? 'ankercredits'}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n </div>\n )}\n {redeemAndBuyError && <div className=\"text-[14px] font-[700] text-[#f84d4f]\">{redeemAndBuyError}</div>}\n\n {listLoading ? (\n <div className=\"flex flex-1 items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n ) : (\n <div className=\"flex flex-col\">\n {list.map((item, idx) => {\n const hasProduct = !!item.product\n return (\n <div key={idx} className=\"relative py-[16px]\">\n {idx > 0 && <div className=\"absolute inset-x-0 top-0 h-px bg-[#dadce0]\" />}\n <div className=\"flex items-center gap-[12px]\">\n {(() => {\n const mappedImgUrl = copy.imageMapping?.[item.type]?.url\n const imgUrl = hasProduct\n ? (item.variant?.image?.url ?? item.product?.images?.[0]?.url ?? item.image?.url)\n : (mappedImgUrl ?? item.image?.url)\n const imgAlt = hasProduct\n ? (item.variant?.image?.altText ?? item.product?.images?.[0]?.alt ?? item.image?.alt ?? '')\n : (item.image?.alt ?? '')\n if (!imgUrl) return null\n return (\n <div\n className={cn(\n 'relative size-[64px] shrink-0 overflow-hidden',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n >\n <Picture\n source={imgUrl}\n alt={imgAlt}\n className=\"flex size-full items-center justify-center\"\n imgClassName={hasProduct ? 'object-cover' : 'h-full w-auto object-contain'}\n />\n {!hasProduct && item.value && (\n <div className=\"absolute bottom-[16px] left-[4px] text-[12px] font-[800] leading-none text-white\">\n {item.value} {copy.off}\n </div>\n )}\n </div>\n )\n })()}\n <div className=\"min-w-0 flex-1\">\n <div className=\"text-[16px] font-[700] text-[#1e2024] line-clamp-2\">\n {hasProduct && item.product?.title ? item.product.title : item.title}\n </div>\n <div className=\"mt-[4px] text-[14px] text-[#666]\">\n {hasProduct && item.price != null\n ? `${numberFormat(item.alpcData.consume_credits)} ${copy.pointUnit ?? ''} + $${Number(item.price).toFixed(2)}`\n : `${numberFormat(item.alpcData.consume_credits)} ${copy.pointUnit ?? ''}`}\n </div>\n </div>\n <div className=\"relative group\">\n <Button\n className={cn(\n 'bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={isDisabled(item)}\n loading={loadingId === item.redeemId}\n onClick={() => handleRedeem(item)}\n >\n {getButtonLabel(item)}\n </Button>\n {item.insufficient && (\n <div className=\"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block\">\n <div className=\"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow\">\n <p className=\"text-pretty tracking-[-0.02em] text-[14px]\">{copy.insufficientCredits}</p>\n <div className=\"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]\" />\n </div>\n </div>\n )}\n </div>\n </div>\n </div>\n )\n })}\n </div>\n )}\n\n {copy.creditsPage?.url && (\n <a\n href={copy.creditsPage.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline\"\n >\n {copy.creditsPage.label ?? 'Go to Credits Page'}\n </a>\n )}\n </div>\n </>\n )\n}\n\nexport default Cons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C,OAAI,UAAU,qDACZ,SAAAqC,GAAclB,EAAK,SAAS,MAAQA,EAAK,QAAQ,MAAQA,EAAK,MACjE,KACA,OAAC,OAAI,UAAU,mCACZ,SAAAkB,GAAclB,EAAK,OAAS,KACzB,MAAG,gBAAaA,EAAK,SAAS,eAAe,CAAC,IAAInB,EAAK,WAAa,EAAE,OAAO,OAAOmB,EAAK,KAAK,EAAE,QAAQ,CAAC,CAAC,GAC1G,MAAG,gBAAaA,EAAK,SAAS,eAAe,CAAC,IAAInB,EAAK,WAAa,EAAE,GAC5E,GACF,KACA,QAAC,OAAI,UAAU,iBACb,oBAAC,UACC,aAAW,EAAAmC,YACT,6FACA1B,EAAU,gBAAkB,cAC9B,EACA,SAAUuB,EAAWb,CAAI,EACzB,QAASP,IAAcO,EAAK,SAC5B,QAAS,IAAMc,EAAad,CAAI,EAE/B,SAAAY,EAAeZ,CAAI,EACtB,EACCA,EAAK,iBACJ,OAAC,OAAI,UAAU,qGACb,oBAAC,OAAI,UAAU,0EACb,oBAAC,KAAE,UAAU,6CAA8C,SAAAnB,EAAK,oBAAoB,KACpF,OAAC,OAAI,UAAU,oGAAoG,GACrH,EACF,GAEJ,GACF,IAhEQoC,CAiEV,CAEJ,CAAC,EACH,EAGDpC,EAAK,aAAa,QACjB,OAAC,KACC,KAAMA,EAAK,YAAY,IACvB,OAAO,SACP,IAAI,sBACJ,UAAU,qEAET,SAAAA,EAAK,YAAY,OAAS,qBAC7B,GAEJ,EACF,CAEJ,CAEA,IAAOd,EAAQa",
6
+ "names": ["ConsumeCredits_exports", "__export", "ConsumeCredits_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_provider", "import_viewStack", "import_useRedeemableList", "import_useRedeemAndBuy", "import_type", "import_utils", "import_constants", "ConsumeCredits", "copy", "isActivateSuccess", "onClose", "profile", "creditInfo", "openSignUpPopup", "alpcConfig", "pushView", "brand", "rounded", "redeemAndBuyError", "setRedeemAndBuyError", "loadingId", "setLoadingId", "isLogin", "redeemableList", "listLoading", "redeemAndBuy", "handles", "item", "products", "list", "alpcData", "r", "availableCredit", "insufficient", "soldOut", "product", "variant", "p", "v", "getButtonLabel", "isDisabled", "handleRedeem", "e", "cn", "idx", "hasProduct", "mappedImgUrl", "imgUrl", "imgAlt"]
7
7
  }
@@ -0,0 +1,11 @@
1
+ import type { SubscribeModalCopy } from '../../type';
2
+ type Props = {
3
+ onClose: () => void;
4
+ onSuccess?: () => void;
5
+ copy: SubscribeModalCopy;
6
+ email?: string;
7
+ hideForm: boolean;
8
+ onHideForm: () => void;
9
+ };
10
+ export default function ActivitiesSubscribeModal({ onClose, onSuccess, copy, email: initialEmail, hideForm, onHideForm }: Props): import("react/jsx-runtime").JSX.Element;
11
+ export {};