@ikas/storefront 0.0.164-alpha.2 → 0.0.164-alpha.4

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.
@@ -59,8 +59,8 @@ export default class CheckoutViewModel {
59
59
  get installmentExtraPrice(): number | undefined;
60
60
  get finalPrice(): number;
61
61
  get hasStockError(): boolean;
62
- get canProceedToShipping(): boolean;
63
- get canProceedToPayment(): boolean;
62
+ get canProceedToShipping(): boolean | undefined;
63
+ get canProceedToPayment(): boolean | undefined;
64
64
  get canPerformPayment(): boolean | undefined;
65
65
  saveCheckout: () => Promise<void>;
66
66
  checkStocks: () => Promise<void>;
package/build/index.es.js CHANGED
@@ -11328,6 +11328,8 @@ var IkasOrderAddress = /** @class */ (function () {
11328
11328
  this.identityNumber = data.identityNumber || null;
11329
11329
  this.taxNumber = data.taxNumber || null;
11330
11330
  this.taxOffice = data.taxOffice || null;
11331
+ this.checkoutSettings = data.checkoutSettings;
11332
+ this.isDistrictRequired = data.isDistrictRequired || false;
11331
11333
  makeAutoObservable(this);
11332
11334
  }
11333
11335
  Object.defineProperty(IkasOrderAddress.prototype, "addressText", {
@@ -23185,10 +23187,7 @@ var CheckoutViewModel = /** @class */ (function () {
23185
23187
  newCheckout = _a.sent();
23186
23188
  if (newCheckout) {
23187
23189
  oldCheckout = this.checkout;
23188
- this.checkout = newCheckout;
23189
- this.checkout.customer = oldCheckout.customer;
23190
- this.checkout.shippingAddress = oldCheckout.shippingAddress;
23191
- this.checkout.billingAddress = oldCheckout.billingAddress;
23190
+ this.checkout = new IkasCheckout(__assign(__assign({}, newCheckout), { shippingAddress: oldCheckout.shippingAddress, billingAddress: oldCheckout.billingAddress, customer: oldCheckout.customer }));
23192
23191
  }
23193
23192
  return [3 /*break*/, 4];
23194
23193
  case 3:
@@ -23718,10 +23717,10 @@ var CheckoutViewModel = /** @class */ (function () {
23718
23717
  Object.defineProperty(CheckoutViewModel.prototype, "canProceedToShipping", {
23719
23718
  // VALIDATIONS
23720
23719
  get: function () {
23721
- var _a;
23722
- return (this.checkout.shippingAddress.isValid &&
23720
+ var _a, _b;
23721
+ return (((_a = this.checkout.shippingAddress) === null || _a === void 0 ? void 0 : _a.isValid) &&
23723
23722
  this.checkout.hasValidCustomer &&
23724
- ((_a = this.error) === null || _a === void 0 ? void 0 : _a.type) !== ErrorType.NO_SHIPPING_ERROR);
23723
+ ((_b = this.error) === null || _b === void 0 ? void 0 : _b.type) !== ErrorType.NO_SHIPPING_ERROR);
23725
23724
  },
23726
23725
  enumerable: false,
23727
23726
  configurable: true
@@ -61102,7 +61101,8 @@ var CartSummary = observer(function (_a) {
61102
61101
  !!vm.installmentExtraPrice && (createElement(InfoRow, { label: t("checkout-page:cartInterest"), value: formatMoney(vm.installmentExtraPrice, cart.currencyCode) })),
61103
61102
  createElement(Adjustments, { vm: vm }),
61104
61103
  createElement(CalculatedAdditionalPrices, { vm: vm }),
61105
- ((vm.step === CheckoutStep.SUCCESS && !!vm.checkout.note) ||
61104
+ ((vm.step === CheckoutStep.SUCCESS &&
61105
+ (!!vm.checkout.note || !!vm.checkout.appliedCouponCode)) ||
61106
61106
  vm.step !== CheckoutStep.SUCCESS) && (createElement("div", { className: styles$h.Divider, style: { marginTop: "24px", marginBottom: "24px" } })),
61107
61107
  createElement(Coupon, { vm: vm, isAddingCoupon: isAddingCoupon, setAddingCoupon: setAddingCoupon, setCouponError: setCouponError }),
61108
61108
  createElement(Note, { vm: vm, isAddingNote: isAddingNote, setAddingNote: setAddingNote })),
@@ -61202,7 +61202,8 @@ var Coupon = observer(function (_a) {
61202
61202
  }
61203
61203
  });
61204
61204
  }); };
61205
- if (vm.step === CheckoutStep.SUCCESS)
61205
+ var isSuccess = vm.step === CheckoutStep.SUCCESS;
61206
+ if (isSuccess && !vm.checkout.appliedCouponCode)
61206
61207
  return null;
61207
61208
  var adjustment = vm.checkout.couponAdjustment;
61208
61209
  return (createElement("div", { className: styles$h.InfoRow },
@@ -61216,8 +61217,8 @@ var Coupon = observer(function (_a) {
61216
61217
  t("checkout-page:couponCode"),
61217
61218
  createElement("span", { className: styles$h.AppliedCoupon },
61218
61219
  createElement("span", { className: styles$h.CouponCode }, vm.checkout.appliedCouponCode),
61219
- createElement("span", { className: styles$h.ClearCoupon, onClick: onClearCouponCode },
61220
- createElement(SVGCross, null))))),
61220
+ vm.step !== CheckoutStep.SUCCESS && (createElement("span", { className: styles$h.ClearCoupon, onClick: onClearCouponCode },
61221
+ createElement(SVGCross, null)))))),
61221
61222
  !!vm.checkout.appliedCouponCode && !isAddingCoupon && (createElement("div", { className: styles$h.Value },
61222
61223
  createElement("span", null, (adjustment === null || adjustment === void 0 ? void 0 : adjustment.type) === "DECREMENT" ? "- " : ""),
61223
61224
  " ",
@@ -62456,7 +62457,7 @@ var _slug_ = /*#__PURE__*/Object.freeze({
62456
62457
  });
62457
62458
 
62458
62459
  var CheckoutPage = function (_a) {
62459
- var checkoutId = _a.checkoutId, checkoutSettingsStr = _a.checkoutSettingsStr, customizationProps = _a.customizationProps, configJson = _a.configJson, others = __rest(_a, ["checkoutId", "checkoutSettingsStr", "customizationProps", "configJson"]);
62460
+ var checkoutId = _a.checkoutId, editorCheckout = _a.editorCheckout, checkoutSettingsStr = _a.checkoutSettingsStr, customizationProps = _a.customizationProps, configJson = _a.configJson, others = __rest(_a, ["checkoutId", "editorCheckout", "checkoutSettingsStr", "customizationProps", "configJson"]);
62460
62461
  var router = useRouter();
62461
62462
  var _b = useState(), checkout = _b[0], setCheckout = _b[1];
62462
62463
  IkasStorefrontConfig.initWithJson(configJson);
@@ -62484,7 +62485,10 @@ var CheckoutPage = function (_a) {
62484
62485
  }, [customizationProps]);
62485
62486
  useEffect(function () {
62486
62487
  store.checkLocalization();
62487
- getCheckout();
62488
+ if (!editorCheckout)
62489
+ getCheckout();
62490
+ else
62491
+ setCheckout(editorCheckout);
62488
62492
  }, []);
62489
62493
  var getCheckout = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
62490
62494
  var checkout;
package/build/index.js CHANGED
@@ -11344,6 +11344,8 @@ var IkasOrderAddress = /** @class */ (function () {
11344
11344
  this.identityNumber = data.identityNumber || null;
11345
11345
  this.taxNumber = data.taxNumber || null;
11346
11346
  this.taxOffice = data.taxOffice || null;
11347
+ this.checkoutSettings = data.checkoutSettings;
11348
+ this.isDistrictRequired = data.isDistrictRequired || false;
11347
11349
  mobx.makeAutoObservable(this);
11348
11350
  }
11349
11351
  Object.defineProperty(IkasOrderAddress.prototype, "addressText", {
@@ -23193,10 +23195,7 @@ var CheckoutViewModel = /** @class */ (function () {
23193
23195
  newCheckout = _a.sent();
23194
23196
  if (newCheckout) {
23195
23197
  oldCheckout = this.checkout;
23196
- this.checkout = newCheckout;
23197
- this.checkout.customer = oldCheckout.customer;
23198
- this.checkout.shippingAddress = oldCheckout.shippingAddress;
23199
- this.checkout.billingAddress = oldCheckout.billingAddress;
23198
+ this.checkout = new IkasCheckout(__assign(__assign({}, newCheckout), { shippingAddress: oldCheckout.shippingAddress, billingAddress: oldCheckout.billingAddress, customer: oldCheckout.customer }));
23200
23199
  }
23201
23200
  return [3 /*break*/, 4];
23202
23201
  case 3:
@@ -23726,10 +23725,10 @@ var CheckoutViewModel = /** @class */ (function () {
23726
23725
  Object.defineProperty(CheckoutViewModel.prototype, "canProceedToShipping", {
23727
23726
  // VALIDATIONS
23728
23727
  get: function () {
23729
- var _a;
23730
- return (this.checkout.shippingAddress.isValid &&
23728
+ var _a, _b;
23729
+ return (((_a = this.checkout.shippingAddress) === null || _a === void 0 ? void 0 : _a.isValid) &&
23731
23730
  this.checkout.hasValidCustomer &&
23732
- ((_a = this.error) === null || _a === void 0 ? void 0 : _a.type) !== ErrorType.NO_SHIPPING_ERROR);
23731
+ ((_b = this.error) === null || _b === void 0 ? void 0 : _b.type) !== ErrorType.NO_SHIPPING_ERROR);
23733
23732
  },
23734
23733
  enumerable: false,
23735
23734
  configurable: true
@@ -61081,7 +61080,8 @@ var CartSummary = mobxReactLite.observer(function (_a) {
61081
61080
  !!vm.installmentExtraPrice && (React.createElement(InfoRow, { label: t("checkout-page:cartInterest"), value: formatMoney(vm.installmentExtraPrice, cart.currencyCode) })),
61082
61081
  React.createElement(Adjustments, { vm: vm }),
61083
61082
  React.createElement(CalculatedAdditionalPrices, { vm: vm }),
61084
- ((vm.step === CheckoutStep.SUCCESS && !!vm.checkout.note) ||
61083
+ ((vm.step === CheckoutStep.SUCCESS &&
61084
+ (!!vm.checkout.note || !!vm.checkout.appliedCouponCode)) ||
61085
61085
  vm.step !== CheckoutStep.SUCCESS) && (React.createElement("div", { className: styles$h.Divider, style: { marginTop: "24px", marginBottom: "24px" } })),
61086
61086
  React.createElement(Coupon, { vm: vm, isAddingCoupon: isAddingCoupon, setAddingCoupon: setAddingCoupon, setCouponError: setCouponError }),
61087
61087
  React.createElement(Note, { vm: vm, isAddingNote: isAddingNote, setAddingNote: setAddingNote })),
@@ -61181,7 +61181,8 @@ var Coupon = mobxReactLite.observer(function (_a) {
61181
61181
  }
61182
61182
  });
61183
61183
  }); };
61184
- if (vm.step === CheckoutStep.SUCCESS)
61184
+ var isSuccess = vm.step === CheckoutStep.SUCCESS;
61185
+ if (isSuccess && !vm.checkout.appliedCouponCode)
61185
61186
  return null;
61186
61187
  var adjustment = vm.checkout.couponAdjustment;
61187
61188
  return (React.createElement("div", { className: styles$h.InfoRow },
@@ -61195,8 +61196,8 @@ var Coupon = mobxReactLite.observer(function (_a) {
61195
61196
  t("checkout-page:couponCode"),
61196
61197
  React.createElement("span", { className: styles$h.AppliedCoupon },
61197
61198
  React.createElement("span", { className: styles$h.CouponCode }, vm.checkout.appliedCouponCode),
61198
- React.createElement("span", { className: styles$h.ClearCoupon, onClick: onClearCouponCode },
61199
- React.createElement(SVGCross, null))))),
61199
+ vm.step !== CheckoutStep.SUCCESS && (React.createElement("span", { className: styles$h.ClearCoupon, onClick: onClearCouponCode },
61200
+ React.createElement(SVGCross, null)))))),
61200
61201
  !!vm.checkout.appliedCouponCode && !isAddingCoupon && (React.createElement("div", { className: styles$h.Value },
61201
61202
  React.createElement("span", null, (adjustment === null || adjustment === void 0 ? void 0 : adjustment.type) === "DECREMENT" ? "- " : ""),
61202
61203
  " ",
@@ -62435,7 +62436,7 @@ var _slug_ = /*#__PURE__*/Object.freeze({
62435
62436
  });
62436
62437
 
62437
62438
  var CheckoutPage = function (_a) {
62438
- var checkoutId = _a.checkoutId, checkoutSettingsStr = _a.checkoutSettingsStr, customizationProps = _a.customizationProps, configJson = _a.configJson, others = __rest(_a, ["checkoutId", "checkoutSettingsStr", "customizationProps", "configJson"]);
62439
+ var checkoutId = _a.checkoutId, editorCheckout = _a.editorCheckout, checkoutSettingsStr = _a.checkoutSettingsStr, customizationProps = _a.customizationProps, configJson = _a.configJson, others = __rest(_a, ["checkoutId", "editorCheckout", "checkoutSettingsStr", "customizationProps", "configJson"]);
62439
62440
  var router$1 = router.useRouter();
62440
62441
  var _b = React.useState(), checkout = _b[0], setCheckout = _b[1];
62441
62442
  IkasStorefrontConfig.initWithJson(configJson);
@@ -62463,7 +62464,10 @@ var CheckoutPage = function (_a) {
62463
62464
  }, [customizationProps]);
62464
62465
  React.useEffect(function () {
62465
62466
  store.checkLocalization();
62466
- getCheckout();
62467
+ if (!editorCheckout)
62468
+ getCheckout();
62469
+ else
62470
+ setCheckout(editorCheckout);
62467
62471
  }, []);
62468
62472
  var getCheckout = React.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
62469
62473
  var checkout;
@@ -3,8 +3,10 @@ import * as React from "react";
3
3
  import { GetServerSideProps } from "next";
4
4
  import { ParsedUrlQuery } from "querystring";
5
5
  import { IkasCheckoutCustomizationProps } from "../../components/checkout/index";
6
+ import { IkasCheckout } from "../../models/index";
6
7
  declare type Props = {
7
8
  checkoutId: string;
9
+ editorCheckout?: IkasCheckout;
8
10
  checkoutSettingsStr: string | null;
9
11
  customizationProps: IkasCheckoutCustomizationProps;
10
12
  returnPolicy: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "0.0.164-alpha.2",
3
+ "version": "0.0.164-alpha.4",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.es.js",
6
6
  "author": "Umut Ozan Yıldırım",