@hotwax/dxp-components 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/lib/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { useProductIdentificationStore } from "./store/productIdentification";
2
+ export declare let dxpComponents: {
3
+ install(app: any): void;
4
+ };
5
+ export { useProductIdentificationStore };
package/lib/index.js ADDED
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.dxpComponents = void 0;
7
+ Object.defineProperty(exports, "useProductIdentificationStore", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _productIdentification.useProductIdentificationStore;
11
+ }
12
+ });
13
+ var _pinia = require("pinia");
14
+ var _productIdentification = require("./store/productIdentification");
15
+ // TODO: handle cases when the store from app or pinia store are not available
16
+ // creating a pinia store for the plugin
17
+ const pinia = (0, _pinia.createPinia)();
18
+
19
+ // executed on app initialization
20
+ let dxpComponents = {
21
+ install(app) {
22
+ // registering pinia in the app
23
+ app.use(pinia);
24
+ }
25
+ };
26
+ exports.dxpComponents = dxpComponents;
@@ -0,0 +1,43 @@
1
+ export declare const useProductIdentificationStore: import("pinia").StoreDefinition<"productIdentification", {
2
+ productIdentificationPref: {
3
+ primaryId: string;
4
+ secondaryId: string;
5
+ };
6
+ productIdentificationOptions: string[];
7
+ }, {
8
+ getProductIdentificationPref: (state: {
9
+ productIdentificationPref: {
10
+ primaryId: string;
11
+ secondaryId: string;
12
+ };
13
+ productIdentificationOptions: string[];
14
+ } & import("pinia").PiniaCustomStateProperties<{
15
+ productIdentificationPref: {
16
+ primaryId: string;
17
+ secondaryId: string;
18
+ };
19
+ productIdentificationOptions: string[];
20
+ }>) => {
21
+ primaryId: string;
22
+ secondaryId: string;
23
+ };
24
+ getProductIdentificationOptions: (state: {
25
+ productIdentificationPref: {
26
+ primaryId: string;
27
+ secondaryId: string;
28
+ };
29
+ productIdentificationOptions: string[];
30
+ } & import("pinia").PiniaCustomStateProperties<{
31
+ productIdentificationPref: {
32
+ primaryId: string;
33
+ secondaryId: string;
34
+ };
35
+ productIdentificationOptions: string[];
36
+ }>) => string[];
37
+ }, {
38
+ setProductIdentificationPref(id: string, value: string, eComStoreId: string): Promise<void>;
39
+ getIdentificationPref(eComStoreId: string): Promise<{
40
+ primaryId: string;
41
+ secondaryId: string;
42
+ } | undefined>;
43
+ }>;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useProductIdentificationStore = void 0;
7
+ var _omsApi = require("@hotwax/oms-api");
8
+ var _pinia = require("pinia");
9
+ const useProductIdentificationStore = (0, _pinia.defineStore)('productIdentification', {
10
+ state: () => {
11
+ return {
12
+ productIdentificationPref: {
13
+ primaryId: 'productId',
14
+ secondaryId: ''
15
+ },
16
+ productIdentificationOptions: ["productId", "groupId", "groupName", "internalName", "parentProductName", "primaryProductCategoryName", "productId", "sku", "title", "SHOPIFY_PROD_SKU"]
17
+ };
18
+ },
19
+ getters: {
20
+ getProductIdentificationPref: state => state.productIdentificationPref,
21
+ getProductIdentificationOptions: state => state.productIdentificationOptions
22
+ },
23
+ actions: {
24
+ async setProductIdentificationPref(id, value, eComStoreId) {
25
+ const productIdentificationPref = JSON.parse(JSON.stringify(this.getProductIdentificationPref));
26
+
27
+ // When eComStoreId is not available then make the values change to what selected previously
28
+ if (!eComStoreId) {
29
+ this.productIdentificationPref = productIdentificationPref;
30
+ return;
31
+ }
32
+ productIdentificationPref[id] = value;
33
+ try {
34
+ this.productIdentificationPref = await (0, _omsApi.setProductIdentificationPref)(eComStoreId, productIdentificationPref);
35
+ } catch (err) {
36
+ console.log('error', err);
37
+ }
38
+ },
39
+ async getIdentificationPref(eComStoreId) {
40
+ // when selecting none as ecom store, not fetching the pref as it returns all the entries with the pref id
41
+ if (!eComStoreId) {
42
+ return this.productIdentificationPref = {
43
+ primaryId: 'productId',
44
+ secondaryId: ''
45
+ };
46
+ }
47
+ this.productIdentificationPref = await (0, _omsApi.getProductIdentificationPref)(eComStoreId);
48
+ }
49
+ }
50
+ });
51
+ exports.useProductIdentificationStore = useProductIdentificationStore;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotwax/dxp-components",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",