@ikas/storefront 4.0.0-alpha.46 → 4.0.0-alpha.48

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "4.0.0-alpha.46",
3
+ "version": "4.0.0-alpha.48",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "Umut Ozan Yıldırım",
6
6
  "license": "ISC",
@@ -24,11 +24,11 @@
24
24
  "libphonenumber-js": "^1.10.6"
25
25
  },
26
26
  "devDependencies": {
27
- "@ikas/storefront-api": "^4.0.0-alpha.46",
28
- "@ikas/storefront-config": "^4.0.0-alpha.46",
29
- "@ikas/storefront-model-functions": "^4.0.0-alpha.46",
30
- "@ikas/storefront-models": "^4.0.0-alpha.46",
31
- "@ikas/storefront-providers": "^4.0.0-alpha.46",
27
+ "@ikas/storefront-api": "^4.0.0-alpha.48",
28
+ "@ikas/storefront-config": "^4.0.0-alpha.48",
29
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.48",
30
+ "@ikas/storefront-models": "^4.0.0-alpha.48",
31
+ "@ikas/storefront-providers": "^4.0.0-alpha.48",
32
32
  "@rollup/plugin-commonjs": "^22.0.0",
33
33
  "@rollup/plugin-json": "^4.1.0",
34
34
  "@rollup/plugin-node-resolve": "^13.3.0",
@@ -52,11 +52,11 @@
52
52
  "html-react-parser": "^1.4.0"
53
53
  },
54
54
  "peerDependencies": {
55
- "@ikas/storefront-api": "^4.0.0-alpha.46",
56
- "@ikas/storefront-config": "^4.0.0-alpha.46",
57
- "@ikas/storefront-model-functions": "^4.0.0-alpha.46",
58
- "@ikas/storefront-models": "^4.0.0-alpha.46",
59
- "@ikas/storefront-providers": "^4.0.0-alpha.46",
55
+ "@ikas/storefront-api": "^4.0.0-alpha.48",
56
+ "@ikas/storefront-config": "^4.0.0-alpha.48",
57
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.48",
58
+ "@ikas/storefront-models": "^4.0.0-alpha.48",
59
+ "@ikas/storefront-providers": "^4.0.0-alpha.48",
60
60
  "mobx": "^6.1.3",
61
61
  "mobx-react-lite": "^3.1.5",
62
62
  "next": "12.2.0",
@@ -447,7 +447,7 @@ export default class IkasAnalytics {
447
447
  };
448
448
 
449
449
  await this.sendEvents([event]);
450
- this.createSessionId();
450
+ await this.createSessionId();
451
451
  }
452
452
 
