@anker-in/campaign-ui 0.5.0-beta.22 → 0.5.0-beta.24

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 (32) hide show
  1. package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivatePanel.js +1 -1
  2. package/dist/cjs/components/memberPopup/panels/EarnCredits/ActivatePanel.js.map +2 -2
  3. package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js +1 -1
  4. package/dist/cjs/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js.map +2 -2
  5. package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js +1 -1
  6. package/dist/cjs/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js.map +2 -2
  7. package/dist/cjs/components/memberPopup/panels/EarnCredits/index.js +1 -1
  8. package/dist/cjs/components/memberPopup/panels/EarnCredits/index.js.map +3 -3
  9. package/dist/cjs/components/memberPopup/type.d.ts +0 -1
  10. package/dist/cjs/components/memberPopup/type.js +1 -1
  11. package/dist/cjs/components/memberPopup/type.js.map +1 -1
  12. package/dist/cjs/templates/Credits.js +1 -1
  13. package/dist/cjs/templates/Credits.js.map +3 -3
  14. package/dist/esm/components/memberPopup/panels/EarnCredits/ActivatePanel.js +1 -1
  15. package/dist/esm/components/memberPopup/panels/EarnCredits/ActivatePanel.js.map +2 -2
  16. package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js +1 -1
  17. package/dist/esm/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.js.map +2 -2
  18. package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js +1 -1
  19. package/dist/esm/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.js.map +2 -2
  20. package/dist/esm/components/memberPopup/panels/EarnCredits/index.js +1 -1
  21. package/dist/esm/components/memberPopup/panels/EarnCredits/index.js.map +3 -3
  22. package/dist/esm/components/memberPopup/type.d.ts +0 -1
  23. package/dist/esm/components/memberPopup/type.js.map +1 -1
  24. package/dist/esm/templates/Credits.js +1 -1
  25. package/dist/esm/templates/Credits.js.map +3 -3
  26. package/package.json +1 -1
  27. package/src/components/memberPopup/panels/EarnCredits/ActivatePanel.tsx +2 -2
  28. package/src/components/memberPopup/panels/EarnCredits/CompleteProfilePanel.tsx +1 -1
  29. package/src/components/memberPopup/panels/EarnCredits/SubscribeEmailPanel.tsx +1 -1
  30. package/src/components/memberPopup/panels/EarnCredits/index.tsx +7 -4
  31. package/src/components/memberPopup/type.ts +0 -1
  32. package/src/templates/Credits.tsx +6 -21
@@ -1,2 +1,2 @@
1
- "use strict";var S=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var X=(e,i)=>{for(var u in i)S(e,u,{get:i[u],enumerable:!0})},Y=(e,i,u,g)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of J(i))!Q.call(e,r)&&r!==u&&S(e,r,{get:()=>i[r],enumerable:!(g=G(i,r))||g.enumerable});return e};var Z=e=>Y(S({},"__esModule",{value:!0}),e);var ee={};X(ee,{default:()=>V});module.exports=Z(ee);var n=require("react/jsx-runtime"),o=require("react"),c=require("@anker-in/headless-ui"),s=require("@anker-in/lib"),R=require("../../../registration/authCodeActivate/Message"),H=require("../../../registration"),L=require("../../context/provider"),P=require("../../../../constants");function V({copy:e,onClose:i}){const{setIsActivateSuccess:u,fetchCreditInfo:g,profile:r}=(0,L.useMemberPopupContext)(),{locale:y,brand:B}=(0,s.useHeadlessContext)(),{email:d}=(0,H.useRegistration)(),F=P.ROUNDED_BRANDS.includes(B),{isMutating:$,trigger:C,data:E}=(0,s.useSendEmailValidation)(),{isMutating:j,trigger:k}=(0,s.useEmailValidation)(),[z,f]=(0,o.useState)(""),[W,p]=(0,o.useState)(""),{startCountDown:A,startAction:D,countDown:K}=(0,s.useCountDown)(60),[I,b]=(0,o.useState)(""),[w,_]=(0,o.useState)(0),[m,N]=(0,o.useState)(new Array(6).fill("")),T=(0,o.useRef)([]),v=m.join("");(0,o.useEffect)(()=>{T.current[w]&&T.current[w].focus()},[w]),(0,o.useEffect)(()=>{d&&C({email:d,data:{redirect_url:`${window?.location?.origin}${window?.location?.pathname}`}},{onSuccess:()=>{p("success"),f(e?.sendEmailSuccessMessage||""),D(),setTimeout(()=>{p(""),f("")},5e3)}})},[d]);const O=(0,o.useCallback)(async()=>{d&&(await C({email:d,data:{redirect_url:`${window?.location?.origin}${window?.location?.pathname}`}},{onSuccess:()=>{p("success"),f(e?.sendEmailSuccessMessage||""),D(),setTimeout(()=>{p(""),f("")},5e3)}}),(0,s.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{page_group:"reg_sub_pop",position:"auth_code",button_name:"sent_again"}}))},[d,C]),U=(x,a)=>{const{value:t}=x.target;if(b(""),Number.isNaN(Number(t)))return;if(t.length>1){a<m.length-1&&(m[a+1]||(_(a+1),N(h=>{const M=[...h];return M[a]=t[0],t.length>1&&(M[a+1]=t[1]),M})));return}const l=[...m];l[a]=t,N(l),t?a<m.length-1&&!m[a+1]&&_(a+1):a>0&&_(a-1)},q=(0,o.useCallback)(async()=>{if(!v?.length){b(e?.codeEmptyError||"");return}if(v.length<6){b(e?.incorrectCodeError||"");return}const x=E?.data?.data?.active_token??E?.data?.active_token;x&&await k({token:x,code:v},{onSuccess:t=>{if(t.status>=200&&t.status<300)p("success"),f(e?.authSuccessMessage||""),u(!0),r?.user_id&&g(r.user_id),(0,s.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{page_group:"reg_sub_pop",position:"auth_code",button_name:"check_and_active",info:"Member Floating Window"}}),setTimeout(()=>{i()},3e3);else{const l=t?.data?.error_code??t?.error_code;l==="104"?(u(!0),r?.user_id&&g(r.user_id),(0,s.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{page_group:"reg_sub_pop",position:"auth_code",button_name:"check_and_active",info:"Member Floating Window"}}),setTimeout(()=>{i()},3e3)):b(l==="142"?e?.incorrectCodeError||"Invalid verification code.":l==="154"?e?.expiredCodeMessage||"":e?.sendEmailErrorMessage||"")}}});let a=setTimeout(()=>{p(""),f(""),clearTimeout(a)},5e3)},[v,e?.codeEmptyError,e?.authSuccessMessage,e?.incorrectCodeError,e?.expiredCodeMessage,e?.sendEmailErrorMessage,y,E,k,i,u,g,r]);return(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(c.Text,{className:"text-[22px] font-extrabold leading-[120%] text-[#333] min-l:text-[24px] [&_abbr]:text-[#005d8e]",html:e?.authCodeTitle}),(0,n.jsx)(c.Text,{as:"p",className:"mt-3 text-[14px] font-semibold leading-[140%] text-[rgba(51,51,51,0.75)] min-l:text-base [&_abbr]:text-[#333]",html:e?.authCodeDesc?.replace("%email%",d||"")})]}),(0,n.jsxs)("div",{className:"mt-6",children:[(0,n.jsx)(c.Text,{className:"mt-4 text-[14px] !font-bold font-semibold leading-[140%] text-[#333] min-l:mt-6",html:e?.enterActiveCodeText}),(0,n.jsx)("div",{className:"my-3 grid grid-cols-6 gap-2",children:m.map((x,a)=>(0,n.jsx)("div",{className:"col-span-1 aspect-1 text-[#555]",children:(0,n.jsx)("input",{ref:t=>{t&&(T.current[a]=t)},type:"tel",className:(0,s.classNames)("flex size-full items-center justify-center border border-[#333333]/20 bg-[#EEEEEE] text-center text-[24px] font-medium focus:border-[#333]/50 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none [&:focus-visible]:outline-none",F&&"rounded-[12px]"),value:x,autoComplete:"false",autoCorrect:"false",spellCheck:"false",autoCapitalize:"false",onChange:t=>U(t,a),onFocus:()=>{_(a)},onPaste:t=>{const l=t.clipboardData.getData("text");if(!Number.isNaN(Number(l))){const h=l.split("").slice(0,6);N(h.concat(Array(6-h.length).fill(""))),h.length<=m.length&&_(h.length-1)}},onKeyDown:t=>{const{value:l}=t.target;t.key==="Backspace"&&!l&&a>0&&_(a-1)}},a)},a))}),I&&(0,n.jsx)(c.Text,{className:"mb-3 text-[14px] font-semibold leading-[120%] text-[#f84d4f]",html:I}),e?.authCodeContent&&(0,n.jsx)("ul",{className:'flex flex-col gap-1 [&_li]:flex [&_li]:gap-2 [&_li]:text-[14px] [&_li]:font-semibold [&_li]:leading-[120%] [&_li]:text-[rgba(51,51,51,0.55)] [&_li]:before:content-["\u2022"]',dangerouslySetInnerHTML:{__html:e?.authCodeContent}})]}),(0,n.jsxs)("div",{className:"mt-4 min-l:mt-6",children:[(0,n.jsx)(c.Text,{className:"text-base font-semibold leading-[100%] text-[#333]",html:e?.authCodeReceiveText})," ",A?(0,n.jsx)(c.Text,{html:e?.retrieveText?.replace("%countdownTime%",K.toString()),className:"cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline"}):(0,n.jsx)(c.Text,{onClick:O,className:(0,s.classNames)("cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline",{"pointer-events-none":A||$}),html:e?.sendAgainText}),(0,n.jsx)(c.Button,{type:"submit",loading:j,className:"mt-6 flex h-[54px] w-full cursor-pointer items-center justify-center px-8 py-[15px] text-center text-base font-bold leading-[100%] text-white min-l:mt-8",onClick:q,children:e.buttonText})]}),(0,n.jsx)(R.Message,{status:W,message:z})]})}
1
+ "use strict";var S=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var X=(e,i)=>{for(var u in i)S(e,u,{get:i[u],enumerable:!0})},Y=(e,i,u,g)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of J(i))!Q.call(e,r)&&r!==u&&S(e,r,{get:()=>i[r],enumerable:!(g=G(i,r))||g.enumerable});return e};var Z=e=>Y(S({},"__esModule",{value:!0}),e);var ee={};X(ee,{default:()=>V});module.exports=Z(ee);var n=require("react/jsx-runtime"),o=require("react"),c=require("@anker-in/headless-ui"),s=require("@anker-in/lib"),R=require("../../../registration/authCodeActivate/Message"),H=require("../../../registration"),L=require("../../context/provider"),P=require("../../../../constants");function V({copy:e,onClose:i}){const{setIsActivateSuccess:u,fetchCreditInfo:g,profile:r}=(0,L.useMemberPopupContext)(),{locale:y,brand:B}=(0,s.useHeadlessContext)(),{email:d}=(0,H.useRegistration)(),F=P.ROUNDED_BRANDS.includes(B),{isMutating:$,trigger:C,data:E}=(0,s.useSendEmailValidation)(),{isMutating:j,trigger:k}=(0,s.useEmailValidation)(),[z,f]=(0,o.useState)(""),[W,p]=(0,o.useState)(""),{startCountDown:A,startAction:D,countDown:K}=(0,s.useCountDown)(60),[I,b]=(0,o.useState)(""),[w,_]=(0,o.useState)(0),[m,N]=(0,o.useState)(new Array(6).fill("")),T=(0,o.useRef)([]),v=m.join("");(0,o.useEffect)(()=>{T.current[w]&&T.current[w].focus()},[w]),(0,o.useEffect)(()=>{d&&C({email:d,data:{redirect_url:`${window?.location?.origin}${window?.location?.pathname}`}},{onSuccess:()=>{p("success"),f(e?.sendEmailSuccessMessage||""),D(),setTimeout(()=>{p(""),f("")},5e3)}})},[d]);const O=(0,o.useCallback)(async()=>{d&&(await C({email:d,data:{redirect_url:`${window?.location?.origin}${window?.location?.pathname}`}},{onSuccess:()=>{p("success"),f(e?.sendEmailSuccessMessage||""),D(),setTimeout(()=>{p(""),f("")},5e3)}}),(0,s.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{page_group:"reg_sub_pop",position:"auth_code",button_name:"sent_again"}}))},[d,C]),U=(x,a)=>{const{value:t}=x.target;if(b(""),Number.isNaN(Number(t)))return;if(t.length>1){a<m.length-1&&(m[a+1]||(_(a+1),N(h=>{const M=[...h];return M[a]=t[0],t.length>1&&(M[a+1]=t[1]),M})));return}const l=[...m];l[a]=t,N(l),t?a<m.length-1&&!m[a+1]&&_(a+1):a>0&&_(a-1)},q=(0,o.useCallback)(async()=>{if(!v?.length){b(e?.codeEmptyError||"");return}if(v.length<6){b(e?.incorrectCodeError||"");return}const x=E?.data?.data?.active_token??E?.data?.active_token;x&&await k({token:x,code:v},{onSuccess:t=>{if(t.status>=200&&t.status<300)p("success"),f(e?.authSuccessMessage||""),u(!0),r?.user_id&&setTimeout(()=>g(r.user_id),3e3),(0,s.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{page_group:"reg_sub_pop",position:"auth_code",button_name:"check_and_active",info:"Member Floating Window"}}),setTimeout(()=>{i()},3e3);else{const l=t?.data?.error_code??t?.error_code;l==="104"?(u(!0),r?.user_id&&setTimeout(()=>g(r.user_id),3e3),(0,s.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{page_group:"reg_sub_pop",position:"auth_code",button_name:"check_and_active",info:"Member Floating Window"}}),setTimeout(()=>{i()},3e3)):b(l==="142"?e?.incorrectCodeError||"Invalid verification code.":l==="154"?e?.expiredCodeMessage||"":e?.sendEmailErrorMessage||"")}}});let a=setTimeout(()=>{p(""),f(""),clearTimeout(a)},5e3)},[v,e?.codeEmptyError,e?.authSuccessMessage,e?.incorrectCodeError,e?.expiredCodeMessage,e?.sendEmailErrorMessage,y,E,k,i,u,g,r]);return(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)(c.Text,{className:"text-[22px] font-extrabold leading-[120%] text-[#333] min-l:text-[24px] [&_abbr]:text-[#005d8e]",html:e?.authCodeTitle}),(0,n.jsx)(c.Text,{as:"p",className:"mt-3 text-[14px] font-semibold leading-[140%] text-[rgba(51,51,51,0.75)] min-l:text-base [&_abbr]:text-[#333]",html:e?.authCodeDesc?.replace("%email%",d||"")})]}),(0,n.jsxs)("div",{className:"mt-6",children:[(0,n.jsx)(c.Text,{className:"mt-4 text-[14px] !font-bold font-semibold leading-[140%] text-[#333] min-l:mt-6",html:e?.enterActiveCodeText}),(0,n.jsx)("div",{className:"my-3 grid grid-cols-6 gap-2",children:m.map((x,a)=>(0,n.jsx)("div",{className:"col-span-1 aspect-1 text-[#555]",children:(0,n.jsx)("input",{ref:t=>{t&&(T.current[a]=t)},type:"tel",className:(0,s.classNames)("flex size-full items-center justify-center border border-[#333333]/20 bg-[#EEEEEE] text-center text-[24px] font-medium focus:border-[#333]/50 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none [&:focus-visible]:outline-none",F&&"rounded-[12px]"),value:x,autoComplete:"false",autoCorrect:"false",spellCheck:"false",autoCapitalize:"false",onChange:t=>U(t,a),onFocus:()=>{_(a)},onPaste:t=>{const l=t.clipboardData.getData("text");if(!Number.isNaN(Number(l))){const h=l.split("").slice(0,6);N(h.concat(Array(6-h.length).fill(""))),h.length<=m.length&&_(h.length-1)}},onKeyDown:t=>{const{value:l}=t.target;t.key==="Backspace"&&!l&&a>0&&_(a-1)}},a)},a))}),I&&(0,n.jsx)(c.Text,{className:"mb-3 text-[14px] font-semibold leading-[120%] text-[#f84d4f]",html:I}),e?.authCodeContent&&(0,n.jsx)("ul",{className:'flex flex-col gap-1 [&_li]:flex [&_li]:gap-2 [&_li]:text-[14px] [&_li]:font-semibold [&_li]:leading-[120%] [&_li]:text-[rgba(51,51,51,0.55)] [&_li]:before:content-["\u2022"]',dangerouslySetInnerHTML:{__html:e?.authCodeContent}})]}),(0,n.jsxs)("div",{className:"mt-4 min-l:mt-6",children:[(0,n.jsx)(c.Text,{className:"text-base font-semibold leading-[100%] text-[#333]",html:e?.authCodeReceiveText})," ",A?(0,n.jsx)(c.Text,{html:e?.retrieveText?.replace("%countdownTime%",K.toString()),className:"cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline"}):(0,n.jsx)(c.Text,{onClick:O,className:(0,s.classNames)("cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline",{"pointer-events-none":A||$}),html:e?.sendAgainText}),(0,n.jsx)(c.Button,{type:"submit",loading:j,className:"mt-6 flex h-[54px] w-full cursor-pointer items-center justify-center px-8 py-[15px] text-center text-base font-bold leading-[100%] text-white min-l:mt-8",onClick:q,children:e.buttonText})]}),(0,n.jsx)(R.Message,{status:W,message:z})]})}
2
2
  //# sourceMappingURL=ActivatePanel.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/EarnCredits/ActivatePanel.tsx"],
