@anker-in/campaign-ui 0.2.10-beta.26 → 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.
Files changed (108) hide show
  1. package/dist/cjs/components/credits/context/hooks/useSubscribed.js +1 -1
  2. package/dist/cjs/components/credits/context/hooks/useSubscribed.js.map +3 -3
  3. package/dist/cjs/components/credits/context/hooks/useSubscriptions.d.ts +7 -3
  4. package/dist/cjs/components/credits/context/hooks/useSubscriptions.js +1 -1
  5. package/dist/cjs/components/credits/context/hooks/useSubscriptions.js.map +3 -3
  6. package/dist/cjs/components/credits/creditsWaysToGetCredits/useActions.js +1 -1
  7. package/dist/cjs/components/credits/creditsWaysToGetCredits/useActions.js.map +2 -2
  8. package/dist/cjs/index.d.ts +0 -1
  9. package/dist/cjs/index.js +1 -1
  10. package/dist/cjs/index.js.map +2 -2
  11. package/dist/esm/components/credits/context/hooks/useSubscribed.js +1 -1
  12. package/dist/esm/components/credits/context/hooks/useSubscribed.js.map +3 -3
  13. package/dist/esm/components/credits/context/hooks/useSubscriptions.d.ts +7 -3
  14. package/dist/esm/components/credits/context/hooks/useSubscriptions.js +1 -1
  15. package/dist/esm/components/credits/context/hooks/useSubscriptions.js.map +3 -3
  16. package/dist/esm/components/credits/creditsWaysToGetCredits/useActions.js +1 -1
  17. package/dist/esm/components/credits/creditsWaysToGetCredits/useActions.js.map +2 -2
  18. package/dist/esm/index.d.ts +0 -1
  19. package/dist/esm/index.js +1 -1
  20. package/dist/esm/index.js.map +2 -2
  21. package/dist/index.d.mts +0 -1
  22. package/dist/index.d.ts +493 -2
  23. package/dist/index.js +4291 -1249
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +4158 -1137
  26. package/dist/index.mjs.map +1 -1
  27. package/package.json +2 -2
  28. package/src/components/credits/context/hooks/useSubscribed.ts +5 -5
  29. package/src/components/credits/context/hooks/useSubscriptions.ts +12 -37
  30. package/src/components/credits/creditsWaysToGetCredits/useActions.ts +0 -1
  31. package/src/index.ts +0 -3
  32. package/dist/components/chat/action.d.ts +0 -25
  33. package/dist/components/chat/button.d.ts +0 -3
  34. package/dist/components/chat/chatContext.d.ts +0 -101
  35. package/dist/components/chat/index.d.ts +0 -71
  36. package/dist/components/chat/markdown.d.ts +0 -5
  37. package/dist/components/chat/messages.d.ts +0 -3
  38. package/dist/components/chat/props.d.ts +0 -43
  39. package/dist/components/chat/response.d.ts +0 -4
  40. package/dist/components/chat/suggestions.d.ts +0 -3
  41. package/dist/components/chat/utils.d.ts +0 -3
  42. package/dist/components/credits/context/const.d.ts +0 -81
  43. package/dist/components/credits/context/hooks/useActivities.d.ts +0 -12
  44. package/dist/components/credits/context/hooks/useAddressValidate.d.ts +0 -34
  45. package/dist/components/credits/context/hooks/useAlpcFetch.d.ts +0 -23
  46. package/dist/components/credits/context/hooks/useClickOutside.d.ts +0 -3
  47. package/dist/components/credits/context/hooks/useCopy.d.ts +0 -5
  48. package/dist/components/credits/context/hooks/useCountries.d.ts +0 -8
  49. package/dist/components/credits/context/hooks/useFirstPurchaseFinished.d.ts +0 -1
  50. package/dist/components/credits/context/hooks/useMyRewards.d.ts +0 -14
  51. package/dist/components/credits/context/hooks/useReceiptUploaded.d.ts +0 -2
  52. package/dist/components/credits/context/hooks/useRedeemAndBuy.d.ts +0 -9
  53. package/dist/components/credits/context/hooks/useRedeemCoupon.d.ts +0 -17
  54. package/dist/components/credits/context/hooks/useRedeemProduct.d.ts +0 -16
  55. package/dist/components/credits/context/hooks/useRedeemableList.d.ts +0 -7
  56. package/dist/components/credits/context/hooks/useSendEmailValidation.d.ts +0 -1
  57. package/dist/components/credits/context/hooks/useSubscribed.d.ts +0 -1
  58. package/dist/components/credits/context/hooks/useSubscriptions.d.ts +0 -5
  59. package/dist/components/credits/context/hooks/useUploadReceipt.d.ts +0 -14
  60. package/dist/components/credits/context/provider.d.ts +0 -49
  61. package/dist/components/credits/context/response.d.ts +0 -63
  62. package/dist/components/credits/context/utils.d.ts +0 -25
  63. package/dist/components/credits/creditsBanner/index.d.ts +0 -23
  64. package/dist/components/credits/creditsBenefits/benefitItem.d.ts +0 -19
  65. package/dist/components/credits/creditsBenefits/iconInfo.d.ts +0 -2
  66. package/dist/components/credits/creditsBenefits/index.d.ts +0 -12
  67. package/dist/components/credits/creditsCash/RedeemableItem.d.ts +0 -15
  68. package/dist/components/credits/creditsCash/index.d.ts +0 -13
  69. package/dist/components/credits/creditsCash/type.d.ts +0 -47
  70. package/dist/components/credits/creditsFaq/faqItem/FaqItem.d.ts +0 -13
  71. package/dist/components/credits/creditsFaq/index.d.ts +0 -16
  72. package/dist/components/credits/creditsInfoCard/index.d.ts +0 -20
  73. package/dist/components/credits/creditsRedeemList/AddressForm/CountrySelect.d.ts +0 -14
  74. package/dist/components/credits/creditsRedeemList/AddressForm/FormItem.d.ts +0 -6
  75. package/dist/components/credits/creditsRedeemList/AddressForm/Input.d.ts +0 -13
  76. package/dist/components/credits/creditsRedeemList/AddressForm/StateSelect.d.ts +0 -15
  77. package/dist/components/credits/creditsRedeemList/AddressForm/index.d.ts +0 -2
  78. package/dist/components/credits/creditsRedeemList/AddressForm/type.d.ts +0 -26
  79. package/dist/components/credits/creditsRedeemList/RedeemCouponModal.d.ts +0 -9
  80. package/dist/components/credits/creditsRedeemList/RedeemProductModal/Address.d.ts +0 -20
  81. package/dist/components/credits/creditsRedeemList/RedeemProductModal/Error.d.ts +0 -8
  82. package/dist/components/credits/creditsRedeemList/RedeemProductModal/Init.d.ts +0 -11
  83. package/dist/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.d.ts +0 -8
  84. package/dist/components/credits/creditsRedeemList/RedeemProductModal/Success.d.ts +0 -13
  85. package/dist/components/credits/creditsRedeemList/RedeemProductModal/index.d.ts +0 -11
  86. package/dist/components/credits/creditsRedeemList/RedeemableItem.d.ts +0 -9
  87. package/dist/components/credits/creditsRedeemList/index.d.ts +0 -13
  88. package/dist/components/credits/creditsRedeemList/type.d.ts +0 -77
  89. package/dist/components/credits/creditsWaysToGetCredits/index.d.ts +0 -2
  90. package/dist/components/credits/creditsWaysToGetCredits/type.d.ts +0 -60
  91. package/dist/components/credits/creditsWaysToGetCredits/useActions.d.ts +0 -96
  92. package/dist/components/credits/index.d.ts +0 -10
  93. package/dist/components/credits/modal/MyRewardsModal.d.ts +0 -32
  94. package/dist/components/credits/modal/activitiesModal.d.ts +0 -32
  95. package/dist/components/credits/modal/creditsUploadReceiptModal.d.ts +0 -24
  96. package/dist/components/credits/modal/loadingDots.d.ts +0 -6
  97. package/dist/components/credits/modal/modalContainer.d.ts +0 -15
  98. package/dist/components/credits/modal/rulesModal.d.ts +0 -7
  99. package/dist/components/credits/modal/tip.d.ts +0 -5
  100. package/dist/components/credits/type.d.ts +0 -55
  101. package/dist/components/index.d.ts +0 -3
  102. package/dist/debug-env.d.ts +0 -7
  103. package/dist/helpers/fetchResponse.d.ts +0 -14
  104. package/dist/helpers/fetcher.d.ts +0 -2
  105. package/dist/helpers/index.d.ts +0 -2
  106. package/dist/helpers/track.d.ts +0 -19
  107. package/dist/helpers/utils.d.ts +0 -3
  108. package/dist/stories/chat.stories.d.ts +0 -7
