@anker-in/campaign-ui 0.5.20 → 0.5.21
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/useUploadReceipt.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useUploadReceipt.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/useUploadReceipt.tsx +2 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var l=Object.create;var a=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var r in t)a(e,r,{get:t[r],enumerable:!0})},s=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of y(t))!f.call(e,o)&&o!==r&&a(e,o,{get:()=>t[o],enumerable:!(n=m(t,o))||n.enumerable});return e};var h=(e,t,r)=>(r=e!=null?l(_(e)):{},s(t||!e||!e.__esModule?a(r,"default",{value:e,enumerable:!0}):r,e)),k=e=>s(a({},"__esModule",{value:!0}),e);var R={};g(R,{useUploadReceipt:()=>C});module.exports=k(R);var d=h(require("swr/mutation")),c=require("../../../../lib"),u=require("../provider");const v=e=>e&&(e.data?e.data:e),C=()=>{const{locale:e}=(0,c.useHeadlessContext)(),{apiBaseUrl:t}=(0,u.useCreditsContext)(),r=async(n,{arg:{orderName:o}})=>{const p=await(await fetch(`${t||""}/api/multipass/mktsrv/v1/credit/upload_third_party_order`,{credentials:"include",method:"POST",headers:{"Content-Type":"application/json","current-language":e},body:JSON.stringify({order_name:o})})).json(),i=v(p);return{ok:i?.code===0,code:i?.code??-1}};return(0,d.default)(`${t||""}/api/multipass/mktsrv/v1/credit/upload_third_party_order`,r)};
|
|
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 '../../../../lib'\nimport { useCreditsContext } from '../provider'\n\nconst normalizeResponseData = (responseData: any) => {\n if (!responseData) return responseData\n\n if (
|
|
5
|
-
"mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA2B,2BAC3BC,EAAmC,2BACnCC,EAAkC,uBAElC,MAAMC,EAAyBC,GACxBA,
|
|
4
|
+
"sourcesContent": ["import useSWRMutation from 'swr/mutation'\nimport { useHeadlessContext } from '../../../../lib'\nimport { useCreditsContext } from '../provider'\n\nconst normalizeResponseData = (responseData: any) => {\n if (!responseData) return responseData\n\n // \u517C\u5BB9\u90E8\u5206\u4ED3\u5E93\u7684\u4EE3\u7801\u4F1A\u5BF9\u8FD4\u56DE\u8FDB\u884C\u5C01\u88C5\n if (responseData.data) {\n return responseData.data\n }\n return responseData\n}\n\nexport const useUploadReceipt = () => {\n const { locale } = useHeadlessContext()\n const { apiBaseUrl } = useCreditsContext()\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(`${apiBaseUrl || ''}/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(`${apiBaseUrl || ''}/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,2BACnCC,EAAkC,uBAElC,MAAMC,EAAyBC,GACxBA,IAGDA,EAAa,KACRA,EAAa,KAEfA,GAGIN,EAAmB,IAAM,CACpC,KAAM,CAAE,OAAAO,CAAO,KAAI,sBAAmB,EAChC,CAAE,WAAAC,CAAW,KAAI,qBAAkB,EAEnCC,EAAgB,MACpBC,EACA,CAAE,IAAK,CAAE,UAAAC,CAAU,CAAE,IAIjB,CAYJ,MAAMC,EAAS,MAXE,MAAM,MAAM,GAAGJ,GAAc,EAAE,2DAA4D,CAC1G,YAAa,UACb,OAAQ,OACR,QAAS,CACP,eAAgB,mBAChB,mBAAoBD,CACtB,EACA,KAAM,KAAK,UAAU,CACnB,WAAYI,CACd,CAAC,CACH,CAAC,GAC6B,KAAK,EAC7BE,EAAiBR,EAAsBO,CAAM,EACnD,MAAO,CACL,GAAIC,GAAgB,OAAS,EAC7B,KAAMA,GAAgB,MAAQ,EAChC,CACF,EAEA,SAAO,EAAAC,SAAe,GAAGN,GAAc,EAAE,2DAA4DC,CAAa,CACpH",
|
|
6
6
|
"names": ["useUploadReceipt_exports", "__export", "useUploadReceipt", "__toCommonJS", "import_mutation", "import_lib", "import_provider", "normalizeResponseData", "responseData", "locale", "apiBaseUrl", "uploadReceipt", "_", "orderName", "result", "normalizedData", "useSWRMutation"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import i from"swr/mutation";import{useHeadlessContext as
|
|
1
|
+
import i from"swr/mutation";import{useHeadlessContext as s}from"../../../../lib";import{useCreditsContext as d}from"../provider";const c=e=>e&&(e.data?e.data:e),_=()=>{const{locale:e}=s(),{apiBaseUrl:t}=d(),o=async(u,{arg:{orderName:a}})=>{const n=await(await fetch(`${t||""}/api/multipass/mktsrv/v1/credit/upload_third_party_order`,{credentials:"include",method:"POST",headers:{"Content-Type":"application/json","current-language":e},body:JSON.stringify({order_name:a})})).json(),r=c(n);return{ok:r?.code===0,code:r?.code??-1}};return i(`${t||""}/api/multipass/mktsrv/v1/credit/upload_third_party_order`,o)};export{_ 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 '../../../../lib'\nimport { useCreditsContext } from '../provider'\n\nconst normalizeResponseData = (responseData: any) => {\n if (!responseData) return responseData\n\n if (
|
|
5
|
-
"mappings": "AAAA,OAAOA,MAAoB,eAC3B,OAAS,sBAAAC,MAA0B,kBACnC,OAAS,qBAAAC,MAAyB,cAElC,MAAMC,EAAyBC,GACxBA,
|
|
4
|
+
"sourcesContent": ["import useSWRMutation from 'swr/mutation'\nimport { useHeadlessContext } from '../../../../lib'\nimport { useCreditsContext } from '../provider'\n\nconst normalizeResponseData = (responseData: any) => {\n if (!responseData) return responseData\n\n // \u517C\u5BB9\u90E8\u5206\u4ED3\u5E93\u7684\u4EE3\u7801\u4F1A\u5BF9\u8FD4\u56DE\u8FDB\u884C\u5C01\u88C5\n if (responseData.data) {\n return responseData.data\n }\n return responseData\n}\n\nexport const useUploadReceipt = () => {\n const { locale } = useHeadlessContext()\n const { apiBaseUrl } = useCreditsContext()\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(`${apiBaseUrl || ''}/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(`${apiBaseUrl || ''}/api/multipass/mktsrv/v1/credit/upload_third_party_order`, uploadReceipt)\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAAoB,eAC3B,OAAS,sBAAAC,MAA0B,kBACnC,OAAS,qBAAAC,MAAyB,cAElC,MAAMC,EAAyBC,GACxBA,IAGDA,EAAa,KACRA,EAAa,KAEfA,GAGIC,EAAmB,IAAM,CACpC,KAAM,CAAE,OAAAC,CAAO,EAAIL,EAAmB,EAChC,CAAE,WAAAM,CAAW,EAAIL,EAAkB,EAEnCM,EAAgB,MACpBC,EACA,CAAE,IAAK,CAAE,UAAAC,CAAU,CAAE,IAIjB,CAYJ,MAAMC,EAAS,MAXE,MAAM,MAAM,GAAGJ,GAAc,EAAE,2DAA4D,CAC1G,YAAa,UACb,OAAQ,OACR,QAAS,CACP,eAAgB,mBAChB,mBAAoBD,CACtB,EACA,KAAM,KAAK,UAAU,CACnB,WAAYI,CACd,CAAC,CACH,CAAC,GAC6B,KAAK,EAC7BE,EAAiBT,EAAsBQ,CAAM,EACnD,MAAO,CACL,GAAIC,GAAgB,OAAS,EAC7B,KAAMA,GAAgB,MAAQ,EAChC,CACF,EAEA,OAAOZ,EAAe,GAAGO,GAAc,EAAE,2DAA4DC,CAAa,CACpH",
|
|
6
6
|
"names": ["useSWRMutation", "useHeadlessContext", "useCreditsContext", "normalizeResponseData", "responseData", "useUploadReceipt", "locale", "apiBaseUrl", "uploadReceipt", "_", "orderName", "result", "normalizedData"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -5,11 +5,10 @@ import { useCreditsContext } from '../provider'
|
|
|
5
5
|
const normalizeResponseData = (responseData: any) => {
|
|
6
6
|
if (!responseData) return responseData
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// 兼容部分仓库的代码会对返回进行封装
|
|
9
|
+
if (responseData.data) {
|
|
9
10
|
return responseData.data
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
// 一层结构,直接返回
|
|
13
12
|
return responseData
|
|
14
13
|
}
|
|
15
14
|
|