4
- "sourcesContent": ["import { useState, useCallback, useRef, useEffect } from 'react'\nimport { Button, Text } from '@anker-in/headless-ui'\nimport {\n useSendEmailValidation,\n gaTrack,\n classNames as cn,\n useHeadlessContext,\n useEmailValidation,\n useCountDown,\n} from '@anker-in/lib'\nimport { Message } from '../../../registration/authCodeActivate/Message'\nimport type { AuthCodeActivateCopy } from '../../type'\nimport { useRegistration } from '../../../registration'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n copy: AuthCodeActivateCopy\n onClose: () => void\n}\n\nexport default function ActivatePanel({ copy, onClose }: Props) {\n const { setIsActivateSuccess, fetchCreditInfo, profile } = useMemberPopupContext()\n const { locale, brand } = useHeadlessContext()\n const { email } = useRegistration()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const {\n isMutating: isSendingEmail,\n trigger: triggerSendValidationEmail,\n data: sendEmailData,\n } = useSendEmailValidation()\n\n const { isMutating: emailValidationLoading, trigger: triggerEmailValidation } = useEmailValidation()\n\n const [messageText, setMessageText] = useState('')\n const [messageStatus, setMessageStatus] = useState('')\n const { startCountDown: isStartCountDown, startAction: startCountDown, countDown } = useCountDown(60)\n\n const [error, setError] = useState('')\n const [focusIndex, setFocusIndex] = useState(0)\n const [codeArray, setCodeArray] = useState(new Array(6).fill(''))\n\n const inputRefs = useRef<HTMLInputElement[]>([])\n const code = codeArray.join('')\n\n useEffect(() => {\n if (inputRefs.current[focusIndex]) {\n inputRefs.current[focusIndex].focus()\n }\n }, [focusIndex])\n\n useEffect(() => {\n if (email) {\n triggerSendValidationEmail(\n {\n email: email,\n data: {\n redirect_url: `${window?.location?.origin}${window?.location?.pathname}`,\n },\n },\n {\n onSuccess: () => {\n setMessageStatus('success')\n setMessageText(copy?.sendEmailSuccessMessage || '')\n startCountDown()\n setTimeout(() => {\n setMessageStatus('')\n setMessageText('')\n }, 5000)\n },\n }\n )\n }\n }, [email])\n\n const handleSendAgain = useCallback(async () => {\n if (!email) return\n await triggerSendValidationEmail(\n {\n email: email,\n data: {\n redirect_url: `${window?.location?.origin}${window?.location?.pathname}`,\n },\n },\n {\n onSuccess: () => {\n setMessageStatus('success')\n setMessageText(copy?.sendEmailSuccessMessage || '')\n startCountDown()\n setTimeout(() => {\n setMessageStatus('')\n setMessageText('')\n }, 5000)\n },\n }\n )\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n page_group: 'reg_sub_pop',\n position: 'auth_code',\n button_name: 'sent_again',\n },\n })\n }, [email, triggerSendValidationEmail])\n\n const handleInputCodeChange = (event: React.ChangeEvent<HTMLInputElement>, index: number) => {\n const { value } = event.target\n\n setError('')\n\n if (Number.isNaN(Number(value))) {\n return\n }\n\n if (value.length > 1) {\n if (index < codeArray.length - 1) {\n if (!codeArray[index + 1]) {\n setFocusIndex(index + 1)\n setCodeArray(old => {\n const newCode = [...old]\n newCode[index] = value[0]\n if (value.length > 1) {\n newCode[index + 1] = value[1]\n }\n return newCode\n })\n }\n }\n return\n }\n const newCode = [...codeArray]\n newCode[index] = value\n setCodeArray(newCode)\n if (value) {\n if (index < codeArray.length - 1 && !codeArray[index + 1]) {\n setFocusIndex(index + 1)\n }\n } else if (index > 0) {\n setFocusIndex(index - 1)\n }\n }\n\n const handleAuthCodeSubmit = useCallback(async () => {\n if (!code?.length) {\n setError(copy?.codeEmptyError || '')\n return\n }\n\n if (code.length < 6) {\n setError(copy?.incorrectCodeError || '')\n return\n }\n\n const token = sendEmailData?.data?.data?.active_token ?? sendEmailData?.data?.active_token\n if (token) {\n await triggerEmailValidation(\n {\n token: token,\n code: code,\n },\n {\n onSuccess: data => {\n if (data.status >= 200 && data.status < 300) {\n setMessageStatus('success')\n setMessageText(copy?.authSuccessMessage || '')\n setIsActivateSuccess(true)\n if (profile?.user_id) fetchCreditInfo(profile.user_id)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n page_group: 'reg_sub_pop',\n position: 'auth_code',\n button_name: 'check_and_active',\n info: 'Member Floating Window',\n },\n })\n setTimeout(() => {\n onClose()\n }, 3000)\n } else {\n const errorCode = data?.data?.error_code ?? data?.error_code\n if (errorCode === '104') {\n setIsActivateSuccess(true)\n if (profile?.user_id) fetchCreditInfo(profile.user_id)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n page_group: 'reg_sub_pop',\n position: 'auth_code',\n button_name: 'check_and_active',\n info: 'Member Floating Window',\n },\n })\n setTimeout(() => {\n onClose()\n }, 3000)\n } else if (errorCode === '142') {\n setError(copy?.incorrectCodeError || 'Invalid verification code.')\n } else if (errorCode === '154') {\n setError(copy?.expiredCodeMessage || '')\n } else {\n setError(copy?.sendEmailErrorMessage || '')\n }\n }\n },\n }\n )\n }\n\n let timer = setTimeout(() => {\n setMessageStatus('')\n setMessageText('')\n clearTimeout(timer)\n }, 5000)\n }, [\n code,\n copy?.codeEmptyError,\n copy?.authSuccessMessage,\n copy?.incorrectCodeError,\n copy?.expiredCodeMessage,\n copy?.sendEmailErrorMessage,\n locale,\n sendEmailData,\n triggerEmailValidation,\n onClose,\n setIsActivateSuccess,\n fetchCreditInfo,\n profile,\n ])\n\n return (\n <div className=\"relative\">\n <div>\n <Text\n className=\"text-[22px] font-extrabold leading-[120%] text-[#333] min-l:text-[24px] [&_abbr]:text-[#005d8e]\"\n html={copy?.authCodeTitle}\n />\n <Text\n as=\"p\"\n className=\"mt-3 text-[14px] font-semibold leading-[140%] text-[rgba(51,51,51,0.75)] min-l:text-base [&_abbr]:text-[#333]\"\n html={copy?.authCodeDesc?.replace('%email%', email || '')}\n />\n </div>\n <div className=\"mt-6\">\n <Text\n className=\"mt-4 text-[14px] !font-bold font-semibold leading-[140%] text-[#333] min-l:mt-6\"\n html={copy?.enterActiveCodeText}\n />\n <div className=\"my-3 grid grid-cols-6 gap-2\">\n {codeArray.map((item, index) => (\n <div key={index} className=\"col-span-1 aspect-1 text-[#555]\">\n <input\n ref={inputRef => {\n if (inputRef) {\n inputRefs.current[index] = inputRef\n }\n }}\n key={index}\n type=\"tel\"\n className={cn(\n 'flex size-full items-center justify-center border border-[#333333]/20 bg-[#EEEEEE] text-center text-[24px] font-medium focus:border-[#333]/50 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none [&:focus-visible]:outline-none',\n rounded && 'rounded-[12px]'\n )}\n value={item}\n autoComplete=\"false\"\n autoCorrect=\"false\"\n spellCheck=\"false\"\n autoCapitalize=\"false\"\n onChange={event => handleInputCodeChange(event, index)}\n onFocus={() => {\n setFocusIndex(index)\n }}\n onPaste={event => {\n const paste = event.clipboardData.getData('text')\n if (!Number.isNaN(Number(paste))) {\n const pastedCode = paste.split('').slice(0, 6)\n setCodeArray(pastedCode.concat(Array(6 - pastedCode.length).fill('')))\n if (pastedCode.length <= codeArray.length) {\n setFocusIndex(pastedCode.length - 1)\n }\n }\n }}\n onKeyDown={event => {\n const { value } = event.target as HTMLInputElement\n if (event.key === 'Backspace' && !value && index > 0) {\n setFocusIndex(index - 1)\n }\n }}\n />\n </div>\n ))}\n </div>\n\n {error && <Text className=\"mb-3 text-[14px] font-semibold leading-[120%] text-[#f84d4f]\" html={error} />}\n {copy?.authCodeContent && (\n <ul\n className='flex flex-col gap-1 [&_li]:flex [&_li]:gap-2 [&_li]:text-[14px] [&_li]:font-semibold [&_li]:leading-[120%] [&_li]:text-[rgba(51,51,51,0.55)] [&_li]:before:content-[\"\u2022\"]'\n dangerouslySetInnerHTML={{ __html: copy?.authCodeContent }}\n />\n )}\n </div>\n <div className=\"mt-4 min-l:mt-6\">\n <Text className=\"text-base font-semibold leading-[100%] text-[#333]\" html={copy?.authCodeReceiveText} />{' '}\n {isStartCountDown ? (\n <Text\n html={copy?.retrieveText?.replace('%countdownTime%', countDown.toString())}\n className=\"cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline\"\n />\n ) : (\n <Text\n onClick={handleSendAgain}\n className={cn(\n 'cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline',\n {\n 'pointer-events-none': isStartCountDown || isSendingEmail,\n }\n )}\n html={copy?.sendAgainText}\n />\n )}\n <Button\n type=\"submit\"\n loading={emailValidationLoading}\n className=\"mt-6 flex h-[54px] w-full cursor-pointer items-center justify-center px-8 py-[15px] text-center text-base font-bold leading-[100%] text-white min-l:mt-8\"\n onClick={handleAuthCodeSubmit}\n >\n {copy.buttonText}\n </Button>\n </div>\n <Message status={messageStatus} message={messageText} />\n </div>\n )\n}\n"],
5
- "mappings": "yaAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,IAAA,eAAAC,EAAAH,IA6OM,IAAAI,EAAA,6BA7ONC,EAAyD,iBACzDC,EAA6B,iCAC7BC,EAOO,yBACPC,EAAwB,0DAExBC,EAAgC,iCAChCC,EAAsC,kCACtCC,EAA+B,iCAOhB,SAART,EAA+B,CAAE,KAAAU,EAAM,QAAAC,CAAQ,EAAU,CAC9D,KAAM,CAAE,qBAAAC,EAAsB,gBAAAC,EAAiB,QAAAC,CAAQ,KAAI,yBAAsB,EAC3E,CAAE,OAAAC,EAAQ,MAAAC,CAAM,KAAI,sBAAmB,EACvC,CAAE,MAAAC,CAAM,KAAI,mBAAgB,EAC5BC,EAAU,iBAAe,SAASF,CAAK,EAEvC,CACJ,WAAYG,EACZ,QAASC,EACT,KAAMC,CACR,KAAI,0BAAuB,EAErB,CAAE,WAAYC,EAAwB,QAASC,CAAuB,KAAI,sBAAmB,EAE7F,CAACC,EAAaC,CAAc,KAAI,YAAS,EAAE,EAC3C,CAACC,EAAeC,CAAgB,KAAI,YAAS,EAAE,EAC/C,CAAE,eAAgBC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WAAQ,OAAQgB,EAAe,QAASF,EAAa,GACxD,CAEJ",
4
+ "sourcesContent": ["import { useState, useCallback, useRef, useEffect } from 'react'\nimport { Button, Text } from '@anker-in/headless-ui'\nimport {\n useSendEmailValidation,\n gaTrack,\n classNames as cn,\n useHeadlessContext,\n useEmailValidation,\n useCountDown,\n} from '@anker-in/lib'\nimport { Message } from '../../../registration/authCodeActivate/Message'\nimport type { AuthCodeActivateCopy } from '../../type'\nimport { useRegistration } from '../../../registration'\nimport { useMemberPopupContext } from '../../context/provider'\nimport { ROUNDED_BRANDS } from '../../../../constants'\n\ntype Props = {\n copy: AuthCodeActivateCopy\n onClose: () => void\n}\n\nexport default function ActivatePanel({ copy, onClose }: Props) {\n const { setIsActivateSuccess, fetchCreditInfo, profile } = useMemberPopupContext()\n const { locale, brand } = useHeadlessContext()\n const { email } = useRegistration()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const {\n isMutating: isSendingEmail,\n trigger: triggerSendValidationEmail,\n data: sendEmailData,\n } = useSendEmailValidation()\n\n const { isMutating: emailValidationLoading, trigger: triggerEmailValidation } = useEmailValidation()\n\n const [messageText, setMessageText] = useState('')\n const [messageStatus, setMessageStatus] = useState('')\n const { startCountDown: isStartCountDown, startAction: startCountDown, countDown } = useCountDown(60)\n\n const [error, setError] = useState('')\n const [focusIndex, setFocusIndex] = useState(0)\n const [codeArray, setCodeArray] = useState(new Array(6).fill(''))\n\n const inputRefs = useRef<HTMLInputElement[]>([])\n const code = codeArray.join('')\n\n useEffect(() => {\n if (inputRefs.current[focusIndex]) {\n inputRefs.current[focusIndex].focus()\n }\n }, [focusIndex])\n\n useEffect(() => {\n if (email) {\n triggerSendValidationEmail(\n {\n email: email,\n data: {\n redirect_url: `${window?.location?.origin}${window?.location?.pathname}`,\n },\n },\n {\n onSuccess: () => {\n setMessageStatus('success')\n setMessageText(copy?.sendEmailSuccessMessage || '')\n startCountDown()\n setTimeout(() => {\n setMessageStatus('')\n setMessageText('')\n }, 5000)\n },\n }\n )\n }\n }, [email])\n\n const handleSendAgain = useCallback(async () => {\n if (!email) return\n await triggerSendValidationEmail(\n {\n email: email,\n data: {\n redirect_url: `${window?.location?.origin}${window?.location?.pathname}`,\n },\n },\n {\n onSuccess: () => {\n setMessageStatus('success')\n setMessageText(copy?.sendEmailSuccessMessage || '')\n startCountDown()\n setTimeout(() => {\n setMessageStatus('')\n setMessageText('')\n }, 5000)\n },\n }\n )\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n page_group: 'reg_sub_pop',\n position: 'auth_code',\n button_name: 'sent_again',\n },\n })\n }, [email, triggerSendValidationEmail])\n\n const handleInputCodeChange = (event: React.ChangeEvent<HTMLInputElement>, index: number) => {\n const { value } = event.target\n\n setError('')\n\n if (Number.isNaN(Number(value))) {\n return\n }\n\n if (value.length > 1) {\n if (index < codeArray.length - 1) {\n if (!codeArray[index + 1]) {\n setFocusIndex(index + 1)\n setCodeArray(old => {\n const newCode = [...old]\n newCode[index] = value[0]\n if (value.length > 1) {\n newCode[index + 1] = value[1]\n }\n return newCode\n })\n }\n }\n return\n }\n const newCode = [...codeArray]\n newCode[index] = value\n setCodeArray(newCode)\n if (value) {\n if (index < codeArray.length - 1 && !codeArray[index + 1]) {\n setFocusIndex(index + 1)\n }\n } else if (index > 0) {\n setFocusIndex(index - 1)\n }\n }\n\n const handleAuthCodeSubmit = useCallback(async () => {\n if (!code?.length) {\n setError(copy?.codeEmptyError || '')\n return\n }\n\n if (code.length < 6) {\n setError(copy?.incorrectCodeError || '')\n return\n }\n\n const token = sendEmailData?.data?.data?.active_token ?? sendEmailData?.data?.active_token\n if (token) {\n await triggerEmailValidation(\n {\n token: token,\n code: code,\n },\n {\n onSuccess: data => {\n if (data.status >= 200 && data.status < 300) {\n setMessageStatus('success')\n setMessageText(copy?.authSuccessMessage || '')\n setIsActivateSuccess(true)\n if (profile?.user_id) setTimeout(() => fetchCreditInfo(profile.user_id), 3000)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n page_group: 'reg_sub_pop',\n position: 'auth_code',\n button_name: 'check_and_active',\n info: 'Member Floating Window',\n },\n })\n setTimeout(() => {\n onClose()\n }, 3000)\n } else {\n const errorCode = data?.data?.error_code ?? data?.error_code\n if (errorCode === '104') {\n setIsActivateSuccess(true)\n if (profile?.user_id) setTimeout(() => fetchCreditInfo(profile.user_id), 3000)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n event_parameters: {\n page_group: 'reg_sub_pop',\n position: 'auth_code',\n button_name: 'check_and_active',\n info: 'Member Floating Window',\n },\n })\n setTimeout(() => {\n onClose()\n }, 3000)\n } else if (errorCode === '142') {\n setError(copy?.incorrectCodeError || 'Invalid verification code.')\n } else if (errorCode === '154') {\n setError(copy?.expiredCodeMessage || '')\n } else {\n setError(copy?.sendEmailErrorMessage || '')\n }\n }\n },\n }\n )\n }\n\n let timer = setTimeout(() => {\n setMessageStatus('')\n setMessageText('')\n clearTimeout(timer)\n }, 5000)\n }, [\n code,\n copy?.codeEmptyError,\n copy?.authSuccessMessage,\n copy?.incorrectCodeError,\n copy?.expiredCodeMessage,\n copy?.sendEmailErrorMessage,\n locale,\n sendEmailData,\n triggerEmailValidation,\n onClose,\n setIsActivateSuccess,\n fetchCreditInfo,\n profile,\n ])\n\n return (\n <div className=\"relative\">\n <div>\n <Text\n className=\"text-[22px] font-extrabold leading-[120%] text-[#333] min-l:text-[24px] [&_abbr]:text-[#005d8e]\"\n html={copy?.authCodeTitle}\n />\n <Text\n as=\"p\"\n className=\"mt-3 text-[14px] font-semibold leading-[140%] text-[rgba(51,51,51,0.75)] min-l:text-base [&_abbr]:text-[#333]\"\n html={copy?.authCodeDesc?.replace('%email%', email || '')}\n />\n </div>\n <div className=\"mt-6\">\n <Text\n className=\"mt-4 text-[14px] !font-bold font-semibold leading-[140%] text-[#333] min-l:mt-6\"\n html={copy?.enterActiveCodeText}\n />\n <div className=\"my-3 grid grid-cols-6 gap-2\">\n {codeArray.map((item, index) => (\n <div key={index} className=\"col-span-1 aspect-1 text-[#555]\">\n <input\n ref={inputRef => {\n if (inputRef) {\n inputRefs.current[index] = inputRef\n }\n }}\n key={index}\n type=\"tel\"\n className={cn(\n 'flex size-full items-center justify-center border border-[#333333]/20 bg-[#EEEEEE] text-center text-[24px] font-medium focus:border-[#333]/50 [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none [&:focus-visible]:outline-none',\n rounded && 'rounded-[12px]'\n )}\n value={item}\n autoComplete=\"false\"\n autoCorrect=\"false\"\n spellCheck=\"false\"\n autoCapitalize=\"false\"\n onChange={event => handleInputCodeChange(event, index)}\n onFocus={() => {\n setFocusIndex(index)\n }}\n onPaste={event => {\n const paste = event.clipboardData.getData('text')\n if (!Number.isNaN(Number(paste))) {\n const pastedCode = paste.split('').slice(0, 6)\n setCodeArray(pastedCode.concat(Array(6 - pastedCode.length).fill('')))\n if (pastedCode.length <= codeArray.length) {\n setFocusIndex(pastedCode.length - 1)\n }\n }\n }}\n onKeyDown={event => {\n const { value } = event.target as HTMLInputElement\n if (event.key === 'Backspace' && !value && index > 0) {\n setFocusIndex(index - 1)\n }\n }}\n />\n </div>\n ))}\n </div>\n\n {error && <Text className=\"mb-3 text-[14px] font-semibold leading-[120%] text-[#f84d4f]\" html={error} />}\n {copy?.authCodeContent && (\n <ul\n className='flex flex-col gap-1 [&_li]:flex [&_li]:gap-2 [&_li]:text-[14px] [&_li]:font-semibold [&_li]:leading-[120%] [&_li]:text-[rgba(51,51,51,0.55)] [&_li]:before:content-[\"\u2022\"]'\n dangerouslySetInnerHTML={{ __html: copy?.authCodeContent }}\n />\n )}\n </div>\n <div className=\"mt-4 min-l:mt-6\">\n <Text className=\"text-base font-semibold leading-[100%] text-[#333]\" html={copy?.authCodeReceiveText} />{' '}\n {isStartCountDown ? (\n <Text\n html={copy?.retrieveText?.replace('%countdownTime%', countDown.toString())}\n className=\"cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline\"\n />\n ) : (\n <Text\n onClick={handleSendAgain}\n className={cn(\n 'cursor-pointer text-base font-semibold leading-[100%] !text-brand text-[#005d8e] text-[#333] underline',\n {\n 'pointer-events-none': isStartCountDown || isSendingEmail,\n }\n )}\n html={copy?.sendAgainText}\n />\n )}\n <Button\n type=\"submit\"\n loading={emailValidationLoading}\n className=\"mt-6 flex h-[54px] w-full cursor-pointer items-center justify-center px-8 py-[15px] text-center text-base font-bold leading-[100%] text-white min-l:mt-8\"\n onClick={handleAuthCodeSubmit}\n >\n {copy.buttonText}\n </Button>\n </div>\n <Message status={messageStatus} message={messageText} />\n </div>\n )\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,IAAA,eAAAC,EAAAH,IA6OM,IAAAI,EAAA,6BA7ONC,EAAyD,iBACzDC,EAA6B,iCAC7BC,EAOO,yBACPC,EAAwB,0DAExBC,EAAgC,iCAChCC,EAAsC,kCACtCC,EAA+B,iCAOhB,SAART,EAA+B,CAAE,KAAAU,EAAM,QAAAC,CAAQ,EAAU,CAC9D,KAAM,CAAE,qBAAAC,EAAsB,gBAAAC,EAAiB,QAAAC,CAAQ,KAAI,yBAAsB,EAC3E,CAAE,OAAAC,EAAQ,MAAAC,CAAM,KAAI,sBAAmB,EACvC,CAAE,MAAAC,CAAM,KAAI,mBAAgB,EAC5BC,EAAU,iBAAe,SAASF,CAAK,EAEvC,CACJ,WAAYG,EACZ,QAASC,EACT,KAAMC,CACR,KAAI,0BAAuB,EAErB,CAAE,WAAYC,EAAwB,QAASC,CAAuB,KAAI,sBAAmB,EAE7F,CAACC,EAAaC,CAAc,KAAI,YAAS,EAAE,EAC3C,CAACC,EAAeC,CAAgB,KAAI,YAAS,EAAE,EAC/C,CAAE,eAAgBC,EAAkB,YAAaC,EAAgB,UAAAC,CAAU,KAAI,gBAAa,EAAE,EAE9F,CAACC,EAAOC,CAAQ,KAAI,YAAS,EAAE,EAC/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  "names": ["ActivatePanel_exports", "__export", "ActivatePanel", "__toCommonJS", "import_jsx_runtime", "import_react", "import_headless_ui", "import_lib", "import_Message", "import_registration", "import_provider", "import_constants", "copy", "onClose", "setIsActivateSuccess", "fetchCreditInfo", "profile", "locale", "brand", "email", "rounded", "isSendingEmail", "triggerSendValidationEmail", "sendEmailData", "emailValidationLoading", "triggerEmailValidation", "messageText", "setMessageText", "messageStatus", "setMessageStatus", "isStartCountDown", "startCountDown", "countDown", "error", "setError", "focusIndex", "setFocusIndex", "codeArray", "setCodeArray", "inputRefs", "code", "handleSendAgain", "handleInputCodeChange", "event", "index", "value", "old", "newCode", "handleAuthCodeSubmit", "token", "data", "errorCode", "timer", "item", "inputRef", "cn", "paste", "pastedCode"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var H=Object.create;var c=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var K=(t,n)=>{for(var a in n)c(t,a,{get:n[a],enumerable:!0})},q=(t,n,a,p)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of W(n))!J.call(t,s)&&s!==a&&c(t,s,{get:()=>n[s],enumerable:!(p=O(n,s))||p.enumerable});return t};var Q=(t,n,a)=>(a=t!=null?H(G(t)):{},q(n||!t||!t.__esModule?c(a,"default",{value:t,enumerable:!0}):a,t)),V=t=>q(c({},"__esModule",{value:!0}),t);var X={};K(X,{default:()=>M});module.exports=V(X);var e=require("react/jsx-runtime"),r=require("react"),d=require("@anker-in/headless-ui"),l=require("@anker-in/lib"),F=require("./hooks/useUpdateProfile"),L=Q(require("../../../credits/context/hooks/useCountries")),z=require("../../context/provider"),I=require("../../../../constants");function M({copy:t,onClose:n}){const{profile:a,fetchCreditInfo:p,alpcConfig:s,setIsProfileCompleteSuccess:k}=(0,z.useMemberPopupContext)(),{locale:R}=s,{brand:T,storeDomain:U}=(0,l.useHeadlessContext)(),i=I.ROUNDED_BRANDS.includes(T),[m,P]=(0,r.useState)(""),[x,w]=(0,r.useState)(""),[b,E]=(0,r.useState)(""),[v,y]=(0,r.useState)(""),[u,N]=(0,r.useState)(""),[h,g]=(0,r.useState)(""),[C,_]=(0,r.useState)(""),{updateProfile:D,isLoading:B}=(0,F.useUpdateProfile)({locale:R,appName:s.appName}),{countries:f}=(0,L.default)({shopifyStoreDomain:U});(0,r.useEffect)(()=>{a&&(P(a.first_name??""),w(a.last_name??""),E(a.phone_number??""),y(a.dob??""),N(a.country?.id??""))},[a]),(0,r.useEffect)(()=>{f.length>0&&!u&&N(f[0].id)},[f]);const S=(0,r.useCallback)(()=>{let o=!1;return m.trim()?g(""):(g(t.required),o=!0),x.trim()?_(""):(_(t.required),o=!0),o},[m,x,t.required]),A=(0,r.useCallback)(async()=>{if(S())return;await D({first_name:m.trim(),last_name:x.trim(),phone_number:b,country:u,dob:v})&&(p(a?.user_id),k(!0),(0,l.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"earn_credits",button_name:"complete_profile_success",info:"Member Floating Window"}}),n())},[S,D,m,x,b,u,v,p,a,k,n]);return(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[t.subtitle&&(0,e.jsx)(d.Text,{className:"text-[14px] text-[#1d1d1f]",html:t.subtitle}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:t.email}),(0,e.jsx)("input",{className:(0,l.classNames)("mt-[8px] h-[46px] w-full border border-[#d8d8d8] bg-[#f5f5f5] px-[12px] text-[14px] text-[#999]",i?"rounded-[4px]":"rounded-none"),value:a?.email??"",disabled:!0})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:[t.firstName," ",(0,e.jsx)("span",{className:"text-[#f84d4f]",children:"*"})]}),(0,e.jsx)("input",{className:(0,l.classNames)("mt-[8px] h-[46px] w-full border px-[12px] text-[14px] outline-none",h?"border-[#f84d4f]":"border-[#d8d8d8]",i?"rounded-[4px]":"rounded-none"),value:m,onChange:o=>{P(o.target.value),g("")}}),h&&(0,e.jsx)(d.Text,{className:"mt-[4px] text-[12px] text-[#f84d4f]",html:h})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:[t.lastName," ",(0,e.jsx)("span",{className:"text-[#f84d4f]",children:"*"})]}),(0,e.jsx)("input",{className:(0,l.classNames)("mt-[8px] h-[46px] w-full border px-[12px] text-[14px] outline-none",C?"border-[#f84d4f]":"border-[#d8d8d8]",i?"rounded-[4px]":"rounded-none"),value:x,onChange:o=>{w(o.target.value),_("")}}),C&&(0,e.jsx)(d.Text,{className:"mt-[4px] text-[12px] text-[#f84d4f]",html:C})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:t.birthday}),(0,e.jsx)("input",{className:(0,l.classNames)("mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none",i?"rounded-[4px]":"rounded-none"),type:"date",value:v,onChange:o=>y(o.target.value)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:t.phone}),(0,e.jsx)("input",{className:(0,l.classNames)("mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none",i?"rounded-[4px]":"rounded-none"),value:b,onChange:o=>E(o.target.value)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:t.country}),(0,e.jsx)("select",{className:(0,l.classNames)("mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none",i?"rounded-[4px]":"rounded-none"),value:u,onChange:o=>N(o.target.value),children:f.map(o=>(0,e.jsx)("option",{value:o.id,children:o.name},o.id))})]}),(0,e.jsxs)("div",{className:"flex gap-[12px]",children:[(0,e.jsx)(d.Button,{variant:"secondary",size:"lg",className:"flex-1",onClick:n,disabled:B,children:t.cancel}),(0,e.jsx)(d.Button,{variant:"primary",size:"lg",className:"flex-1",loading:B,onClick:A,children:t.save})]})]})}
1
+ "use strict";var H=Object.create;var c=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var K=(t,n)=>{for(var a in n)c(t,a,{get:n[a],enumerable:!0})},q=(t,n,a,p)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of W(n))!J.call(t,s)&&s!==a&&c(t,s,{get:()=>n[s],enumerable:!(p=O(n,s))||p.enumerable});return t};var Q=(t,n,a)=>(a=t!=null?H(G(t)):{},q(n||!t||!t.__esModule?c(a,"default",{value:t,enumerable:!0}):a,t)),V=t=>q(c({},"__esModule",{value:!0}),t);var X={};K(X,{default:()=>I});module.exports=V(X);var e=require("react/jsx-runtime"),r=require("react"),d=require("@anker-in/headless-ui"),l=require("@anker-in/lib"),F=require("./hooks/useUpdateProfile"),L=Q(require("../../../credits/context/hooks/useCountries")),T=require("../../context/provider"),z=require("../../../../constants");function I({copy:t,onClose:n}){const{profile:a,fetchCreditInfo:p,alpcConfig:s,setIsProfileCompleteSuccess:k}=(0,T.useMemberPopupContext)(),{locale:M}=s,{brand:R,storeDomain:U}=(0,l.useHeadlessContext)(),i=z.ROUNDED_BRANDS.includes(R),[m,P]=(0,r.useState)(""),[x,w]=(0,r.useState)(""),[b,E]=(0,r.useState)(""),[v,y]=(0,r.useState)(""),[u,N]=(0,r.useState)(""),[h,g]=(0,r.useState)(""),[C,_]=(0,r.useState)(""),{updateProfile:D,isLoading:B}=(0,F.useUpdateProfile)({locale:M,appName:s.appName}),{countries:f}=(0,L.default)({shopifyStoreDomain:U});(0,r.useEffect)(()=>{a&&(P(a.first_name??""),w(a.last_name??""),E(a.phone_number??""),y(a.dob??""),N(a.country?.id??""))},[a]),(0,r.useEffect)(()=>{f.length>0&&!u&&N(f[0].id)},[f]);const S=(0,r.useCallback)(()=>{let o=!1;return m.trim()?g(""):(g(t.required),o=!0),x.trim()?_(""):(_(t.required),o=!0),o},[m,x,t.required]),A=(0,r.useCallback)(async()=>{if(S())return;await D({first_name:m.trim(),last_name:x.trim(),phone_number:b,country:u,dob:v})&&(setTimeout(()=>p(a?.user_id),3e3),k(!0),(0,l.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"earn_credits",button_name:"complete_profile_success",info:"Member Floating Window"}}),n())},[S,D,m,x,b,u,v,p,a,k,n]);return(0,e.jsxs)("div",{className:"flex flex-col gap-[16px]",children:[t.subtitle&&(0,e.jsx)(d.Text,{className:"text-[14px] text-[#1d1d1f]",html:t.subtitle}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:t.email}),(0,e.jsx)("input",{className:(0,l.classNames)("mt-[8px] h-[46px] w-full border border-[#d8d8d8] bg-[#f5f5f5] px-[12px] text-[14px] text-[#999]",i?"rounded-[4px]":"rounded-none"),value:a?.email??"",disabled:!0})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:[t.firstName," ",(0,e.jsx)("span",{className:"text-[#f84d4f]",children:"*"})]}),(0,e.jsx)("input",{className:(0,l.classNames)("mt-[8px] h-[46px] w-full border px-[12px] text-[14px] outline-none",h?"border-[#f84d4f]":"border-[#d8d8d8]",i?"rounded-[4px]":"rounded-none"),value:m,onChange:o=>{P(o.target.value),g("")}}),h&&(0,e.jsx)(d.Text,{className:"mt-[4px] text-[12px] text-[#f84d4f]",html:h})]}),(0,e.jsxs)("div",{children:[(0,e.jsxs)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:[t.lastName," ",(0,e.jsx)("span",{className:"text-[#f84d4f]",children:"*"})]}),(0,e.jsx)("input",{className:(0,l.classNames)("mt-[8px] h-[46px] w-full border px-[12px] text-[14px] outline-none",C?"border-[#f84d4f]":"border-[#d8d8d8]",i?"rounded-[4px]":"rounded-none"),value:x,onChange:o=>{w(o.target.value),_("")}}),C&&(0,e.jsx)(d.Text,{className:"mt-[4px] text-[12px] text-[#f84d4f]",html:C})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:t.birthday}),(0,e.jsx)("input",{className:(0,l.classNames)("mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none",i?"rounded-[4px]":"rounded-none"),type:"date",value:v,onChange:o=>y(o.target.value)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:t.phone}),(0,e.jsx)("input",{className:(0,l.classNames)("mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none",i?"rounded-[4px]":"rounded-none"),value:b,onChange:o=>E(o.target.value)})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-[14px] font-[700] text-[#1d1d1f]",children:t.country}),(0,e.jsx)("select",{className:(0,l.classNames)("mt-[8px] h-[46px] w-full border border-[#d8d8d8] px-[12px] text-[14px] outline-none",i?"rounded-[4px]":"rounded-none"),value:u,onChange:o=>N(o.target.value),children:f.map(o=>(0,e.jsx)("option",{value:o.id,children:o.name},o.id))})]}),(0,e.jsxs)("div",{className:"flex gap-[12px]",children:[(0,e.jsx)(d.Button,{variant:"secondary",size:"lg",className:"flex-1",onClick:n,disabled:B,children:t.cancel}),(0,e.jsx)(d.Button,{variant:"primary",size:"lg",className:"flex-1",loading:B,onClick:A,children:t.save})]})]})}
2
2
  //# sourceMappingURL=CompleteProfilePanel.js.map
@@ -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 fetchCreditInfo(profile?.user_id)\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,kCACtCC,EAA+B,iCAOhB,SAART,EAAsC,CAAE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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=\"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,EAA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AAQ,YAAY,KAAK,KAAK,UAAU,SAAS,QAAShC,EAAS,SAAUwB,EAClF,SAAAzB,EAAK,OACR,KACA,OAAC,UAAO,QAAQ,UAAU,KAAK,KAAK,UAAU,SAAS,QAASyB,EAAW,QAASK,EACjF,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&&I(g.user_id),(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 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"})]})]})}
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) fetchCreditInfo(profile.user_id)\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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,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 { 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,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,E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C,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",
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 I=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var y=(i,t)=>{for(var n in t)v(i,n,{get:t[n],enumerable:!0})},R=(i,t,n,d)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of U(t))!M.call(i,o)&&o!==n&&v(i,o,{get:()=>t[o],enumerable:!(d=I(t,o))||d.enumerable});return i};var D=i=>R(v({},"__esModule",{value:!0}),i);var H={};y(H,{default:()=>z});module.exports=D(H);var e=require("react/jsx-runtime"),u=require("react"),l=require("@anker-in/lib"),P=require("../../context/provider"),_=require("../../context/viewStack"),E=require("./hooks/useSubscribed"),s=require("../../type"),c=require("../../icons"),g=require("../../../credits/context/utils"),L=require("../../../../constants");function F({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 O({copy:i}){const{profile:t,openSignUpPopup:n,alpcConfig:d,creditInfo:o,isSubscribeSuccess:N,isActivateSuccess:k,isProfileCompleteSuccess:m}=(0,P.useMemberPopupContext)(),{pushView:x}=(0,_.useViewStack)(),{locale:w}=d,{brand:h}=(0,l.useHeadlessContext)(),b=L.ROUNDED_BRANDS.includes(h);console.log("creditInfo",o);const r=!!t,C=(0,E.useSubscribed)({userId:t?.user_id,brand:h,email:t?.email,locale:w,apiBaseUrl:d.apiBaseUrl}),S=(0,u.useMemo)(()=>m||!!(t?.first_name||t?.last_name)&&!!t?.phone_number&&!!t?.dob,[t,m]);function f(a){const p={[s.EarnCreditsTaskType.Activate]:"activate",[s.EarnCreditsTaskType.CompleteProfile]:"complete_profile",[s.EarnCreditsTaskType.Subscribe]:"subscribe",[s.EarnCreditsTaskType.Shop]:"shop"};(0,l.gaTrack)({event:"ga4Event",event_name:"lp_button",event_parameters:{position:"earn_credits",button_name:p[a],info:"Member Floating Window"}})}const T=(0,u.useMemo)(()=>({[s.EarnCreditsTaskType.Activate]:{finished:!!t?.activated||k,onClick:r?()=>{f(s.EarnCreditsTaskType.Activate),x({type:s.MemberPopupPanelType.Activate})}:n},[s.EarnCreditsTaskType.CompleteProfile]:{finished:S,onClick:r?()=>{f(s.EarnCreditsTaskType.CompleteProfile),x({type:s.MemberPopupPanelType.CompleteProfile})}:n},[s.EarnCreditsTaskType.Subscribe]:{finished:C||N,onClick:r?()=>{f(s.EarnCreditsTaskType.Subscribe),x({type:s.MemberPopupPanelType.SubscribeEmail})}:n},[s.EarnCreditsTaskType.Shop]:{finished:!1,link:i.goShopLink,onClick:r?()=>f(s.EarnCreditsTaskType.Shop):n}}),[t,r,k,m,S,C,N,n,x,i.goShopLink]),A=(0,u.useMemo)(()=>i.list.map(a=>{const p=T[a.id];if(!p)return null;const B=p.finished?i.completed:r?V(a.id,i):i.joinNow;return{...a,...p,buttonLabel:B}}).filter(Boolean),[i,T,r]);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})}),r&&(0,e.jsxs)("div",{className:(0,l.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)(o?.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)(o?.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:A.map((a,p)=>(0,e.jsxs)("div",{className:"relative py-[16px]",children:[p>0&&(0,e.jsx)("div",{className:"absolute left-0 right-0 top-0 h-px bg-[#dadce0]"}),(0,e.jsxs)("div",{className:(0,l.classNames)("flex items-center gap-[12px]"),children:[(0,e.jsx)(F,{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.description&&(0,e.jsx)("div",{className:"mt-[4px] text-[14px] font-[700] text-[#4a4c56]",children:a.description})]}),!a.finished&&a.link&&r?(0,e.jsx)("a",{href:a.link,target:"_blank",rel:"noopener noreferrer",className:(0,l.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:()=>f(a.id),children:a.buttonLabel}):(0,e.jsx)("button",{className:(0,l.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})]})]},p))})]})]})}function V(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 z=O;
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;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/memberPopup/panels/EarnCredits/index.tsx"],
4
- "sourcesContent": ["import { useMemo } from 'react'\nimport { 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 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 console.log('creditInfo', creditInfo)\n\n const isLogin = !!profile\n\n const isSubscribed = useSubscribed({\n userId: profile?.user_id,\n brand: brand,\n email: profile?.email,\n locale,\n apiBaseUrl: alpcConfig.apiBaseUrl,\n })\n\n const profileCompleted = useMemo(() => {\n return (\n isProfileCompleteSuccess ||\n (!!(profile?.first_name || profile?.last_name) && !!profile?.phone_number && !!profile?.dob)\n )\n }, [profile, isProfileCompleteSuccess])\n\n 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.description && (\n <div className=\"mt-[4px] text-[14px] font-[700] text-[#4a4c56]\">{item.description}</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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D,YAAG,8BAA8B,EAC/C,oBAAC5B,EAAA,CAAS,GAAIwB,EAAK,GAAI,UAAU,uBAAuB,KACxD,QAAC,OAAI,UAAU,SACb,oBAAC,OAAI,UAAU,wCAAyC,SAAAA,EAAK,MAAM,EAClEA,EAAK,gBACJ,OAAC,OAAI,UAAU,iDAAkD,SAAAA,EAAK,YAAY,GAEtF,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,EAAoB1B,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", "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'\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,kCACtC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AAAA,EAAK,MAAM,EAClEA,EAAK,YACJ,OAAC,OAAI,UAAU,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"]
7
7
  }
