@hotwax/dxp-components 1.2.0 → 1.3.0
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/lib/components/Login.d.ts +1 -1
- package/lib/components/Login.js +9 -11
- package/lib/index.d.ts +3 -1
- package/lib/index.js +11 -3
- package/lib/store/auth.js +2 -1
- package/lib/store/productIdentification.js +4 -4
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
declare const _default: import("vue").DefineComponent<{}, {}, {
|
|
2
2
|
errorMsg: string;
|
|
3
|
+
authStore: any;
|
|
3
4
|
router: any;
|
|
4
5
|
route: any;
|
|
5
|
-
authStore: any;
|
|
6
6
|
}, {}, {
|
|
7
7
|
handleUserFlow(token: string, oms: string, expirationTime: string): Promise<void>;
|
|
8
8
|
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
package/lib/components/Login.js
CHANGED
|
@@ -17,17 +17,15 @@ var _default = (0, _vue.defineComponent)({
|
|
|
17
17
|
data() {
|
|
18
18
|
return {
|
|
19
19
|
errorMsg: '',
|
|
20
|
+
authStore: {},
|
|
20
21
|
router: {},
|
|
21
|
-
route: {}
|
|
22
|
-
authStore: {}
|
|
22
|
+
route: {}
|
|
23
23
|
};
|
|
24
24
|
},
|
|
25
25
|
async mounted() {
|
|
26
|
-
// exporting the same from index.ts through globalProperties does not work as expected
|
|
27
|
-
const instance = (0, _vue.getCurrentInstance)();
|
|
28
|
-
this.route = instance.appContext.config.globalProperties.$route;
|
|
29
|
-
this.router = instance.appContext.config.globalProperties.$router;
|
|
30
26
|
this.authStore = (0, _index.useAuthStore)();
|
|
27
|
+
this.router = _index.appContext.config.globalProperties.$router;
|
|
28
|
+
this.route = _index.appContext.config.globalProperties.$route;
|
|
31
29
|
if (!Object.keys(this.route.query).length) {
|
|
32
30
|
this.errorMsg = 'Unable to login. Could not authenticate the user';
|
|
33
31
|
return;
|
|
@@ -41,7 +39,7 @@ var _default = (0, _vue.defineComponent)({
|
|
|
41
39
|
const appOms = this.authStore.oms;
|
|
42
40
|
const appExpirationTime = this.authStore.token.expiration;
|
|
43
41
|
|
|
44
|
-
// show alert if token/oms are different from the app's
|
|
42
|
+
// show alert if token/oms exist and are different from the app's
|
|
45
43
|
if (appToken && token && (appToken != token || appOms != oms)) {
|
|
46
44
|
// for backward compatibility
|
|
47
45
|
this.authStore.$patch({
|
|
@@ -51,9 +49,11 @@ var _default = (0, _vue.defineComponent)({
|
|
|
51
49
|
},
|
|
52
50
|
oms: appOms
|
|
53
51
|
});
|
|
54
|
-
|
|
52
|
+
_index.loginContext.confirmSessionEnd('dev-oms').then(isConfirmed => {
|
|
55
53
|
isConfirmed ? this.handleUserFlow(token, oms, expirationTime) : this.router.push('/');
|
|
56
54
|
});
|
|
55
|
+
} else {
|
|
56
|
+
this.handleUserFlow(token, oms, expirationTime);
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
methods: {
|
|
@@ -75,9 +75,7 @@ var _default = (0, _vue.defineComponent)({
|
|
|
75
75
|
token,
|
|
76
76
|
oms
|
|
77
77
|
});
|
|
78
|
-
this.router.
|
|
79
|
-
path: '/'
|
|
80
|
-
});
|
|
78
|
+
this.router.push('/');
|
|
81
79
|
} catch (error) {
|
|
82
80
|
console.error(error);
|
|
83
81
|
this.errorMsg = 'Unable to login. Please contact the administrator';
|
package/lib/index.d.ts
CHANGED
|
@@ -5,7 +5,9 @@ import ShopifyImg from "./components/ShopifyImg";
|
|
|
5
5
|
import { goToOms } from "./utils";
|
|
6
6
|
declare let loginContext: any;
|
|
7
7
|
declare let shopifyImgContext: any;
|
|
8
|
+
declare let appContext: any;
|
|
9
|
+
declare let productIdentificationContext: any;
|
|
8
10
|
export declare let dxpComponents: {
|
|
9
11
|
install(app: any, options: any): void;
|
|
10
12
|
};
|
|
11
|
-
export { useProductIdentificationStore, useAuthStore, Login, loginContext, shopifyImgContext, ShopifyImg, goToOms };
|
|
13
|
+
export { useProductIdentificationStore, useAuthStore, Login, loginContext, shopifyImgContext, ShopifyImg, goToOms, appContext, productIdentificationContext };
|
package/lib/index.js
CHANGED
|
@@ -15,14 +15,14 @@ Object.defineProperty(exports, "ShopifyImg", {
|
|
|
15
15
|
return _ShopifyImg.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
exports.dxpComponents = void 0;
|
|
18
|
+
exports.dxpComponents = exports.appContext = void 0;
|
|
19
19
|
Object.defineProperty(exports, "goToOms", {
|
|
20
20
|
enumerable: true,
|
|
21
21
|
get: function () {
|
|
22
22
|
return _utils.goToOms;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
exports.shopifyImgContext = exports.loginContext = void 0;
|
|
25
|
+
exports.shopifyImgContext = exports.productIdentificationContext = exports.loginContext = void 0;
|
|
26
26
|
Object.defineProperty(exports, "useAuthStore", {
|
|
27
27
|
enumerable: true,
|
|
28
28
|
get: function () {
|
|
@@ -50,11 +50,17 @@ pinia.use(_piniaPluginPersistedstate.default);
|
|
|
50
50
|
let loginContext = {};
|
|
51
51
|
exports.loginContext = loginContext;
|
|
52
52
|
let shopifyImgContext = {};
|
|
53
|
+
exports.shopifyImgContext = shopifyImgContext;
|
|
54
|
+
let appContext = {};
|
|
55
|
+
exports.appContext = appContext;
|
|
56
|
+
let productIdentificationContext = {};
|
|
53
57
|
|
|
54
58
|
// executed on app initialization
|
|
55
|
-
exports.
|
|
59
|
+
exports.productIdentificationContext = productIdentificationContext;
|
|
56
60
|
let dxpComponents = {
|
|
57
61
|
install(app, options) {
|
|
62
|
+
exports.appContext = appContext = app;
|
|
63
|
+
|
|
58
64
|
// registering pinia in the app
|
|
59
65
|
app.use(pinia);
|
|
60
66
|
app.component('Login', _Login.default);
|
|
@@ -64,6 +70,8 @@ let dxpComponents = {
|
|
|
64
70
|
loginContext.logout = options.logout;
|
|
65
71
|
loginContext.loader = options.loader;
|
|
66
72
|
shopifyImgContext.defaultImgUrl = options.defaultImgUrl;
|
|
73
|
+
productIdentificationContext.getProductIdentificationPref = options.getProductIdentificationPref;
|
|
74
|
+
productIdentificationContext.setProductIdentificationPref = options.setProductIdentificationPref;
|
|
67
75
|
}
|
|
68
76
|
};
|
|
69
77
|
exports.dxpComponents = dxpComponents;
|
package/lib/store/auth.js
CHANGED
|
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.useProductIdentificationStore = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _index = require("../index");
|
|
8
8
|
var _pinia = require("pinia");
|
|
9
9
|
const useProductIdentificationStore = (0, _pinia.defineStore)('productIdentification', {
|
|
10
10
|
state: () => {
|
|
11
11
|
return {
|
|
12
12
|
productIdentificationPref: {
|
|
13
|
-
primaryId: '
|
|
13
|
+
primaryId: '',
|
|
14
14
|
secondaryId: ''
|
|
15
15
|
},
|
|
16
16
|
productIdentificationOptions: ["productId", "groupId", "groupName", "internalName", "parentProductName", "primaryProductCategoryName", "productId", "sku", "title", "SHOPIFY_PROD_SKU"]
|
|
@@ -31,7 +31,7 @@ const useProductIdentificationStore = (0, _pinia.defineStore)('productIdentifica
|
|
|
31
31
|
}
|
|
32
32
|
productIdentificationPref[id] = value;
|
|
33
33
|
try {
|
|
34
|
-
this.productIdentificationPref = await
|
|
34
|
+
this.productIdentificationPref = await _index.productIdentificationContext.setProductIdentificationPref(eComStoreId, productIdentificationPref);
|
|
35
35
|
} catch (err) {
|
|
36
36
|
console.log('error', err);
|
|
37
37
|
}
|
|
@@ -44,7 +44,7 @@ const useProductIdentificationStore = (0, _pinia.defineStore)('productIdentifica
|
|
|
44
44
|
secondaryId: ''
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
this.productIdentificationPref = await
|
|
47
|
+
this.productIdentificationPref = await _index.productIdentificationContext.getProductIdentificationPref(eComStoreId);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
});
|