@ikas/storefront 0.0.165 → 0.0.166-alpha.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.
@@ -5,7 +5,7 @@ export declare class Analytics {
5
5
  constructor();
6
6
  static pageView(url: string): void;
7
7
  static productView(productDetail: IkasProductDetail): void;
8
- static addToCart(item: IkasProductDetail | IkasOrderLineItem, quantity: number, eventId: string): void;
8
+ static addToCart(item: IkasOrderLineItem, quantity: number, eventId: string): void;
9
9
  static removeFromCart(item: IkasProductDetail | IkasOrderLineItem, quantity: number): void;
10
10
  static beginCheckout(checkout: IkasCheckout): void;
11
11
  static purchase(checkout: IkasCheckout, eventId: string): void;
@@ -3,7 +3,7 @@ import { IkasCart } from "../models/data/cart/index";
3
3
  export declare class FacebookPixel {
4
4
  constructor();
5
5
  static productView(productDetail: IkasProductDetail): void;
6
- static addToCart(item: IkasProductDetail | IkasOrderLineItem, quantity: number, eventId: string): void;
6
+ static addToCart(item: IkasOrderLineItem, quantity: number, eventId: string): void;
7
7
  static beginCheckout(checkout: IkasCheckout): void;
8
8
  static purchase(checkout: IkasCheckout, eventId: string): void;
9
9
  static addToWishlist(id: string): void;
package/build/index.es.js CHANGED
@@ -17879,9 +17879,7 @@ var FacebookPixel = /** @class */ (function () {
17879
17879
  try {
17880
17880
  !isServer &&
17881
17881
  window.fbq &&
17882
- window.fbq("track", "AddToCart", item instanceof IkasProductDetail
17883
- ? productToFBPItem(item, quantity)
17884
- : orderLineItemToFBPItem(item, quantity), { eventId: eventId });
17882
+ window.fbq("track", "AddToCart", orderLineItemToFBPItem(item, quantity), { eventId: eventId });
17885
17883
  return;
17886
17884
  }
17887
17885
  catch (err) {
@@ -22513,7 +22511,7 @@ var IkasCartStore = /** @class */ (function () {
22513
22511
  this.addItem = function (variant, product, initialQuantity) {
22514
22512
  if (initialQuantity === void 0) { initialQuantity = 1; }
22515
22513
  return __awaiter(_this, void 0, void 0, function () {
22516
- var existingItem, input, cart, eventId, err_2;
22514
+ var existingItem, input, cart, eventId, item, err_2;
22517
22515
  var _a, _b, _c;
22518
22516
  return __generator(this, function (_d) {
22519
22517
  switch (_d.label) {
@@ -22554,7 +22552,10 @@ var IkasCartStore = /** @class */ (function () {
22554
22552
  case 3:
22555
22553
  if (this.cart) {
22556
22554
  eventId = this.cart.id + "-" + this.cart.updatedAt;
22557
- Analytics.addToCart(new IkasProductDetail(product, variant.variantValues), initialQuantity, eventId);
22555
+ item = this.cart.items.find(function (i) { return i.variant.id; });
22556
+ if (item) {
22557
+ Analytics.addToCart(item, initialQuantity, eventId);
22558
+ }
22558
22559
  }
22559
22560
  return [3 /*break*/, 5];
22560
22561
  case 4:
@@ -61522,7 +61523,7 @@ var Image = function (_a) {
61522
61523
  });
61523
61524
  return image.getSrc(closest);
61524
61525
  };
61525
- return (createElement(NextImage, __assign({}, others, { loader: loader, quality: 100, src: image.src, alt: others.alt || "Image", unoptimized: true })));
61526
+ return (createElement(NextImage, __assign({}, others, { loader: loader, quality: 100, src: image.src, alt: others.alt || "Image" })));
61526
61527
  };
61527
61528
 
61528
61529
  var styles$l = {"StepContainer":"style-module_StepContainer__1O2dD","Step":"style-module_Step__1iOYA","StepTitleContainer":"style-module_StepTitleContainer__2GUg2","First":"style-module_First__cAzdJ","StepTitleTop":"style-module_StepTitleTop__3zfsj","WithRightContent":"style-module_WithRightContent__2fqb1","StepCircle":"style-module_StepCircle__36A5q","Selected":"style-module_Selected__3j91L","StepTitle":"style-module_StepTitle__10YDP","Light":"style-module_Light__15wSX","StepTitleRightContent":"style-module_StepTitleRightContent__2Q43m","StepContent":"style-module_StepContent__20QIi"};
@@ -62251,31 +62252,14 @@ var Page$1 = function (_a) {
62251
62252
  IkasStorefrontConfig.initWithJson(configJson);
62252
62253
  var router = useRouter();
62253
62254
  var _b = useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
62254
- var initialPropValues = useMemo(function () {
62255
- return IkasPageDataProvider.initPropValues(propValuesStr, router, settingsStr);
62256
- }, [propValuesStr]);
62257
- var _c = useState(initialPropValues), propValues = _c[0], setPropValues = _c[1];
62255
+ var _c = useState(IkasPageDataProvider.initPropValues(propValuesStr, router, settingsStr)), propValues = _c[0], setPropValues = _c[1];
62258
62256
  useEffect(function () {
62259
62257
  setIsBrowser(typeof window !== "undefined");
62260
62258
  handleAnalytics(page, pageSpecificDataStr);
62261
- }, [pageSpecificDataStr]);
62259
+ }, [page, pageSpecificDataStr]);
62262
62260
  useEffect(function () {
62263
62261
  setPropValues(IkasPageDataProvider.initPropValues(propValuesStr, router, settingsStr, isBrowser));
62264
- }, [isBrowser, propValuesStr]);
62265
- // If the user clicks a link for the same page, we need this logic to re-render the page
62266
- useEffect(function () {
62267
- router.events.on("routeChangeComplete", handleRouteChange);
62268
- return function () {
62269
- router.events.off("routeChangeComplete", handleRouteChange);
62270
- };
62271
- }, []);
62272
- var handleRouteChange = function (url, options) {
62273
- var shallow = options.shallow;
62274
- if (!shallow &&
62275
- [IkasThemePageType.CATEGORY, IkasThemePageType.BRAND].includes(page.type)) {
62276
- setPropValues(IkasPageDataProvider.initPropValues(propValuesStr, router, settingsStr, isBrowser));
62277
- }
62278
- };
62262
+ }, [isBrowser, propValuesStr, page]);
62279
62263
  return (createElement(IkasPage, { page: page, propValues: propValues, pageSpecificDataStr: pageSpecificDataStr, settingsStr: settingsStr, merchantSettings: merchantSettings, addOgpMetas: true }));
62280
62264
  };
62281
62265
  var index$1 = observer(Page$1);
package/build/index.js CHANGED
@@ -17887,9 +17887,7 @@ var FacebookPixel = /** @class */ (function () {
17887
17887
  try {
17888
17888
  !isServer &&
17889
17889
  window.fbq &&
17890
- window.fbq("track", "AddToCart", item instanceof IkasProductDetail
17891
- ? productToFBPItem(item, quantity)
17892
- : orderLineItemToFBPItem(item, quantity), { eventId: eventId });
17890
+ window.fbq("track", "AddToCart", orderLineItemToFBPItem(item, quantity), { eventId: eventId });
17893
17891
  return;
17894
17892
  }
17895
17893
  catch (err) {
@@ -22521,7 +22519,7 @@ var IkasCartStore = /** @class */ (function () {
22521
22519
  this.addItem = function (variant, product, initialQuantity) {
22522
22520
  if (initialQuantity === void 0) { initialQuantity = 1; }
22523
22521
  return __awaiter(_this, void 0, void 0, function () {
22524
- var existingItem, input, cart, eventId, err_2;
22522
+ var existingItem, input, cart, eventId, item, err_2;
22525
22523
  var _a, _b, _c;
22526
22524
  return __generator(this, function (_d) {
22527
22525
  switch (_d.label) {
@@ -22562,7 +22560,10 @@ var IkasCartStore = /** @class */ (function () {
22562
22560
  case 3:
22563
22561
  if (this.cart) {
22564
22562
  eventId = this.cart.id + "-" + this.cart.updatedAt;
22565
- Analytics.addToCart(new IkasProductDetail(product, variant.variantValues), initialQuantity, eventId);
22563
+ item = this.cart.items.find(function (i) { return i.variant.id; });
22564
+ if (item) {
22565
+ Analytics.addToCart(item, initialQuantity, eventId);
22566
+ }
22566
22567
  }
22567
22568
  return [3 /*break*/, 5];
22568
22569
  case 4:
@@ -61501,7 +61502,7 @@ var Image = function (_a) {
61501
61502
  });
61502
61503
  return image.getSrc(closest);
61503
61504
  };
61504
- return (React.createElement(NextImage__default['default'], __assign({}, others, { loader: loader, quality: 100, src: image.src, alt: others.alt || "Image", unoptimized: true })));
61505
+ return (React.createElement(NextImage__default['default'], __assign({}, others, { loader: loader, quality: 100, src: image.src, alt: others.alt || "Image" })));
61505
61506
  };
61506
61507
 
61507
61508
  var styles$l = {"StepContainer":"style-module_StepContainer__1O2dD","Step":"style-module_Step__1iOYA","StepTitleContainer":"style-module_StepTitleContainer__2GUg2","First":"style-module_First__cAzdJ","StepTitleTop":"style-module_StepTitleTop__3zfsj","WithRightContent":"style-module_WithRightContent__2fqb1","StepCircle":"style-module_StepCircle__36A5q","Selected":"style-module_Selected__3j91L","StepTitle":"style-module_StepTitle__10YDP","Light":"style-module_Light__15wSX","StepTitleRightContent":"style-module_StepTitleRightContent__2Q43m","StepContent":"style-module_StepContent__20QIi"};
@@ -62230,31 +62231,14 @@ var Page$1 = function (_a) {
62230
62231
  IkasStorefrontConfig.initWithJson(configJson);
62231
62232
  var router$1 = router.useRouter();
62232
62233
  var _b = React.useState(false), isBrowser = _b[0], setIsBrowser = _b[1];
62233
- var initialPropValues = React.useMemo(function () {
62234
- return IkasPageDataProvider.initPropValues(propValuesStr, router$1, settingsStr);
62235
- }, [propValuesStr]);
62236
- var _c = React.useState(initialPropValues), propValues = _c[0], setPropValues = _c[1];
62234
+ var _c = React.useState(IkasPageDataProvider.initPropValues(propValuesStr, router$1, settingsStr)), propValues = _c[0], setPropValues = _c[1];
62237
62235
  React.useEffect(function () {
62238
62236
  setIsBrowser(typeof window !== "undefined");
62239
62237
  handleAnalytics(page, pageSpecificDataStr);
62240
- }, [pageSpecificDataStr]);
62238
+ }, [page, pageSpecificDataStr]);
62241
62239
  React.useEffect(function () {
62242
62240
  setPropValues(IkasPageDataProvider.initPropValues(propValuesStr, router$1, settingsStr, isBrowser));
62243
- }, [isBrowser, propValuesStr]);
62244
- // If the user clicks a link for the same page, we need this logic to re-render the page
62245
- React.useEffect(function () {
62246
- router$1.events.on("routeChangeComplete", handleRouteChange);
62247
- return function () {
62248
- router$1.events.off("routeChangeComplete", handleRouteChange);
62249
- };
62250
- }, []);
62251
- var handleRouteChange = function (url, options) {
62252
- var shallow = options.shallow;
62253
- if (!shallow &&
62254
- [exports.IkasThemePageType.CATEGORY, exports.IkasThemePageType.BRAND].includes(page.type)) {
62255
- setPropValues(IkasPageDataProvider.initPropValues(propValuesStr, router$1, settingsStr, isBrowser));
62256
- }
62257
- };
62241
+ }, [isBrowser, propValuesStr, page]);
62258
62242
  return (React.createElement(IkasPage, { page: page, propValues: propValues, pageSpecificDataStr: pageSpecificDataStr, settingsStr: settingsStr, merchantSettings: merchantSettings, addOgpMetas: true }));
62259
62243
  };
62260
62244
  var index$1 = mobxReactLite.observer(Page$1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.165",
3
+ "version": "0.0.166-alpha.1",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",