@@ -92,7 +92,6 @@ export type EarnCreditsCopy = {
92
92
  list: {
93
93
  id: EarnCreditsTaskType;
94
94
  title: string;
95
- description: string;
96
95
  credits?: string;
97
96
  }[];
98
97
  authCodeActivate: AuthCodeActivateCopy;
@@ -1,2 +1,2 @@
1
- "use strict";var g=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var m=(r,e)=>{for(var o in e)g(r,o,{get:e[o],enumerable:!0})},E=(r,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of C(e))!b.call(r,t)&&t!==o&&g(r,t,{get:()=>e[t],enumerable:!(s=u(e,t))||s.enumerable});return r};var f=r=>E(g({},"__esModule",{value:!0}),r);var L={};m(L,{ConsumeCreditsItemType:()=>p,EarnCreditsTaskType:()=>c,MemberPopupActionType:()=>a,MemberPopupPageScope:()=>d,MemberPopupPanelType:()=>l});module.exports=f(L);var l=(i=>(i.EarnCredits="EARN_CREDITS",i.ConsumeCredits="CONSUME_CREDITS",i.Referral="REFERRAL",i.CompleteProfile="COMPLETE_PROFILE",i.Subscribe="SUBSCRIBE",i.SubscribeEmail="SUBSCRIBE_EMAIL",i.RedeemCoupon="REDEEM_COUPON",i.Activate="ACTIVATE",i))(l||{}),a=(n=>(n.ExternalLink="EXTERNAL_LINK",n.OpenEarnCredits="OPEN_EARN_CREDITS",n.OpenConsumeCredits="OPEN_CONSUME_CREDITS",n.OpenReferral="OPEN_REFERRAL",n.OpenSubscribe="OPEN_SUBSCRIBE",n))(a||{}),c=(t=>(t.Activate="activate",t.CompleteProfile="completeProfile",t.Subscribe="subscribe",t.Shop="shop",t))(c||{}),p=(t=>(t.Coupon="COUPON",t.RedeemAndBuy="REDEEM_AND_BUY",t.GiftCard="GIFT_CARD",t.Product="PRODUCT",t))(p||{}),d=(s=>(s.Global="GLOBAL",s.Include="INCLUDE",s.Exclude="EXCLUDE",s))(d||{});
1
+ "use strict";var g=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var m=(r,e)=>{for(var o in e)g(r,o,{get:e[o],enumerable:!0})},E=(r,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of C(e))!b.call(r,t)&&t!==o&&g(r,t,{get:()=>e[t],enumerable:!(s=d(e,t))||s.enumerable});return r};var f=r=>E(g({},"__esModule",{value:!0}),r);var L={};m(L,{ConsumeCreditsItemType:()=>p,EarnCreditsTaskType:()=>c,MemberPopupActionType:()=>a,MemberPopupPageScope:()=>u,MemberPopupPanelType:()=>l});module.exports=f(L);var l=(i=>(i.EarnCredits="EARN_CREDITS",i.ConsumeCredits="CONSUME_CREDITS",i.Referral="REFERRAL",i.CompleteProfile="COMPLETE_PROFILE",i.Subscribe="SUBSCRIBE",i.SubscribeEmail="SUBSCRIBE_EMAIL",i.RedeemCoupon="REDEEM_COUPON",i.Activate="ACTIVATE",i))(l||{}),a=(n=>(n.ExternalLink="EXTERNAL_LINK",n.OpenEarnCredits="OPEN_EARN_CREDITS",n.OpenConsumeCredits="OPEN_CONSUME_CREDITS",n.OpenReferral="OPEN_REFERRAL",n.OpenSubscribe="OPEN_SUBSCRIBE",n))(a||{}),c=(t=>(t.Activate="activate",t.CompleteProfile="completeProfile",t.Subscribe="subscribe",t.Shop="shop",t))(c||{}),p=(t=>(t.Coupon="COUPON",t.RedeemAndBuy="REDEEM_AND_BUY",t.GiftCard="GIFT_CARD",t.Product="PRODUCT",t))(p||{}),u=(s=>(s.Global="GLOBAL",s.Include="INCLUDE",s.Exclude="EXCLUDE",s))(u||{});
2
2
  //# sourceMappingURL=type.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/memberPopup/type.ts"],
