@shipengine/react-api 2.1.0 → 2.1.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useGetAccountBillingPlan: () => import("@tanstack/react-query").UseQueryResult<import("packages/shipengine-api/javascript/src/
|
|
1
|
+
export declare const useGetAccountBillingPlan: () => import("@tanstack/react-query").UseQueryResult<import("packages/shipengine-api/javascript/src/account-billing-plan").AccountBillingPlanResponse, import("@shipengine/js-api").CodedError[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @category ShipEngine API Hooks
|
|
3
3
|
* */
|
|
4
|
-
export declare const useUpdateAccountBillingPlan: () => import("@tanstack/react-query").UseMutationResult<import("packages/shipengine-api/javascript/src/
|
|
4
|
+
export declare const useUpdateAccountBillingPlan: () => import("@tanstack/react-query").UseMutationResult<import("packages/shipengine-api/javascript/src/account-billing-plan").UpdateAccountBillingPlanResponse, import("@shipengine/js-api").CodedError[], string, unknown>;
|
package/index.js
CHANGED
|
@@ -15,28 +15,24 @@ const ShipEngine = ({
|
|
|
15
15
|
getToken,
|
|
16
16
|
onApiError
|
|
17
17
|
}) => {
|
|
18
|
+
const [client, setClient] = react.useState();
|
|
18
19
|
const [queryClient] = react.useState(() => new reactQuery.QueryClient());
|
|
19
|
-
|
|
20
|
+
react.useEffect(() => {
|
|
20
21
|
const token = getToken();
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
const commonClientProps = {
|
|
23
|
+
baseURL,
|
|
24
|
+
getToken,
|
|
25
|
+
headers: headers != null ? headers : {},
|
|
26
|
+
onApiError
|
|
27
|
+
};
|
|
28
|
+
if (typeof token === "string") {
|
|
29
|
+
setClient(new jsApi.ShipEngineAPI(token, commonClientProps));
|
|
30
|
+
} else {
|
|
31
|
+
token.then((t) => {
|
|
32
|
+
setClient(new jsApi.ShipEngineAPI(t, commonClientProps));
|
|
27
33
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
new jsApi.ShipEngineAPI(t, {
|
|
31
|
-
baseURL,
|
|
32
|
-
getToken,
|
|
33
|
-
headers: headers != null ? headers : {},
|
|
34
|
-
onApiError
|
|
35
|
-
})
|
|
36
|
-
)
|
|
37
|
-
);
|
|
38
|
-
return void 0;
|
|
39
|
-
});
|
|
34
|
+
}
|
|
35
|
+
}, []);
|
|
40
36
|
if (!client) {
|
|
41
37
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
42
38
|
"div",
|
package/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { QueryClient, QueryClientProvider, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { createContext, useState, useContext } from 'react';
|
|
3
|
+
import { createContext, useState, useEffect, useContext } from 'react';
|
|
4
4
|
import { ShipEngineAPI, SE } from '@shipengine/js-api';
|
|
5
5
|
export * from '@shipengine/js-api';
|
|
6
6
|
|
|
@@ -12,28 +12,24 @@ const ShipEngine = ({
|
|
|
12
12
|
getToken,
|
|
13
13
|
onApiError
|
|
14
14
|
}) => {
|
|
15
|
+
const [client, setClient] = useState();
|
|
15
16
|
const [queryClient] = useState(() => new QueryClient());
|
|
16
|
-
|
|
17
|
+
useEffect(() => {
|
|
17
18
|
const token = getToken();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
const commonClientProps = {
|
|
20
|
+
baseURL,
|
|
21
|
+
getToken,
|
|
22
|
+
headers: headers != null ? headers : {},
|
|
23
|
+
onApiError
|
|
24
|
+
};
|
|
25
|
+
if (typeof token === "string") {
|
|
26
|
+
setClient(new ShipEngineAPI(token, commonClientProps));
|
|
27
|
+
} else {
|
|
28
|
+
token.then((t) => {
|
|
29
|
+
setClient(new ShipEngineAPI(t, commonClientProps));
|
|
24
30
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
new ShipEngineAPI(t, {
|
|
28
|
-
baseURL,
|
|
29
|
-
getToken,
|
|
30
|
-
headers: headers != null ? headers : {},
|
|
31
|
-
onApiError
|
|
32
|
-
})
|
|
33
|
-
)
|
|
34
|
-
);
|
|
35
|
-
return void 0;
|
|
36
|
-
});
|
|
31
|
+
}
|
|
32
|
+
}, []);
|
|
37
33
|
if (!client) {
|
|
38
34
|
return /* @__PURE__ */ jsx(
|
|
39
35
|
"div",
|