@anker-in/campaign-ui 0.4.5-beta.8 → 0.4.5-beta.9
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/useActivities.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useActivities.js.map +2 -2
- package/dist/cjs/components/credits/context/hooks/useMyRewards.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useMyRewards.js.map +2 -2
- package/dist/cjs/components/credits/context/hooks/useRedeemableList.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useRedeemableList.js.map +2 -2
- package/dist/cjs/components/credits/context/hooks/useUploadReceipt.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useUploadReceipt.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useActivities.js +1 -1
- package/dist/esm/components/credits/context/hooks/useActivities.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useMyRewards.js +1 -1
- package/dist/esm/components/credits/context/hooks/useMyRewards.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useRedeemableList.js +1 -1
- package/dist/esm/components/credits/context/hooks/useRedeemableList.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useUploadReceipt.js +1 -1
- package/dist/esm/components/credits/context/hooks/useUploadReceipt.js.map +2 -2
- package/package.json +1 -1
- package/src/components/credits/context/hooks/useActivities.ts +6 -4
- package/src/components/credits/context/hooks/useMyRewards.ts +3 -3
- package/src/components/credits/context/hooks/useRedeemableList.ts +2 -2
- package/src/components/credits/context/hooks/useUploadReceipt.tsx +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var u=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var z=(t,e)=>{for(var r in e)u(t,r,{get:e[r],enumerable:!0})},B=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of R(e))!h.call(t,s)&&s!==r&&u(t,s,{get:()=>e[s],enumerable:!(o=P(e,s))||o.enumerable});return t};var M=t=>B(u({},"__esModule",{value:!0}),t);var E={};z(E,{default:()=>k});module.exports=M(E);var i=require("react"),f=require("./useAlpcFetch"),b=require("../provider"),C=require("@anker-in/lib");function S({page:t,pageSize:e,options:r={}}){const{profile:o,isLoadingProfile:s,alpcBrand:L}=(0,b.useCreditsContext)(),{brand:v}=(0,C.useHeadlessContext)(),c=L||v,[n,_]=(0,i.useState)([]),[d,x]=(0,i.useState)(0),[g,A]=(0,i.useState)(0),{isMutating:a,trigger:l}=(0,f.useAlpcMutation)({url:"/v1/credit/log",initData:{brand:c}}),m=(0,i.useCallback)(async()=>{const y={page:t,page_size:e,user_id:o?.user_id,...r};l(y,{onSuccess(p){A(t),x(p?.total),_(n.concat(p?.creditLogs||[]))}})},[n,o,t,e,r,l]);return(0,i.useEffect)(()=>{s||!o||!c||a||t!==g&&t&&m()},[m,s,a,o,c,t,g]),{activities:n,isLoading:a,total:d,canNext:d>n.length&&!a}}var k=S;
|
|
1
|
+
"use strict";var u=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var z=(t,e)=>{for(var r in e)u(t,r,{get:e[r],enumerable:!0})},B=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of R(e))!h.call(t,s)&&s!==r&&u(t,s,{get:()=>e[s],enumerable:!(o=P(e,s))||o.enumerable});return t};var M=t=>B(u({},"__esModule",{value:!0}),t);var E={};z(E,{default:()=>k});module.exports=M(E);var i=require("react"),f=require("./useAlpcFetch"),b=require("../provider"),C=require("@anker-in/lib");function S({page:t,pageSize:e,options:r={}}){const{profile:o,isLoadingProfile:s,alpcBrand:L}=(0,b.useCreditsContext)(),{brand:v}=(0,C.useHeadlessContext)(),c=L||v,[n,_]=(0,i.useState)([]),[d,x]=(0,i.useState)(0),[g,A]=(0,i.useState)(0),{isMutating:a,trigger:l}=(0,f.useAlpcMutation)({url:"/v1/credit/log",initData:{brand:c}}),m=(0,i.useCallback)(async()=>{const y={page:t,page_size:e,user_id:o?.user_id,...r};l(y,{onSuccess(p){A(t),x(p?.data?.total),_(n.concat(p?.data?.creditLogs||[]))}})},[n,o,t,e,r,l]);return(0,i.useEffect)(()=>{s||!o||!c||a||t!==g&&t&&m()},[m,s,a,o,c,t,g]),{activities:n,isLoading:a,total:d,canNext:d>n.length&&!a}}var k=S;
|
|
2
2
|
//# sourceMappingURL=useActivities.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useActivities.ts"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { useAlpcMutation } from './useAlpcFetch'\nimport type { CreditLogResponse } from '../response'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useActivities({ page, pageSize, options = {} }: { page: number; pageSize: number; options?: any }) {\n const { profile, isLoadingProfile, alpcBrand } = useCreditsContext()\n const { brand: headlessBrand } = useHeadlessContext()\n const brand = alpcBrand || headlessBrand\n const [activities, setActivities] = useState<CreditLogResponse[]>([])\n const [total, setTotal] = useState(0)\n\n const [currentPage, setCurrentPage] = useState(0)\n\n const { isMutating: isLoading, trigger } = useAlpcMutation<\n {\n total: number\n
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAiD,iBAEjDC,EAAgC,0BAEhCC,EAAkC,uBAClCC,EAAmC,yBAEnC,SAASC,EAAc,CAAE,KAAAC,EAAM,SAAAC,EAAU,QAAAC,EAAU,CAAC,CAAE,EAAsD,CAC1G,KAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,UAAAC,CAAU,KAAI,qBAAkB,EAC7D,CAAE,MAAOC,CAAc,KAAI,sBAAmB,EAC9CC,EAAQF,GAAaC,EACrB,CAACE,EAAYC,CAAa,KAAI,YAA8B,CAAC,CAAC,EAC9D,CAACC,EAAOC,CAAQ,KAAI,YAAS,CAAC,EAE9B,CAACC,EAAaC,CAAc,KAAI,YAAS,CAAC,EAE1C,CAAE,WAAYC,EAAW,QAAAC,CAAQ,KAAI,
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { useAlpcMutation } from './useAlpcFetch'\nimport type { CreditLogResponse } from '../response'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useActivities({ page, pageSize, options = {} }: { page: number; pageSize: number; options?: any }) {\n const { profile, isLoadingProfile, alpcBrand } = useCreditsContext()\n const { brand: headlessBrand } = useHeadlessContext()\n const brand = alpcBrand || headlessBrand\n const [activities, setActivities] = useState<CreditLogResponse[]>([])\n const [total, setTotal] = useState(0)\n\n const [currentPage, setCurrentPage] = useState(0)\n\n const { isMutating: isLoading, trigger } = useAlpcMutation<\n {\n data: {\n total: number\n creditLogs: CreditLogResponse[]\n }\n },\n {\n page: number\n page_size: number\n user_id: string\n }\n >({\n url: `/v1/credit/log`,\n initData: {\n brand,\n },\n })\n\n const getActivities = useCallback(async () => {\n const params = {\n page: page,\n page_size: pageSize,\n user_id: profile?.user_id,\n ...options,\n }\n\n trigger(params, {\n onSuccess(responseData) {\n setCurrentPage(page)\n setTotal(responseData?.data?.total)\n setActivities(activities.concat(responseData?.data?.creditLogs || []))\n },\n })\n }, [activities, profile, page, pageSize, options, trigger])\n\n useEffect(() => {\n if (isLoadingProfile || !profile || !brand || isLoading) {\n return\n }\n\n if (page !== currentPage && page) {\n getActivities()\n }\n }, [getActivities, isLoadingProfile, isLoading, profile, brand, page, currentPage])\n\n return {\n activities,\n isLoading,\n total,\n canNext: total > activities.length && !isLoading,\n }\n}\n\nexport default useActivities\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAiD,iBAEjDC,EAAgC,0BAEhCC,EAAkC,uBAClCC,EAAmC,yBAEnC,SAASC,EAAc,CAAE,KAAAC,EAAM,SAAAC,EAAU,QAAAC,EAAU,CAAC,CAAE,EAAsD,CAC1G,KAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,UAAAC,CAAU,KAAI,qBAAkB,EAC7D,CAAE,MAAOC,CAAc,KAAI,sBAAmB,EAC9CC,EAAQF,GAAaC,EACrB,CAACE,EAAYC,CAAa,KAAI,YAA8B,CAAC,CAAC,EAC9D,CAACC,EAAOC,CAAQ,KAAI,YAAS,CAAC,EAE9B,CAACC,EAAaC,CAAc,KAAI,YAAS,CAAC,EAE1C,CAAE,WAAYC,EAAW,QAAAC,CAAQ,KAAI,mBAYzC,CACA,IAAK,iBACL,SAAU,CACR,MAAAR,CACF,CACF,CAAC,EAEKS,KAAgB,eAAY,SAAY,CAC5C,MAAMC,EAAS,CACb,KAAMjB,EACN,UAAWC,EACX,QAASE,GAAS,QAClB,GAAGD,CACL,EAEAa,EAAQE,EAAQ,CACd,UAAUC,EAAc,CACtBL,EAAeb,CAAI,EACnBW,EAASO,GAAc,MAAM,KAAK,EAClCT,EAAcD,EAAW,OAAOU,GAAc,MAAM,YAAc,CAAC,CAAC,CAAC,CACvE,CACF,CAAC,CACH,EAAG,CAACV,EAAYL,EAASH,EAAMC,EAAUC,EAASa,CAAO,CAAC,EAE1D,sBAAU,IAAM,CACVX,GAAoB,CAACD,GAAW,CAACI,GAASO,GAI1Cd,IAASY,GAAeZ,GAC1BgB,EAAc,CAElB,EAAG,CAACA,EAAeZ,EAAkBU,EAAWX,EAASI,EAAOP,EAAMY,CAAW,CAAC,EAE3E,CACL,WAAAJ,EACA,UAAAM,EACA,MAAAJ,EACA,QAASA,EAAQF,EAAW,QAAU,CAACM,CACzC,CACF,CAEA,IAAOrB,EAAQM",
|
|
6
6
|
"names": ["useActivities_exports", "__export", "useActivities_default", "__toCommonJS", "import_react", "import_useAlpcFetch", "import_provider", "import_lib", "useActivities", "page", "pageSize", "options", "profile", "isLoadingProfile", "alpcBrand", "headlessBrand", "brand", "activities", "setActivities", "total", "setTotal", "currentPage", "setCurrentPage", "isLoading", "trigger", "getActivities", "params", "responseData"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var i=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var x=(t,e)=>{for(var s in e)i(t,s,{get:e[s],enumerable:!0})},N=(t,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of L(e))!T.call(t,r)&&r!==s&&i(t,r,{get:()=>e[r],enumerable:!(o=w(e,r))||o.enumerable});return t};var h=t=>N(i({},"__esModule",{value:!0}),t);var P={};x(P,{default:()=>B});module.exports=h(P);var n=require("react"),a=require("../const"),_=require("./useAlpcFetch"),f=require("../provider"),y=require("@anker-in/lib");function z({page:t,pageSize:e,consumeType:s}){const{profile:o,alpcBrand:r}=(0,f.useCreditsContext)(),{brand:R,locale:m,appName:C}=(0,y.useHeadlessContext)(),u=r||R,[d,b]=(0,n.useState)([]),[c,A]=(0,n.useState)(0),{isMutating:l,trigger:M}=(0,_.useAlpcMutation)({url:"/v1/credit/log/coupon",initData:{brand:u,country:a.ALPC_COUNTRY_MAP.get(m)||m,app_name:C}}),p=(0,n.useCallback)(async()=>{o?.user_id&&await M({consume_type:s||a.AlpcConsumeType.Coupon,page:t,page_size:e,user_id:o?.user_id},{onSuccess(g){A(g?.total),b(g?.redeem_logs||[])}})},[s,t,e,o?.user_id]);return(0,n.useEffect)(()=>{!u||!o?.user_id||p()},[p,u]),{myRewards:d,isLoading:l,total:c,getMyRewards:p,canNext:c>d.length&&!l}}var B=z;
|
|
1
|
+
"use strict";var i=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var x=(t,e)=>{for(var s in e)i(t,s,{get:e[s],enumerable:!0})},N=(t,e,s,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of L(e))!T.call(t,r)&&r!==s&&i(t,r,{get:()=>e[r],enumerable:!(o=w(e,r))||o.enumerable});return t};var h=t=>N(i({},"__esModule",{value:!0}),t);var P={};x(P,{default:()=>B});module.exports=h(P);var n=require("react"),a=require("../const"),_=require("./useAlpcFetch"),f=require("../provider"),y=require("@anker-in/lib");function z({page:t,pageSize:e,consumeType:s}){const{profile:o,alpcBrand:r}=(0,f.useCreditsContext)(),{brand:R,locale:m,appName:C}=(0,y.useHeadlessContext)(),u=r||R,[d,b]=(0,n.useState)([]),[c,A]=(0,n.useState)(0),{isMutating:l,trigger:M}=(0,_.useAlpcMutation)({url:"/v1/credit/log/coupon",initData:{brand:u,country:a.ALPC_COUNTRY_MAP.get(m)||m,app_name:C}}),p=(0,n.useCallback)(async()=>{o?.user_id&&await M({consume_type:s||a.AlpcConsumeType.Coupon,page:t,page_size:e,user_id:o?.user_id},{onSuccess(g){A(g?.data?.total),b(g?.data?.redeem_logs||[])}})},[s,t,e,o?.user_id]);return(0,n.useEffect)(()=>{!u||!o?.user_id||p()},[p,u]),{myRewards:d,isLoading:l,total:c,getMyRewards:p,canNext:c>d.length&&!l}}var B=z;
|
|
2
2
|
//# sourceMappingURL=useMyRewards.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useMyRewards.ts"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { ALPC_COUNTRY_MAP, AlpcConsumeType } from '../const'\nimport { useAlpcMutation } from './useAlpcFetch'\nimport type { RedeemLogResponse } from '../response'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useMyRewards({\n page,\n pageSize,\n consumeType,\n}: {\n page: number\n pageSize: number\n consumeType?: AlpcConsumeType\n}) {\n const { profile, alpcBrand } = useCreditsContext()\n const { brand: headlessBrand, locale, appName } = useHeadlessContext()\n const brand = alpcBrand || headlessBrand\n\n const [myRewards, setMyRewards] = useState<RedeemLogResponse[]>([])\n const [total, setTotal] = useState(0)\n\n const { isMutating: isLoading, trigger } = useAlpcMutation<\n { redeem_logs: RedeemLogResponse[]; total: number },\n {\n page: number\n page_size: number\n consume_type: AlpcConsumeType\n user_id: string\n }\n >({\n url: `/v1/credit/log/coupon`,\n initData: {\n brand: brand,\n country: ALPC_COUNTRY_MAP.get(locale) || locale,\n app_name: appName,\n },\n })\n\n const getMyRewards = useCallback(async () => {\n if (!profile?.user_id) {\n return\n }\n await trigger(\n {\n consume_type: consumeType || AlpcConsumeType.Coupon,\n page,\n page_size: pageSize,\n user_id: profile?.user_id,\n },\n {\n onSuccess(responseData) {\n setTotal(responseData?.total)\n setMyRewards(responseData?.redeem_logs || [])\n },\n }\n )\n }, [consumeType, page, pageSize, profile?.user_id])\n\n useEffect(() => {\n if (!brand || !profile?.user_id) {\n return\n }\n getMyRewards()\n }, [getMyRewards, brand])\n\n return {\n myRewards,\n isLoading,\n total,\n getMyRewards,\n canNext: total > myRewards.length && !isLoading,\n }\n}\n\nexport default useMyRewards\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAiD,iBAEjDC,EAAkD,oBAClDC,EAAgC,0BAEhCC,EAAkC,uBAClCC,EAAmC,yBAEnC,SAASC,EAAa,CACpB,KAAAC,EACA,SAAAC,EACA,YAAAC,CACF,EAIG,CACD,KAAM,CAAE,QAAAC,EAAS,UAAAC,CAAU,KAAI,qBAAkB,EAC3C,CAAE,MAAOC,EAAe,OAAAC,EAAQ,QAAAC,CAAQ,KAAI,sBAAmB,EAC/DC,EAAQJ,GAAaC,EAErB,CAACI,EAAWC,CAAY,KAAI,YAA8B,CAAC,CAAC,EAC5D,CAACC,EAAOC,CAAQ,KAAI,YAAS,CAAC,EAE9B,CAAE,WAAYC,EAAW,QAAAC,CAAQ,KAAI,mBAQzC,CACA,IAAK,wBACL,SAAU,CACR,MAAON,EACP,QAAS,mBAAiB,IAAIF,CAAM,GAAKA,EACzC,SAAUC,CACZ,CACF,CAAC,EAEKQ,KAAe,eAAY,SAAY,CACtCZ,GAAS,SAGd,MAAMW,EACJ,CACE,aAAcZ,GAAe,kBAAgB,OAC7C,KAAAF,EACA,UAAWC,EACX,QAASE,GAAS,OACpB,EACA,CACE,UAAUa,EAAc,CACtBJ,EAASI,GAAc,KAAK,
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { ALPC_COUNTRY_MAP, AlpcConsumeType } from '../const'\nimport { useAlpcMutation } from './useAlpcFetch'\nimport type { RedeemLogResponse } from '../response'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useMyRewards({\n page,\n pageSize,\n consumeType,\n}: {\n page: number\n pageSize: number\n consumeType?: AlpcConsumeType\n}) {\n const { profile, alpcBrand } = useCreditsContext()\n const { brand: headlessBrand, locale, appName } = useHeadlessContext()\n const brand = alpcBrand || headlessBrand\n\n const [myRewards, setMyRewards] = useState<RedeemLogResponse[]>([])\n const [total, setTotal] = useState(0)\n\n const { isMutating: isLoading, trigger } = useAlpcMutation<\n { data: { redeem_logs: RedeemLogResponse[]; total: number } },\n {\n page: number\n page_size: number\n consume_type: AlpcConsumeType\n user_id: string\n }\n >({\n url: `/v1/credit/log/coupon`,\n initData: {\n brand: brand,\n country: ALPC_COUNTRY_MAP.get(locale) || locale,\n app_name: appName,\n },\n })\n\n const getMyRewards = useCallback(async () => {\n if (!profile?.user_id) {\n return\n }\n await trigger(\n {\n consume_type: consumeType || AlpcConsumeType.Coupon,\n page,\n page_size: pageSize,\n user_id: profile?.user_id,\n },\n {\n onSuccess(responseData) {\n setTotal(responseData?.data?.total)\n setMyRewards(responseData?.data?.redeem_logs || [])\n },\n }\n )\n }, [consumeType, page, pageSize, profile?.user_id])\n\n useEffect(() => {\n if (!brand || !profile?.user_id) {\n return\n }\n getMyRewards()\n }, [getMyRewards, brand])\n\n return {\n myRewards,\n isLoading,\n total,\n getMyRewards,\n canNext: total > myRewards.length && !isLoading,\n }\n}\n\nexport default useMyRewards\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAiD,iBAEjDC,EAAkD,oBAClDC,EAAgC,0BAEhCC,EAAkC,uBAClCC,EAAmC,yBAEnC,SAASC,EAAa,CACpB,KAAAC,EACA,SAAAC,EACA,YAAAC,CACF,EAIG,CACD,KAAM,CAAE,QAAAC,EAAS,UAAAC,CAAU,KAAI,qBAAkB,EAC3C,CAAE,MAAOC,EAAe,OAAAC,EAAQ,QAAAC,CAAQ,KAAI,sBAAmB,EAC/DC,EAAQJ,GAAaC,EAErB,CAACI,EAAWC,CAAY,KAAI,YAA8B,CAAC,CAAC,EAC5D,CAACC,EAAOC,CAAQ,KAAI,YAAS,CAAC,EAE9B,CAAE,WAAYC,EAAW,QAAAC,CAAQ,KAAI,mBAQzC,CACA,IAAK,wBACL,SAAU,CACR,MAAON,EACP,QAAS,mBAAiB,IAAIF,CAAM,GAAKA,EACzC,SAAUC,CACZ,CACF,CAAC,EAEKQ,KAAe,eAAY,SAAY,CACtCZ,GAAS,SAGd,MAAMW,EACJ,CACE,aAAcZ,GAAe,kBAAgB,OAC7C,KAAAF,EACA,UAAWC,EACX,QAASE,GAAS,OACpB,EACA,CACE,UAAUa,EAAc,CACtBJ,EAASI,GAAc,MAAM,KAAK,EAClCN,EAAaM,GAAc,MAAM,aAAe,CAAC,CAAC,CACpD,CACF,CACF,CACF,EAAG,CAACd,EAAaF,EAAMC,EAAUE,GAAS,OAAO,CAAC,EAElD,sBAAU,IAAM,CACV,CAACK,GAAS,CAACL,GAAS,SAGxBY,EAAa,CACf,EAAG,CAACA,EAAcP,CAAK,CAAC,EAEjB,CACL,UAAAC,EACA,UAAAI,EACA,MAAAF,EACA,aAAAI,EACA,QAASJ,EAAQF,EAAU,QAAU,CAACI,CACxC,CACF,CAEA,IAAOrB,EAAQO",
|
|
6
6
|
"names": ["useMyRewards_exports", "__export", "useMyRewards_default", "__toCommonJS", "import_react", "import_const", "import_useAlpcFetch", "import_provider", "import_lib", "useMyRewards", "page", "pageSize", "consumeType", "profile", "alpcBrand", "headlessBrand", "locale", "appName", "brand", "myRewards", "setMyRewards", "total", "setTotal", "isLoading", "trigger", "getMyRewards", "responseData"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var c=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var M=(s,e)=>{for(var t in e)c(s,t,{get:e[t],enumerable:!0})},P=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of A(e))!x.call(s,o)&&o!==t&&c(s,o,{get:()=>e[o],enumerable:!(r=b(e,o))||r.enumerable});return s};var B=s=>P(c({},"__esModule",{value:!0}),s);var h={};M(h,{default:()=>U});module.exports=B(h);var n=require("react"),d=require("./useAlpcFetch"),C=require("../const"),f=require("../provider"),y=require("@anker-in/lib");function S(s){let e="";const{profile:t,isLoadingProfile:r,alpcBrand:o}=(0,f.useCreditsContext)(),{locale:l,brand:_}=(0,y.useHeadlessContext)(),u=o||_;l==="pl"?e="eu":e=l;const[g,T]=(0,n.useState)([]),{isMutating:R,trigger:m}=(0,d.useAlpcMutation)({url:"/v1/credit/consume_credit_rules",initData:{brand:u,page:1,page_size:999,country:(C.ALPC_COUNTRY_MAP.get(e)||e)?.toUpperCase()}}),i=(0,n.useCallback)(p=>{m({user_id:t?.user_id,...p?.consumeType&&{consume_type:p.consumeType}},{onSuccess(a){console.log("responseData",a);let L=a?.consume_credit_rules||[];T(L)}})},[t,m,e]);return(0,n.useEffect)(()=>{!u||r||i({consumeType:s?.consumeType})},[i,r,u]),{listLoading:R,redeemableList:g,getRedeemableList:i}}var U=S;
|
|
1
|
+
"use strict";var c=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var M=(s,e)=>{for(var t in e)c(s,t,{get:e[t],enumerable:!0})},P=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of A(e))!x.call(s,o)&&o!==t&&c(s,o,{get:()=>e[o],enumerable:!(r=b(e,o))||r.enumerable});return s};var B=s=>P(c({},"__esModule",{value:!0}),s);var h={};M(h,{default:()=>U});module.exports=B(h);var n=require("react"),d=require("./useAlpcFetch"),C=require("../const"),f=require("../provider"),y=require("@anker-in/lib");function S(s){let e="";const{profile:t,isLoadingProfile:r,alpcBrand:o}=(0,f.useCreditsContext)(),{locale:l,brand:_}=(0,y.useHeadlessContext)(),u=o||_;l==="pl"?e="eu":e=l;const[g,T]=(0,n.useState)([]),{isMutating:R,trigger:m}=(0,d.useAlpcMutation)({url:"/v1/credit/consume_credit_rules",initData:{brand:u,page:1,page_size:999,country:(C.ALPC_COUNTRY_MAP.get(e)||e)?.toUpperCase()}}),i=(0,n.useCallback)(p=>{m({user_id:t?.user_id,...p?.consumeType&&{consume_type:p.consumeType}},{onSuccess(a){console.log("responseData",a);let L=a?.data?.consume_credit_rules||[];T(L)}})},[t,m,e]);return(0,n.useEffect)(()=>{!u||r||i({consumeType:s?.consumeType})},[i,r,u]),{listLoading:R,redeemableList:g,getRedeemableList:i}}var U=S;
|
|
2
2
|
//# sourceMappingURL=useRedeemableList.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useRedeemableList.ts"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { useAlpcMutation } from './useAlpcFetch'\nimport { ALPC_COUNTRY_MAP, AlpcConsumeType } from '../const'\nimport { useCreditsContext } from '../provider'\nimport type { ConsumeCreditRuleResponse } from '../response'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useRedeemableList(props?: { consumeType: AlpcConsumeType }) {\n let locale = '' as string\n const { profile, isLoadingProfile, alpcBrand } = useCreditsContext()\n const { locale: contextLocale, brand: headlessBrand } = useHeadlessContext()\n const brand = alpcBrand || headlessBrand\n\n if (contextLocale === 'pl') {\n locale = 'eu'\n } else {\n locale = contextLocale\n }\n\n const [redeemableList, setRedeemableList] = useState<ConsumeCreditRuleResponse[]>([])\n const { isMutating: listLoading, trigger } = useAlpcMutation<\n {\n consume_credit_rules: ConsumeCreditRuleResponse[]\n },\n { consume_type?: AlpcConsumeType; user_id?: string }\n >({\n url: `/v1/credit/consume_credit_rules`,\n initData: {\n brand,\n page: 1,\n page_size: 999,\n country: (ALPC_COUNTRY_MAP.get(locale) || locale)?.toUpperCase(),\n },\n })\n\n const getRedeemableList = useCallback(\n (props?: { consumeType?: AlpcConsumeType }) => {\n trigger(\n {\n user_id: profile?.user_id,\n ...(props?.consumeType && { consume_type: props.consumeType }),\n },\n {\n onSuccess(responseData) {\n console.log('responseData', responseData)\n let list = responseData?.consume_credit_rules || []\n setRedeemableList(list)\n },\n }\n )\n },\n [profile, trigger, locale]\n )\n\n useEffect(() => {\n if (!brand || isLoadingProfile) {\n return\n }\n getRedeemableList({ consumeType: props?.consumeType })\n }, [getRedeemableList, isLoadingProfile, brand])\n\n return {\n listLoading,\n redeemableList,\n getRedeemableList,\n }\n}\n\nexport default useRedeemableList\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAiD,iBAEjDC,EAAgC,0BAChCC,EAAkD,oBAClDC,EAAkC,uBAElCC,EAAmC,yBAEnC,SAASC,EAAkBC,EAA0C,CACnE,IAAIC,EAAS,GACb,KAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,UAAAC,CAAU,KAAI,qBAAkB,EAC7D,CAAE,OAAQC,EAAe,MAAOC,CAAc,KAAI,sBAAmB,EACrEC,EAAQH,GAAaE,EAEvBD,IAAkB,KACpBJ,EAAS,KAETA,EAASI,EAGX,KAAM,CAACG,EAAgBC,CAAiB,KAAI,YAAsC,CAAC,CAAC,EAC9E,CAAE,WAAYC,EAAa,QAAAC,CAAQ,KAAI,mBAK3C,CACA,IAAK,kCACL,SAAU,CACR,MAAAJ,EACA,KAAM,EACN,UAAW,IACX,SAAU,mBAAiB,IAAIN,CAAM,GAAKA,IAAS,YAAY,CACjE,CACF,CAAC,EAEKW,KAAoB,eACvBZ,GAA8C,CAC7CW,EACE,CACE,QAAST,GAAS,QAClB,GAAIF,GAAO,aAAe,CAAE,aAAcA,EAAM,WAAY,CAC9D,EACA,CACE,UAAUa,EAAc,CACtB,QAAQ,IAAI,eAAgBA,CAAY,EACxC,IAAIC,EAAOD,GAAc,sBAAwB,CAAC,
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { useAlpcMutation } from './useAlpcFetch'\nimport { ALPC_COUNTRY_MAP, AlpcConsumeType } from '../const'\nimport { useCreditsContext } from '../provider'\nimport type { ConsumeCreditRuleResponse } from '../response'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useRedeemableList(props?: { consumeType: AlpcConsumeType }) {\n let locale = '' as string\n const { profile, isLoadingProfile, alpcBrand } = useCreditsContext()\n const { locale: contextLocale, brand: headlessBrand } = useHeadlessContext()\n const brand = alpcBrand || headlessBrand\n\n if (contextLocale === 'pl') {\n locale = 'eu'\n } else {\n locale = contextLocale\n }\n\n const [redeemableList, setRedeemableList] = useState<ConsumeCreditRuleResponse[]>([])\n const { isMutating: listLoading, trigger } = useAlpcMutation<\n {\n data: { consume_credit_rules: ConsumeCreditRuleResponse[] }\n },\n { consume_type?: AlpcConsumeType; user_id?: string }\n >({\n url: `/v1/credit/consume_credit_rules`,\n initData: {\n brand,\n page: 1,\n page_size: 999,\n country: (ALPC_COUNTRY_MAP.get(locale) || locale)?.toUpperCase(),\n },\n })\n\n const getRedeemableList = useCallback(\n (props?: { consumeType?: AlpcConsumeType }) => {\n trigger(\n {\n user_id: profile?.user_id,\n ...(props?.consumeType && { consume_type: props.consumeType }),\n },\n {\n onSuccess(responseData) {\n console.log('responseData', responseData)\n let list = responseData?.data?.consume_credit_rules || []\n setRedeemableList(list)\n },\n }\n )\n },\n [profile, trigger, locale]\n )\n\n useEffect(() => {\n if (!brand || isLoadingProfile) {\n return\n }\n getRedeemableList({ consumeType: props?.consumeType })\n }, [getRedeemableList, isLoadingProfile, brand])\n\n return {\n listLoading,\n redeemableList,\n getRedeemableList,\n }\n}\n\nexport default useRedeemableList\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAAiD,iBAEjDC,EAAgC,0BAChCC,EAAkD,oBAClDC,EAAkC,uBAElCC,EAAmC,yBAEnC,SAASC,EAAkBC,EAA0C,CACnE,IAAIC,EAAS,GACb,KAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,UAAAC,CAAU,KAAI,qBAAkB,EAC7D,CAAE,OAAQC,EAAe,MAAOC,CAAc,KAAI,sBAAmB,EACrEC,EAAQH,GAAaE,EAEvBD,IAAkB,KACpBJ,EAAS,KAETA,EAASI,EAGX,KAAM,CAACG,EAAgBC,CAAiB,KAAI,YAAsC,CAAC,CAAC,EAC9E,CAAE,WAAYC,EAAa,QAAAC,CAAQ,KAAI,mBAK3C,CACA,IAAK,kCACL,SAAU,CACR,MAAAJ,EACA,KAAM,EACN,UAAW,IACX,SAAU,mBAAiB,IAAIN,CAAM,GAAKA,IAAS,YAAY,CACjE,CACF,CAAC,EAEKW,KAAoB,eACvBZ,GAA8C,CAC7CW,EACE,CACE,QAAST,GAAS,QAClB,GAAIF,GAAO,aAAe,CAAE,aAAcA,EAAM,WAAY,CAC9D,EACA,CACE,UAAUa,EAAc,CACtB,QAAQ,IAAI,eAAgBA,CAAY,EACxC,IAAIC,EAAOD,GAAc,MAAM,sBAAwB,CAAC,EACxDJ,EAAkBK,CAAI,CACxB,CACF,CACF,CACF,EACA,CAACZ,EAASS,EAASV,CAAM,CAC3B,EAEA,sBAAU,IAAM,CACV,CAACM,GAASJ,GAGdS,EAAkB,CAAE,YAAaZ,GAAO,WAAY,CAAC,CACvD,EAAG,CAACY,EAAmBT,EAAkBI,CAAK,CAAC,EAExC,CACL,YAAAG,EACA,eAAAF,EACA,kBAAAI,CACF,CACF,CAEA,IAAOpB,EAAQO",
|
|
6
6
|
"names": ["useRedeemableList_exports", "__export", "useRedeemableList_default", "__toCommonJS", "import_react", "import_useAlpcFetch", "import_const", "import_provider", "import_lib", "useRedeemableList", "props", "locale", "profile", "isLoadingProfile", "alpcBrand", "contextLocale", "headlessBrand", "brand", "redeemableList", "setRedeemableList", "listLoading", "trigger", "getRedeemableList", "responseData", "list"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var l=Object.create;var
|
|
1
|
+
"use strict";var l=Object.create;var d=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,_=Object.prototype.hasOwnProperty;var f=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},i=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of m(e))!_.call(t,a)&&a!==r&&d(t,a,{get:()=>e[a],enumerable:!(o=p(e,a))||o.enumerable});return t};var g=(t,e,r)=>(r=t!=null?l(y(t)):{},i(e||!t||!t.__esModule?d(r,"default",{value:t,enumerable:!0}):r,t)),h=t=>i(d({},"__esModule",{value:!0}),t);var k={};f(k,{useUploadReceipt:()=>b});module.exports=h(k);var c=g(require("swr/mutation")),s=require("@anker-in/lib");const R=t=>t&&(t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:t),b=()=>{const{locale:t}=(0,s.useHeadlessContext)();return(0,c.default)("/api/multipass/mktsrv/v1/credit/upload_third_party_order",async(r,{arg:{orderName:o}})=>{const u=await(await fetch("/api/multipass/mktsrv/v1/credit/upload_third_party_order",{credentials:"include",method:"POST",headers:{"Content-Type":"application/json","current-language":t},body:JSON.stringify({order_name:o})})).json(),n=R(u);return{ok:n?.data?.code===0,code:n?.data?.code??-1}})};
|
|
2
2
|
//# sourceMappingURL=useUploadReceipt.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useUploadReceipt.tsx"],
|
|
4
|
-
"sourcesContent": ["import useSWRMutation from 'swr/mutation'\nimport { useHeadlessContext } from '@anker-in/lib'\n\n/**\n * \u7EDF\u4E00\u5904\u7406 ALPC \u63A5\u53E3\u8FD4\u56DE\u7684\u6570\u636E\u7ED3\u6784\n * \u517C\u5BB9\u4E00\u5C42 data \u548C\u4E24\u5C42 data \u7684\u573A\u666F\n */\nconst normalizeResponseData = (responseData: any) => {\n if (!responseData) return responseData\n\n // \u5982\u679C responseData.data \u5B58\u5728\u4E14\u662F\u4E00\u4E2A\u5BF9\u8C61\uFF08\u4E0D\u662F\u6570\u7EC4\uFF09\uFF0C\u8BF4\u660E\u662F\u4E24\u5C42 data \u7ED3\u6784\n if (responseData.data && typeof responseData.data === 'object' && !Array.isArray(responseData.data)) {\n return responseData.data\n }\n\n // \u4E00\u5C42 data \u7ED3\u6784\u6216\u5176\u4ED6\u60C5\u51B5\uFF0C\u76F4\u63A5\u8FD4\u56DE\n return responseData\n}\n\nexport const useUploadReceipt = () => {\n const { locale } = useHeadlessContext()\n\n const uploadReceipt = async (\n _: any,\n { arg: { orderName } }: { arg: { orderName: string } }\n ): Promise<{\n ok: boolean\n code: number\n }> => {\n const response = await fetch(`/api/multipass/mktsrv/v1/credit/upload_third_party_order`, {\n credentials: 'include',\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'current-language': locale,\n },\n body: JSON.stringify({\n order_name: orderName,\n }),\n })\n const result = await response.json()\n const normalizedData = normalizeResponseData(result)\n return {\n ok: normalizedData?.code === 0,\n code: normalizedData?.code ?? -1,\n }\n }\n\n return useSWRMutation('/api/multipass/mktsrv/v1/credit/upload_third_party_order', uploadReceipt)\n}\n"],
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA2B,2BAC3BC,EAAmC,yBAMnC,MAAMC,EAAyBC,GACxBA,IAGDA,EAAa,MAAQ,OAAOA,EAAa,MAAS,UAAY,CAAC,MAAM,QAAQA,EAAa,IAAI,EACzFA,EAAa,KAIfA,GAGIL,EAAmB,IAAM,CACpC,KAAM,CAAE,OAAAM,CAAO,KAAI,sBAAmB,EA4BtC,SAAO,EAAAC,SAAe,2DA1BA,MACpBC,EACA,CAAE,IAAK,CAAE,UAAAC,CAAU,CAAE,IAIjB,CAYJ,MAAMC,EAAS,MAXE,MAAM,MAAM,2DAA4D,CACvF,YAAa,UACb,OAAQ,OACR,QAAS,CACP,eAAgB,mBAChB,mBAAoBJ,CACtB,EACA,KAAM,KAAK,UAAU,CACnB,WAAYG,CACd,CAAC,CACH,CAAC,GAC6B,KAAK,EAC7BE,EAAiBP,EAAsBM,CAAM,EACnD,MAAO,CACL,GAAIC,GAAgB,OAAS,
|
|
4
|
+
"sourcesContent": ["import useSWRMutation from 'swr/mutation'\nimport { useHeadlessContext } from '@anker-in/lib'\n\n/**\n * \u7EDF\u4E00\u5904\u7406 ALPC \u63A5\u53E3\u8FD4\u56DE\u7684\u6570\u636E\u7ED3\u6784\n * \u517C\u5BB9\u4E00\u5C42 data \u548C\u4E24\u5C42 data \u7684\u573A\u666F\n */\nconst normalizeResponseData = (responseData: any) => {\n if (!responseData) return responseData\n\n // \u5982\u679C responseData.data \u5B58\u5728\u4E14\u662F\u4E00\u4E2A\u5BF9\u8C61\uFF08\u4E0D\u662F\u6570\u7EC4\uFF09\uFF0C\u8BF4\u660E\u662F\u4E24\u5C42 data \u7ED3\u6784\n if (responseData.data && typeof responseData.data === 'object' && !Array.isArray(responseData.data)) {\n return responseData.data\n }\n\n // \u4E00\u5C42 data \u7ED3\u6784\u6216\u5176\u4ED6\u60C5\u51B5\uFF0C\u76F4\u63A5\u8FD4\u56DE\n return responseData\n}\n\nexport const useUploadReceipt = () => {\n const { locale } = useHeadlessContext()\n\n const uploadReceipt = async (\n _: any,\n { arg: { orderName } }: { arg: { orderName: string } }\n ): Promise<{\n ok: boolean\n code: number\n }> => {\n const response = await fetch(`/api/multipass/mktsrv/v1/credit/upload_third_party_order`, {\n credentials: 'include',\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'current-language': locale,\n },\n body: JSON.stringify({\n order_name: orderName,\n }),\n })\n const result = await response.json()\n const normalizedData = normalizeResponseData(result)\n return {\n ok: normalizedData?.data?.code === 0,\n code: normalizedData?.data?.code ?? -1,\n }\n }\n\n return useSWRMutation('/api/multipass/mktsrv/v1/credit/upload_third_party_order', uploadReceipt)\n}\n"],
|
|
5
|
+
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA2B,2BAC3BC,EAAmC,yBAMnC,MAAMC,EAAyBC,GACxBA,IAGDA,EAAa,MAAQ,OAAOA,EAAa,MAAS,UAAY,CAAC,MAAM,QAAQA,EAAa,IAAI,EACzFA,EAAa,KAIfA,GAGIL,EAAmB,IAAM,CACpC,KAAM,CAAE,OAAAM,CAAO,KAAI,sBAAmB,EA4BtC,SAAO,EAAAC,SAAe,2DA1BA,MACpBC,EACA,CAAE,IAAK,CAAE,UAAAC,CAAU,CAAE,IAIjB,CAYJ,MAAMC,EAAS,MAXE,MAAM,MAAM,2DAA4D,CACvF,YAAa,UACb,OAAQ,OACR,QAAS,CACP,eAAgB,mBAChB,mBAAoBJ,CACtB,EACA,KAAM,KAAK,UAAU,CACnB,WAAYG,CACd,CAAC,CACH,CAAC,GAC6B,KAAK,EAC7BE,EAAiBP,EAAsBM,CAAM,EACnD,MAAO,CACL,GAAIC,GAAgB,MAAM,OAAS,EACnC,KAAMA,GAAgB,MAAM,MAAQ,EACtC,CACF,CAE+F,CACjG",
|
|
6
6
|
"names": ["useUploadReceipt_exports", "__export", "useUploadReceipt", "__toCommonJS", "import_mutation", "import_lib", "normalizeResponseData", "responseData", "locale", "useSWRMutation", "_", "orderName", "result", "normalizedData"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useCallback as _,useEffect as x,useState as o}from"react";import{useAlpcMutation as A}from"./useAlpcFetch";import{useCreditsContext as y}from"../provider";import{useHeadlessContext as P}from"@anker-in/lib";function R({page:t,pageSize:n,options:a={}}){const{profile:e,isLoadingProfile:c,alpcBrand:p}=y(),{brand:f}=P(),r=p||f,[s,b]=o([]),[u,C]=o(0),[d,L]=o(0),{isMutating:i,trigger:g}=A({url:"/v1/credit/log",initData:{brand:r}}),l=_(async()=>{const v={page:t,page_size:n,user_id:e?.user_id,...a};g(v,{onSuccess(m){L(t),C(m?.total),b(s.concat(m?.creditLogs||[]))}})},[s,e,t,n,a,g]);return x(()=>{c||!e||!r||i||t!==d&&t&&l()},[l,c,i,e,r,t,d]),{activities:s,isLoading:i,total:u,canNext:u>s.length&&!i}}var S=R;export{S as default};
|
|
1
|
+
import{useCallback as _,useEffect as x,useState as o}from"react";import{useAlpcMutation as A}from"./useAlpcFetch";import{useCreditsContext as y}from"../provider";import{useHeadlessContext as P}from"@anker-in/lib";function R({page:t,pageSize:n,options:a={}}){const{profile:e,isLoadingProfile:c,alpcBrand:p}=y(),{brand:f}=P(),r=p||f,[s,b]=o([]),[u,C]=o(0),[d,L]=o(0),{isMutating:i,trigger:g}=A({url:"/v1/credit/log",initData:{brand:r}}),l=_(async()=>{const v={page:t,page_size:n,user_id:e?.user_id,...a};g(v,{onSuccess(m){L(t),C(m?.data?.total),b(s.concat(m?.data?.creditLogs||[]))}})},[s,e,t,n,a,g]);return x(()=>{c||!e||!r||i||t!==d&&t&&l()},[l,c,i,e,r,t,d]),{activities:s,isLoading:i,total:u,canNext:u>s.length&&!i}}var S=R;export{S as default};
|
|
2
2
|
//# sourceMappingURL=useActivities.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useActivities.ts"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { useAlpcMutation } from './useAlpcFetch'\nimport type { CreditLogResponse } from '../response'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useActivities({ page, pageSize, options = {} }: { page: number; pageSize: number; options?: any }) {\n const { profile, isLoadingProfile, alpcBrand } = useCreditsContext()\n const { brand: headlessBrand } = useHeadlessContext()\n const brand = alpcBrand || headlessBrand\n const [activities, setActivities] = useState<CreditLogResponse[]>([])\n const [total, setTotal] = useState(0)\n\n const [currentPage, setCurrentPage] = useState(0)\n\n const { isMutating: isLoading, trigger } = useAlpcMutation<\n {\n total: number\n
|
|
5
|
-
"mappings": "AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QAEjD,OAAS,mBAAAC,MAAuB,iBAEhC,OAAS,qBAAAC,MAAyB,cAClC,OAAS,sBAAAC,MAA0B,gBAEnC,SAASC,EAAc,CAAE,KAAAC,EAAM,SAAAC,EAAU,QAAAC,EAAU,CAAC,CAAE,EAAsD,CAC1G,KAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,UAAAC,CAAU,EAAIR,EAAkB,EAC7D,CAAE,MAAOS,CAAc,EAAIR,EAAmB,EAC9CS,EAAQF,GAAaC,EACrB,CAACE,EAAYC,CAAa,EAAId,EAA8B,CAAC,CAAC,EAC9D,CAACe,EAAOC,CAAQ,EAAIhB,EAAS,CAAC,EAE9B,CAACiB,EAAaC,CAAc,EAAIlB,EAAS,CAAC,EAE1C,CAAE,WAAYmB,EAAW,QAAAC,CAAQ,EAAInB,
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { useAlpcMutation } from './useAlpcFetch'\nimport type { CreditLogResponse } from '../response'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useActivities({ page, pageSize, options = {} }: { page: number; pageSize: number; options?: any }) {\n const { profile, isLoadingProfile, alpcBrand } = useCreditsContext()\n const { brand: headlessBrand } = useHeadlessContext()\n const brand = alpcBrand || headlessBrand\n const [activities, setActivities] = useState<CreditLogResponse[]>([])\n const [total, setTotal] = useState(0)\n\n const [currentPage, setCurrentPage] = useState(0)\n\n const { isMutating: isLoading, trigger } = useAlpcMutation<\n {\n data: {\n total: number\n creditLogs: CreditLogResponse[]\n }\n },\n {\n page: number\n page_size: number\n user_id: string\n }\n >({\n url: `/v1/credit/log`,\n initData: {\n brand,\n },\n })\n\n const getActivities = useCallback(async () => {\n const params = {\n page: page,\n page_size: pageSize,\n user_id: profile?.user_id,\n ...options,\n }\n\n trigger(params, {\n onSuccess(responseData) {\n setCurrentPage(page)\n setTotal(responseData?.data?.total)\n setActivities(activities.concat(responseData?.data?.creditLogs || []))\n },\n })\n }, [activities, profile, page, pageSize, options, trigger])\n\n useEffect(() => {\n if (isLoadingProfile || !profile || !brand || isLoading) {\n return\n }\n\n if (page !== currentPage && page) {\n getActivities()\n }\n }, [getActivities, isLoadingProfile, isLoading, profile, brand, page, currentPage])\n\n return {\n activities,\n isLoading,\n total,\n canNext: total > activities.length && !isLoading,\n }\n}\n\nexport default useActivities\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QAEjD,OAAS,mBAAAC,MAAuB,iBAEhC,OAAS,qBAAAC,MAAyB,cAClC,OAAS,sBAAAC,MAA0B,gBAEnC,SAASC,EAAc,CAAE,KAAAC,EAAM,SAAAC,EAAU,QAAAC,EAAU,CAAC,CAAE,EAAsD,CAC1G,KAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,UAAAC,CAAU,EAAIR,EAAkB,EAC7D,CAAE,MAAOS,CAAc,EAAIR,EAAmB,EAC9CS,EAAQF,GAAaC,EACrB,CAACE,EAAYC,CAAa,EAAId,EAA8B,CAAC,CAAC,EAC9D,CAACe,EAAOC,CAAQ,EAAIhB,EAAS,CAAC,EAE9B,CAACiB,EAAaC,CAAc,EAAIlB,EAAS,CAAC,EAE1C,CAAE,WAAYmB,EAAW,QAAAC,CAAQ,EAAInB,EAYzC,CACA,IAAK,iBACL,SAAU,CACR,MAAAW,CACF,CACF,CAAC,EAEKS,EAAgBvB,EAAY,SAAY,CAC5C,MAAMwB,EAAS,CACb,KAAMjB,EACN,UAAWC,EACX,QAASE,GAAS,QAClB,GAAGD,CACL,EAEAa,EAAQE,EAAQ,CACd,UAAUC,EAAc,CACtBL,EAAeb,CAAI,EACnBW,EAASO,GAAc,MAAM,KAAK,EAClCT,EAAcD,EAAW,OAAOU,GAAc,MAAM,YAAc,CAAC,CAAC,CAAC,CACvE,CACF,CAAC,CACH,EAAG,CAACV,EAAYL,EAASH,EAAMC,EAAUC,EAASa,CAAO,CAAC,EAE1D,OAAArB,EAAU,IAAM,CACVU,GAAoB,CAACD,GAAW,CAACI,GAASO,GAI1Cd,IAASY,GAAeZ,GAC1BgB,EAAc,CAElB,EAAG,CAACA,EAAeZ,EAAkBU,EAAWX,EAASI,EAAOP,EAAMY,CAAW,CAAC,EAE3E,CACL,WAAAJ,EACA,UAAAM,EACA,MAAAJ,EACA,QAASA,EAAQF,EAAW,QAAU,CAACM,CACzC,CACF,CAEA,IAAOK,EAAQpB",
|
|
6
6
|
"names": ["useCallback", "useEffect", "useState", "useAlpcMutation", "useCreditsContext", "useHeadlessContext", "useActivities", "page", "pageSize", "options", "profile", "isLoadingProfile", "alpcBrand", "headlessBrand", "brand", "activities", "setActivities", "total", "setTotal", "currentPage", "setCurrentPage", "isLoading", "trigger", "getActivities", "params", "responseData", "useActivities_default"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useCallback as R,useEffect as C,useState as d}from"react";import{ALPC_COUNTRY_MAP as b,AlpcConsumeType as A}from"../const";import{useAlpcMutation as M}from"./useAlpcFetch";import{useCreditsContext as w}from"../provider";import{useHeadlessContext as L}from"@anker-in/lib";function T({page:o,pageSize:r,consumeType:n}){const{profile:e,alpcBrand:c}=w(),{brand:l,locale:a,appName:g}=L(),t=c||l,[u,_]=d([]),[p,f]=d(0),{isMutating:i,trigger:y}=M({url:"/v1/credit/log/coupon",initData:{brand:t,country:b.get(a)||a,app_name:g}}),s=R(async()=>{e?.user_id&&await y({consume_type:n||A.Coupon,page:o,page_size:r,user_id:e?.user_id},{onSuccess(m){f(m?.total),_(m?.redeem_logs||[])}})},[n,o,r,e?.user_id]);return C(()=>{!t||!e?.user_id||s()},[s,t]),{myRewards:u,isLoading:i,total:p,getMyRewards:s,canNext:p>u.length&&!i}}var P=T;export{P as default};
|
|
1
|
+
import{useCallback as R,useEffect as C,useState as d}from"react";import{ALPC_COUNTRY_MAP as b,AlpcConsumeType as A}from"../const";import{useAlpcMutation as M}from"./useAlpcFetch";import{useCreditsContext as w}from"../provider";import{useHeadlessContext as L}from"@anker-in/lib";function T({page:o,pageSize:r,consumeType:n}){const{profile:e,alpcBrand:c}=w(),{brand:l,locale:a,appName:g}=L(),t=c||l,[u,_]=d([]),[p,f]=d(0),{isMutating:i,trigger:y}=M({url:"/v1/credit/log/coupon",initData:{brand:t,country:b.get(a)||a,app_name:g}}),s=R(async()=>{e?.user_id&&await y({consume_type:n||A.Coupon,page:o,page_size:r,user_id:e?.user_id},{onSuccess(m){f(m?.data?.total),_(m?.data?.redeem_logs||[])}})},[n,o,r,e?.user_id]);return C(()=>{!t||!e?.user_id||s()},[s,t]),{myRewards:u,isLoading:i,total:p,getMyRewards:s,canNext:p>u.length&&!i}}var P=T;export{P as default};
|
|
2
2
|
//# sourceMappingURL=useMyRewards.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useMyRewards.ts"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { ALPC_COUNTRY_MAP, AlpcConsumeType } from '../const'\nimport { useAlpcMutation } from './useAlpcFetch'\nimport type { RedeemLogResponse } from '../response'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useMyRewards({\n page,\n pageSize,\n consumeType,\n}: {\n page: number\n pageSize: number\n consumeType?: AlpcConsumeType\n}) {\n const { profile, alpcBrand } = useCreditsContext()\n const { brand: headlessBrand, locale, appName } = useHeadlessContext()\n const brand = alpcBrand || headlessBrand\n\n const [myRewards, setMyRewards] = useState<RedeemLogResponse[]>([])\n const [total, setTotal] = useState(0)\n\n const { isMutating: isLoading, trigger } = useAlpcMutation<\n { redeem_logs: RedeemLogResponse[]; total: number },\n {\n page: number\n page_size: number\n consume_type: AlpcConsumeType\n user_id: string\n }\n >({\n url: `/v1/credit/log/coupon`,\n initData: {\n brand: brand,\n country: ALPC_COUNTRY_MAP.get(locale) || locale,\n app_name: appName,\n },\n })\n\n const getMyRewards = useCallback(async () => {\n if (!profile?.user_id) {\n return\n }\n await trigger(\n {\n consume_type: consumeType || AlpcConsumeType.Coupon,\n page,\n page_size: pageSize,\n user_id: profile?.user_id,\n },\n {\n onSuccess(responseData) {\n setTotal(responseData?.total)\n setMyRewards(responseData?.redeem_logs || [])\n },\n }\n )\n }, [consumeType, page, pageSize, profile?.user_id])\n\n useEffect(() => {\n if (!brand || !profile?.user_id) {\n return\n }\n getMyRewards()\n }, [getMyRewards, brand])\n\n return {\n myRewards,\n isLoading,\n total,\n getMyRewards,\n canNext: total > myRewards.length && !isLoading,\n }\n}\n\nexport default useMyRewards\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QAEjD,OAAS,oBAAAC,EAAkB,mBAAAC,MAAuB,WAClD,OAAS,mBAAAC,MAAuB,iBAEhC,OAAS,qBAAAC,MAAyB,cAClC,OAAS,sBAAAC,MAA0B,gBAEnC,SAASC,EAAa,CACpB,KAAAC,EACA,SAAAC,EACA,YAAAC,CACF,EAIG,CACD,KAAM,CAAE,QAAAC,EAAS,UAAAC,CAAU,EAAIP,EAAkB,EAC3C,CAAE,MAAOQ,EAAe,OAAAC,EAAQ,QAAAC,CAAQ,EAAIT,EAAmB,EAC/DU,EAAQJ,GAAaC,EAErB,CAACI,EAAWC,CAAY,EAAIjB,EAA8B,CAAC,CAAC,EAC5D,CAACkB,EAAOC,CAAQ,EAAInB,EAAS,CAAC,EAE9B,CAAE,WAAYoB,EAAW,QAAAC,CAAQ,EAAIlB,EAQzC,CACA,IAAK,wBACL,SAAU,CACR,MAAOY,EACP,QAASd,EAAiB,IAAIY,CAAM,GAAKA,EACzC,SAAUC,CACZ,CACF,CAAC,EAEKQ,EAAexB,EAAY,SAAY,CACtCY,GAAS,SAGd,MAAMW,EACJ,CACE,aAAcZ,GAAeP,EAAgB,OAC7C,KAAAK,EACA,UAAWC,EACX,QAASE,GAAS,OACpB,EACA,CACE,UAAUa,EAAc,CACtBJ,EAASI,GAAc,KAAK,
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { ALPC_COUNTRY_MAP, AlpcConsumeType } from '../const'\nimport { useAlpcMutation } from './useAlpcFetch'\nimport type { RedeemLogResponse } from '../response'\nimport { useCreditsContext } from '../provider'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useMyRewards({\n page,\n pageSize,\n consumeType,\n}: {\n page: number\n pageSize: number\n consumeType?: AlpcConsumeType\n}) {\n const { profile, alpcBrand } = useCreditsContext()\n const { brand: headlessBrand, locale, appName } = useHeadlessContext()\n const brand = alpcBrand || headlessBrand\n\n const [myRewards, setMyRewards] = useState<RedeemLogResponse[]>([])\n const [total, setTotal] = useState(0)\n\n const { isMutating: isLoading, trigger } = useAlpcMutation<\n { data: { redeem_logs: RedeemLogResponse[]; total: number } },\n {\n page: number\n page_size: number\n consume_type: AlpcConsumeType\n user_id: string\n }\n >({\n url: `/v1/credit/log/coupon`,\n initData: {\n brand: brand,\n country: ALPC_COUNTRY_MAP.get(locale) || locale,\n app_name: appName,\n },\n })\n\n const getMyRewards = useCallback(async () => {\n if (!profile?.user_id) {\n return\n }\n await trigger(\n {\n consume_type: consumeType || AlpcConsumeType.Coupon,\n page,\n page_size: pageSize,\n user_id: profile?.user_id,\n },\n {\n onSuccess(responseData) {\n setTotal(responseData?.data?.total)\n setMyRewards(responseData?.data?.redeem_logs || [])\n },\n }\n )\n }, [consumeType, page, pageSize, profile?.user_id])\n\n useEffect(() => {\n if (!brand || !profile?.user_id) {\n return\n }\n getMyRewards()\n }, [getMyRewards, brand])\n\n return {\n myRewards,\n isLoading,\n total,\n getMyRewards,\n canNext: total > myRewards.length && !isLoading,\n }\n}\n\nexport default useMyRewards\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QAEjD,OAAS,oBAAAC,EAAkB,mBAAAC,MAAuB,WAClD,OAAS,mBAAAC,MAAuB,iBAEhC,OAAS,qBAAAC,MAAyB,cAClC,OAAS,sBAAAC,MAA0B,gBAEnC,SAASC,EAAa,CACpB,KAAAC,EACA,SAAAC,EACA,YAAAC,CACF,EAIG,CACD,KAAM,CAAE,QAAAC,EAAS,UAAAC,CAAU,EAAIP,EAAkB,EAC3C,CAAE,MAAOQ,EAAe,OAAAC,EAAQ,QAAAC,CAAQ,EAAIT,EAAmB,EAC/DU,EAAQJ,GAAaC,EAErB,CAACI,EAAWC,CAAY,EAAIjB,EAA8B,CAAC,CAAC,EAC5D,CAACkB,EAAOC,CAAQ,EAAInB,EAAS,CAAC,EAE9B,CAAE,WAAYoB,EAAW,QAAAC,CAAQ,EAAIlB,EAQzC,CACA,IAAK,wBACL,SAAU,CACR,MAAOY,EACP,QAASd,EAAiB,IAAIY,CAAM,GAAKA,EACzC,SAAUC,CACZ,CACF,CAAC,EAEKQ,EAAexB,EAAY,SAAY,CACtCY,GAAS,SAGd,MAAMW,EACJ,CACE,aAAcZ,GAAeP,EAAgB,OAC7C,KAAAK,EACA,UAAWC,EACX,QAASE,GAAS,OACpB,EACA,CACE,UAAUa,EAAc,CACtBJ,EAASI,GAAc,MAAM,KAAK,EAClCN,EAAaM,GAAc,MAAM,aAAe,CAAC,CAAC,CACpD,CACF,CACF,CACF,EAAG,CAACd,EAAaF,EAAMC,EAAUE,GAAS,OAAO,CAAC,EAElD,OAAAX,EAAU,IAAM,CACV,CAACgB,GAAS,CAACL,GAAS,SAGxBY,EAAa,CACf,EAAG,CAACA,EAAcP,CAAK,CAAC,EAEjB,CACL,UAAAC,EACA,UAAAI,EACA,MAAAF,EACA,aAAAI,EACA,QAASJ,EAAQF,EAAU,QAAU,CAACI,CACxC,CACF,CAEA,IAAOI,EAAQlB",
|
|
6
6
|
"names": ["useCallback", "useEffect", "useState", "ALPC_COUNTRY_MAP", "AlpcConsumeType", "useAlpcMutation", "useCreditsContext", "useHeadlessContext", "useMyRewards", "page", "pageSize", "consumeType", "profile", "alpcBrand", "headlessBrand", "locale", "appName", "brand", "myRewards", "setMyRewards", "total", "setTotal", "isLoading", "trigger", "getMyRewards", "responseData", "useMyRewards_default"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useCallback as y,useEffect as _,useState as g}from"react";import{useAlpcMutation as T}from"./useAlpcFetch";import{ALPC_COUNTRY_MAP as R}from"../const";import{useCreditsContext as L}from"../provider";import{useHeadlessContext as b}from"@anker-in/lib";function A(l){let e="";const{profile:o,isLoadingProfile:n,alpcBrand:m}=L(),{locale:r,brand:p}=b(),s=m||p;r==="pl"?e="eu":e=r;const[a,d]=g([]),{isMutating:C,trigger:u}=T({url:"/v1/credit/consume_credit_rules",initData:{brand:s,page:1,page_size:999,country:(R.get(e)||e)?.toUpperCase()}}),t=y(i=>{u({user_id:o?.user_id,...i?.consumeType&&{consume_type:i.consumeType}},{onSuccess(c){console.log("responseData",c);let f=c?.consume_credit_rules||[];d(f)}})},[o,u,e]);return _(()=>{!s||n||t({consumeType:l?.consumeType})},[t,n,s]),{listLoading:C,redeemableList:a,getRedeemableList:t}}var h=A;export{h as default};
|
|
1
|
+
import{useCallback as y,useEffect as _,useState as g}from"react";import{useAlpcMutation as T}from"./useAlpcFetch";import{ALPC_COUNTRY_MAP as R}from"../const";import{useCreditsContext as L}from"../provider";import{useHeadlessContext as b}from"@anker-in/lib";function A(l){let e="";const{profile:o,isLoadingProfile:n,alpcBrand:m}=L(),{locale:r,brand:p}=b(),s=m||p;r==="pl"?e="eu":e=r;const[a,d]=g([]),{isMutating:C,trigger:u}=T({url:"/v1/credit/consume_credit_rules",initData:{brand:s,page:1,page_size:999,country:(R.get(e)||e)?.toUpperCase()}}),t=y(i=>{u({user_id:o?.user_id,...i?.consumeType&&{consume_type:i.consumeType}},{onSuccess(c){console.log("responseData",c);let f=c?.data?.consume_credit_rules||[];d(f)}})},[o,u,e]);return _(()=>{!s||n||t({consumeType:l?.consumeType})},[t,n,s]),{listLoading:C,redeemableList:a,getRedeemableList:t}}var h=A;export{h as default};
|
|
2
2
|
//# sourceMappingURL=useRedeemableList.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useRedeemableList.ts"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { useAlpcMutation } from './useAlpcFetch'\nimport { ALPC_COUNTRY_MAP, AlpcConsumeType } from '../const'\nimport { useCreditsContext } from '../provider'\nimport type { ConsumeCreditRuleResponse } from '../response'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useRedeemableList(props?: { consumeType: AlpcConsumeType }) {\n let locale = '' as string\n const { profile, isLoadingProfile, alpcBrand } = useCreditsContext()\n const { locale: contextLocale, brand: headlessBrand } = useHeadlessContext()\n const brand = alpcBrand || headlessBrand\n\n if (contextLocale === 'pl') {\n locale = 'eu'\n } else {\n locale = contextLocale\n }\n\n const [redeemableList, setRedeemableList] = useState<ConsumeCreditRuleResponse[]>([])\n const { isMutating: listLoading, trigger } = useAlpcMutation<\n {\n consume_credit_rules: ConsumeCreditRuleResponse[]\n },\n { consume_type?: AlpcConsumeType; user_id?: string }\n >({\n url: `/v1/credit/consume_credit_rules`,\n initData: {\n brand,\n page: 1,\n page_size: 999,\n country: (ALPC_COUNTRY_MAP.get(locale) || locale)?.toUpperCase(),\n },\n })\n\n const getRedeemableList = useCallback(\n (props?: { consumeType?: AlpcConsumeType }) => {\n trigger(\n {\n user_id: profile?.user_id,\n ...(props?.consumeType && { consume_type: props.consumeType }),\n },\n {\n onSuccess(responseData) {\n console.log('responseData', responseData)\n let list = responseData?.consume_credit_rules || []\n setRedeemableList(list)\n },\n }\n )\n },\n [profile, trigger, locale]\n )\n\n useEffect(() => {\n if (!brand || isLoadingProfile) {\n return\n }\n getRedeemableList({ consumeType: props?.consumeType })\n }, [getRedeemableList, isLoadingProfile, brand])\n\n return {\n listLoading,\n redeemableList,\n getRedeemableList,\n }\n}\n\nexport default useRedeemableList\n"],
|
|
5
|
-
"mappings": "AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QAEjD,OAAS,mBAAAC,MAAuB,iBAChC,OAAS,oBAAAC,MAAyC,WAClD,OAAS,qBAAAC,MAAyB,cAElC,OAAS,sBAAAC,MAA0B,gBAEnC,SAASC,EAAkBC,EAA0C,CACnE,IAAIC,EAAS,GACb,KAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,UAAAC,CAAU,EAAIP,EAAkB,EAC7D,CAAE,OAAQQ,EAAe,MAAOC,CAAc,EAAIR,EAAmB,EACrES,EAAQH,GAAaE,EAEvBD,IAAkB,KACpBJ,EAAS,KAETA,EAASI,EAGX,KAAM,CAACG,EAAgBC,CAAiB,EAAIf,EAAsC,CAAC,CAAC,EAC9E,CAAE,WAAYgB,EAAa,QAAAC,CAAQ,EAAIhB,EAK3C,CACA,IAAK,kCACL,SAAU,CACR,MAAAY,EACA,KAAM,EACN,UAAW,IACX,SAAUX,EAAiB,IAAIK,CAAM,GAAKA,IAAS,YAAY,CACjE,CACF,CAAC,EAEKW,EAAoBpB,EACvBQ,GAA8C,CAC7CW,EACE,CACE,QAAST,GAAS,QAClB,GAAIF,GAAO,aAAe,CAAE,aAAcA,EAAM,WAAY,CAC9D,EACA,CACE,UAAUa,EAAc,CACtB,QAAQ,IAAI,eAAgBA,CAAY,EACxC,IAAIC,EAAOD,GAAc,sBAAwB,CAAC,
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useState } from 'react'\n\nimport { useAlpcMutation } from './useAlpcFetch'\nimport { ALPC_COUNTRY_MAP, AlpcConsumeType } from '../const'\nimport { useCreditsContext } from '../provider'\nimport type { ConsumeCreditRuleResponse } from '../response'\nimport { useHeadlessContext } from '@anker-in/lib'\n\nfunction useRedeemableList(props?: { consumeType: AlpcConsumeType }) {\n let locale = '' as string\n const { profile, isLoadingProfile, alpcBrand } = useCreditsContext()\n const { locale: contextLocale, brand: headlessBrand } = useHeadlessContext()\n const brand = alpcBrand || headlessBrand\n\n if (contextLocale === 'pl') {\n locale = 'eu'\n } else {\n locale = contextLocale\n }\n\n const [redeemableList, setRedeemableList] = useState<ConsumeCreditRuleResponse[]>([])\n const { isMutating: listLoading, trigger } = useAlpcMutation<\n {\n data: { consume_credit_rules: ConsumeCreditRuleResponse[] }\n },\n { consume_type?: AlpcConsumeType; user_id?: string }\n >({\n url: `/v1/credit/consume_credit_rules`,\n initData: {\n brand,\n page: 1,\n page_size: 999,\n country: (ALPC_COUNTRY_MAP.get(locale) || locale)?.toUpperCase(),\n },\n })\n\n const getRedeemableList = useCallback(\n (props?: { consumeType?: AlpcConsumeType }) => {\n trigger(\n {\n user_id: profile?.user_id,\n ...(props?.consumeType && { consume_type: props.consumeType }),\n },\n {\n onSuccess(responseData) {\n console.log('responseData', responseData)\n let list = responseData?.data?.consume_credit_rules || []\n setRedeemableList(list)\n },\n }\n )\n },\n [profile, trigger, locale]\n )\n\n useEffect(() => {\n if (!brand || isLoadingProfile) {\n return\n }\n getRedeemableList({ consumeType: props?.consumeType })\n }, [getRedeemableList, isLoadingProfile, brand])\n\n return {\n listLoading,\n redeemableList,\n getRedeemableList,\n }\n}\n\nexport default useRedeemableList\n"],
|
|
5
|
+
"mappings": "AAAA,OAAS,eAAAA,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QAEjD,OAAS,mBAAAC,MAAuB,iBAChC,OAAS,oBAAAC,MAAyC,WAClD,OAAS,qBAAAC,MAAyB,cAElC,OAAS,sBAAAC,MAA0B,gBAEnC,SAASC,EAAkBC,EAA0C,CACnE,IAAIC,EAAS,GACb,KAAM,CAAE,QAAAC,EAAS,iBAAAC,EAAkB,UAAAC,CAAU,EAAIP,EAAkB,EAC7D,CAAE,OAAQQ,EAAe,MAAOC,CAAc,EAAIR,EAAmB,EACrES,EAAQH,GAAaE,EAEvBD,IAAkB,KACpBJ,EAAS,KAETA,EAASI,EAGX,KAAM,CAACG,EAAgBC,CAAiB,EAAIf,EAAsC,CAAC,CAAC,EAC9E,CAAE,WAAYgB,EAAa,QAAAC,CAAQ,EAAIhB,EAK3C,CACA,IAAK,kCACL,SAAU,CACR,MAAAY,EACA,KAAM,EACN,UAAW,IACX,SAAUX,EAAiB,IAAIK,CAAM,GAAKA,IAAS,YAAY,CACjE,CACF,CAAC,EAEKW,EAAoBpB,EACvBQ,GAA8C,CAC7CW,EACE,CACE,QAAST,GAAS,QAClB,GAAIF,GAAO,aAAe,CAAE,aAAcA,EAAM,WAAY,CAC9D,EACA,CACE,UAAUa,EAAc,CACtB,QAAQ,IAAI,eAAgBA,CAAY,EACxC,IAAIC,EAAOD,GAAc,MAAM,sBAAwB,CAAC,EACxDJ,EAAkBK,CAAI,CACxB,CACF,CACF,CACF,EACA,CAACZ,EAASS,EAASV,CAAM,CAC3B,EAEA,OAAAR,EAAU,IAAM,CACV,CAACc,GAASJ,GAGdS,EAAkB,CAAE,YAAaZ,GAAO,WAAY,CAAC,CACvD,EAAG,CAACY,EAAmBT,EAAkBI,CAAK,CAAC,EAExC,CACL,YAAAG,EACA,eAAAF,EACA,kBAAAI,CACF,CACF,CAEA,IAAOG,EAAQhB",
|
|
6
6
|
"names": ["useCallback", "useEffect", "useState", "useAlpcMutation", "ALPC_COUNTRY_MAP", "useCreditsContext", "useHeadlessContext", "useRedeemableList", "props", "locale", "profile", "isLoadingProfile", "alpcBrand", "contextLocale", "headlessBrand", "brand", "redeemableList", "setRedeemableList", "listLoading", "trigger", "getRedeemableList", "responseData", "list", "useRedeemableList_default"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from"swr/mutation";import{useHeadlessContext as d}from"@anker-in/lib";const n=t=>t&&(t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:t),p=()=>{const{locale:t}=d();return o("/api/multipass/mktsrv/v1/credit/upload_third_party_order",async(c,{arg:{orderName:r}})=>{const a=await(await fetch("/api/multipass/mktsrv/v1/credit/upload_third_party_order",{credentials:"include",method:"POST",headers:{"Content-Type":"application/json","current-language":t},body:JSON.stringify({order_name:r})})).json(),e=n(a);return{ok:e?.data?.code===0,code:e?.data?.code??-1}})};export{p as useUploadReceipt};
|
|
2
2
|
//# sourceMappingURL=useUploadReceipt.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../../src/components/credits/context/hooks/useUploadReceipt.tsx"],
|
|
4
|
-
"sourcesContent": ["import useSWRMutation from 'swr/mutation'\nimport { useHeadlessContext } from '@anker-in/lib'\n\n/**\n * \u7EDF\u4E00\u5904\u7406 ALPC \u63A5\u53E3\u8FD4\u56DE\u7684\u6570\u636E\u7ED3\u6784\n * \u517C\u5BB9\u4E00\u5C42 data \u548C\u4E24\u5C42 data \u7684\u573A\u666F\n */\nconst normalizeResponseData = (responseData: any) => {\n if (!responseData) return responseData\n\n // \u5982\u679C responseData.data \u5B58\u5728\u4E14\u662F\u4E00\u4E2A\u5BF9\u8C61\uFF08\u4E0D\u662F\u6570\u7EC4\uFF09\uFF0C\u8BF4\u660E\u662F\u4E24\u5C42 data \u7ED3\u6784\n if (responseData.data && typeof responseData.data === 'object' && !Array.isArray(responseData.data)) {\n return responseData.data\n }\n\n // \u4E00\u5C42 data \u7ED3\u6784\u6216\u5176\u4ED6\u60C5\u51B5\uFF0C\u76F4\u63A5\u8FD4\u56DE\n return responseData\n}\n\nexport const useUploadReceipt = () => {\n const { locale } = useHeadlessContext()\n\n const uploadReceipt = async (\n _: any,\n { arg: { orderName } }: { arg: { orderName: string } }\n ): Promise<{\n ok: boolean\n code: number\n }> => {\n const response = await fetch(`/api/multipass/mktsrv/v1/credit/upload_third_party_order`, {\n credentials: 'include',\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'current-language': locale,\n },\n body: JSON.stringify({\n order_name: orderName,\n }),\n })\n const result = await response.json()\n const normalizedData = normalizeResponseData(result)\n return {\n ok: normalizedData?.code === 0,\n code: normalizedData?.code ?? -1,\n }\n }\n\n return useSWRMutation('/api/multipass/mktsrv/v1/credit/upload_third_party_order', uploadReceipt)\n}\n"],
|
|
5
|
-
"mappings": "AAAA,OAAOA,MAAoB,eAC3B,OAAS,sBAAAC,MAA0B,gBAMnC,MAAMC,EAAyBC,GACxBA,IAGDA,EAAa,MAAQ,OAAOA,EAAa,MAAS,UAAY,CAAC,MAAM,QAAQA,EAAa,IAAI,EACzFA,EAAa,KAIfA,GAGIC,EAAmB,IAAM,CACpC,KAAM,CAAE,OAAAC,CAAO,EAAIJ,EAAmB,EA4BtC,OAAOD,EAAe,2DA1BA,MACpBM,EACA,CAAE,IAAK,CAAE,UAAAC,CAAU,CAAE,IAIjB,CAYJ,MAAMC,EAAS,MAXE,MAAM,MAAM,2DAA4D,CACvF,YAAa,UACb,OAAQ,OACR,QAAS,CACP,eAAgB,mBAChB,mBAAoBH,CACtB,EACA,KAAM,KAAK,UAAU,CACnB,WAAYE,CACd,CAAC,CACH,CAAC,GAC6B,KAAK,EAC7BE,EAAiBP,EAAsBM,CAAM,EACnD,MAAO,CACL,GAAIC,GAAgB,OAAS,
|
|
4
|
+
"sourcesContent": ["import useSWRMutation from 'swr/mutation'\nimport { useHeadlessContext } from '@anker-in/lib'\n\n/**\n * \u7EDF\u4E00\u5904\u7406 ALPC \u63A5\u53E3\u8FD4\u56DE\u7684\u6570\u636E\u7ED3\u6784\n * \u517C\u5BB9\u4E00\u5C42 data \u548C\u4E24\u5C42 data \u7684\u573A\u666F\n */\nconst normalizeResponseData = (responseData: any) => {\n if (!responseData) return responseData\n\n // \u5982\u679C responseData.data \u5B58\u5728\u4E14\u662F\u4E00\u4E2A\u5BF9\u8C61\uFF08\u4E0D\u662F\u6570\u7EC4\uFF09\uFF0C\u8BF4\u660E\u662F\u4E24\u5C42 data \u7ED3\u6784\n if (responseData.data && typeof responseData.data === 'object' && !Array.isArray(responseData.data)) {\n return responseData.data\n }\n\n // \u4E00\u5C42 data \u7ED3\u6784\u6216\u5176\u4ED6\u60C5\u51B5\uFF0C\u76F4\u63A5\u8FD4\u56DE\n return responseData\n}\n\nexport const useUploadReceipt = () => {\n const { locale } = useHeadlessContext()\n\n const uploadReceipt = async (\n _: any,\n { arg: { orderName } }: { arg: { orderName: string } }\n ): Promise<{\n ok: boolean\n code: number\n }> => {\n const response = await fetch(`/api/multipass/mktsrv/v1/credit/upload_third_party_order`, {\n credentials: 'include',\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'current-language': locale,\n },\n body: JSON.stringify({\n order_name: orderName,\n }),\n })\n const result = await response.json()\n const normalizedData = normalizeResponseData(result)\n return {\n ok: normalizedData?.data?.code === 0,\n code: normalizedData?.data?.code ?? -1,\n }\n }\n\n return useSWRMutation('/api/multipass/mktsrv/v1/credit/upload_third_party_order', uploadReceipt)\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAAoB,eAC3B,OAAS,sBAAAC,MAA0B,gBAMnC,MAAMC,EAAyBC,GACxBA,IAGDA,EAAa,MAAQ,OAAOA,EAAa,MAAS,UAAY,CAAC,MAAM,QAAQA,EAAa,IAAI,EACzFA,EAAa,KAIfA,GAGIC,EAAmB,IAAM,CACpC,KAAM,CAAE,OAAAC,CAAO,EAAIJ,EAAmB,EA4BtC,OAAOD,EAAe,2DA1BA,MACpBM,EACA,CAAE,IAAK,CAAE,UAAAC,CAAU,CAAE,IAIjB,CAYJ,MAAMC,EAAS,MAXE,MAAM,MAAM,2DAA4D,CACvF,YAAa,UACb,OAAQ,OACR,QAAS,CACP,eAAgB,mBAChB,mBAAoBH,CACtB,EACA,KAAM,KAAK,UAAU,CACnB,WAAYE,CACd,CAAC,CACH,CAAC,GAC6B,KAAK,EAC7BE,EAAiBP,EAAsBM,CAAM,EACnD,MAAO,CACL,GAAIC,GAAgB,MAAM,OAAS,EACnC,KAAMA,GAAgB,MAAM,MAAQ,EACtC,CACF,CAE+F,CACjG",
|
|
6
6
|
"names": ["useSWRMutation", "useHeadlessContext", "normalizeResponseData", "responseData", "useUploadReceipt", "locale", "_", "orderName", "result", "normalizedData"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -16,8 +16,10 @@ function useActivities({ page, pageSize, options = {} }: { page: number; pageSiz
|
|
|
16
16
|
|
|
17
17
|
const { isMutating: isLoading, trigger } = useAlpcMutation<
|
|
18
18
|
{
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
data: {
|
|
20
|
+
total: number
|
|
21
|
+
creditLogs: CreditLogResponse[]
|
|
22
|
+
}
|
|
21
23
|
},
|
|
22
24
|
{
|
|
23
25
|
page: number
|
|
@@ -42,8 +44,8 @@ function useActivities({ page, pageSize, options = {} }: { page: number; pageSiz
|
|
|
42
44
|
trigger(params, {
|
|
43
45
|
onSuccess(responseData) {
|
|
44
46
|
setCurrentPage(page)
|
|
45
|
-
setTotal(responseData?.total)
|
|
46
|
-
setActivities(activities.concat(responseData?.creditLogs || []))
|
|
47
|
+
setTotal(responseData?.data?.total)
|
|
48
|
+
setActivities(activities.concat(responseData?.data?.creditLogs || []))
|
|
47
49
|
},
|
|
48
50
|
})
|
|
49
51
|
}, [activities, profile, page, pageSize, options, trigger])
|
|
@@ -23,7 +23,7 @@ function useMyRewards({
|
|
|
23
23
|
const [total, setTotal] = useState(0)
|
|
24
24
|
|
|
25
25
|
const { isMutating: isLoading, trigger } = useAlpcMutation<
|
|
26
|
-
{ redeem_logs: RedeemLogResponse[]; total: number },
|
|
26
|
+
{ data: { redeem_logs: RedeemLogResponse[]; total: number } },
|
|
27
27
|
{
|
|
28
28
|
page: number
|
|
29
29
|
page_size: number
|
|
@@ -52,8 +52,8 @@ function useMyRewards({
|
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
onSuccess(responseData) {
|
|
55
|
-
setTotal(responseData?.total)
|
|
56
|
-
setMyRewards(responseData?.redeem_logs || [])
|
|
55
|
+
setTotal(responseData?.data?.total)
|
|
56
|
+
setMyRewards(responseData?.data?.redeem_logs || [])
|
|
57
57
|
},
|
|
58
58
|
}
|
|
59
59
|
)
|
|
@@ -21,7 +21,7 @@ function useRedeemableList(props?: { consumeType: AlpcConsumeType }) {
|
|
|
21
21
|
const [redeemableList, setRedeemableList] = useState<ConsumeCreditRuleResponse[]>([])
|
|
22
22
|
const { isMutating: listLoading, trigger } = useAlpcMutation<
|
|
23
23
|
{
|
|
24
|
-
consume_credit_rules: ConsumeCreditRuleResponse[]
|
|
24
|
+
data: { consume_credit_rules: ConsumeCreditRuleResponse[] }
|
|
25
25
|
},
|
|
26
26
|
{ consume_type?: AlpcConsumeType; user_id?: string }
|
|
27
27
|
>({
|
|
@@ -44,7 +44,7 @@ function useRedeemableList(props?: { consumeType: AlpcConsumeType }) {
|
|
|
44
44
|
{
|
|
45
45
|
onSuccess(responseData) {
|
|
46
46
|
console.log('responseData', responseData)
|
|
47
|
-
let list = responseData?.consume_credit_rules || []
|
|
47
|
+
let list = responseData?.data?.consume_credit_rules || []
|
|
48
48
|
setRedeemableList(list)
|
|
49
49
|
},
|
|
50
50
|
}
|
|
@@ -41,8 +41,8 @@ export const useUploadReceipt = () => {
|
|
|
41
41
|
const result = await response.json()
|
|
42
42
|
const normalizedData = normalizeResponseData(result)
|
|
43
43
|
return {
|
|
44
|
-
ok: normalizedData?.code === 0,
|
|
45
|
-
code: normalizedData?.code ?? -1,
|
|
44
|
+
ok: normalizedData?.data?.code === 0,
|
|
45
|
+
code: normalizedData?.data?.code ?? -1,
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|