@ikas/storefront-providers 4.0.0-alpha.49 → 4.0.0-alpha.5

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-providers",
3
- "version": "4.0.0-alpha.49",
3
+ "version": "4.0.0-alpha.5",
4
4
  "description": "Data providers for ikas storefront theme components.",
5
5
  "author": "Umut Ozan Yıldırım",
6
6
  "license": "ISC",
@@ -17,10 +17,10 @@
17
17
  },
18
18
  "devDependencies": {
19
19
  "@rollup/plugin-commonjs": "^22.0.0",
20
- "@ikas/storefront-api": "^4.0.0-alpha.49",
21
- "@ikas/storefront-config": "^4.0.0-alpha.49",
22
- "@ikas/storefront-model-functions": "^4.0.0-alpha.49",
23
- "@ikas/storefront-models": "^4.0.0-alpha.49",
20
+ "@ikas/storefront-api": "^4.0.0-alpha.5",
21
+ "@ikas/storefront-config": "^4.0.0-alpha.5",
22
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.5",
23
+ "@ikas/storefront-models": "^4.0.0-alpha.5",
24
24
  "@rollup/plugin-node-resolve": "^13.3.0",
25
25
  "@types/lodash": "^4.14.168",
26
26
  "@types/react": "^16.9.55",
@@ -37,10 +37,10 @@
37
37
  },
38
38
  "peerDependencies": {
39
39
  "mobx": "^6.1.3",
40
- "@ikas/storefront-api": "^4.0.0-alpha.49",
41
- "@ikas/storefront-config": "^4.0.0-alpha.49",
42
- "@ikas/storefront-model-functions": "^4.0.0-alpha.49",
43
- "@ikas/storefront-models": "^4.0.0-alpha.49",
40
+ "@ikas/storefront-api": "^4.0.0-alpha.5",
41
+ "@ikas/storefront-config": "^4.0.0-alpha.5",
42
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.5",
43
+ "@ikas/storefront-models": "^4.0.0-alpha.5",
44
44
  "lodash": "^4.17.20"
45
45
  }
46
46
  }
@@ -1,4 +1,4 @@
1
- import { listStorefrontRaffle } from "@ikas/storefront-api";
1
+ import { listRaffle } from "@ikas/storefront-api";
2
2
  import { IkasRaffleList } from ".";
3
3
  import { populateRaffleProducts } from "../../../providers/helpers/raffle";
4
4
 
