@redotech/redo-hydrogen 1.0.0 → 1.0.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.
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/redo-checkout-buttons.tsx +2 -2
- package/src/providers/redo-coverage-client.tsx +7 -5
- package/src/types.ts +1 -0
- package/src/utils/security.ts +2 -5
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "@shopify/hydrogen";
|
|
8
8
|
import { useRedoCoverageClient } from "../providers/redo-coverage-client";
|
|
9
9
|
import { CartInfoToEnable, RedoCoverageClient } from "../types";
|
|
10
|
-
import {
|
|
10
|
+
import { REDO_PUBLIC_API_HOSTNAME } from "../utils/security";
|
|
11
11
|
|
|
12
12
|
type CheckoutButtonUIResponse = {
|
|
13
13
|
html: string;
|
|
@@ -25,7 +25,7 @@ const getButtonsToShow = ({
|
|
|
25
25
|
}): Promise<CheckoutButtonUIResponse | null> => {
|
|
26
26
|
return new Promise<CheckoutButtonUIResponse | null>((resolve, reject) => {
|
|
27
27
|
fetch(
|
|
28
|
-
`
|
|
28
|
+
`https://${REDO_PUBLIC_API_HOSTNAME}/v2.2/stores/${storeId}/checkout-buttons-ui`,
|
|
29
29
|
{
|
|
30
30
|
method: "GET",
|
|
31
31
|
headers: {
|
|
@@ -2,7 +2,7 @@ import { useFetcher } from "@remix-run/react";
|
|
|
2
2
|
import { CartReturn } from "@shopify/hydrogen";
|
|
3
3
|
import { createContext, ReactNode, useContext, useEffect, useState } from "react";
|
|
4
4
|
import { CartProductVariantFragment, CartAttributeKey, CartInfoToEnable, RedoContextValue, RedoCoverageClient } from "../types";
|
|
5
|
-
import {
|
|
5
|
+
import { REDO_PUBLIC_API_HOSTNAME } from "../utils/security";
|
|
6
6
|
import { addProductToCartIfNeeded, removeProductFromCartIfNeeded, setCartRedoEnabledAttribute, useFetcherWithPromise } from "../utils/cart";
|
|
7
7
|
|
|
8
8
|
const DEFAULT_REDO_CONTEXT_VALUE: RedoContextValue = {
|
|
@@ -27,7 +27,7 @@ const RedoProvider = ({
|
|
|
27
27
|
const [loading, setLoading] = useState<boolean>(true);
|
|
28
28
|
|
|
29
29
|
useEffect(() => {
|
|
30
|
-
fetch(`
|
|
30
|
+
fetch(`https://${REDO_PUBLIC_API_HOSTNAME}/v2.2/stores/${storeId}/coverage-products`, {
|
|
31
31
|
method: 'POST',
|
|
32
32
|
headers: {
|
|
33
33
|
"Content-Type": "application/json"
|
|
@@ -67,9 +67,8 @@ const RedoProvider = ({
|
|
|
67
67
|
let json = await res.json();
|
|
68
68
|
|
|
69
69
|
setLoading(false);
|
|
70
|
-
|
|
71
|
-
setCartInfoToEnable(json.cartInfoToEnable);
|
|
72
|
-
// setCartInfoToEnable(json.coverageProducts[0].cartInfoToEnable);
|
|
70
|
+
|
|
71
|
+
setCartInfoToEnable(json.coverageProducts[0].cartInfoToEnable);
|
|
73
72
|
})
|
|
74
73
|
}, [cart]);
|
|
75
74
|
|
|
@@ -136,6 +135,9 @@ const useRedoCoverageClient = (): RedoCoverageClient => {
|
|
|
136
135
|
});
|
|
137
136
|
return true;
|
|
138
137
|
},
|
|
138
|
+
get loading() {
|
|
139
|
+
return redoContext.loading;
|
|
140
|
+
},
|
|
139
141
|
get enabled() {
|
|
140
142
|
return redoContext.enabled;
|
|
141
143
|
},
|
package/src/types.ts
CHANGED
|
@@ -10,6 +10,7 @@ type CartAttributeKey = string;
|
|
|
10
10
|
interface RedoCoverageClient {
|
|
11
11
|
enable(): Promise<boolean>;
|
|
12
12
|
disable(): Promise<boolean>;
|
|
13
|
+
get loading(): boolean;
|
|
13
14
|
get enabled(): boolean;
|
|
14
15
|
get price(): number;
|
|
15
16
|
get cartProduct(): CartProductVariantFragment | undefined
|
package/src/utils/security.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
const REDO_PUBLIC_API_HOSTNAME = 'api.getredo.com';
|
|
2
|
-
const REDO_PUBLIC_API_HOSTNAME_LOCAL = 'localhost:8001';
|
|
3
2
|
|
|
4
3
|
const REDO_REQUIRED_HOSTNAMES = [
|
|
5
|
-
REDO_PUBLIC_API_HOSTNAME
|
|
6
|
-
REDO_PUBLIC_API_HOSTNAME_LOCAL
|
|
4
|
+
REDO_PUBLIC_API_HOSTNAME
|
|
7
5
|
];
|
|
8
6
|
|
|
9
7
|
export {
|
|
10
8
|
REDO_REQUIRED_HOSTNAMES,
|
|
11
|
-
REDO_PUBLIC_API_HOSTNAME
|
|
12
|
-
REDO_PUBLIC_API_HOSTNAME_LOCAL,
|
|
9
|
+
REDO_PUBLIC_API_HOSTNAME
|
|
13
10
|
};
|