@ikas/storefront 4.0.0-alpha.38 → 4.0.0-alpha.39

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.38",
3
+ "version": "4.0.0-alpha.39",
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.38",
28
- "@ikas/storefront-config": "^4.0.0-alpha.38",
29
- "@ikas/storefront-model-functions": "^4.0.0-alpha.38",
30
- "@ikas/storefront-models": "^4.0.0-alpha.38",
31
- "@ikas/storefront-providers": "^4.0.0-alpha.38",
27
+ "@ikas/storefront-api": "^4.0.0-alpha.39",
28
+ "@ikas/storefront-config": "^4.0.0-alpha.39",
29
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.39",
30
+ "@ikas/storefront-models": "^4.0.0-alpha.39",
31
+ "@ikas/storefront-providers": "^4.0.0-alpha.39",
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.38",
56
- "@ikas/storefront-config": "^4.0.0-alpha.38",
57
- "@ikas/storefront-model-functions": "^4.0.0-alpha.38",
58
- "@ikas/storefront-models": "^4.0.0-alpha.38",
59
- "@ikas/storefront-providers": "^4.0.0-alpha.38",
55
+ "@ikas/storefront-api": "^4.0.0-alpha.39",
56
+ "@ikas/storefront-config": "^4.0.0-alpha.39",
57
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.39",
58
+ "@ikas/storefront-models": "^4.0.0-alpha.39",
59
+ "@ikas/storefront-providers": "^4.0.0-alpha.39",
60
60
  "mobx": "^6.1.3",
61
61
  "mobx-react-lite": "^3.1.5",
62
62
  "next": "12.2.0",
@@ -105,7 +105,7 @@ export const IkasPage: React.FC<IkasPageProps> = observer(
105
105
 
106
106
  React.useEffect(() => {
107
107
  handleAnalytics(pageType, IkasPageDataInit.pageSpecificData);
108
- }, [pageType, IkasPageDataInit.pageSpecificData]);
108
+ }, [pageType, pageSpecificData]); // Not IkasPageDataInit.pageSpecificData on purpose
109
109
 
110
110
  const renderedComponents = React.useMemo(() => {
111
111
  const headerComponentPropValue = _propValues.find(
@@ -166,21 +166,18 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
166
166
 
167
167
  get refundableItems() {
168
168
  if (!this.refundSettings) return [];
169
- return IkasOrderFunctions.getRefundableItems(this, this.refundSettings).map(
170
- (i) => new IkasOrderLineItem(i)
171
- );
169
+ return IkasOrderFunctions.getRefundableItems(
170
+ this,
171
+ this.refundSettings
172
+ ) as IkasOrderLineItem[];
172
173
  }
173
174
 
174
175
  get unfullfilledItems() {
175
- return IkasOrderFunctions.getUnfullfilledItems(this).map(
176
- (i) => new IkasOrderLineItem(i)
177
- );
176
+ return IkasOrderFunctions.getUnfullfilledItems(this) as IkasOrderLineItem[];
178
177
  }
179
178
 
180
179
  get refundedItems() {
181
- return IkasOrderFunctions.getRefundedItems(this).map(
182
- (i) => new IkasOrderLineItem(i)
183
- );
180
+ return IkasOrderFunctions.getRefundedItems(this) as IkasOrderLineItem[];
184
181
  }
185
182
 
186
183
  get totalTax() {
@@ -240,14 +237,17 @@ export class IkasOrder extends IkasBaseModel implements IOrder {
240
237
  }
241
238
 
242
239
  get couponAdjustment() {
243
- const adjustment = IkasOrderFunctions.getCouponAdjustment(this);
244
- return adjustment ? new IkasOrderAdjustment(adjustment) : undefined;
240
+ return IkasOrderFunctions.getCouponAdjustment(this) as IkasOrderAdjustment;
245
241
  }
246
242
 
247
243
  get nonCouponAdjustments() {
248
- return IkasOrderFunctions.getNonCouponAdjustments(this)?.map(
249
- (a) => new IkasOrderAdjustment(a)
250
- );
244
+ return IkasOrderFunctions.getNonCouponAdjustments(
245
+ this
246
+ ) as IkasOrderAdjustment[];
247
+ }
248
+
249
+ get isRefundEnabled() {
250
+ return !this.refundableItems.some((item) => item.refundQuantity === null);
251
251
  }
252
252
  }
253
253
 
@@ -96,9 +96,7 @@ export class IkasProduct implements IProduct {
96
96
 
97
97
  get hasValidProductOptionValues() {
98
98
  if (this.productOptionSet) {
99
- return IkasProductOptionSetFunctions.hasValidValues(
100
- this.productOptionSet
101
- );
99
+ return this.productOptionSet.hasValidValues;
102
100
  } else {
103
101
  return true;
104
102
  }
@@ -88,6 +88,10 @@ export class IkasProductOptionSet implements IProductOptionSet {
88
88
  );
89
89
  }
90
90
 
91
+ get hasValidValues() {
92
+ return this.displayedOptions.every((o) => o.hasValidValues);
93
+ }
94
+
91
95
  initOptionValues = async () => {
92
96
  this.options.forEach((o) => o.initValues());
93
97
  };
@@ -181,8 +181,9 @@ export class IkasProductOption implements IProductOption {
181
181
  this.requiredOptionValueIds = data.requiredOptionValueIds || null;
182
182
 
183
183
  this.values = data.values || [];
184
- //@ts-ignore
185
- this.childOptions = data.childOptions || [];
184
+ this.childOptions = data.childOptions
185
+ ? data.childOptions.map((co) => new IkasProductOption(co))
186
+ : [];
186
187
 
187
188
  makeAutoObservable(this);
188
189
  }
@@ -228,8 +229,11 @@ export class IkasProductOption implements IProductOption {
228
229
  return uploadedFiles;
229
230
  };
230
231
 
231
- get hasValidValues() {
232
- return IkasProductOptionFunctions.hasValidValues(this);
232
+ get hasValidValues(): boolean {
233
+ return (
234
+ IkasProductOptionFunctions.hasValidValues(this) &&
235
+ this.displayedChildOptions.every((o) => o.hasValidValues)
236
+ );
233
237
  }
234
238
 
235
239
  get values() {