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

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.37",
3
+ "version": "4.0.0-alpha.38",
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.37",
28
- "@ikas/storefront-config": "^4.0.0-alpha.37",
29
- "@ikas/storefront-model-functions": "^4.0.0-alpha.37",
30
- "@ikas/storefront-models": "^4.0.0-alpha.37",
31
- "@ikas/storefront-providers": "^4.0.0-alpha.37",
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",
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.37",
56
- "@ikas/storefront-config": "^4.0.0-alpha.37",
57
- "@ikas/storefront-model-functions": "^4.0.0-alpha.37",
58
- "@ikas/storefront-models": "^4.0.0-alpha.37",
59
- "@ikas/storefront-providers": "^4.0.0-alpha.37",
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",
60
60
  "mobx": "^6.1.3",
61
61
  "mobx-react-lite": "^3.1.5",
62
62
  "next": "12.2.0",
@@ -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;
@@ -161,6 +163,24 @@ export class IkasProduct implements IProduct {
161
163
  );
162
164
  }
163
165
 
166
+ get groupedAttributeValues(): IkasProductAttributeMap[] {
167
+ const groupedValues = _groupBy(this.attributes, "productAttributeId");
168
+
169
+ return (this.attributes
170
+ ?.map((attribute) => {
171
+ const attributeId = attribute.productAttributeId;
172
+ if (!attributeId) return;
173
+
174
+ const values = groupedValues[attributeId];
175
+ if (values?.length && values[0].productAttribute)
176
+ return {
177
+ attribute: values[0].productAttribute,
178
+ values: values,
179
+ };
180
+ })
181
+ .filter((v) => !!v) || []) as IkasProductAttributeMap[];
182
+ }
183
+
164
184
  selectVariantValue(variantValue: IkasVariantValue) {
165
185
  const metaData = this.metaData;
166
186
  const selectedVariantValues = this.selectedVariantValues.map((vv) => {
@@ -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 { uploadProductOptionFile } from "@ikas/storefront-api";
16
+ import { getProductOptionFileUrl, uploadFile } from "@ikas/storefront-api";
17
17
 
18
18
  export class IkasProductOptionOtherPrice implements IProductOptionOtherPrice {
19
19
  currencyCode: string;
@@ -202,11 +202,30 @@ export class IkasProductOption implements IProductOption {
202
202
  )
203
203
  return [];
204
204
 
205
- let fileIds = await Promise.all(
206
- files.map((file) => uploadProductOptionFile(file, this))
207
- );
208
- fileIds = fileIds.filter((id) => id !== null);
209
- return fileIds;
205
+ let tempUploadFiles = (
206
+ await Promise.all(
207
+ files.map((file) =>
208
+ getProductOptionFileUrl(
209
+ {
210
+ fileName: file.name,
211
+ productOptionSetId: this.productOptionSetId,
212
+ productOptionId: this.id,
213
+ },
214
+ file
215
+ )
216
+ )
217
+ )
218
+ ).filter((file) => file.data);
219
+
220
+ const uploadedFiles: string[] = [];
221
+ for (const file of tempUploadFiles) {
222
+ const isSuccess = await uploadFile(file.data!, file.data!.file);
223
+ if (isSuccess) {
224
+ uploadedFiles.push(file.data!.optionUrl);
225
+ }
226
+ }
227
+
228
+ return uploadedFiles;
210
229
  };
211
230
 
212
231
  get hasValidValues() {
@@ -1,6 +1,9 @@
1
1
  import { IkasProductPrice } from "./price";
2
2
  import { IkasVariantValue } from "../../variant-type/variant-value";
3
- import { IkasProductAttributeValue } from "../attribute-value";
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 },