@dutchiesdk/ecommerce-extensions-sdk 0.11.0 → 0.12.1
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/context/ecommerce-data-bridge.cjs +5 -4
- package/dist/context/ecommerce-data-bridge.d.ts +2 -1
- package/dist/esm/context/ecommerce-data-bridge.d.ts +2 -1
- package/dist/esm/context/ecommerce-data-bridge.js +5 -4
- package/dist/esm/types/actions.d.ts +4 -6
- package/dist/esm/types/data.d.ts +2 -0
- package/dist/types/actions.d.ts +4 -6
- package/dist/types/data.d.ts +2 -0
- package/package.json +1 -1
|
@@ -30,19 +30,20 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
30
30
|
useDataBridge: ()=>useDataBridge
|
|
31
31
|
});
|
|
32
32
|
const external_react_namespaceObject = require("react");
|
|
33
|
-
const DataBridgeVersion = '0.
|
|
33
|
+
const DataBridgeVersion = '0.12.1';
|
|
34
34
|
const DataBridgeContext = (0, external_react_namespaceObject.createContext)(void 0);
|
|
35
35
|
const useDataBridge = ()=>{
|
|
36
36
|
const context = (0, external_react_namespaceObject.useContext)(DataBridgeContext);
|
|
37
37
|
if (void 0 === context) throw new Error('useDataBridge must be used within a DataBridgeProvider');
|
|
38
38
|
return context;
|
|
39
39
|
};
|
|
40
|
-
const useAsyncLoader = (fn)=>{
|
|
40
|
+
const useAsyncLoader = (fn, params)=>{
|
|
41
41
|
const [data, setData] = (0, external_react_namespaceObject.useState)(null);
|
|
42
42
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
43
|
-
fn().then(setData);
|
|
43
|
+
fn(params).then(setData);
|
|
44
44
|
}, [
|
|
45
|
-
fn
|
|
45
|
+
fn,
|
|
46
|
+
params
|
|
46
47
|
]);
|
|
47
48
|
return {
|
|
48
49
|
data,
|
|
@@ -23,9 +23,10 @@ export declare const useDataBridge: () => CommerceComponentsDataInterface;
|
|
|
23
23
|
* A hook to load data asynchronously.
|
|
24
24
|
*
|
|
25
25
|
* @param fn - The function to load the data.
|
|
26
|
+
* @param params - Optional parameters to pass to the function.
|
|
26
27
|
* @returns The data and a boolean indicating if the data is loading.
|
|
27
28
|
*/
|
|
28
|
-
export declare const useAsyncLoader: <S>(fn: () => Promise<S
|
|
29
|
+
export declare const useAsyncLoader: <S, P = void>(fn: (params: P) => Promise<S>, params?: P) => {
|
|
29
30
|
data: S | null;
|
|
30
31
|
isLoading: boolean;
|
|
31
32
|
};
|
|
@@ -23,9 +23,10 @@ export declare const useDataBridge: () => CommerceComponentsDataInterface;
|
|
|
23
23
|
* A hook to load data asynchronously.
|
|
24
24
|
*
|
|
25
25
|
* @param fn - The function to load the data.
|
|
26
|
+
* @param params - Optional parameters to pass to the function.
|
|
26
27
|
* @returns The data and a boolean indicating if the data is loading.
|
|
27
28
|
*/
|
|
28
|
-
export declare const useAsyncLoader: <S>(fn: () => Promise<S
|
|
29
|
+
export declare const useAsyncLoader: <S, P = void>(fn: (params: P) => Promise<S>, params?: P) => {
|
|
29
30
|
data: S | null;
|
|
30
31
|
isLoading: boolean;
|
|
31
32
|
};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { createContext, useContext, useEffect, useState } from "react";
|
|
2
|
-
const DataBridgeVersion = '0.
|
|
2
|
+
const DataBridgeVersion = '0.12.1';
|
|
3
3
|
const DataBridgeContext = createContext(void 0);
|
|
4
4
|
const useDataBridge = ()=>{
|
|
5
5
|
const context = useContext(DataBridgeContext);
|
|
6
6
|
if (void 0 === context) throw new Error('useDataBridge must be used within a DataBridgeProvider');
|
|
7
7
|
return context;
|
|
8
8
|
};
|
|
9
|
-
const useAsyncLoader = (fn)=>{
|
|
9
|
+
const useAsyncLoader = (fn, params)=>{
|
|
10
10
|
const [data, setData] = useState(null);
|
|
11
11
|
useEffect(()=>{
|
|
12
|
-
fn().then(setData);
|
|
12
|
+
fn(params).then(setData);
|
|
13
13
|
}, [
|
|
14
|
-
fn
|
|
14
|
+
fn,
|
|
15
|
+
params
|
|
15
16
|
]);
|
|
16
17
|
return {
|
|
17
18
|
data,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { CartItem } from './data';
|
|
2
|
-
type QueryParameter = string;
|
|
3
2
|
type AdditionalRoutableParameters = {
|
|
4
|
-
query?:
|
|
3
|
+
query?: Record<string, string>;
|
|
5
4
|
};
|
|
6
5
|
type GoToIdOrCnameParameters = {
|
|
7
6
|
cname?: string;
|
|
@@ -15,7 +14,7 @@ type AuthenticationActions = {
|
|
|
15
14
|
/**
|
|
16
15
|
* Navigate to loyalty. Redirects to the homepage if the user is not logged in.
|
|
17
16
|
*/
|
|
18
|
-
goToLoyalty: () => void;
|
|
17
|
+
goToLoyalty: (params?: AdditionalRoutableParameters) => void;
|
|
19
18
|
/**
|
|
20
19
|
* Navigate to registration
|
|
21
20
|
*/
|
|
@@ -37,7 +36,7 @@ type CartActions = {
|
|
|
37
36
|
/**
|
|
38
37
|
* Navigate to checkout
|
|
39
38
|
*/
|
|
40
|
-
goToCheckout: (
|
|
39
|
+
goToCheckout: () => void;
|
|
41
40
|
/**
|
|
42
41
|
* Remove product from cart
|
|
43
42
|
*/
|
|
@@ -114,8 +113,7 @@ type ListPageActions = {
|
|
|
114
113
|
categoryId?: string;
|
|
115
114
|
collectionCname?: string;
|
|
116
115
|
collectionId?: string;
|
|
117
|
-
|
|
118
|
-
}) => void;
|
|
116
|
+
} & AdditionalRoutableParameters) => void;
|
|
119
117
|
};
|
|
120
118
|
type NavigationActions = {
|
|
121
119
|
/**
|
package/dist/esm/types/data.d.ts
CHANGED
|
@@ -51,10 +51,12 @@ export type Dispensary = {
|
|
|
51
51
|
website: string;
|
|
52
52
|
storeFrontRoot: string;
|
|
53
53
|
};
|
|
54
|
+
medDispensary: boolean;
|
|
54
55
|
name: string;
|
|
55
56
|
orderTypes: DispensaryOrderTypes;
|
|
56
57
|
orderTypesConfig: OrderTypesConfig;
|
|
57
58
|
phone: string;
|
|
59
|
+
recDispensary: boolean;
|
|
58
60
|
status: string;
|
|
59
61
|
};
|
|
60
62
|
export type DispensaryAddress = {
|
package/dist/types/actions.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { CartItem } from './data';
|
|
2
|
-
type QueryParameter = string;
|
|
3
2
|
type AdditionalRoutableParameters = {
|
|
4
|
-
query?:
|
|
3
|
+
query?: Record<string, string>;
|
|
5
4
|
};
|
|
6
5
|
type GoToIdOrCnameParameters = {
|
|
7
6
|
cname?: string;
|
|
@@ -15,7 +14,7 @@ type AuthenticationActions = {
|
|
|
15
14
|
/**
|
|
16
15
|
* Navigate to loyalty. Redirects to the homepage if the user is not logged in.
|
|
17
16
|
*/
|
|
18
|
-
goToLoyalty: () => void;
|
|
17
|
+
goToLoyalty: (params?: AdditionalRoutableParameters) => void;
|
|
19
18
|
/**
|
|
20
19
|
* Navigate to registration
|
|
21
20
|
*/
|
|
@@ -37,7 +36,7 @@ type CartActions = {
|
|
|
37
36
|
/**
|
|
38
37
|
* Navigate to checkout
|
|
39
38
|
*/
|
|
40
|
-
goToCheckout: (
|
|
39
|
+
goToCheckout: () => void;
|
|
41
40
|
/**
|
|
42
41
|
* Remove product from cart
|
|
43
42
|
*/
|
|
@@ -114,8 +113,7 @@ type ListPageActions = {
|
|
|
114
113
|
categoryId?: string;
|
|
115
114
|
collectionCname?: string;
|
|
116
115
|
collectionId?: string;
|
|
117
|
-
|
|
118
|
-
}) => void;
|
|
116
|
+
} & AdditionalRoutableParameters) => void;
|
|
119
117
|
};
|
|
120
118
|
type NavigationActions = {
|
|
121
119
|
/**
|
package/dist/types/data.d.ts
CHANGED
|
@@ -51,10 +51,12 @@ export type Dispensary = {
|
|
|
51
51
|
website: string;
|
|
52
52
|
storeFrontRoot: string;
|
|
53
53
|
};
|
|
54
|
+
medDispensary: boolean;
|
|
54
55
|
name: string;
|
|
55
56
|
orderTypes: DispensaryOrderTypes;
|
|
56
57
|
orderTypesConfig: OrderTypesConfig;
|
|
57
58
|
phone: string;
|
|
59
|
+
recDispensary: boolean;
|
|
58
60
|
status: string;
|
|
59
61
|
};
|
|
60
62
|
export type DispensaryAddress = {
|