@anker-in/campaign-ui 0.5.24 → 0.5.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/credits/creditsWaysToGetCredits/useActions.js +1 -1
- package/dist/cjs/components/credits/creditsWaysToGetCredits/useActions.js.map +3 -3
- package/dist/esm/components/credits/creditsWaysToGetCredits/useActions.js +1 -1
- package/dist/esm/components/credits/creditsWaysToGetCredits/useActions.js.map +3 -3
- package/package.json +1 -1
- package/src/components/credits/creditsWaysToGetCredits/useActions.ts +25 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var A=Object.create;var c=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var E=Object.getPrototypeOf,G=Object.prototype.hasOwnProperty;var W=(e,o)=>{for(var a in o)c(e,a,{get:o[a],enumerable:!0})},P=(e,o,a,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of x(o))!G.call(e,n)&&n!==a&&c(e,n,{get:()=>o[n],enumerable:!(r=T(o,n))||r.enumerable});return e};var $=(e,o,a)=>(a=e!=null?A(E(e)):{},P(o||!e||!e.__esModule?c(a,"default",{value:e,enumerable:!0}):a,e)),q=e=>P(c({},"__esModule",{value:!0}),e);var M={};W(M,{useActions:()=>H});module.exports=q(M);var u=require("../../../lib"),t=require("./type"),g=require("../context/provider"),s=require("react"),v=$(require("../context/hooks/useReceiptUploaded")),S=require("../context/hooks/useFirstPurchaseFinished"),w=require("../context/hooks/useSubscribed"),F=require("../../registration");const H=({copy:e,subscribe:o,uploadReceipt:a,gaParameters:r})=>{const{openSignUpPopup:n,gtm:R,profile:l}=(0,g.useCreditsContext)(),{authCodeActivate:p}=(0,F.useRegistration)(),h=(0,w.useSubscribed)(),k=(0,S.useFirstPurchaseFinished)(),f=(0,v.default)(),{appName:d,passportUrl:L}=(0,u.useHeadlessContext)(),[m,j]=(0,s.useState)("");(0,s.useEffect)(()=>{j(window.location.href)},[]);const C=(0,s.useMemo)(()=>{const i=new URLSearchParams;d&&i.set("app",d),m&&i.set("redirect",m);const b=i.toString();return`${L}/account/profile${b?`?${b}`:""}`},[L,d,m]),N=(0,s.useMemo)(()=>(l?.first_name||l?.last_name)&&l?.phone_number&&l?.dob,[l]);return(0,s.useMemo)(()=>{const i=({buttonName:b,id:U,callback:_})=>{(0,u.gaTrack)({event:"ga4Event",event_name:"lp_button",member_active_status:l?.activated?"active":"not active",event_parameters:{page_group:R.pageGroup,position:r?.position||e.title,button_name:b,info:U}}),_()};return{actions:{[t.TaskType.Activate]:{finished:l?.activated,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:n,id:t.TaskType.Activate})},notFinished:{buttonLabel:e?.activate,handleClick:()=>i({buttonName:e?.activate,callback:()=>{p.setAutoSendEmail(!0),p.open()},id:t.TaskType.Activate})},completed:{buttonLabel:e?.completed}},[t.TaskType.Subscribe]:{finished:h,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:n,id:t.TaskType.Subscribe})},notFinished:{buttonLabel:e?.subscribeLabel,handleClick:()=>i({buttonName:e?.subscribeLabel,callback:()=>o.openSubscribePopup(),id:t.TaskType.Subscribe})},completed:{buttonLabel:e?.completed}},[t.TaskType.CompleteProfile]:{finished:N,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:n,id:t.TaskType.CompleteProfile})},notFinished:{buttonLabel:e?.completeProfile,link:C,handleClick:()=>i({buttonName:e?.completeProfile,callback:()=>{},id:t.TaskType.CompleteProfile})},completed:{buttonLabel:e?.completed}},[t.TaskType.FirstPurchase]:{finished:k,notLogin:{buttonLabel:e?.makeFirstPurchase,handleClick:()=>i({buttonName:e?.makeFirstPurchase,callback:n,id:t.TaskType.FirstPurchase})},notFinished:{buttonLabel:e?.makeFirstPurchase,link:e?.goShopLink,handleClick:()=>i({buttonName:e?.makeFirstPurchase,callback:()=>{},id:t.TaskType.FirstPurchase})},completed:{buttonLabel:e?.completed}},[t.TaskType.UploadReceipt]:{finished:f,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:n,id:t.TaskType.UploadReceipt})},notFinished:{buttonLabel:e?.uploadReceipt,handleClick:()=>i({buttonName:e?.uploadReceipt,callback:()=>a.openUploadReceiptPopup(),id:t.TaskType.UploadReceipt})},completed:{buttonLabel:e?.completed}},[t.TaskType.Shop]:{finished:!1,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:n,id:t.TaskType.Shop})},notFinished:{buttonLabel:e?.shopNow,link:e?.goShopLink,handleClick:()=>i({buttonName:e?.shopNow,callback:()=>{},id:t.TaskType.Shop})},completed:{buttonLabel:e?.completed}}}}},[l?.activated,e?.joinNow,e?.activate,e?.completed,e?.subscribe,e?.completeProfile,e?.makeFirstPurchase,e?.uploadReceipt,e?.shopNow,e.title,e?.goShopLink,h,N,k,f,r?.position,n,C])};
|
|
2
2
|
//# sourceMappingURL=useActions.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/components/credits/creditsWaysToGetCredits/useActions.ts"],
|
|
4
|
-
"sourcesContent": ["import { useHeadlessContext, gaTrack } from '../../../lib'\n\nimport { TaskType } from './type'\nimport { useCreditsContext } from '../context/provider'\nimport { useMemo } from 'react'\nimport useReceiptUploaded from '../context/hooks/useReceiptUploaded'\nimport { useFirstPurchaseFinished } from '../context/hooks/useFirstPurchaseFinished'\nimport { useSubscribed } from '../context/hooks/useSubscribed'\nimport type { CreditsWaysToGetCreditsCopy } from './type'\n\nimport { useRegistration } from '../../registration'\n\nexport const useActions = ({\n copy,\n subscribe,\n uploadReceipt,\n gaParameters,\n}: {\n copy: CreditsWaysToGetCreditsCopy\n subscribe: {\n openSubscribePopup: () => void\n isSuccess: boolean\n }\n uploadReceipt: {\n openUploadReceiptPopup: () => void\n isSuccess: boolean\n }\n gaParameters?: {\n position: string\n }\n}) => {\n const { openSignUpPopup, gtm, profile } = useCreditsContext()\n const { authCodeActivate } = useRegistration()\n const isSubscribed = useSubscribed()\n const firstPurchaseFinished = useFirstPurchaseFinished()\n const uploadedReceipt = useReceiptUploaded()\n const { appName, passportUrl } = useHeadlessContext()\n\n const profileCompleted = useMemo(() => {\n return (profile?.first_name || profile?.last_name) && profile?.phone_number && profile?.dob\n }, [profile])\n\n return useMemo(() => {\n const handleClickWithTrack = ({\n buttonName,\n id,\n callback,\n }: {\n buttonName: string\n id?: string\n callback: () => void\n }) => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: gtm.pageGroup,\n position: gaParameters?.position || copy.title,\n button_name: buttonName,\n info: id,\n },\n })\n callback()\n }\n return {\n actions: {\n [TaskType.Activate]: {\n finished: profile?.activated,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({ buttonName: copy?.joinNow, callback: openSignUpPopup, id: TaskType.Activate }),\n },\n notFinished: {\n buttonLabel: copy?.activate,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.activate,\n callback: () => {\n authCodeActivate.setAutoSendEmail(true)\n authCodeActivate.open()\n },\n id: TaskType.Activate,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.Subscribe]: {\n finished: isSubscribed,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({ buttonName: copy?.joinNow, callback: openSignUpPopup, id: TaskType.Subscribe }),\n },\n notFinished: {\n buttonLabel: copy?.subscribeLabel,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.subscribeLabel,\n callback: () => subscribe.openSubscribePopup(),\n id: TaskType.Subscribe,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.CompleteProfile]: {\n finished: profileCompleted,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.CompleteProfile,\n }),\n },\n notFinished: {\n buttonLabel: copy?.completeProfile,\n link:
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4C,wBAE5CC,EAAyB,kBACzBC,EAAkC,+BAClCC,
|
|
6
|
-
"names": ["useActions_exports", "__export", "useActions", "__toCommonJS", "import_lib", "import_type", "import_provider", "import_react", "import_useReceiptUploaded", "import_useFirstPurchaseFinished", "import_useSubscribed", "import_registration", "copy", "subscribe", "uploadReceipt", "gaParameters", "openSignUpPopup", "gtm", "profile", "authCodeActivate", "isSubscribed", "firstPurchaseFinished", "uploadedReceipt", "useReceiptUploaded", "appName", "passportUrl", "profileCompleted", "handleClickWithTrack", "buttonName", "id", "callback"]
|
|
4
|
+
"sourcesContent": ["import { useHeadlessContext, gaTrack } from '../../../lib'\n\nimport { TaskType } from './type'\nimport { useCreditsContext } from '../context/provider'\nimport { useEffect, useMemo, useState } from 'react'\nimport useReceiptUploaded from '../context/hooks/useReceiptUploaded'\nimport { useFirstPurchaseFinished } from '../context/hooks/useFirstPurchaseFinished'\nimport { useSubscribed } from '../context/hooks/useSubscribed'\nimport type { CreditsWaysToGetCreditsCopy } from './type'\n\nimport { useRegistration } from '../../registration'\n\nexport const useActions = ({\n copy,\n subscribe,\n uploadReceipt,\n gaParameters,\n}: {\n copy: CreditsWaysToGetCreditsCopy\n subscribe: {\n openSubscribePopup: () => void\n isSuccess: boolean\n }\n uploadReceipt: {\n openUploadReceiptPopup: () => void\n isSuccess: boolean\n }\n gaParameters?: {\n position: string\n }\n}) => {\n const { openSignUpPopup, gtm, profile } = useCreditsContext()\n const { authCodeActivate } = useRegistration()\n const isSubscribed = useSubscribed()\n const firstPurchaseFinished = useFirstPurchaseFinished()\n const uploadedReceipt = useReceiptUploaded()\n const { appName, passportUrl } = useHeadlessContext()\n\n // window \u5728 SSR\uFF08Next.js \u670D\u52A1\u7AEF\u6E32\u67D3\uFF09\u4E0B\u4E0D\u5B58\u5728\uFF0C\u76F4\u63A5\u8BFB window.location.href \u4F1A\u5BFC\u81F4\n // \u670D\u52A1\u7AEF\u62A5 \"window is not defined\"\uFF0C\u4E14\u670D\u52A1\u7AEF/\u5BA2\u6237\u7AEF\u9996\u5E27\u7ED3\u679C\u4E0D\u4E00\u81F4\u5F15\u53D1 hydration mismatch\u3002\n // \u8FD9\u91CC\u7EDF\u4E00\u5EF6\u8FDF\u5230\u5BA2\u6237\u7AEF\u6302\u8F7D\u540E\u518D\u8BFB\u53D6\uFF0C\u4FDD\u8BC1\u4E24\u7AEF\u9996\u5E27\u6E32\u67D3\u7ED3\u679C\u4E00\u81F4\u3002\n const [clientUrl, setClientUrl] = useState('')\n\n useEffect(() => {\n setClientUrl(window.location.href)\n }, [])\n\n // passport \u5B8C\u6210\u8D44\u6599\u540E\u56DE\u8DF3\u5230\u5F53\u524D\u9875\u9762\uFF0C\u9700\u6574\u4F53 encode\uFF0C\u5426\u5219 href \u91CC\u7684 ? / & / # \u4F1A\u6C61\u67D3 query\n const completeProfileLink = useMemo(() => {\n const query = new URLSearchParams()\n if (appName) {\n query.set('app', appName)\n }\n if (clientUrl) {\n query.set('redirect', clientUrl)\n }\n const search = query.toString()\n return `${passportUrl}/account/profile${search ? `?${search}` : ''}`\n }, [passportUrl, appName, clientUrl])\n\n const profileCompleted = useMemo(() => {\n return (profile?.first_name || profile?.last_name) && profile?.phone_number && profile?.dob\n }, [profile])\n\n return useMemo(() => {\n const handleClickWithTrack = ({\n buttonName,\n id,\n callback,\n }: {\n buttonName: string\n id?: string\n callback: () => void\n }) => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: gtm.pageGroup,\n position: gaParameters?.position || copy.title,\n button_name: buttonName,\n info: id,\n },\n })\n callback()\n }\n return {\n actions: {\n [TaskType.Activate]: {\n finished: profile?.activated,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({ buttonName: copy?.joinNow, callback: openSignUpPopup, id: TaskType.Activate }),\n },\n notFinished: {\n buttonLabel: copy?.activate,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.activate,\n callback: () => {\n authCodeActivate.setAutoSendEmail(true)\n authCodeActivate.open()\n },\n id: TaskType.Activate,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.Subscribe]: {\n finished: isSubscribed,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({ buttonName: copy?.joinNow, callback: openSignUpPopup, id: TaskType.Subscribe }),\n },\n notFinished: {\n buttonLabel: copy?.subscribeLabel,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.subscribeLabel,\n callback: () => subscribe.openSubscribePopup(),\n id: TaskType.Subscribe,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.CompleteProfile]: {\n finished: profileCompleted,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.CompleteProfile,\n }),\n },\n notFinished: {\n buttonLabel: copy?.completeProfile,\n link: completeProfileLink,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.completeProfile,\n callback: () => {},\n id: TaskType.CompleteProfile,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.FirstPurchase]: {\n finished: firstPurchaseFinished,\n notLogin: {\n buttonLabel: copy?.makeFirstPurchase,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.makeFirstPurchase,\n callback: openSignUpPopup,\n id: TaskType.FirstPurchase,\n }),\n },\n notFinished: {\n buttonLabel: copy?.makeFirstPurchase,\n link: copy?.goShopLink,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.makeFirstPurchase,\n callback: () => {},\n id: TaskType.FirstPurchase,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.UploadReceipt]: {\n finished: uploadedReceipt,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.UploadReceipt,\n }),\n },\n notFinished: {\n buttonLabel: copy?.uploadReceipt,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.uploadReceipt,\n callback: () => uploadReceipt.openUploadReceiptPopup(),\n id: TaskType.UploadReceipt,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.Shop]: {\n finished: false,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.Shop,\n }),\n },\n notFinished: {\n buttonLabel: copy?.shopNow,\n link: copy?.goShopLink,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.shopNow,\n callback: () => {},\n id: TaskType.Shop,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n },\n }\n }, [\n profile?.activated,\n copy?.joinNow,\n copy?.activate,\n copy?.completed,\n copy?.subscribe,\n copy?.completeProfile,\n copy?.makeFirstPurchase,\n copy?.uploadReceipt,\n copy?.shopNow,\n copy.title,\n copy?.goShopLink,\n isSubscribed,\n profileCompleted,\n firstPurchaseFinished,\n uploadedReceipt,\n gaParameters?.position,\n openSignUpPopup,\n completeProfileLink,\n ])\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4C,wBAE5CC,EAAyB,kBACzBC,EAAkC,+BAClCC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AAUI,EACV,GAAI,WAAS,aACf,CAAC,CACL,EACA,YAAa,CACX,YAAaJ,GAAM,kBACnB,KAAMA,GAAM,WACZ,YAAa,IACXoB,EAAqB,CACnB,WAAYpB,GAAM,kBAClB,SAAU,IAAM,CAAC,EACjB,GAAI,WAAS,aACf,CAAC,CACL,EACA,UAAW,CACT,YAAaA,GAAM,SACrB,CACF,EACA,CAAC,WAAS,aAAa,EAAG,CACxB,SAAUU,EACV,SAAU,CACR,YAAaV,GAAM,QACnB,YAAa,IACXoB,EAAqB,CACnB,WAAYpB,GAAM,QAClB,SAAUI,EACV,GAAI,WAAS,aACf,CAAC,CACL,EACA,YAAa,CACX,YAAaJ,GAAM,cACnB,YAAa,IACXoB,EAAqB,CACnB,WAAYpB,GAAM,cAClB,SAAU,IAAME,EAAc,uBAAuB,EACrD,GAAI,WAAS,aACf,CAAC,CACL,EACA,UAAW,CACT,YAAaF,GAAM,SACrB,CACF,EACA,CAAC,WAAS,IAAI,EAAG,CACf,SAAU,GACV,SAAU,CACR,YAAaA,GAAM,QACnB,YAAa,IACXoB,EAAqB,CACnB,WAAYpB,GAAM,QAClB,SAAUI,EACV,GAAI,WAAS,IACf,CAAC,CACL,EACA,YAAa,CACX,YAAaJ,GAAM,QACnB,KAAMA,GAAM,WACZ,YAAa,IACXoB,EAAqB,CACnB,WAAYpB,GAAM,QAClB,SAAU,IAAM,CAAC,EACjB,GAAI,WAAS,IACf,CAAC,CACL,EACA,UAAW,CACT,YAAaA,GAAM,SACrB,CACF,CACF,CACF,CACF,EAAG,CACDM,GAAS,UACTN,GAAM,QACNA,GAAM,SACNA,GAAM,UACNA,GAAM,UACNA,GAAM,gBACNA,GAAM,kBACNA,GAAM,cACNA,GAAM,QACNA,EAAK,MACLA,GAAM,WACNQ,EACAW,EACAV,EACAC,EACAP,GAAc,SACdC,EACAY,CACF,CAAC,CACH",
|
|
6
|
+
"names": ["useActions_exports", "__export", "useActions", "__toCommonJS", "import_lib", "import_type", "import_provider", "import_react", "import_useReceiptUploaded", "import_useFirstPurchaseFinished", "import_useSubscribed", "import_registration", "copy", "subscribe", "uploadReceipt", "gaParameters", "openSignUpPopup", "gtm", "profile", "authCodeActivate", "isSubscribed", "firstPurchaseFinished", "uploadedReceipt", "useReceiptUploaded", "appName", "passportUrl", "clientUrl", "setClientUrl", "completeProfileLink", "query", "search", "profileCompleted", "handleClickWithTrack", "buttonName", "id", "callback"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useHeadlessContext as
|
|
1
|
+
import{useHeadlessContext as v,gaTrack as S}from"../../../lib";import{TaskType as t}from"./type";import{useCreditsContext as w}from"../context/provider";import{useEffect as F,useMemo as r,useState as R}from"react";import j from"../context/hooks/useReceiptUploaded";import{useFirstPurchaseFinished as U}from"../context/hooks/useFirstPurchaseFinished";import{useSubscribed as _}from"../context/hooks/useSubscribed";import{useRegistration as A}from"../../registration";const M=({copy:e,subscribe:f,uploadReceipt:L,gaParameters:b})=>{const{openSignUpPopup:n,gtm:C,profile:o}=w(),{authCodeActivate:c}=A(),u=_(),d=U(),m=j(),{appName:l,passportUrl:p}=v(),[s,N]=R("");F(()=>{N(window.location.href)},[]);const h=r(()=>{const i=new URLSearchParams;l&&i.set("app",l),s&&i.set("redirect",s);const a=i.toString();return`${p}/account/profile${a?`?${a}`:""}`},[p,l,s]),k=r(()=>(o?.first_name||o?.last_name)&&o?.phone_number&&o?.dob,[o]);return r(()=>{const i=({buttonName:a,id:P,callback:g})=>{S({event:"ga4Event",event_name:"lp_button",member_active_status:o?.activated?"active":"not active",event_parameters:{page_group:C.pageGroup,position:b?.position||e.title,button_name:a,info:P}}),g()};return{actions:{[t.Activate]:{finished:o?.activated,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:n,id:t.Activate})},notFinished:{buttonLabel:e?.activate,handleClick:()=>i({buttonName:e?.activate,callback:()=>{c.setAutoSendEmail(!0),c.open()},id:t.Activate})},completed:{buttonLabel:e?.completed}},[t.Subscribe]:{finished:u,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:n,id:t.Subscribe})},notFinished:{buttonLabel:e?.subscribeLabel,handleClick:()=>i({buttonName:e?.subscribeLabel,callback:()=>f.openSubscribePopup(),id:t.Subscribe})},completed:{buttonLabel:e?.completed}},[t.CompleteProfile]:{finished:k,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:n,id:t.CompleteProfile})},notFinished:{buttonLabel:e?.completeProfile,link:h,handleClick:()=>i({buttonName:e?.completeProfile,callback:()=>{},id:t.CompleteProfile})},completed:{buttonLabel:e?.completed}},[t.FirstPurchase]:{finished:d,notLogin:{buttonLabel:e?.makeFirstPurchase,handleClick:()=>i({buttonName:e?.makeFirstPurchase,callback:n,id:t.FirstPurchase})},notFinished:{buttonLabel:e?.makeFirstPurchase,link:e?.goShopLink,handleClick:()=>i({buttonName:e?.makeFirstPurchase,callback:()=>{},id:t.FirstPurchase})},completed:{buttonLabel:e?.completed}},[t.UploadReceipt]:{finished:m,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:n,id:t.UploadReceipt})},notFinished:{buttonLabel:e?.uploadReceipt,handleClick:()=>i({buttonName:e?.uploadReceipt,callback:()=>L.openUploadReceiptPopup(),id:t.UploadReceipt})},completed:{buttonLabel:e?.completed}},[t.Shop]:{finished:!1,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:n,id:t.Shop})},notFinished:{buttonLabel:e?.shopNow,link:e?.goShopLink,handleClick:()=>i({buttonName:e?.shopNow,callback:()=>{},id:t.Shop})},completed:{buttonLabel:e?.completed}}}}},[o?.activated,e?.joinNow,e?.activate,e?.completed,e?.subscribe,e?.completeProfile,e?.makeFirstPurchase,e?.uploadReceipt,e?.shopNow,e.title,e?.goShopLink,u,k,d,m,b?.position,n,h])};export{M as useActions};
|
|
2
2
|
//# sourceMappingURL=useActions.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/components/credits/creditsWaysToGetCredits/useActions.ts"],
|
|
4
|
-
"sourcesContent": ["import { useHeadlessContext, gaTrack } from '../../../lib'\n\nimport { TaskType } from './type'\nimport { useCreditsContext } from '../context/provider'\nimport { useMemo } from 'react'\nimport useReceiptUploaded from '../context/hooks/useReceiptUploaded'\nimport { useFirstPurchaseFinished } from '../context/hooks/useFirstPurchaseFinished'\nimport { useSubscribed } from '../context/hooks/useSubscribed'\nimport type { CreditsWaysToGetCreditsCopy } from './type'\n\nimport { useRegistration } from '../../registration'\n\nexport const useActions = ({\n copy,\n subscribe,\n uploadReceipt,\n gaParameters,\n}: {\n copy: CreditsWaysToGetCreditsCopy\n subscribe: {\n openSubscribePopup: () => void\n isSuccess: boolean\n }\n uploadReceipt: {\n openUploadReceiptPopup: () => void\n isSuccess: boolean\n }\n gaParameters?: {\n position: string\n }\n}) => {\n const { openSignUpPopup, gtm, profile } = useCreditsContext()\n const { authCodeActivate } = useRegistration()\n const isSubscribed = useSubscribed()\n const firstPurchaseFinished = useFirstPurchaseFinished()\n const uploadedReceipt = useReceiptUploaded()\n const { appName, passportUrl } = useHeadlessContext()\n\n const profileCompleted = useMemo(() => {\n return (profile?.first_name || profile?.last_name) && profile?.phone_number && profile?.dob\n }, [profile])\n\n return useMemo(() => {\n const handleClickWithTrack = ({\n buttonName,\n id,\n callback,\n }: {\n buttonName: string\n id?: string\n callback: () => void\n }) => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: gtm.pageGroup,\n position: gaParameters?.position || copy.title,\n button_name: buttonName,\n info: id,\n },\n })\n callback()\n }\n return {\n actions: {\n [TaskType.Activate]: {\n finished: profile?.activated,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({ buttonName: copy?.joinNow, callback: openSignUpPopup, id: TaskType.Activate }),\n },\n notFinished: {\n buttonLabel: copy?.activate,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.activate,\n callback: () => {\n authCodeActivate.setAutoSendEmail(true)\n authCodeActivate.open()\n },\n id: TaskType.Activate,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.Subscribe]: {\n finished: isSubscribed,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({ buttonName: copy?.joinNow, callback: openSignUpPopup, id: TaskType.Subscribe }),\n },\n notFinished: {\n buttonLabel: copy?.subscribeLabel,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.subscribeLabel,\n callback: () => subscribe.openSubscribePopup(),\n id: TaskType.Subscribe,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.CompleteProfile]: {\n finished: profileCompleted,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.CompleteProfile,\n }),\n },\n notFinished: {\n buttonLabel: copy?.completeProfile,\n link:
|
|
5
|
-
"mappings": "AAAA,OAAS,sBAAAA,EAAoB,WAAAC,MAAe,eAE5C,OAAS,YAAAC,MAAgB,SACzB,OAAS,qBAAAC,MAAyB,sBAClC,OAAS,WAAAC,
|
|
6
|
-
"names": ["useHeadlessContext", "gaTrack", "TaskType", "useCreditsContext", "useMemo", "useReceiptUploaded", "useFirstPurchaseFinished", "useSubscribed", "useRegistration", "useActions", "copy", "subscribe", "uploadReceipt", "gaParameters", "openSignUpPopup", "gtm", "profile", "authCodeActivate", "isSubscribed", "firstPurchaseFinished", "uploadedReceipt", "appName", "passportUrl", "profileCompleted", "handleClickWithTrack", "buttonName", "id", "callback"]
|
|
4
|
+
"sourcesContent": ["import { useHeadlessContext, gaTrack } from '../../../lib'\n\nimport { TaskType } from './type'\nimport { useCreditsContext } from '../context/provider'\nimport { useEffect, useMemo, useState } from 'react'\nimport useReceiptUploaded from '../context/hooks/useReceiptUploaded'\nimport { useFirstPurchaseFinished } from '../context/hooks/useFirstPurchaseFinished'\nimport { useSubscribed } from '../context/hooks/useSubscribed'\nimport type { CreditsWaysToGetCreditsCopy } from './type'\n\nimport { useRegistration } from '../../registration'\n\nexport const useActions = ({\n copy,\n subscribe,\n uploadReceipt,\n gaParameters,\n}: {\n copy: CreditsWaysToGetCreditsCopy\n subscribe: {\n openSubscribePopup: () => void\n isSuccess: boolean\n }\n uploadReceipt: {\n openUploadReceiptPopup: () => void\n isSuccess: boolean\n }\n gaParameters?: {\n position: string\n }\n}) => {\n const { openSignUpPopup, gtm, profile } = useCreditsContext()\n const { authCodeActivate } = useRegistration()\n const isSubscribed = useSubscribed()\n const firstPurchaseFinished = useFirstPurchaseFinished()\n const uploadedReceipt = useReceiptUploaded()\n const { appName, passportUrl } = useHeadlessContext()\n\n // window \u5728 SSR\uFF08Next.js \u670D\u52A1\u7AEF\u6E32\u67D3\uFF09\u4E0B\u4E0D\u5B58\u5728\uFF0C\u76F4\u63A5\u8BFB window.location.href \u4F1A\u5BFC\u81F4\n // \u670D\u52A1\u7AEF\u62A5 \"window is not defined\"\uFF0C\u4E14\u670D\u52A1\u7AEF/\u5BA2\u6237\u7AEF\u9996\u5E27\u7ED3\u679C\u4E0D\u4E00\u81F4\u5F15\u53D1 hydration mismatch\u3002\n // \u8FD9\u91CC\u7EDF\u4E00\u5EF6\u8FDF\u5230\u5BA2\u6237\u7AEF\u6302\u8F7D\u540E\u518D\u8BFB\u53D6\uFF0C\u4FDD\u8BC1\u4E24\u7AEF\u9996\u5E27\u6E32\u67D3\u7ED3\u679C\u4E00\u81F4\u3002\n const [clientUrl, setClientUrl] = useState('')\n\n useEffect(() => {\n setClientUrl(window.location.href)\n }, [])\n\n // passport \u5B8C\u6210\u8D44\u6599\u540E\u56DE\u8DF3\u5230\u5F53\u524D\u9875\u9762\uFF0C\u9700\u6574\u4F53 encode\uFF0C\u5426\u5219 href \u91CC\u7684 ? / & / # \u4F1A\u6C61\u67D3 query\n const completeProfileLink = useMemo(() => {\n const query = new URLSearchParams()\n if (appName) {\n query.set('app', appName)\n }\n if (clientUrl) {\n query.set('redirect', clientUrl)\n }\n const search = query.toString()\n return `${passportUrl}/account/profile${search ? `?${search}` : ''}`\n }, [passportUrl, appName, clientUrl])\n\n const profileCompleted = useMemo(() => {\n return (profile?.first_name || profile?.last_name) && profile?.phone_number && profile?.dob\n }, [profile])\n\n return useMemo(() => {\n const handleClickWithTrack = ({\n buttonName,\n id,\n callback,\n }: {\n buttonName: string\n id?: string\n callback: () => void\n }) => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: gtm.pageGroup,\n position: gaParameters?.position || copy.title,\n button_name: buttonName,\n info: id,\n },\n })\n callback()\n }\n return {\n actions: {\n [TaskType.Activate]: {\n finished: profile?.activated,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({ buttonName: copy?.joinNow, callback: openSignUpPopup, id: TaskType.Activate }),\n },\n notFinished: {\n buttonLabel: copy?.activate,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.activate,\n callback: () => {\n authCodeActivate.setAutoSendEmail(true)\n authCodeActivate.open()\n },\n id: TaskType.Activate,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.Subscribe]: {\n finished: isSubscribed,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({ buttonName: copy?.joinNow, callback: openSignUpPopup, id: TaskType.Subscribe }),\n },\n notFinished: {\n buttonLabel: copy?.subscribeLabel,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.subscribeLabel,\n callback: () => subscribe.openSubscribePopup(),\n id: TaskType.Subscribe,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.CompleteProfile]: {\n finished: profileCompleted,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.CompleteProfile,\n }),\n },\n notFinished: {\n buttonLabel: copy?.completeProfile,\n link: completeProfileLink,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.completeProfile,\n callback: () => {},\n id: TaskType.CompleteProfile,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.FirstPurchase]: {\n finished: firstPurchaseFinished,\n notLogin: {\n buttonLabel: copy?.makeFirstPurchase,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.makeFirstPurchase,\n callback: openSignUpPopup,\n id: TaskType.FirstPurchase,\n }),\n },\n notFinished: {\n buttonLabel: copy?.makeFirstPurchase,\n link: copy?.goShopLink,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.makeFirstPurchase,\n callback: () => {},\n id: TaskType.FirstPurchase,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.UploadReceipt]: {\n finished: uploadedReceipt,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.UploadReceipt,\n }),\n },\n notFinished: {\n buttonLabel: copy?.uploadReceipt,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.uploadReceipt,\n callback: () => uploadReceipt.openUploadReceiptPopup(),\n id: TaskType.UploadReceipt,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.Shop]: {\n finished: false,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.Shop,\n }),\n },\n notFinished: {\n buttonLabel: copy?.shopNow,\n link: copy?.goShopLink,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.shopNow,\n callback: () => {},\n id: TaskType.Shop,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n },\n }\n }, [\n profile?.activated,\n copy?.joinNow,\n copy?.activate,\n copy?.completed,\n copy?.subscribe,\n copy?.completeProfile,\n copy?.makeFirstPurchase,\n copy?.uploadReceipt,\n copy?.shopNow,\n copy.title,\n copy?.goShopLink,\n isSubscribed,\n profileCompleted,\n firstPurchaseFinished,\n uploadedReceipt,\n gaParameters?.position,\n openSignUpPopup,\n completeProfileLink,\n ])\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,sBAAAA,EAAoB,WAAAC,MAAe,eAE5C,OAAS,YAAAC,MAAgB,SACzB,OAAS,qBAAAC,MAAyB,sBAClC,OAAS,aAAAC,EAAW,WAAAC,EAAS,YAAAC,MAAgB,QAC7C,OAAOC,MAAwB,sCAC/B,OAAS,4BAAAC,MAAgC,4CACzC,OAAS,iBAAAC,MAAqB,iCAG9B,OAAS,mBAAAC,MAAuB,qBAEzB,MAAMC,EAAa,CAAC,CACzB,KAAAC,EACA,UAAAC,EACA,cAAAC,EACA,aAAAC,CACF,IAaM,CACJ,KAAM,CAAE,gBAAAC,EAAiB,IAAAC,EAAK,QAAAC,CAAQ,EAAIf,EAAkB,EACtD,CAAE,iBAAAgB,CAAiB,EAAIT,EAAgB,EACvCU,EAAeX,EAAc,EAC7BY,EAAwBb,EAAyB,EACjDc,EAAkBf,EAAmB,EACrC,CAAE,QAAAgB,EAAS,YAAAC,CAAY,EAAIxB,EAAmB,EAK9C,CAACyB,EAAWC,CAAY,EAAIpB,EAAS,EAAE,EAE7CF,EAAU,IAAM,CACdsB,EAAa,OAAO,SAAS,IAAI,CACnC,EAAG,CAAC,CAAC,EAGL,MAAMC,EAAsBtB,EAAQ,IAAM,CACxC,MAAMuB,EAAQ,IAAI,gBACdL,GACFK,EAAM,IAAI,MAAOL,CAAO,EAEtBE,GACFG,EAAM,IA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,YAAaU,GAAM,QACnB,YAAa,IACXmB,EAAqB,CACnB,WAAYnB,GAAM,QAClB,SAAUI,EACV,GAAId,EAAS,IACf,CAAC,CACL,EACA,YAAa,CACX,YAAaU,GAAM,QACnB,KAAMA,GAAM,WACZ,YAAa,IACXmB,EAAqB,CACnB,WAAYnB,GAAM,QAClB,SAAU,IAAM,CAAC,EACjB,GAAIV,EAAS,IACf,CAAC,CACL,EACA,UAAW,CACT,YAAaU,GAAM,SACrB,CACF,CACF,CACF,CACF,EAAG,CACDM,GAAS,UACTN,GAAM,QACNA,GAAM,SACNA,GAAM,UACNA,GAAM,UACNA,GAAM,gBACNA,GAAM,kBACNA,GAAM,cACNA,GAAM,QACNA,EAAK,MACLA,GAAM,WACNQ,EACAU,EACAT,EACAC,EACAP,GAAc,SACdC,EACAW,CACF,CAAC,CACH",
|
|
6
|
+
"names": ["useHeadlessContext", "gaTrack", "TaskType", "useCreditsContext", "useEffect", "useMemo", "useState", "useReceiptUploaded", "useFirstPurchaseFinished", "useSubscribed", "useRegistration", "useActions", "copy", "subscribe", "uploadReceipt", "gaParameters", "openSignUpPopup", "gtm", "profile", "authCodeActivate", "isSubscribed", "firstPurchaseFinished", "uploadedReceipt", "appName", "passportUrl", "clientUrl", "setClientUrl", "completeProfileLink", "query", "search", "profileCompleted", "handleClickWithTrack", "buttonName", "id", "callback"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import { useHeadlessContext, gaTrack } from '../../../lib'
|
|
|
2
2
|
|
|
3
3
|
import { TaskType } from './type'
|
|
4
4
|
import { useCreditsContext } from '../context/provider'
|
|
5
|
-
import { useMemo } from 'react'
|
|
5
|
+
import { useEffect, useMemo, useState } from 'react'
|
|
6
6
|
import useReceiptUploaded from '../context/hooks/useReceiptUploaded'
|
|
7
7
|
import { useFirstPurchaseFinished } from '../context/hooks/useFirstPurchaseFinished'
|
|
8
8
|
import { useSubscribed } from '../context/hooks/useSubscribed'
|
|
@@ -36,6 +36,28 @@ export const useActions = ({
|
|
|
36
36
|
const uploadedReceipt = useReceiptUploaded()
|
|
37
37
|
const { appName, passportUrl } = useHeadlessContext()
|
|
38
38
|
|
|
39
|
+
// window 在 SSR(Next.js 服务端渲染)下不存在,直接读 window.location.href 会导致
|
|
40
|
+
// 服务端报 "window is not defined",且服务端/客户端首帧结果不一致引发 hydration mismatch。
|
|
41
|
+
// 这里统一延迟到客户端挂载后再读取,保证两端首帧渲染结果一致。
|
|
42
|
+
const [clientUrl, setClientUrl] = useState('')
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
setClientUrl(window.location.href)
|
|
46
|
+
}, [])
|
|
47
|
+
|
|
48
|
+
// passport 完成资料后回跳到当前页面,需整体 encode,否则 href 里的 ? / & / # 会污染 query
|
|
49
|
+
const completeProfileLink = useMemo(() => {
|
|
50
|
+
const query = new URLSearchParams()
|
|
51
|
+
if (appName) {
|
|
52
|
+
query.set('app', appName)
|
|
53
|
+
}
|
|
54
|
+
if (clientUrl) {
|
|
55
|
+
query.set('redirect', clientUrl)
|
|
56
|
+
}
|
|
57
|
+
const search = query.toString()
|
|
58
|
+
return `${passportUrl}/account/profile${search ? `?${search}` : ''}`
|
|
59
|
+
}, [passportUrl, appName, clientUrl])
|
|
60
|
+
|
|
39
61
|
const profileCompleted = useMemo(() => {
|
|
40
62
|
return (profile?.first_name || profile?.last_name) && profile?.phone_number && profile?.dob
|
|
41
63
|
}, [profile])
|
|
@@ -121,7 +143,7 @@ export const useActions = ({
|
|
|
121
143
|
},
|
|
122
144
|
notFinished: {
|
|
123
145
|
buttonLabel: copy?.completeProfile,
|
|
124
|
-
link:
|
|
146
|
+
link: completeProfileLink,
|
|
125
147
|
handleClick: () =>
|
|
126
148
|
handleClickWithTrack({
|
|
127
149
|
buttonName: copy?.completeProfile,
|
|
@@ -227,5 +249,6 @@ export const useActions = ({
|
|
|
227
249
|
uploadedReceipt,
|
|
228
250
|
gaParameters?.position,
|
|
229
251
|
openSignUpPopup,
|
|
252
|
+
completeProfileLink,
|
|
230
253
|
])
|
|
231
254
|
}
|