@@ -25,7 +25,7 @@ async function getRaffleList(
25
25
  page: number,
26
26
  limit: number
27
27
  ) {
28
- const response = await listStorefrontRaffle({
28
+ const response = await listRaffle({
29
29
  start: list.start ? { eq: list.start } : undefined,
30
30
  end: list.end ? { eq: list.end } : undefined,
31
31
  includeDeleted: list.includeDeleted || false,
@@ -62,7 +62,7 @@ import {
62
62
  listHTMLMetaData,
63
63
  listMerchantSettings,
64
64
  listProductOptionSet,
65
- listStorefrontRaffle,
65
+ listRaffle,
66
66
  listRaffleMetaData,
67
67
  searchProducts,
68
68
  } from "@ikas/storefront-api";
@@ -80,7 +80,7 @@ export class IkasPageDataProvider {
80
80
  theme: IkasThemeJson;
81
81
  pageType?: IkasThemeJsonPageType | null = null;
82
82
  pageParams: Record<string, any> = {};
83
- private pageComponentPropValues: IkasPageComponentPropValue[] = [];
83
+ pageComponentPropValues: IkasPageComponentPropValue[] = [];
84
84
  pageSpecificData?: any | null = null;
85
85
  merchantSettings?: IkasMerchantSettings | null = null;
86
86
  possiblePageTypes?: IkasThemeJsonPageType[] = []; // Used for distinguishing blog slug page from main slug page
@@ -154,10 +154,6 @@ export class IkasPageDataProvider {
154
154
  return this.page?.components || [];
155
155
  }
156
156
 
157
- get $pageComponentPropValues() {
158
- return this.pageComponentPropValues;
159
- }
160
-
161
157
  async getMerchantSettings() {
162
158
  const merchantSettingsResponse = await listMerchantSettings({});
163
159
 
@@ -349,12 +345,11 @@ export class IkasPageDataProvider {
349
345
  };
350
346
 
351
347
  const handleBlogPage = async () => {
352
- const blogsResponse = await listBlog({
348
+ const blog = await listBlog({
353
349
  id: { eq: metaData.targetId },
354
350
  });
355
- if (!blogsResponse.isSuccess || !blogsResponse.data?.data?.length) return;
351
+ if (!blog) return;
356
352
 
357
- const blog = blogsResponse.data.data[0];
358
353
  this.pageSpecificData = blog;
359
354
  this.pageType = IkasThemeJsonPageType.BLOG;
360
355
  this.setPageMetaData(metaData);
@@ -376,13 +371,14 @@ export class IkasPageDataProvider {
376
371
  return;
377
372
 
378
373
  const blogCategory = blogCategoriesResponse.data.data[0];
374
+
379
375
  this.pageSpecificData = blogCategory;
380
376
  this.pageType = IkasThemeJsonPageType.BLOG_CATEGORY;
381
377
  this.setPageMetaData(metaData);
382
378
  };
383
379
 
384
380
  const handleRafflePage = async () => {
385
- const response = await listStorefrontRaffle({
381
+ const response = await listRaffle({
386
382
  id: { eq: metaData.targetId },
387
383
  });
388
384
 
@@ -674,21 +670,21 @@ export class IkasPageDataProvider {
674
670
  switch (type) {
675
671
  case "DEFAULT":
676
672
  const htmlMetaDataResponse = await listHTMLMetaData({
677
- targetId: { in: idList },
673
+ id: { in: idList },
678
674
  });
679
675
  results = htmlMetaDataResponse.data || [];
680
676
  break;
681
677
 
682
678
  case "BLOG":
683
679
  const blogMetaDataResponse = await listBlogMetaData({
684
- targetId: { in: idList },
680
+ id: { in: idList },
685
681
  });
686
682
  results = blogMetaDataResponse.data?.data || [];
687
683
  break;
688
684
 
689
685
  case "RAFFLE":
690
686
  const raffleMetaDataResponse = await listRaffleMetaData({
691
- targetId: { in: idList },
687
+ id: { in: idList },
692
688
  });
693
689
  results = raffleMetaDataResponse.data || [];
694
690
  break;
@@ -25,7 +25,6 @@ export function getPlaceholderProduct() {
25
25
  attributes: [],
26
26
  variantTypes: [],
27
27
  productOptionSetId: null,
28
- baseUnit: null,
29
28
  };
30
29
  return product;
31
30
  }
@@ -113,11 +112,13 @@ export function getPlaceholderRaffle(): IkasRaffle {
113
112
  dateRange: null,
114
113
  metadata: null,
115
114
  name: "",
115
+ participantCount: null,
116
116
  requiredCustomerAccount: false,
117
117
  status: false,
118
118
  variants: [],
119
119
  products: [],
120
120
  verificationType: IkasRaffleVerificationType.EMAIL,
121
+ isCustomerWinner: false,
121
122
  };
122
123
  }
123
124
 
@@ -7,11 +7,11 @@ export type IkasLinkMetaDataType = "DEFAULT" | "BLOG" | "RAFFLE";
7
7
  export type IkasLinkMetaDataTargetId = {
8
8
  type: IkasLinkMetaDataType;
9
9
  id: string;
10
- navigationLink: NavigationLink;
10
+ navigationLink: IkasNavigationLink;
11
11
  };
12
12
 
13
13
  export class IkasLinkPropValueProvider
14
- implements IkasPropValueProvider<NavigationLink | NavigationLink[]>
14
+ implements IkasPropValueProvider<IkasNavigationLink | IkasNavigationLink[]>
15
15
  {
16
16
  private linkPropValue: IkasLinkPropValue | IkasLinkPropValue[];
17
17
  private theme: IkasThemeJson;
@@ -29,89 +29,89 @@ export class IkasLinkPropValueProvider
29
29
 
30
30
  private async getNavigationLink(
31
31
  linkPropValue: IkasLinkPropValue
32
- ): Promise<NavigationLink> {
33
- let navigationLink: NavigationLink | undefined;
32
+ ): Promise<IkasNavigationLink> {
33
+ let navigationLink: IkasNavigationLink | undefined;
34
34
 
35
35
  if (linkPropValue.linkType === IkasLinkType.PAGE) {
36
36
  // INDEX PAGE
37
37
  if (linkPropValue.pageType === IkasThemeJsonPageType.INDEX) {
38
- navigationLink = new NavigationLink({
38
+ navigationLink = {
39
39
  href: "/",
40
40
  label: linkPropValue.label || "",
41
41
  subLinks: [],
42
- });
42
+ };
43
43
  } else if (linkPropValue.pageType === IkasThemeJsonPageType.ACCOUNT) {
44
- navigationLink = new NavigationLink({
44
+ navigationLink = {
45
45
  href: "/account",
46
46
  label: linkPropValue.label || "",
47
47
  subLinks: [],
48
- });
48
+ };
49
49
  } else if (linkPropValue.pageType === IkasThemeJsonPageType.ADDRESSES) {
50
- navigationLink = new NavigationLink({
50
+ navigationLink = {
51
51
  href: "/account/addresses",
52
52
  label: linkPropValue.label || "",
53
53
  subLinks: [],
54
- });
54
+ };
55
55
  } else if (linkPropValue.pageType === IkasThemeJsonPageType.ORDERS) {
56
- navigationLink = new NavigationLink({
56
+ navigationLink = {
57
57
  href: "/account/orders",
58
58
  label: linkPropValue.label || "",
59
59
  subLinks: [],
60
- });
60
+ };
61
61
  } else if (
62
62
  linkPropValue.pageType === IkasThemeJsonPageType.FAVORITE_PRODUCTS
63
63
  ) {
64
- navigationLink = new NavigationLink({
64
+ navigationLink = {
65
65
  href: "/account/favorite-products",
66
66
  label: linkPropValue.label || "",
67
67
  subLinks: [],
68
- });
68
+ };
69
69
  } else if (linkPropValue.pageType === IkasThemeJsonPageType.LOGIN) {
70
- navigationLink = new NavigationLink({
70
+ navigationLink = {
71
71
  href: "/account/login",
72
72
  label: linkPropValue.label || "",
73
73
  subLinks: [],
74
- });
74
+ };
75
75
  } else if (linkPropValue.pageType === IkasThemeJsonPageType.REGISTER) {
76
- navigationLink = new NavigationLink({
76
+ navigationLink = {
77
77
  href: "/account/register",
78
78
  label: linkPropValue.label || "",
79
79
  subLinks: [],
80
- });
80
+ };
81
81
  } else if (
82
82
  linkPropValue.pageType === IkasThemeJsonPageType.FORGOT_PASSWORD
83
83
  ) {
84
- navigationLink = new NavigationLink({
84
+ navigationLink = {
85
85
  href: "/account/forgot-password",
86
86
  label: linkPropValue.label || "",
87
87
  subLinks: [],
88
- });
88
+ };
89
89
  } else if (
90
90
  linkPropValue.pageType === IkasThemeJsonPageType.RECOVER_PASSWORD
91
91
  ) {
92
- navigationLink = new NavigationLink({
92
+ navigationLink = {
93
93
  href: "/account/recover-password",
94
94
  label: linkPropValue.label || "",
95
95
  subLinks: [],
96
- });
96
+ };
97
97
  } else if (linkPropValue.pageType === IkasThemeJsonPageType.BLOG_INDEX) {
98
- navigationLink = new NavigationLink({
98
+ navigationLink = {
99
99
  href: "/blog",
100
100
  label: linkPropValue.label || "",
101
101
  subLinks: [],
102
- });
102
+ };
103
103
  } else if (linkPropValue.pageType === IkasThemeJsonPageType.CART) {
104
- navigationLink = new NavigationLink({
104
+ navigationLink = {
105
105
  href: "/cart",
106
106
  label: linkPropValue.label || "",
107
107
  subLinks: [],
108
- });
108
+ };
109
109
  } else if (linkPropValue.pageType === IkasThemeJsonPageType.SEARCH) {
110
- navigationLink = new NavigationLink({
110
+ navigationLink = {
111
111
  href: "/search",
112
112
  label: linkPropValue.label || "",
113
113
  subLinks: [],
114
- });
114
+ };
115
115
  }
116
116
  // CUSTOM PAGE
117
117
  else if (linkPropValue.pageType === IkasThemeJsonPageType.CUSTOM) {
@@ -119,11 +119,11 @@ export class IkasLinkPropValueProvider
119
119
  (p) => p.id === linkPropValue.pageId
120
120
  );
121
121
  if (themePage) {
122
- navigationLink = new NavigationLink({
122
+ navigationLink = {
123
123
  href: "/pages/" + themePage.slug,
124
124
  label: linkPropValue.label || "",
125
125
  subLinks: [],
126
- });
126
+ };
127
127
  }
128
128
  }
129
129
  // ITEM PAGES
@@ -135,11 +135,11 @@ export class IkasLinkPropValueProvider
135
135
  ].includes(linkPropValue.pageType!)
136
136
  ) {
137
137
  if (linkPropValue.itemId) {
138
- navigationLink = new NavigationLink({
138
+ navigationLink = {
139
139
  href: "/",
140
140
  label: linkPropValue.label || "",
141
141
  subLinks: [],
142
- });
142
+ };
143
143
  this.linkMetaDataTargetIds.push({
144
144
  type: "DEFAULT",
145
145
  id: linkPropValue.itemId,
@@ -155,11 +155,11 @@ export class IkasLinkPropValueProvider
155
155
  ].includes(linkPropValue.pageType!)
156
156
  ) {
157
157
  if (linkPropValue.itemId) {
158
- navigationLink = new NavigationLink({
158
+ navigationLink = {
159
159
  href: "/blog/",
160
160
  label: linkPropValue.label || "",
161
161
  subLinks: [],
162
- });
162
+ };
163
163
  this.linkMetaDataTargetIds.push({
164
164
  type: "BLOG",
165
165
  id: linkPropValue.itemId,
@@ -170,11 +170,11 @@ export class IkasLinkPropValueProvider
170
170
  // RAFFLE ITEM PAGE
171
171
  else if (linkPropValue.pageType === IkasThemeJsonPageType.RAFFLE_DETAIL) {
172
172
  if (linkPropValue.itemId) {
173
- navigationLink = new NavigationLink({
173
+ navigationLink = {
174
174
  href: "/raffle/",
175
175
  label: linkPropValue.label || "",
176
176
  subLinks: [],
177
- });
177
+ };
178
178
  this.linkMetaDataTargetIds.push({
179
179
  type: "RAFFLE",
180
180
  id: linkPropValue.itemId,
@@ -200,12 +200,12 @@ export class IkasLinkPropValueProvider
200
200
  }
201
201
  // EXTERNAL LINK
202
202
  else if (linkPropValue.linkType === IkasLinkType.EXTERNAL) {
203
- navigationLink = new NavigationLink({
203
+ navigationLink = {
204
204
  href: linkPropValue.externalLink || "",
205
205
  label: linkPropValue.label || "",
206
206
  subLinks: [],
207
207
  isExternal: true,
208
- });
208
+ };
209
209
  }
210
210
 
211
211
  if (navigationLink) {
@@ -244,7 +244,7 @@ export class IkasLinkPropValueProvider
244
244
  return navigationLink;
245
245
  }
246
246
 
247
- return new NavigationLink({ href: "", label: "", subLinks: [] });
247
+ return { href: "", label: "", subLinks: [] } as IkasNavigationLink;
248
248
  }
249
249
 
250
250
  async getValue(): Promise<IkasNavigationLink | IkasNavigationLink[]> {
@@ -257,20 +257,3 @@ export class IkasLinkPropValueProvider
257
257
  }
258
258
  }
259
259
  }
260
-
261
- // This is a class by choice, mobx creates clones of plain JSON objects, but not class instances
262
- export class NavigationLink implements IkasNavigationLink {
263
- href: string;
264
- label: string;
265
- subLinks: IkasNavigationLink[];
266
- isExternal?: boolean | null;
267
- itemId?: string;
268
-
269
- constructor(data: IkasNavigationLink) {
270
- this.href = data.href;
271
- this.label = data.label;
272
- this.subLinks = data.subLinks;
273
- this.isExternal = data.isExternal;
274
- this.itemId = data.itemId;
275
- }
276
- }
@@ -81,13 +81,15 @@ export class IkasProductListPropValueProvider
81
81
  IkasRelatedProductsType.CATEGORY
82
82
  ) {
83
83
  this.relatedProductData.categoryIds =
84
- this.pageSpecificData.categories.map(
84
+ this.pageSpecificData.product.categories.map(
85
85
  (category: IkasCategory) => category.id
86
86
  );
87
87
  } else {
88
- this.relatedProductData.brandIds = [this.pageSpecificData?.brand?.id];
88
+ this.relatedProductData.brandIds = [
89
+ this.pageSpecificData.product?.brand?.id,
90
+ ];
89
91
  }
90
- this.relatedProductData.productId = this.pageSpecificData.id;
92
+ this.relatedProductData.productId = this.pageSpecificData.product.id;
91
93
  }
92
94
 
93
95
  const productList: IkasProductList = {
@@ -1,4 +1,4 @@
1
- import { listStorefrontRaffle } from "@ikas/storefront-api";
1
+ import { listRaffle } from "@ikas/storefront-api";
2
2
  import IkasPropValueProvider from ".";
3
3
  import { IkasRafflePropValue } from "../../models/prop-value/raffle";
4
4
  import { populateRaffleProducts } from "../helpers/raffle";
@@ -23,7 +23,7 @@ export class IkasRafflePropValueProvider
23
23
  }
24
24
  if (!this.rafflePropValue.raffleId) return null;
25
25
 
26
- const rafflesResponse = await listStorefrontRaffle({
26
+ const rafflesResponse = await listRaffle({
27
27
  id: { eq: this.rafflePropValue.raffleId },
28
28
  });
29
29
 
@@ -19,7 +19,6 @@ import { IkasBrandPropValue } from "../models/prop-value/brand";
19
19
  import { IkasCategoryPropValue } from "../models/prop-value/category";
20
20
  import { IkasProductPropValue } from "../models/prop-value/product";
21
21
  import { IkasRafflePropValue } from "../models/prop-value/raffle";
22
- import { makeAutoObservable } from "mobx";
23
22
 
24
23
  export class IkasPageComponentPropValue {
25
24
  pageComponent: IkasThemeJsonPageComponent;
@@ -30,8 +29,6 @@ export class IkasPageComponentPropValue {
30
29
  this.pageComponent = data.pageComponent;
31
30
  this.component = data.component;
32
31
  this.propValues = data.propValues || {};
33
-
34
- makeAutoObservable(this);
35
32
  }
36
33
  }
37
34