@anker-in/campaign-ui 0.5.0-beta.25 → 0.5.0-beta.27

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 (42) hide show
  1. package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.js +1 -1
  2. package/dist/cjs/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +2 -2
  3. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js +1 -1
  4. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js.map +2 -2
  5. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.js +1 -1
  6. package/dist/cjs/components/memberPopup/panels/ConsumeCredits/index.js.map +2 -2
  7. package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivatePanel.js +1 -1
  8. package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivatePanel.js.map +2 -2
  9. package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js +1 -1
  10. package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js.map +2 -2
  11. package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js +1 -1
  12. package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js.map +2 -2
  13. package/dist/cjs/components/memberPopup/panels/EarnCredits/index.js +1 -1
  14. package/dist/cjs/components/memberPopup/panels/EarnCredits/index.js.map +3 -3
  15. package/dist/cjs/components/memberPopup/panels/Referral/index.js +1 -1
  16. package/dist/cjs/components/memberPopup/panels/Referral/index.js.map +2 -2
  17. package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js +1 -1
  18. package/dist/esm/components/memberPopup/panels/ActivitiesSubscribePanel.js.map +3 -3
  19. package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js +1 -1
  20. package/dist/esm/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.js.map +2 -2
  21. package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.js +1 -1
  22. package/dist/esm/components/memberPopup/panels/ConsumeCredits/index.js.map +2 -2
  23. package/dist/esm/components/memberPopup/panels/EarnCredits/ActivatePanel.js +1 -1
  24. package/dist/esm/components/memberPopup/panels/EarnCredits/ActivatePanel.js.map +2 -2
  25. package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js +1 -1
  26. package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js.map +2 -2
  27. package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js +1 -1
  28. package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js.map +3 -3
  29. package/dist/esm/components/memberPopup/panels/EarnCredits/index.js +1 -1
  30. package/dist/esm/components/memberPopup/panels/EarnCredits/index.js.map +3 -3
  31. package/dist/esm/components/memberPopup/panels/Referral/index.js +1 -1
  32. package/dist/esm/components/memberPopup/panels/Referral/index.js.map +3 -3
  33. package/package.json +1 -1
  34. package/src/components/memberPopup/panels/ActivitiesSubscribePanel.tsx +2 -9
  35. package/src/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.tsx +2 -19
  36. package/src/components/memberPopup/panels/ConsumeCredits/index.tsx +3 -6
  37. package/src/components/memberPopup/panels/EarnCredits/ActivatePanel.tsx +1 -1
  38. package/src/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.tsx +2 -2
  39. package/src/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.tsx +16 -15
  40. package/src/components/memberPopup/panels/EarnCredits/index.tsx +7 -20
  41. package/src/components/memberPopup/panels/Referral/index.tsx +6 -7
  42. package/src/components/memberPopup/panels/EarnCredits/CompleteProfileModal.tsx +0 -191
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.tsx"],
4
- "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Button, Text } from '@anker-in/headless-ui'\nimport { gaTrack, classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport type { CompleteProfileCopy } from '../../type'\nimport { useUpdateProfile } from './hooks/useUpdateProfile'\nimport useCountries from '../../../credits/context/hooks/useCountries'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n copy: CompleteProfileCopy\n onClose: () => void\n}\n\nexport default function CompleteProfilePanel({ copy, onClose }: Props) {\n const { profile, fetchCreditInfo, alpcConfig, setIsProfileCompleteSuccess } = useMemberPopupContext()\n const { locale } = alpcConfig\n const { brand, storeDomain } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const [firstName, setFirstName] = useState('')\n const [lastName, setLastName] = useState('')\n const [phone, setPhone] = useState('')\n const [birthDay, setBirthDay] = useState('')\n const [country, setCountry] = useState('')\n const [firstNameError, setFirstNameError] = useState('')\n const [lastNameError, setLastNameError] = useState('')\n\n const { updateProfile, isLoading } = useUpdateProfile({ locale, appName: alpcConfig.appName })\n const { countries } = useCountries({ shopifyStoreDomain: storeDomain })\n\n useEffect(() => {\n if (profile) {\n setFirstName(profile.first_name ?? '')\n setLastName(profile.last_name ?? '')\n setPhone(profile.phone_number ?? '')\n setBirthDay(profile.dob ?? '')\n setCountry(profile.country?.id ?? '')\n }\n }, [profile])\n\n useEffect(() => {\n if (countries.length > 0 && !country) {\n setCountry(countries[0].id)\n }\n }, [countries])\n\n const validate = useCallback(() => {\n let hasError = false\n if (!firstName.trim()) {\n setFirstNameError(copy.required)\n hasError = true\n } else {\n setFirstNameError('')\n }\n if (!lastName.trim()) {\n setLastNameError(copy.required)\n hasError = true\n } else {\n setLastNameError('')\n }\n return hasError\n }, [firstName, lastName, copy.required])\n\n const handleSubmit = useCallback(async () => {\n if (validate()) return\n const success = await updateProfile({\n first_name: firstName.trim(),\n last_name: lastName.trim(),\n phone_number: phone,\n country,\n dob: birthDay,\n })\n if (success) {\n setTimeout(() => fetchCreditInfo(profile?.user_id), 3000)\n setIsProfileCompleteSuccess(true)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'earn_credits',\n button_name: 'complete_profile_success',\n info: 'Member Floating Window',\n },\n })\n onClose()\n }\n }, [\n validate,\n updateProfile,\n firstName,\n lastName,\n phone,\n country,\n birthDay,\n fetchCreditInfo,\n profile,\n setIsProfileCompleteSuccess,\n onClose,\n ])\n\n return (\n <div className=\"flex flex-col gap-[16px]\">\n {copy.subtitle && <Text className=\"text-[14px] text-[#1d1d1f]\" html={copy.subtitle} />}\n\n <div>\n <label className=\"block text-[14px] font-[700] text-[#1d1d1f]\">{copy.email}</label>\n <input\n className={cn(\n 'mt-[8px] h-[46px] w-full border border-[#d8d8d8] bg-[#f5f5f5] px-[12px] text-[14px] text-[#999]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n value={profile?.email ?? ''}\n disabled\n />\n </div>\n\n <div>\n <label className=\"block text-[14px] font-[700] text-[#1d1d1f]\">\n {copy.firstName} <span className=\"text-[#f84d4f]\">*</span>\n </label>\n <input\n className={cn(\n 'mt-[8px] h-[46px] w-full border px-[12px] text-[14px] outline-none',\n firstNameError ? 'border-[#f84d4f]' : 'border-[#d8d8d8]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n value={firstName}\n onChange={e => {\n setFirstName(e.target.value)\n setFirstNameError('')\n }}\n />\n {firstNameError && <Text className=\"mt-[4px] text-[12px] text-[#f84d4f]\" html={firstNameError} />}\n </div>\n\n <div>\n <label className=\"block text-[14px] font-[700] text-[#1d1d1f]\">\n {copy.lastName} <span className=\"text-[#f84d4f]\">*</span>\n </label>\n <input\n className={cn(\n 'mt-[8px] h-[46px] w-full border px-[12px] text-[14px] outline-none',\n lastNameError ? 'border-[#f84d4f]' : 'border-[#d8d8d8]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n value={lastName}\n onChange={e => {\n setLastName(e.target.value)\n setLastNameError('')\n }}\n />\n {lastNameError && <Text className=\"mt-[4px] text-[12px] text-[#f84d4f]\" html={lastNameError} />}\n </div>\n\n <div>\n <label className=\"block text-[14px] font-[700] text-[#1d1d1f]\">{copy.birthday}</label>\n <input\n className={cn(\n 'mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n type=\"date\"\n value={birthDay}\n onChange={e => setBirthDay(e.target.value)}\n />\n </div>\n\n <div>\n <label className=\"block text-[14px] font-[700] text-[#1d1d1f]\">{copy.phone}</label>\n <input\n className={cn(\n 'mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n value={phone}\n onChange={e => setPhone(e.target.value)}\n />\n </div>\n\n <div>\n <label className=\"block text-[14px] font-[700] text-[#1d1d1f]\">{copy.country}</label>\n <select\n className={cn(\n 'mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n value={country}\n onChange={e => setCountry(e.target.value)}\n >\n {countries.map((c: { id: string; name: string }) => (\n <option key={c.id} value={c.id}>\n {c.name}\n </option>\n ))}\n </select>\n </div>\n\n <div className=\"flex gap-[12px]\">\n <Button variant=\"secondary\" size=\"lg\" className=\"flex-1\" onClick={onClose} disabled={isLoading}>\n {copy.cancel}\n </Button>\n <Button variant=\"primary\" size=\"lg\" className=\"flex-1\" loading={isLoading} onClick={handleSubmit}>\n {copy.save}\n </Button>\n </div>\n </div>\n )\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAuGwB,IAAAI,EAAA,6BAvGxBC,EAAiD,iBACjDC,EAA6B,iCAC7BC,EAA8D,yBAE9DC,EAAiC,oCACjCC,EAAyB,0DACzBC,EAAsC,kCACtC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AC,UAAO,QAAQ,UAAU,KAAK,KAAK,UAAU,SAAS,QAASyB,EAAW,QAASK,EACjF,SAAA9B,EAAK,KACR,GACF,GACF,CAEJ",
4
+ "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Button, Text } from '@anker-in/headless-ui'\nimport { gaTrack, classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport type { CompleteProfileCopy } from '../../type'\nimport { useUpdateProfile } from './hooks/useUpdateProfile'\nimport useCountries from '../../../credits/context/hooks/useCountries'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n copy: CompleteProfileCopy\n onClose: () => void\n}\n\nexport default function CompleteProfilePanel({ copy, onClose }: Props) {\n const { profile, fetchCreditInfo, alpcConfig, setIsProfileCompleteSuccess } = useMemberPopupContext()\n const { locale } = alpcConfig\n const { brand, storeDomain } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const [firstName, setFirstName] = useState('')\n const [lastName, setLastName] = useState('')\n const [phone, setPhone] = useState('')\n const [birthDay, setBirthDay] = useState('')\n const [country, setCountry] = useState('')\n const [firstNameError, setFirstNameError] = useState('')\n const [lastNameError, setLastNameError] = useState('')\n\n const { updateProfile, isLoading } = useUpdateProfile({ locale, appName: alpcConfig.appName })\n const { countries } = useCountries({ shopifyStoreDomain: storeDomain })\n\n useEffect(() => {\n if (profile) {\n setFirstName(profile.first_name ?? '')\n setLastName(profile.last_name ?? '')\n setPhone(profile.phone_number ?? '')\n setBirthDay(profile.dob ?? '')\n setCountry(profile.country?.id ?? '')\n }\n }, [profile])\n\n useEffect(() => {\n if (countries.length > 0 && !country) {\n setCountry(countries[0].id)\n }\n }, [countries])\n\n const validate = useCallback(() => {\n let hasError = false\n if (!firstName.trim()) {\n setFirstNameError(copy.required)\n hasError = true\n } else {\n setFirstNameError('')\n }\n if (!lastName.trim()) {\n setLastNameError(copy.required)\n hasError = true\n } else {\n setLastNameError('')\n }\n return hasError\n }, [firstName, lastName, copy.required])\n\n const handleSubmit = useCallback(async () => {\n if (validate()) return\n const success = await updateProfile({\n first_name: firstName.trim(),\n last_name: lastName.trim(),\n phone_number: phone,\n country,\n dob: birthDay,\n })\n if (success) {\n setTimeout(() => fetchCreditInfo(profile?.user_id), 3000)\n setIsProfileCompleteSuccess(true)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'earn_credits',\n button_name: 'complete_profile_success',\n info: 'Member Floating Window',\n },\n })\n onClose()\n }\n }, [\n validate,\n updateProfile,\n firstName,\n lastName,\n phone,\n country,\n birthDay,\n fetchCreditInfo,\n profile,\n setIsProfileCompleteSuccess,\n onClose,\n ])\n\n return (\n <div className=\"flex flex-col gap-[16px]\">\n {copy.subtitle && <Text className=\"text-[14px] text-[#1d1d1f]\" html={copy.subtitle} />}\n\n <div>\n <label className=\"block text-[14px] font-[700] text-[#1d1d1f]\">{copy.email}</label>\n <input\n className={cn(\n 'mt-[8px] h-[46px] w-full border border-[#d8d8d8] bg-[#f5f5f5] px-[12px] text-[14px] text-[#999]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n value={profile?.email ?? ''}\n disabled\n />\n </div>\n\n <div>\n <label className=\"block text-[14px] font-[700] text-[#1d1d1f]\">\n {copy.firstName} <span className=\"text-[#f84d4f]\">*</span>\n </label>\n <input\n className={cn(\n 'mt-[8px] h-[46px] w-full border px-[12px] text-[14px] outline-none',\n firstNameError ? 'border-[#f84d4f]' : 'border-[#d8d8d8]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n value={firstName}\n onChange={e => {\n setFirstName(e.target.value)\n setFirstNameError('')\n }}\n />\n {firstNameError && <Text className=\"mt-[4px] text-[12px] text-[#f84d4f]\" html={firstNameError} />}\n </div>\n\n <div>\n <label className=\"block text-[14px] font-[700] text-[#1d1d1f]\">\n {copy.lastName} <span className=\"text-[#f84d4f]\">*</span>\n </label>\n <input\n className={cn(\n 'mt-[8px] h-[46px] w-full border px-[12px] text-[14px] outline-none',\n lastNameError ? 'border-[#f84d4f]' : 'border-[#d8d8d8]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n value={lastName}\n onChange={e => {\n setLastName(e.target.value)\n setLastNameError('')\n }}\n />\n {lastNameError && <Text className=\"mt-[4px] text-[12px] text-[#f84d4f]\" html={lastNameError} />}\n </div>\n\n <div>\n <label className=\"block text-[14px] font-[700] text-[#1d1d1f]\">{copy.birthday}</label>\n <input\n className={cn(\n 'mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n type=\"date\"\n value={birthDay}\n onChange={e => setBirthDay(e.target.value)}\n />\n </div>\n\n <div>\n <label className=\"block text-[14px] font-[700] text-[#1d1d1f]\">{copy.phone}</label>\n <input\n className={cn(\n 'mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n value={phone}\n onChange={e => setPhone(e.target.value)}\n />\n </div>\n\n <div>\n <label className=\"block text-[14px] font-[700] text-[#1d1d1f]\">{copy.country}</label>\n <select\n className={cn(\n 'mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n value={country}\n onChange={e => setCountry(e.target.value)}\n >\n {countries.map((c: { id: string; name: string }) => (\n <option key={c.id} value={c.id}>\n {c.name}\n </option>\n ))}\n </select>\n </div>\n\n <div className=\"flex gap-[12px]\">\n <Button variant=\"secondary\" size=\"base\" className=\"flex-1\" onClick={onClose} disabled={isLoading}>\n {copy.cancel}\n </Button>\n <Button variant=\"primary\" size=\"base\" className=\"flex-1\" loading={isLoading} onClick={handleSubmit}>\n {copy.save}\n </Button>\n </div>\n </div>\n )\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE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ACD,EACH,GACF,KAEA,QAAC,OAAI,UAAU,kBACb,oBAAC,UAAO,QAAQ,YAAY,KAAK,OAAO,UAAU,SAAS,QAAShC,EAAS,SAAUwB,EACpF,SAAAzB,EAAK,OACR,KACA,OAAC,UAAO,QAAQ,UAAU,KAAK,OAAO,UAAU,SAAS,QAASyB,EAAW,QAASK,EACnF,SAAA9B,EAAK,KACR,GACF,GACF,CAEJ",
6
6
  "names": ["CompleteProfilePanel_exports", "__export", "CompleteProfilePanel", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_useUpdateProfile", "import_useCountries", "import_provider", "import_constants", "copy", "onClose", "profile", "fetchCreditInfo", "alpcConfig", "setIsProfileCompleteSuccess", "locale", "brand", "storeDomain", "rounded", "firstName", "setFirstName", "lastName", "setLastName", "phone", "setPhone", "birthDay", "setBirthDay", "country", "setCountry", "firstNameError", "setFirstNameError", "lastNameError", "setLastNameError", "updateProfile", "isLoading", "countries", "useCountries", "validate", "hasError", "handleSubmit", "cn", "e", "c"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var B=Object.create;var m=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var J=(e,t)=>{for(var s in t)m(e,s,{get:t[s],enumerable:!0})},w=(e,t,s,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of R(t))!q.call(e,a)&&a!==s&&m(e,a,{get:()=>t[a],enumerable:!(f=H(t,a))||f.enumerable});return e};var U=(e,t,s)=>(s=e!=null?B(j(e)):{},w(t||!e||!e.__esModule?m(s,"default",{value:e,enumerable:!0}):s,e)),V=e=>w(m({},"__esModule",{value:!0}),e);var F={};J(F,{default:()=>E});module.exports=V(F);var r=require("react/jsx-runtime"),o=require("react"),u=require("@anker-in/headless-ui"),i=require("@anker-in/lib"),d=U(require("js-cookie")),T=require("query-string"),M=require("../../../credits/context/utils"),P=require("../../context/provider"),D=require("../../../../constants");function z(){if(typeof window>"u")return{register_source:""};const{search:e,href:t}=window.location,s=(0,T.parse)(e);return{fbuy_ref_code:d.default.get("fbuy_ref_code"),ref:d.default.get("ref_ads"),inviter_code:s.ic??s.inviter_code??d.default.get("inviter_code"),register_source:s.redirect??d.default.get("reg_source")??t}}function E({copy:e,email:t,onClose:s}){const{alpcConfig:f,setIsSubscribeSuccess:a,fetchCreditInfo:I,profile:g}=(0,P.useMemberPopupContext)(),{brand:h,locale:_}=f,{brand:L}=(0,i.useHeadlessContext)(),v=D.ROUNDED_BRANDS.includes(L),[x,y]=(0,o.useState)(e.policyDefaultChecked??!1),[c,C]=(0,o.useState)(t??""),[p,l]=(0,o.useState)(""),[b,N]=(0,o.useState)(""),[O,S]=(0,o.useState)(!1);(0,o.useEffect)(()=>{t&&C(t)},[t]);const A=(0,o.useCallback)(async()=>{if(l(""),!c)return l("Please fill in your email");if(!(0,M.emailValidate)(c))return l("Invalid email address");if(!x)return l("Please agree to the policy");S(!0);const{register_source:n}=z();try{const k=await(await fetch("/api/multipass/subscribe/subscribe_emails",{method:"POST",headers:{"Content-Type":"application/json","current-language":_},body:JSON.stringify({email:c,register_source:n,brand:h,deals_type:e.dealsType??"vip_subscribe"})})).json();k.errors?l(k.errors??"Error occurred"):(N(e.successTips??"Subscribed successfully!"),a(!0),g?.user_id&&setTimeout(()=>I(g.user_id),3e3),(0,i.gaTrack)({event:"ga4Event",event_name:"subscribe",event_parameters:{page_group:e.dealsType??"",position:"sticky",info:""}}),setTimeout(()=>{N(""),s()},3e3))}catch{l("Network error")}finally{S(!1)}},[c,x,_,h,e,s,a]);return(0,r.jsxs)("div",{className:"flex flex-col gap-[12px]",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-[8px]",children:[e.title&&(0,r.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:e.title}),e.desc&&(0,r.jsx)(u.Text,{className:"text-[16px] text-[#1e2024]",html:e.desc})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[(0,r.jsx)("input",{className:(0,i.classNames)("h-[46px] w-full border px-[14px] text-[16px] outline-none placeholder:text-[#999]",p?"border-[#f84d4f]":"border-[#d8d8d8]",v?"rounded-[4px]":"rounded-none"),placeholder:e.placeholder,value:c,onChange:n=>{l(""),C(n.target.value.trim())}}),(0,r.jsxs)("div",{className:"flex w-full items-start gap-[8px]",children:[(0,r.jsx)(u.Checkbox,{checked:x,onCheckedChange:()=>y(n=>!n),className:"mt-[2px] border-[#1d1d1f]"}),(0,r.jsx)("label",{className:"cursor-pointer text-left text-[14px] text-[#1e2024] [&_a]:underline",onClick:()=>y(n=>!n),dangerouslySetInnerHTML:{__html:e.policy??""}})]}),(p||b)&&(0,r.jsx)("div",{className:(0,i.classNames)("text-[14px] font-[700]",p&&"text-[#f84d4f]",b&&"text-[#52c41a]"),children:(0,r.jsx)(u.Text,{html:b||p})}),(0,r.jsx)("button",{className:(0,i.classNames)("w-full cursor-pointer bg-[#080a0f] py-[14px] text-[14px] font-[700] text-white disabled:opacity-60",v?"rounded-[4px]":"rounded-none"),disabled:O,onClick:A,children:e.buttonLabel??"Subscribe"})]})]})}