453
453
  static async beginCheckout(checkout: IkasCheckout) {
@@ -19,6 +19,7 @@ import {
19
19
  } from "../../../../models/data/payment-gateway";
20
20
  import OfferProduct from "../../components/offer-product";
21
21
  import { IkasTransactionCardAssociation } from "@ikas/storefront-models";
22
+ import { Analytics } from "../../../../analytics";
22
23
 
23
24
  type Props = {
24
25
  vm: CheckoutViewModel;
@@ -31,8 +32,12 @@ export const StepSuccess: React.FC<Props> = observer(({ vm }) => {
31
32
  if (typeof localStorage !== "undefined") {
32
33
  const lsCartId = localStorage.getItem(CART_LS_KEY);
33
34
 
34
- if (lsCartId && lsCartId === vm.checkout.id)
35
+ if (lsCartId && lsCartId === vm.checkout.id) {
36
+ if (vm.successTransaction)
37
+ Analytics.purchase(vm.checkout, vm.successTransaction);
38
+
35
39
  localStorage.removeItem(CART_LS_KEY);
40
+ }
36
41
  }
37
42
  }, []);
38
43
 
@@ -1,18 +1,31 @@
1
1
  import {
2
2
  IkasProductUnitType,
3
3
  IkasProductBaseUnit as IProductBaseUnit,
4
+ IkasProductUnit as IProductUnit,
4
5
  } from "@ikas/storefront-models";
5
6
  import { makeAutoObservable } from "mobx";
6
7
 
7
8
  export class IkasProductBaseUnit implements IProductBaseUnit {
8
9
  baseAmount: number | null;
9
10
  type: IkasProductUnitType;
10
- unitId: string | null;
11
+ unit: IkasProductUnit;
11
12
 
12
13
  constructor(data: IProductBaseUnit) {
13
14
  this.baseAmount = data.baseAmount;
14
15
  this.type = data.type;
15
- this.unitId = data.unitId;
16
+ this.unit = new IkasProductUnit(data.unit);
17
+
18
+ makeAutoObservable(this);
19
+ }
20
+ }
21
+
22
+ export class IkasProductUnit implements IProductUnit {
23
+ id: string;
24
+ name: string;
25
+
26
+ constructor(data: IkasProductUnit) {
27
+ this.id = data.id;
28
+ this.name = data.name;
16
29
 
17
30
  makeAutoObservable(this);
18
31
  }
@@ -13,10 +13,7 @@ import {
13
13
  } from "@ikas/storefront-models";
14
14
  import { IkasProductOptionSet } from "./option-set";
15
15
  import { makeAutoObservable } from "mobx";
16
- import {
17
- IkasProductFunctions,
18
- IkasProductOptionSetFunctions,
19
- } from "@ikas/storefront-model-functions";
16
+ import { IkasProductFunctions } from "@ikas/storefront-model-functions";
20
17
  import { IkasVariantValue } from "../variant-type/variant-value";
21
18
  import { IkasProductCampaign } from "./campaign";
22
19
  import { IkasStorefrontConfig } from "@ikas/storefront-config";
@@ -26,6 +23,7 @@ import { IkasBaseStore } from "../../../store/base";
26
23
  import { IkasProductAttributeMap } from "./attribute-value";
27
24
  import _groupBy from "lodash/groupBy";
28
25
  import { IkasProductBaseUnit } from "./base-unit";
26
+ import { formatCurrency } from "../../../utils";
29
27
 
30
28
  export class IkasProduct implements IProduct {
31
29
  id: string;
@@ -184,6 +182,10 @@ export class IkasProduct implements IProduct {
184
182
  .filter((v) => !!v) || []) as IkasProductAttributeMap[];
185
183
  }
186
184
 
185
+ get selectedVariantUnitPriceText() {
186
+ return this.getVariantUnitPriceText(this.selectedVariant);
187
+ }
188
+
187
189
  selectVariantValue(variantValue: IkasVariantValue) {
188
190
  const metaData = this.metaData;
189
191
  const selectedVariantValues = this.selectedVariantValues.map((vv) => {
@@ -281,6 +283,19 @@ export class IkasProduct implements IProduct {
281
283
  Analytics.productView(this);
282
284
  }
283
285
 
286
+ getVariantUnitPriceText(variant: IkasProductVariant) {
287
+ const price = variant.price;
288
+ if (!price.unitPrice || !this.baseUnit) {
289
+ return;
290
+ }
291
+
292
+ return `${formatCurrency(
293
+ price.unitPrice,
294
+ price.currency || "",
295
+ price.currencySymbol || ""
296
+ )} / ${this.baseUnit?.unit?.name}`;
297
+ }
298
+
284
299
  private setOptionPrices() {
285
300
  const variant = this.variants[0];
286
301
  if (!variant) return;
@@ -10,6 +10,7 @@ export class IkasProductPrice implements IProductPrice {
10
10
  discountPrice: number | null = null;
11
11
  priceListId: string | null = null;
12
12
  sellPrice: number;
13
+ unitPrice: number | null = null;
13
14
 
14
15
  constructor(data?: IProductPrice) {
15
16
  this.buyPrice = data?.buyPrice ?? null;
@@ -18,6 +19,7 @@ export class IkasProductPrice implements IProductPrice {
18
19
  this.discountPrice = data?.discountPrice ?? null;
19
20
  this.priceListId = data?.priceListId ?? null;
20
21
  this.sellPrice = data?.sellPrice ?? 0;
22
+ this.unitPrice = data?.unitPrice ?? null;
21
23
 
22
24
  makeAutoObservable(this);
23
25
  }
package/src/store/base.ts CHANGED
@@ -12,8 +12,8 @@ import { IkasThemeJsonPageType } from "@ikas/storefront-models";
12
12
  import { IkasStorefrontConfig } from "@ikas/storefront-config";
13
13
  import { NextRouter } from "next/router";
14
14
  import ProductStore from "./product";
15
- import { IkasCustomerReviewList } from "../models/ui";
16
- import { IkasCustomerReviewSummaryList } from "../models/ui";
15
+ import { IkasCustomerReviewList } from "../models/ui/customer-review-list";
16
+ import { IkasCustomerReviewSummaryList } from "../models/ui/customer-review-summary-list";
17
17
  import { IkasProduct } from "../models/data";
18
18
 
19
19
  configure({