4
- "sourcesContent": ["import type { AuthCodeActivateCopy } from '../registration/authCodeActivate/type'\nimport type { CreditInfoResponse } from '../credits/context/response'\nimport type { DTC_TASK_TYPE } from '../credits/context/const'\n\nexport type { AuthCodeActivateCopy }\n\n// \u2500\u2500\u2500 \u9762\u677F\u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupPanelType {\n EarnCredits = 'EARN_CREDITS',\n ConsumeCredits = 'CONSUME_CREDITS',\n Referral = 'REFERRAL',\n CompleteProfile = 'COMPLETE_PROFILE',\n Subscribe = 'SUBSCRIBE',\n SubscribeEmail = 'SUBSCRIBE_EMAIL',\n RedeemCoupon = 'REDEEM_COUPON',\n Activate = 'ACTIVATE',\n}\n\n// \u2500\u2500\u2500 item action \u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupActionType {\n ExternalLink = 'EXTERNAL_LINK',\n OpenEarnCredits = 'OPEN_EARN_CREDITS',\n OpenConsumeCredits = 'OPEN_CONSUME_CREDITS',\n OpenReferral = 'OPEN_REFERRAL',\n OpenSubscribe = 'OPEN_SUBSCRIBE',\n}\n\n// \u2500\u2500\u2500 EarnCredits \u4EFB\u52A1\u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum EarnCreditsTaskType {\n Activate = 'activate',\n CompleteProfile = 'completeProfile',\n Subscribe = 'subscribe',\n Shop = 'shop',\n}\n\n// \u2500\u2500\u2500 ConsumeCredits item \u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum ConsumeCreditsItemType {\n Coupon = 'COUPON',\n RedeemAndBuy = 'REDEEM_AND_BUY',\n GiftCard = 'GIFT_CARD',\n Product = 'PRODUCT',\n}\n\n// \u2500\u2500\u2500 \u901A\u7528 link\uFF08\u7EDF\u4E00\u4E00\u79CD\u7C7B\u578B\uFF09 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type MemberPopupLink = {\n type: MemberPopupActionType\n label: string\n url?: string // \u4EC5 ExternalLink \u65F6\u4F7F\u7528\n}\n\n// \u2500\u2500\u2500 list item \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type MemberPopupItem = {\n title: string\n description?: string\n links: MemberPopupLink[]\n}\n\n// \u2500\u2500 \u4E3B\u7EC4\u4EF6 Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupPageScope {\n /** \u5168\u5C40\u5C55\u793A */\n Global = 'GLOBAL',\n /** \u4EC5\u5728\u7279\u5B9A\u9875\u9762\u5C55\u793A */\n Include = 'INCLUDE',\n /** \u5728\u7279\u5B9A\u9875\u9762\u4E0D\u5C55\u793A */\n Exclude = 'EXCLUDE',\n}\n\nexport type MemberPopupPageConfig = {\n scope: MemberPopupPageScope\n /** \u9875\u9762\u8DEF\u5F84\u5217\u8868\uFF0C\u652F\u6301\u7CBE\u786E\u5339\u914D\u548C\u524D\u7F00\u5339\u914D\uFF08\u5982 \"/products\" \u4F1A\u5339\u914D \"/products/xxx\"\uFF09 */\n pages: string[]\n}\n\nexport type MemberPopupCopy = {\n triggerImg: { url: string; alt?: string }\n title?: string\n subtitle?: string\n list: MemberPopupItem[]\n footer?: {\n loginHint: string\n loginLabel: string\n joinLabel: string\n shopLabel: string\n shopUrl?: string\n }\n activitiesSubscribe?: SubscribeModalCopy\n earnCredits?: EarnCreditsCopy\n consumeCredits?: ConsumeCreditsopy\n referral?: ReferralCopy\n /** \u9875\u9762\u8986\u76D6\u8303\u56F4\u914D\u7F6E\uFF0C\u9ED8\u8BA4\u5168\u5C40\u5C55\u793A */\n pageConfig?: MemberPopupPageConfig\n}\n\n// \u2500\u2500\u2500 EarnCredits Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type EarnCreditsCopy = {\n title?: string\n subtitle?: string\n balanceLabel?: string\n comingSoonLabel?: string\n creditUnit?: string\n joinNow: string\n completed: string\n activate: string\n completeProfileLabel: string\n subscribeLabel: string\n shopNow: string\n goShopLink?: string\n list: {\n id: EarnCreditsTaskType\n title: string\n description: string\n credits?: string\n }[]\n // \u5B50\u5F39\u7A97\u6587\u6848\n authCodeActivate: AuthCodeActivateCopy\n completeProfile: CompleteProfileCopy\n subscribe: SubscribeModalCopy\n}\n\nexport type CompleteProfileCopy = {\n title: string\n subtitle?: string\n firstName: string\n lastName: string\n email: string\n phone: string\n birthday: string\n country: string\n save: string\n cancel: string\n edit: string\n required: string\n}\n\nexport type SubscribeModalCopy = {\n title: string\n desc?: string\n placeholder: string\n policy?: string\n policyDefaultChecked?: boolean\n successTips?: string\n subscribedLabel?: string\n dealsType?: string\n buttonLabel?: string\n single_brand_subscribe?: boolean\n genre?: string\n sub_brand_type?: string\n promo?: {\n title?: string\n description?: string\n learnMoreLabel?: string\n learnMoreUrl?: string\n image?: { url: string; alt?: string }\n }\n}\n\n// \u2500\u2500\u2500 ConsumeCredits Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type ConsumeCreditsopy = {\n title?: string\n subtitle?: string\n soldOut: string\n unlockRewards: string\n btnRedeem: string\n insufficientCredits?: string\n balanceLabel?: string\n comingSoonLabel?: string\n creditUnit?: string\n off?: string\n imageMapping?: {\n [key in ConsumeCreditsItemType]?: { url: string }\n }\n list: ConsumeCreditsItem[]\n redeemModal: RedeemCouponModalCopy\n creditsPage?: { label: string; url: string; redeemListSectionId?: string }\n}\n\nexport type ConsumeCreditsItem = {\n redeemId: string | number\n title: string\n description?: string\n image: { url: string; alt?: string }\n type: ConsumeCreditsItemType\n product?: { handle: string; sku: string }\n price?: number\n value?: string\n rules?: string[]\n}\n\nexport type RedeemCouponModalCopy = {\n confirmTitle: string\n confirmButton: string\n off?: string\n commonError: string\n redeemLimitError: string\n inventoryNotEnough: string\n creditsNotEnough: string\n crossSiteError: string\n successTitle: string\n successDesc: string\n successButton: string\n successButtonUrl?: string\n}\n\n// \u2500\u2500\u2500 Referral Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type ReferralCopy = {\n title?: string\n description?: string\n cashAvailableLabel: string\n cashPendingLabel: string\n creditUnit?: string\n referralLinksLabel?: string\n referralLinkBaseUrl?: string\n copyLabel?: string\n copiedLabel?: string\n howToTitle?: string\n howToDescription?: string\n learnMoreLabel?: string\n learnMoreUrl?: string\n image?: { url: string; alt?: string }\n ctaButton: string\n ctaUrl?: string\n loginTitle?: string\n loginDescription?: string\n loginCtaLabel?: string\n}\n\n// \u2500\u2500\u2500 Provider Context \u7C7B\u578B \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type AlpcConfig = {\n brand: string\n locale: string\n appName: string\n apiBaseUrl?: string\n}\n\nexport type MemberPopupContextValue = {\n profile: any\n isLoadingProfile: boolean\n creditInfo?: CreditInfoResponse\n fetchCreditInfo: (userId: string) => void\n openSignUpPopup: () => void\n openSignInPopup: () => void\n taskIdToTypeMapping?: Record<string, DTC_TASK_TYPE>\n alpcConfig: AlpcConfig\n pageHandle?: string\n}\n\nexport type MemberPopupInternalContextValue = MemberPopupContextValue & {\n isSubscribeSuccess: boolean\n setIsSubscribeSuccess: (v: boolean) => void\n isActivateSuccess: boolean\n setIsActivateSuccess: (v: boolean) => void\n isProfileCompleteSuccess: boolean\n setIsProfileCompleteSuccess: (v: boolean) => void\n}\n"],
4
+ "sourcesContent": ["import type { AuthCodeActivateCopy } from '../registration/authCodeActivate/type'\nimport type { CreditInfoResponse } from '../credits/context/response'\nimport type { DTC_TASK_TYPE } from '../credits/context/const'\n\nexport type { AuthCodeActivateCopy }\n\n// \u2500\u2500\u2500 \u9762\u677F\u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupPanelType {\n EarnCredits = 'EARN_CREDITS',\n ConsumeCredits = 'CONSUME_CREDITS',\n Referral = 'REFERRAL',\n CompleteProfile = 'COMPLETE_PROFILE',\n Subscribe = 'SUBSCRIBE',\n SubscribeEmail = 'SUBSCRIBE_EMAIL',\n RedeemCoupon = 'REDEEM_COUPON',\n Activate = 'ACTIVATE',\n}\n\n// \u2500\u2500\u2500 item action \u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupActionType {\n ExternalLink = 'EXTERNAL_LINK',\n OpenEarnCredits = 'OPEN_EARN_CREDITS',\n OpenConsumeCredits = 'OPEN_CONSUME_CREDITS',\n OpenReferral = 'OPEN_REFERRAL',\n OpenSubscribe = 'OPEN_SUBSCRIBE',\n}\n\n// \u2500\u2500\u2500 EarnCredits \u4EFB\u52A1\u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum EarnCreditsTaskType {\n Activate = 'activate',\n CompleteProfile = 'completeProfile',\n Subscribe = 'subscribe',\n Shop = 'shop',\n}\n\n// \u2500\u2500\u2500 ConsumeCredits item \u7C7B\u578B\u679A\u4E3E \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum ConsumeCreditsItemType {\n Coupon = 'COUPON',\n RedeemAndBuy = 'REDEEM_AND_BUY',\n GiftCard = 'GIFT_CARD',\n Product = 'PRODUCT',\n}\n\n// \u2500\u2500\u2500 \u901A\u7528 link\uFF08\u7EDF\u4E00\u4E00\u79CD\u7C7B\u578B\uFF09 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type MemberPopupLink = {\n type: MemberPopupActionType\n label: string\n url?: string // \u4EC5 ExternalLink \u65F6\u4F7F\u7528\n}\n\n// \u2500\u2500\u2500 list item \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type MemberPopupItem = {\n title: string\n description?: string\n links: MemberPopupLink[]\n}\n\n// \u2500\u2500 \u4E3B\u7EC4\u4EF6 Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport enum MemberPopupPageScope {\n /** \u5168\u5C40\u5C55\u793A */\n Global = 'GLOBAL',\n /** \u4EC5\u5728\u7279\u5B9A\u9875\u9762\u5C55\u793A */\n Include = 'INCLUDE',\n /** \u5728\u7279\u5B9A\u9875\u9762\u4E0D\u5C55\u793A */\n Exclude = 'EXCLUDE',\n}\n\nexport type MemberPopupPageConfig = {\n scope: MemberPopupPageScope\n /** \u9875\u9762\u8DEF\u5F84\u5217\u8868\uFF0C\u652F\u6301\u7CBE\u786E\u5339\u914D\u548C\u524D\u7F00\u5339\u914D\uFF08\u5982 \"/products\" \u4F1A\u5339\u914D \"/products/xxx\"\uFF09 */\n pages: string[]\n}\n\nexport type MemberPopupCopy = {\n triggerImg: { url: string; alt?: string }\n title?: string\n subtitle?: string\n list: MemberPopupItem[]\n footer?: {\n loginHint: string\n loginLabel: string\n joinLabel: string\n shopLabel: string\n shopUrl?: string\n }\n activitiesSubscribe?: SubscribeModalCopy\n earnCredits?: EarnCreditsCopy\n consumeCredits?: ConsumeCreditsopy\n referral?: ReferralCopy\n /** \u9875\u9762\u8986\u76D6\u8303\u56F4\u914D\u7F6E\uFF0C\u9ED8\u8BA4\u5168\u5C40\u5C55\u793A */\n pageConfig?: MemberPopupPageConfig\n}\n\n// \u2500\u2500\u2500 EarnCredits Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type EarnCreditsCopy = {\n title?: string\n subtitle?: string\n balanceLabel?: string\n comingSoonLabel?: string\n creditUnit?: string\n joinNow: string\n completed: string\n activate: string\n completeProfileLabel: string\n subscribeLabel: string\n shopNow: string\n goShopLink?: string\n list: {\n id: EarnCreditsTaskType\n title: string\n credits?: string\n }[]\n // \u5B50\u5F39\u7A97\u6587\u6848\n authCodeActivate: AuthCodeActivateCopy\n completeProfile: CompleteProfileCopy\n subscribe: SubscribeModalCopy\n}\n\nexport type CompleteProfileCopy = {\n title: string\n subtitle?: string\n firstName: string\n lastName: string\n email: string\n phone: string\n birthday: string\n country: string\n save: string\n cancel: string\n edit: string\n required: string\n}\n\nexport type SubscribeModalCopy = {\n title: string\n desc?: string\n placeholder: string\n policy?: string\n policyDefaultChecked?: boolean\n successTips?: string\n subscribedLabel?: string\n dealsType?: string\n buttonLabel?: string\n single_brand_subscribe?: boolean\n genre?: string\n sub_brand_type?: string\n promo?: {\n title?: string\n description?: string\n learnMoreLabel?: string\n learnMoreUrl?: string\n image?: { url: string; alt?: string }\n }\n}\n\n// \u2500\u2500\u2500 ConsumeCredits Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type ConsumeCreditsopy = {\n title?: string\n subtitle?: string\n soldOut: string\n unlockRewards: string\n btnRedeem: string\n insufficientCredits?: string\n balanceLabel?: string\n comingSoonLabel?: string\n creditUnit?: string\n off?: string\n imageMapping?: {\n [key in ConsumeCreditsItemType]?: { url: string }\n }\n list: ConsumeCreditsItem[]\n redeemModal: RedeemCouponModalCopy\n creditsPage?: { label: string; url: string; redeemListSectionId?: string }\n}\n\nexport type ConsumeCreditsItem = {\n redeemId: string | number\n title: string\n description?: string\n image: { url: string; alt?: string }\n type: ConsumeCreditsItemType\n product?: { handle: string; sku: string }\n price?: number\n value?: string\n rules?: string[]\n}\n\nexport type RedeemCouponModalCopy = {\n confirmTitle: string\n confirmButton: string\n off?: string\n commonError: string\n redeemLimitError: string\n inventoryNotEnough: string\n creditsNotEnough: string\n crossSiteError: string\n successTitle: string\n successDesc: string\n successButton: string\n successButtonUrl?: string\n}\n\n// \u2500\u2500\u2500 Referral Copy \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type ReferralCopy = {\n title?: string\n description?: string\n cashAvailableLabel: string\n cashPendingLabel: string\n creditUnit?: string\n referralLinksLabel?: string\n referralLinkBaseUrl?: string\n copyLabel?: string\n copiedLabel?: string\n howToTitle?: string\n howToDescription?: string\n learnMoreLabel?: string\n learnMoreUrl?: string\n image?: { url: string; alt?: string }\n ctaButton: string\n ctaUrl?: string\n loginTitle?: string\n loginDescription?: string\n loginCtaLabel?: string\n}\n\n// \u2500\u2500\u2500 Provider Context \u7C7B\u578B \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nexport type AlpcConfig = {\n brand: string\n locale: string\n appName: string\n apiBaseUrl?: string\n}\n\nexport type MemberPopupContextValue = {\n profile: any\n isLoadingProfile: boolean\n creditInfo?: CreditInfoResponse\n fetchCreditInfo: (userId: string) => void\n openSignUpPopup: () => void\n openSignInPopup: () => void\n taskIdToTypeMapping?: Record<string, DTC_TASK_TYPE>\n alpcConfig: AlpcConfig\n pageHandle?: string\n}\n\nexport type MemberPopupInternalContextValue = MemberPopupContextValue & {\n isSubscribeSuccess: boolean\n setIsSubscribeSuccess: (v: boolean) => void\n isActivateSuccess: boolean\n setIsActivateSuccess: (v: boolean) => void\n isProfileCompleteSuccess: boolean\n setIsProfileCompleteSuccess: (v: boolean) => void\n}\n"],
5
5
  "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4BAAAE,EAAA,wBAAAC,EAAA,0BAAAC,EAAA,yBAAAC,EAAA,yBAAAC,IAAA,eAAAC,EAAAP,GAOO,IAAKM,OACVA,EAAA,YAAc,eACdA,EAAA,eAAiB,kBACjBA,EAAA,SAAW,WACXA,EAAA,gBAAkB,mBAClBA,EAAA,UAAY,YACZA,EAAA,eAAiB,kBACjBA,EAAA,aAAe,gBACfA,EAAA,SAAW,WARDA,OAAA,IAYAF,OACVA,EAAA,aAAe,gBACfA,EAAA,gBAAkB,oBAClBA,EAAA,mBAAqB,uBACrBA,EAAA,aAAe,gBACfA,EAAA,cAAgB,iBALNA,OAAA,IASAD,OACVA,EAAA,SAAW,WACXA,EAAA,gBAAkB,kBAClBA,EAAA,UAAY,YACZA,EAAA,KAAO,OAJGA,OAAA,IAQAD,OACVA,EAAA,OAAS,SACTA,EAAA,aAAe,iBACfA,EAAA,SAAW,YACXA,EAAA,QAAU,UAJAA,OAAA,IAsBAG,OAEVA,EAAA,OAAS,SAETA,EAAA,QAAU,UAEVA,EAAA,QAAU,UANAA,OAAA",
