@ikas/storefront 4.0.0-alpha.30 → 4.0.0-alpha.32

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.30",
3
+ "version": "4.0.0-alpha.32",
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.30",
28
- "@ikas/storefront-config": "^4.0.0-alpha.30",
29
- "@ikas/storefront-model-functions": "^4.0.0-alpha.30",
30
- "@ikas/storefront-models": "^4.0.0-alpha.30",
31
- "@ikas/storefront-providers": "^4.0.0-alpha.30",
27
+ "@ikas/storefront-api": "^4.0.0-alpha.32",
28
+ "@ikas/storefront-config": "^4.0.0-alpha.32",
29
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.32",
30
+ "@ikas/storefront-models": "^4.0.0-alpha.32",
31
+ "@ikas/storefront-providers": "^4.0.0-alpha.32",
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.30",
56
- "@ikas/storefront-config": "^4.0.0-alpha.30",
57
- "@ikas/storefront-model-functions": "^4.0.0-alpha.30",
58
- "@ikas/storefront-models": "^4.0.0-alpha.30",
59
- "@ikas/storefront-providers": "^4.0.0-alpha.30",
55
+ "@ikas/storefront-api": "^4.0.0-alpha.32",
56
+ "@ikas/storefront-config": "^4.0.0-alpha.32",
57
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.32",
58
+ "@ikas/storefront-models": "^4.0.0-alpha.32",
59
+ "@ikas/storefront-providers": "^4.0.0-alpha.32",
60
60
  "mobx": "^6.1.3",
61
61
  "mobx-react-lite": "^3.1.5",
62
62
  "next": "12.2.0",
@@ -569,6 +569,7 @@ export default class IkasPageEditorViewModel {
569
569
  apiUrl: data.apiUrl,
570
570
  adminApiUrl: data.adminApiUrl,
571
571
  cdnUrl: data.cdnUrl,
572
+ merchantSettings: data.merchantSettings,
572
573
  });
573
574
 
574
575
  setAPIClientConfig();
@@ -621,87 +622,16 @@ export default class IkasPageEditorViewModel {
621
622
  prop
622
623
  );
623
624
 
624
- await this.pageDataProvider.setLinkSlugs();
625
+ if (propValue.linkType || JSON.stringify(propValue)?.includes("linkType"))
626
+ await this.pageDataProvider.setLinkSlugs();
625
627
 
626
628
  if (pageComponentPropValues) {
627
- if (prop.type === IkasThemeJsonComponentPropType.CUSTOM) {
628
- IkasPageDataInit.initCustomDataPropValue(
629
- prop,
630
- propValue,
631
- pageComponentPropValues,
632
- this.theme!.settings,
633
- true
634
- );
635
- } else if (prop.type === IkasThemeJsonComponentPropType.COMPONENT) {
636
- IkasPageDataInit.initComponentPropValue(
637
- prop,
638
- propValue,
639
- pageComponentPropValues,
640
- this.theme!.settings,
641
- true
642
- );
643
- } else if (prop.type === IkasThemeJsonComponentPropType.COMPONENT_LIST) {
644
- IkasPageDataInit.initComponentListPropValue(
645
- prop,
646
- propValue,
647
- pageComponentPropValues,
648
- this.theme!.settings,
649
- true
650
- );
651
- } else if (prop.type === IkasThemeJsonComponentPropType.PRODUCT_DETAIL) {
652
- IkasPageDataInit.initProductPropValue(
653
- prop,
654
- propValue,
655
- pageComponentPropValues
656
- );
657
- } else if (prop.type === IkasThemeJsonComponentPropType.PRODUCT_LIST) {
658
- IkasPageDataInit.initProductListPropValue(
659
- prop,
660
- propValue,
661
- pageComponentPropValues
662
- );
663
- } else if (prop.type === IkasThemeJsonComponentPropType.CATEGORY) {
664
- IkasPageDataInit.initCategoryPropValue(
665
- prop,
666
- propValue,
667
- pageComponentPropValues
668
- );
669
- } else if (prop.type === IkasThemeJsonComponentPropType.BRAND) {
670
- IkasPageDataInit.initBrandPropValue(
671
- prop,
672
- propValue,
673
- pageComponentPropValues
674
- );
675
- } else if (prop.type === IkasThemeJsonComponentPropType.BLOG) {
676
- IkasPageDataInit.initBlogPropValue(
677
- prop,
678
- propValue,
679
- pageComponentPropValues
680
- );
681
- } else if (prop.type === IkasThemeJsonComponentPropType.BLOG_CATEGORY) {
682
- IkasPageDataInit.initBlogCategoryPropValue(
683
- prop,
684
- propValue,
685
- pageComponentPropValues
686
- );
687
- } else if (prop.type === IkasThemeJsonComponentPropType.RAFFLE) {
688
- IkasPageDataInit.initRafflePropValue(
689
- prop,
690
- propValue,
691
- pageComponentPropValues
692
- );
693
- } else if (
694
- prop.type === IkasThemeJsonComponentPropType.LINK ||
695
- prop.type === IkasThemeJsonComponentPropType.LIST_OF_LINK
696
- ) {
697
- IkasPageDataInit.initLinkPropValue(
698
- prop,
699
- propValue,
700
- pageComponentPropValues
701
- );
702
- } else {
703
- pageComponentPropValues.propValues[propName] = propValue;
704
- }
629
+ pageComponentPropValues.propValues[propName] = propValue;
630
+ IkasPageDataInit.initPropValue(
631
+ pageComponentPropValues,
632
+ this.theme!.settings,
633
+ true
634
+ );
705
635
  }