@@ -1,2 +1,2 @@
1
- "use strict";var S=Object.create;var u=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var g=(e,s)=>{for(var r in s)u(e,r,{get:s[r],enumerable:!0})},c=(e,s,r,i)=>{if(s&&typeof s=="object"||typeof s=="function")for(let t of v(s))!C.call(e,t)&&t!==r&&u(e,t,{get:()=>s[t],enumerable:!(i=l(s,t))||i.enumerable});return e};var b=(e,s,r)=>(r=e!=null?S(x(e)):{},c(s||!e||!e.__esModule?u(r,"default",{value:e,enumerable:!0}):r,e)),k=e=>c(u({},"__esModule",{value:!0}),e);var R={};g(R,{useSubscribed:()=>y});module.exports=k(R);var n=require("react"),p=require("../const"),m=b(require("./useActivities")),a=b(require("./useSubscriptions")),f=require("../provider"),d=require("@anker-in/lib");const y=()=>{const{profile:e}=(0,f.useCreditsContext)(),{brand:s}=(0,d.useHeadlessContext)(),r=(0,n.useMemo)(()=>({page:1,pageSize:50}),[]),{activities:i}=(0,m.default)(r),{subscriptionData:t}=(0,a.default)(e?.email);return(0,n.useMemo)(()=>t?.preference?t.preference.some(o=>o.brand===s&&o.subscribe)?!0:i?.some(o=>o.task_sub_type===p.TaskSubType.Subscription):!1,[t,i])};
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 { subscriptionData } = useSubscriptions(profile?.email)\n\n const isSubscribed = useMemo(() => {\n if (!subscriptionData?.preference) {\n return false\n }\n\n const subscribeResult = subscriptionData.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 }, [subscriptionData, 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,EAA6B,iCAC7BC,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,iBAAAG,CAAiB,KAAI,EAAAC,SAAiBN,GAAS,KAAK,EAoB5D,SAlBqB,WAAQ,IACtBK,GAAkB,WAICA,EAAiB,WAAW,KAAKE,GAChDA,EAAK,QAAUN,GAASM,EAAK,SACrC,EAGQ,GAGFJ,GAAY,KAAKI,GACfA,EAAK,gBAAkB,cAAY,YAC3C,EAbQ,GAcR,CAACF,EAAkBF,CAAU,CAAC,CAGnC",
6
- "names": ["useSubscribed_exports", "__export", "useSubscribed", "__toCommonJS", "import_react", "import_const", "import_useActivities", "import_useSubscriptions", "import_provider", "import_lib", "profile", "brand", "activitiesOptions", "activities", "useActivities", "subscriptionData", "useSubscriptions", "item"]
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
- declare function useSubscriptions(email?: string): {
3
- subscriptionData: Subscription | undefined;
3
+ export type SubscriptionApiResponse = {
4
+ data: Subscription;
4
5
  };
5
- export default useSubscriptions;
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 l=Object.create;var i=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var S=(t,r)=>{for(var e in r)i(t,e,{get:r[e],enumerable:!0})},a=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of m(r))!d.call(t,o)&&o!==e&&i(t,o,{get:()=>r[o],enumerable:!(n=b(r,o))||n.enumerable});return t};var h=(t,r,e)=>(e=t!=null?l(y(t)):{},a(r||!t||!t.__esModule?i(e,"default",{value:t,enumerable:!0}):e,t)),g=t=>a(i({},"__esModule",{value:!0}),t);var D={};S(D,{default:()=>C});module.exports=g(D);var s=require("react"),p=h(require("../../../../helpers/fetcher")),f=require("@anker-in/lib");function x(t){const r=(0,s.useRef)(!1),[e,n]=(0,s.useState)(),{locale:o}=(0,f.useHeadlessContext)(),u=(0,s.useCallback)(async()=>{if(t&&!r.current){r.current=!0;try{const c=await(0,p.default)({method:"GET",url:"/api/multipass/account/subscriptions",body:{email:t},action:"login",locale:o,headers:{},type:""});c&&n(c)}catch(c){console.error(c)}finally{r.current=!1}}},[t,o,r]);return(0,s.useEffect)(()=>{u()},[u]),{subscriptionData:e}}var C=x;
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 { useCallback, useEffect, useRef, useState } from 'react'\nimport type { Subscription } from '../../type'\nimport fetcher from '../../../../helpers/fetcher'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useSubscriptions(email?: string) {\n const loading = useRef(false)\n const [subscriptionData, setSubscriptionData] = useState<Subscription>()\n const { locale } = useHeadlessContext()\n\n const fetchSubscription = useCallback(async () => {\n if (!email) {\n return\n }\n\n if (loading.current) {\n return\n }\n\n loading.current = true\n\n try {\n const response = await fetcher({\n method: 'GET',\n url: '/api/multipass/account/subscriptions',\n body: {\n email,\n },\n action: 'login',\n locale,\n headers: {},\n type: '',\n })\n\n if (response) {\n setSubscriptionData(response)\n }\n } catch (error) {\n console.error(error)\n } finally {\n loading.current = false\n }\n }, [email, locale, loading])\n\n useEffect(() => {\n fetchSubscription()\n }, [fetchSubscription])\n\n return {\n subscriptionData,\n }\n}\n\nexport default useSubscriptions\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAyD,iBAEzDC,EAAoB,0CACpBC,EAAmC,yBAEnC,SAASC,EAAiBC,EAAgB,CACxC,MAAMC,KAAU,UAAO,EAAK,EACtB,CAACC,EAAkBC,CAAmB,KAAI,YAAuB,EACjE,CAAE,OAAAC,CAAO,KAAI,sBAAmB,EAEhCC,KAAoB,eAAY,SAAY,CAChD,GAAKL,GAID,CAAAC,EAAQ,QAIZ,CAAAA,EAAQ,QAAU,GAElB,GAAI,CACF,MAAMK,EAAW,QAAM,EAAAC,SAAQ,CAC7B,OAAQ,MACR,IAAK,uCACL,KAAM,CACJ,MAAAP,CACF,EACA,OAAQ,QACR,OAAAI,EACA,QAAS,CAAC,EACV,KAAM,EACR,CAAC,EAEGE,GACFH,EAAoBG,CAAQ,CAEhC,OAASE,EAAO,CACd,QAAQ,MAAMA,CAAK,CACrB,QAAE,CACAP,EAAQ,QAAU,EACpB,EACF,EAAG,CAACD,EAAOI,EAAQH,CAAO,CAAC,EAE3B,sBAAU,IAAM,CACdI,EAAkB,CACpB,EAAG,CAACA,CAAiB,CAAC,EAEf,CACL,iBAAAH,CACF,CACF,CAEA,IAAOR,EAAQK",
6
- "names": ["useSubscriptions_exports", "__export", "useSubscriptions_default", "__toCommonJS", "import_react", "import_fetcher", "import_lib", "useSubscriptions", "email", "loading", "subscriptionData", "setSubscriptionData", "locale", "fetchSubscription", "response", "fetcher", "error"]
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 b=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)b(e,a,{get:i[a],enumerable:!0})},k=(e,i,a,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of U(i))!A.call(e,n)&&n!==a&&b(e,n,{get:()=>i[n],enumerable:!(r=R(i,n))||r.enumerable});return e};var G=(e,i,a)=>(a=e!=null?_(T(e)):{},k(i||!e||!e.__esModule?b(a,"default",{value:e,enumerable:!0}):a,e)),W=e=>k(b({},"__esModule",{value:!0}),e);var E={};x(E,{useActions:()=>$});module.exports=W(E);var t=require("./type"),f=require("../context/provider"),d=require("react"),N=G(require("../context/hooks/useReceiptUploaded")),L=require("../context/hooks/useFirstPurchaseFinished"),C=require("../context/hooks/useSubscribed"),P=require("@anker-in/lib"),g=require("../../../helpers/track");const $=({copy:e,subscribe:i,uploadReceipt:a,activate:r,gaParameters:n})=>{const{openSignUpPopup:s,gtm:v,profile:l}=(0,f.useCreditsContext)(),u=(0,C.useSubscribed)(),c=(0,L.useFirstPurchaseFinished)(),m=(0,N.default)(),{appName:F,passportUrl:p}=(0,P.useHeadlessContext)();console.log("passportUrl",p);const h=(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,g.gaTrack)({event:"ga4Event",event_name:"lp_button",member_active_status:l?.activated?"active":"not active",event_parameters:{page_group:v.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:()=>r.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:h,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>o({buttonName:e?.joinNow,callback:s,id:t.TaskType.CompleteProfile})},notFinished:{buttonLabel:e?.completeProfile,link:`${p}/account/profile?app=${F}`,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,h,c,m,n?.position,s])};
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 console.log('passportUrl', passportUrl)\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,EACt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,GAAM,QAClB,SAAUK,EACV,GAAI,WAAS,IACf,CAAC,CACL,EACA,YAAa,CACX,YAAaL,GAAM,QACnB,KAAMA,GAAM,WACZ,YAAa,IACXe,EAAqB,CACnB,WAAYf,GAAM,QAClB,SAAU,IAAM,CAAC,EACjB,GAAI,WAAS,IACf,CAAC,CACL,EACA,UAAW,CACT,YAAaA,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,EACAM,EACAL,EACAC,EACAN,GAAc,SACdC,CACF,CAAC,CACH",
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,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ME,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,IACXe,EAAqB,CACnB,WAAYf,GAAM,QAClB,SAAUK,EACV,GAAI,WAAS,IACf,CAAC,CACL,EACA,YAAa,CACX,YAAaL,GAAM,QACnB,KAAMA,GAAM,WACZ,YAAa,IACXe,EAAqB,CACnB,WAAYf,GAAM,QAClB,SAAU,IAAM,CAAC,EACjB,GAAI,WAAS,IACf,CAAC,CACL,EACA,UAAW,CACT,YAAaA,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,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
  }