6
6
  "names": ["type_exports", "__export", "ConsumeCreditsItemType", "EarnCreditsTaskType", "MemberPopupActionType", "MemberPopupPageScope", "MemberPopupPanelType", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var O=Object.create;var l=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var Y=(r,t)=>{for(var d in t)l(r,d,{get:t[d],enumerable:!0})},T=(r,t,d,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of H(t))!K.call(r,n)&&n!==d&&l(r,n,{get:()=>t[n],enumerable:!(i=U(t,n))||i.enumerable});return r};var h=(r,t,d)=>(d=r!=null?O(W(r)):{},T(t||!r||!r.__esModule?l(d,"default",{value:r,enumerable:!0}):d,r)),z=r=>T(l({},"__esModule",{value:!0}),r);var V={};Y(V,{CreditsTemplate:()=>Q});module.exports=z(V);var e=require("react/jsx-runtime"),f=require("@anker-in/lib"),u=require("react"),M=require("../components/registration/context/provider"),g=require("../components/credits/context/provider"),w=require("../components/credits/creditsBanner"),B=require("../components/credits/creditsInfoCard"),b=require("../components/credits/creditsBenefits"),I=require("../components/credits/creditsWaysToGetCredits"),G=require("../components/credits/creditsAnkersolixTask"),L=require("../components/credits/creditsRedeemList"),R=require("../components/credits/creditsGoGift"),S=require("../components/credits/creditsCash"),A=require("../components/credits/creditsMemberPrice"),F=require("../components/credits/creditsFaq"),q=require("../components/credits/creditsNavigation"),D=h(require("../components/credits/modal/ActivitiesModal")),N=h(require("../components/credits/modal/RewardsModal")),s=require("./Credits.types");const J=({headlessConfig:r,pageConfig:t,userContext:d})=>{const{openMyRewardsModal:i,setOpenMyRewardsModal:n,openActivitiesModal:m,setOpenActivitiesModal:y,pageCommon:p}=(0,g.useCreditsContext)(),v=(0,u.useRef)(!1);return(0,u.useEffect)(()=>{if(v.current||typeof window>"u")return;const a=new URLSearchParams(window.location.search).get("section");if(!a)return;const x=56,E=C=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{const c=C.getBoundingClientRect().top+window.pageYOffset-x;window.scrollTo({top:c,behavior:"instant"}),v.current=!0})})},P=(C=0)=>{const c=document.getElementById(a);c?E(c):C<15&&setTimeout(()=>P(C+1),200)};document.readyState==="complete"?P():window.addEventListener("load",()=>P(),{once:!0})},[]),(0,e.jsxs)(e.Fragment,{children:[t.components[s.ComponentKey.Navigation]&&(0,e.jsx)(q.CreditsNavigation,{copy:t.components[s.ComponentKey.Navigation]}),(0,e.jsx)("div",{className:(0,f.classNames)("bg-[#f5f5f7] leading-[1.2]"),children:t.order.map(o=>{if(o===s.ComponentKey.Navigation)return null;const a=t.components?.[o];return a?(0,e.jsxs)(e.Fragment,{children:[o===s.ComponentKey.Banner&&(0,e.jsx)(w.CreditsBanner,{copy:a,id:o}),o===s.ComponentKey.InfoCard&&d?.profile&&(0,e.jsx)(B.CreditsInfoCard,{copy:a,id:o}),o===s.ComponentKey.Benefits&&(0,e.jsx)(b.CreditsBenefits,{copy:a,id:o}),o===s.ComponentKey.WaysToGetCredits&&(0,e.jsx)(I.CreditsWaysToGetCredits,{copy:a,id:o,classNames:r.brand==="anker"?{subtitle:"text-white",equalCreditsText:"bg-gradient-to-r from-[#3AD1FF] to-[#008CD6] bg-clip-text text-transparent"}:{subtitle:"text-[#D1D1D1]",equalCreditsText:"text-[#F6EAD0]"}}),o===s.ComponentKey.AnkersolixTask&&(0,e.jsx)(G.CreditsAnkersolixTask,{copy:a,id:o}),o===s.ComponentKey.RedeemList&&(0,e.jsx)(L.CreditsRedeemList,{copy:a,id:o}),o===s.ComponentKey.GoGift&&(0,e.jsx)(R.CreditsGoGift,{copy:a,id:o}),o===s.ComponentKey.SpendCreditsLikeCash&&(0,e.jsx)(S.CreditsCash,{copy:a,id:o}),o===s.ComponentKey.MemberPrice&&(0,e.jsx)(A.CreditsMemberPrice,{copy:a,id:o}),o===s.ComponentKey.Faqs&&(0,e.jsx)(F.CreditsFaq,{copy:a,id:o}),o!==s.ComponentKey.Banner&&(0,e.jsx)("div",{className:"laptop:h-16 desktop:h-[96px] lg-desktop:h-[128px] tablet:h-16 h-16"})]}):null})}),p?.activitiesModal&&(0,e.jsx)(D.default,{isOpen:m,data:p.activitiesModal,onClose:()=>y(!1)}),p?.rewardsModal&&(0,e.jsx)(N.default,{isOpen:i,data:p.rewardsModal,onClose:()=>n(!1)})]})},Q=({headlessConfig:r,siteConfig:t,creditsConfig:d,userContext:i,pageConfig:n,registrationContext:m,gtm:y,cartConfig:p})=>(0,e.jsx)(f.HeadlessProvider,{headlessConfig:r,children:(0,e.jsx)(M.RegistrationProvider,{copy:t.registrationsSettings,email:i?.profile?.email,children:(0,e.jsx)(g.CreditsProvider,{profile:i?.profile,removeProfile:i?.removeProfile,isLoadingProfile:i?.isLoadingProfile,openSignInPopup:m.openSignInPopup,openSignUpPopup:m.openSignUpPopup,creditInfo:i?.creditInfo,taskIdToTypeMapping:t.taskIdToTypeMapping,customer:i?.customer,fetchCreditInfo:i?.fetchCreditInfo,customerLoading:i?.customerLoading,gtm:y,pageCommon:n.common,memberPriceDiscount:t.memberPriceDiscount,alpcBrand:d?.alpcBrand,cartConfig:p,apiBaseUrl:i?.apiBaseUrl,children:(0,e.jsx)(J,{headlessConfig:r,pageConfig:n,userContext:i})})})});
