@anker-in/campaign-ui 0.5.0-beta.4 → 0.5.0-beta.5

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 (52) 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/index.js +1 -1
  9. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.js.map +3 -3
  10. package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.d.ts +11 -0
  11. package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js +2 -0
  12. package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js.map +7 -0
  13. package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeModal.js +1 -1
  14. package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeModal.js.map +2 -2
  15. package/dist/cjs/components/memberPopup/panels/EarnCredits/index.js +1 -1
  16. package/dist/cjs/components/memberPopup/panels/EarnCredits/index.js.map +2 -2
  17. package/dist/cjs/components/memberPopup/panels/Referral/index.js +1 -1
  18. package/dist/cjs/components/memberPopup/panels/Referral/index.js.map +2 -2
  19. package/dist/cjs/components/memberPopup/type.d.ts +14 -2
  20. package/dist/cjs/components/memberPopup/type.js +1 -1
  21. package/dist/cjs/components/memberPopup/type.js.map +2 -2
  22. package/dist/esm/components/credits/context/hooks/useCountries.js +1 -1
  23. package/dist/esm/components/credits/context/hooks/useCountries.js.map +3 -3
  24. package/dist/esm/components/memberPopup/MemberPopup.js +1 -1
  25. package/dist/esm/components/memberPopup/MemberPopup.js.map +3 -3
  26. package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.d.ts +10 -0
  27. package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js +2 -0
  28. package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +7 -0
  29. package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.js +1 -1
  30. package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.js.map +3 -3
  31. package/dist/esm/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.d.ts +11 -0
  32. package/dist/esm/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js +2 -0
  33. package/dist/esm/components/memberPopup/panels/EarnCredits/ActivitiesSubscribePanel.js.map +7 -0
  34. package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeModal.js +1 -1
  35. package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeModal.js.map +2 -2
  36. package/dist/esm/components/memberPopup/panels/EarnCredits/index.js +1 -1
  37. package/dist/esm/components/memberPopup/panels/EarnCredits/index.js.map +2 -2
  38. package/dist/esm/components/memberPopup/panels/Referral/index.js +1 -1
  39. package/dist/esm/components/memberPopup/panels/Referral/index.js.map +2 -2
  40. package/dist/esm/components/memberPopup/type.d.ts +14 -2
  41. package/dist/esm/components/memberPopup/type.js +1 -1
  42. package/dist/esm/components/memberPopup/type.js.map +2 -2
  43. package/package.json +1 -1
  44. package/src/components/credits/context/hooks/useCountries.ts +1 -2
  45. package/src/components/memberPopup/MemberPopup.tsx +17 -13
  46. package/src/components/memberPopup/panels/ActivitiesSubscribePanel.tsx +198 -0
  47. package/src/components/memberPopup/panels/ConsumeCredits/index.tsx +39 -14
  48. package/src/components/memberPopup/panels/EarnCredits/index.tsx +94 -64
  49. package/src/components/memberPopup/panels/Referral/index.tsx +1 -1
  50. package/src/components/memberPopup/type.ts +10 -1
  51. package/src/components/memberPopup/panels/EarnCredits/SubscribeModal.tsx +0 -144
  52. package/src/components/memberPopup/panels/EarnCredits/SubscribePanel.tsx +0 -147