706
636
  };
707
637
 
@@ -770,24 +700,16 @@ export default class IkasPageEditorViewModel {
770
700
  const pageComponentPropValues =
771
701
  await this.pageDataProvider!.getPageComponentPropValues(pageComponent);
772
702
 
773
- const customDataProps = pageComponentPropValues.component.props.filter(
774
- (p) => p.type === IkasThemeJsonComponentPropType.CUSTOM
703
+ IkasPageDataInit.initPropValue(
704
+ pageComponentPropValues,
705
+ this.theme!.settings,
706
+ true
775
707
  );
776
708
 
777
- customDataProps.forEach((customDataProp) => {
778
- IkasPageDataInit.initCustomDataPropValue(
779
- customDataProp,
780
- pageComponentPropValues.propValues[customDataProp.name],
781
- pageComponentPropValues,
782
- this.theme!.settings,
783
- true
784
- );
785
-
786
- this.pageDataProvider!.pageComponentPropValues.push(
787
- pageComponentPropValues
788
- );
789
- this.pageComponents.push(pageComponent);
790
- });
709
+ this.pageDataProvider!.pageComponentPropValues.push(
710
+ pageComponentPropValues
711
+ );
712
+ this.pageComponents.push(pageComponent);
791
713
  };
792
714
 
793
715
  handleDeletePageComponent = (data: any) => {
@@ -3,7 +3,6 @@ import { IkasCategoryListParams } from "../models/ui/category-list";
3
3
  import { IkasAttributeList } from "../models/ui/product-attribute-list";
4
4
  import { IkasProductListParams } from "../models/ui/product-list";
5
5
  import { IkasRaffleListParams } from "../models/ui/raffle-list";
6
- import { observable } from "mobx";
7
6
 
8
7
  import {
9
8
  IkasThemeJsonSettings,
@@ -54,7 +53,7 @@ import {
54
53
  import _cloneDeep from "lodash/cloneDeep";
55
54
 
56
55
  export class IkasPageDataInit {
57
- static pageSpecificData: any = observable({});
56
+ static pageSpecificData: any = {};
58
57
 
59
58
  static setPageSpecificData(
60
59
  pageSpecificData: any,
@@ -71,7 +70,8 @@ export class IkasPageDataInit {
71
70
  const product = pageSpecificData as IkasProduct;
72
71
  IkasPageDataInit.pageSpecificData = new IkasProduct({
73
72
  ...product,
74
- selectedVariantValues: product.selectedVariantValues,
73
+ selectedVariantValues:
74
+ product.selectedVariantValues || product.variants[0].variantValues,
75
75
  });
76
76
  if (isBrowser) {
77
77
  this._initProductOnBrowser(IkasPageDataInit.pageSpecificData);
@@ -113,202 +113,212 @@ export class IkasPageDataInit {
113
113
  }
114
114
 
115
115
  static initPropValues(
116
- _pageComponentPropValues: IkasPageComponentPropValue[],
116
+ pageComponentPropValues: IkasPageComponentPropValue[],
117
117
  settings: IkasThemeJsonSettings,
118
118
  isBrowser?: boolean
119
119
  ) {
120
- const pageComponentPropValues = _cloneDeep(_pageComponentPropValues);
121
-
122
120
  pageComponentPropValues.forEach((pageComponentPropValue) => {
123
- const props = pageComponentPropValue.component.props;
124
-
125
- props.forEach((prop) => {
126
- const propValue = pageComponentPropValue.propValues[prop.name];
127
- if (propValue === null || propValue === undefined) return;
128
-
129
- switch (prop.type) {
130
- case IkasThemeJsonComponentPropType.IMAGE:
131
- IkasPageDataInit.initImagePropValue(
132
- prop,
133
- propValue,
134
- pageComponentPropValue
135
- );
136
- break;
121
+ IkasPageDataInit.initPropValue(
122
+ pageComponentPropValue,
123
+ settings,
124
+ isBrowser
125
+ );
126
+ });
137
127
 
138
- case IkasThemeJsonComponentPropType.IMAGE_LIST:
139
- IkasPageDataInit.initImageListPropValue(
140
- prop,
141
- propValue,
142
- pageComponentPropValue
143
- );
144
- break;
128
+ return pageComponentPropValues;
129
+ }
145
130
 
146
- case IkasThemeJsonComponentPropType.BRAND:
147
- IkasPageDataInit.initBrandPropValue(
148
- prop,
149
- propValue,
150
- pageComponentPropValue
151
- );
152
- break;
131
+ static initPropValue(
132
+ pageComponentPropValue: IkasPageComponentPropValue,
133
+ settings: IkasThemeJsonSettings,
134
+ isBrowser?: boolean
135
+ ) {
136
+ const props = pageComponentPropValue.component.props;
137
+
138
+ props.forEach((prop) => {
139
+ const propValue = pageComponentPropValue.propValues[prop.name];
140
+ if (propValue === null || propValue === undefined) return;
141
+
142
+ switch (prop.type) {
143
+ case IkasThemeJsonComponentPropType.IMAGE:
144
+ IkasPageDataInit.initImagePropValue(
145
+ prop,
146
+ propValue,
147
+ pageComponentPropValue
148
+ );
149
+ break;
153
150
 
154
- case IkasThemeJsonComponentPropType.BRAND_LIST:
155
- IkasPageDataInit.initBrandListPropValue(
156
- prop,
157
- propValue,
158
- pageComponentPropValue
159
- );
160
- break;
151
+ case IkasThemeJsonComponentPropType.IMAGE_LIST:
152
+ IkasPageDataInit.initImageListPropValue(
153
+ prop,
154
+ propValue,
155
+ pageComponentPropValue
156
+ );
157
+ break;
161
158
 
162
- case IkasThemeJsonComponentPropType.CATEGORY:
163
- IkasPageDataInit.initCategoryPropValue(
164
- prop,
165
- propValue,
166
- pageComponentPropValue
167
- );
168
- break;
159
+ case IkasThemeJsonComponentPropType.BRAND:
160
+ IkasPageDataInit.initBrandPropValue(
161
+ prop,
162
+ propValue,
163
+ pageComponentPropValue
164
+ );
165
+ break;
169
166
 
170
- case IkasThemeJsonComponentPropType.CATEGORY_LIST:
171
- IkasPageDataInit.initCategoryListPropValue(
172
- prop,
173
- propValue,
174
- pageComponentPropValue
175
- );
176
- break;
167
+ case IkasThemeJsonComponentPropType.BRAND_LIST:
168
+ IkasPageDataInit.initBrandListPropValue(
169
+ prop,
170
+ propValue,
171
+ pageComponentPropValue
172
+ );
173
+ break;
177
174
 
178
- case IkasThemeJsonComponentPropType.PRODUCT_LIST:
179
- IkasPageDataInit.initProductListPropValue(
180
- prop,
181
- propValue,
182
- pageComponentPropValue
183
- );
184
- break;
175
+ case IkasThemeJsonComponentPropType.CATEGORY:
176
+ IkasPageDataInit.initCategoryPropValue(
177
+ prop,
178
+ propValue,
179
+ pageComponentPropValue
180
+ );
181
+ break;
185
182
 
186
- case IkasThemeJsonComponentPropType.PRODUCT_DETAIL:
187
- IkasPageDataInit.initProductPropValue(
188
- prop,
189
- propValue,
190
- pageComponentPropValue
191
- );
192
- break;
183
+ case IkasThemeJsonComponentPropType.CATEGORY_LIST:
184
+ IkasPageDataInit.initCategoryListPropValue(
185
+ prop,
186
+ propValue,
187
+ pageComponentPropValue
188
+ );
189
+ break;
193
190
 
194
- case IkasThemeJsonComponentPropType.PRODUCT_ATTRIBUTE:
195
- IkasPageDataInit.initAttributePropValue(
196
- prop,
197
- propValue,
198
- pageComponentPropValue
199
- );
200
- break;
191
+ case IkasThemeJsonComponentPropType.PRODUCT_LIST:
192
+ IkasPageDataInit.initProductListPropValue(
193
+ prop,
194
+ propValue,
195
+ pageComponentPropValue
196
+ );
197
+ break;
201
198
 
202
- case IkasThemeJsonComponentPropType.PRODUCT_ATTRIBUTE_LIST:
203
- IkasPageDataInit.initAttributeListPropValue(
204
- prop,
205
- propValue,
206
- pageComponentPropValue
207
- );
208
- break;
209
-
210
- case IkasThemeJsonComponentPropType.LINK:
211
- case IkasThemeJsonComponentPropType.LIST_OF_LINK:
212
- IkasPageDataInit.initLinkPropValue(
213
- prop,
214
- propValue,
215
- pageComponentPropValue
216
- );
217
- break;
218
-
219
- case IkasThemeJsonComponentPropType.COMPONENT:
220
- IkasPageDataInit.initComponentPropValue(
221
- prop,
222
- propValue,
223
- pageComponentPropValue,
224
- settings,
225
- isBrowser
226
- );
227
- break;
228
-
229
- case IkasThemeJsonComponentPropType.COMPONENT_LIST:
230
- IkasPageDataInit.initComponentListPropValue(
231
- prop,
232
- propValue,
233
- pageComponentPropValue,
234
- settings,
235
- isBrowser
236
- );
237
- break;
238
-
239
- case IkasThemeJsonComponentPropType.CUSTOM:
240
- IkasPageDataInit.initCustomDataPropValue(
241
- prop,
242
- propValue,
243
- pageComponentPropValue,
244
- settings,
245
- isBrowser
246
- );
247
- break;
199
+ case IkasThemeJsonComponentPropType.PRODUCT_DETAIL:
200
+ IkasPageDataInit.initProductPropValue(
201
+ prop,
202
+ propValue,
203
+ pageComponentPropValue
204
+ );
205
+ break;
248
206
 
249
- case IkasThemeJsonComponentPropType.BLOG:
250
- IkasPageDataInit.initBlogPropValue(
251
- prop,
252
- propValue,
253
- pageComponentPropValue
254
- );
255
- break;
207
+ case IkasThemeJsonComponentPropType.PRODUCT_ATTRIBUTE:
208
+ IkasPageDataInit.initAttributePropValue(
209
+ prop,
210
+ propValue,
211
+ pageComponentPropValue
212
+ );
213
+ break;
256
214
 
257
- case IkasThemeJsonComponentPropType.BLOG_LIST:
258
- IkasPageDataInit.initBlogListPropValue(
259
- prop,
260
- propValue,
261
- pageComponentPropValue
262
- );
263
- break;
215
+ case IkasThemeJsonComponentPropType.PRODUCT_ATTRIBUTE_LIST:
216
+ IkasPageDataInit.initAttributeListPropValue(
217
+ prop,
218
+ propValue,
219
+ pageComponentPropValue
220
+ );
221
+ break;
222
+
223
+ case IkasThemeJsonComponentPropType.LINK:
224
+ case IkasThemeJsonComponentPropType.LIST_OF_LINK:
225
+ IkasPageDataInit.initLinkPropValue(
226
+ prop,
227
+ propValue,
228
+ pageComponentPropValue
229
+ );
230
+ break;
264
231
 
265
- case IkasThemeJsonComponentPropType.BLOG_CATEGORY:
266
- IkasPageDataInit.initBlogCategoryPropValue(
267
- prop,
268
- propValue,
269
- pageComponentPropValue
270
- );
271
- break;
232
+ case IkasThemeJsonComponentPropType.COMPONENT:
233
+ IkasPageDataInit.initComponentPropValue(
234
+ prop,
235
+ propValue,
236
+ pageComponentPropValue,
237
+ settings,
238
+ isBrowser
239
+ );
240
+ break;
272
241
 
273
- case IkasThemeJsonComponentPropType.BLOG_LIST:
274
- IkasPageDataInit.initBlogCategoryListPropValue(
275
- prop,
276
- propValue,
277
- pageComponentPropValue
278
- );
279
- break;
242
+ case IkasThemeJsonComponentPropType.COMPONENT_LIST:
243
+ IkasPageDataInit.initComponentListPropValue(
244
+ prop,
245
+ propValue,
246
+ pageComponentPropValue,
247
+ settings,
248
+ isBrowser
249
+ );
250
+ break;
280
251
 
281
- case IkasThemeJsonComponentPropType.RAFFLE:
282
- IkasPageDataInit.initRafflePropValue(
283
- prop,
284
- propValue,
285
- pageComponentPropValue
286
- );
287
- break;
252
+ case IkasThemeJsonComponentPropType.CUSTOM:
253
+ IkasPageDataInit.initCustomDataPropValue(
254
+ prop,
255
+ propValue,
256
+ pageComponentPropValue,
257
+ settings,
258
+ isBrowser
259
+ );
260
+ break;
288
261
 
289
- case IkasThemeJsonComponentPropType.RAFFLE_LIST:
290
- IkasPageDataInit.initRaffleListPropValue(
291
- prop,
292
- propValue,
293
- pageComponentPropValue
294
- );
295
- break;
262
+ case IkasThemeJsonComponentPropType.BLOG:
263
+ IkasPageDataInit.initBlogPropValue(
264
+ prop,
265
+ propValue,
266
+ pageComponentPropValue
267
+ );
268
+ break;
296
269
 
297
- case IkasThemeJsonComponentPropType.SLIDER:
298
- IkasPageDataInit.initSliderPropValue(
299
- prop,
300
- propValue,
301
- pageComponentPropValue
302
- );
303
- break;
270
+ case IkasThemeJsonComponentPropType.BLOG_LIST:
271
+ IkasPageDataInit.initBlogListPropValue(
272
+ prop,
273
+ propValue,
274
+ pageComponentPropValue
275
+ );
276
+ break;
304
277
 
305
- default:
306
- break;
307
- }
308
- });
309
- });
278
+ case IkasThemeJsonComponentPropType.BLOG_CATEGORY:
279
+ IkasPageDataInit.initBlogCategoryPropValue(
280
+ prop,
281
+ propValue,
282
+ pageComponentPropValue
283
+ );
284
+ break;
310
285
 
311
- return pageComponentPropValues;
286
+ case IkasThemeJsonComponentPropType.BLOG_LIST:
287
+ IkasPageDataInit.initBlogCategoryListPropValue(
288
+ prop,
289
+ propValue,
290
+ pageComponentPropValue
291
+ );
292
+ break;
293
+
294
+ case IkasThemeJsonComponentPropType.RAFFLE:
295
+ IkasPageDataInit.initRafflePropValue(
296
+ prop,
297
+ propValue,
298
+ pageComponentPropValue
299
+ );
300
+ break;
301
+
302
+ case IkasThemeJsonComponentPropType.RAFFLE_LIST:
303
+ IkasPageDataInit.initRaffleListPropValue(
304
+ prop,
305
+ propValue,
306
+ pageComponentPropValue
307
+ );
308
+ break;
309
+
310
+ case IkasThemeJsonComponentPropType.SLIDER:
311
+ IkasPageDataInit.initSliderPropValue(
312
+ prop,
313
+ propValue,
314
+ pageComponentPropValue
315
+ );
316
+ break;
317
+
318
+ default:
319
+ break;
320
+ }
321
+ });
312
322
  }
313
323
 
314
324
  static initBrandPropValue(