1
+ "use strict";var U=Object.create;var C=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var Y=(r,i)=>{for(var a in i)C(r,a,{get:i[a],enumerable:!0})},h=(r,i,a,t)=>{if(i&&typeof i=="object"||typeof i=="function")for(let p of E(i))!K.call(r,p)&&p!==a&&C(r,p,{get:()=>i[p],enumerable:!(t=W(i,p))||t.enumerable});return r};var T=(r,i,a)=>(a=r!=null?U(H(r)):{},h(i||!r||!r.__esModule?C(a,"default",{value:r,enumerable:!0}):a,r)),z=r=>h(C({},"__esModule",{value:!0}),r);var V={};Y(V,{CreditsTemplate:()=>Q});module.exports=z(V);var e=require("react/jsx-runtime"),c=require("@anker-in/lib"),l=require("react"),M=require("../components/registration/context/provider"),f=require("../components/credits/context/provider"),w=require("../components/credits/creditsBanner"),B=require("../components/credits/creditsInfoCard"),b=require("../components/credits/creditsBenefits"),I=require("../components/credits/creditsWaysToGetCredits"),G=require("../components/credits/creditsAnkersolixTask"),R=require("../components/credits/creditsRedeemList"),L=require("../components/credits/creditsGoGift"),A=require("../components/credits/creditsCash"),S=require("../components/credits/creditsMemberPrice"),D=require("../components/credits/creditsFaq"),N=require("../components/credits/creditsNavigation"),F=T(require("../components/credits/modal/ActivitiesModal")),q=T(require("../components/credits/modal/RewardsModal")),s=require("./Credits.types");const J=({headlessConfig:r,pageConfig:i,userContext:a})=>{const{openMyRewardsModal:t,setOpenMyRewardsModal:p,openActivitiesModal:m,setOpenActivitiesModal:g,pageCommon:n}=(0,f.useCreditsContext)(),y=(0,l.useRef)(!1);return(0,l.useEffect)(()=>{if(y.current||typeof window>"u")return;const d=new URLSearchParams(window.location.search).get("section");if(!d)return;const x=56,P=(u=0)=>{const v=document.getElementById(d);if(v){y.current=!0;const O=v.getBoundingClientRect().top+window.pageYOffset-x;window.scrollTo({top:O,behavior:"smooth"})}else u<10&&setTimeout(()=>P(u+1),300)};P()},[]),(0,e.jsxs)(e.Fragment,{children:[i.components[s.ComponentKey.Navigation]&&(0,e.jsx)(N.CreditsNavigation,{copy:i.components[s.ComponentKey.Navigation]}),(0,e.jsx)("div",{className:(0,c.classNames)("bg-[#f5f5f7] leading-[1.2]"),children:i.order.map(o=>{if(o===s.ComponentKey.Navigation)return null;const d=i.components?.[o];return d?(0,e.jsxs)(e.Fragment,{children:[o===s.ComponentKey.Banner&&(0,e.jsx)(w.CreditsBanner,{copy:d,id:o}),o===s.ComponentKey.InfoCard&&a?.profile&&(0,e.jsx)(B.CreditsInfoCard,{copy:d,id:o}),o===s.ComponentKey.Benefits&&(0,e.jsx)(b.CreditsBenefits,{copy:d,id:o}),o===s.ComponentKey.WaysToGetCredits&&(0,e.jsx)(I.CreditsWaysToGetCredits,{copy:d,id:o,classNames:r.brand==="anker"?{subtitle:"text-white",equalCreditsText:"bg-gradient-to-r from-[#3AD1FF] to-[#008CD6] bg-clip-text text-transparent"}:{subtitle:"text-[#D1D1D1]",equalCreditsText:"text-[#F6EAD0]"}}),o===s.ComponentKey.AnkersolixTask&&(0,e.jsx)(G.CreditsAnkersolixTask,{copy:d,id:o}),o===s.ComponentKey.RedeemList&&(0,e.jsx)(R.CreditsRedeemList,{copy:d,id:o}),o===s.ComponentKey.GoGift&&(0,e.jsx)(L.CreditsGoGift,{copy:d,id:o}),o===s.ComponentKey.SpendCreditsLikeCash&&(0,e.jsx)(A.CreditsCash,{copy:d,id:o}),o===s.ComponentKey.MemberPrice&&(0,e.jsx)(S.CreditsMemberPrice,{copy:d,id:o}),o===s.ComponentKey.Faqs&&(0,e.jsx)(D.CreditsFaq,{copy:d,id:o}),o!==s.ComponentKey.Banner&&(0,e.jsx)("div",{className:"laptop:h-16 desktop:h-[96px] lg-desktop:h-[128px] tablet:h-16 h-16"})]}):null})}),n?.activitiesModal&&(0,e.jsx)(F.default,{isOpen:m,data:n.activitiesModal,onClose:()=>g(!1)}),n?.rewardsModal&&(0,e.jsx)(q.default,{isOpen:t,data:n.rewardsModal,onClose:()=>p(!1)})]})},Q=({headlessConfig:r,siteConfig:i,creditsConfig:a,userContext:t,pageConfig:p,registrationContext:m,gtm:g,cartConfig:n})=>(0,e.jsx)(c.HeadlessProvider,{headlessConfig:r,children:(0,e.jsx)(M.RegistrationProvider,{copy:i.registrationsSettings,email:t?.profile?.email,children:(0,e.jsx)(f.CreditsProvider,{profile:t?.profile,removeProfile:t?.removeProfile,isLoadingProfile:t?.isLoadingProfile,openSignInPopup:m.openSignInPopup,openSignUpPopup:m.openSignUpPopup,creditInfo:t?.creditInfo,taskIdToTypeMapping:i.taskIdToTypeMapping,customer:t?.customer,fetchCreditInfo:t?.fetchCreditInfo,customerLoading:t?.customerLoading,gtm:g,pageCommon:p.common,memberPriceDiscount:i.memberPriceDiscount,alpcBrand:a?.alpcBrand,cartConfig:n,apiBaseUrl:t?.apiBaseUrl,children:(0,e.jsx)(J,{headlessConfig:r,pageConfig:p,userContext:t})})})});
2
2
  //# sourceMappingURL=Credits.js.map