@ikas/storefront 4.0.0-alpha.37 → 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 +11 -11
- package/src/components/page/index.tsx +1 -1
- package/src/models/data/order/index.ts +14 -14
- package/src/models/data/product/index.ts +21 -3
- package/src/models/data/product/option-set/index.ts +4 -0
- package/src/models/data/product/option-set/option/index.ts +33 -10
- package/src/models/data/product/variant/index.ts +23 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
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.
|
|
28
|
-
"@ikas/storefront-config": "^4.0.0-alpha.
|
|
29
|
-
"@ikas/storefront-model-functions": "^4.0.0-alpha.
|
|
30
|
-
"@ikas/storefront-models": "^4.0.0-alpha.
|
|
31
|
-
"@ikas/storefront-providers": "^4.0.0-alpha.
|
|
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.
|
|
56
|
-
"@ikas/storefront-config": "^4.0.0-alpha.
|
|
57
|
-
"@ikas/storefront-model-functions": "^4.0.0-alpha.
|
|
58
|
-
"@ikas/storefront-models": "^4.0.0-alpha.
|
|
59
|
-
"@ikas/storefront-providers": "^4.0.0-alpha.
|
|
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,
|
|
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(
|
|
170
|
-
|
|
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)
|
|
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)
|
|
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
|
-
|
|
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(
|
|
249
|
-
|
|
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
|
|
|
@@ -23,6 +23,8 @@ import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
|
23
23
|
import { Analytics } from "../../../analytics";
|
|
24
24
|
import { IkasVariantType } from "../variant-type";
|
|
25
25
|
import { IkasBaseStore } from "../../../store/base";
|
|
26
|
+
import { IkasProductAttributeMap } from "./attribute-value";
|
|
27
|
+
import _groupBy from "lodash/groupBy";
|
|
26
28
|
|
|
27
29
|
export class IkasProduct implements IProduct {
|
|
28
30
|
id: string;
|
|
@@ -94,9 +96,7 @@ export class IkasProduct implements IProduct {
|
|
|
94
96
|
|
|
95
97
|
get hasValidProductOptionValues() {
|
|
96
98
|
if (this.productOptionSet) {
|
|
97
|
-
return
|
|
98
|
-
this.productOptionSet
|
|
99
|
-
);
|
|
99
|
+
return this.productOptionSet.hasValidValues;
|
|
100
100
|
} else {
|
|
101
101
|
return true;
|
|
102
102
|
}
|
|
@@ -161,6 +161,24 @@ export class IkasProduct implements IProduct {
|
|
|
161
161
|
);
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
+
get groupedAttributeValues(): IkasProductAttributeMap[] {
|
|
165
|
+
const groupedValues = _groupBy(this.attributes, "productAttributeId");
|
|
166
|
+
|
|
167
|
+
return (this.attributes
|
|
168
|
+
?.map((attribute) => {
|
|
169
|
+
const attributeId = attribute.productAttributeId;
|
|
170
|
+
if (!attributeId) return;
|
|
171
|
+
|
|
172
|
+
const values = groupedValues[attributeId];
|
|
173
|
+
if (values?.length && values[0].productAttribute)
|
|
174
|
+
return {
|
|
175
|
+
attribute: values[0].productAttribute,
|
|
176
|
+
values: values,
|
|
177
|
+
};
|
|
178
|
+
})
|
|
179
|
+
.filter((v) => !!v) || []) as IkasProductAttributeMap[];
|
|
180
|
+
}
|
|
181
|
+
|
|
164
182
|
selectVariantValue(variantValue: IkasVariantValue) {
|
|
165
183
|
const metaData = this.metaData;
|
|
166
184
|
const selectedVariantValues = this.selectedVariantValues.map((vv) => {
|
|
@@ -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
|
};
|
|
@@ -13,7 +13,7 @@ import { makeAutoObservable } from "mobx";
|
|
|
13
13
|
import { IkasImage } from "../../../image";
|
|
14
14
|
import _sortBy from "lodash/sortBy";
|
|
15
15
|
import { IkasProductOptionFunctions } from "@ikas/storefront-model-functions";
|
|
16
|
-
import {
|
|
16
|
+
import { getProductOptionFileUrl, uploadFile } from "@ikas/storefront-api";
|
|
17
17
|
|
|
18
18
|
export class IkasProductOptionOtherPrice implements IProductOptionOtherPrice {
|
|
19
19
|
currencyCode: string;
|
|
@@ -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
|
-
|
|
185
|
-
|
|
184
|
+
this.childOptions = data.childOptions
|
|
185
|
+
? data.childOptions.map((co) => new IkasProductOption(co))
|
|
186
|
+
: [];
|
|
186
187
|
|
|
187
188
|
makeAutoObservable(this);
|
|
188
189
|
}
|
|
@@ -202,15 +203,37 @@ export class IkasProductOption implements IProductOption {
|
|
|
202
203
|
)
|
|
203
204
|
return [];
|
|
204
205
|
|
|
205
|
-
let
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
206
|
+
let tempUploadFiles = (
|
|
207
|
+
await Promise.all(
|
|
208
|
+
files.map((file) =>
|
|
209
|
+
getProductOptionFileUrl(
|
|
210
|
+
{
|
|
211
|
+
fileName: file.name,
|
|
212
|
+
productOptionSetId: this.productOptionSetId,
|
|
213
|
+
productOptionId: this.id,
|
|
214
|
+
},
|
|
215
|
+
file
|
|
216
|
+
)
|
|
217
|
+
)
|
|
218
|
+
)
|
|
219
|
+
).filter((file) => file.data);
|
|
220
|
+
|
|
221
|
+
const uploadedFiles: string[] = [];
|
|
222
|
+
for (const file of tempUploadFiles) {
|
|
223
|
+
const isSuccess = await uploadFile(file.data!, file.data!.file);
|
|
224
|
+
if (isSuccess) {
|
|
225
|
+
uploadedFiles.push(file.data!.optionUrl);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return uploadedFiles;
|
|
210
230
|
};
|
|
211
231
|
|
|
212
|
-
get hasValidValues() {
|
|
213
|
-
return
|
|
232
|
+
get hasValidValues(): boolean {
|
|
233
|
+
return (
|
|
234
|
+
IkasProductOptionFunctions.hasValidValues(this) &&
|
|
235
|
+
this.displayedChildOptions.every((o) => o.hasValidValues)
|
|
236
|
+
);
|
|
214
237
|
}
|
|
215
238
|
|
|
216
239
|
get values() {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { IkasProductPrice } from "./price";
|
|
2
2
|
import { IkasVariantValue } from "../../variant-type/variant-value";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
IkasProductAttributeMap,
|
|
5
|
+
IkasProductAttributeValue,
|
|
6
|
+
} from "../attribute-value";
|
|
4
7
|
import { IkasProductCampaign } from "../campaign";
|
|
5
8
|
import { IkasProductImage } from "../image";
|
|
6
9
|
import { IkasProductVariant as IProductVariant } from "@ikas/storefront-models";
|
|
@@ -11,6 +14,7 @@ import {
|
|
|
11
14
|
listProductBackInStockRemind,
|
|
12
15
|
saveProductBackInStockRemind,
|
|
13
16
|
} from "@ikas/storefront-api";
|
|
17
|
+
import _groupBy from "lodash/groupBy";
|
|
14
18
|
|
|
15
19
|
export class IkasProductVariant implements IProductVariant {
|
|
16
20
|
id: string;
|
|
@@ -73,6 +77,24 @@ export class IkasProductVariant implements IProductVariant {
|
|
|
73
77
|
return this._backInStockReminderSaved;
|
|
74
78
|
}
|
|
75
79
|
|
|
80
|
+
get groupedAttributeValues(): IkasProductAttributeMap[] {
|
|
81
|
+
const groupedValues = _groupBy(this.attributes, "productAttributeId");
|
|
82
|
+
|
|
83
|
+
return (this.attributes
|
|
84
|
+
?.map((attribute) => {
|
|
85
|
+
const attributeId = attribute.productAttributeId;
|
|
86
|
+
if (!attributeId) return;
|
|
87
|
+
|
|
88
|
+
const values = groupedValues[attributeId];
|
|
89
|
+
if (values?.length && values[0].productAttribute)
|
|
90
|
+
return {
|
|
91
|
+
attribute: values[0].productAttribute,
|
|
92
|
+
values: values,
|
|
93
|
+
};
|
|
94
|
+
})
|
|
95
|
+
.filter((v) => !!v) || []) as IkasProductAttributeMap[];
|
|
96
|
+
}
|
|
97
|
+
|
|
76
98
|
async saveBackInStockReminder(email: string) {
|
|
77
99
|
const listResponse = await listProductBackInStockRemind({
|
|
78
100
|
email: { eq: email },
|