@perceptimagery/dita-configurator-staging 0.2.0 → 0.2.1000

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.
Files changed (2) hide show
  1. package/dist/index.js +27 -30
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ var __publicField = (obj, key, value) => {
18
18
  return value;
19
19
  };
20
20
  (function() {
21
- var _a;
21
+ var _a, _b;
22
22
  "use strict";
23
23
  class FetcherServiceFactory {
24
24
  constructor(config2) {
@@ -112,7 +112,7 @@ var __publicField = (obj, key, value) => {
112
112
  host: "https://api.sprie.io"
113
113
  };
114
114
  const config$1 = Object.freeze(Config$2);
115
- const version$1 = "0.2.0000";
115
+ const version$1 = "0.2.1000";
116
116
  function modifyLensArr$1(arr, element) {
117
117
  const index = arr.findIndex((e) => e["sku"] === element["sku"]);
118
118
  if (index !== -1) {
@@ -216,21 +216,14 @@ var __publicField = (obj, key, value) => {
216
216
  let formData = {
217
217
  "items": items
218
218
  };
219
- await this.shopifyAPI.Post(formData);
220
- }
221
- // async AddToShopifyCart(item: string, iterator: number){
222
- // setTimeout( async () => {
223
- // console.log(item);
224
- // //splitting the available_ids
225
- // var formContents = item.split('-');
226
- // //[0] returns the variant id to add to cart
227
- // //[1] returns the quantity to add to cart
228
- // const data = 'quantity=' + formContents[1] + '&id=' + formContents[0];
229
- // await this.shopifyAPI.Post(data);
230
- // }, 1000 * iterator);
231
- // //1000 * iterator means this code fires 1 seconds after each iteration which makes sure addition of add to cart is
232
- // //successful
233
- // }
219
+ const responseData = await this.shopifyAPI.Post(formData);
220
+ if (responseData) {
221
+ const cart = await this.shopifyAPI.Get();
222
+ document.querySelector(".header__cart-count").textContent = cart.item_count;
223
+ document.querySelector(".drawer--full").setAttribute("close", "");
224
+ document.querySelector(".mini-cart").setAttribute("open", "");
225
+ }
226
+ }
234
227
  }
235
228
  var ESDKStatus = /* @__PURE__ */ ((ESDKStatus2) => {
236
229
  ESDKStatus2["Init"] = "init";
@@ -51256,7 +51249,8 @@ bool bvhIntersectFirstHit(
51256
51249
  });
51257
51250
  let CustomEventEmitter = _CustomEventEmitter2;
51258
51251
  const ShopifyConfig = {
51259
- cartUrl: ((_a = window.Shopify) == null ? void 0 : _a.routes.root) + "/cart/add.js"
51252
+ getCartUrl: ((_a = window.Shopify) == null ? void 0 : _a.routes.root) + "/cart.js",
51253
+ addToCartUrl: ((_b = window.Shopify) == null ? void 0 : _b.routes.root) + "/cart/add.js"
51260
51254
  };
51261
51255
  const configShopify = Object.freeze(ShopifyConfig);
51262
51256
  class ShopifyServiceFactory {
@@ -51277,23 +51271,25 @@ bool bvhIntersectFirstHit(
51277
51271
  }
51278
51272
  };
51279
51273
  }
51280
- // /**
51281
- // * @description nice and tidy reuqest wrapper
51282
- // * @param {string} url CActual URL
51283
- // * @returns
51284
- // */
51285
- // public async Get<T>(url: RequestInfo) {
51286
- // const response = await fetch(this.config.HOST + url, this.RequestOptions('GET'));
51287
- // const result = await response.json();
51288
- // return result as T;
51289
- // }
51274
+ /**
51275
+ * @description nice and tidy reuqest wrapper
51276
+ * @returns
51277
+ */
51278
+ async Get() {
51279
+ await fetch(this.config.getCartUrl, this.RequestOptions("GET")).then((response) => {
51280
+ const result = response.json();
51281
+ return result;
51282
+ }).catch((e) => {
51283
+ console.error("Error:", e);
51284
+ });
51285
+ }
51290
51286
  /**
51291
51287
  * @description nice and tidy reuqest wrapper
51292
51288
  * @param {object} data body Data
51293
51289
  * @returns
51294
51290
  */
51295
51291
  async Post(data) {
51296
- await fetch(this.config.cartUrl, this.RequestOptions("POST", data || {})).then((response) => {
51292
+ await fetch(this.config.addToCartUrl, this.RequestOptions("POST", data || {})).then((response) => {
51297
51293
  const result = response.json();
51298
51294
  return result;
51299
51295
  }).catch((e) => {
@@ -51311,7 +51307,8 @@ bool bvhIntersectFirstHit(
51311
51307
  STORE_PREFIX: config$1.storePrefix
51312
51308
  };
51313
51309
  const shopifyConfig = {
51314
- cartUrl: configShopify.cartUrl
51310
+ addToCartUrl: configShopify.addToCartUrl,
51311
+ getCartUrl: configShopify.getCartUrl
51315
51312
  };
51316
51313
  class DitaConfiguratorPublicAPI {
51317
51314
  constructor() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perceptimagery/dita-configurator-staging",
3
- "version": "0.2.0000",
3
+ "version": "0.2.1000",
4
4
  "author": "Rohan Satpute <rohan@perceptimagery.com>",
5
5
  "license": "UNLICENSED",
6
6
  "main": "dist/index.js",