@@ -0,0 +1,2 @@
1
+ import{Fragment as V,jsx as t,jsxs as a}from"react/jsx-runtime";import{useCallback as B,useEffect as A,useState as i}from"react";import{Button as D,Checkbox as R,Picture as O,Text as c}from"@anker-in/headless-ui";import{classNames as u,useHeadlessContext as U}from"@anker-in/lib";import f from"js-cookie";import{parse as j}from"query-string";import{emailValidate as E}from"../../credits/context/utils";import{useMemberPopupContext as F}from"../context/provider";import{ROUNDED_BRANDS as H}from"../../../constants";function I(){if(typeof window>"u")return{register_source:""};const{search:o,href:e}=window.location,r=j(o);return{fbuy_ref_code:f.get("fbuy_ref_code"),ref:f.get("ref_ads"),inviter_code:r.ic??r.inviter_code??f.get("inviter_code"),register_source:r.redirect??f.get("reg_source")??e}}async function q(o){if(typeof window>"u"||!window?.grecaptcha?.execute||!o)return"";try{return await window.grecaptcha.execute(o,{action:"activity"})}catch{return""}}function J({onSuccess:o,copy:e,email:r,hideForm:N,onHideForm:x}){const{alpcConfig:C}=F(),{locale:g}=C,{brand:M,storeDomain:b,recaptchaSitekey:S}=U(),d=H.includes(M),[m,k]=i(!1),[n,h]=i(r??""),[p,s]=i(""),[T,v]=i(""),[y,_]=i(!1);A(()=>{r&&h(r)},[r]);const L=B(async()=>{if(s(""),!n)return s("Please fill in your email");if(!E(n))return s("Invalid email address");if(!m)return s("Please agree to the policy");_(!0);const{register_source:l}=I(),P=await q(S||"");try{const w=await(await fetch("/api/multipass/rainbowbridge/activities",{method:"POST",headers:{"Content-Type":"application/json","current-language":g,"X-Recaptcha-Token":P},body:JSON.stringify({email:n,register_source:l,shopify_domain:b,single_brand_subscribe:e.single_brand_subscribe??!0,genre:e.genre??e.dealsType??"",sub_brand_type:e.sub_brand_type??""})})).json();w.errors?s(w.errors??"Error occurred"):(v(e.successTips??"Subscribed successfully!"),o?.(),setTimeout(()=>{x(),v("")},3e3))}catch{s("Network error")}finally{_(!1)}},[n,m,g,b,e,o,x]);return a("div",{className:"flex flex-col gap-[16px] text-center",children:[!N&&a(V,{children:[t(c,{className:"text-[22px] font-bold",html:e.title}),e.desc&&t(c,{className:"text-left text-[16px] font-semibold text-[#1f2021]",html:e.desc}),a("div",{className:u("flex h-[52px] w-full overflow-hidden md:flex-col md:h-auto md:gap-[16px]",d?"rounded-[2px]":"rounded-none"),children:[t("input",{className:u("h-[46px] w-full border px-[14px] text-[16px] outline-none placeholder:text-[#999]",p?"border-[#f84d4f]":"border-[#d8d8d8]",d?"rounded-[4px]":"rounded-none"),placeholder:e.placeholder,value:n,onChange:l=>{s(""),h(l.target.value.trim())}}),t(D,{variant:"primary",loading:y,className:u("!h-full !min-w-0 !px-[24px] md:!h-[46px]",d?"!rounded-l-none !rounded-r-[2px] md:!rounded-[2px]":"!rounded-none"),onClick:L,children:e.buttonLabel??"Subscribe"})]}),a("div",{className:"flex w-full items-start gap-[8px]",children:[t(R,{checked:m,onCheckedChange:()=>k(l=>!l),className:"border-[#1d1d1f]"}),t("label",{className:"text-left text-[14px] font-semibold text-[#777] [&_a]:underline",dangerouslySetInnerHTML:{__html:e.policy??""}})]}),p&&t("div",{className:"text-left text-[16px] font-semibold text-[#f84d4f]",children:t(c,{html:p})}),t("div",{className:"text-left text-[16px] font-semibold text-[#52c41a]",children:t(c,{html:T})})]}),e.promo&&a("div",{className:"flex flex-col text-left",children:[a("div",{className:"flex flex-col gap-[8px]",children:[e.promo?.title&&t("h3",{className:"text-[20px] font-[700] leading-[1.2] text-[#080a0f]",children:e.promo?.title}),e.promo.description&&t("p",{className:"text-[14px] leading-[1.5] text-[#1e2024]",children:e.promo.description}),e.promo.learnMoreLabel&&e.promo.learnMoreUrl&&a("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,t("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:t("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&&t(O,{source:e.promo.image.url,alt:e.promo.image.alt??"",className:u("h-[100px] mt-[8px] w-full object-cover",d?"rounded-[8px]":"rounded-none")})]})]})}export{J as default};
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 <div\n className={cn(\n 'flex h-[52px] w-full overflow-hidden md:flex-col md:h-auto md:gap-[16px]',\n rounded ? 'rounded-[2px]' : 'rounded-none'\n )}\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 <Button\n variant=\"primary\"\n loading={loading}\n className={cn(\n '!h-full !min-w-0 !px-[24px] md:!h-[46px]',\n rounded ? '!rounded-l-none !rounded-r-[2px] md:!rounded-[2px]' : '!rounded-none'\n )}\n onClick={handleSubmit}\n >\n {copy.buttonLabel ?? 'Subscribe'}\n </Button>\n </div>\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 {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": "AA4GQ,mBAAAA,EACE,OAAAC,EAEA,QAAAC,MAHF,oBA5GR,OAAS,eAAAC,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QACjD,OAAS,UAAAC,EAAQ,YAAAC,EAAU,WAAAC,EAAS,QAAAC,MAAY,wBAChD,OAAS,cAAcC,EAAI,sBAAAC,MAA0B,gBACrD,OAAOC,MAAa,YACpB,OAAS,SAAAC,MAAa,eACtB,OAAS,iBAAAC,MAAqB,8BAC9B,OAAS,yBAAAC,MAA6B,sBAEtC,OAAS,kBAAAC,MAAsB,qBAU/B,SAASC,GAAc,CACrB,GAAI,OAAO,OAAW,IAAa,MAAO,CAAE,gBAAiB,EAAG,EAChE,KAAM,CAAE,OAAAC,EAAQ,KAAAC,CAAK,EAAI,OAAO,SAC1BC,EAAQP,EAAMK,CAAM,EAC1B,MAAO,CACL,cAAeN,EAAQ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"jsxs", "useCallback", "useEffect", "useState", "Button", "Checkbox", "Picture", "Text", "cn", "useHeadlessContext", "Cookies", "parse", "emailValidate", "useMemberPopupContext", "ROUNDED_BRANDS", "getAdCookie", "search", "href", "query", "getRecaptchaToken", "sitekey", "ActivitiesSubscribeModal", "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", "e", "v"]
7
+ }
@@ -1,2 +1,2 @@
1
- import{Fragment as K,jsx as n,jsxs as r}from"react/jsx-runtime";import{useMemo as L,useState as I}from"react";import{Picture as S,Button as $}from"@anker-in/headless-ui";import{classNames as R,useProductsByHandles as z,useHeadlessContext as F}from"@anker-in/lib";import{useMemberPopupContext as T}from"../../context/provider";import{useViewStack as V}from"../../context/viewStack";import{useRedeemableList as j}from"./hooks/useRedeemableList";import{useRedeemAndBuy as H}from"./hooks/useRedeemAndBuy";import{ConsumeCreditsItemType as o,MemberPopupPanelType as G}from"../../type";import{numberFormat as v}from"../../../credits/context/utils";import{ROUNDED_BRANDS as q}from"../../../../constants";function J({copy:t,onClose:Q}){const{profile:d,creditInfo:u,openSignUpPopup:B,alpcConfig:c}=T(),{pushView:D}=V(),{brand:_}=F(),g=q.includes(_),[b,N]=I(""),[P,C]=I(null),p=!!d,{redeemableList:y,listLoading:w}=j(c),{trigger:A}=H(c),k=t.list.map(e=>e.product?.handle).filter(Boolean),{data:h}=z({handles:k}),M=L(()=>t.list.map(e=>{const a=y.find(l=>String(l.id)===String(e.redeemId));if(!a)return null;const i=Number(u?.available_credit??0),f=p&&!!d?.activated&&a.consume_credits>i,m=a.is_limited&&(!a.remaining_inventory||a.remaining_inventory<=0);let s,x;return e.type===o.RedeemAndBuy&&e.product&&(s=h?.find(l=>l.handle===e.product.handle),x=s?.variants?.find(l=>l.sku===e.product.sku)??s?.variants?.[0],!s||!x)?null:{...e,alpcData:a,insufficient:f,soldOut:m,product:s,variant:x}}).filter(Boolean),[t.list,y,u,d,p,h]);function O(e){return p?e.soldOut?t.soldOut:t.btnRedeem:t.unlockRewards}function U(e){return e.soldOut||e.insufficient}async function E(e){if(!p){B();return}if(e.type===o.Coupon)D({type:G.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:d?.user_id,alpcConfig:c}});else{N(""),C(e.redeemId);try{await A({productVariant:e.variant,redeemId:Number(e.redeemId),userId:d?.user_id})}catch(a){N(a?.message??t.redeemModal.commonError)}finally{C(null)}}}return n(K,{children:r("div",{className:"flex flex-1 flex-col gap-[12px]",children:[r("div",{className:"flex flex-col gap-[8px]",children:[t.title&&n("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:t.title}),t.subtitle&&n("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:t.subtitle})]}),t.insufficientCredits&&u&&r("div",{className:"text-[14px] font-[700] text-[#1d1d1f]",children:[t.insufficientCredits,": ",v(u.available_credit)," ",t.pointUnit]}),b&&n("div",{className:"text-[14px] font-[700] text-[#f84d4f]",children:b}),w?n("div",{className:"flex flex-1 items-center justify-center py-[32px]",children:n("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}):n("div",{className:"flex flex-col",children:M.map((e,a)=>r("div",{className:"relative py-[16px]",children:[a>0&&n("div",{className:"absolute inset-x-0 top-0 h-px bg-[#dadce0]"}),r("div",{className:"flex items-center gap-[12px]",children:[(()=>{const i=e.type===o.RedeemAndBuy,f=t.imageMapping?.[e.type]?.url,m=i?e.variant?.image?.url??e.product?.images?.[0]?.url??e.image?.url:f??e.image?.url,s=i?e.variant?.image?.altText??e.product?.images?.[0]?.alt??e.image?.alt??"":e.image?.alt??"";return m?r("div",{className:R("relative size-[64px] shrink-0 overflow-hidden",g?"rounded-[4px]":"rounded-none"),children:[n(S,{source:m,alt:s,className:"flex size-full items-center justify-center",imgClassName:i?"object-cover":"h-full w-auto object-contain"}),!i&&e.value&&r("div",{className:"absolute bottom-[20px] left-[4px] text-[14px] font-[800] leading-none text-white",children:[e.value," ",t.off]})]}):null})(),r("div",{className:"min-w-0 flex-1",children:[n("div",{className:"text-[16px] font-[700] text-[#1e2024] line-clamp-2",children:e.type===o.RedeemAndBuy&&e.product?.title?e.product.title:e.title}),n("div",{className:"mt-[4px] text-[14px] text-[#666]",children:e.type===o.RedeemAndBuy&&e.price!=null?`${v(e.alpcData.consume_credits)} ${t.pointUnit??""} + $${Number(e.price).toFixed(2)}`:`${v(e.alpcData.consume_credits)} ${t.pointUnit??""}`})]}),r("div",{className:"relative group",children:[n($,{className:R("bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",g?"rounded-[4px]":"rounded-none"),disabled:U(e),loading:P===e.redeemId,onClick:()=>E(e),children:O(e)}),e.insufficient&&n("div",{className:"pointer-events-none absolute left-[48px] top-full mt-[10px] hidden -translate-x-1/2 group-hover:block",children:r("div",{className:"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow md:px-[10px] md:py-[8px]",children:[n("p",{className:"text-pretty tracking-[-0.02em] text-[14px]",children:t.insufficientCredits}),n("div",{className:"absolute -top-[8px] left-[48px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]"})]})})]})]})]},a))}),t.creditsPage?.url&&n("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 ie=J;export{ie as default};
1
+ import{Fragment as K,jsx as r,jsxs as a}from"react/jsx-runtime";import{useMemo as S,useState as P}from"react";import{Picture as $,Button as z}from"@anker-in/headless-ui";import{classNames as R,useProductsByHandles as F,useHeadlessContext as T}from"@anker-in/lib";import{useMemberPopupContext as V}from"../../context/provider";import{useViewStack as j}from"../../context/viewStack";import{useRedeemableList as G}from"./hooks/useRedeemableList";import{useRedeemAndBuy as H}from"./hooks/useRedeemAndBuy";import{ConsumeCreditsItemType as s,MemberPopupPanelType as w}from"../../type";import{numberFormat as g}from"../../../credits/context/utils";import{ROUNDED_BRANDS as q}from"../../../../constants";function J({copy:t,onClose:Q}){const{profile:l,creditInfo:u,openSignUpPopup:_,alpcConfig:f}=V(),{pushView:v}=j(),{brand:B}=T(),b=q.includes(B),[C,N]=P(""),[D,h]=P(null),p=!!l,{redeemableList:y,listLoading:k}=G(f),{trigger:A}=H(f),M=t.list.map(e=>e.product?.handle).filter(Boolean),{data:I}=F({handles:M}),O=S(()=>t.list.map(e=>{const n=y.find(o=>String(o.id)===String(e.redeemId));if(!n)return null;const i=Number(u?.available_credit??0),m=p&&!!l?.activated&&n.consume_credits>i,c=n.is_limited&&(!n.remaining_inventory||n.remaining_inventory<=0);let d,x;return(e.type===s.RedeemAndBuy||e.type===s.Product)&&e.product&&(d=I?.find(o=>o.handle===e.product.handle),x=d?.variants?.find(o=>o.sku===e.product.sku)??d?.variants?.[0],e.type===s.RedeemAndBuy&&(!d||!x))?null:{...e,alpcData:n,insufficient:m,soldOut:c,product:d,variant:x}}).filter(Boolean),[t.list,y,u,l,p,I]);function U(e){return p?e.soldOut?t.soldOut:t.btnRedeem:t.unlockRewards}function E(e){return e.type===s.GiftCard||e.type===s.Product?e.insufficient:e.soldOut||e.insufficient}async function L(e){if(!p){_();return}if(!l?.activated){v({type:w.Activate});return}if(e.type===s.GiftCard||e.type===s.Product){t.creditsPage?.url&&window.open(t.creditsPage.url,"_blank","noopener,noreferrer");return}if(e.type===s.Coupon)v({type:w.RedeemCoupon,props:{itemTitle:e.title,itemCredits:e.alpcData.consume_credits,itemImage:t.imageMapping?.[e.type]?{url:t.imageMapping[e.type].url,alt:e.image?.alt}:e.image,itemValue:e.value,itemOff:t.off,redeemId:Number(e.redeemId),userId:l?.user_id,alpcConfig:f}});else{N(""),h(e.redeemId);try{await A({productVariant:e.variant,redeemId:Number(e.redeemId),userId:l?.user_id})}catch(n){N(n?.message??t.redeemModal.commonError)}finally{h(null)}}}return r(K,{children:a("div",{className:"flex flex-1 flex-col gap-[12px]",children:[a("div",{className:"flex flex-col gap-[8px]",children:[t.title&&r("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:t.title}),t.subtitle&&r("p",{className:"text-[16px] font-[700] leading-snug text-[#4a4c56]",children:t.subtitle})]}),t.insufficientCredits&&u&&a("div",{className:"text-[14px] font-[700] text-[#1d1d1f]",children:[t.insufficientCredits,": ",g(u.available_credit)," ",t.pointUnit]}),C&&r("div",{className:"text-[14px] font-[700] text-[#f84d4f]",children:C}),k?r("div",{className:"flex flex-1 items-center justify-center py-[32px]",children:r("div",{className:"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent"})}):r("div",{className:"flex flex-col",children:O.map((e,n)=>{const i=!!e.product;return a("div",{className:"relative py-[16px]",children:[n>0&&r("div",{className:"absolute inset-x-0 top-0 h-px bg-[#dadce0]"}),a("div",{className:"flex items-center gap-[12px]",children:[(()=>{const m=t.imageMapping?.[e.type]?.url,c=i?e.variant?.image?.url??e.product?.images?.[0]?.url??e.image?.url:m??e.image?.url,d=i?e.variant?.image?.altText??e.product?.images?.[0]?.alt??e.image?.alt??"":e.image?.alt??"";return c?a("div",{className:R("relative size-[64px] shrink-0 overflow-hidden",b?"rounded-[4px]":"rounded-none"),children:[r($,{source:c,alt:d,className:"flex size-full items-center justify-center",imgClassName:i?"object-cover":"h-full w-auto object-contain"}),!i&&e.value&&a("div",{className:"absolute bottom-[20px] left-[4px] text-[14px] font-[800] leading-none text-white",children:[e.value," ",t.off]})]}):null})(),a("div",{className:"min-w-0 flex-1",children:[r("div",{className:"text-[16px] font-[700] text-[#1e2024] line-clamp-2",children:i&&e.product?.title?e.product.title:e.title}),r("div",{className:"mt-[4px] text-[14px] text-[#666]",children:i&&e.price!=null?`${g(e.alpcData.consume_credits)} ${t.pointUnit??""} + $${Number(e.price).toFixed(2)}`:`${g(e.alpcData.consume_credits)} ${t.pointUnit??""}`})]}),a("div",{className:"relative group",children:[r(z,{className:R("bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",b?"rounded-[4px]":"rounded-none"),disabled:E(e),loading:D===e.redeemId,onClick:()=>L(e),children:U(e)}),e.insufficient&&r("div",{className:"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block",children:a("div",{className:"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow",children:[r("p",{className:"text-pretty tracking-[-0.02em] text-[14px]",children:t.insufficientCredits}),r("div",{className:"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]"})]})})]})]})]},n)})}),t.creditsPage?.url&&r("a",{href:t.creditsPage.url,target:"_blank",rel:"noopener noreferrer",className:"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline",children:t.creditsPage.label??"Go to Credits Page"})]})})}var se=J;export{se as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/ConsumeCredits/index.tsx"],
4
- "sourcesContent": ["import { useMemo, useState } from 'react'\nimport { Picture, Button } from '@anker-in/headless-ui'\nimport { classNames as cn, useProductsByHandles, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useRedeemableList } from './hooks/useRedeemableList'\nimport { useRedeemAndBuy } from './hooks/useRedeemAndBuy'\nimport {\n ConsumeCreditsItemType,\n MemberPopupPanelType,\n type ConsumeCreditsopy,\n type ConsumeCreditsItem,\n} from '../../type'\nimport { numberFormat } from '../../../credits/context/utils'\nimport type { ConsumeCreditRuleResponse } from '../../../credits/context/response'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype EnrichedItem = ConsumeCreditsItem & {\n alpcData: ConsumeCreditRuleResponse\n insufficient: boolean\n soldOut: boolean\n product?: any\n variant?: any\n}\n\ntype Props = {\n copy: ConsumeCreditsopy\n onClose: () => void\n}\n\nfunction ConsumeCredits({ copy, onClose }: Props) {\n const { profile, creditInfo, openSignUpPopup, alpcConfig } = useMemberPopupContext()\n const { pushView } = useViewStack()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const [redeemAndBuyError, setRedeemAndBuyError] = useState('')\n const [loadingId, setLoadingId] = useState<string | number | null>(null)\n\n const isLogin = !!profile\n const { redeemableList, listLoading } = useRedeemableList(alpcConfig)\n const { trigger: redeemAndBuy } = useRedeemAndBuy(alpcConfig)\n\n const handles = copy.list.map(item => item.product?.handle).filter(Boolean) as string[]\n const { data: products } = useProductsByHandles({ handles })\n\n const list = useMemo(() => {\n return copy.list\n .map(item => {\n const alpcData = redeemableList.find(r => String(r.id) === String(item.redeemId))\n if (!alpcData) return null\n\n const availableCredit = Number(creditInfo?.available_credit ?? 0)\n const insufficient = isLogin && !!profile?.activated && alpcData.consume_credits > availableCredit\n const soldOut = alpcData.is_limited && (!alpcData.remaining_inventory || alpcData.remaining_inventory <= 0)\n\n let product\n let variant\n if (item.type === ConsumeCreditsItemType.RedeemAndBuy && item.product) {\n product = products?.find((p: any) => p.handle === item.product!.handle)\n variant = product?.variants?.find((v: any) => v.sku === item.product!.sku) ?? product?.variants?.[0]\n if (!product || !variant) return null\n }\n\n return { ...item, alpcData, insufficient, soldOut, product, variant }\n })\n .filter(Boolean) as EnrichedItem[]\n }, [copy.list, redeemableList, creditInfo, profile, isLogin, products])\n\n function getButtonLabel(item: (typeof list)[number]) {\n if (!isLogin) return copy.unlockRewards\n if (item.soldOut) return copy.soldOut\n return copy.btnRedeem\n }\n\n function isDisabled(item: (typeof list)[number]) {\n return item.soldOut || item.insufficient\n }\n\n async function handleRedeem(item: (typeof list)[number]) {\n if (!isLogin) {\n openSignUpPopup()\n return\n }\n if (item.type === ConsumeCreditsItemType.Coupon) {\n pushView({\n type: MemberPopupPanelType.RedeemCoupon,\n props: {\n itemTitle: item.title,\n itemCredits: item.alpcData.consume_credits,\n itemImage: copy.imageMapping?.[item.type]\n ? { url: copy.imageMapping[item.type]!.url, alt: item.image?.alt }\n : item.image,\n itemValue: item.value,\n itemOff: copy.off,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n alpcConfig,\n },\n })\n } else {\n setRedeemAndBuyError('')\n setLoadingId(item.redeemId)\n try {\n await redeemAndBuy({\n productVariant: item.variant,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n })\n } catch (e: any) {\n setRedeemAndBuyError(e?.message ?? copy.redeemModal.commonError)\n } finally {\n setLoadingId(null)\n }\n }\n }\n\n return (\n <>\n <div className=\"flex flex-1 flex-col gap-[12px]\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>}\n {copy.subtitle && <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>}\n </div>\n\n {copy.insufficientCredits && creditInfo && (\n <div className=\"text-[14px] font-[700] text-[#1d1d1f]\">\n {copy.insufficientCredits}: {numberFormat(creditInfo.available_credit)} {copy.pointUnit}\n </div>\n )}\n {redeemAndBuyError && <div className=\"text-[14px] font-[700] text-[#f84d4f]\">{redeemAndBuyError}</div>}\n\n {listLoading ? (\n <div className=\"flex flex-1 items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n ) : (\n <div className=\"flex flex-col\">\n {list.map((item, idx) => (\n <div key={idx} className=\"relative py-[16px]\">\n {idx > 0 && <div className=\"absolute inset-x-0 top-0 h-px bg-[#dadce0]\" />}\n <div className=\"flex items-center gap-[12px]\">\n {(() => {\n const isRedeemAndBuy = item.type === ConsumeCreditsItemType.RedeemAndBuy\n const mappedImgUrl = copy.imageMapping?.[item.type]?.url\n const imgUrl = isRedeemAndBuy\n ? (item.variant?.image?.url ?? item.product?.images?.[0]?.url ?? item.image?.url)\n : (mappedImgUrl ?? item.image?.url)\n const imgAlt = isRedeemAndBuy\n ? (item.variant?.image?.altText ?? item.product?.images?.[0]?.alt ?? item.image?.alt ?? '')\n : (item.image?.alt ?? '')\n if (!imgUrl) return null\n return (\n <div className={cn('relative size-[64px] shrink-0 overflow-hidden', rounded ? 'rounded-[4px]' : 'rounded-none')}>\n <Picture\n source={imgUrl}\n alt={imgAlt}\n className=\"flex size-full items-center justify-center\"\n imgClassName={isRedeemAndBuy ? 'object-cover' : 'h-full w-auto object-contain'}\n />\n {!isRedeemAndBuy && item.value && (\n <div className=\"absolute bottom-[20px] left-[4px] text-[14px] font-[800] leading-none text-white\">\n {item.value} {copy.off}\n </div>\n )}\n </div>\n )\n })()}\n <div className=\"min-w-0 flex-1\">\n <div className=\"text-[16px] font-[700] text-[#1e2024] line-clamp-2\">\n {item.type === ConsumeCreditsItemType.RedeemAndBuy && item.product?.title\n ? item.product.title\n : item.title}\n </div>\n <div className=\"mt-[4px] text-[14px] text-[#666]\">\n {item.type === ConsumeCreditsItemType.RedeemAndBuy && item.price != null\n ? `${numberFormat(item.alpcData.consume_credits)} ${copy.pointUnit ?? ''} + $${Number(item.price).toFixed(2)}`\n : `${numberFormat(item.alpcData.consume_credits)} ${copy.pointUnit ?? ''}`}\n </div>\n </div>\n <div className=\"relative group\">\n <Button\n className={cn('bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white', rounded ? 'rounded-[4px]' : 'rounded-none')}\n disabled={isDisabled(item)}\n loading={loadingId === item.redeemId}\n onClick={() => handleRedeem(item)}\n >\n {getButtonLabel(item)}\n </Button>\n {item.insufficient && (\n <div className=\"pointer-events-none absolute left-[48px] top-full mt-[10px] hidden -translate-x-1/2 group-hover:block\">\n <div className=\"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow md:px-[10px] md:py-[8px]\">\n <p className=\"text-pretty tracking-[-0.02em] text-[14px]\">{copy.insufficientCredits}</p>\n <div className=\"absolute -top-[8px] left-[48px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]\" />\n </div>\n </div>\n )}\n </div>\n </div>\n </div>\n ))}\n </div>\n )}\n\n {copy.creditsPage?.url && (\n <a\n href={copy.creditsPage.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline\"\n >\n {copy.creditsPage.label ?? 'Go to Credits Page'}\n </a>\n )}\n </div>\n </>\n )\n}\n\nexport default ConsumeCredits\n"],
5
- "mappings": "AAsHI,mBAAAA,EAGqB,OAAAC,EADjB,QAAAC,MAFJ,oBAtHJ,OAAS,WAAAC,EAAS,YAAAC,MAAgB,QAClC,OAAS,WAAAC,EAAS,UAAAC,MAAc,wBAChC,OAAS,cAAcC,EAAI,wBAAAC,EAAsB,sBAAAC,MAA0B,gBAC3E,OAAS,yBAAAC,MAA6B,yBACtC,OAAS,gBAAAC,MAAoB,0BAC7B,OAAS,qBAAAC,MAAyB,4BAClC,OAAS,mBAAAC,MAAuB,0BAChC,OACE,0BAAAC,EACA,wBAAAC,MAGK,aACP,OAAS,gBAAAC,MAAoB,iCAE7B,OAAS,kBAAAC,MAAsB,wBAe/B,SAASC,EAAe,CAAE,KAAAC,EAAM,QAAAC,CAAQ,EAAU,CAChD,KAAM,CAAE,QAAAC,EAAS,WAAAC,EAAY,gBAAAC,EAAiB,WAAAC,CAAW,EAAId,EAAsB,EAC7E,CAAE,SAAAe,CAAS,EAAId,EAAa,EAC5B,CAAE,MAAAe,CAAM,EAAIjB,EAAmB,EAC/BkB,EAAUV,EAA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AgBuB,EAAK,OAAS,KAChE,GAAGrB,EAAaqB,EAAK,SAAS,eAAe,CAAC,IAAIlB,EAAK,WAAa,EAAE,OAAO,OAAOkB,EAAK,KAAK,EAAE,QAAQ,CAAC,CAAC,GAC1G,GAAGrB,EAAaqB,EAAK,SAAS,eAAe,CAAC,IAAIlB,EAAK,WAAa,EAAE,GAC5E,GACF,EACAjB,EAAC,OAAI,UAAU,iBACb,UAAAD,EAACK,EAAA,CACC,UAAWC,EAAG,6FAA8FoB,EAAU,gBAAkB,cAAc,EACtJ,SAAUuB,EAAWb,CAAI,EACzB,QAASP,IAAcO,EAAK,SAC5B,QAAS,IAAMc,EAAad,CAAI,EAE/B,SAAAY,EAAeZ,CAAI,EACtB,EACCA,EAAK,cACJpC,EAAC,OAAI,UAAU,wGACb,SAAAC,EAAC,OAAI,UAAU,mGACb,UAAAD,EAAC,KAAE,UAAU,6CAA8C,SAAAkB,EAAK,oBAAoB,EACpFlB,EAAC,OAAI,UAAU,mGAAmG,GACpH,EACF,GAEJ,GACF,IA3DQoD,CA4DV,CACD,EACH,EAGClC,EAAK,aAAa,KACjBlB,EAAC,KACC,KAAMkB,EAAK,YAAY,IACvB,OAAO,SACP,IAAI,sBACJ,UAAU,qEAET,SAAAA,EAAK,YAAY,OAAS,qBAC7B,GAEJ,EACF,CAEJ,CAEA,IAAOuC,GAAQxC",
6
- "names": ["Fragment", "jsx", "jsxs", "useMemo", "useState", "Picture", "Button", "cn", "useProductsByHandles", "useHeadlessContext", "useMemberPopupContext", "useViewStack", "useRedeemableList", "useRedeemAndBuy", "ConsumeCreditsItemType", "MemberPopupPanelType", "numberFormat", "ROUNDED_BRANDS", "ConsumeCredits", "copy", "onClose", "profile", "creditInfo", "openSignUpPopup", "alpcConfig", "pushView", "brand", "rounded", "redeemAndBuyError", "setRedeemAndBuyError", "loadingId", "setLoadingId", "isLogin", "redeemableList", "listLoading", "redeemAndBuy", "handles", "item", "products", "list", "alpcData", "r", "availableCredit", "insufficient", "soldOut", "product", "variant", "p", "v", "getButtonLabel", "isDisabled", "handleRedeem", "e", "idx", "isRedeemAndBuy", "mappedImgUrl", "imgUrl", "imgAlt", "ConsumeCredits_default"]
4
+ "sourcesContent": ["import { useMemo, useState } from 'react'\nimport { Picture, Button } from '@anker-in/headless-ui'\nimport { classNames as cn, useProductsByHandles, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useRedeemableList } from './hooks/useRedeemableList'\nimport { useRedeemAndBuy } from './hooks/useRedeemAndBuy'\nimport {\n ConsumeCreditsItemType,\n MemberPopupPanelType,\n type ConsumeCreditsopy,\n type ConsumeCreditsItem,\n} from '../../type'\nimport { numberFormat } from '../../../credits/context/utils'\nimport type { ConsumeCreditRuleResponse } from '../../../credits/context/response'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype EnrichedItem = ConsumeCreditsItem & {\n alpcData: ConsumeCreditRuleResponse\n insufficient: boolean\n soldOut: boolean\n product?: any\n variant?: any\n}\n\ntype Props = {\n copy: ConsumeCreditsopy\n onClose: () => void\n}\n\nfunction ConsumeCredits({ copy, onClose }: Props) {\n const { profile, creditInfo, openSignUpPopup, alpcConfig } = useMemberPopupContext()\n const { pushView } = useViewStack()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const [redeemAndBuyError, setRedeemAndBuyError] = useState('')\n const [loadingId, setLoadingId] = useState<string | number | null>(null)\n\n const isLogin = !!profile\n const { redeemableList, listLoading } = useRedeemableList(alpcConfig)\n const { trigger: redeemAndBuy } = useRedeemAndBuy(alpcConfig)\n\n const handles = copy.list.map(item => item.product?.handle).filter(Boolean) as string[]\n const { data: products } = useProductsByHandles({ handles })\n\n const list = useMemo(() => {\n return copy.list\n .map(item => {\n const alpcData = redeemableList.find(r => String(r.id) === String(item.redeemId))\n if (!alpcData) return null\n\n const availableCredit = Number(creditInfo?.available_credit ?? 0)\n const insufficient = isLogin && !!profile?.activated && alpcData.consume_credits > availableCredit\n const soldOut = alpcData.is_limited && (!alpcData.remaining_inventory || alpcData.remaining_inventory <= 0)\n\n let product\n let variant\n if (\n (item.type === ConsumeCreditsItemType.RedeemAndBuy ||\n item.type === ConsumeCreditsItemType.Product) &&\n item.product\n ) {\n product = products?.find((p: any) => p.handle === item.product!.handle)\n variant = product?.variants?.find((v: any) => v.sku === item.product!.sku) ?? product?.variants?.[0]\n if (item.type === ConsumeCreditsItemType.RedeemAndBuy && (!product || !variant)) return null\n }\n\n return { ...item, alpcData, insufficient, soldOut, product, variant }\n })\n .filter(Boolean) as EnrichedItem[]\n }, [copy.list, redeemableList, creditInfo, profile, isLogin, products])\n\n function getButtonLabel(item: (typeof list)[number]) {\n if (!isLogin) return copy.unlockRewards\n if (item.soldOut) return copy.soldOut\n return copy.btnRedeem\n }\n\n function isDisabled(item: (typeof list)[number]) {\n if (\n item.type === ConsumeCreditsItemType.GiftCard ||\n item.type === ConsumeCreditsItemType.Product\n ) {\n return item.insufficient\n }\n return item.soldOut || item.insufficient\n }\n\n async function handleRedeem(item: (typeof list)[number]) {\n if (!isLogin) {\n openSignUpPopup()\n return\n }\n if (!profile?.activated) {\n pushView({ type: MemberPopupPanelType.Activate })\n return\n }\n if (\n item.type === ConsumeCreditsItemType.GiftCard ||\n item.type === ConsumeCreditsItemType.Product\n ) {\n if (copy.creditsPage?.url) {\n window.open(copy.creditsPage.url, '_blank', 'noopener,noreferrer')\n }\n return\n }\n if (item.type === ConsumeCreditsItemType.Coupon) {\n pushView({\n type: MemberPopupPanelType.RedeemCoupon,\n props: {\n itemTitle: item.title,\n itemCredits: item.alpcData.consume_credits,\n itemImage: copy.imageMapping?.[item.type]\n ? { url: copy.imageMapping[item.type]!.url, alt: item.image?.alt }\n : item.image,\n itemValue: item.value,\n itemOff: copy.off,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n alpcConfig,\n },\n })\n } else {\n setRedeemAndBuyError('')\n setLoadingId(item.redeemId)\n try {\n await redeemAndBuy({\n productVariant: item.variant,\n redeemId: Number(item.redeemId),\n userId: profile?.user_id,\n })\n } catch (e: any) {\n setRedeemAndBuyError(e?.message ?? copy.redeemModal.commonError)\n } finally {\n setLoadingId(null)\n }\n }\n }\n\n return (\n <>\n <div className=\"flex flex-1 flex-col gap-[12px]\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>}\n {copy.subtitle && <p className=\"text-[16px] font-[700] leading-snug text-[#4a4c56]\">{copy.subtitle}</p>}\n </div>\n\n {copy.insufficientCredits && creditInfo && (\n <div className=\"text-[14px] font-[700] text-[#1d1d1f]\">\n {copy.insufficientCredits}: {numberFormat(creditInfo.available_credit)} {copy.pointUnit}\n </div>\n )}\n {redeemAndBuyError && <div className=\"text-[14px] font-[700] text-[#f84d4f]\">{redeemAndBuyError}</div>}\n\n {listLoading ? (\n <div className=\"flex flex-1 items-center justify-center py-[32px]\">\n <div className=\"size-[32px] animate-spin rounded-full border-[3px] border-[#080a0f] border-t-transparent\" />\n </div>\n ) : (\n <div className=\"flex flex-col\">\n {list.map((item, idx) => {\n const hasProduct = !!item.product\n return (\n <div key={idx} className=\"relative py-[16px]\">\n {idx > 0 && <div className=\"absolute inset-x-0 top-0 h-px bg-[#dadce0]\" />}\n <div className=\"flex items-center gap-[12px]\">\n {(() => {\n const mappedImgUrl = copy.imageMapping?.[item.type]?.url\n const imgUrl = hasProduct\n ? (item.variant?.image?.url ?? item.product?.images?.[0]?.url ?? item.image?.url)\n : (mappedImgUrl ?? item.image?.url)\n const imgAlt = hasProduct\n ? (item.variant?.image?.altText ?? item.product?.images?.[0]?.alt ?? item.image?.alt ?? '')\n : (item.image?.alt ?? '')\n if (!imgUrl) return null\n return (\n <div className={cn('relative size-[64px] shrink-0 overflow-hidden', rounded ? 'rounded-[4px]' : 'rounded-none')}>\n <Picture\n source={imgUrl}\n alt={imgAlt}\n className=\"flex size-full items-center justify-center\"\n imgClassName={hasProduct ? 'object-cover' : 'h-full w-auto object-contain'}\n />\n {!hasProduct && item.value && (\n <div className=\"absolute bottom-[20px] left-[4px] text-[14px] font-[800] leading-none text-white\">\n {item.value} {copy.off}\n </div>\n )}\n </div>\n )\n })()}\n <div className=\"min-w-0 flex-1\">\n <div className=\"text-[16px] font-[700] text-[#1e2024] line-clamp-2\">\n {hasProduct && item.product?.title\n ? item.product.title\n : item.title}\n </div>\n <div className=\"mt-[4px] text-[14px] text-[#666]\">\n {hasProduct && item.price != null\n ? `${numberFormat(item.alpcData.consume_credits)} ${copy.pointUnit ?? ''} + $${Number(item.price).toFixed(2)}`\n : `${numberFormat(item.alpcData.consume_credits)} ${copy.pointUnit ?? ''}`}\n </div>\n </div>\n <div className=\"relative group\">\n <Button\n className={cn('bg-[#080a0f] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white', rounded ? 'rounded-[4px]' : 'rounded-none')}\n disabled={isDisabled(item)}\n loading={loadingId === item.redeemId}\n onClick={() => handleRedeem(item)}\n >\n {getButtonLabel(item)}\n </Button>\n {item.insufficient && (\n <div className=\"pointer-events-none absolute right-0 top-full z-[100] mt-[10px] hidden w-[200px] group-hover:block\">\n <div className=\"relative bg-[#6D6D6F] p-[16px] text-[14px] font-[700] text-white shadow\">\n <p className=\"text-pretty tracking-[-0.02em] text-[14px]\">{copy.insufficientCredits}</p>\n <div className=\"absolute -top-[8px] right-[20px] size-[16px] origin-top-left rotate-45 rounded-[2px] bg-[#6D6D6F]\" />\n </div>\n </div>\n )}\n </div>\n </div>\n </div>\n )\n })}\n </div>\n )}\n\n {copy.creditsPage?.url && (\n <a\n href={copy.creditsPage.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"mt-auto self-start text-[14px] font-[700] text-[#080a0f] underline\"\n >\n {copy.creditsPage.label ?? 'Go to Credits Page'}\n </a>\n )}\n </div>\n </>\n )\n}\n\nexport default ConsumeCredits\n"],
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,EAAC,OAAI,UAAU,iBACb,UAAAD,EAACK,EAAA,CACC,UAAWC,EAAG,6FAA8FoB,EAAU,gBAAkB,cAAc,EACtJ,SAAUuB,EAAWb,CAAI,EACzB,QAASP,IAAcO,EAAK,SAC5B,QAAS,IAAMc,EAAad,CAAI,EAE/B,SAAAY,EAAeZ,CAAI,EACtB,EACCA,EAAK,cACJpC,EAAC,OAAI,UAAU,qGACb,SAAAC,EAAC,OAAI,UAAU,0EACb,UAAAD,EAAC,KAAE,UAAU,6CAA8C,SAAAkB,EAAK,oBAAoB,EACpFlB,EAAC,OAAI,UAAU,oGAAoG,GACrH,EACF,GAEJ,GACF,IA1DQoD,CA2DV,CAEF,CAAC,EACH,EAGClC,EAAK,aAAa,KACjBlB,EAAC,KACC,KAAMkB,EAAK,YAAY,IACvB,OAAO,SACP,IAAI,sBACJ,UAAU,qEAET,SAAAA,EAAK,YAAY,OAAS,qBAC7B,GAEJ,EACF,CAEJ,CAEA,IAAOuC,GAAQxC",
6
+ "names": ["Fragment", "jsx", "jsxs", "useMemo", "useState", "Picture", "Button", "cn", "useProductsByHandles", "useHeadlessContext", "useMemberPopupContext", "useViewStack", "useRedeemableList", "useRedeemAndBuy", "ConsumeCreditsItemType", "MemberPopupPanelType", "numberFormat", "ROUNDED_BRANDS", "ConsumeCredits", "copy", "onClose", "profile", "creditInfo", "openSignUpPopup", "alpcConfig", "pushView", "brand", "rounded", "redeemAndBuyError", "setRedeemAndBuyError", "loadingId", "setLoadingId", "isLogin", "redeemableList", "listLoading", "redeemAndBuy", "handles", "item", "products", "list", "alpcData", "r", "availableCredit", "insufficient", "soldOut", "product", "variant", "p", "v", "getButtonLabel", "isDisabled", "handleRedeem", "e", "idx", "hasProduct", "mappedImgUrl", "imgUrl", "imgAlt", "ConsumeCredits_default"]
7
7
  }
@@ -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 {};
@@ -0,0 +1,2 @@
1
+ import{Fragment as X,jsx as t,jsxs as o}from"react/jsx-runtime";import{useCallback as A,useEffect as D,useState as i}from"react";import{Button as R,Checkbox as O,Picture as U,Text as u}from"@anker-in/headless-ui";import{classNames as f,useHeadlessContext as j}from"@anker-in/lib";import m from"js-cookie";import{parse as E}from"query-string";import{emailValidate as F}from"../../../credits/context/utils";import{useMemberPopupContext as H}from"../../context/provider";import{ROUNDED_BRANDS as I}from"../../../../constants";function q(){if(typeof window>"u")return{register_source:""};const{search:s,href:l}=window.location,e=E(s);return{fbuy_ref_code:m.get("fbuy_ref_code"),ref:m.get("ref_ads"),inviter_code:e.ic??e.inviter_code??m.get("inviter_code"),register_source:e.redirect??m.get("reg_source")??l}}async function J(s){if(typeof window>"u"||!window?.grecaptcha?.execute||!s)return"";try{return await window.grecaptcha.execute(s,{action:"activity"})}catch{return""}}function V({onClose:s,onSuccess:l,copy:e,email:d,hideForm:N,onHideForm:g}){const{alpcConfig:M}=H(),{locale:b}=M,{brand:S,storeDomain:h,recaptchaSitekey:k}=j(),c=I.includes(S),[p,T]=i(!1),[a,v]=i(d??""),[x,r]=i(""),[y,_]=i(""),[L,w]=i(!1);D(()=>{d&&v(d)},[d]);const P=A(async()=>{if(r(""),!a)return r("Please fill in your email");if(!F(a))return r("Invalid email address");if(!p)return r("Please agree to the policy");w(!0);const{register_source:n}=q(),B=await J(k||"");try{const C=await(await fetch("/api/multipass/rainbowbridge/activities",{method:"POST",headers:{"Content-Type":"application/json","current-language":b,"X-Recaptcha-Token":B},body:JSON.stringify({email:a,register_source:n,shopify_domain:h,single_brand_subscribe:e.single_brand_subscribe??!0,genre:e.genre??e.dealsType??"",sub_brand_type:e.sub_brand_type??""})})).json();C.errors?r(C.errors??"Error occurred"):(_(e.successTips??"Subscribed successfully!"),l?.(),setTimeout(()=>{g(),_("")},3e3))}catch{r("Network error")}finally{w(!1)}},[a,p,b,h,e,l,g]);return o("div",{className:"flex flex-col gap-[16px] text-center",children:[!N&&o(X,{children:[t(u,{className:"text-[22px] font-bold",html:e.title}),e.desc&&t(u,{className:"text-left text-[16px] font-semibold text-[#1f2021]",html:e.desc}),o("div",{className:f("flex h-[52px] w-full overflow-hidden md:flex-col md:h-auto md:gap-[16px]",c?"rounded-[2px]":"rounded-none"),children:[t("input",{className:f("h-[46px] w-full border px-[14px] text-[16px] outline-none placeholder:text-[#999]",x?"border-[#f84d4f]":"border-[#d8d8d8]",c?"rounded-[4px]":"rounded-none"),placeholder:e.placeholder,value:a,onChange:n=>{r(""),v(n.target.value.trim())}}),t(R,{variant:"primary",loading:L,className:f("!h-full !min-w-0 !px-[24px] md:!h-[46px]",c?"!rounded-l-none !rounded-r-[2px] md:!rounded-[2px]":"!rounded-none"),onClick:P,children:e.buttonLabel??"Subscribe"})]}),o("div",{className:"flex w-full items-start gap-[8px]",children:[t(O,{checked:p,onCheckedChange:()=>T(n=>!n),className:"border-[#1d1d1f]"}),t("label",{className:"text-left text-[14px] font-semibold text-[#777] [&_a]:underline",dangerouslySetInnerHTML:{__html:e.policy??""}})]}),x&&t("div",{className:"text-left text-[16px] font-semibold text-[#f84d4f]",children:t(u,{html:x})}),t("div",{className:"text-left text-[16px] font-semibold text-[#52c41a]",children:t(u,{html:y})})]}),e.promo&&o("div",{className:"flex flex-col text-left",children:[o("div",{className:"flex flex-col gap-[8px]",children:[e.promo?.title&&t("h3",{className:"text-[20px] font-[700] leading-[1.2] text-[#080a0f]",children:e.promo?.title}),e.promo.description&&t("p",{className:"text-[14px] leading-[1.5] text-[#1e2024]",children:e.promo.description}),e.promo.learnMoreLabel&&e.promo.learnMoreUrl&&o("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,t("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:t("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&&t(U,{source:e.promo.image.url,alt:e.promo.image.alt??"",className:f("h-[100px] mt-[8px] w-full object-cover",c?"rounded-[8px]":"rounded-none")})]})]})}export{V as default};
2
+ //# sourceMappingURL=ActivitiesSubscribePanel.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../src/components/memberPopup/panels/EarnCredits/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 { CreditsModalContainer } from '../../../credits/modal/ModalContainer'\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 onClose: () => void\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({ onClose, onSuccess, copy, email: initialEmail, hideForm, onHideForm }: 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 <div\n className={cn(\n 'flex h-[52px] w-full overflow-hidden md:flex-col md:h-auto md:gap-[16px]',\n rounded ? 'rounded-[2px]' : 'rounded-none'\n )}\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 <Button\n variant=\"primary\"\n loading={loading}\n className={cn(\n '!h-full !min-w-0 !px-[24px] md:!h-[46px]',\n rounded ? '!rounded-l-none !rounded-r-[2px] md:!rounded-[2px]' : '!rounded-none'\n )}\n onClick={handleSubmit}\n >\n {copy.buttonLabel ?? 'Subscribe'}\n </Button>\n </div>\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 {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": "AAwGQ,mBAAAA,EACE,OAAAC,EAEA,QAAAC,MAHF,oBAxGR,OAAS,eAAAC,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QACjD,OAAS,UAAAC,EAAQ,YAAAC,EAAU,WAAAC,EAAS,QAAAC,MAAY,wBAChD,OAAS,cAAcC,EAAI,sBAAAC,MAA0B,gBACrD,OAAOC,MAAa,YACpB,OAAS,SAAAC,MAAa,eAEtB,OAAS,iBAAAC,MAAqB,iCAC9B,OAAS,yBAAAC,MAA6B,yBAEtC,OAAS,kBAAAC,MAAsB,wBAW/B,SAASC,GAAc,CACrB,GAAI,OAAO,OAAW,IAAa,MAAO,CAAE,gBAAiB,EAAG,EACh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IACzB,IAAKA,EAAK,MAAM,MAAM,KAAO,GAC7B,UAAWhB,EAAG,yCAA0CyB,EAAU,gBAAkB,cAAc,EACpG,GAEJ,GAEJ,CAEJ",
6
+ "names": ["Fragment", "jsx", "jsxs", "useCallback", "useEffect", "useState", "Button", "Checkbox", "Picture", "Text", "cn", "useHeadlessContext", "Cookies", "parse", "emailValidate", "useMemberPopupContext", "ROUNDED_BRANDS", "getAdCookie", "search", "href", "query", "getRecaptchaToken", "sitekey", "ActivitiesSubscribeModal", "onClose", "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", "e", "v"]
7
+ }
@@ -1,2 +1,2 @@
1
- import{jsx as t,jsxs as x}from"react/jsx-runtime";import{useCallback as B,useEffect as D,useState as d}from"react";import{Button as R,Checkbox as A,Text as f}from"@anker-in/headless-ui";import{classNames as c,useHeadlessContext as E}from"@anker-in/lib";import u from"js-cookie";import{parse as L}from"query-string";import{CreditsModalContainer as H}from"../../../credits/modal/ModalContainer";import{emailValidate as I}from"../../../credits/context/utils";import{useMemberPopupContext as j}from"../../context/provider";import{ROUNDED_BRANDS as q}from"../../../../constants";function J(){if(typeof window>"u")return{register_source:""};const{search:o,href:n}=window.location,s=L(o);return{fbuy_ref_code:u.get("fbuy_ref_code"),ref:u.get("ref_ads"),inviter_code:s.ic??s.inviter_code??u.get("inviter_code"),register_source:s.redirect??u.get("reg_source")??n}}async function U(o){if(typeof window>"u"||!window?.grecaptcha?.execute||!o)return"";try{return await window.grecaptcha.execute(o,{action:"activity"})}catch{return""}}function $({isOpen:o,onClose:n,onSuccess:s,copy:e,email:l}){const{alpcConfig:N}=j(),{locale:b}=N,{brand:S,storeDomain:g,recaptchaSitekey:k}=E(),m=q.includes(S),[p,M]=d(!1),[a,h]=d(l??""),[_,r]=d(""),[y,v]=d(""),[T,w]=d(!1);D(()=>{l&&h(l)},[l]);const P=B(async()=>{if(r(""),!a)return r("Please fill in your email");if(!I(a))return r("Invalid email address");if(!p)return r("Please agree to the policy");w(!0);const{register_source:i}=J(),O=await U(k||"");try{const C=await(await fetch("/api/multipass/rainbowbridge/activities",{method:"POST",headers:{"Content-Type":"application/json","current-language":b,"X-Recaptcha-Token":O},body:JSON.stringify({email:a,register_source:i,shopify_domain:g,single_brand_subscribe:e.single_brand_subscribe??!0,genre:e.genre??e.dealsType??"",sub_brand_type:e.sub_brand_type??""})})).json();C.errors?r(C.errors??"Error occurred"):(v(e.successTips??"Subscribed successfully!"),s?.(),setTimeout(()=>{v(""),n()},3e3))}catch{r("Network error")}finally{w(!1)}},[a,p,b,g,e,s,n]);return t(H,{isOpen:o,onClose:n,className:"w-[540px] md:h-auto",scrollClassName:"mb-[40px] md:mb-[24px]",useAnimation:!0,animationClassName:"md:translate-y-[100vh]",children:x("div",{className:"flex flex-col gap-[16px] text-center",children:[t(f,{className:"text-[22px] font-bold",html:e.title}),e.desc&&t(f,{className:"text-left text-[16px] font-semibold text-[#1f2021]",html:e.desc}),x("div",{className:c("flex h-[52px] w-full overflow-hidden md:flex-col md:h-auto md:gap-[16px]",m?"rounded-[2px]":"rounded-none"),children:[t("input",{className:c("h-full flex-1 border border-[#d8d8d8] px-[14px] text-[16px] outline-none placeholder:text-[#999] md:h-[52px]",m?"rounded-l-[2px] md:rounded-[2px]":"rounded-none"),placeholder:e.placeholder,value:a,onChange:i=>{r(""),h(i.target.value.trim())}}),t(R,{variant:"primary",loading:T,className:c("!h-full !min-w-0 !px-[24px] md:!h-[46px]",m?"!rounded-l-none !rounded-r-[2px] md:!rounded-[2px]":"!rounded-none"),onClick:P,children:e.buttonLabel??"Subscribe"})]}),x("div",{className:"flex w-full items-start gap-[8px]",children:[t(A,{checked:p,onCheckedChange:()=>M(i=>!i),className:"border-[#1d1d1f]"}),t("label",{className:"text-left text-[14px] font-semibold text-[#777] [&_a]:underline",dangerouslySetInnerHTML:{__html:e.policy??""}})]}),t("div",{className:c("text-left text-[16px] font-semibold",_&&"text-[#f84d4f]",y&&"text-[#52c41a]"),children:t(f,{html:y||_||""})})]})})}export{$ as EarnCreditsSubscribeModal};
1
+ import{jsx as t,jsxs as a}from"react/jsx-runtime";import{useCallback as B,useEffect as O,useState as d}from"react";import{Button as D,Checkbox as R,Text as x}from"@anker-in/headless-ui";import{classNames as m,useHeadlessContext as j}from"@anker-in/lib";import p from"js-cookie";import{parse as A}from"query-string";import{CreditsModalContainer as E}from"../../../credits/modal/ModalContainer";import{emailValidate as H}from"../../../credits/context/utils";import{useMemberPopupContext as I}from"../../context/provider";import{ROUNDED_BRANDS as U}from"../../../../constants";function q(){if(typeof window>"u")return{register_source:""};const{search:o,href:n}=window.location,s=A(o);return{fbuy_ref_code:p.get("fbuy_ref_code"),ref:p.get("ref_ads"),inviter_code:s.ic??s.inviter_code??p.get("inviter_code"),register_source:s.redirect??p.get("reg_source")??n}}async function J(o){if(typeof window>"u"||!window?.grecaptcha?.execute||!o)return"";try{return await window.grecaptcha.execute(o,{action:"activity"})}catch{return""}}function $({isOpen:o,onClose:n,onSuccess:s,copy:e,email:c}){const{alpcConfig:k}=I(),{locale:g}=k,{brand:M,storeDomain:b,recaptchaSitekey:S}=j(),u=U.includes(M),[f,y]=d(!1),[i,h]=d(c??""),[v,r]=d(""),[w,_]=d(""),[T,N]=d(!1);O(()=>{c&&h(c)},[c]),console.log("copy",e);const L=B(async()=>{if(r(""),!i)return r("Please fill in your email");if(!H(i))return r("Invalid email address");if(!f)return r("Please agree to the policy");N(!0);const{register_source:l}=q(),P=await J(S||"");try{const C=await(await fetch("/api/multipass/rainbowbridge/activities",{method:"POST",headers:{"Content-Type":"application/json","current-language":g,"X-Recaptcha-Token":P},body:JSON.stringify({email:i,register_source:l,shopify_domain:b,single_brand_subscribe:e.single_brand_subscribe??!0,genre:e.genre??e.dealsType??"",sub_brand_type:e.sub_brand_type??""})})).json();C.errors?r(C.errors??"Error occurred"):(_(e.successTips??"Subscribed successfully!"),s?.(),setTimeout(()=>{_(""),n()},3e3))}catch{r("Network error")}finally{N(!1)}},[i,f,g,b,e,s,n]);return t(E,{isOpen:o,onClose:n,className:"w-[540px] md:h-auto",scrollClassName:"mb-[40px] md:mb-[24px]",useAnimation:!0,animationClassName:"md:translate-y-[100vh]",children:a("div",{className:"flex flex-col gap-[16px] text-center",children:[t(x,{className:"text-[22px] font-bold",html:e.title}),e.desc&&t(x,{className:"text-left text-[16px] font-semibold text-[#1f2021]",html:e.desc}),a("div",{className:m("flex h-[52px] w-full overflow-hidden md:flex-col md:h-auto md:gap-[16px]",u?"rounded-[2px]":"rounded-none"),children:[t("input",{className:m("h-full flex-1 border border-[#d8d8d8] px-[14px] text-[16px] outline-none placeholder:text-[#999] md:h-[52px]",u?"rounded-l-[2px] md:rounded-[2px]":"rounded-none"),placeholder:e.placeholder,value:i,onChange:l=>{r(""),h(l.target.value.trim())}}),t(D,{variant:"primary",loading:T,className:m("!h-full !min-w-0 !px-[24px] md:!h-[46px]",u?"!rounded-l-none !rounded-r-[2px] md:!rounded-[2px]":"!rounded-none"),onClick:L,children:e.buttonLabel??"Subscribe"})]}),a("div",{className:"flex w-full items-start gap-[8px]",children:[t(R,{checked:f,onCheckedChange:()=>y(l=>!l),className:"border-[#1d1d1f]"}),t("label",{className:"text-left text-[14px] font-semibold text-[#777] [&_a]:underline",dangerouslySetInnerHTML:{__html:e.policy??""}})]}),e.promo&&t("div",{className:"border-t border-[#e5e5e5] pt-[16px]",children:a("div",{className:"flex items-center gap-[12px]",children:[a("div",{className:"flex flex-1 flex-col gap-[8px] text-left",children:[e.promo.title&&t("p",{className:"text-[14px] font-[700] text-[#080a0f]",children:e.promo.title}),e.promo.description&&t("p",{className:"text-[12px] font-[400] leading-[18px] text-[#666]",children:e.promo.description}),e.promo.learnMoreLabel&&a("a",{href:e.promo.learnMoreUrl??"#",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-[4px] text-[12px] font-[600] text-[#080a0f] underline-offset-2 hover:underline",children:[e.promo.learnMoreLabel,t("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t("path",{d:"M4.5 2.5L7.5 6L4.5 9.5",stroke:"#080a0f",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round"})})]})]}),e.promo.image?.url&&t("img",{src:e.promo.image.url,alt:e.promo.image.alt??"",className:"h-[80px] w-[100px] flex-shrink-0 rounded-[8px] object-cover"})]})}),t("div",{className:m("text-left text-[16px] font-semibold",v&&"text-[#f84d4f]",w&&"text-[#52c41a]"),children:t(x,{html:w||v||""})})]})})}export{$ as EarnCreditsSubscribeModal};
2
2
  //# sourceMappingURL=SubscribeModal.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/EarnCredits/SubscribeModal.tsx"],
4
- "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Button, Checkbox, 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 { CreditsModalContainer } from '../../../credits/modal/ModalContainer'\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 isOpen: boolean\n onClose: () => void\n onSuccess?: () => void\n copy: SubscribeModalCopy\n email?: string\n}\n\nfunction getAdCookie() {\n if (typeof window === 'undefined') return { register_source: '' }\n const { search, href } = window.location\n const query = parse(search)\n return {\n fbuy_ref_code: Cookies.get('fbuy_ref_code'),\n ref: Cookies.get('ref_ads'),\n inviter_code: query.ic ?? query.inviter_code ?? Cookies.get('inviter_code'),\n register_source: query.redirect ?? Cookies.get('reg_source') ?? href,\n }\n}\n\nasync function getRecaptchaToken(sitekey: string): Promise<string> {\n if (typeof window === 'undefined' || !window?.grecaptcha?.execute) return ''\n if (!sitekey) return ''\n try {\n return await window.grecaptcha.execute(sitekey, { action: 'activity' })\n } catch {\n return ''\n }\n}\n\nexport function EarnCreditsSubscribeModal({ isOpen, onClose, onSuccess, copy, email: initialEmail }: 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 setSuccessMessage('')\n onClose()\n }, 3000)\n } else {\n setErrorMessage(result.errors ?? 'Error occurred')\n }\n } catch {\n setErrorMessage('Network error')\n } finally {\n setLoading(false)\n }\n }, [email, policy, locale, storeDomain, copy, onSuccess, onClose])\n\n return (\n <CreditsModalContainer\n isOpen={isOpen}\n onClose={onClose}\n className=\"w-[540px] md:h-auto\"\n scrollClassName=\"mb-[40px] md:mb-[24px]\"\n useAnimation\n animationClassName=\"md:translate-y-[100vh]\"\n >\n <div className=\"flex flex-col gap-[16px] text-center\">\n <Text className=\"text-[22px] font-bold\" html={copy.title} />\n {copy.desc && (\n <Text className=\"text-left text-[16px] font-semibold text-[#1f2021]\" html={copy.desc} />\n )}\n <div className={cn('flex h-[52px] w-full overflow-hidden md:flex-col md:h-auto md:gap-[16px]', rounded ? 'rounded-[2px]' : 'rounded-none')}>\n <input\n className={cn('h-full flex-1 border border-[#d8d8d8] px-[14px] text-[16px] outline-none placeholder:text-[#999] md:h-[52px]', rounded ? 'rounded-l-[2px] md:rounded-[2px]' : 'rounded-none')}\n placeholder={copy.placeholder}\n value={email}\n onChange={e => { setErrorMessage(''); setEmail(e.target.value.trim()) }}\n />\n <Button\n variant=\"primary\"\n loading={loading}\n className={cn('!h-full !min-w-0 !px-[24px] md:!h-[46px]', rounded ? '!rounded-l-none !rounded-r-[2px] md:!rounded-[2px]' : '!rounded-none')}\n onClick={handleSubmit}\n >\n {copy.buttonLabel ?? 'Subscribe'}\n </Button>\n </div>\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 <div className={cn('text-left text-[16px] font-semibold', errorMessage && 'text-[#f84d4f]', successMessage && 'text-[#52c41a]')}>\n <Text html={successMessage || errorMessage || ''} />\n </div>\n </div>\n </CreditsModalContainer>\n )\n}\n"],
5
- "mappings": "AA8GQ,cAAAA,EAIA,QAAAC,MAJA,oBA9GR,OAAS,eAAAC,EAAa,aAAAC,EAAW,YAAAC,MAAgB,Q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QAASC,EACT,UAAU,sBACV,gBAAgB,yBAChB,aAAY,GACZ,mBAAmB,yBAEnB,SAAAvB,EAAC,OAAI,UAAU,uCACb,UAAAD,EAACO,EAAA,CAAK,UAAU,wBAAwB,KAAMmB,EAAK,MAAO,EACzDA,EAAK,MACJ1B,EAACO,EAAA,CAAK,UAAU,qDAAqD,KAAMmB,EAAK,KAAM,EAExFzB,EAAC,OAAI,UAAWO,EAAG,2EAA4EyB,EAAU,gBAAkB,cAAc,EACvI,UAAAjC,EAAC,SACC,UAAWQ,EAAG,+GAAgHyB,EAAU,mCAAqC,cAAc,EAC3L,YAAaP,EAAK,YAClB,MAAOU,EACP,SAAUY,GAAK,CAAET,EAAgB,EAAE,EAAGF,EAASW,EAAE,OAAO,MAAM,KAAK,CAAC,CAAE,EACxE,EACAhD,EAACK,EAAA,CACC,QAAQ,UACR,QAASqC,EACT,UAAWlC,EAAG,2CAA4CyB,EAAU,qDAAuD,eAAe,EAC1I,QAASW,EAER,SAAAlB,EAAK,aAAe,YACvB,GACF,EACAzB,EAAC,OAAI,UAAU,oCACb,UAAAD,EAACM,EAAA,CAAS,QAAS4B,EAAQ,gBAAiB,IAAMC,EAAUc,GAAK,CAACA,CAAC,EAAG,UAAU,mBAAmB,EACnGjD,EAAC,SACC,UAAU,kEACV,wBAAyB,CAAE,OAAQ0B,EAAK,QAAU,EAAG,EACvD,GACF,EACA1B,EAAC,OAAI,UAAWQ,EAAG,sCAAuC8B,GAAgB,iBAAkBE,GAAkB,gBAAgB,EAC5H,SAAAxC,EAACO,EAAA,CAAK,KAAMiC,GAAkBF,GAAgB,GAAI,EACpD,GACF,EACF,CAEJ",
4
+ "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Button, Checkbox, 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 { CreditsModalContainer } from '../../../credits/modal/ModalContainer'\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 isOpen: boolean\n onClose: () => void\n onSuccess?: () => void\n copy: SubscribeModalCopy\n email?: string\n}\n\nfunction getAdCookie() {\n if (typeof window === 'undefined') return { register_source: '' }\n const { search, href } = window.location\n const query = parse(search)\n return {\n fbuy_ref_code: Cookies.get('fbuy_ref_code'),\n ref: Cookies.get('ref_ads'),\n inviter_code: query.ic ?? query.inviter_code ?? Cookies.get('inviter_code'),\n register_source: query.redirect ?? Cookies.get('reg_source') ?? href,\n }\n}\n\nasync function getRecaptchaToken(sitekey: string): Promise<string> {\n if (typeof window === 'undefined' || !window?.grecaptcha?.execute) return ''\n if (!sitekey) return ''\n try {\n return await window.grecaptcha.execute(sitekey, { action: 'activity' })\n } catch {\n return ''\n }\n}\n\nexport function EarnCreditsSubscribeModal({ isOpen, onClose, onSuccess, copy, email: initialEmail }: 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 console.log('copy', copy)\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 setSuccessMessage('')\n onClose()\n }, 3000)\n } else {\n setErrorMessage(result.errors ?? 'Error occurred')\n }\n } catch {\n setErrorMessage('Network error')\n } finally {\n setLoading(false)\n }\n }, [email, policy, locale, storeDomain, copy, onSuccess, onClose])\n\n return (\n <CreditsModalContainer\n isOpen={isOpen}\n onClose={onClose}\n className=\"w-[540px] md:h-auto\"\n scrollClassName=\"mb-[40px] md:mb-[24px]\"\n useAnimation\n animationClassName=\"md:translate-y-[100vh]\"\n >\n <div className=\"flex flex-col gap-[16px] text-center\">\n <Text className=\"text-[22px] font-bold\" html={copy.title} />\n {copy.desc && <Text className=\"text-left text-[16px] font-semibold text-[#1f2021]\" html={copy.desc} />}\n <div\n className={cn(\n 'flex h-[52px] w-full overflow-hidden md:flex-col md:h-auto md:gap-[16px]',\n rounded ? 'rounded-[2px]' : 'rounded-none'\n )}\n >\n <input\n className={cn(\n 'h-full flex-1 border border-[#d8d8d8] px-[14px] text-[16px] outline-none placeholder:text-[#999] md:h-[52px]',\n rounded ? 'rounded-l-[2px] md:rounded-[2px]' : 'rounded-none'\n )}\n placeholder={copy.placeholder}\n value={email}\n onChange={e => {\n setErrorMessage('')\n setEmail(e.target.value.trim())\n }}\n />\n <Button\n variant=\"primary\"\n loading={loading}\n className={cn(\n '!h-full !min-w-0 !px-[24px] md:!h-[46px]',\n rounded ? '!rounded-l-none !rounded-r-[2px] md:!rounded-[2px]' : '!rounded-none'\n )}\n onClick={handleSubmit}\n >\n {copy.buttonLabel ?? 'Subscribe'}\n </Button>\n </div>\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 {copy.promo && (\n <div className=\"border-t border-[#e5e5e5] pt-[16px]\">\n <div className=\"flex items-center gap-[12px]\">\n <div className=\"flex flex-1 flex-col gap-[8px] text-left\">\n {copy.promo.title && <p className=\"text-[14px] font-[700] text-[#080a0f]\">{copy.promo.title}</p>}\n {copy.promo.description && (\n <p className=\"text-[12px] font-[400] leading-[18px] text-[#666]\">{copy.promo.description}</p>\n )}\n {copy.promo.learnMoreLabel && (\n <a\n href={copy.promo.learnMoreUrl ?? '#'}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"flex items-center gap-[4px] text-[12px] font-[600] text-[#080a0f] underline-offset-2 hover:underline\"\n >\n {copy.promo.learnMoreLabel}\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M4.5 2.5L7.5 6L4.5 9.5\"\n stroke=\"#080a0f\"\n strokeWidth=\"1.2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </a>\n )}\n </div>\n {copy.promo.image?.url && (\n <img\n src={copy.promo.image.url}\n alt={copy.promo.image.alt ?? ''}\n className=\"h-[80px] w-[100px] flex-shrink-0 rounded-[8px] object-cover\"\n />\n )}\n </div>\n </div>\n )}\n <div\n className={cn(\n 'text-left text-[16px] font-semibold',\n errorMessage && 'text-[#f84d4f]',\n successMessage && 'text-[#52c41a]'\n )}\n >\n <Text html={successMessage || errorMessage || ''} />\n </div>\n </div>\n </CreditsModalContainer>\n )\n}\n"],
5
+ "mappings": "AAgHQ,cAAAA,EAEA,QAAAC,MAFA,oBAhHR,OAAS,eAAAC,EAAa,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M,cAAgB,IACjC,OAAO,SACP,IAAI,sBACJ,UAAU,uGAET,UAAAA,EAAK,MAAM,eACZ1B,EAAC,OAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OAAO,MAAM,6BAChE,SAAAA,EAAC,QACC,EAAE,yBACF,OAAO,UACP,YAAY,MACZ,cAAc,QACd,eAAe,QACjB,EACF,GACF,GAEJ,EACC0B,EAAK,MAAM,OAAO,KACjB1B,EAAC,OACC,IAAK0B,EAAK,MAAM,MAAM,IACtB,IAAKA,EAAK,MAAM,MAAM,KAAO,GAC7B,UAAU,8DACZ,GAEJ,EACF,EAEF1B,EAAC,OACC,UAAWQ,EACT,sCACA8B,GAAgB,iBAChBE,GAAkB,gBACpB,EAEA,SAAAxC,EAACO,EAAA,CAAK,KAAMiC,GAAkBF,GAAgB,GAAI,EACpD,GACF,EACF,CAEJ",
6
6
  "names": ["jsx", "jsxs", "useCallback", "useEffect", "useState", "Button", "Checkbox", "Text", "cn", "useHeadlessContext", "Cookies", "parse", "CreditsModalContainer", "emailValidate", "useMemberPopupContext", "ROUNDED_BRANDS", "getAdCookie", "search", "href", "query", "getRecaptchaToken", "sitekey", "EarnCreditsSubscribeModal", "isOpen", "onClose", "onSuccess", "copy", "initialEmail", "alpcConfig", "locale", "headlessBrand", "storeDomain", "recaptchaSitekey", "rounded", "policy", "setPolicy", "email", "setEmail", "errorMessage", "setErrorMessage", "successMessage", "setSuccessMessage", "loading", "setLoading", "handleSubmit", "register_source", "recaptchaToken", "result", "e", "v"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as n}from"react/jsx-runtime";import{useMemo as b}from"react";import{classNames as c,useHeadlessContext as I}from"@anker-in/lib";import{useMemberPopupContext as B}from"../../context/provider";import{useViewStack as U}from"../../context/viewStack";import{useSubscribed as D}from"./hooks/useSubscribed";import{EarnCreditsTaskType as i,MemberPopupPanelType as v}from"../../type";import{IconBag as M,IconLock as R,IconSubscription as y,IconOrders as F}from"../../icons";import{numberFormat as S}from"../../../credits/context/utils";import{ROUNDED_BRANDS as O}from"../../../../constants";function V({id:t,className:a}){switch(t){case i.Activate:return e(R,{className:a});case i.Subscribe:return e(y,{className:a});case i.Shop:return e(M,{className:a});case i.CompleteProfile:return e(F,{className:a})}}function z({copy:t,onClose:a,isSubscribeSuccess:g=!1,isActivateSuccess:N=!1,isProfileCompleteSuccess:f=!1,onSubscribeSuccess:L,onActivateSuccess:w,onProfileCompleteSuccess:P}){const{profile:o,openSignUpPopup:d,alpcConfig:x,creditInfo:u}=B(),{pushView:p}=U(),{locale:E}=x,{brand:T}=I(),m=O.includes(T),l=!!o,h=D({userId:o?.user_id,brand:x.brand,email:o?.email,locale:E,apiBaseUrl:x.apiBaseUrl}),C=b(()=>f||!!(o?.first_name||o?.last_name)&&!!o?.phone_number&&!!o?.dob,[o,f]),k=b(()=>({[i.Activate]:{finished:!!o?.activated||N,onClick:l?()=>p({type:v.Activate,props:{onSuccess:w}}):d},[i.CompleteProfile]:{finished:C,onClick:l?()=>p({type:v.CompleteProfile,props:{onSuccess:P}}):d},[i.Subscribe]:{finished:h||g,onClick:l?()=>p({type:v.SubscribeEmail,props:{onSuccess:L}}):d},[i.Shop]:{finished:!1,link:t.goShopLink,onClick:l?void 0:d}}),[o,l,N,f,C,h,g,d,p,t.goShopLink]),_=b(()=>t.list.map(s=>{const r=k[s.id];if(!r)return null;const A=r.finished?t.completed:l?H(s.id,t):t.joinNow;return{...s,...r,buttonLabel:A}}).filter(Boolean),[t,k,l]);return n("div",{className:"flex flex-col gap-[16px]",children:[n("div",{className:"flex flex-col gap-[16px]",children:[e("div",{className:"flex flex-col gap-[8px]",children:t.title&&e("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:t.title})}),l&&u&&n("div",{className:c("flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]",m?"rounded-[8px]":"rounded-none"),children:[n("div",{className:"flex flex-1 flex-col gap-[4px]",children:[e("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:t.balanceLabel??"AnkerCredits Balance"}),n("div",{className:"flex items-end gap-[4px]",children:[e("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:S(u.available_credit)}),e("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:t.creditUnit??"ankercredits"})]})]}),e("div",{className:"h-full w-px bg-[#dadce0]"}),n("div",{className:"flex flex-1 flex-col gap-[4px]",children:[e("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:t.comingSoonLabel??"Coming Soon"}),n("div",{className:"flex items-end gap-[4px]",children:[e("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:S(u.pending_credit??0)}),e("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:t.creditUnit??"ankercredits"})]})]})]})]}),n("div",{className:"flex flex-col gap-[16px]",children:[t.subtitle&&e("p",{className:"text-[16px] font-[700] text-[#1e2024]",children:t.subtitle}),e("div",{className:"flex flex-col",children:_.map((s,r)=>n("div",{className:"relative py-[16px]",children:[r>0&&e("div",{className:"absolute left-0 right-0 top-0 h-px bg-[#dadce0]"}),n("div",{className:c("flex items-center gap-[12px]",s.finished&&"opacity-60"),children:[e(V,{id:s.id,className:"size-[24px] shrink-0"}),n("div",{className:"flex-1",children:[e("div",{className:"text-[16px] font-[700] text-[#1e2024]",children:s.title}),s.description&&e("div",{className:"mt-[4px] text-[14px] font-[700] text-[#4a4c56]",children:s.description})]}),!s.finished&&s.link?e("a",{href:s.link,target:"_blank",rel:"noopener noreferrer",className:c("cursor-pointer bg-[#080a0f] min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",m?"rounded-[4px]":"rounded-none"),children:s.buttonLabel}):e("button",{className:c("cursor-pointer min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",s.finished?"bg-[#767880]":"bg-[#080a0f]",m?"rounded-[4px]":"rounded-none"),disabled:s.finished,onClick:s.finished?void 0:s.onClick,children:s.buttonLabel})]})]},r))})]})]})}function H(t,a){switch(t){case i.Activate:return a.activate;case i.CompleteProfile:return a.completeProfileLabel;case i.Subscribe:return a.subscribeLabel;case i.Shop:return a.shopNow}}var Z=z;export{Z as default};
1
+ import{jsx as e,jsxs as n}from"react/jsx-runtime";import{useMemo as m}from"react";import{classNames as c,useHeadlessContext as A}from"@anker-in/lib";import{useMemberPopupContext as B}from"../../context/provider";import{useViewStack as U}from"../../context/viewStack";import{useSubscribed as D}from"./hooks/useSubscribed";import{EarnCreditsTaskType as i,MemberPopupPanelType as b}from"../../type";import{IconBag as M,IconLock as R,IconSubscription as y,IconOrders as F}from"../../icons";import{numberFormat as L}from"../../../credits/context/utils";import{ROUNDED_BRANDS as O}from"../../../../constants";function V({id:t,className:a}){switch(t){case i.Activate:return e(R,{className:a});case i.Subscribe:return e(y,{className:a});case i.Shop:return e(M,{className:a});case i.CompleteProfile:return e(F,{className:a})}}function z({copy:t,onClose:a,isSubscribeSuccess:v=!1,isActivateSuccess:g=!1,isProfileCompleteSuccess:f=!1,onSubscribeSuccess:w,onActivateSuccess:P,onProfileCompleteSuccess:E}){const{profile:o,openSignUpPopup:d,alpcConfig:N,creditInfo:x}=B(),{pushView:p}=U(),{locale:T}=N,{brand:h}=A(),u=O.includes(h);console.log("creditInfo",x);const l=!!o,C=D({userId:o?.user_id,brand:h,email:o?.email,locale:T,apiBaseUrl:N.apiBaseUrl}),k=m(()=>f||!!(o?.first_name||o?.last_name)&&!!o?.phone_number&&!!o?.dob,[o,f]),S=m(()=>({[i.Activate]:{finished:!!o?.activated||g,onClick:l?()=>p({type:b.Activate,props:{onSuccess:P}}):d},[i.CompleteProfile]:{finished:k,onClick:l?()=>p({type:b.CompleteProfile,props:{onSuccess:E}}):d},[i.Subscribe]:{finished:C||v,onClick:l?()=>p({type:b.SubscribeEmail,props:{onSuccess:w}}):d},[i.Shop]:{finished:!1,link:t.goShopLink,onClick:l?void 0:d}}),[o,l,g,f,k,C,v,d,p,t.goShopLink]),I=m(()=>t.list.map(s=>{const r=S[s.id];if(!r)return null;const _=r.finished?t.completed:l?H(s.id,t):t.joinNow;return{...s,...r,buttonLabel:_}}).filter(Boolean),[t,S,l]);return n("div",{className:"flex flex-col gap-[16px]",children:[n("div",{className:"flex flex-col gap-[16px]",children:[e("div",{className:"flex flex-col gap-[8px]",children:t.title&&e("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:t.title})}),l&&n("div",{className:c("flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]",u?"rounded-[8px]":"rounded-none"),children:[n("div",{className:"flex flex-1 flex-col gap-[4px]",children:[e("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:t.balanceLabel??"AnkerCredits Balance"}),n("div",{className:"flex items-end gap-[4px]",children:[e("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:L(x?.available_credit??0)}),e("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:t.creditUnit??"ankercredits"})]})]}),e("div",{className:"h-full w-px bg-[#dadce0]"}),n("div",{className:"flex flex-1 flex-col gap-[4px]",children:[e("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:t.comingSoonLabel??"Coming Soon"}),n("div",{className:"flex items-end gap-[4px]",children:[e("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:L(x?.pending_credit??0)}),e("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:t.creditUnit??"ankercredits"})]})]})]})]}),n("div",{className:"flex flex-col gap-[16px]",children:[t.subtitle&&e("p",{className:"text-[16px] font-[700] text-[#1e2024]",children:t.subtitle}),e("div",{className:"flex flex-col",children:I.map((s,r)=>n("div",{className:"relative py-[16px]",children:[r>0&&e("div",{className:"absolute left-0 right-0 top-0 h-px bg-[#dadce0]"}),n("div",{className:c("flex items-center gap-[12px]",s.finished&&"opacity-60"),children:[e(V,{id:s.id,className:"size-[24px] shrink-0"}),n("div",{className:"flex-1",children:[e("div",{className:"text-[16px] font-[700] text-[#1e2024]",children:s.title}),s.description&&e("div",{className:"mt-[4px] text-[14px] font-[700] text-[#4a4c56]",children:s.description})]}),!s.finished&&s.link?e("a",{href:s.link,target:"_blank",rel:"noopener noreferrer",className:c("cursor-pointer bg-[#080a0f] min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",u?"rounded-[4px]":"rounded-none"),children:s.buttonLabel}):e("button",{className:c("cursor-pointer min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",s.finished?"bg-[#767880]":"bg-[#080a0f]",u?"rounded-[4px]":"rounded-none"),disabled:s.finished,onClick:s.finished?void 0:s.onClick,children:s.buttonLabel})]})]},r))})]})]})}function H(t,a){switch(t){case i.Activate:return a.activate;case i.CompleteProfile:return a.completeProfileLabel;case i.Subscribe:return a.subscribeLabel;case i.Shop:return a.shopNow}}var Z=z;export{Z as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/EarnCredits/index.tsx"],
4
- "sourcesContent": ["import { useMemo } from 'react'\nimport { classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useSubscribed } from './hooks/useSubscribed'\nimport { EarnCreditsTaskType, MemberPopupPanelType, type EarnCreditsCopy } from '../../type'\nimport { IconBag, IconLock, IconSubscription, IconOrders } from '../../icons'\nimport { numberFormat } from '../../../credits/context/utils'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\nfunction TaskIcon({ id, className }: { id: EarnCreditsTaskType; className?: string }) {\n switch (id) {\n case EarnCreditsTaskType.Activate:\n return <IconLock className={className} />\n case EarnCreditsTaskType.Subscribe:\n return <IconSubscription className={className} />\n case EarnCreditsTaskType.Shop:\n return <IconBag className={className} />\n case EarnCreditsTaskType.CompleteProfile:\n return <IconOrders className={className} />\n }\n}\n\ntype Props = {\n copy: EarnCreditsCopy\n onClose: () => void\n isSubscribeSuccess?: boolean\n isActivateSuccess?: boolean\n isProfileCompleteSuccess?: boolean\n onSubscribeSuccess?: () => void\n onActivateSuccess?: () => void\n onProfileCompleteSuccess?: () => void\n}\n\nfunction EarnCredits({\n copy,\n onClose,\n isSubscribeSuccess = false,\n isActivateSuccess = false,\n isProfileCompleteSuccess = false,\n onSubscribeSuccess,\n onActivateSuccess,\n onProfileCompleteSuccess,\n}: Props) {\n const { profile, openSignUpPopup, alpcConfig, creditInfo } = useMemberPopupContext()\n const { pushView } = useViewStack()\n const { locale } = alpcConfig\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const isLogin = !!profile\n\n const isSubscribed = useSubscribed({\n userId: profile?.user_id,\n brand: alpcConfig.brand,\n email: profile?.email,\n locale,\n apiBaseUrl: alpcConfig.apiBaseUrl,\n })\n\n const profileCompleted = useMemo(() => {\n return isProfileCompleteSuccess || (!!(profile?.first_name || profile?.last_name) && !!profile?.phone_number && !!profile?.dob)\n }, [profile, isProfileCompleteSuccess])\n\n const taskStates: Record<EarnCreditsTaskType, { finished: boolean; onClick?: () => void; link?: string }> = useMemo(() => ({\n [EarnCreditsTaskType.Activate]: {\n finished: !!profile?.activated || isActivateSuccess,\n onClick: isLogin\n ? () => pushView({\n type: MemberPopupPanelType.Activate,\n props: { onSuccess: onActivateSuccess },\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.CompleteProfile]: {\n finished: profileCompleted,\n onClick: isLogin\n ? () => pushView({\n type: MemberPopupPanelType.CompleteProfile,\n props: { onSuccess: onProfileCompleteSuccess },\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.Subscribe]: {\n finished: isSubscribed || isSubscribeSuccess,\n onClick: isLogin\n ? () => pushView({\n type: MemberPopupPanelType.SubscribeEmail,\n props: { onSuccess: onSubscribeSuccess },\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.Shop]: {\n finished: false,\n link: copy.goShopLink,\n onClick: isLogin ? undefined : openSignUpPopup,\n },\n }), [profile, isLogin, isActivateSuccess, isProfileCompleteSuccess, profileCompleted, isSubscribed, isSubscribeSuccess, openSignUpPopup, pushView, copy.goShopLink])\n\n const list = useMemo(() => {\n return copy.list.map(item => {\n const state = taskStates[item.id]\n if (!state) return null\n const buttonLabel = state.finished\n ? copy.completed\n : isLogin\n ? getNotFinishedLabel(item.id, copy)\n : copy.joinNow\n return { ...item, ...state, buttonLabel }\n }).filter(Boolean) as (typeof copy.list[number] & {\n finished: boolean\n onClick?: () => void\n link?: string\n buttonLabel: string\n })[]\n }, [copy, taskStates, isLogin])\n\n return (\n <div className=\"flex flex-col gap-[16px]\">\n <div className=\"flex flex-col gap-[16px]\">\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 </div>\n\n {isLogin && creditInfo && (\n <div className={cn('flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">\n {copy.balanceLabel ?? 'AnkerCredits Balance'}\n </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)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n <div className=\"h-full w-px bg-[#dadce0]\" />\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">\n {copy.comingSoonLabel ?? 'Coming Soon'}\n </div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo.pending_credit ?? 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n </div>\n )}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n {copy.subtitle && (\n <p className=\"text-[16px] font-[700] text-[#1e2024]\">{copy.subtitle}</p>\n )}\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 left-0 right-0 top-0 h-px bg-[#dadce0]\" />}\n <div className={cn('flex items-center gap-[12px]', item.finished && 'opacity-60')}>\n <TaskIcon id={item.id} className=\"size-[24px] shrink-0\" />\n <div className=\"flex-1\">\n <div className=\"text-[16px] font-[700] text-[#1e2024]\">{item.title}</div>\n {item.description && (\n <div className=\"mt-[4px] text-[14px] font-[700] text-[#4a4c56]\">{item.description}</div>\n )}\n </div>\n {!item.finished && item.link ? (\n <a\n href={item.link}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={cn('cursor-pointer bg-[#080a0f] min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white', rounded ? 'rounded-[4px]' : 'rounded-none')}\n >\n {item.buttonLabel}\n </a>\n ) : (\n <button\n className={cn(\n 'cursor-pointer min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n item.finished ? 'bg-[#767880]' : 'bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={item.finished}\n onClick={!item.finished ? item.onClick : undefined}\n >\n {item.buttonLabel}\n </button>\n )}\n </div>\n </div>\n ))}\n </div>\n </div>\n </div>\n )\n}\n\nfunction getNotFinishedLabel(id: EarnCreditsTaskType, copy: EarnCreditsCopy): string {\n switch (id) {\n case EarnCreditsTaskType.Activate: return copy.activate\n case EarnCreditsTaskType.CompleteProfile: return copy.completeProfileLabel\n case EarnCreditsTaskType.Subscribe: return copy.subscribeLabel\n case EarnCreditsTaskType.Shop: return copy.shopNow\n }\n}\n\nexport default EarnCredits\n"],
5
- "mappings": "AAaa,cAAAA,EAqHC,QAAAC,MArHD,oBAbb,OAAS,WAAAC,MAAe,QACxB,OAAS,cAAcC,EAAI,sBAAAC,MAA0B,gBACrD,OAAS,yBAAAC,MAA6B,yBACtC,OAAS,gBAAAC,MAAoB,0BAC7B,OAAS,iBAAAC,MAAqB,wBAC9B,OAAS,uBAAAC,EAAqB,wBAAAC,MAAkD,aAChF,OAAS,WAAAC,EAAS,YAAAC,EAAU,oBAAAC,EAAkB,cAAAC,MAAkB,cAChE,OAAS,gBAAAC,MAAoB,iCAC7B,OAAS,kBAAAC,MAAsB,wBAE/B,SAASC,EAAS,CAAE,GAAAC,EAAI,UAAAC,CAAU,EAAoD,CACpF,OAAQD,EAAI,CACV,KAAKT,EAAoB,SACvB,OAAOR,EAACW,EAAA,CAAS,UAAWO,EAAW,EACzC,KAAKV,EAAoB,UACvB,OAAOR,EAACY,EAAA,CAAiB,UAAWM,EAAW,EACjD,KAAKV,EAAoB,KACvB,OAAOR,EAACU,EAAA,CAAQ,UAAWQ,EAAW,EACxC,KAAKV,EAAoB,gBACvB,OAAOR,EAACa,EAAA,CAAW,UAAWK,EAAW,CAC7C,CACF,CAaA,SAASC,EAAY,CACnB,KAAAC,EACA,QAAAC,EACA,mBAAAC,EAAqB,GACrB,kBAAAC,EAAoB,GACpB,yBAAAC,EAA2B,GAC3B,mBAAAC,EACA,kBAAAC,EACA,yBAAAC,CACF,EAAU,CACR,KAAM,CAAE,QAAAC,EAAS,gBAAAC,EAAiB,WAAAC,EAAY,WAAAC,CAAW,EAAI1B,EAAsB,EAC7E,CAAE,SAAA2B,CAAS,EAAI1B,EAAa,EAC5B,CAAE,OAAA2B,CAAO,EAAIH,EACb,CAAE,MAAAI,CAAM,EAAI9B,EAAmB,EAC/B+B,EAAUpB,EAAe,SAASmB,C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K7C,EAAC,OAAI,UAAU,kDAAkD,EAC7EC,EAAC,OAAI,UAAWE,EAAG,+BAAgCsC,EAAK,UAAY,YAAY,EAC9E,UAAAzC,EAACgB,EAAA,CAAS,GAAIyB,EAAK,GAAI,UAAU,uBAAuB,EACxDxC,EAAC,OAAI,UAAU,SACb,UAAAD,EAAC,OAAI,UAAU,wCAAyC,SAAAyC,EAAK,MAAM,EAClEA,EAAK,aACJzC,EAAC,OAAI,UAAU,iDAAkD,SAAAyC,EAAK,YAAY,GAEtF,EACC,CAACA,EAAK,UAAYA,EAAK,KACtBzC,EAAC,KACC,KAAMyC,EAAK,KACX,OAAO,SACP,IAAI,sBACJ,UAAWtC,EAAG,0HAA2HgC,EAAU,gBAAkB,cAAc,EAElL,SAAAM,EAAK,YACR,EAEAzC,EAAC,UACC,UAAWG,EACT,6GACAsC,EAAK,SAAW,eAAiB,eACjCN,EAAU,gBAAkB,cAC9B,EACA,SAAUM,EAAK,SACf,QAAUA,EAAK,SAA0B,OAAfA,EAAK,QAE9B,SAAAA,EAAK,YACR,GAEJ,IAhCQI,CAiCV,CACD,EACH,GACF,GACF,CAEJ,CAEA,SAASD,EAAoB3B,EAAyBG,EAA+B,CACnF,OAAQH,EAAI,CACV,KAAKT,EAAoB,SAAU,OAAOY,EAAK,SAC/C,KAAKZ,EAAoB,gBAAiB,OAAOY,EAAK,qBACtD,KAAKZ,EAAoB,UAAW,OAAOY,EAAK,eAChD,KAAKZ,EAAoB,KAAM,OAAOY,EAAK,OAC7C,CACF,CAEA,IAAO0B,EAAQ3B",
4
+ "sourcesContent": ["import { useMemo } from 'react'\nimport { classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useViewStack } from '../../context/viewStack'\nimport { useSubscribed } from './hooks/useSubscribed'\nimport { EarnCreditsTaskType, MemberPopupPanelType, type EarnCreditsCopy } from '../../type'\nimport { IconBag, IconLock, IconSubscription, IconOrders } from '../../icons'\nimport { numberFormat } from '../../../credits/context/utils'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\nfunction TaskIcon({ id, className }: { id: EarnCreditsTaskType; className?: string }) {\n switch (id) {\n case EarnCreditsTaskType.Activate:\n return <IconLock className={className} />\n case EarnCreditsTaskType.Subscribe:\n return <IconSubscription className={className} />\n case EarnCreditsTaskType.Shop:\n return <IconBag className={className} />\n case EarnCreditsTaskType.CompleteProfile:\n return <IconOrders className={className} />\n }\n}\n\ntype Props = {\n copy: EarnCreditsCopy\n onClose: () => void\n isSubscribeSuccess?: boolean\n isActivateSuccess?: boolean\n isProfileCompleteSuccess?: boolean\n onSubscribeSuccess?: () => void\n onActivateSuccess?: () => void\n onProfileCompleteSuccess?: () => void\n}\n\nfunction EarnCredits({\n copy,\n onClose,\n isSubscribeSuccess = false,\n isActivateSuccess = false,\n isProfileCompleteSuccess = false,\n onSubscribeSuccess,\n onActivateSuccess,\n onProfileCompleteSuccess,\n}: Props) {\n const { profile, openSignUpPopup, alpcConfig, creditInfo } = useMemberPopupContext()\n const { pushView } = useViewStack()\n const { locale } = alpcConfig\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n console.log('creditInfo', creditInfo)\n\n const isLogin = !!profile\n\n const isSubscribed = useSubscribed({\n userId: profile?.user_id,\n brand: brand,\n email: profile?.email,\n locale,\n apiBaseUrl: alpcConfig.apiBaseUrl,\n })\n\n const profileCompleted = useMemo(() => {\n return (\n isProfileCompleteSuccess ||\n (!!(profile?.first_name || profile?.last_name) && !!profile?.phone_number && !!profile?.dob)\n )\n }, [profile, isProfileCompleteSuccess])\n\n const taskStates: Record<EarnCreditsTaskType, { finished: boolean; onClick?: () => void; link?: string }> = useMemo(\n () => ({\n [EarnCreditsTaskType.Activate]: {\n finished: !!profile?.activated || isActivateSuccess,\n onClick: isLogin\n ? () =>\n pushView({\n type: MemberPopupPanelType.Activate,\n props: { onSuccess: onActivateSuccess },\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.CompleteProfile]: {\n finished: profileCompleted,\n onClick: isLogin\n ? () =>\n pushView({\n type: MemberPopupPanelType.CompleteProfile,\n props: { onSuccess: onProfileCompleteSuccess },\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.Subscribe]: {\n finished: isSubscribed || isSubscribeSuccess,\n onClick: isLogin\n ? () =>\n pushView({\n type: MemberPopupPanelType.SubscribeEmail,\n props: { onSuccess: onSubscribeSuccess },\n })\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.Shop]: {\n finished: false,\n link: copy.goShopLink,\n onClick: isLogin ? undefined : openSignUpPopup,\n },\n }),\n [\n profile,\n isLogin,\n isActivateSuccess,\n isProfileCompleteSuccess,\n profileCompleted,\n isSubscribed,\n isSubscribeSuccess,\n openSignUpPopup,\n pushView,\n copy.goShopLink,\n ]\n )\n\n const list = useMemo(() => {\n return copy.list\n .map(item => {\n const state = taskStates[item.id]\n if (!state) return null\n const buttonLabel = state.finished\n ? copy.completed\n : isLogin\n ? getNotFinishedLabel(item.id, copy)\n : copy.joinNow\n return { ...item, ...state, buttonLabel }\n })\n .filter(Boolean) as ((typeof copy.list)[number] & {\n finished: boolean\n onClick?: () => void\n link?: string\n buttonLabel: string\n })[]\n }, [copy, taskStates, isLogin])\n\n return (\n <div className=\"flex flex-col gap-[16px]\">\n <div className=\"flex flex-col gap-[16px]\">\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 </div>\n\n {isLogin && (\n <div\n className={cn(\n 'flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]',\n rounded ? 'rounded-[8px]' : 'rounded-none'\n )}\n >\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.balanceLabel ?? 'AnkerCredits Balance'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.available_credit ?? 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n <div className=\"h-full w-px bg-[#dadce0]\" />\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.comingSoonLabel ?? 'Coming Soon'}</div>\n <div className=\"flex items-end gap-[4px]\">\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {numberFormat(creditInfo?.pending_credit ?? 0)}\n </span>\n <span className=\"text-[14px] font-[700] leading-[1.4] text-[#1e2024]\">\n {copy.creditUnit ?? 'ankercredits'}\n </span>\n </div>\n </div>\n </div>\n )}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n {copy.subtitle && <p className=\"text-[16px] font-[700] text-[#1e2024]\">{copy.subtitle}</p>}\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 left-0 right-0 top-0 h-px bg-[#dadce0]\" />}\n <div className={cn('flex items-center gap-[12px]', item.finished && 'opacity-60')}>\n <TaskIcon id={item.id} className=\"size-[24px] shrink-0\" />\n <div className=\"flex-1\">\n <div className=\"text-[16px] font-[700] text-[#1e2024]\">{item.title}</div>\n {item.description && (\n <div className=\"mt-[4px] text-[14px] font-[700] text-[#4a4c56]\">{item.description}</div>\n )}\n </div>\n {!item.finished && item.link ? (\n <a\n href={item.link}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={cn(\n 'cursor-pointer bg-[#080a0f] min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n >\n {item.buttonLabel}\n </a>\n ) : (\n <button\n className={cn(\n 'cursor-pointer min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white',\n item.finished ? 'bg-[#767880]' : 'bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={item.finished}\n onClick={!item.finished ? item.onClick : undefined}\n >\n {item.buttonLabel}\n </button>\n )}\n </div>\n </div>\n ))}\n </div>\n </div>\n </div>\n )\n}\n\nfunction getNotFinishedLabel(id: EarnCreditsTaskType, copy: EarnCreditsCopy): string {\n switch (id) {\n case EarnCreditsTaskType.Activate:\n return copy.activate\n case EarnCreditsTaskType.CompleteProfile:\n return copy.completeProfileLabel\n case EarnCreditsTaskType.Subscribe:\n return copy.subscribeLabel\n case EarnCreditsTaskType.Shop:\n return copy.shopNow\n }\n}\n\nexport default EarnCredits\n"],
5
+ "mappings": "AAaa,cAAAA,EAgJC,QAAAC,MAhJD,oBAbb,OAAS,WAAAC,MAAe,QACxB,OAAS,cAAcC,EAAI,sBAAAC,MAA0B,gBACrD,OAAS,yBAAAC,MAA6B,yBACtC,OAAS,gBAAAC,MAAoB,0BAC7B,OAAS,iBAAAC,MAAqB,wBAC9B,OAAS,uBAAAC,EAAqB,wBAAAC,MAAkD,aAChF,OAAS,WAAAC,EAAS,YAAAC,EAAU,oBAAAC,EAAkB,cAAAC,MAAkB,cAChE,OAAS,gBAAAC,MAAoB,iCAC7B,OAAS,kBAAAC,MAAsB,wBAE/B,SAASC,EAAS,CAAE,GAAAC,EAAI,UAAAC,CAAU,EAAoD,CACpF,OAAQD,EAAI,CACV,KAAKT,EAAoB,SACvB,OAAOR,EAACW,EAAA,CAAS,UAAWO,EAAW,EACzC,KAAKV,EAAoB,UACvB,OAAOR,EAACY,EAAA,CAAiB,UAAWM,EAAW,EACjD,KAAKV,EAAoB,KACvB,OAAOR,EAACU,EAAA,CAAQ,UAAWQ,EAAW,EACxC,KAAKV,EAAoB,gBACvB,OAAOR,EAACa,EAAA,CAAW,UAAWK,EAAW,CAC7C,CACF,CAaA,SAASC,EAAY,CACnB,KAAAC,EACA,QAAAC,EACA,mBAAAC,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,EAAoB,KACvB,OAAOY,EAAK,OAChB,CACF,CAEA,IAAO0B,EAAQ3B",
6
6
  "names": ["jsx", "jsxs", "useMemo", "cn", "useHeadlessContext", "useMemberPopupContext", "useViewStack", "useSubscribed", "EarnCreditsTaskType", "MemberPopupPanelType", "IconBag", "IconLock", "IconSubscription", "IconOrders", "numberFormat", "ROUNDED_BRANDS", "TaskIcon", "id", "className", "EarnCredits", "copy", "onClose", "isSubscribeSuccess", "isActivateSuccess", "isProfileCompleteSuccess", "onSubscribeSuccess", "onActivateSuccess", "onProfileCompleteSuccess", "profile", "openSignUpPopup", "alpcConfig", "creditInfo", "pushView", "locale", "brand", "rounded", "isLogin", "isSubscribed", "profileCompleted", "taskStates", "list", "item", "state", "buttonLabel", "getNotFinishedLabel", "idx", "EarnCredits_default"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{jsx as a,jsxs as t}from"react/jsx-runtime";import{Picture as m}from"@anker-in/headless-ui";import{classNames as n,useHeadlessContext as g}from"@anker-in/lib";import{useMemberPopupContext as u}from"../../context/provider";import{useReferralOverview as h}from"./hooks/useReferralOverview";import{formatPrice as x}from"../../../credits/context/utils";import{ROUNDED_BRANDS as v}from"../../../../constants";function N({copy:e,onClose:b}){const{profile:f,alpcConfig:r}=u(),c=!!f,{brand:p,currencyCode:s="USD"}=g(),o=v.includes(p),{data:l}=h(),i=l?.data?.data?.available??0,d=l?.data?.data?.pending??0;return console.log("cashAvailable",i),console.log("cashPending",d),console.log("data",l),console.log("data.data",l?.data),t("div",{className:"flex flex-col gap-[12px]",children:[e.title&&a("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:e.title}),c&&t("div",{className:n("flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]",o?"rounded-[8px]":"rounded-none"),children:[t("div",{className:"flex flex-1 flex-col gap-[4px]",children:[a("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:e.cashAvailableLabel}),a("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:x({amount:i,currencyCode:s,locale:r.locale})})]}),a("div",{className:"h-full w-px self-stretch bg-[#dadce0]"}),t("div",{className:"flex flex-1 flex-col gap-[4px]",children:[a("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:e.cashPendingLabel}),a("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:x({amount:d,currencyCode:s,locale:r.locale})})]})]}),(e.howToTitle||e.howToDescription)&&t("div",{className:"flex flex-col gap-[8px]",children:[e.howToTitle&&a("h3",{className:"text-[20px] font-[700] leading-[1.2] text-[#080a0f]",children:e.howToTitle}),e.howToDescription&&a("p",{className:"text-[14px] leading-[1.5] text-[#1e2024]",children:e.howToDescription}),e.learnMoreLabel&&e.learnMoreUrl&&t("a",{href:e.learnMoreUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-[4px] text-[14px] font-[700] text-[#080a0f] underline",children:[e.learnMoreLabel,a("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:a("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.image?.url&&a(m,{source:e.image.url,alt:e.image.alt??"",className:n("h-[100px] w-full object-cover",o?"rounded-[8px]":"rounded-none")}),e.ctaButton&&a("a",{href:e.ctaUrl??"#",target:"_blank",rel:"noopener noreferrer",className:n("block w-full cursor-pointer bg-[#080a0f] py-[14px] text-center text-[14px] font-[700] text-white",o?"rounded-[4px]":"rounded-none"),children:e.ctaButton})]})}var M=N;export{M as default};
1
+ import{jsx as a,jsxs as t}from"react/jsx-runtime";import{Picture as m}from"@anker-in/headless-ui";import{classNames as n,useHeadlessContext as g}from"@anker-in/lib";import{useMemberPopupContext as u}from"../../context/provider";import{useReferralOverview as h}from"./hooks/useReferralOverview";import{formatPrice as x}from"../../../credits/context/utils";import{ROUNDED_BRANDS as v}from"../../../../constants";function N({copy:e,onClose:b}){const{profile:f,alpcConfig:r}=u(),c=!!f,{brand:p,currencyCode:s="USD"}=g(),o=v.includes(p),{data:l}=h(),i=l?.data?.data?.available??0,d=l?.data?.data?.pending??0;return console.log("cashAvailable",i),console.log("cashPending",d),console.log("data",l),console.log("data.data",l?.data),t("div",{className:"flex flex-col gap-[12px]",children:[e.title&&a("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:e.title}),c&&t("div",{className:n("flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]",o?"rounded-[8px]":"rounded-none"),children:[t("div",{className:"flex flex-1 flex-col gap-[4px]",children:[a("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:e.cashAvailableLabel}),a("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:x({amount:i,currencyCode:s,locale:r.locale})})]}),a("div",{className:"h-full w-px self-stretch bg-[#dadce0]"}),t("div",{className:"flex flex-1 flex-col gap-[4px]",children:[a("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:e.cashPendingLabel}),a("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:x({amount:d,currencyCode:s,locale:r.locale})})]})]}),(e.howToTitle||e.howToDescription)&&t("div",{className:"flex flex-col gap-[8px]",children:[e.howToTitle&&a("h3",{className:"text-[20px] font-[700] leading-[1.2] text-[#080a0f]",children:e.howToTitle}),e.howToDescription&&a("p",{className:"text-[14px] leading-[1.5] text-[#1e2024]",children:e.howToDescription}),e.learnMoreLabel&&e.learnMoreUrl&&t("a",{href:e.learnMoreUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-[4px] text-[14px] font-[700] text-[#080a0f] underline",children:[e.learnMoreLabel,a("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:a("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.image?.url&&a(m,{source:e.image.url,alt:e.image.alt??"",className:n("mt-[8px] h-[100px] w-full object-cover",o?"rounded-[8px]":"rounded-none")}),e.ctaButton&&a("a",{href:e.ctaUrl??"#",target:"_blank",rel:"noopener noreferrer",className:n("block w-full cursor-pointer bg-[#080a0f] py-[14px] text-center text-[14px] font-[700] text-white",o?"rounded-[4px]":"rounded-none"),children:e.ctaButton})]})}var M=N;export{M as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/Referral/index.tsx"],
4
- "sourcesContent": ["import { Picture } from '@anker-in/headless-ui'\nimport { classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useReferralOverview } from './hooks/useReferralOverview'\nimport { formatPrice } from '../../../credits/context/utils'\n\nimport type { ReferralCopy } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n copy: ReferralCopy\n onClose: () => void\n}\n\nfunction Referral({ copy, onClose }: Props) {\n const { profile, alpcConfig } = useMemberPopupContext()\n const isLogin = !!profile\n const { brand, currencyCode = 'USD' as string } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const { data } = useReferralOverview()\n\n const cashAvailable = data?.data?.data?.available ?? 0\n const cashPending = data?.data?.data?.pending ?? 0\n\n console.log('cashAvailable', cashAvailable)\n console.log('cashPending', cashPending)\n console.log('data', data)\n console.log('data.data', data?.data)\n\n return (\n <div className=\"flex flex-col gap-[12px]\">\n {copy.title && <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>}\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.cashAvailableLabel}</div>\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {formatPrice({ amount: cashAvailable, currencyCode, locale: alpcConfig.locale })}\n </span>\n </div>\n <div className=\"h-full w-px self-stretch bg-[#dadce0]\" />\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.cashPendingLabel}</div>\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {formatPrice({ amount: cashPending, currencyCode, locale: alpcConfig.locale })}\n </span>\n </div>\n </div>\n )}\n\n {(copy.howToTitle || copy.howToDescription) && (\n <div className=\"flex flex-col gap-[8px]\">\n {copy.howToTitle && (\n <h3 className=\"text-[20px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.howToTitle}</h3>\n )}\n {copy.howToDescription && <p className=\"text-[14px] leading-[1.5] text-[#1e2024]\">{copy.howToDescription}</p>}\n {copy.learnMoreLabel && copy.learnMoreUrl && (\n <a\n href={copy.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.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 )}\n\n {copy.image?.url && (\n <Picture\n source={copy.image.url}\n alt={copy.image.alt ?? ''}\n className={cn('h-[100px] w-full object-cover', rounded ? 'rounded-[8px]' : 'rounded-none')}\n />\n )}\n\n {copy.ctaButton && (\n <a\n href={copy.ctaUrl ?? '#'}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={cn(\n 'block w-full cursor-pointer bg-[#080a0f] py-[14px] text-center text-[14px] font-[700] text-white',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n >\n {copy.ctaButton}\n </a>\n )}\n </div>\n )\n}\n\nexport default Referral\n"],
5
- "mappings": "AAgCqB,cAAAA,EASX,QAAAC,MATW,oBAhCrB,OAAS,WAAAC,MAAe,wBACxB,OAAS,cAAcC,EAAI,sBAAAC,MAA0B,gBACrD,OAAS,yBAAAC,MAA6B,yBACtC,OAAS,uBAAAC,MAA2B,8BACpC,OAAS,eAAAC,MAAmB,iCAG5B,OAAS,kBAAAC,MAAsB,wBAO/B,SAASC,EAAS,CAAE,KAAAC,EAAM,QAAAC,CAAQ,EAAU,CAC1C,KAAM,CAAE,QAAAC,EAAS,WAAAC,CAAW,EAAIR,EAAsB,EAChDS,EAAU,CAAC,CAACF,EACZ,CAAE,MAAAG,EAAO,aAAAC,EAAe,KAAgB,EAAIZ,EAAmB,EAC/Da,EAAUT,EAAe,SAASO,CAAK,EAEvC,CAAE,KAAAG,CAAK,EAAIZ,EAAoB,EAE/Ba,EAAgBD,GAAM,MAAM,MAAM,WAAa,EAC/CE,EAAcF,GAAM,MAAM,MAAM,SAAW,EAEjD,eAAQ,IAAI,gBAAiBC,CAAa,EAC1C,QAAQ,IAAI,cAAeC,CAAW,EACtC,QAAQ,IAAI,OAAQF,CAAI,EACxB,QAAQ,IA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EAAK,WACJV,EAAC,KACC,KAAMU,EAAK,QAAU,IACrB,OAAO,SACP,IAAI,sBACJ,UAAWP,EACT,mGACAc,EAAU,gBAAkB,cAC9B,EAEC,SAAAP,EAAK,UACR,GAEJ,CAEJ,CAEA,IAAOW,EAAQZ",
4
+ "sourcesContent": ["import { Picture } from '@anker-in/headless-ui'\nimport { classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { useReferralOverview } from './hooks/useReferralOverview'\nimport { formatPrice } from '../../../credits/context/utils'\n\nimport type { ReferralCopy } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n copy: ReferralCopy\n onClose: () => void\n}\n\nfunction Referral({ copy, onClose }: Props) {\n const { profile, alpcConfig } = useMemberPopupContext()\n const isLogin = !!profile\n const { brand, currencyCode = 'USD' as string } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const { data } = useReferralOverview()\n\n const cashAvailable = data?.data?.data?.available ?? 0\n const cashPending = data?.data?.data?.pending ?? 0\n\n console.log('cashAvailable', cashAvailable)\n console.log('cashPending', cashPending)\n console.log('data', data)\n console.log('data.data', data?.data)\n\n return (\n <div className=\"flex flex-col gap-[12px]\">\n {copy.title && <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>}\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.cashAvailableLabel}</div>\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {formatPrice({ amount: cashAvailable, currencyCode, locale: alpcConfig.locale })}\n </span>\n </div>\n <div className=\"h-full w-px self-stretch bg-[#dadce0]\" />\n <div className=\"flex flex-1 flex-col gap-[4px]\">\n <div className=\"text-[14px] font-[700] text-[#1e2024]\">{copy.cashPendingLabel}</div>\n <span className=\"text-[24px] font-[700] leading-[1.2] text-[#1e2024]\">\n {formatPrice({ amount: cashPending, currencyCode, locale: alpcConfig.locale })}\n </span>\n </div>\n </div>\n )}\n\n {(copy.howToTitle || copy.howToDescription) && (\n <div className=\"flex flex-col gap-[8px]\">\n {copy.howToTitle && (\n <h3 className=\"text-[20px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.howToTitle}</h3>\n )}\n {copy.howToDescription && <p className=\"text-[14px] leading-[1.5] text-[#1e2024]\">{copy.howToDescription}</p>}\n {copy.learnMoreLabel && copy.learnMoreUrl && (\n <a\n href={copy.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.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 )}\n\n {copy.image?.url && (\n <Picture\n source={copy.image.url}\n alt={copy.image.alt ?? ''}\n className={cn('mt-[8px] h-[100px] w-full object-cover', rounded ? 'rounded-[8px]' : 'rounded-none')}\n />\n )}\n\n {copy.ctaButton && (\n <a\n href={copy.ctaUrl ?? '#'}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={cn(\n 'block w-full cursor-pointer bg-[#080a0f] py-[14px] text-center text-[14px] font-[700] text-white',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n >\n {copy.ctaButton}\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,UAAU,wCAAyC,SAAAU,EAAK,iBAAiB,EAC9EV,EAAC,QAAK,UAAU,sDACb,SAAAO,EAAY,CAAE,OAAQa,EAAa,aAAAJ,EAAc,OAAQH,EAAW,MAAO,CAAC,EAC/E,GACF,GACF,GAGAH,EAAK,YAAcA,EAAK,mBACxBT,EAAC,OAAI,UAAU,0BACZ,UAAAS,EAAK,YACJV,EAAC,MAAG,UAAU,sDAAuD,SAAAU,EAAK,WAAW,EAEtFA,EAAK,kBAAoBV,EAAC,KAAE,UAAU,2CAA4C,SAAAU,EAAK,iBAAiB,EACxGA,EAAK,gBAAkBA,EAAK,cAC3BT,EAAC,KACC,KAAMS,EAAK,aACX,OAAO,SACP,IAAI,sBACJ,UAAU,8EAET,UAAAA,EAAK,eACNV,EAAC,OAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OACnD,SAAAA,EAAC,QACC,EAAE,kUACF,KAAK,UACP,EACF,GACF,GAEJ,EAGDU,EAAK,OAAO,KACXV,EAACE,EAAA,CACC,OAAQQ,EAAK,MAAM,IACnB,IAAKA,EAAK,MAAM,KAAO,GACvB,UAAWP,EAAG,yCAA0Cc,EAAU,gBAAkB,cAAc,EACpG,EAGDP,EAAK,WACJV,EAAC,KACC,KAAMU,EAAK,QAAU,IACrB,OAAO,SACP,IAAI,sBACJ,UAAWP,EACT,mGACAc,EAAU,gBAAkB,cAC9B,EAEC,SAAAP,EAAK,UACR,GAEJ,CAEJ,CAEA,IAAOW,EAAQZ",
6
6
  "names": ["jsx", "jsxs", "Picture", "cn", "useHeadlessContext", "useMemberPopupContext", "useReferralOverview", "formatPrice", "ROUNDED_BRANDS", "Referral", "copy", "onClose", "profile", "alpcConfig", "isLogin", "brand", "currencyCode", "rounded", "data", "cashAvailable", "cashPending", "Referral_default"]
7
7
  }
@@ -27,7 +27,9 @@ export declare enum EarnCreditsTaskType {
27
27
  }
28
28
  export declare enum ConsumeCreditsItemType {
29
29
  Coupon = "COUPON",
30
- RedeemAndBuy = "REDEEM_AND_BUY"
30
+ RedeemAndBuy = "REDEEM_AND_BUY",
31
+ GiftCard = "GIFT_CARD",
32
+ Product = "PRODUCT"
31
33
  }
32
34
  export type MemberPopupLink = {
33
35
  type: MemberPopupActionType;
@@ -67,7 +69,7 @@ export type MemberPopupCopy = {
67
69
  shopLabel: string;
68
70
  shopUrl?: string;
69
71
  };
70
- subscribe?: SubscribeModalCopy;
72
+ activitiesSubscribe?: SubscribeModalCopy;
71
73
  earnCredits?: EarnCreditsCopy;
72
74
  consumeCredits?: ConsumeCreditsopy;
73
75
  referral?: ReferralCopy;
@@ -122,6 +124,16 @@ export type SubscribeModalCopy = {
122
124
  single_brand_subscribe?: boolean;
123
125
  genre?: string;
124
126
  sub_brand_type?: string;
127
+ promo?: {
128
+ title?: string;
129
+ description?: string;
130
+ learnMoreLabel?: string;
131
+ learnMoreUrl?: string;
132
+ image?: {
133
+ url: string;
134
+ alt?: string;
135
+ };
136
+ };
125
137
  };
126
138
  export type ConsumeCreditsopy = {
127
139
  title?: string;
@@ -1,2 +1,2 @@
1
- var n=(t=>(t.EarnCredits="EARN_CREDITS",t.ConsumeCredits="CONSUME_CREDITS",t.Referral="REFERRAL",t.CompleteProfile="COMPLETE_PROFILE",t.Subscribe="SUBSCRIBE",t.SubscribeEmail="SUBSCRIBE_EMAIL",t.RedeemCoupon="REDEEM_COUPON",t.Activate="ACTIVATE",t))(n||{}),o=(i=>(i.ExternalLink="EXTERNAL_LINK",i.OpenEarnCredits="OPEN_EARN_CREDITS",i.OpenConsumeCredits="OPEN_CONSUME_CREDITS",i.OpenReferral="OPEN_REFERRAL",i.OpenSubscribe="OPEN_SUBSCRIBE",i))(o||{}),g=(e=>(e.Activate="activate",e.CompleteProfile="completeProfile",e.Subscribe="subscribe",e.Shop="shop",e))(g||{}),l=(s=>(s.Coupon="COUPON",s.RedeemAndBuy="REDEEM_AND_BUY",s))(l||{}),p=(r=>(r.Global="GLOBAL",r.Include="INCLUDE",r.Exclude="EXCLUDE",r))(p||{});export{l as ConsumeCreditsItemType,g as EarnCreditsTaskType,o as MemberPopupActionType,p as MemberPopupPageScope,n as MemberPopupPanelType};
1
+ var n=(i=>(i.EarnCredits="EARN_CREDITS",i.ConsumeCredits="CONSUME_CREDITS",i.Referral="REFERRAL",i.CompleteProfile="COMPLETE_PROFILE",i.Subscribe="SUBSCRIBE",i.SubscribeEmail="SUBSCRIBE_EMAIL",i.RedeemCoupon="REDEEM_COUPON",i.Activate="ACTIVATE",i))(n||{}),s=(r=>(r.ExternalLink="EXTERNAL_LINK",r.OpenEarnCredits="OPEN_EARN_CREDITS",r.OpenConsumeCredits="OPEN_CONSUME_CREDITS",r.OpenReferral="OPEN_REFERRAL",r.OpenSubscribe="OPEN_SUBSCRIBE",r))(s||{}),o=(t=>(t.Activate="activate",t.CompleteProfile="completeProfile",t.Subscribe="subscribe",t.Shop="shop",t))(o||{}),g=(t=>(t.Coupon="COUPON",t.RedeemAndBuy="REDEEM_AND_BUY",t.GiftCard="GIFT_CARD",t.Product="PRODUCT",t))(g||{}),l=(e=>(e.Global="GLOBAL",e.Include="INCLUDE",e.Exclude="EXCLUDE",e))(l||{});export{g as ConsumeCreditsItemType,o as EarnCreditsTaskType,s as MemberPopupActionType,l as MemberPopupPageScope,n as MemberPopupPanelType};
2
2
  //# sourceMappingURL=type.js.map