1
+ "use strict";var A=Object.create;var m=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var J=(e,t)=>{for(var s in t)m(e,s,{get:t[s],enumerable:!0})},k=(e,t,s,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of R(t))!q.call(e,a)&&a!==s&&m(e,a,{get:()=>t[a],enumerable:!(f=H(t,a))||f.enumerable});return e};var U=(e,t,s)=>(s=e!=null?A(j(e)):{},k(t||!e||!e.__esModule?m(s,"default",{value:e,enumerable:!0}):s,e)),V=e=>k(m({},"__esModule",{value:!0}),e);var F={};J(F,{default:()=>B});module.exports=V(F);var r=require("react/jsx-runtime"),o=require("react"),n=require("@anker-in/headless-ui"),c=require("@anker-in/lib"),u=U(require("js-cookie")),w=require("query-string"),T=require("../../../credits/context/utils"),M=require("../../context/provider"),P=require("../../../../constants");function z(){if(typeof window>"u")return{register_source:""};const{search:e,href:t}=window.location,s=(0,w.parse)(e);return{fbuy_ref_code:u.default.get("fbuy_ref_code"),ref:u.default.get("ref_ads"),inviter_code:s.ic??s.inviter_code??u.default.get("inviter_code"),register_source:s.redirect??u.default.get("reg_source")??t}}function B({copy:e,email:t,onClose:s}){const{alpcConfig:f,setIsSubscribeSuccess:a,fetchCreditInfo:D,profile:g}=(0,M.useMemberPopupContext)(),{brand:h,locale:_}=f,{brand:E}=(0,c.useHeadlessContext)(),I=P.ROUNDED_BRANDS.includes(E),[x,v]=(0,o.useState)(e.policyDefaultChecked??!1),[d,y]=(0,o.useState)(t??""),[p,i]=(0,o.useState)(""),[b,C]=(0,o.useState)(""),[L,N]=(0,o.useState)(!1);(0,o.useEffect)(()=>{t&&y(t)},[t]);const O=(0,o.useCallback)(async()=>{if(i(""),!d)return i("Please fill in your email");if(!(0,T.emailValidate)(d))return i("Invalid email address");if(!x)return i("Please agree to the policy");N(!0);const{register_source:l}=z();try{const S=await(await fetch("/api/multipass/subscribe/subscribe_emails",{method:"POST",headers:{"Content-Type":"application/json","current-language":_},body:JSON.stringify({email:d,register_source:l,brand:h,deals_type:e.dealsType??"vip_subscribe"})})).json();S.errors?i(S.errors??"Error occurred"):(C(e.successTips??"Subscribed successfully!"),a(!0),g?.user_id&&setTimeout(()=>D(g.user_id),3e3),(0,c.gaTrack)({event:"ga4Event",event_name:"subscribe",event_parameters:{page_group:e.dealsType??"",position:"sticky",info:""}}),setTimeout(()=>{C(""),s()},3e3))}catch{i("Network error")}finally{N(!1)}},[d,x,_,h,e,s,a]);return(0,r.jsxs)("div",{className:"flex flex-col gap-[12px]",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-[8px]",children:[e.title&&(0,r.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:e.title}),e.desc&&(0,r.jsx)(n.Text,{className:"text-[16px] text-[#1e2024]",html:e.desc})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[(0,r.jsx)("input",{className:(0,c.classNames)("h-[46px] w-full border px-[14px] text-[16px] outline-none placeholder:text-[#999]",p?"border-[#f84d4f]":"border-[#d8d8d8]",I?"rounded-[4px]":"rounded-none"),placeholder:e.placeholder,value:d,onChange:l=>{i(""),y(l.target.value.trim())}}),(0,r.jsxs)("div",{className:"flex w-full items-start gap-[8px]",children:[(0,r.jsx)(n.Checkbox,{checked:x,onCheckedChange:()=>v(l=>!l),className:"mt-[2px] border-[#1d1d1f]"}),(0,r.jsx)("label",{className:"cursor-pointer text-left text-[14px] text-[#1e2024] [&_a]:underline",onClick:()=>v(l=>!l),dangerouslySetInnerHTML:{__html:e.policy??""}})]}),(p||b)&&(0,r.jsx)("div",{className:(0,c.classNames)("text-[14px] font-[700]",p&&"text-[#f84d4f]",b&&"text-[#52c41a]"),children:(0,r.jsx)(n.Text,{html:b||p})}),(0,r.jsx)(n.Button,{className:"w-full",loading:L,onClick:O,children:e.buttonLabel??"Subscribe"})]})]})}
2
2
  //# sourceMappingURL=SubscribeEmailPanel.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.tsx"],
4
- "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Checkbox, Text } from '@anker-in/headless-ui'\nimport { gaTrack, classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport Cookies from 'js-cookie'\nimport { parse } from 'query-string'\nimport { emailValidate } from '../../../credits/context/utils'\nimport { useMemberPopupContext } from '../../context/provider'\nimport type { SubscribeModalCopy } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n copy: SubscribeModalCopy\n email?: string\n onClose: () => void\n}\n\nfunction getAdCookie() {\n if (typeof window === 'undefined') return { register_source: '' }\n const { search, href } = window.location\n const query = parse(search)\n return {\n fbuy_ref_code: Cookies.get('fbuy_ref_code'),\n ref: Cookies.get('ref_ads'),\n inviter_code: query.ic ?? query.inviter_code ?? Cookies.get('inviter_code'),\n register_source: query.redirect ?? Cookies.get('reg_source') ?? href,\n }\n}\n\nexport default function SubscribeEmailPanel({ copy, email: initialEmail, onClose }: Props) {\n const { alpcConfig, setIsSubscribeSuccess, fetchCreditInfo, profile } = useMemberPopupContext()\n const { brand, locale } = alpcConfig\n const { brand: headlessBrand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(headlessBrand)\n const [policy, setPolicy] = useState(copy.policyDefaultChecked ?? false)\n const [email, setEmail] = useState(initialEmail ?? '')\n const [errorMessage, setErrorMessage] = useState('')\n const [successMessage, setSuccessMessage] = useState('')\n const [loading, setLoading] = useState(false)\n\n useEffect(() => {\n if (initialEmail) setEmail(initialEmail)\n }, [initialEmail])\n\n const handleSubmit = useCallback(async () => {\n setErrorMessage('')\n if (!email) return setErrorMessage('Please fill in your email')\n if (!emailValidate(email)) return setErrorMessage('Invalid email address')\n if (!policy) return setErrorMessage('Please agree to the policy')\n\n setLoading(true)\n const { register_source } = getAdCookie()\n try {\n const response = await fetch('/api/multipass/subscribe/subscribe_emails', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', 'current-language': locale },\n body: JSON.stringify({\n email,\n register_source,\n brand,\n deals_type: copy.dealsType ?? 'vip_subscribe',\n }),\n })\n const result = await response.json()\n if (!result.errors) {\n setSuccessMessage(copy.successTips ?? 'Subscribed successfully!')\n setIsSubscribeSuccess(true)\n if (profile?.user_id) setTimeout(() => fetchCreditInfo(profile.user_id), 3000)\n gaTrack({\n event: 'ga4Event',\n event_name: 'subscribe',\n event_parameters: {\n page_group: copy.dealsType ?? '',\n position: 'sticky',\n info: '',\n },\n })\n setTimeout(() => {\n setSuccessMessage('')\n onClose()\n }, 3000)\n } else {\n setErrorMessage(result.errors ?? 'Error occurred')\n }\n } catch {\n setErrorMessage('Network error')\n } finally {\n setLoading(false)\n }\n }, [email, policy, locale, brand, copy, onClose, setIsSubscribeSuccess])\n\n return (\n <div className=\"flex flex-col gap-[12px]\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && (\n <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>\n )}\n {copy.desc && (\n <Text className=\"text-[16px] text-[#1e2024]\" html={copy.desc} />\n )}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n <input\n className={cn(\n 'h-[46px] w-full border px-[14px] text-[16px] outline-none placeholder:text-[#999]',\n errorMessage ? 'border-[#f84d4f]' : 'border-[#d8d8d8]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n placeholder={copy.placeholder}\n value={email}\n onChange={e => { setErrorMessage(''); setEmail(e.target.value.trim()) }}\n />\n\n <div className=\"flex w-full items-start gap-[8px]\">\n <Checkbox checked={policy} onCheckedChange={() => setPolicy(v => !v)} className=\"mt-[2px] border-[#1d1d1f]\" />\n <label\n className=\"cursor-pointer text-left text-[14px] text-[#1e2024] [&_a]:underline\"\n onClick={() => setPolicy(v => !v)}\n dangerouslySetInnerHTML={{ __html: copy.policy ?? '' }}\n />\n </div>\n\n {(errorMessage || successMessage) && (\n <div className={cn('text-[14px] font-[700]', errorMessage && 'text-[#f84d4f]', successMessage && 'text-[#52c41a]')}>\n <Text html={successMessage || errorMessage} />\n </div>\n )}\n\n <button\n className={cn('w-full cursor-pointer bg-[#080a0f] py-[14px] text-[14px] font-[700] text-white disabled:opacity-60', rounded ? 'rounded-[4px]' : 'rounded-none')}\n disabled={loading}\n onClick={handleSubmit}\n >\n {copy.buttonLabel ?? 'Subscribe'}\n </button>\n </div>\n </div>\n )\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GA4FM,IAAAI,EAAA,6BA5FNC,EAAiD,iBACjDC,EAA+B,iCAC/BC,EAA8D,yBAC9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,CAAET,EAAgB,EAAE,EAAGF,EAASW,EAAE,OAAO,MAAM,KAAK,CAAC,CAAE,EACxE,KAEA,QAAC,OAAI,UAAU,oCACb,oBAAC,YAAS,QAASd,EAAQ,gBAAiB,IAAMC,EAAUc,GAAK,CAACA,CAAC,EAAG,UAAU,4BAA4B,KAC5G,OAAC,SACC,UAAU,sEACV,QAAS,IAAMd,EAAUc,GAAK,CAACA,CAAC,EAChC,wBAAyB,CAAE,OAAQ1B,EAAK,QAAU,EAAG,EACvD,GACF,GAEEe,GAAgBE,OAChB,OAAC,OAAI,aAAW,EAAAO,YAAG,yBAA0BT,GAAgB,iBAAkBE,GAAkB,gBAAgB,EAC/G,mBAAC,QAAK,KAAMA,GAAkBF,EAAc,EAC9C,KAGF,OAAC,UACC,aAAW,EAAAS,YAAG,qGAAsGd,EAAU,gBAAkB,cAAc,EAC9J,SAAUS,EACV,QAASE,EAER,SAAArB,EAAK,aAAe,YACvB,GACF,GACF,CAEJ",
4
+ "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Button, Checkbox, Text } from '@anker-in/headless-ui'\nimport { gaTrack, classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport Cookies from 'js-cookie'\nimport { parse } from 'query-string'\nimport { emailValidate } from '../../../credits/context/utils'\nimport { useMemberPopupContext } from '../../context/provider'\nimport type { SubscribeModalCopy } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n copy: SubscribeModalCopy\n email?: string\n onClose: () => void\n}\n\nfunction getAdCookie() {\n if (typeof window === 'undefined') return { register_source: '' }\n const { search, href } = window.location\n const query = parse(search)\n return {\n fbuy_ref_code: Cookies.get('fbuy_ref_code'),\n ref: Cookies.get('ref_ads'),\n inviter_code: query.ic ?? query.inviter_code ?? Cookies.get('inviter_code'),\n register_source: query.redirect ?? Cookies.get('reg_source') ?? href,\n }\n}\n\nexport default function SubscribeEmailPanel({ copy, email: initialEmail, onClose }: Props) {\n const { alpcConfig, setIsSubscribeSuccess, fetchCreditInfo, profile } = useMemberPopupContext()\n const { brand, locale } = alpcConfig\n const { brand: headlessBrand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(headlessBrand)\n const [policy, setPolicy] = useState(copy.policyDefaultChecked ?? false)\n const [email, setEmail] = useState(initialEmail ?? '')\n const [errorMessage, setErrorMessage] = useState('')\n const [successMessage, setSuccessMessage] = useState('')\n const [loading, setLoading] = useState(false)\n\n useEffect(() => {\n if (initialEmail) setEmail(initialEmail)\n }, [initialEmail])\n\n const handleSubmit = useCallback(async () => {\n setErrorMessage('')\n if (!email) return setErrorMessage('Please fill in your email')\n if (!emailValidate(email)) return setErrorMessage('Invalid email address')\n if (!policy) return setErrorMessage('Please agree to the policy')\n\n setLoading(true)\n const { register_source } = getAdCookie()\n try {\n const response = await fetch('/api/multipass/subscribe/subscribe_emails', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json', 'current-language': locale },\n body: JSON.stringify({\n email,\n register_source,\n brand,\n deals_type: copy.dealsType ?? 'vip_subscribe',\n }),\n })\n const result = await response.json()\n if (!result.errors) {\n setSuccessMessage(copy.successTips ?? 'Subscribed successfully!')\n setIsSubscribeSuccess(true)\n if (profile?.user_id) setTimeout(() => fetchCreditInfo(profile.user_id), 3000)\n gaTrack({\n event: 'ga4Event',\n event_name: 'subscribe',\n event_parameters: {\n page_group: copy.dealsType ?? '',\n position: 'sticky',\n info: '',\n },\n })\n setTimeout(() => {\n setSuccessMessage('')\n onClose()\n }, 3000)\n } else {\n setErrorMessage(result.errors ?? 'Error occurred')\n }\n } catch {\n setErrorMessage('Network error')\n } finally {\n setLoading(false)\n }\n }, [email, policy, locale, brand, copy, onClose, setIsSubscribeSuccess])\n\n return (\n <div className=\"flex flex-col gap-[12px]\">\n <div className=\"flex flex-col gap-[8px]\">\n {copy.title && <h2 className=\"text-[24px] font-[700] leading-[1.2] text-[#080a0f]\">{copy.title}</h2>}\n {copy.desc && <Text className=\"text-[16px] text-[#1e2024]\" html={copy.desc} />}\n </div>\n\n <div className=\"flex flex-col gap-[16px]\">\n <input\n className={cn(\n 'h-[46px] w-full border px-[14px] text-[16px] outline-none placeholder:text-[#999]',\n errorMessage ? 'border-[#f84d4f]' : 'border-[#d8d8d8]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n placeholder={copy.placeholder}\n value={email}\n onChange={e => {\n setErrorMessage('')\n setEmail(e.target.value.trim())\n }}\n />\n\n <div className=\"flex w-full items-start gap-[8px]\">\n <Checkbox checked={policy} onCheckedChange={() => setPolicy(v => !v)} className=\"mt-[2px] border-[#1d1d1f]\" />\n <label\n className=\"cursor-pointer text-left text-[14px] text-[#1e2024] [&_a]:underline\"\n onClick={() => setPolicy(v => !v)}\n dangerouslySetInnerHTML={{ __html: copy.policy ?? '' }}\n />\n </div>\n\n {(errorMessage || successMessage) && (\n <div\n className={cn(\n 'text-[14px] font-[700]',\n errorMessage && 'text-[#f84d4f]',\n successMessage && 'text-[#52c41a]'\n )}\n >\n <Text html={successMessage || errorMessage} />\n </div>\n )}\n\n <Button className=\"w-full\" loading={loading} onClick={handleSubmit}>\n {copy.buttonLabel ?? 'Subscribe'}\n </Button>\n </div>\n </div>\n )\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GA4FM,IAAAI,EAAA,6BA5FNC,EAAiD,iBACjDC,EAAuC,iCACvCC,EAA8D,yBAC9DC,EAAoB,wBACpBC,EAAsB,wBACtBC,EAA8B,0CAC9BC,EAAsC,kCAEtCC,EAA+B,iCAQ/B,SAASC,GAAc,CACrB,GAAI,OAAO,OAAW,IAAa,MAAO,CAAE,gBAAiB,EAAG,EAChE,KAAM,CAAE,OAAAC,EAAQ,KAAAC,CAAK,EAAI,OAAO,SAC1BC,KAAQ,SAAMF,CAAM,EAC1B,MAAO,CACL,cAAe,EAAAG,QAAQ,IAAI,eAAe,EAC1C,IAAK,EAAAA,QAAQ,IAAI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AEEe,GAAgBE,OAChB,OAAC,OACC,aAAW,EAAAO,YACT,yBACAT,GAAgB,iBAChBE,GAAkB,gBACpB,EAEA,mBAAC,QAAK,KAAMA,GAAkBF,EAAc,EAC9C,KAGF,OAAC,UAAO,UAAU,SAAS,QAASI,EAAS,QAASE,EACnD,SAAArB,EAAK,aAAe,YACvB,GACF,GACF,CAEJ",
6
6
  "names": ["SubscribeEmailPanel_exports", "__export", "SubscribeEmailPanel", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_js_cookie", "import_query_string", "import_utils", "import_provider", "import_constants", "getAdCookie", "search", "href", "query", "Cookies", "copy", "initialEmail", "onClose", "alpcConfig", "setIsSubscribeSuccess", "fetchCreditInfo", "profile", "brand", "locale", "headlessBrand", "rounded", "policy", "setPolicy", "email", "setEmail", "errorMessage", "setErrorMessage", "successMessage", "setSuccessMessage", "loading", "setLoading", "handleSubmit", "register_source", "result", "cn", "e", "v"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var v=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var R=(i,t)=>{for(var n in t)v(i,n,{get:t[n],enumerable:!0})},D=(i,t,n,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of M(t))!y.call(i,l)&&l!==n&&v(i,l,{get:()=>t[l],enumerable:!(f=U(t,l))||f.enumerable});return i};var F=i=>D(v({},"__esModule",{value:!0}),i);var W={};R(W,{default:()=>H});module.exports=F(W);var e=require("react/jsx-runtime"),c=require("react"),r=require("@anker-in/lib"),_=require("../../context/provider"),E=require("../../context/viewStack"),P=require("./hooks/useSubscribed"),s=require("../../type"),p=require("../../icons"),g=require("../../../credits/context/utils"),L=require("../../../../constants");function O({id:i,className:t}){switch(i){case s.EarnCreditsTaskType.Activate:return(0,e.jsx)(p.IconLock,{className:t});case s.EarnCreditsTaskType.Subscribe:return(0,e.jsx)(p.IconSubscription,{className:t});case s.EarnCreditsTaskType.Shop:return(0,e.jsx)(p.IconBag,{className:t});case s.EarnCreditsTaskType.CompleteProfile:return(0,e.jsx)(p.IconOrders,{className:t})}}function V({copy:i}){const{profile:t,openSignUpPopup:n,alpcConfig:f,creditInfo:l,fetchCreditInfo:w,isSubscribeSuccess:C,isActivateSuccess:N,isProfileCompleteSuccess:m}=(0,_.useMemberPopupContext)(),{pushView:u}=(0,E.useViewStack)(),{locale:A}=f,{brand:h}=(0,r.useHeadlessContext)(),b=L.ROUNDED_BRANDS.includes(h);(0,c.useEffect)(()=>{t?.user_id&&w(t.user_id)},[]);const o=!!t,k=(0,P.useSubscribed)({userId:t?.user_id,brand:h,email:t?.email,locale:A,apiBaseUrl:f.apiBaseUrl}),S=(0,c.useMemo)(()=>m||!!(t?.first_name||t?.last_name)&&!!t?.phone_number&&!!t?.dob,[t,m]);function x(a){const d={[s.EarnCreditsTaskType.Activate]:"activate",[s.EarnCreditsTaskType.CompleteProfile]:"complete_profile",[s.EarnCreditsTaskType.Subscribe]:"subscribe",[s.EarnCreditsTaskType.Shop]:"shop"};(0,r.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"earn_credits",button_name:d[a],info:"Member Floating Window"}})}const T=(0,c.useMemo)(()=>({[s.EarnCreditsTaskType.Activate]:{finished:!!t?.activated||N,onClick:o?()=>{x(s.EarnCreditsTaskType.Activate),u({type:s.MemberPopupPanelType.Activate})}:n},[s.EarnCreditsTaskType.CompleteProfile]:{finished:S,onClick:o?()=>{x(s.EarnCreditsTaskType.CompleteProfile),u({type:s.MemberPopupPanelType.CompleteProfile})}:n},[s.EarnCreditsTaskType.Subscribe]:{finished:k||C,onClick:o?()=>{x(s.EarnCreditsTaskType.Subscribe),u({type:s.MemberPopupPanelType.SubscribeEmail})}:n},[s.EarnCreditsTaskType.Shop]:{finished:!1,link:i.goShopLink,onClick:o?()=>x(s.EarnCreditsTaskType.Shop):n}}),[t,o,N,m,S,k,C,n,u,i.goShopLink]),B=(0,c.useMemo)(()=>i.list.map(a=>{const d=T[a.id];if(!d)return null;const I=d.finished?i.completed:o?z(a.id,i):i.joinNow;return{...a,...d,buttonLabel:I}}).filter(Boolean),[i,T,o]);return(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[(0,e.jsx)("div",{className:"flex flex-col gap-[8px]",children:i.title&&(0,e.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:i.title})}),o&&(0,e.jsxs)("div",{className:(0,r.classNames)("flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]",b?"rounded-[8px]":"rounded-none"),children:[(0,e.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,e.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:i.balanceLabel??"AnkerCredits Balance"}),(0,e.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,e.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,g.numberFormat)(l?.available_credit??0)}),(0,e.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:i.creditUnit??"ankercredits"})]})]}),(0,e.jsx)("div",{className:"h-full w-px bg-[#dadce0]"}),(0,e.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,e.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:i.comingSoonLabel??"Coming Soon"}),(0,e.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,e.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,g.numberFormat)(l?.pending_credit??0)}),(0,e.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:i.creditUnit??"ankercredits"})]})]})]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[i.subtitle&&(0,e.jsx)("p",{className:"text-[16px] font-[700] text-[#1e2024]",children:i.subtitle}),(0,e.jsx)("div",{className:"flex flex-col",children:B.map((a,d)=>(0,e.jsxs)("div",{className:"relative py-[16px]",children:[d>0&&(0,e.jsx)("div",{className:"absolute left-0 right-0 top-0 h-px bg-[#dadce0]"}),(0,e.jsxs)("div",{className:(0,r.classNames)("flex items-center gap-[12px]"),children:[(0,e.jsx)(O,{id:a.id,className:"size-[24px] shrink-0"}),(0,e.jsxs)("div",{className:"flex-1",children:[(0,e.jsx)("div",{className:"text-[16px] font-[700] text-[#1e2024]",children:a.title}),a.credits&&(0,e.jsx)("div",{className:"mt-[4px] text-[14px] font-bold text-[#4A4C56]",children:a.credits})]}),!a.finished&&a.link&&o?(0,e.jsx)("a",{href:a.link,target:"_blank",rel:"noopener noreferrer",className:(0,r.classNames)("cursor-pointer bg-[#080a0f] min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",b?"rounded-[4px]":"rounded-none"),onClick:()=>x(a.id),children:a.buttonLabel}):(0,e.jsx)("button",{className:(0,r.classNames)("cursor-pointer min-w-[118px] px-[20px] pb-[10px] pt-[11px] text-[14px] font-[700] leading-[1.2] text-white",a.finished?"bg-[#767880]":"bg-[#080a0f]",b?"rounded-[4px]":"rounded-none",a.finished&&"opacity-60"),disabled:a.finished,onClick:a.finished?void 0:a.onClick,children:a.buttonLabel})]})]},d))})]})]})}function z(i,t){switch(i){case s.EarnCreditsTaskType.Activate:return t.activate;case s.EarnCreditsTaskType.CompleteProfile:return t.completeProfileLabel;case s.EarnCreditsTaskType.Subscribe:return t.subscribeLabel;case s.EarnCreditsTaskType.Shop:return t.shopNow}}var H=V;
1
+ "use strict";var b=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var D=(i,t)=>{for(var n in t)b(i,n,{get:t[n],enumerable:!0})},F=(i,t,n,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of R(t))!y.call(i,r)&&r!==n&&b(i,r,{get:()=>t[r],enumerable:!(f=M(t,r))||f.enumerable});return i};var O=i=>F(b({},"__esModule",{value:!0}),i);var j={};D(j,{default:()=>W});module.exports=O(j);var e=require("react/jsx-runtime"),p=require("react"),d=require("@anker-in/lib"),_=require("../../context/provider"),E=require("../../context/viewStack"),P=require("./hooks/useSubscribed"),s=require("../../type"),c=require("../../icons"),v=require("../../../credits/context/utils"),L=require("../../../../constants"),g=require("@anker-in/headless-ui");function V({id:i,className:t}){switch(i){case s.EarnCreditsTaskType.Activate:return(0,e.jsx)(c.IconLock,{className:t});case s.EarnCreditsTaskType.Subscribe:return(0,e.jsx)(c.IconSubscription,{className:t});case s.EarnCreditsTaskType.Shop:return(0,e.jsx)(c.IconBag,{className:t});case s.EarnCreditsTaskType.CompleteProfile:return(0,e.jsx)(c.IconOrders,{className:t})}}function z({copy:i}){const{profile:t,openSignUpPopup:n,alpcConfig:f,creditInfo:r,fetchCreditInfo:B,isSubscribeSuccess:C,isActivateSuccess:k,isProfileCompleteSuccess:x}=(0,_.useMemberPopupContext)(),{pushView:u}=(0,E.useViewStack)(),{locale:A}=f,{brand:N}=(0,d.useHeadlessContext)(),w=L.ROUNDED_BRANDS.includes(N);(0,p.useEffect)(()=>{t?.user_id&&B(t.user_id)},[]);const o=!!t,h=(0,P.useSubscribed)({userId:t?.user_id,brand:N,email:t?.email,locale:A,apiBaseUrl:f.apiBaseUrl}),S=(0,p.useMemo)(()=>x||!!(t?.first_name||t?.last_name)&&!!t?.phone_number&&!!t?.dob,[t,x]);function m(a){const l={[s.EarnCreditsTaskType.Activate]:"activate",[s.EarnCreditsTaskType.CompleteProfile]:"complete_profile",[s.EarnCreditsTaskType.Subscribe]:"subscribe",[s.EarnCreditsTaskType.Shop]:"shop"};(0,d.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"earn_credits",button_name:l[a],info:"Member Floating Window"}})}const T=(0,p.useMemo)(()=>({[s.EarnCreditsTaskType.Activate]:{finished:!!t?.activated||k,onClick:o?()=>{m(s.EarnCreditsTaskType.Activate),u({type:s.MemberPopupPanelType.Activate})}:n},[s.EarnCreditsTaskType.CompleteProfile]:{finished:S,onClick:o?()=>{m(s.EarnCreditsTaskType.CompleteProfile),u({type:s.MemberPopupPanelType.CompleteProfile})}:n},[s.EarnCreditsTaskType.Subscribe]:{finished:h||C,onClick:o?()=>{m(s.EarnCreditsTaskType.Subscribe),u({type:s.MemberPopupPanelType.SubscribeEmail})}:n},[s.EarnCreditsTaskType.Shop]:{finished:!1,link:i.goShopLink,onClick:o?()=>m(s.EarnCreditsTaskType.Shop):n}}),[t,o,k,x,S,h,C,n,u,i.goShopLink]),I=(0,p.useMemo)(()=>i.list.map(a=>{const l=T[a.id];if(!l)return null;const U=l.finished?i.completed:o?H(a.id,i):i.joinNow;return{...a,...l,buttonLabel:U}}).filter(Boolean),[i,T,o]);return(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[(0,e.jsx)("div",{className:"flex flex-col gap-[8px]",children:i.title&&(0,e.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:i.title})}),o&&(0,e.jsxs)("div",{className:(0,d.classNames)("flex items-center gap-[12px] bg-[#f5f6f7] p-[16px]",w?"rounded-[8px]":"rounded-none"),children:[(0,e.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,e.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:i.balanceLabel??"AnkerCredits Balance"}),(0,e.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,e.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,v.numberFormat)(r?.available_credit??0)}),(0,e.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:i.creditUnit??"ankercredits"})]})]}),(0,e.jsx)("div",{className:"h-full w-px bg-[#dadce0]"}),(0,e.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,e.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:i.comingSoonLabel??"Coming Soon"}),(0,e.jsxs)("div",{className:"flex items-end gap-[4px]",children:[(0,e.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,v.numberFormat)(r?.pending_credit??0)}),(0,e.jsx)("span",{className:"text-[14px] font-[700] leading-[1.4] text-[#1e2024]",children:i.creditUnit??"ankercredits"})]})]})]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[i.subtitle&&(0,e.jsx)("p",{className:"text-[16px] font-[700] text-[#1e2024]",children:i.subtitle}),(0,e.jsx)("div",{className:"flex flex-col",children:I.map((a,l)=>(0,e.jsxs)("div",{className:"relative py-[16px]",children:[l>0&&(0,e.jsx)("div",{className:"absolute left-0 right-0 top-0 h-px bg-[#dadce0]"}),(0,e.jsxs)("div",{className:(0,d.classNames)("flex items-center gap-[12px]"),children:[(0,e.jsx)(V,{id:a.id,className:"size-[24px] shrink-0"}),(0,e.jsxs)("div",{className:"flex-1",children:[(0,e.jsx)("div",{className:"text-[16px] font-[700] text-[#1e2024]",children:a.title}),a.credits&&(0,e.jsx)("div",{className:"mt-[4px] text-[14px] font-bold text-[#4A4C56]",children:a.credits})]}),!a.finished&&a.link&&o?(0,e.jsx)(g.Button,{as:"a",href:a.link,target:"_blank",rel:"noopener noreferrer",onClick:()=>m(a.id),children:a.buttonLabel}):(0,e.jsx)(g.Button,{disabled:a.finished,onClick:a.finished?void 0:a.onClick,children:a.buttonLabel})]})]},l))})]})]})}function H(i,t){switch(i){case s.EarnCreditsTaskType.Activate:return t.activate;case s.EarnCreditsTaskType.CompleteProfile:return t.completeProfileLabel;case s.EarnCreditsTaskType.Subscribe:return t.subscribeLabel;case s.EarnCreditsTaskType.Shop:return t.shopNow}}var W=z;
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 { useEffect, useMemo } from 'react'\nimport { gaTrack, 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}\n\nfunction EarnCredits({ copy }: Props) {\n const {\n profile,\n openSignUpPopup,\n alpcConfig,\n creditInfo,\n fetchCreditInfo,\n isSubscribeSuccess,\n isActivateSuccess,\n isProfileCompleteSuccess,\n } = useMemberPopupContext()\n const { pushView } = useViewStack()\n const { locale } = alpcConfig\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n useEffect(() => {\n if (profile?.user_id) fetchCreditInfo(profile.user_id)\n }, [])\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 function trackTaskButton(taskId: EarnCreditsTaskType) {\n const taskButtonNameMap: Record<EarnCreditsTaskType, string> = {\n [EarnCreditsTaskType.Activate]: 'activate',\n [EarnCreditsTaskType.CompleteProfile]: 'complete_profile',\n [EarnCreditsTaskType.Subscribe]: 'subscribe',\n [EarnCreditsTaskType.Shop]: 'shop',\n }\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'earn_credits',\n button_name: taskButtonNameMap[taskId],\n info: 'Member Floating Window',\n },\n })\n }\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 trackTaskButton(EarnCreditsTaskType.Activate)\n pushView({\n type: MemberPopupPanelType.Activate,\n })\n }\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.CompleteProfile]: {\n finished: profileCompleted,\n onClick: isLogin\n ? () => {\n trackTaskButton(EarnCreditsTaskType.CompleteProfile)\n pushView({\n type: MemberPopupPanelType.CompleteProfile,\n })\n }\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.Subscribe]: {\n finished: isSubscribed || isSubscribeSuccess,\n onClick: isLogin\n ? () => {\n trackTaskButton(EarnCreditsTaskType.Subscribe)\n pushView({\n type: MemberPopupPanelType.SubscribeEmail,\n })\n }\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.Shop]: {\n finished: false,\n link: copy.goShopLink,\n onClick: isLogin ? () => trackTaskButton(EarnCreditsTaskType.Shop) : 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]')}>\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.credits && (\n <div className=\"mt-[4px] text-[14px] font-bold text-[#4A4C56]\">{item.credits}</div>\n )}\n </div>\n {!item.finished && item.link && isLogin ? (\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 onClick={() => trackTaskButton(item.id)}\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 item.finished && 'opacity-60'\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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAaa,IAAAI,EAAA,6BAbbC,EAAmC,iBACnCC,EAA8D,yBAC9DC,EAAsC,kCACtCC,EAA6B,mCAC7BC,EAA8B,iCAC9BC,EAAgF,sBAChFC,E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U,gDAAiD,SAAAA,EAAK,QAAQ,GAEjF,EACC,CAACA,EAAK,UAAYA,EAAK,MAAQR,KAC9B,OAAC,KACC,KAAMQ,EAAK,KACX,OAAO,SACP,IAAI,sBACJ,aAAW,EAAAI,YACT,0HACAb,EAAU,gBAAkB,cAC9B,EACA,QAAS,IAAMI,EAAgBK,EAAK,EAAE,EAErC,SAAAA,EAAK,YACR,KAEA,OAAC,UACC,aAAW,EAAAI,YACT,6GACAJ,EAAK,SAAW,eAAiB,eACjCT,EAAU,gBAAkB,eAC5BS,EAAK,UAAY,YACnB,EACA,SAAUA,EAAK,SACf,QAAUA,EAAK,SAA0B,OAAfA,EAAK,QAE9B,SAAAA,EAAK,YACR,GAEJ,IArCQK,CAsCV,CACD,EACH,GACF,GACF,CAEJ,CAEA,SAASF,EAAoB3B,EAAyBG,EAA+B,CACnF,OAAQH,EAAI,CACV,KAAK,sBAAoB,SACvB,OAAOG,EAAK,SACd,KAAK,sBAAoB,gBACvB,OAAOA,EAAK,qBACd,KAAK,sBAAoB,UACvB,OAAOA,EAAK,eACd,KAAK,sBAAoB,KACvB,OAAOA,EAAK,OAChB,CACF,CAEA,IAAOhB,EAAQe",
6
- "names": ["EarnCredits_exports", "__export", "EarnCredits_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_lib", "import_provider", "import_viewStack", "import_useSubscribed", "import_type", "import_icons", "import_utils", "import_constants", "TaskIcon", "id", "className", "EarnCredits", "copy", "profile", "openSignUpPopup", "alpcConfig", "creditInfo", "fetchCreditInfo", "isSubscribeSuccess", "isActivateSuccess", "isProfileCompleteSuccess", "pushView", "locale", "brand", "rounded", "isLogin", "isSubscribed", "profileCompleted", "trackTaskButton", "taskId", "taskButtonNameMap", "taskStates", "list", "item", "state", "buttonLabel", "getNotFinishedLabel", "cn", "idx"]
4
+ "sourcesContent": ["import { useEffect, useMemo } from 'react'\nimport { gaTrack, 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'\nimport { Button } from '@anker-in/headless-ui'\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}\n\nfunction EarnCredits({ copy }: Props) {\n const {\n profile,\n openSignUpPopup,\n alpcConfig,\n creditInfo,\n fetchCreditInfo,\n isSubscribeSuccess,\n isActivateSuccess,\n isProfileCompleteSuccess,\n } = useMemberPopupContext()\n const { pushView } = useViewStack()\n const { locale } = alpcConfig\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n useEffect(() => {\n if (profile?.user_id) fetchCreditInfo(profile.user_id)\n }, [])\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 function trackTaskButton(taskId: EarnCreditsTaskType) {\n const taskButtonNameMap: Record<EarnCreditsTaskType, string> = {\n [EarnCreditsTaskType.Activate]: 'activate',\n [EarnCreditsTaskType.CompleteProfile]: 'complete_profile',\n [EarnCreditsTaskType.Subscribe]: 'subscribe',\n [EarnCreditsTaskType.Shop]: 'shop',\n }\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'earn_credits',\n button_name: taskButtonNameMap[taskId],\n info: 'Member Floating Window',\n },\n })\n }\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 trackTaskButton(EarnCreditsTaskType.Activate)\n pushView({\n type: MemberPopupPanelType.Activate,\n })\n }\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.CompleteProfile]: {\n finished: profileCompleted,\n onClick: isLogin\n ? () => {\n trackTaskButton(EarnCreditsTaskType.CompleteProfile)\n pushView({\n type: MemberPopupPanelType.CompleteProfile,\n })\n }\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.Subscribe]: {\n finished: isSubscribed || isSubscribeSuccess,\n onClick: isLogin\n ? () => {\n trackTaskButton(EarnCreditsTaskType.Subscribe)\n pushView({\n type: MemberPopupPanelType.SubscribeEmail,\n })\n }\n : openSignUpPopup,\n },\n [EarnCreditsTaskType.Shop]: {\n finished: false,\n link: copy.goShopLink,\n onClick: isLogin ? () => trackTaskButton(EarnCreditsTaskType.Shop) : 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]')}>\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.credits && <div className=\"mt-[4px] text-[14px] font-bold text-[#4A4C56]\">{item.credits}</div>}\n </div>\n {!item.finished && item.link && isLogin ? (\n <Button\n as=\"a\"\n href={item.link}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n onClick={() => trackTaskButton(item.id)}\n >\n {item.buttonLabel}\n </Button>\n ) : (\n <Button disabled={item.finished} onClick={!item.finished ? item.onClick : undefined}>\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": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAca,IAAAI,EAAA,6BAdbC,EAAmC,iBACnCC,EAA8D,yBAC9DC,EAAsC,kCACtCC,EAA6B,mCAC7BC,EAA8B,iCAC9BC,EAAgF,sBAChFC,EAAgE,uBAChEC,EAA6B,0CAC7BC,EAA+B,iCAC/BC,EAAuB,iCAEvB,SAASC,EAAS,CAAE,GAAAC,EAAI,UAAAC,CAAU,EAAoD,CACpF,OAAQD,EAAI,CACV,KAAK,sBAAoB,SACvB,SAAO,OAAC,YAAS,UAAWC,EAAW,EACzC,KAAK,sBAAoB,UACvB,SAAO,OAAC,oBAAiB,UAAWA,EAAW,EACjD,KAAK,sBAAoB,KACvB,SAAO,OAAC,WAAQ,UAAWA,EAAW,EACxC,KAAK,sBAAoB,gBACvB,SAAO,OAAC,cAAW,UAAWA,EAAW,CAC7C,CACF,CAMA,SAASC,EAAY,CAAE,KAA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OAAQH,EAAI,CACV,KAAK,sBAAoB,SACvB,OAAOG,EAAK,SACd,KAAK,sBAAoB,gBACvB,OAAOA,EAAK,qBACd,KAAK,sBAAoB,UACvB,OAAOA,EAAK,eACd,KAAK,sBAAoB,KACvB,OAAOA,EAAK,OAChB,CACF,CAEA,IAAOjB,EAAQgB",
6
+ "names": ["EarnCredits_exports", "__export", "EarnCredits_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_lib", "import_provider", "import_viewStack", "import_useSubscribed", "import_type", "import_icons", "import_utils", "import_constants", "import_headless_ui", "TaskIcon", "id", "className", "EarnCredits", "copy", "profile", "openSignUpPopup", "alpcConfig", "creditInfo", "fetchCreditInfo", "isSubscribeSuccess", "isActivateSuccess", "isProfileCompleteSuccess", "pushView", "locale", "brand", "rounded", "isLogin", "isSubscribed", "profileCompleted", "trackTaskButton", "taskId", "taskButtonNameMap", "taskStates", "list", "item", "state", "buttonLabel", "getNotFinishedLabel", "cn", "idx"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var f=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var P=(e,a)=>{for(var n in a)f(e,n,{get:a[n],enumerable:!0})},U=(e,a,n,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let r of R(a))!_.call(e,r)&&r!==n&&f(e,r,{get:()=>a[r],enumerable:!(o=T(a,r))||o.enumerable});return e};var D=e=>U(f({},"__esModule",{value:!0}),e);var A={};P(A,{default:()=>k});module.exports=D(A);var t=require("react/jsx-runtime"),g=require("@anker-in/headless-ui"),l=require("@anker-in/lib"),u=require("../../context/provider"),v=require("./hooks/useReferralOverview"),d=require("../../../credits/context/utils"),h=require("../../../../constants");function M({copy:e,onClose:a}){const{profile:n,alpcConfig:o,pageHandle:r}=(0,u.useMemberPopupContext)(),b=!!n,{brand:N,currencyCode:x="USD"}=(0,l.useHeadlessContext)(),i=h.ROUNDED_BRANDS.includes(N),{data:c}=(0,v.useReferralOverview)(),w=c?.data?.data?.available??0,C=c?.data?.data?.pending??0;function p(s){try{if(!r)return s;const m=new URL(s,window.location.href);return m.searchParams.set("ref",`${r}_referral`),m.toString()}catch{return s}}function L(){(0,l.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"referral",button_name:"referral_cta",info:"Member Floating Window"}})}return(0,t.jsxs)("div",{className:"flex flex-col",children:[e.title&&(0,t.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:e.title}),b&&(0,t.jsxs)("div",{className:(0,l.classNames)("flex items-center mt-[16px] gap-[12px] bg-[#f5f6f7] p-[16px]",i?"rounded-[8px]":"rounded-none"),children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,t.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:e.cashAvailableLabel}),(0,t.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,d.formatPrice)({amount:w,currencyCode:x,locale:o.locale})})]}),(0,t.jsx)("div",{className:"h-full w-px self-stretch bg-[#dadce0]"}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,t.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:e.cashPendingLabel}),(0,t.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,d.formatPrice)({amount:C,currencyCode:x,locale:o.locale})})]})]}),(e.howToTitle||e.howToDescription)&&(0,t.jsxs)("div",{className:"flex mt-[32px] flex-col gap-[8px]",children:[e.howToTitle&&(0,t.jsx)("h3",{className:"text-[20px] font-bold leading-[1.2] text-[#080a0f]",children:e.howToTitle}),e.howToDescription&&(0,t.jsx)("p",{className:"text-[14px] font-bold leading-[1.4] text-[#080A0F]",children:e.howToDescription}),e.learnMoreLabel&&e.learnMoreUrl&&(0,t.jsxs)("a",{href:p(e.learnMoreUrl),target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-[4px] text-[14px] font-[700] text-[#080a0f] underline",children:[e.learnMoreLabel,(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:(0,t.jsx)("path",{d:"M5.52827 3.52876C5.78862 3.26841 6.21063 3.26841 6.47098 3.52876L10.471 7.52876C10.7313 7.78911 10.7313 8.21112 10.471 8.47147L6.47098 12.4715C6.21063 12.7318 5.78862 12.7318 5.52827 12.4715C5.26792 12.2111 5.26792 11.7891 5.52827 11.5288L9.05692 8.00011L5.52827 4.47147C5.26792 4.21112 5.26792 3.78911 5.52827 3.52876Z",fill:"#080A0F"})})]})]}),e.image?.url&&(0,t.jsx)(g.Picture,{source:e.image.url,alt:e.image.alt??"",className:(0,l.classNames)("mt-[8px] w-full",i?"rounded-[8px]":"rounded-none")}),e.ctaButton&&(0,t.jsx)("a",{href:e.ctaUrl?p(e.ctaUrl):"#",target:"_blank",rel:"noopener noreferrer",className:(0,l.classNames)("block w-full mt-[16px] cursor-pointer bg-[#080a0f] py-[14px] text-center text-[14px] font-[700] text-white",i?"rounded-[4px]":"rounded-none"),onClick:L,children:e.ctaButton})]})}var k=M;
1
+ "use strict";var f=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var P=(e,a)=>{for(var n in a)f(e,n,{get:a[n],enumerable:!0})},U=(e,a,n,o)=>{if(a&&typeof a=="object"||typeof a=="function")for(let l of R(a))!_.call(e,l)&&l!==n&&f(e,l,{get:()=>a[l],enumerable:!(o=T(a,l))||o.enumerable});return e};var D=e=>U(f({},"__esModule",{value:!0}),e);var k={};P(k,{default:()=>B});module.exports=D(k);var t=require("react/jsx-runtime"),s=require("@anker-in/headless-ui"),r=require("@anker-in/lib"),u=require("../../context/provider"),v=require("./hooks/useReferralOverview"),d=require("../../../credits/context/utils"),h=require("../../../../constants");function M({copy:e,onClose:a}){const{profile:n,alpcConfig:o,pageHandle:l}=(0,u.useMemberPopupContext)(),b=!!n,{brand:N,currencyCode:x="USD"}=(0,r.useHeadlessContext)(),m=h.ROUNDED_BRANDS.includes(N),{data:c}=(0,v.useReferralOverview)(),w=c?.data?.data?.available??0,C=c?.data?.data?.pending??0;function p(i){try{if(!l)return i;const g=new URL(i,window.location.href);return g.searchParams.set("ref",`${l}_referral`),g.toString()}catch{return i}}function L(){(0,r.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"referral",button_name:"referral_cta",info:"Member Floating Window"}})}return(0,t.jsxs)("div",{className:"flex flex-col",children:[e.title&&(0,t.jsx)("h2",{className:"text-[24px] font-[700] leading-[1.2] text-[#080a0f]",children:e.title}),b&&(0,t.jsxs)("div",{className:(0,r.classNames)("flex items-center mt-[16px] gap-[12px] bg-[#f5f6f7] p-[16px]",m?"rounded-[8px]":"rounded-none"),children:[(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,t.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:e.cashAvailableLabel}),(0,t.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,d.formatPrice)({amount:w,currencyCode:x,locale:o.locale})})]}),(0,t.jsx)("div",{className:"h-full w-px self-stretch bg-[#dadce0]"}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-[4px]",children:[(0,t.jsx)("div",{className:"text-[14px] font-[700] text-[#1e2024]",children:e.cashPendingLabel}),(0,t.jsx)("span",{className:"text-[24px] font-[700] leading-[1.2] text-[#1e2024]",children:(0,d.formatPrice)({amount:C,currencyCode:x,locale:o.locale})})]})]}),(e.howToTitle||e.howToDescription)&&(0,t.jsxs)("div",{className:"flex mt-[32px] flex-col gap-[8px]",children:[e.howToTitle&&(0,t.jsx)("h3",{className:"text-[20px] font-bold leading-[1.2] text-[#080a0f]",children:e.howToTitle}),e.howToDescription&&(0,t.jsx)("p",{className:"text-[14px] font-bold leading-[1.4] text-[#080A0F]",children:e.howToDescription}),e.learnMoreLabel&&e.learnMoreUrl&&(0,t.jsxs)("a",{href:p(e.learnMoreUrl),target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-[4px] text-[14px] font-[700] text-[#080a0f] underline",children:[e.learnMoreLabel,(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:(0,t.jsx)("path",{d:"M5.52827 3.52876C5.78862 3.26841 6.21063 3.26841 6.47098 3.52876L10.471 7.52876C10.7313 7.78911 10.7313 8.21112 10.471 8.47147L6.47098 12.4715C6.21063 12.7318 5.78862 12.7318 5.52827 12.4715C5.26792 12.2111 5.26792 11.7891 5.52827 11.5288L9.05692 8.00011L5.52827 4.47147C5.26792 4.21112 5.26792 3.78911 5.52827 3.52876Z",fill:"#080A0F"})})]})]}),e.image?.url&&(0,t.jsx)(s.Picture,{source:e.image.url,alt:e.image.alt??"",className:(0,r.classNames)("mt-[8px] w-full",m?"rounded-[8px]":"rounded-none")}),e.ctaButton&&(0,t.jsx)(s.Button,{size:"base",as:"a",className:"mt-[16px]",href:e.ctaUrl?p(e.ctaUrl):"#",target:"_blank",rel:"noopener noreferrer",onClick:L,children:e.ctaButton})]})}var B=M;
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 { gaTrack, 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, pageHandle } = 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 function buildRefUrl(url: string) {\n try {\n if (!pageHandle) return url\n const target = new URL(url, window.location.href)\n target.searchParams.set('ref', `${pageHandle}_referral`)\n return target.toString()\n } catch {\n return url\n }\n }\n\n function trackReferralCta() {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'referral',\n button_name: 'referral_cta',\n info: 'Member Floating Window',\n },\n })\n }\n\n return (\n <div className=\"flex flex-col\">\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 mt-[16px] 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 mt-[32px] flex-col gap-[8px]\">\n {copy.howToTitle && <h3 className=\"text-[20px] font-bold leading-[1.2] text-[#080a0f]\">{copy.howToTitle}</h3>}\n {copy.howToDescription && (\n <p className=\"text-[14px] font-bold leading-[1.4] text-[#080A0F]\">{copy.howToDescription}</p>\n )}\n {copy.learnMoreLabel && copy.learnMoreUrl && (\n <a\n href={buildRefUrl(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] w-full', rounded ? 'rounded-[8px]' : 'rounded-none')}\n />\n )}\n\n {copy.ctaButton && (\n <a\n href={copy.ctaUrl ? buildRefUrl(copy.ctaUrl) : '#'}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={cn(\n 'block w-full mt-[16px] cursor-pointer bg-[#080a0f] py-[14px] text-center text-[14px] font-[700] text-white',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n onClick={trackReferralCta}\n >\n {copy.ctaButton}\n </a>\n )}\n </div>\n )\n}\n\nexport default Referral\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAkDqB,IAAAI,EAAA,6BAlDrBC,EAAwB,iCACxBC,EAA8D,yBAC9DC,EAAsC,kCACtCC,EAAoC,uCACpCC,EAA4B,0CAG5BC,EAA+B,iCAO/B,SAASC,EAAS,CAAE,KAAAC,EAAM,QAAAC,CAAQ,EAAU,CAC1C,KAAM,CAAE,QAAAC,EAAS,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AH,EAAK,YAAcA,EAAK,sBACxB,QAAC,OAAI,UAAU,oCACZ,UAAAA,EAAK,eAAc,OAAC,MAAG,UAAU,qDAAsD,SAAAA,EAAK,WAAW,EACvGA,EAAK,qBACJ,OAAC,KAAE,UAAU,qDAAsD,SAAAA,EAAK,iBAAiB,EAE1FA,EAAK,gBAAkBA,EAAK,iBAC3B,QAAC,KACC,KAAMY,EAAYZ,EAAK,YAAY,EACnC,OAAO,SACP,IAAI,sBACJ,UAAU,8EAET,UAAAA,EAAK,kBACN,OAAC,OAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OACnD,mBAAC,QACC,EAAE,kUACF,KAAK,UACP,EACF,GACF,GAEJ,EAGDA,EAAK,OAAO,QACX,OAAC,WACC,OAAQA,EAAK,MAAM,IACnB,IAAKA,EAAK,MAAM,KAAO,GACvB,aAAW,EAAAgB,YAAG,kBAAmBR,EAAU,gBAAkB,cAAc,EAC7E,EAGDR,EAAK,cACJ,OAAC,KACC,KAAMA,EAAK,OAASY,EAAYZ,EAAK,MAAM,EAAI,IAC/C,OAAO,SACP,IAAI,sBACJ,aAAW,EAAAgB,YACT,6GACAR,EAAU,gBAAkB,cAC9B,EACA,QAASO,EAER,SAAAf,EAAK,UACR,GAEJ,CAEJ,CAEA,IAAOV,EAAQS",
4
+ "sourcesContent": ["import { Button, Picture } from '@anker-in/headless-ui'\nimport { gaTrack, 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, pageHandle } = 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 function buildRefUrl(url: string) {\n try {\n if (!pageHandle) return url\n const target = new URL(url, window.location.href)\n target.searchParams.set('ref', `${pageHandle}_referral`)\n return target.toString()\n } catch {\n return url\n }\n }\n\n function trackReferralCta() {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'referral',\n button_name: 'referral_cta',\n info: 'Member Floating Window',\n },\n })\n }\n\n return (\n <div className=\"flex flex-col\">\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 mt-[16px] 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 mt-[32px] flex-col gap-[8px]\">\n {copy.howToTitle && <h3 className=\"text-[20px] font-bold leading-[1.2] text-[#080a0f]\">{copy.howToTitle}</h3>}\n {copy.howToDescription && (\n <p className=\"text-[14px] font-bold leading-[1.4] text-[#080A0F]\">{copy.howToDescription}</p>\n )}\n {copy.learnMoreLabel && copy.learnMoreUrl && (\n <a\n href={buildRefUrl(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] w-full', rounded ? 'rounded-[8px]' : 'rounded-none')}\n />\n )}\n\n {copy.ctaButton && (\n <Button\n size=\"base\"\n as=\"a\"\n className=\"mt-[16px]\"\n href={copy.ctaUrl ? buildRefUrl(copy.ctaUrl) : '#'}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n onClick={trackReferralCta}\n >\n {copy.ctaButton}\n </Button>\n )}\n </div>\n )\n}\n\nexport default Referral\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAkDqB,IAAAI,EAAA,6BAlDrBC,EAAgC,iCAChCC,EAA8D,yBAC9DC,EAAsC,kCACtCC,EAAoC,uCACpCC,EAA4B,0CAG5BC,EAA+B,iCAO/B,SAASC,EAAS,CAAE,KAAAC,EAAM,QAAAC,CAAQ,EAAU,CAC1C,KAAM,CAAE,QAAAC,EAAS,WAAAC,EAAY,WAAAC,CAAW,KAAI,yBAAsB,EAC5DC,EAAU,CAAC,CAACH,EACZ,CAAE,MA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AAG,UAAU,qDAAsD,SAAAA,EAAK,WAAW,EACvGA,EAAK,qBACJ,OAAC,KAAE,UAAU,qDAAsD,SAAAA,EAAK,iBAAiB,EAE1FA,EAAK,gBAAkBA,EAAK,iBAC3B,QAAC,KACC,KAAMY,EAAYZ,EAAK,YAAY,EACnC,OAAO,SACP,IAAI,sBACJ,UAAU,8EAET,UAAAA,EAAK,kBACN,OAAC,OAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OACnD,mBAAC,QACC,EAAE,kUACF,KAAK,UACP,EACF,GACF,GAEJ,EAGDA,EAAK,OAAO,QACX,OAAC,WACC,OAAQA,EAAK,MAAM,IACnB,IAAKA,EAAK,MAAM,KAAO,GACvB,aAAW,EAAAgB,YAAG,kBAAmBR,EAAU,gBAAkB,cAAc,EAC7E,EAGDR,EAAK,cACJ,OAAC,UACC,KAAK,OACL,GAAG,IACH,UAAU,YACV,KAAMA,EAAK,OAASY,EAAYZ,EAAK,MAAM,EAAI,IAC/C,OAAO,SACP,IAAI,sBACJ,QAASe,EAER,SAAAf,EAAK,UACR,GAEJ,CAEJ,CAEA,IAAOV,EAAQS",
6
6
  "names": ["Referral_exports", "__export", "Referral_default", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_lib", "import_provider", "import_useReferralOverview", "import_utils", "import_constants", "Referral", "copy", "onClose", "profile", "alpcConfig", "pageHandle", "isLogin", "brand", "currencyCode", "rounded", "data", "cashAvailable", "cashPending", "buildRefUrl", "url", "target", "trackReferralCta", "cn"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{jsx as t,jsxs as c}from"react/jsx-runtime";import{useCallback as y,useEffect as A,useState as l}from"react";import{Checkbox as U,Picture as D,Text as a}from"@anker-in/headless-ui";import{gaTrack as R,classNames as p,useHeadlessContext as B}from"@anker-in/lib";import d 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 O(){if(typeof window>"u")return{register_source:""};const{search:e,href:s}=window.location,n=E(e);return{fbuy_ref_code:d.get("fbuy_ref_code"),ref:d.get("ref_ads"),inviter_code:n.ic??n.inviter_code??d.get("inviter_code"),register_source:n.redirect??d.get("reg_source")??s}}async function j(e){if(typeof window>"u"||!window?.grecaptcha?.execute||!e)return"";try{return await window.grecaptcha.execute(e,{action:"activity"})}catch{return""}}function q({copy:e,email:s}){const{alpcConfig:n,setIsSubscribeSuccess:x,pageHandle:b}=H(),{locale:g}=n,{brand:N,storeDomain:h,recaptchaSitekey:M}=B(),u=I.includes(N),[m,S]=l(e.policyDefaultChecked??!1),[i,_]=l(s??""),[v,o]=l(""),[k,w]=l(""),[L,C]=l(!1);A(()=>{s&&_(s)},[s]);const T=y(async()=>{if(o(""),!i)return o("Please fill in your email");if(!F(i))return o("Invalid email address");if(!m)return o("Please agree to the policy");C(!0);const{register_source:r}=O(),P=await j(M||"");try{const f=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:r,shopify_domain:h,single_brand_subscribe:e.single_brand_subscribe??!0,genre:e.genre??e.dealsType??"",sub_brand_type:e.sub_brand_type??""})})).json();f?.data?.is_new_subscribe?f?.data?.errors?o(f?.data?.errors??"Error occurred"):(w(e.successTips??"Subscribed successfully!"),x(!0),R({event:"ga4Event",event_name:"subscribe",event_parameters:{page_group:e.dealsType??e.genre??"",position:"sticky",info:"Member Floating Window"}})):w(e.subscribedLabel??"You've already subscribed!")}catch{o("Network error")}finally{C(!1)}},[i,m,g,h,e,x]);return c("div",{className:"flex flex-col",children:[t(a,{className:"text-[22px] font-bold leading-[1.2]",html:e.title}),e.desc&&t(a,{className:"text-[16px] mt-[16px] font-bold text-[#1E2024]",html:e.desc}),t("input",{className:p("h-[46px] w-full border mt-[8px] px-[14px] text-[16px] outline-none placeholder:text-[#999]",u?"rounded-[4px]":"rounded-none"),placeholder:e.placeholder,value:i,onChange:r=>{o(""),_(r.target.value.trim())}}),c("div",{className:"flex w-full mt-[8px] items-start gap-[8px]",children:[t(U,{checked:m,onCheckedChange:()=>S(r=>!r),className:"border-[#1d1d1f] mt-[2px]"}),t("label",{className:"text-left text-[14px] font-bold text-[#4A4C56] [&_a]:underline",dangerouslySetInnerHTML:{__html:e.policy??""}})]}),t("button",{className:p("w-full cursor-pointer bg-[#080a0f] mt-[16px] py-[14px] text-[14px] font-[700] text-white disabled:opacity-60",u?"rounded-[4px]":"rounded-none"),disabled:L,onClick:T,children:e.buttonLabel??"Subscribe"}),v&&t("div",{className:"text-left mt-[4px] text-[16px] font-semibold text-[#f84d4f]",children:t(a,{html:v})}),t("div",{className:"text-left mt-[4px] text-[16px] font-semibold text-[#52c41a]",children:t(a,{html:k})}),e.promo&&c("div",{className:"flex mt-[32px] flex-col text-left",children:[c("div",{className:"flex flex-col",children:[e.promo?.title&&t(a,{className:"text-[18px] font-bold leading-[1.2]",html:e.promo.title}),e.promo.description&&t(a,{className:"text-[14px] text-[#080A0F] mt-[8px] font-bold",html:e.promo.description}),e.promo.learnMoreLabel&&e.promo.learnMoreUrl&&c("a",{href:(()=>{try{if(!b)return e.promo.learnMoreUrl;const r=new URL(e.promo.learnMoreUrl,window.location.href);return r.searchParams.set("ref",`${b}_subscribe`),r.toString()}catch{return e.promo.learnMoreUrl}})(),target:"_blank",rel:"noopener noreferrer",className:"flex mt-[8px] items-center gap-[4px] text-[14px] font-bold",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(D,{source:e.promo.image.url,alt:e.promo.image.alt??"",className:p("h-[100px] mt-[8px] w-full object-cover",u?"rounded-[8px]":"rounded-none")})]})]})}export{q as default};
1
+ import{jsx as t,jsxs as c}from"react/jsx-runtime";import{useCallback as y,useEffect as A,useState as i}from"react";import{Button as U,Checkbox as B,Picture as D,Text as a}from"@anker-in/headless-ui";import{gaTrack as R,classNames as C,useHeadlessContext as E}from"@anker-in/lib";import d from"js-cookie";import{parse as F}from"query-string";import{emailValidate as H}from"../../credits/context/utils";import{useMemberPopupContext as I}from"../context/provider";import{ROUNDED_BRANDS as O}from"../../../constants";function j(){if(typeof window>"u")return{register_source:""};const{search:e,href:o}=window.location,n=F(e);return{fbuy_ref_code:d.get("fbuy_ref_code"),ref:d.get("ref_ads"),inviter_code:n.ic??n.inviter_code??d.get("inviter_code"),register_source:n.redirect??d.get("reg_source")??o}}async function q(e){if(typeof window>"u"||!window?.grecaptcha?.execute||!e)return"";try{return await window.grecaptcha.execute(e,{action:"activity"})}catch{return""}}function J({copy:e,email:o}){const{alpcConfig:n,setIsSubscribeSuccess:f,pageHandle:p}=I(),{locale:x}=n,{brand:N,storeDomain:b,recaptchaSitekey:M}=E(),g=O.includes(N),[u,S]=i(e.policyDefaultChecked??!1),[l,h]=i(o??""),[_,s]=i(""),[k,v]=i(""),[L,w]=i(!1);A(()=>{o&&h(o)},[o]);const T=y(async()=>{if(s(""),!l)return s("Please fill in your email");if(!H(l))return s("Invalid email address");if(!u)return s("Please agree to the policy");w(!0);const{register_source:r}=j(),P=await q(M||"");try{const m=await(await fetch("/api/multipass/rainbowbridge/activities",{method:"POST",headers:{"Content-Type":"application/json","current-language":x,"X-Recaptcha-Token":P},body:JSON.stringify({email:l,register_source:r,shopify_domain:b,single_brand_subscribe:e.single_brand_subscribe??!0,genre:e.genre??e.dealsType??"",sub_brand_type:e.sub_brand_type??""})})).json();m?.data?.is_new_subscribe?m?.data?.errors?s(m?.data?.errors??"Error occurred"):(v(e.successTips??"Subscribed successfully!"),f(!0),R({event:"ga4Event",event_name:"subscribe",event_parameters:{page_group:e.dealsType??e.genre??"",position:"sticky",info:"Member Floating Window"}})):v(e.subscribedLabel??"You've already subscribed!")}catch{s("Network error")}finally{w(!1)}},[l,u,x,b,e,f]);return c("div",{className:"flex flex-col",children:[t(a,{className:"text-[22px] font-bold leading-[1.2]",html:e.title}),e.desc&&t(a,{className:"text-[16px] mt-[16px] font-bold text-[#1E2024]",html:e.desc}),t("input",{className:C("h-[46px] w-full border mt-[8px] px-[14px] text-[16px] outline-none placeholder:text-[#999]",g?"rounded-[4px]":"rounded-none"),placeholder:e.placeholder,value:l,onChange:r=>{s(""),h(r.target.value.trim())}}),c("div",{className:"flex w-full mt-[8px] items-start gap-[8px]",children:[t(B,{checked:u,onCheckedChange:()=>S(r=>!r),className:"border-[#1d1d1f] mt-[2px]"}),t("label",{className:"text-left text-[14px] font-bold text-[#4A4C56] [&_a]:underline",dangerouslySetInnerHTML:{__html:e.policy??""}})]}),t(U,{className:"w-full mt-[16px]",loading:L,onClick:T,children:e.buttonLabel??"Subscribe"}),_&&t("div",{className:"text-left mt-[4px] text-[16px] font-semibold text-[#f84d4f]",children:t(a,{html:_})}),t("div",{className:"text-left mt-[4px] text-[16px] font-semibold text-[#52c41a]",children:t(a,{html:k})}),e.promo&&c("div",{className:"flex mt-[32px] flex-col text-left",children:[c("div",{className:"flex flex-col",children:[e.promo?.title&&t(a,{className:"text-[18px] font-bold leading-[1.2]",html:e.promo.title}),e.promo.description&&t(a,{className:"text-[14px] text-[#080A0F] mt-[8px] font-bold",html:e.promo.description}),e.promo.learnMoreLabel&&e.promo.learnMoreUrl&&c("a",{href:(()=>{try{if(!p)return e.promo.learnMoreUrl;const r=new URL(e.promo.learnMoreUrl,window.location.href);return r.searchParams.set("ref",`${p}_subscribe`),r.toString()}catch{return e.promo.learnMoreUrl}})(),target:"_blank",rel:"noopener noreferrer",className:"flex mt-[8px] items-center gap-[4px] text-[14px] font-bold",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(D,{source:e.promo.image.url,alt:e.promo.image.alt??"",className:C("h-[100px] mt-[8px] w-full object-cover",g?"rounded-[8px]":"rounded-none")})]})]})}export{J as default};
2
2
  //# sourceMappingURL=ActivitiesSubscribePanel.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/memberPopup/panels/ActivitiesSubscribePanel.tsx"],
4
- "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Button, Checkbox, Picture, Text } from '@anker-in/headless-ui'\nimport { gaTrack, classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport Cookies from 'js-cookie'\nimport { parse } from 'query-string'\nimport { emailValidate } from '../../credits/context/utils'\nimport { useMemberPopupContext } from '../context/provider'\nimport type { SubscribeModalCopy } from '../type'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\ntype Props = {\n copy: SubscribeModalCopy\n email?: string\n}\n\nfunction getAdCookie() {\n if (typeof window === 'undefined') return { register_source: '' }\n const { search, href } = window.location\n const query = parse(search)\n return {\n fbuy_ref_code: Cookies.get('fbuy_ref_code'),\n ref: Cookies.get('ref_ads'),\n inviter_code: query.ic ?? query.inviter_code ?? Cookies.get('inviter_code'),\n register_source: query.redirect ?? Cookies.get('reg_source') ?? href,\n }\n}\n\nasync function getRecaptchaToken(sitekey: string): Promise<string> {\n if (typeof window === 'undefined' || !window?.grecaptcha?.execute) return ''\n if (!sitekey) return ''\n try {\n return await window.grecaptcha.execute(sitekey, { action: 'activity' })\n } catch {\n return ''\n }\n}\n\nexport default function ActivitiesSubscribeModal({ copy, email: initialEmail }: Props) {\n const { alpcConfig, setIsSubscribeSuccess, pageHandle } = useMemberPopupContext()\n const { locale } = alpcConfig\n const { brand: headlessBrand, storeDomain, recaptchaSitekey } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(headlessBrand)\n const [policy, setPolicy] = useState(copy.policyDefaultChecked ?? false)\n const [email, setEmail] = useState(initialEmail ?? '')\n const [errorMessage, setErrorMessage] = useState('')\n const [successMessage, setSuccessMessage] = useState('')\n const [loading, setLoading] = useState(false)\n\n useEffect(() => {\n if (initialEmail) setEmail(initialEmail)\n }, [initialEmail])\n\n const handleSubmit = useCallback(async () => {\n setErrorMessage('')\n if (!email) return setErrorMessage('Please fill in your email')\n if (!emailValidate(email)) return setErrorMessage('Invalid email address')\n if (!policy) return setErrorMessage('Please agree to the policy')\n\n setLoading(true)\n const { register_source } = getAdCookie()\n const recaptchaToken = await getRecaptchaToken(recaptchaSitekey || '')\n try {\n const response = await fetch('/api/multipass/rainbowbridge/activities', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'current-language': locale,\n 'X-Recaptcha-Token': recaptchaToken,\n },\n body: JSON.stringify({\n email,\n register_source,\n shopify_domain: storeDomain,\n single_brand_subscribe: copy.single_brand_subscribe ?? true,\n genre: copy.genre ?? copy.dealsType ?? '',\n sub_brand_type: copy.sub_brand_type ?? '',\n }),\n })\n const result = await response.json()\n if (!result?.data?.is_new_subscribe) {\n setSuccessMessage(copy.subscribedLabel ?? \"You've already subscribed!\")\n } else if (!result?.data?.errors) {\n setSuccessMessage(copy.successTips ?? 'Subscribed successfully!')\n setIsSubscribeSuccess(true)\n gaTrack({\n event: 'ga4Event',\n event_name: 'subscribe',\n event_parameters: {\n page_group: copy.dealsType ?? copy.genre ?? '',\n position: 'sticky',\n info: 'Member Floating Window',\n },\n })\n } else {\n setErrorMessage(result?.data?.errors ?? 'Error occurred')\n }\n } catch {\n setErrorMessage('Network error')\n } finally {\n setLoading(false)\n }\n }, [email, policy, locale, storeDomain, copy, setIsSubscribeSuccess])\n\n return (\n <div className=\"flex flex-col\">\n <Text className=\"text-[22px] font-bold leading-[1.2]\" html={copy.title} />\n {copy.desc && <Text className=\"text-[16px] mt-[16px] font-bold text-[#1E2024]\" html={copy.desc} />}\n\n <input\n className={cn(\n 'h-[46px] w-full border mt-[8px] px-[14px] text-[16px] outline-none placeholder:text-[#999]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n placeholder={copy.placeholder}\n value={email}\n onChange={e => {\n setErrorMessage('')\n setEmail(e.target.value.trim())\n }}\n />\n\n <div className=\"flex w-full mt-[8px] items-start gap-[8px]\">\n <Checkbox checked={policy} onCheckedChange={() => setPolicy(v => !v)} className=\"border-[#1d1d1f] mt-[2px]\" />\n <label\n className=\"text-left text-[14px] font-bold text-[#4A4C56] [&_a]:underline\"\n dangerouslySetInnerHTML={{ __html: copy.policy ?? '' }}\n />\n </div>\n\n <button\n className={cn(\n 'w-full cursor-pointer bg-[#080a0f] mt-[16px] py-[14px] text-[14px] font-[700] text-white disabled:opacity-60',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={loading}\n onClick={handleSubmit}\n >\n {copy.buttonLabel ?? 'Subscribe'}\n </button>\n\n {errorMessage && (\n <div className=\"text-left mt-[4px] text-[16px] font-semibold text-[#f84d4f]\">\n <Text html={errorMessage} />\n </div>\n )}\n <div className=\"text-left mt-[4px] text-[16px] font-semibold text-[#52c41a]\">\n <Text html={successMessage} />\n </div>\n\n {copy.promo && (\n <div className=\"flex mt-[32px] flex-col text-left\">\n <div className=\"flex flex-col\">\n {copy.promo?.title && <Text className=\"text-[18px] font-bold leading-[1.2]\" html={copy.promo.title} />}\n {copy.promo.description && (\n <Text className=\"text-[14px] text-[#080A0F] mt-[8px] font-bold\" html={copy.promo.description} />\n )}\n {copy.promo.learnMoreLabel && copy.promo.learnMoreUrl && (\n <a\n href={(() => {\n try {\n if (!pageHandle) return copy.promo!.learnMoreUrl!\n const url = new URL(copy.promo!.learnMoreUrl!, window.location.href)\n url.searchParams.set('ref', `${pageHandle}_subscribe`)\n return url.toString()\n } catch {\n return copy.promo!.learnMoreUrl!\n }\n })()}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"flex mt-[8px] items-center gap-[4px] text-[14px] font-bold\"\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": "AAyGM,cAAAA,EAgBA,QAAAC,MAhBA,oBAzGN,OAAS,eAAAC,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QACjD,OAAiB,YAAAC,EAAU,WAAAC,EAAS,QAAAC,MAAY,wBAChD,OAAS,WAAAC,EAAS,cAAcC,EAAI,sBAAAC,MAA0B,gBAC9D,OAAOC,MAAa,YACpB,OAAS,SAAAC,MAAa,eACtB,OAAS,iBAAAC,MAAqB,8BAC9B,OAAS,yBAAAC,MAA6B,sBAEtC,OAAS,kBAAAC,MAAsB,qBAO/B,SAASC,GAAc,C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ACN,OAAO1B,EAAK,MAAO,YACrB,CACF,GAAG,EACH,OAAO,SACP,IAAI,sBACJ,UAAU,6DAET,UAAAA,EAAK,MAAM,eACZvB,EAAC,OAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OACnD,SAAAA,EAAC,QACC,EAAE,kUACF,KAAK,UACP,EACF,GACF,GAEJ,EACCuB,EAAK,MAAM,OAAO,KACjBvB,EAACM,EAAA,CACC,OAAQiB,EAAK,MAAM,MAAM,IACzB,IAAKA,EAAK,MAAM,MAAM,KAAO,GAC7B,UAAWd,EAAG,yCAA0CuB,EAAU,gBAAkB,cAAc,EACpG,GAEJ,GAEJ,CAEJ",
6
- "names": ["jsx", "jsxs", "useCallback", "useEffect", "useState", "Checkbox", "Picture", "Text", "gaTrack", "cn", "useHeadlessContext", "Cookies", "parse", "emailValidate", "useMemberPopupContext", "ROUNDED_BRANDS", "getAdCookie", "search", "href", "query", "getRecaptchaToken", "sitekey", "ActivitiesSubscribeModal", "copy", "initialEmail", "alpcConfig", "setIsSubscribeSuccess", "pageHandle", "locale", "headlessBrand", "storeDomain", "recaptchaSitekey", "rounded", "policy", "setPolicy", "email", "setEmail", "errorMessage", "setErrorMessage", "successMessage", "setSuccessMessage", "loading", "setLoading", "handleSubmit", "register_source", "recaptchaToken", "result", "e", "v", "url"]
4
+ "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Button, Checkbox, Picture, Text } from '@anker-in/headless-ui'\nimport { gaTrack, classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport Cookies from 'js-cookie'\nimport { parse } from 'query-string'\nimport { emailValidate } from '../../credits/context/utils'\nimport { useMemberPopupContext } from '../context/provider'\nimport type { SubscribeModalCopy } from '../type'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\ntype Props = {\n copy: SubscribeModalCopy\n email?: string\n}\n\nfunction getAdCookie() {\n if (typeof window === 'undefined') return { register_source: '' }\n const { search, href } = window.location\n const query = parse(search)\n return {\n fbuy_ref_code: Cookies.get('fbuy_ref_code'),\n ref: Cookies.get('ref_ads'),\n inviter_code: query.ic ?? query.inviter_code ?? Cookies.get('inviter_code'),\n register_source: query.redirect ?? Cookies.get('reg_source') ?? href,\n }\n}\n\nasync function getRecaptchaToken(sitekey: string): Promise<string> {\n if (typeof window === 'undefined' || !window?.grecaptcha?.execute) return ''\n if (!sitekey) return ''\n try {\n return await window.grecaptcha.execute(sitekey, { action: 'activity' })\n } catch {\n return ''\n }\n}\n\nexport default function ActivitiesSubscribeModal({ copy, email: initialEmail }: Props) {\n const { alpcConfig, setIsSubscribeSuccess, pageHandle } = useMemberPopupContext()\n const { locale } = alpcConfig\n const { brand: headlessBrand, storeDomain, recaptchaSitekey } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(headlessBrand)\n const [policy, setPolicy] = useState(copy.policyDefaultChecked ?? false)\n const [email, setEmail] = useState(initialEmail ?? '')\n const [errorMessage, setErrorMessage] = useState('')\n const [successMessage, setSuccessMessage] = useState('')\n const [loading, setLoading] = useState(false)\n\n useEffect(() => {\n if (initialEmail) setEmail(initialEmail)\n }, [initialEmail])\n\n const handleSubmit = useCallback(async () => {\n setErrorMessage('')\n if (!email) return setErrorMessage('Please fill in your email')\n if (!emailValidate(email)) return setErrorMessage('Invalid email address')\n if (!policy) return setErrorMessage('Please agree to the policy')\n\n setLoading(true)\n const { register_source } = getAdCookie()\n const recaptchaToken = await getRecaptchaToken(recaptchaSitekey || '')\n try {\n const response = await fetch('/api/multipass/rainbowbridge/activities', {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'current-language': locale,\n 'X-Recaptcha-Token': recaptchaToken,\n },\n body: JSON.stringify({\n email,\n register_source,\n shopify_domain: storeDomain,\n single_brand_subscribe: copy.single_brand_subscribe ?? true,\n genre: copy.genre ?? copy.dealsType ?? '',\n sub_brand_type: copy.sub_brand_type ?? '',\n }),\n })\n const result = await response.json()\n if (!result?.data?.is_new_subscribe) {\n setSuccessMessage(copy.subscribedLabel ?? \"You've already subscribed!\")\n } else if (!result?.data?.errors) {\n setSuccessMessage(copy.successTips ?? 'Subscribed successfully!')\n setIsSubscribeSuccess(true)\n gaTrack({\n event: 'ga4Event',\n event_name: 'subscribe',\n event_parameters: {\n page_group: copy.dealsType ?? copy.genre ?? '',\n position: 'sticky',\n info: 'Member Floating Window',\n },\n })\n } else {\n setErrorMessage(result?.data?.errors ?? 'Error occurred')\n }\n } catch {\n setErrorMessage('Network error')\n } finally {\n setLoading(false)\n }\n }, [email, policy, locale, storeDomain, copy, setIsSubscribeSuccess])\n\n return (\n <div className=\"flex flex-col\">\n <Text className=\"text-[22px] font-bold leading-[1.2]\" html={copy.title} />\n {copy.desc && <Text className=\"text-[16px] mt-[16px] font-bold text-[#1E2024]\" html={copy.desc} />}\n\n <input\n className={cn(\n 'h-[46px] w-full border mt-[8px] px-[14px] text-[16px] outline-none placeholder:text-[#999]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n placeholder={copy.placeholder}\n value={email}\n onChange={e => {\n setErrorMessage('')\n setEmail(e.target.value.trim())\n }}\n />\n\n <div className=\"flex w-full mt-[8px] items-start gap-[8px]\">\n <Checkbox checked={policy} onCheckedChange={() => setPolicy(v => !v)} className=\"border-[#1d1d1f] mt-[2px]\" />\n <label\n className=\"text-left text-[14px] font-bold text-[#4A4C56] [&_a]:underline\"\n dangerouslySetInnerHTML={{ __html: copy.policy ?? '' }}\n />\n </div>\n\n <Button className={'w-full mt-[16px]'} loading={loading} onClick={handleSubmit}>\n {copy.buttonLabel ?? 'Subscribe'}\n </Button>\n\n {errorMessage && (\n <div className=\"text-left mt-[4px] text-[16px] font-semibold text-[#f84d4f]\">\n <Text html={errorMessage} />\n </div>\n )}\n <div className=\"text-left mt-[4px] text-[16px] font-semibold text-[#52c41a]\">\n <Text html={successMessage} />\n </div>\n\n {copy.promo && (\n <div className=\"flex mt-[32px] flex-col text-left\">\n <div className=\"flex flex-col\">\n {copy.promo?.title && <Text className=\"text-[18px] font-bold leading-[1.2]\" html={copy.promo.title} />}\n {copy.promo.description && (\n <Text className=\"text-[14px] text-[#080A0F] mt-[8px] font-bold\" html={copy.promo.description} />\n )}\n {copy.promo.learnMoreLabel && copy.promo.learnMoreUrl && (\n <a\n href={(() => {\n try {\n if (!pageHandle) return copy.promo!.learnMoreUrl!\n const url = new URL(copy.promo!.learnMoreUrl!, window.location.href)\n url.searchParams.set('ref', `${pageHandle}_subscribe`)\n return url.toString()\n } catch {\n return copy.promo!.learnMoreUrl!\n }\n })()}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"flex mt-[8px] items-center gap-[4px] text-[14px] font-bold\"\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": "AAyGM,cAAAA,EAgBA,QAAAC,MAhBA,oBAzGN,OAAS,eAAAC,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QACjD,OAAS,UAAAC,EAAQ,YAAAC,EAAU,WAAAC,EAAS,QAAAC,MAAY,wBAChD,OAAS,WAAAC,EAAS,cAAcC,EAAI,sBAAAC,MAA0B,gBAC9D,OAAOC,MAAa,YACpB,OAAS,SAAAC,MAAa,eACtB,O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OAAA0B,EAAI,aAAa,IAAI,MAAO,GAAGtB,CAAU,YAAY,EAC9CsB,EAAI,SAAS,CACtB,MAAQ,CACN,OAAO1B,EAAK,MAAO,YACrB,CACF,GAAG,EACH,OAAO,SACP,IAAI,sBACJ,UAAU,6DAET,UAAAA,EAAK,MAAM,eACZxB,EAAC,OAAI,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OACnD,SAAAA,EAAC,QACC,EAAE,kUACF,KAAK,UACP,EACF,GACF,GAEJ,EACCwB,EAAK,MAAM,OAAO,KACjBxB,EAACO,EAAA,CACC,OAAQiB,EAAK,MAAM,MAAM,IACzB,IAAKA,EAAK,MAAM,MAAM,KAAO,GAC7B,UAAWd,EAAG,yCAA0CuB,EAAU,gBAAkB,cAAc,EACpG,GAEJ,GAEJ,CAEJ",
6
+ "names": ["jsx", "jsxs", "useCallback", "useEffect", "useState", "Button", "Checkbox", "Picture", "Text", "gaTrack", "cn", "useHeadlessContext", "Cookies", "parse", "emailValidate", "useMemberPopupContext", "ROUNDED_BRANDS", "getAdCookie", "search", "href", "query", "getRecaptchaToken", "sitekey", "ActivitiesSubscribeModal", "copy", "initialEmail", "alpcConfig", "setIsSubscribeSuccess", "pageHandle", "locale", "headlessBrand", "storeDomain", "recaptchaSitekey", "rounded", "policy", "setPolicy", "email", "setEmail", "errorMessage", "setErrorMessage", "successMessage", "setSuccessMessage", "loading", "setLoading", "handleSubmit", "register_source", "recaptchaToken", "result", "e", "v", "url"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{jsx as t,jsxs as s}from"react/jsx-runtime";import{useCallback as P,useEffect as F,useState as f}from"react";import{Text as r,Button as w}from"@anker-in/headless-ui";import{gaTrack as V,useHeadlessContext as j,classNames as x}from"@anker-in/lib";import{AlpcErrorCode as a}from"../../../credits/context/const";import{useRedeemCoupon as H}from"./hooks/useRedeemCoupon";import O from"../../../credits/context/hooks/useCopy";import{ROUNDED_BRANDS as W}from"../../../../constants";function $({onClose:E,item:I,copy:R,onError:g}){const{itemTitle:q,itemCredits:_,itemImage:c,itemValue:C,itemRules:m,redeemId:p,userId:v,alpcConfig:k}=I,{redeemModal:e,creditUnit:B}=R,D=B??"pts",[i,b]=f(),[N,d]=f(""),[L,l]=f(!1),{copy:T,copied:y}=O(),{brand:S}=j(),u=W.includes(S),{isMutating:U,trigger:h}=H(k),A=P(async()=>{d("");const{data:o}=await h({user_id:v,rule_id:p});if(!o){d(e.commonError);return}if(o.data?.success)b(o.data.coupon_code),V({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"redeem_coupon_success",info:"Member Floating Window"}});else{let n=e.commonError;o.code===a.CodeLpcShopifyCouponRuleRedeemLimit?(n=e.redeemLimitError,l(!0)):o.code===a.CodeLpcRuleInventoryNotEnough?(n=e.inventoryNotEnough,l(!0)):o.code===a.CodeLpcNotEnoughCredits?(n=e.creditsNotEnough,l(!0)):o.code===a.CodeCrossSiteError&&(n=e.crossSiteError,l(!0)),d(n),g?.(o.code)}},[h,v,p,e,g]);F(()=>{b(void 0),d(""),l(!1)},[p]);const M=m&&m.length>0&&t("div",{className:"w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]",children:t("ul",{className:"ml-4 grid grid-flow-row gap-[4px]",children:m?.map((o,n)=>t("li",{className:"list-disc",children:t(r,{html:o,className:"font-bold"})},n))})});return s("div",{className:"flex flex-col",children:[c?.url&&t("div",{className:"relative w-full px-[24px]",children:s("div",{className:x("relative mx-auto overflow-hidden",u?"rounded-[8px]":"rounded-none"),children:[t("img",{src:c.url,alt:c.alt??"",className:"mx-auto h-[140px] w-full object-cover"}),C&&s("div",{className:"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white",children:[C,e.off?` ${e.off}`:""]})]})}),!i&&s("div",{className:"flex flex-col gap-[16px] px-[24px] py-[20px]",children:[s("p",{className:"text-center text-[24px] font-[700] text-[#1d1d1f]",children:[_," ",D]}),M]}),i&&s("div",{className:"flex mt-[16px] flex-col gap-[8px] text-center",children:[s("div",{className:"flex items-center justify-center gap-[10px]",children:[t("span",{className:"text-[24px] font-[700]",children:i}),t("button",{className:"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none",disabled:y,onClick:()=>T(i),children:y?e.copiedLabel??"Copied":e.copyLabel??"Copy"})]}),t(r,{className:"text-[20px] font-[700]",html:e.successTitle}),t(r,{className:"text-[14px] font-[700] text-[#6d6d6f]",html:e.successDesc}),t(w,{className:x("w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]",u?"rounded-[4px]":"rounded-none"),onClick:()=>{e.successButtonUrl&&(window.location.href=e.successButtonUrl),E()},children:e.successButton})]}),!i&&s("div",{className:"sticky bottom-0 bg-white border-t border-[#e5e5e5] pt-[10px]",children:[s("div",{className:"flex flex-col gap-[8px] text-center",children:[t(r,{className:"block text-[16px] font-[700] leading-[1.3]",html:e.confirmTitle}),t(w,{className:x("w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]",u?"rounded-[4px]":"rounded-none"),disabled:L,loading:U,onClick:A,children:e.confirmButton})]}),N&&t(r,{className:"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]",html:N})]})]})}export{$ as default};
1
+ import{jsx as t,jsxs as s}from"react/jsx-runtime";import{useCallback as U,useEffect as M,useState as u}from"react";import{Text as r,Button as y}from"@anker-in/headless-ui";import{gaTrack as P,useHeadlessContext as F,classNames as V}from"@anker-in/lib";import{AlpcErrorCode as d}from"../../../credits/context/const";import{useRedeemCoupon as j}from"./hooks/useRedeemCoupon";import H from"../../../credits/context/hooks/useCopy";import{ROUNDED_BRANDS as O}from"../../../../constants";function W({onClose:$,item:h,copy:E,onError:f}){const{itemTitle:q,itemCredits:w,itemImage:c,itemValue:x,itemRules:m,redeemId:p,userId:g,alpcConfig:I}=h,{redeemModal:e,creditUnit:R}=E,_=R??"pts",[i,C]=u(),[v,a]=u(""),[k,l]=u(!1),{copy:B,copied:N}=H(),{brand:D}=F(),L=O.includes(D),{isMutating:T,trigger:b}=j(I),S=U(async()=>{a("");const{data:o}=await b({user_id:g,rule_id:p});if(!o){a(e.commonError);return}if(o.data?.success)C(o.data.coupon_code),P({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"consume_credits",button_name:"redeem_coupon_success",info:"Member Floating Window"}});else{let n=e.commonError;o.code===d.CodeLpcShopifyCouponRuleRedeemLimit?(n=e.redeemLimitError,l(!0)):o.code===d.CodeLpcRuleInventoryNotEnough?(n=e.inventoryNotEnough,l(!0)):o.code===d.CodeLpcNotEnoughCredits?(n=e.creditsNotEnough,l(!0)):o.code===d.CodeCrossSiteError&&(n=e.crossSiteError,l(!0)),a(n),f?.(o.code)}},[b,g,p,e,f]);M(()=>{C(void 0),a(""),l(!1)},[p]);const A=m&&m.length>0&&t("div",{className:"w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]",children:t("ul",{className:"ml-4 grid grid-flow-row gap-[4px]",children:m?.map((o,n)=>t("li",{className:"list-disc",children:t(r,{html:o,className:"font-bold"})},n))})});return s("div",{className:"flex flex-col",children:[c?.url&&t("div",{className:"relative w-full px-[24px]",children:s("div",{className:V("relative mx-auto overflow-hidden",L?"rounded-[8px]":"rounded-none"),children:[t("img",{src:c.url,alt:c.alt??"",className:"mx-auto h-[140px] w-full object-cover"}),x&&s("div",{className:"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white",children:[x,e.off?` ${e.off}`:""]})]})}),!i&&s("div",{className:"flex flex-col gap-[16px] px-[24px] py-[20px]",children:[s("p",{className:"text-center text-[24px] font-[700] text-[#1d1d1f]",children:[w," ",_]}),A]}),i&&s("div",{className:"flex mt-[16px] flex-col gap-[8px] text-center",children:[s("div",{className:"flex items-center justify-center gap-[10px]",children:[t("span",{className:"text-[24px] font-[700]",children:i}),t("button",{className:"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none",disabled:N,onClick:()=>B(i),children:N?e.copiedLabel??"Copied":e.copyLabel??"Copy"})]}),t(r,{className:"text-[20px] font-[700]",html:e.successTitle}),t(r,{className:"text-[14px] font-[700] text-[#6d6d6f]",html:e.successDesc}),t(y,{as:"a",href:e.successButtonUrl,className:"w-full",children:e.successButton})]}),!i&&s("div",{className:"sticky bottom-0 bg-white border-t border-[#e5e5e5] pt-[10px]",children:[s("div",{className:"flex flex-col gap-[8px] text-center",children:[t(r,{className:"block text-[16px] font-[700] leading-[1.3]",html:e.confirmTitle}),t(y,{className:"w-full",disabled:k,loading:T,onClick:S,children:e.confirmButton})]}),v&&t(r,{className:"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]",html:v})]})]})}export{W as default};
2
2
  //# sourceMappingURL=RedeemCouponPanel.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/ConsumeCredits/RedeemCouponPanel.tsx"],
4
- "sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\nimport { Text, Button } from '@anker-in/headless-ui'\nimport { gaTrack, useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport { AlpcErrorCode } from '../../../credits/context/const'\nimport { useRedeemCoupon } from './hooks/useRedeemCoupon'\nimport useCopy from '../../../credits/context/hooks/useCopy'\nimport type { ConsumeCreditsopy, AlpcConfig } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype RedeemCouponItem = {\n itemTitle: string\n itemCredits: number\n itemImage?: { url: string; alt?: string }\n itemValue?: string\n itemRules?: string[]\n redeemId: number\n userId?: string\n alpcConfig: AlpcConfig\n}\n\ntype Props = {\n onClose: () => void\n item: RedeemCouponItem\n copy: ConsumeCreditsopy\n onError?: (code: number) => void\n}\n\nexport default function RedeemCouponPanel({ onClose, item, copy, onError }: Props) {\n const { itemTitle, itemCredits, itemImage, itemValue, itemRules, redeemId, userId, alpcConfig } = item\n const { redeemModal, creditUnit } = copy\n const pointUnit = creditUnit ?? 'pts'\n const [couponCode, setCouponCode] = useState<string>()\n const [errorInfo, setErrorInfo] = useState('')\n const [disabled, setDisabled] = useState(false)\n const { copy: copyText, copied } = useCopy()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const { isMutating: loading, trigger } = useRedeemCoupon(alpcConfig)\n\n const handleConfirm = useCallback(async () => {\n setErrorInfo('')\n const { data } = await trigger({ user_id: userId, rule_id: redeemId })\n if (!data) {\n setErrorInfo(redeemModal.commonError)\n return\n }\n if (data.data?.success) {\n setCouponCode(data.data.coupon_code)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem_coupon_success',\n info: 'Member Floating Window',\n },\n })\n } else {\n let msg = redeemModal.commonError\n if (data.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n msg = redeemModal.redeemLimitError\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n msg = redeemModal.inventoryNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n msg = redeemModal.creditsNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeCrossSiteError) {\n msg = redeemModal.crossSiteError\n setDisabled(true)\n }\n setErrorInfo(msg)\n onError?.(data.code)\n }\n }, [trigger, userId, redeemId, redeemModal, onError])\n\n useEffect(() => {\n setCouponCode(undefined)\n setErrorInfo('')\n setDisabled(false)\n }, [redeemId])\n\n const rulesSection = itemRules && itemRules.length > 0 && (\n <div className=\"w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]\">\n <ul className=\"ml-4 grid grid-flow-row gap-[4px]\">\n {itemRules?.map((text, index) => (\n <li className=\"list-disc\" key={index}>\n <Text html={text} className=\"font-bold\" />\n </li>\n ))}\n </ul>\n </div>\n )\n\n return (\n <div className=\"flex flex-col\">\n {itemImage?.url && (\n <div className=\"relative w-full px-[24px]\">\n <div className={cn('relative mx-auto overflow-hidden', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <img src={itemImage.url} alt={itemImage.alt ?? ''} className=\"mx-auto h-[140px] w-full object-cover\" />\n {itemValue && (\n <div className=\"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white\">\n {itemValue}\n {redeemModal.off ? ` ${redeemModal.off}` : ''}\n </div>\n )}\n </div>\n </div>\n )}\n\n {!couponCode && (\n <div className=\"flex flex-col gap-[16px] px-[24px] py-[20px]\">\n <p className=\"text-center text-[24px] font-[700] text-[#1d1d1f]\">\n {itemCredits} {pointUnit}\n </p>\n {rulesSection}\n </div>\n )}\n\n {couponCode && (\n <div className=\"flex mt-[16px] flex-col gap-[8px] text-center\">\n <div className=\"flex items-center justify-center gap-[10px]\">\n <span className=\"text-[24px] font-[700]\">{couponCode}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none\"\n disabled={copied}\n onClick={() => copyText(couponCode)}\n >\n {copied ? (redeemModal.copiedLabel ?? 'Copied') : (redeemModal.copyLabel ?? 'Copy')}\n </button>\n </div>\n <Text className=\"text-[20px] font-[700]\" html={redeemModal.successTitle} />\n <Text className=\"text-[14px] font-[700] text-[#6d6d6f]\" html={redeemModal.successDesc} />\n <Button\n className={cn(\n 'w-full py-[12px] text-[14px] font-[700] text-white bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n onClick={() => {\n if (redeemModal.successButtonUrl) window.location.href = redeemModal.successButtonUrl\n onClose()\n }}\n >\n {redeemModal.successButton}\n </Button>\n </div>\n )}\n\n {!couponCode && (\n <div className=\"sticky bottom-0 bg-white border-t border-[#e5e5e5] pt-[10px]\">\n <div className=\"flex flex-col gap-[8px] text-center\">\n <Text className=\"block text-[16px] font-[700] leading-[1.3]\" html={redeemModal.confirmTitle} />\n <Button\n className={cn(\n 'w-full py-[12px] text-[14px] font-[700] text-white disabled:opacity-60 bg-[#080a0f]',\n rounded ? 'rounded-[4px]' : 'rounded-none'\n )}\n disabled={disabled}\n loading={loading}\n onClick={handleConfirm}\n >\n {redeemModal.confirmButton}\n </Button>\n </div>\n\n {errorInfo && (\n <Text className=\"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]\" html={errorInfo} />\n )}\n </div>\n )}\n </div>\n )\n}\n"],
5
- "mappings": "AAyFY,cAAAA,EAcE,QAAAC,MAdF,oBAzFZ,OAAS,eAAAC,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QACjD,OAAS,QAAAC,EAAM,UAAAC,MAAc,wBAC7B,OAAS,WAAAC,EAAS,sBAAAC,EAAoB,cAAcC,MAAU,gBAC9D,OAAS,iBAAAC,MAAqB,iCAC9B,OAAS,mBAAAC,MAAuB,0BAChC,OAAOC,MAAa,yCAEpB,OAAS,kBAAAC,MAAsB,wBAoBhB,SAARC,EAAmC,CAAE,QAAAC,EAAS,KAAAC,EAAM,KAAAC,EAAM,QAAAC,CAAQ,EAAU,CACjF,KAAM,CAAE,UAAAC,EAAW,YAAAC,EAAa,UAAAC,EAAW,UAAAC,EAAW,UAAAC,EAAW,SAAAC,EAAU,OAAAC,EAAQ,WAAAC,CAAW,EAAIV,EAC5F,CAAE,YAAAW,EAAa,WAAAC,CAAW,EAAIX,EAC9BY,EAAYD,GAAc,MAC1B,CAACE,EAAYC,CAAa,EAAI3B,EAAiB,EAC/C,CAAC4B,EAAWC,CAAY,EAAI7B,EAAS,EAAE,EACvC,CAAC8B,EAAUC,CAAW,EAAI/B,EAAS,EAAK,EACxC,CAAE,KAAMgC,EAAU,OAAAC,CAAO,EAAIzB,EAAQ,EACrC,CAAE,MAAA0B,CAAM,EAAI9B,EAAmB,EAC/B+B,EAAU1B,EAAe,SAASyB,CAAK,EAEvC,CAAE,WAAYE,EAAS,QAAAC,CAAQ,EAAI9B,EAAgBe,CAAU,EAE7DgB,EAAgBxC,EAAY,SAAY,CAC5C+B,EAAa,EAAE,EACf,KAAM,CAAE,KAAAU,CAAK,EAAI,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, useState } from 'react'\nimport { Text, Button } from '@anker-in/headless-ui'\nimport { gaTrack, useHeadlessContext, classNames as cn } from '@anker-in/lib'\nimport { AlpcErrorCode } from '../../../credits/context/const'\nimport { useRedeemCoupon } from './hooks/useRedeemCoupon'\nimport useCopy from '../../../credits/context/hooks/useCopy'\nimport type { ConsumeCreditsopy, AlpcConfig } from '../../type'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype RedeemCouponItem = {\n itemTitle: string\n itemCredits: number\n itemImage?: { url: string; alt?: string }\n itemValue?: string\n itemRules?: string[]\n redeemId: number\n userId?: string\n alpcConfig: AlpcConfig\n}\n\ntype Props = {\n onClose: () => void\n item: RedeemCouponItem\n copy: ConsumeCreditsopy\n onError?: (code: number) => void\n}\n\nexport default function RedeemCouponPanel({ onClose, item, copy, onError }: Props) {\n const { itemTitle, itemCredits, itemImage, itemValue, itemRules, redeemId, userId, alpcConfig } = item\n const { redeemModal, creditUnit } = copy\n const pointUnit = creditUnit ?? 'pts'\n const [couponCode, setCouponCode] = useState<string>()\n const [errorInfo, setErrorInfo] = useState('')\n const [disabled, setDisabled] = useState(false)\n const { copy: copyText, copied } = useCopy()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const { isMutating: loading, trigger } = useRedeemCoupon(alpcConfig)\n\n const handleConfirm = useCallback(async () => {\n setErrorInfo('')\n const { data } = await trigger({ user_id: userId, rule_id: redeemId })\n if (!data) {\n setErrorInfo(redeemModal.commonError)\n return\n }\n if (data.data?.success) {\n setCouponCode(data.data.coupon_code)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n position: 'consume_credits',\n button_name: 'redeem_coupon_success',\n info: 'Member Floating Window',\n },\n })\n } else {\n let msg = redeemModal.commonError\n if (data.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n msg = redeemModal.redeemLimitError\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n msg = redeemModal.inventoryNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n msg = redeemModal.creditsNotEnough\n setDisabled(true)\n } else if (data.code === AlpcErrorCode.CodeCrossSiteError) {\n msg = redeemModal.crossSiteError\n setDisabled(true)\n }\n setErrorInfo(msg)\n onError?.(data.code)\n }\n }, [trigger, userId, redeemId, redeemModal, onError])\n\n useEffect(() => {\n setCouponCode(undefined)\n setErrorInfo('')\n setDisabled(false)\n }, [redeemId])\n\n const rulesSection = itemRules && itemRules.length > 0 && (\n <div className=\"w-full text-[16px] font-bold leading-[1.4] text-[#6D6D6F] md:mt-[12px] md:text-[14px]\">\n <ul className=\"ml-4 grid grid-flow-row gap-[4px]\">\n {itemRules?.map((text, index) => (\n <li className=\"list-disc\" key={index}>\n <Text html={text} className=\"font-bold\" />\n </li>\n ))}\n </ul>\n </div>\n )\n\n return (\n <div className=\"flex flex-col\">\n {itemImage?.url && (\n <div className=\"relative w-full px-[24px]\">\n <div className={cn('relative mx-auto overflow-hidden', rounded ? 'rounded-[8px]' : 'rounded-none')}>\n <img src={itemImage.url} alt={itemImage.alt ?? ''} className=\"mx-auto h-[140px] w-full object-cover\" />\n {itemValue && (\n <div className=\"absolute bottom-[20px] left-[20px] text-[32px] font-[800] leading-none text-white\">\n {itemValue}\n {redeemModal.off ? ` ${redeemModal.off}` : ''}\n </div>\n )}\n </div>\n </div>\n )}\n\n {!couponCode && (\n <div className=\"flex flex-col gap-[16px] px-[24px] py-[20px]\">\n <p className=\"text-center text-[24px] font-[700] text-[#1d1d1f]\">\n {itemCredits} {pointUnit}\n </p>\n {rulesSection}\n </div>\n )}\n\n {couponCode && (\n <div className=\"flex mt-[16px] flex-col gap-[8px] text-center\">\n <div className=\"flex items-center justify-center gap-[10px]\">\n <span className=\"text-[24px] font-[700]\">{couponCode}</span>\n <button\n className=\"cursor-pointer text-[14px] font-[700] underline disabled:pointer-events-none\"\n disabled={copied}\n onClick={() => copyText(couponCode)}\n >\n {copied ? (redeemModal.copiedLabel ?? 'Copied') : (redeemModal.copyLabel ?? 'Copy')}\n </button>\n </div>\n <Text className=\"text-[20px] font-[700]\" html={redeemModal.successTitle} />\n <Text className=\"text-[14px] font-[700] text-[#6d6d6f]\" html={redeemModal.successDesc} />\n <Button as=\"a\" href={redeemModal.successButtonUrl} className=\"w-full\">\n {redeemModal.successButton}\n </Button>\n </div>\n )}\n\n {!couponCode && (\n <div className=\"sticky bottom-0 bg-white border-t border-[#e5e5e5] pt-[10px]\">\n <div className=\"flex flex-col gap-[8px] text-center\">\n <Text className=\"block text-[16px] font-[700] leading-[1.3]\" html={redeemModal.confirmTitle} />\n <Button className=\"w-full\" disabled={disabled} loading={loading} onClick={handleConfirm}>\n {redeemModal.confirmButton}\n </Button>\n </div>\n\n {errorInfo && (\n <Text className=\"mt-[8px] text-center text-[14px] font-[700] text-[#ff0000]\" html={errorInfo} />\n )}\n </div>\n )}\n </div>\n )\n}\n"],
5
+ "mappings": "AAyFY,cAAAA,EAcE,QAAAC,MAdF,oBAzFZ,OAAS,eAAAC,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QACjD,OAAS,QAAAC,EAAM,UAAAC,MAAc,wBAC7B,OAAS,WAAAC,EAAS,sBAAAC,EAAoB,cAAcC,MAAU,gBAC9D,OAAS,iBAAAC,MAAqB,iCAC9B,OAAS,mBAAAC,MAAuB,0BAChC,OAAOC,MAAa,yCAEpB,OAAS,kBAAAC,MAAsB,wBAoBhB,SAARC,EAAmC,CAAE,QAAAC,EAAS,KAAAC,EAAM,KAAAC,EAAM,QAAAC,CAAQ,EAAU,CACjF,KAAM,CAAE,UAAAC,EAAW,YAAAC,EAAa,UAAAC,EAAW,UAAAC,EAAW,UAAAC,EAAW,SAAAC,EAAU,OAAAC,EAAQ,WAAAC,CAAW,EAAIV,EAC5F,CAAE,YAAAW,EAAa,WAAAC,CAAW,EAAIX,EAC9BY,EAAYD,GAAc,MAC1B,CAACE,EAAYC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AAC,OAAI,UAAU,sCACb,UAAAD,EAACK,EAAA,CAAK,UAAU,6CAA6C,KAAMsB,EAAY,aAAc,EAC7F3B,EAACM,EAAA,CAAO,UAAU,SAAS,SAAU4B,EAAU,QAASM,EAAS,QAASE,EACvE,SAAAf,EAAY,cACf,GACF,EAECK,GACChC,EAACK,EAAA,CAAK,UAAU,6DAA6D,KAAM2B,EAAW,GAElG,GAEJ,CAEJ",
6
6
  "names": ["jsx", "jsxs", "useCallback", "useEffect", "useState", "Text", "Button", "gaTrack", "useHeadlessContext", "cn", "AlpcErrorCode", "useRedeemCoupon", "useCopy", "ROUNDED_BRANDS", "RedeemCouponPanel", "onClose", "item", "copy", "onError", "itemTitle", "itemCredits", "itemImage", "itemValue", "itemRules", "redeemId", "userId", "alpcConfig", "redeemModal", "creditUnit", "pointUnit", "couponCode", "setCouponCode", "errorInfo", "setErrorInfo", "disabled", "setDisabled", "copyText", "copied", "brand", "rounded", "loading", "trigger", "handleConfirm", "data", "msg", "rulesSection", "text", "index"]
7
7
  }