@anker-in/campaign-ui 0.2.10-beta.25 → 0.2.10-beta.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/credits/context/hooks/useSubscribed.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useSubscribed.js.map +3 -3
- package/dist/cjs/components/credits/context/hooks/useSubscriptions.d.ts +7 -3
- package/dist/cjs/components/credits/context/hooks/useSubscriptions.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useSubscriptions.js.map +3 -3
- package/dist/cjs/components/credits/creditsWaysToGetCredits/useActions.js +1 -1
- package/dist/cjs/components/credits/creditsWaysToGetCredits/useActions.js.map +2 -2
- package/dist/cjs/index.d.ts +0 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useSubscribed.js +1 -1
- package/dist/esm/components/credits/context/hooks/useSubscribed.js.map +3 -3
- package/dist/esm/components/credits/context/hooks/useSubscriptions.d.ts +7 -3
- package/dist/esm/components/credits/context/hooks/useSubscriptions.js +1 -1
- package/dist/esm/components/credits/context/hooks/useSubscriptions.js.map +3 -3
- package/dist/esm/components/credits/creditsWaysToGetCredits/useActions.js +1 -1
- package/dist/esm/components/credits/creditsWaysToGetCredits/useActions.js.map +2 -2
- package/dist/esm/index.d.ts +0 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +2 -2
- package/dist/index.d.mts +0 -1
- package/dist/index.d.ts +493 -2
- package/dist/index.js +4291 -1249
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4158 -1137
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -5
- package/src/components/credits/context/hooks/useSubscribed.ts +5 -5
- package/src/components/credits/context/hooks/useSubscriptions.ts +12 -37
- package/src/components/credits/creditsWaysToGetCredits/useActions.ts +0 -1
- package/src/index.ts +0 -3
- package/dist/components/chat/action.d.ts +0 -25
- package/dist/components/chat/button.d.ts +0 -3
- package/dist/components/chat/chatContext.d.ts +0 -101
- package/dist/components/chat/index.d.ts +0 -71
- package/dist/components/chat/markdown.d.ts +0 -5
- package/dist/components/chat/messages.d.ts +0 -3
- package/dist/components/chat/props.d.ts +0 -43
- package/dist/components/chat/response.d.ts +0 -4
- package/dist/components/chat/suggestions.d.ts +0 -3
- package/dist/components/chat/utils.d.ts +0 -3
- package/dist/components/credits/context/const.d.ts +0 -81
- package/dist/components/credits/context/hooks/useActivities.d.ts +0 -12
- package/dist/components/credits/context/hooks/useAddressValidate.d.ts +0 -34
- package/dist/components/credits/context/hooks/useAlpcFetch.d.ts +0 -23
- package/dist/components/credits/context/hooks/useClickOutside.d.ts +0 -3
- package/dist/components/credits/context/hooks/useCopy.d.ts +0 -5
- package/dist/components/credits/context/hooks/useCountries.d.ts +0 -8
- package/dist/components/credits/context/hooks/useFirstPurchaseFinished.d.ts +0 -1
- package/dist/components/credits/context/hooks/useMyRewards.d.ts +0 -14
- package/dist/components/credits/context/hooks/useReceiptUploaded.d.ts +0 -2
- package/dist/components/credits/context/hooks/useRedeemAndBuy.d.ts +0 -9
- package/dist/components/credits/context/hooks/useRedeemCoupon.d.ts +0 -17
- package/dist/components/credits/context/hooks/useRedeemProduct.d.ts +0 -16
- package/dist/components/credits/context/hooks/useRedeemableList.d.ts +0 -7
- package/dist/components/credits/context/hooks/useSendEmailValidation.d.ts +0 -1
- package/dist/components/credits/context/hooks/useSubscribed.d.ts +0 -1
- package/dist/components/credits/context/hooks/useSubscriptions.d.ts +0 -5
- package/dist/components/credits/context/hooks/useUploadReceipt.d.ts +0 -14
- package/dist/components/credits/context/provider.d.ts +0 -49
- package/dist/components/credits/context/response.d.ts +0 -63
- package/dist/components/credits/context/utils.d.ts +0 -25
- package/dist/components/credits/creditsBanner/index.d.ts +0 -23
- package/dist/components/credits/creditsBenefits/benefitItem.d.ts +0 -19
- package/dist/components/credits/creditsBenefits/iconInfo.d.ts +0 -2
- package/dist/components/credits/creditsBenefits/index.d.ts +0 -12
- package/dist/components/credits/creditsCash/RedeemableItem.d.ts +0 -15
- package/dist/components/credits/creditsCash/index.d.ts +0 -13
- package/dist/components/credits/creditsCash/type.d.ts +0 -47
- package/dist/components/credits/creditsFaq/faqItem/FaqItem.d.ts +0 -13
- package/dist/components/credits/creditsFaq/index.d.ts +0 -16
- package/dist/components/credits/creditsInfoCard/index.d.ts +0 -20
- package/dist/components/credits/creditsRedeemList/AddressForm/CountrySelect.d.ts +0 -14
- package/dist/components/credits/creditsRedeemList/AddressForm/FormItem.d.ts +0 -6
- package/dist/components/credits/creditsRedeemList/AddressForm/Input.d.ts +0 -13
- package/dist/components/credits/creditsRedeemList/AddressForm/StateSelect.d.ts +0 -15
- package/dist/components/credits/creditsRedeemList/AddressForm/index.d.ts +0 -2
- package/dist/components/credits/creditsRedeemList/AddressForm/type.d.ts +0 -26
- package/dist/components/credits/creditsRedeemList/RedeemCouponModal.d.ts +0 -9
- package/dist/components/credits/creditsRedeemList/RedeemProductModal/Address.d.ts +0 -20
- package/dist/components/credits/creditsRedeemList/RedeemProductModal/Error.d.ts +0 -8
- package/dist/components/credits/creditsRedeemList/RedeemProductModal/Init.d.ts +0 -11
- package/dist/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.d.ts +0 -8
- package/dist/components/credits/creditsRedeemList/RedeemProductModal/Success.d.ts +0 -13
- package/dist/components/credits/creditsRedeemList/RedeemProductModal/index.d.ts +0 -11
- package/dist/components/credits/creditsRedeemList/RedeemableItem.d.ts +0 -9
- package/dist/components/credits/creditsRedeemList/index.d.ts +0 -13
- package/dist/components/credits/creditsRedeemList/type.d.ts +0 -77
- package/dist/components/credits/creditsWaysToGetCredits/index.d.ts +0 -2
- package/dist/components/credits/creditsWaysToGetCredits/type.d.ts +0 -60
- package/dist/components/credits/creditsWaysToGetCredits/useActions.d.ts +0 -96
- package/dist/components/credits/index.d.ts +0 -10
- package/dist/components/credits/modal/MyRewardsModal.d.ts +0 -32
- package/dist/components/credits/modal/activitiesModal.d.ts +0 -32
- package/dist/components/credits/modal/creditsUploadReceiptModal.d.ts +0 -24
- package/dist/components/credits/modal/loadingDots.d.ts +0 -6
- package/dist/components/credits/modal/modalContainer.d.ts +0 -15
- package/dist/components/credits/modal/rulesModal.d.ts +0 -7
- package/dist/components/credits/modal/tip.d.ts +0 -5
- package/dist/components/credits/type.d.ts +0 -55
- package/dist/components/index.d.ts +0 -3
- package/dist/debug-env.d.ts +0 -7
- package/dist/helpers/fetchResponse.d.ts +0 -14
- package/dist/helpers/fetcher.d.ts +0 -2
- package/dist/helpers/index.d.ts +0 -2
- package/dist/helpers/track.d.ts +0 -19
- package/dist/helpers/utils.d.ts +0 -3
- package/dist/stories/chat.stories.d.ts +0 -7
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.create;var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var C=(e,r)=>{for(var s in r)u(e,s,{get:r[s],enumerable:!0})},c=(e,r,s,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of S(r))!x.call(e,t)&&t!==s&&u(e,t,{get:()=>r[t],enumerable:!(i=l(r,t))||i.enumerable});return e};var g=(e,r,s)=>(s=e!=null?d(v(e)):{},c(r||!e||!e.__esModule?u(s,"default",{value:e,enumerable:!0}):s,e)),k=e=>c(u({},"__esModule",{value:!0}),e);var R={};C(R,{useSubscribed:()=>y});module.exports=k(R);var n=require("react"),b=require("../const"),p=g(require("./useActivities")),m=require("./useSubscriptions"),a=require("../provider"),f=require("@anker-in/lib");const y=()=>{const{profile:e}=(0,a.useCreditsContext)(),{brand:r}=(0,f.useHeadlessContext)(),s=(0,n.useMemo)(()=>({page:1,pageSize:50}),[]),{activities:i}=(0,p.default)(s),{data:t}=(0,m.useSubscriptions)({email:e?.email});return(0,n.useMemo)(()=>t?.preference?t.preference.some(o=>o.brand===r&&o.subscribe)?!0:i?.some(o=>o.task_sub_type===b.TaskSubType.Subscription):!1,[t?.preference,i])};
|
|
2
2
|
//# sourceMappingURL=useSubscribed.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useSubscribed.ts"],
|
|
4
|
-
"sourcesContent": ["import { useMemo } from 'react'\n\nimport { TaskSubType } from '../const'\nimport useActivities from './useActivities'\nimport useSubscriptions from './useSubscriptions'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nexport const useSubscribed = () => {\n const { profile } = useCreditsContext()\n const { brand } = useHeadlessContext()\n\n const activitiesOptions = useMemo(() => ({ page: 1, pageSize: 50 }), [])\n\n const { activities } = useActivities(activitiesOptions)\n const {
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAwB,iBAExBC,EAA4B,oBAC5BC,EAA0B,8BAC1BC,
|
|
6
|
-
"names": ["useSubscribed_exports", "__export", "useSubscribed", "__toCommonJS", "import_react", "import_const", "import_useActivities", "import_useSubscriptions", "import_provider", "import_lib", "profile", "brand", "activitiesOptions", "activities", "useActivities", "
|
|
4
|
+
"sourcesContent": ["import { useMemo } from 'react'\n\nimport { TaskSubType } from '../const'\nimport useActivities from './useActivities'\nimport { useSubscriptions } from './useSubscriptions'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nexport const useSubscribed = () => {\n const { profile } = useCreditsContext()\n const { brand } = useHeadlessContext()\n\n const activitiesOptions = useMemo(() => ({ page: 1, pageSize: 50 }), [])\n\n const { activities } = useActivities(activitiesOptions)\n const { data: subscription } = useSubscriptions({ email: profile?.email })\n\n const isSubscribed = useMemo(() => {\n if (!subscription?.preference) {\n return false\n }\n\n const subscribeResult = subscription.preference.some(item => {\n return item.brand === brand && item.subscribe\n })\n\n if (subscribeResult) {\n return true\n }\n\n return activities?.some(item => {\n return item.task_sub_type === TaskSubType.Subscription\n })\n }, [subscription?.preference, activities])\n\n return isSubscribed\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAwB,iBAExBC,EAA4B,oBAC5BC,EAA0B,8BAC1BC,EAAiC,8BACjCC,EAAkC,uBAClCC,EAAmC,yBAE5B,MAAMP,EAAgB,IAAM,CACjC,KAAM,CAAE,QAAAQ,CAAQ,KAAI,qBAAkB,EAChC,CAAE,MAAAC,CAAM,KAAI,sBAAmB,EAE/BC,KAAoB,WAAQ,KAAO,CAAE,KAAM,EAAG,SAAU,EAAG,GAAI,CAAC,CAAC,EAEjE,CAAE,WAAAC,CAAW,KAAI,EAAAC,SAAcF,CAAiB,EAChD,CAAE,KAAMG,CAAa,KAAI,oBAAiB,CAAE,MAAOL,GAAS,KAAM,CAAC,EAoBzE,SAlBqB,WAAQ,IACtBK,GAAc,WAIKA,EAAa,WAAW,KAAKC,GAC5CA,EAAK,QAAUL,GAASK,EAAK,SACrC,EAGQ,GAGFH,GAAY,KAAKG,GACfA,EAAK,gBAAkB,cAAY,YAC3C,EAbQ,GAcR,CAACD,GAAc,WAAYF,CAAU,CAAC,CAG3C",
|
|
6
|
+
"names": ["useSubscribed_exports", "__export", "useSubscribed", "__toCommonJS", "import_react", "import_const", "import_useActivities", "import_useSubscriptions", "import_provider", "import_lib", "profile", "brand", "activitiesOptions", "activities", "useActivities", "subscription", "item"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { SWRResponse } from 'swr';
|
|
1
2
|
import type { Subscription } from '../../type';
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
export type SubscriptionApiResponse = {
|
|
4
|
+
data: Subscription;
|
|
4
5
|
};
|
|
5
|
-
export
|
|
6
|
+
export type FetchSubscriptionResponse = SWRResponse<Subscription>;
|
|
7
|
+
export declare function useSubscriptions({ email }: {
|
|
8
|
+
email?: string;
|
|
9
|
+
}): FetchSubscriptionResponse;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var b=Object.create;var i=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty;var y=(s,t)=>{for(var e in t)i(s,e,{get:t[e],enumerable:!0})},n=(s,t,e,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of R(t))!l.call(s,o)&&o!==e&&i(s,o,{get:()=>t[o],enumerable:!(p=m(t,o))||p.enumerable});return s};var r=(s,t,e)=>(e=s!=null?b(d(s)):{},n(t||!s||!s.__esModule?i(e,"default",{value:s,enumerable:!0}):e,s)),f=s=>n(i({},"__esModule",{value:!0}),s);var x={};y(x,{useSubscriptions:()=>h});module.exports=f(x);var c=r(require("swr")),u=r(require("../../../../helpers/fetcher")),a=require("@anker-in/lib");function h({email:s}){const{locale:t}=(0,a.useHeadlessContext)(),{data:e,...p}=(0,c.default)(s?["/api/multipass/account/subscriptions",s]:null,async([o,S])=>(0,u.default)({method:"GET",url:o,body:{email:S},action:"login",locale:t,headers:{},type:""}));return{data:e?.data,...p}}
|
|
2
2
|
//# sourceMappingURL=useSubscriptions.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useSubscriptions.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,
|
|
6
|
-
"names": ["useSubscriptions_exports", "__export", "
|
|
4
|
+
"sourcesContent": ["import useSWR, { SWRResponse } from 'swr'\nimport type { Subscription } from '../../type'\nimport fetcher from '../../../../helpers/fetcher'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nexport type SubscriptionApiResponse = { data: Subscription }\nexport type FetchSubscriptionResponse = SWRResponse<Subscription>\n\nexport function useSubscriptions({ email }: { email?: string }): FetchSubscriptionResponse {\n const { locale } = useHeadlessContext()\n\n const { data, ...rest } = useSWR<SubscriptionApiResponse>(\n email ? ['/api/multipass/account/subscriptions', email] : null,\n async ([url, email]) =>\n fetcher({\n method: 'GET',\n url,\n body: {\n email,\n },\n action: 'login',\n locale,\n headers: {},\n type: '',\n })\n )\n\n return { data: data?.data, ...rest } as unknown as FetchSubscriptionResponse\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAoC,kBAEpCC,EAAoB,0CACpBC,EAAmC,yBAK5B,SAASJ,EAAiB,CAAE,MAAAK,CAAM,EAAkD,CACzF,KAAM,CAAE,OAAAC,CAAO,KAAI,sBAAmB,EAEhC,CAAE,KAAAC,EAAM,GAAGC,CAAK,KAAI,EAAAC,SACxBJ,EAAQ,CAAC,uCAAwCA,CAAK,EAAI,KAC1D,MAAO,CAACK,EAAKL,CAAK,OAChB,EAAAM,SAAQ,CACN,OAAQ,MACR,IAAAD,EACA,KAAM,CACJ,MAAAL,CACF,EACA,OAAQ,QACR,OAAAC,EACA,QAAS,CAAC,EACV,KAAM,EACR,CAAC,CACL,EAEA,MAAO,CAAE,KAAMC,GAAM,KAAM,GAAGC,CAAK,CACrC",
|
|
6
|
+
"names": ["useSubscriptions_exports", "__export", "useSubscriptions", "__toCommonJS", "import_swr", "import_fetcher", "import_lib", "email", "locale", "data", "rest", "useSWR", "url", "fetcher"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var _=Object.create;var
|
|
1
|
+
"use strict";var _=Object.create;var r=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var x=(e,i)=>{for(var a in i)r(e,a,{get:i[a],enumerable:!0})},h=(e,i,a,b)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of U(i))!A.call(e,n)&&n!==a&&r(e,n,{get:()=>i[n],enumerable:!(b=R(i,n))||b.enumerable});return e};var G=(e,i,a)=>(a=e!=null?_(T(e)):{},h(i||!e||!e.__esModule?r(a,"default",{value:e,enumerable:!0}):a,e)),W=e=>h(r({},"__esModule",{value:!0}),e);var E={};x(E,{useActions:()=>$});module.exports=W(E);var t=require("./type"),k=require("../context/provider"),d=require("react"),f=G(require("../context/hooks/useReceiptUploaded")),N=require("../context/hooks/useFirstPurchaseFinished"),L=require("../context/hooks/useSubscribed"),C=require("@anker-in/lib"),P=require("../../../helpers/track");const $=({copy:e,subscribe:i,uploadReceipt:a,activate:b,gaParameters:n})=>{const{openSignUpPopup:s,gtm:g,profile:l}=(0,k.useCreditsContext)(),u=(0,L.useSubscribed)(),c=(0,N.useFirstPurchaseFinished)(),m=(0,f.default)(),{appName:v,passportUrl:F}=(0,C.useHeadlessContext)(),p=(0,d.useMemo)(()=>(l?.first_name||l?.last_name)&&l?.phone_number&&l?.dob,[l]);return(0,d.useMemo)(()=>{const o=({buttonName:w,id:S,callback:j})=>{(0,P.gaTrack)({event:"ga4Event",event_name:"lp_button",member_active_status:l?.activated?"active":"not active",event_parameters:{page_group:g.pageGroup,position:n?.position||e.title,button_name:w,info:S}}),j()};return{actions:{[t.TaskType.Activate]:{finished:l?.activated,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>o({buttonName:e?.joinNow,callback:s,id:t.TaskType.Activate})},notFinished:{buttonLabel:e?.activate,handleClick:()=>o({buttonName:e?.activate,callback:()=>b.openAuthCodePopup(),id:t.TaskType.Activate})},completed:{buttonLabel:e?.completed}},[t.TaskType.Subscribe]:{finished:u,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>o({buttonName:e?.joinNow,callback:s,id:t.TaskType.Subscribe})},notFinished:{buttonLabel:e?.subscribe,handleClick:()=>o({buttonName:e?.subscribe,callback:()=>i.openSubscribePopup(),id:t.TaskType.Subscribe})},completed:{buttonLabel:e?.completed}},[t.TaskType.CompleteProfile]:{finished:p,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>o({buttonName:e?.joinNow,callback:s,id:t.TaskType.CompleteProfile})},notFinished:{buttonLabel:e?.completeProfile,link:`${F}/account/profile?app=${v}`,handleClick:()=>o({buttonName:e?.completeProfile,callback:()=>{},id:t.TaskType.CompleteProfile})},completed:{buttonLabel:e?.completed}},[t.TaskType.FirstPurchase]:{finished:c,notLogin:{buttonLabel:e?.makeFirstPurchase,handleClick:()=>o({buttonName:e?.makeFirstPurchase,callback:s,id:t.TaskType.FirstPurchase})},notFinished:{buttonLabel:e?.makeFirstPurchase,link:e?.goShopLink,handleClick:()=>o({buttonName:e?.makeFirstPurchase,callback:()=>{},id:t.TaskType.FirstPurchase})},completed:{buttonLabel:e?.completed}},[t.TaskType.UploadReceipt]:{finished:m,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>o({buttonName:e?.joinNow,callback:s,id:t.TaskType.UploadReceipt})},notFinished:{buttonLabel:e?.uploadReceipt,handleClick:()=>o({buttonName:e?.uploadReceipt,callback:()=>a.openUploadReceiptPopup(),id:t.TaskType.UploadReceipt})},completed:{buttonLabel:e?.completed}},[t.TaskType.Shop]:{finished:!1,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>o({buttonName:e?.joinNow,callback:s,id:t.TaskType.Shop})},notFinished:{buttonLabel:e?.shopNow,link:e?.goShopLink,handleClick:()=>o({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,u,p,c,m,n?.position,s])};
|
|
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 { 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 { CreditsWaysToGetCreditsProps } from './type'\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { gaTrack } from '../../../helpers/track'\n\nexport const useActions = ({\n copy,\n subscribe,\n uploadReceipt,\n activate,\n gaParameters,\n}: CreditsWaysToGetCreditsProps & {\n gaParameters?: {\n position: string\n }\n}) => {\n const { openSignUpPopup, gtm, profile } = useCreditsContext()\n const isSubscribed = useSubscribed()\n const firstPurchaseFinished = useFirstPurchaseFinished()\n const uploadedReceipt = useReceiptUploaded()\n const { appName, passportUrl } = useHeadlessContext()\n
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAyB,kBACzBC,EAAkC,+BAClCC,EAAwB,iBACxBC,EAA+B,kDAC/BC,EAAyC,qDACzCC,EAA8B,0CAE9BC,EAAmC,yBACnCC,EAAwB,kCAEjB,MAAMT,EAAa,CAAC,CACzB,KAAAU,EACA,UAAAC,EACA,cAAAC,EACA,SAAAC,EACA,aAAAC,CACF,IAIM,CACJ,KAAM,CAAE,gBAAAC,EAAiB,IAAAC,EAAK,QAAAC,CAAQ,KAAI,qBAAkB,EACtDC,KAAe,iBAAc,EAC7BC,KAAwB,4BAAyB,EACjDC,KAAkB,EAAAC,SAAmB,EACrC,CAAE,QAAAC,EAAS,YAAAC,CAAY,KAAI,sBAAmB,
|
|
4
|
+
"sourcesContent": ["import { 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 { CreditsWaysToGetCreditsProps } from './type'\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { gaTrack } from '../../../helpers/track'\n\nexport const useActions = ({\n copy,\n subscribe,\n uploadReceipt,\n activate,\n gaParameters,\n}: CreditsWaysToGetCreditsProps & {\n gaParameters?: {\n position: string\n }\n}) => {\n const { openSignUpPopup, gtm, profile } = useCreditsContext()\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: () => activate.openAuthCodePopup(),\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?.subscribe,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.subscribe,\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: `${passportUrl}/account/profile?app=${appName}`,\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 ])\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAyB,kBACzBC,EAAkC,+BAClCC,EAAwB,iBACxBC,EAA+B,kDAC/BC,EAAyC,qDACzCC,EAA8B,0CAE9BC,EAAmC,yBACnCC,EAAwB,kCAEjB,MAAMT,EAAa,CAAC,CACzB,KAAAU,EACA,UAAAC,EACA,cAAAC,EACA,SAAAC,EACA,aAAAC,CACF,IAIM,CACJ,KAAM,CAAE,gBAAAC,EAAiB,IAAAC,EAAK,QAAAC,CAAQ,KAAI,qBAAkB,EACtDC,KAAe,iBAAc,EAC7BC,KAAwB,4BAAyB,EACjDC,KAAkB,EAAAC,SAAmB,EACrC,CAAE,QAAAC,EAAS,YAAAC,CAAY,KAAI,sBAAmB,EAE9CC,KAAmB,WAAQ,KACvBP,GAAS,YAAcA,GAAS,YAAcA,GAAS,cAAgBA,GAAS,IACvF,CAACA,CAAO,CAAC,EAEZ,SAAO,WAAQ,IAAM,CACnB,MAAMQ,EA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GAAM,UACNA,GAAM,UACNA,GAAM,gBACNA,GAAM,kBACNA,GAAM,cACNA,GAAM,QACNA,EAAK,MACLA,GAAM,WACNQ,EACAM,EACAL,EACAC,EACAN,GAAc,SACdC,CACF,CAAC,CACH",
|
|
6
6
|
"names": ["useActions_exports", "__export", "useActions", "__toCommonJS", "import_type", "import_provider", "import_react", "import_useReceiptUploaded", "import_useFirstPurchaseFinished", "import_useSubscribed", "import_lib", "import_track", "copy", "subscribe", "uploadReceipt", "activate", "gaParameters", "openSignUpPopup", "gtm", "profile", "isSubscribed", "firstPurchaseFinished", "uploadedReceipt", "useReceiptUploaded", "appName", "passportUrl", "profileCompleted", "handleClickWithTrack", "buttonName", "id", "callback"]
|
|
7
7
|
}
|
package/dist/cjs/index.d.ts
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(r,o,f,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of c(o))!d.call(r,e)&&e!==f&&a(r,e,{get:()=>o[e],enumerable:!(x=b(o,e))||x.enumerable});return r},t=(r,o,f)=>(p(r,o,"default"),f&&p(f,o,"default"));var g=r=>p(a({},"__esModule",{value:!0}),r);var m={};module.exports=g(m);t(m,require("./components/index"),module.exports);
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './components/index'\n
|
|
5
|
-
"mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,8BAAd
|
|
4
|
+
"sourcesContent": ["export * from './components/index'\n"],
|
|
5
|
+
"mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,8BAAd",
|
|
6
6
|
"names": ["src_exports", "__toCommonJS", "__reExport"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useMemo as t}from"react";import{TaskSubType as n}from"../const";import c from"./useActivities";import b
|
|
1
|
+
import{useMemo as t}from"react";import{TaskSubType as n}from"../const";import c from"./useActivities";import{useSubscriptions as b}from"./useSubscriptions";import{useCreditsContext as p}from"../provider";import{useHeadlessContext as m}from"@anker-in/lib";const g=()=>{const{profile:i}=p(),{brand:o}=m(),u=t(()=>({page:1,pageSize:50}),[]),{activities:s}=c(u),{data:r}=b({email:i?.email});return t(()=>r?.preference?r.preference.some(e=>e.brand===o&&e.subscribe)?!0:s?.some(e=>e.task_sub_type===n.Subscription):!1,[r?.preference,s])};export{g as useSubscribed};
|
|
2
2
|
//# sourceMappingURL=useSubscribed.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useSubscribed.ts"],
|
|
4
|
-
"sourcesContent": ["import { useMemo } from 'react'\n\nimport { TaskSubType } from '../const'\nimport useActivities from './useActivities'\nimport useSubscriptions from './useSubscriptions'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nexport const useSubscribed = () => {\n const { profile } = useCreditsContext()\n const { brand } = useHeadlessContext()\n\n const activitiesOptions = useMemo(() => ({ page: 1, pageSize: 50 }), [])\n\n const { activities } = useActivities(activitiesOptions)\n const {
|
|
5
|
-
"mappings": "AAAA,OAAS,WAAAA,MAAe,QAExB,OAAS,eAAAC,MAAmB,WAC5B,OAAOC,MAAmB,kBAC1B,
|
|
6
|
-
"names": ["useMemo", "TaskSubType", "useActivities", "useSubscriptions", "useCreditsContext", "useHeadlessContext", "useSubscribed", "profile", "brand", "activitiesOptions", "activities", "
|
|
4
|
+
"sourcesContent": ["import { useMemo } from 'react'\n\nimport { TaskSubType } from '../const'\nimport useActivities from './useActivities'\nimport { useSubscriptions } from './useSubscriptions'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nexport const useSubscribed = () => {\n const { profile } = useCreditsContext()\n const { brand } = useHeadlessContext()\n\n const activitiesOptions = useMemo(() => ({ page: 1, pageSize: 50 }), [])\n\n const { activities } = useActivities(activitiesOptions)\n const { data: subscription } = useSubscriptions({ email: profile?.email })\n\n const isSubscribed = useMemo(() => {\n if (!subscription?.preference) {\n return false\n }\n\n const subscribeResult = subscription.preference.some(item => {\n return item.brand === brand && item.subscribe\n })\n\n if (subscribeResult) {\n return true\n }\n\n return activities?.some(item => {\n return item.task_sub_type === TaskSubType.Subscription\n })\n }, [subscription?.preference, activities])\n\n return isSubscribed\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,WAAAA,MAAe,QAExB,OAAS,eAAAC,MAAmB,WAC5B,OAAOC,MAAmB,kBAC1B,OAAS,oBAAAC,MAAwB,qBACjC,OAAS,qBAAAC,MAAyB,cAClC,OAAS,sBAAAC,MAA0B,gBAE5B,MAAMC,EAAgB,IAAM,CACjC,KAAM,CAAE,QAAAC,CAAQ,EAAIH,EAAkB,EAChC,CAAE,MAAAI,CAAM,EAAIH,EAAmB,EAE/BI,EAAoBT,EAAQ,KAAO,CAAE,KAAM,EAAG,SAAU,EAAG,GAAI,CAAC,CAAC,EAEjE,CAAE,WAAAU,CAAW,EAAIR,EAAcO,CAAiB,EAChD,CAAE,KAAME,CAAa,EAAIR,EAAiB,CAAE,MAAOI,GAAS,KAAM,CAAC,EAoBzE,OAlBqBP,EAAQ,IACtBW,GAAc,WAIKA,EAAa,WAAW,KAAKC,GAC5CA,EAAK,QAAUJ,GAASI,EAAK,SACrC,EAGQ,GAGFF,GAAY,KAAKE,GACfA,EAAK,gBAAkBX,EAAY,YAC3C,EAbQ,GAcR,CAACU,GAAc,WAAYD,CAAU,CAAC,CAG3C",
|
|
6
|
+
"names": ["useMemo", "TaskSubType", "useActivities", "useSubscriptions", "useCreditsContext", "useHeadlessContext", "useSubscribed", "profile", "brand", "activitiesOptions", "activities", "subscription", "item"]
|
|
7
7
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { SWRResponse } from 'swr';
|
|
1
2
|
import type { Subscription } from '../../type';
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
export type SubscriptionApiResponse = {
|
|
4
|
+
data: Subscription;
|
|
4
5
|
};
|
|
5
|
-
export
|
|
6
|
+
export type FetchSubscriptionResponse = SWRResponse<Subscription>;
|
|
7
|
+
export declare function useSubscriptions({ email }: {
|
|
8
|
+
email?: string;
|
|
9
|
+
}): FetchSubscriptionResponse;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import n from"swr";import r from"../../../../helpers/fetcher";import{useHeadlessContext as c}from"@anker-in/lib";function m({email:s}){const{locale:t}=c(),{data:e,...o}=n(s?["/api/multipass/account/subscriptions",s]:null,async([p,i])=>r({method:"GET",url:p,body:{email:i},action:"login",locale:t,headers:{},type:""}));return{data:e?.data,...o}}export{m as useSubscriptions};
|
|
2
2
|
//# sourceMappingURL=useSubscriptions.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useSubscriptions.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "AAAA,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import useSWR, { SWRResponse } from 'swr'\nimport type { Subscription } from '../../type'\nimport fetcher from '../../../../helpers/fetcher'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nexport type SubscriptionApiResponse = { data: Subscription }\nexport type FetchSubscriptionResponse = SWRResponse<Subscription>\n\nexport function useSubscriptions({ email }: { email?: string }): FetchSubscriptionResponse {\n const { locale } = useHeadlessContext()\n\n const { data, ...rest } = useSWR<SubscriptionApiResponse>(\n email ? ['/api/multipass/account/subscriptions', email] : null,\n async ([url, email]) =>\n fetcher({\n method: 'GET',\n url,\n body: {\n email,\n },\n action: 'login',\n locale,\n headers: {},\n type: '',\n })\n )\n\n return { data: data?.data, ...rest } as unknown as FetchSubscriptionResponse\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAA6B,MAEpC,OAAOC,MAAa,8BACpB,OAAS,sBAAAC,MAA0B,gBAK5B,SAASC,EAAiB,CAAE,MAAAC,CAAM,EAAkD,CACzF,KAAM,CAAE,OAAAC,CAAO,EAAIH,EAAmB,EAEhC,CAAE,KAAAI,EAAM,GAAGC,CAAK,EAAIP,EACxBI,EAAQ,CAAC,uCAAwCA,CAAK,EAAI,KAC1D,MAAO,CAACI,EAAKJ,CAAK,IAChBH,EAAQ,CACN,OAAQ,MACR,IAAAO,EACA,KAAM,CACJ,MAAAJ,CACF,EACA,OAAQ,QACR,OAAAC,EACA,QAAS,CAAC,EACV,KAAM,EACR,CAAC,CACL,EAEA,MAAO,CAAE,KAAMC,GAAM,KAAM,GAAGC,CAAK,CACrC",
|
|
6
|
+
"names": ["useSWR", "fetcher", "useHeadlessContext", "useSubscriptions", "email", "locale", "data", "rest", "url"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{TaskType as t}from"./type";import{useCreditsContext as C}from"../context/provider";import{useMemo as
|
|
1
|
+
import{TaskType as t}from"./type";import{useCreditsContext as C}from"../context/provider";import{useMemo as d}from"react";import P from"../context/hooks/useReceiptUploaded";import{useFirstPurchaseFinished as g}from"../context/hooks/useFirstPurchaseFinished";import{useSubscribed as v}from"../context/hooks/useSubscribed";import{useHeadlessContext as F}from"@anker-in/lib";import{gaTrack as w}from"../../../helpers/track";const G=({copy:e,subscribe:u,uploadReceipt:c,activate:m,gaParameters:n})=>{const{openSignUpPopup:a,gtm:p,profile:o}=C(),l=v(),s=g(),b=P(),{appName:h,passportUrl:k}=F(),r=d(()=>(o?.first_name||o?.last_name)&&o?.phone_number&&o?.dob,[o]);return d(()=>{const i=({buttonName:f,id:N,callback:L})=>{w({event:"ga4Event",event_name:"lp_button",member_active_status:o?.activated?"active":"not active",event_parameters:{page_group:p.pageGroup,position:n?.position||e.title,button_name:f,info:N}}),L()};return{actions:{[t.Activate]:{finished:o?.activated,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:a,id:t.Activate})},notFinished:{buttonLabel:e?.activate,handleClick:()=>i({buttonName:e?.activate,callback:()=>m.openAuthCodePopup(),id:t.Activate})},completed:{buttonLabel:e?.completed}},[t.Subscribe]:{finished:l,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:a,id:t.Subscribe})},notFinished:{buttonLabel:e?.subscribe,handleClick:()=>i({buttonName:e?.subscribe,callback:()=>u.openSubscribePopup(),id:t.Subscribe})},completed:{buttonLabel:e?.completed}},[t.CompleteProfile]:{finished:r,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:a,id:t.CompleteProfile})},notFinished:{buttonLabel:e?.completeProfile,link:`${k}/account/profile?app=${h}`,handleClick:()=>i({buttonName:e?.completeProfile,callback:()=>{},id:t.CompleteProfile})},completed:{buttonLabel:e?.completed}},[t.FirstPurchase]:{finished:s,notLogin:{buttonLabel:e?.makeFirstPurchase,handleClick:()=>i({buttonName:e?.makeFirstPurchase,callback:a,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:b,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:a,id:t.UploadReceipt})},notFinished:{buttonLabel:e?.uploadReceipt,handleClick:()=>i({buttonName:e?.uploadReceipt,callback:()=>c.openUploadReceiptPopup(),id:t.UploadReceipt})},completed:{buttonLabel:e?.completed}},[t.Shop]:{finished:!1,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:a,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,l,r,s,b,n?.position,a])};export{G 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 { 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 { CreditsWaysToGetCreditsProps } from './type'\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { gaTrack } from '../../../helpers/track'\n\nexport const useActions = ({\n copy,\n subscribe,\n uploadReceipt,\n activate,\n gaParameters,\n}: CreditsWaysToGetCreditsProps & {\n gaParameters?: {\n position: string\n }\n}) => {\n const { openSignUpPopup, gtm, profile } = useCreditsContext()\n const isSubscribed = useSubscribed()\n const firstPurchaseFinished = useFirstPurchaseFinished()\n const uploadedReceipt = useReceiptUploaded()\n const { appName, passportUrl } = useHeadlessContext()\n
|
|
5
|
-
"mappings": "AAAA,OAAS,YAAAA,MAAgB,SACzB,OAAS,qBAAAC,MAAyB,sBAClC,OAAS,WAAAC,MAAe,QACxB,OAAOC,MAAwB,sCAC/B,OAAS,4BAAAC,MAAgC,4CACzC,OAAS,iBAAAC,MAAqB,iCAE9B,OAAS,sBAAAC,MAA0B,gBACnC,OAAS,WAAAC,MAAe,yBAEjB,MAAMC,EAAa,CAAC,CACzB,KAAAC,EACA,UAAAC,EACA,cAAAC,EACA,SAAAC,EACA,aAAAC,CACF,IAIM,CACJ,KAAM,CAAE,gBAAAC,EAAiB,IAAAC,EAAK,QAAAC,CAAQ,EAAIf,EAAkB,EACtDgB,EAAeZ,EAAc,EAC7Ba,EAAwBd,EAAyB,EACjDe,EAAkBhB,EAAmB,EACrC,CAAE,QAAAiB,EAAS,YAAAC,CAAY,EAAIf,EAAmB,
|
|
4
|
+
"sourcesContent": ["import { 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 { CreditsWaysToGetCreditsProps } from './type'\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { gaTrack } from '../../../helpers/track'\n\nexport const useActions = ({\n copy,\n subscribe,\n uploadReceipt,\n activate,\n gaParameters,\n}: CreditsWaysToGetCreditsProps & {\n gaParameters?: {\n position: string\n }\n}) => {\n const { openSignUpPopup, gtm, profile } = useCreditsContext()\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: () => activate.openAuthCodePopup(),\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?.subscribe,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.subscribe,\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: `${passportUrl}/account/profile?app=${appName}`,\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 ])\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,YAAAA,MAAgB,SACzB,OAAS,qBAAAC,MAAyB,sBAClC,OAAS,WAAAC,MAAe,QACxB,OAAOC,MAAwB,sCAC/B,OAAS,4BAAAC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B,YAAa,IACXc,EAAqB,CACnB,WAAYd,GAAM,cAClB,SAAU,IAAME,EAAc,uBAAuB,EACrD,GAAIX,EAAS,aACf,CAAC,CACL,EACA,UAAW,CACT,YAAaS,GAAM,SACrB,CACF,EACA,CAACT,EAAS,IAAI,EAAG,CACf,SAAU,GACV,SAAU,CACR,YAAaS,GAAM,QACnB,YAAa,IACXc,EAAqB,CACnB,WAAYd,GAAM,QAClB,SAAUK,EACV,GAAId,EAAS,IACf,CAAC,CACL,EACA,YAAa,CACX,YAAaS,GAAM,QACnB,KAAMA,GAAM,WACZ,YAAa,IACXc,EAAqB,CACnB,WAAYd,GAAM,QAClB,SAAU,IAAM,CAAC,EACjB,GAAIT,EAAS,IACf,CAAC,CACL,EACA,UAAW,CACT,YAAaS,GAAM,SACrB,CACF,CACF,CACF,CACF,EAAG,CACDO,GAAS,UACTP,GAAM,QACNA,GAAM,SACNA,GAAM,UACNA,GAAM,UACNA,GAAM,gBACNA,GAAM,kBACNA,GAAM,cACNA,GAAM,QACNA,EAAK,MACLA,GAAM,WACNQ,EACAK,EACAJ,EACAC,EACAN,GAAc,SACdC,CACF,CAAC,CACH",
|
|
6
6
|
"names": ["TaskType", "useCreditsContext", "useMemo", "useReceiptUploaded", "useFirstPurchaseFinished", "useSubscribed", "useHeadlessContext", "gaTrack", "useActions", "copy", "subscribe", "uploadReceipt", "activate", "gaParameters", "openSignUpPopup", "gtm", "profile", "isSubscribed", "firstPurchaseFinished", "uploadedReceipt", "appName", "passportUrl", "profileCompleted", "handleClickWithTrack", "buttonName", "id", "callback"]
|
|
7
7
|
}
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export*from"./components/index";
|
|
1
|
+
export*from"./components/index";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './components/index'\n
|
|
5
|
-
"mappings": "AAAA,WAAc
|
|
4
|
+
"sourcesContent": ["export * from './components/index'\n"],
|
|
5
|
+
"mappings": "AAAA,WAAc",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,6 @@ import React from 'react';
|
|
|
3
3
|
export { useCopilotAction, useCopilotChat, useCopilotReadable } from '@copilotkit/react-core';
|
|
4
4
|
export { ActionExecutionMessage, Role, TextMessage } from '@copilotkit/runtime-client-gql';
|
|
5
5
|
import * as swr_dist_mutation from 'swr/dist/mutation';
|
|
6
|
-
export * from '@anker-in/lib';
|
|
7
6
|
|
|
8
7
|
interface ChatProps {
|
|
9
8
|
title: string;
|