@@ -1,2 +1 @@
1
1
  export * from './components/index';
2
- export * from '@anker-in/lib';
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 t=(r,o,p,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let m of c(o))!d.call(r,m)&&m!==p&&a(r,m,{get:()=>o[m],enumerable:!(x=b(o,m))||x.enumerable});return r},f=(r,o,p)=>(t(r,o,"default"),p&&t(p,o,"default"));var g=r=>t(a({},"__esModule",{value:!0}),r);var e={};module.exports=g(e);f(e,require("./components/index"),module.exports);f(e,require("@anker-in/lib"),module.exports);
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export * from './components/index'\n\n// \u5BFC\u51FA Shopify \u76F8\u5173\u6A21\u5757\nexport * from '@anker-in/lib'\n"],
5
- "mappings": "iaAAA,IAAAA,EAAA,kBAAAC,EAAAD,GAAAE,EAAAF,EAAc,8BAAd,gBAGAE,EAAAF,EAAc,yBAHd",
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 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:r}=c(u),{subscriptionData:s}=b(i?.email);return t(()=>s?.preference?s.preference.some(e=>e.brand===o&&e.subscribe)?!0:r?.some(e=>e.task_sub_type===n.Subscription):!1,[s,r])};export{g as useSubscribed};
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 { subscriptionData } = useSubscriptions(profile?.email)\n\n const isSubscribed = useMemo(() => {\n if (!subscriptionData?.preference) {\n return false\n }\n\n const subscribeResult = subscriptionData.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 }, [subscriptionData, activities])\n\n return isSubscribed\n}\n"],
5
- "mappings": "AAAA,OAAS,WAAAA,MAAe,QAExB,OAAS,eAAAC,MAAmB,WAC5B,OAAOC,MAAmB,kBAC1B,OAAOC,MAAsB,qBAC7B,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,iBAAAE,CAAiB,EAAIR,EAAiBI,GAAS,KAAK,EAoB5D,OAlBqBP,EAAQ,IACtBW,GAAkB,WAICA,EAAiB,WAAW,KAAKC,GAChDA,EAAK,QAAUJ,GAASI,EAAK,SACrC,EAGQ,GAGFF,GAAY,KAAKE,GACfA,EAAK,gBAAkBX,EAAY,YAC3C,EAbQ,GAcR,CAACU,EAAkBD,CAAU,CAAC,CAGnC",
6
- "names": ["useMemo", "TaskSubType", "useActivities", "useSubscriptions", "useCreditsContext", "useHeadlessContext", "useSubscribed", "profile", "brand", "activitiesOptions", "activities", "subscriptionData", "item"]
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
- declare function useSubscriptions(email?: string): {
3
- subscriptionData: Subscription | undefined;
3
+ export type SubscriptionApiResponse = {
4
+ data: Subscription;
4
5
  };
5
- export default useSubscriptions;
6
+ export type FetchSubscriptionResponse = SWRResponse<Subscription>;
7
+ export declare function useSubscriptions({ email }: {
8
+ email?: string;
9
+ }): FetchSubscriptionResponse;
@@ -1,2 +1,2 @@
1
- import{useCallback as i,useEffect as u,useRef as a,useState as p}from"react";import f from"../../../../helpers/fetcher";import{useHeadlessContext as l}from"@anker-in/lib";function b(e){const t=a(!1),[n,c]=p(),{locale:o}=l(),s=i(async()=>{if(e&&!t.current){t.current=!0;try{const r=await f({method:"GET",url:"/api/multipass/account/subscriptions",body:{email:e},action:"login",locale:o,headers:{},type:""});r&&c(r)}catch(r){console.error(r)}finally{t.current=!1}}},[e,o,t]);return u(()=>{s()},[s]),{subscriptionData:n}}var S=b;export{S as default};
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 { useCallback, useEffect, useRef, useState } from 'react'\nimport type { Subscription } from '../../type'\nimport fetcher from '../../../../helpers/fetcher'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useSubscriptions(email?: string) {\n const loading = useRef(false)\n const [subscriptionData, setSubscriptionData] = useState<Subscription>()\n const { locale } = useHeadlessContext()\n\n const fetchSubscription = useCallback(async () => {\n if (!email) {\n return\n }\n\n if (loading.current) {\n return\n }\n\n loading.current = true\n\n try {\n const response = await fetcher({\n method: 'GET',\n url: '/api/multipass/account/subscriptions',\n body: {\n email,\n },\n action: 'login',\n locale,\n headers: {},\n type: '',\n })\n\n if (response) {\n setSubscriptionData(response)\n }\n } catch (error) {\n console.error(error)\n } finally {\n loading.current = false\n }\n }, [email, locale, loading])\n\n useEffect(() => {\n fetchSubscription()\n }, [fetchSubscription])\n\n return {\n subscriptionData,\n }\n}\n\nexport default useSubscriptions\n"],
5
- "mappings": "AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,UAAAC,EAAQ,YAAAC,MAAgB,QAEzD,OAAOC,MAAa,8BACpB,OAAS,sBAAAC,MAA0B,gBAEnC,SAASC,EAAiBC,EAAgB,CACxC,MAAMC,EAAUN,EAAO,EAAK,EACtB,CAACO,EAAkBC,CAAmB,EAAIP,EAAuB,EACjE,CAAE,OAAAQ,CAAO,EAAIN,EAAmB,EAEhCO,EAAoBZ,EAAY,SAAY,CAChD,GAAKO,GAID,CAAAC,EAAQ,QAIZ,CAAAA,EAAQ,QAAU,GAElB,GAAI,CACF,MAAMK,EAAW,MAAMT,EAAQ,CAC7B,OAAQ,MACR,IAAK,uCACL,KAAM,CACJ,MAAAG,CACF,EACA,OAAQ,QACR,OAAAI,EACA,QAAS,CAAC,EACV,KAAM,EACR,CAAC,EAEGE,GACFH,EAAoBG,CAAQ,CAEhC,OAASC,EAAO,CACd,QAAQ,MAAMA,CAAK,CACrB,QAAE,CACAN,EAAQ,QAAU,EACpB,EACF,EAAG,CAACD,EAAOI,EAAQH,CAAO,CAAC,EAE3B,OAAAP,EAAU,IAAM,CACdW,EAAkB,CACpB,EAAG,CAACA,CAAiB,CAAC,EAEf,CACL,iBAAAH,CACF,CACF,CAEA,IAAOM,EAAQT",
6
- "names": ["useCallback", "useEffect", "useRef", "useState", "fetcher", "useHeadlessContext", "useSubscriptions", "email", "loading", "subscriptionData", "setSubscriptionData", "locale", "fetchSubscription", "response", "error", "useSubscriptions_default"]
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 u}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:c,uploadReceipt:m,activate:p,gaParameters:n})=>{const{openSignUpPopup:a,gtm:h,profile:o}=C(),l=v(),s=g(),r=P(),{appName:k,passportUrl:b}=F();console.log("passportUrl",b);const d=u(()=>(o?.first_name||o?.last_name)&&o?.phone_number&&o?.dob,[o]);return u(()=>{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:h.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:()=>p.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:()=>c.openSubscribePopup(),id:t.Subscribe})},completed:{buttonLabel:e?.completed}},[t.CompleteProfile]:{finished:d,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:a,id:t.CompleteProfile})},notFinished:{buttonLabel:e?.completeProfile,link:`${b}/account/profile?app=${k}`,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:r,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>i({buttonName:e?.joinNow,callback:a,id:t.UploadReceipt})},notFinished:{buttonLabel:e?.uploadReceipt,handleClick:()=>i({buttonName:e?.uploadReceipt,callback:()=>m.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,d,s,r,n?.position,a])};export{G as useActions};
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 console.log('passportUrl', passportUrl)\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,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,EACpD,QAAQ,IAAI,cAAee,CAAW,EAEtC,MAAMC,EAAmBpB,EAAQ,KACvBc,GAAS,YAAcA,GAAS,YAAcA,GAAS,cAAgBA,GAAS,IACvF,CAACA,CAAO,CAAC,EAEZ,OAAOd,EAAQ,IAAM,CACnB,MAAMqB,EAAuB,CAAC,CAC5B,WAAAC,EACA,GAAAC,EACA,SAAAC,CACF,IAIM,CACJnB,EAAQ,CACN,MAAO,WACP,WAAY,YACZ,qBAAsBS,GAAS,UAAY,SAAW,aACtD,iBAAkB,CAChB,WAAYD,EAAI,UAChB,SAAUF,GAAc,UAAYJ,E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YAAaT,GAAM,kBACnB,YAAa,IACXc,EAAqB,CACnB,WAAYd,GAAM,kBAClB,SAAUK,EACV,GAAId,EAAS,aACf,CAAC,CACL,EACA,YAAa,CACX,YAAaS,GAAM,kBACnB,KAAMA,GAAM,WACZ,YAAa,IACXc,EAAqB,CACnB,WAAYd,GAAM,kBAClB,SAAU,IAAM,CAAC,EACjB,GAAIT,EAAS,aACf,CAAC,CACL,EACA,UAAW,CACT,YAAaS,GAAM,SACrB,CACF,EACA,CAACT,EAAS,aAAa,EAAG,CACxB,SAAUmB,EACV,SAAU,CACR,YAAaV,GAAM,QACnB,YAAa,IACXc,EAAqB,CACnB,WAAYd,GAAM,QAClB,SAAUK,EACV,GAAId,EAAS,aACf,CAAC,CACL,EACA,YAAa,CACX,YAAaS,GAAM,cACnB,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",
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,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,EAE9CgB,EAAmBpB,EAAQ,KACvBc,GAAS,YAAcA,GAAS,YAAcA,GAAS,cAAgBA,GAAS,IACvF,CAACA,CAAO,CAAC,EAEZ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,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
  }
@@ -1,2 +1 @@
1
1
  export * from './components/index';
2
- export * from '@anker-in/lib';
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export*from"./components/index";export*from"@anker-in/lib";
1
+ export*from"./components/index";
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export * from './components/index'\n\n// \u5BFC\u51FA Shopify \u76F8\u5173\u6A21\u5757\nexport * from '@anker-in/lib'\n"],
5
- "mappings": "AAAA,WAAc,qBAGd,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;