@ikas/storefront-providers 4.0.0-alpha.10

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.
Files changed (66) hide show
  1. package/package.json +46 -0
  2. package/src/index.ts +22 -0
  3. package/src/models/prop-value/attribute-list.ts +8 -0
  4. package/src/models/prop-value/attribute.ts +8 -0
  5. package/src/models/prop-value/blog-category-list.ts +9 -0
  6. package/src/models/prop-value/blog-category.ts +6 -0
  7. package/src/models/prop-value/blog-list.ts +13 -0
  8. package/src/models/prop-value/blog.ts +6 -0
  9. package/src/models/prop-value/brand-list.ts +11 -0
  10. package/src/models/prop-value/brand.ts +6 -0
  11. package/src/models/prop-value/category-list.ts +11 -0
  12. package/src/models/prop-value/category.ts +6 -0
  13. package/src/models/prop-value/link.ts +22 -0
  14. package/src/models/prop-value/product-list.ts +29 -0
  15. package/src/models/prop-value/product.ts +7 -0
  16. package/src/models/prop-value/raffle-list.ts +6 -0
  17. package/src/models/prop-value/raffle.ts +6 -0
  18. package/src/models/ui/blog-category-list/index.ts +19 -0
  19. package/src/models/ui/blog-category-list/init.ts +54 -0
  20. package/src/models/ui/blog-list/index.ts +21 -0
  21. package/src/models/ui/blog-list/init.ts +49 -0
  22. package/src/models/ui/brand-list/index.ts +25 -0
  23. package/src/models/ui/brand-list/init.ts +47 -0
  24. package/src/models/ui/category-list/index.ts +25 -0
  25. package/src/models/ui/category-list/init.ts +50 -0
  26. package/src/models/ui/component-renderer/index.ts +5 -0
  27. package/src/models/ui/customer-review-list/index.ts +12 -0
  28. package/src/models/ui/customer-review-list/init.ts +33 -0
  29. package/src/models/ui/customer-review-summary-list/index.ts +12 -0
  30. package/src/models/ui/customer-review-summary-list/init.ts +33 -0
  31. package/src/models/ui/index.ts +12 -0
  32. package/src/models/ui/navigation-link/index.ts +7 -0
  33. package/src/models/ui/product-attribute-detail/index.ts +7 -0
  34. package/src/models/ui/product-attribute-list/index.ts +7 -0
  35. package/src/models/ui/product-list/index.ts +80 -0
  36. package/src/models/ui/product-list/init.ts +407 -0
  37. package/src/models/ui/raffle-list/index.ts +17 -0
  38. package/src/models/ui/raffle-list/init.ts +44 -0
  39. package/src/providers/helpers/raffle.ts +69 -0
  40. package/src/providers/page-data-get.ts +708 -0
  41. package/src/providers/placeholders.ts +138 -0
  42. package/src/providers/prop-value/attribute-list.ts +75 -0
  43. package/src/providers/prop-value/attribute.ts +77 -0
  44. package/src/providers/prop-value/blog-category-list.ts +29 -0
  45. package/src/providers/prop-value/blog-category.ts +49 -0
  46. package/src/providers/prop-value/blog-list.ts +61 -0
  47. package/src/providers/prop-value/blog.ts +41 -0
  48. package/src/providers/prop-value/boolean.ts +14 -0
  49. package/src/providers/prop-value/brand-list.ts +30 -0
  50. package/src/providers/prop-value/brand.ts +46 -0
  51. package/src/providers/prop-value/category-list.ts +31 -0
  52. package/src/providers/prop-value/category.ts +45 -0
  53. package/src/providers/prop-value/color.ts +14 -0
  54. package/src/providers/prop-value/custom.ts +560 -0
  55. package/src/providers/prop-value/image-list.ts +16 -0
  56. package/src/providers/prop-value/image.ts +16 -0
  57. package/src/providers/prop-value/index.ts +3 -0
  58. package/src/providers/prop-value/link.ts +259 -0
  59. package/src/providers/prop-value/product-detail.ts +92 -0
  60. package/src/providers/prop-value/product-list.ts +124 -0
  61. package/src/providers/prop-value/raffle-list.ts +20 -0
  62. package/src/providers/prop-value/raffle.ts +41 -0
  63. package/src/providers/prop-value/rich-text.ts +14 -0
  64. package/src/providers/prop-value/slider.ts +19 -0
  65. package/src/providers/prop-value/text.ts +14 -0
  66. package/src/providers/types.ts +88 -0
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@ikas/storefront-providers",
3
+ "version": "4.0.0-alpha.10",
4
+ "description": "Data providers for ikas storefront theme components.",
5
+ "author": "Umut Ozan Yıldırım",
6
+ "license": "ISC",
7
+ "main": "./src/index.ts",
8
+ "module": "./src/index.ts",
9
+ "files": [
10
+ "./src"
11
+ ],
12
+ "type": "module",
13
+ "scripts": {
14
+ "pack": "npm pack",
15
+ "release": "npm publish",
16
+ "build": "rm -rf build && rollup -c"
17
+ },
18
+ "devDependencies": {
19
+ "@rollup/plugin-commonjs": "^22.0.0",
20
+ "@ikas/storefront-api": "^4.0.0-alpha.10",
21
+ "@ikas/storefront-config": "^4.0.0-alpha.10",
22
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.10",
23
+ "@ikas/storefront-models": "^4.0.0-alpha.10",
24
+ "@rollup/plugin-node-resolve": "^13.3.0",
25
+ "@types/lodash": "^4.14.168",
26
+ "@types/react": "^16.9.55",
27
+ "mobx": "^6.1.3",
28
+ "prettier": "^2.2.1",
29
+ "rollup": "^2.75.6",
30
+ "rollup-plugin-terser": "^7.0.2",
31
+ "rollup-plugin-typescript2": "^0.32.1",
32
+ "rollup-plugin-peer-deps-external": "^2.2.4",
33
+ "typescript": "^4.7.2",
34
+ "ttypescript": "^1.5.12",
35
+ "typescript-transform-paths": "^2.2.2",
36
+ "lodash": "^4.17.20"
37
+ },
38
+ "peerDependencies": {
39
+ "mobx": "^6.1.3",
40
+ "@ikas/storefront-api": "^4.0.0-alpha.10",
41
+ "@ikas/storefront-config": "^4.0.0-alpha.10",
42
+ "@ikas/storefront-model-functions": "^4.0.0-alpha.10",
43
+ "@ikas/storefront-models": "^4.0.0-alpha.10",
44
+ "lodash": "^4.17.20"
45
+ }
46
+ }
package/src/index.ts ADDED
@@ -0,0 +1,22 @@
1
+ export * from "./models/prop-value/attribute";
2
+ export * from "./models/prop-value/attribute-list";
3
+ export * from "./models/prop-value/blog-category-list";
4
+ export * from "./models/prop-value/blog-category";
5
+ export * from "./models/prop-value/blog-list";
6
+ export * from "./models/prop-value/blog";
7
+ export * from "./models/prop-value/brand-list";
8
+ export * from "./models/prop-value/brand";
9
+ export * from "./models/prop-value/category-list";
10
+ export * from "./models/prop-value/category";
11
+ export * from "./models/prop-value/link";
12
+ export * from "./models/prop-value/product-list";
13
+ export * from "./models/prop-value/product";
14
+ export * from "./models/prop-value/raffle-list";
15
+ export * from "./models/prop-value/raffle";
16
+
17
+ export * from "./models/ui";
18
+
19
+ export { IkasPageDataProvider } from "./providers/page-data-get";
20
+ export * from "./providers/types";
21
+ export * from "./providers/placeholders";
22
+ export * from "./providers/helpers/raffle";
@@ -0,0 +1,8 @@
1
+ export type IkasAttributeListPropValue = {
2
+ attributeIds?: string[] | null;
3
+ productId?: string | null;
4
+ variantId?: string | null;
5
+
6
+ // Only for product detail page
7
+ usePageData?: boolean | null;
8
+ };
@@ -0,0 +1,8 @@
1
+ export type IkasAttributePropValue = {
2
+ attributeId?: string | null;
3
+ productId?: string | null;
4
+ variantId?: string | null;
5
+
6
+ // Only for product detail page
7
+ usePageData?: boolean | null;
8
+ };
@@ -0,0 +1,9 @@
1
+ import { IkasBlogCategoryListType } from "../ui";
2
+
3
+ export type IkasBlogCategoryListPropValue = {
4
+ blogCategoryListType: IkasBlogCategoryListType;
5
+ initialLimit?: number | null;
6
+
7
+ // Only for static lists
8
+ blogCategoryIds?: string[] | null;
9
+ };
@@ -0,0 +1,6 @@
1
+ export type IkasBlogCategoryPropValue = {
2
+ blogCategoryId?: string | null;
3
+
4
+ // Only for product detail page
5
+ usePageData?: boolean | null;
6
+ };
@@ -0,0 +1,13 @@
1
+ import { IkasBlogListType } from "../ui";
2
+
3
+ export type IkasBlogListPropValue = {
4
+ blogListType: IkasBlogListType;
5
+ initialLimit?: number | null;
6
+
7
+ // Only for static lists
8
+ blogIds?: string[] | null;
9
+
10
+ // For CATEGORY type only
11
+ categoryId: string | null;
12
+ usePageFilter?: boolean | null;
13
+ };
@@ -0,0 +1,6 @@
1
+ export type IkasBlogPropValue = {
2
+ blogId?: string | null;
3
+
4
+ // Only for product detail page
5
+ usePageData?: boolean | null;
6
+ };
@@ -0,0 +1,11 @@
1
+ import { IkasBrandListSortType, IkasBrandListType } from "../ui";
2
+
3
+ export type IkasBrandListPropValue = {
4
+ brandListType: IkasBrandListType;
5
+ initialSort?: IkasBrandListSortType | null;
6
+ initialLimit?: number | null;
7
+
8
+ // Only for static lists
9
+ brandCount?: number | null;
10
+ brandIds?: string[] | null;
11
+ };
@@ -0,0 +1,6 @@
1
+ export class IkasBrandPropValue {
2
+ brandId?: string | null;
3
+
4
+ // Only for brand detail page
5
+ usePageData?: boolean | null;
6
+ }
@@ -0,0 +1,11 @@
1
+ import { IkasCategoryListSortType, IkasCategoryListType } from "../ui";
2
+
3
+ export type IkasCategoryListPropValue = {
4
+ categoryListType: IkasCategoryListType;
5
+ initialSort?: IkasCategoryListSortType | null;
6
+ initialLimit?: number | null;
7
+
8
+ // Only for static lists
9
+ categoryCount?: number | null;
10
+ categoryIds?: string[] | null;
11
+ };
@@ -0,0 +1,6 @@
1
+ export type IkasCategoryPropValue = {
2
+ categoryId?: string | null;
3
+
4
+ // Only for category detail page
5
+ usePageData?: boolean | null;
6
+ };
@@ -0,0 +1,22 @@
1
+ import { IkasThemeJsonPageType } from "@ikas/storefront-models";
2
+
3
+ export type IkasLinkPropValue = {
4
+ id?: string | null;
5
+ linkType?: IkasLinkType | null;
6
+ label?: string | null;
7
+ pageId?: string | null;
8
+ pageType?: IkasThemeJsonPageType | null;
9
+ itemId?: string | null;
10
+ externalLink?: string | null;
11
+ fileUrl?: string | null;
12
+
13
+ // This will be used to link to a specific part of the page
14
+ pageComponentId?: string | null;
15
+ subLinks: IkasLinkPropValue[];
16
+ };
17
+
18
+ export enum IkasLinkType {
19
+ PAGE = "PAGE",
20
+ EXTERNAL = "EXTERNAL",
21
+ FILE = "FILE",
22
+ }
@@ -0,0 +1,29 @@
1
+ import {
2
+ IkasProductListSortType,
3
+ IkasProductListType,
4
+ IkasRelatedProductsType,
5
+ } from "../ui";
6
+
7
+ export type IkasProductListPropValue = {
8
+ id: string;
9
+ productListType: IkasProductListType;
10
+ initialSort?: IkasProductListSortType | null;
11
+ initialLimit?: number | null;
12
+
13
+ // Only for static lists
14
+ productCount?: number | null;
15
+ productIds?: IkasProductVariantId[] | null;
16
+
17
+ // Only for collection and brand pages
18
+ // Example collections/man -> lists products inside the "man" category
19
+ usePageFilter?: boolean | null;
20
+ category?: string | null;
21
+
22
+ // Only for related products
23
+ relatedProductsType?: IkasRelatedProductsType | null;
24
+ };
25
+
26
+ type IkasProductVariantId = {
27
+ productId: string;
28
+ variantId: string;
29
+ };
@@ -0,0 +1,7 @@
1
+ export type IkasProductPropValue = {
2
+ productId?: string | null;
3
+ variantId?: string | null;
4
+
5
+ // Only for product detail page
6
+ usePageData?: boolean | null;
7
+ };
@@ -0,0 +1,6 @@
1
+ export type IkasRaffleListPropValue = {
2
+ initialLimit?: number | null;
3
+
4
+ // Only for static lists
5
+ raffleIds?: string[] | null;
6
+ };
@@ -0,0 +1,6 @@
1
+ export type IkasRafflePropValue = {
2
+ raffleId?: string | null;
3
+
4
+ // Only for raffle detail page
5
+ usePageData?: boolean | null;
6
+ };
@@ -0,0 +1,19 @@
1
+ import { IkasBlogCategory } from "@ikas/storefront-models";
2
+ import { IkasBlogCategoryListPropValue } from "../../prop-value/blog-category-list";
3
+
4
+ export type IkasBlogCategoryList = {
5
+ data: IkasBlogCategory[];
6
+ type: IkasBlogCategoryListType;
7
+ limit: number;
8
+ page: number;
9
+ count: number;
10
+ initialized?: boolean;
11
+ minPage?: number | null;
12
+ blogCategoryListPropValue: IkasBlogCategoryListPropValue;
13
+ isLoading?: boolean;
14
+ };
15
+
16
+ export enum IkasBlogCategoryListType {
17
+ ALL = "ALL",
18
+ STATIC = "STATIC",
19
+ }
@@ -0,0 +1,54 @@
1
+ import { listBlogCategory } from "@ikas/storefront-api";
2
+ import { IkasBlogCategory } from "@ikas/storefront-models";
3
+ import { IkasBlogCategoryList, IkasBlogCategoryListType } from ".";
4
+
5
+ export async function getInitial(list: IkasBlogCategoryList) {
6
+ try {
7
+ const response = await listBlogCategories(
8
+ list,
9
+ isStatic(list) ? 1 : list.page,
10
+ isStatic(list)
11
+ ? list.blogCategoryListPropValue.blogCategoryIds?.length || 10
12
+ : list.limit
13
+ );
14
+
15
+ if (isStatic(list)) {
16
+ list.data =
17
+ (list.blogCategoryListPropValue.blogCategoryIds
18
+ ?.map((bID) => {
19
+ return response.data?.data?.find((b) => b.id === bID);
20
+ })
21
+ .filter((b) => !!b) as IkasBlogCategory[]) || [];
22
+ } else {
23
+ list.data = response.data?.data || [];
24
+ }
25
+
26
+ list.count = response.data?.count || 0;
27
+ list.initialized = true;
28
+ list.minPage = list.page;
29
+ } catch (err) {
30
+ console.error(err);
31
+ }
32
+ }
33
+
34
+ function isStatic(list: IkasBlogCategoryList) {
35
+ return list.type === IkasBlogCategoryListType.STATIC;
36
+ }
37
+
38
+ async function listBlogCategories(
39
+ list: IkasBlogCategoryList,
40
+ page: number,
41
+ limit: number
42
+ ) {
43
+ return await listBlogCategory({
44
+ id: isStatic(list)
45
+ ? list.blogCategoryListPropValue.blogCategoryIds
46
+ ? { in: list.blogCategoryListPropValue.blogCategoryIds }
47
+ : undefined
48
+ : undefined,
49
+ pagination: {
50
+ page,
51
+ limit,
52
+ },
53
+ });
54
+ }
@@ -0,0 +1,21 @@
1
+ import { IkasBlog } from "@ikas/storefront-models";
2
+ import { IkasBlogListPropValue } from "../../prop-value/blog-list";
3
+
4
+ export type IkasBlogList = {
5
+ data: IkasBlog[];
6
+ type: IkasBlogListType;
7
+ limit: number;
8
+ page: number;
9
+ count: number;
10
+ initialized?: boolean;
11
+ minPage?: number | null;
12
+ blogListPropValue: IkasBlogListPropValue;
13
+ filterCategoryId: string | null;
14
+ isLoading?: boolean;
15
+ };
16
+
17
+ export enum IkasBlogListType {
18
+ ALL = "ALL",
19
+ STATIC = "STATIC",
20
+ CATEGORY = "CATEGORY",
21
+ }
@@ -0,0 +1,49 @@
1
+ import { listBlog } from "@ikas/storefront-api";
2
+ import { IkasBlog } from "@ikas/storefront-models";
3
+ import { IkasBlogList, IkasBlogListType } from ".";
4
+
5
+ export async function getInitial(list: IkasBlogList) {
6
+ try {
7
+ const response = await listBlogs(
8
+ list,
9
+ isStatic(list) ? 1 : list.page,
10
+ isStatic(list) ? list.blogListPropValue.blogIds?.length || 10 : list.limit
11
+ );
12
+
13
+ if (isStatic(list)) {
14
+ list.data =
15
+ (list.blogListPropValue.blogIds
16
+ ?.map((bID) => {
17
+ return response.data?.data?.find((b) => b.id === bID);
18
+ })
19
+ .filter((b) => !!b) as IkasBlog[]) || [];
20
+ } else {
21
+ list.data = response.data?.data || [];
22
+ }
23
+
24
+ list.count = response.data?.count || 0;
25
+ list.initialized = true;
26
+ list.minPage = list.page;
27
+ } catch (err) {
28
+ console.error(err);
29
+ }
30
+ }
31
+
32
+ function isStatic(list: IkasBlogList) {
33
+ return list.type === IkasBlogListType.STATIC;
34
+ }
35
+
36
+ async function listBlogs(list: IkasBlogList, page: number, limit: number) {
37
+ const response = await listBlog({
38
+ id: isStatic(list) ? { in: list.blogListPropValue.blogIds } : undefined,
39
+ pagination: {
40
+ page,
41
+ limit,
42
+ },
43
+ categoryId: list.filterCategoryId
44
+ ? { eq: list.filterCategoryId }
45
+ : undefined,
46
+ });
47
+
48
+ return response;
49
+ }
@@ -0,0 +1,25 @@
1
+ import { IkasBrand } from "@ikas/storefront-models";
2
+ import { IkasBrandListPropValue } from "../../prop-value/brand-list";
3
+
4
+ export type IkasBrandList = {
5
+ data: IkasBrand[];
6
+ type: IkasBrandListType;
7
+ sort: IkasBrandListSortType;
8
+ limit: number;
9
+ page: number;
10
+ count: number;
11
+ initialized?: boolean;
12
+ minPage?: number | null;
13
+ brandListPropValue: IkasBrandListPropValue;
14
+ isLoading?: boolean;
15
+ };
16
+
17
+ export enum IkasBrandListType {
18
+ ALL = "ALL",
19
+ STATIC = "STATIC",
20
+ }
21
+
22
+ export enum IkasBrandListSortType {
23
+ A_Z = "A_Z",
24
+ Z_A = "Z_A",
25
+ }
@@ -0,0 +1,47 @@
1
+ import { listProductBrand } from "@ikas/storefront-api";
2
+ import { IkasBrand } from "@ikas/storefront-models";
3
+ import { IkasBrandList, IkasBrandListSortType, IkasBrandListType } from ".";
4
+
5
+ export async function getInitial(list: IkasBrandList) {
6
+ try {
7
+ const _isStatic = isStatic(list);
8
+ const response = await listProductBrand({
9
+ id: _isStatic
10
+ ? list.brandListPropValue.brandIds
11
+ ? { in: list.brandListPropValue.brandIds }
12
+ : undefined
13
+ : undefined,
14
+ pagination: {
15
+ page: _isStatic ? undefined : list.page,
16
+ limit: _isStatic ? undefined : list.limit,
17
+ },
18
+ sort: getSortParams(list),
19
+ });
20
+
21
+ if (_isStatic) {
22
+ list.data =
23
+ (list.brandListPropValue.brandIds
24
+ ?.map((bID) => {
25
+ return response.data?.data?.find((b) => b.id === bID);
26
+ })
27
+ .filter((b) => !!b) as IkasBrand[]) || [];
28
+ } else {
29
+ list.data = response.data?.data || [];
30
+ }
31
+
32
+ list.count = response.data?.count || 0;
33
+ list.initialized = true;
34
+ list.minPage = list.page;
35
+ } catch (err) {
36
+ console.error(err);
37
+ }
38
+ }
39
+
40
+ function isStatic(list: IkasBrandList) {
41
+ return list.type === IkasBrandListType.STATIC;
42
+ }
43
+
44
+ function getSortParams(list: IkasBrandList) {
45
+ if (list.sort === IkasBrandListSortType.A_Z) return "name";
46
+ else return "-name";
47
+ }
@@ -0,0 +1,25 @@
1
+ import { IkasCategory } from "@ikas/storefront-models";
2
+ import { IkasCategoryListPropValue } from "../../prop-value/category-list";
3
+
4
+ export type IkasCategoryList = {
5
+ data: IkasCategory[];
6
+ type: IkasCategoryListType;
7
+ sort: IkasCategoryListSortType;
8
+ limit: number;
9
+ page: number;
10
+ count: number;
11
+ initialized?: boolean;
12
+ minPage?: number | null;
13
+ categoryListPropValue: IkasCategoryListPropValue;
14
+ isLoading?: boolean;
15
+ };
16
+
17
+ export enum IkasCategoryListType {
18
+ ALL = "ALL",
19
+ STATIC = "STATIC",
20
+ }
21
+
22
+ export enum IkasCategoryListSortType {
23
+ A_Z = "A_Z",
24
+ Z_A = "Z_A",
25
+ }
@@ -0,0 +1,50 @@
1
+ import { listCategory } from "@ikas/storefront-api";
2
+ import { IkasCategory } from "@ikas/storefront-models";
3
+ import {
4
+ IkasCategoryList,
5
+ IkasCategoryListSortType,
6
+ IkasCategoryListType,
7
+ } from ".";
8
+
9
+ export async function getInitial(list: IkasCategoryList) {
10
+ try {
11
+ const response = await listCategory({
12
+ id: isStatic(list)
13
+ ? list.categoryListPropValue.categoryIds
14
+ ? { in: list.categoryListPropValue.categoryIds }
15
+ : undefined
16
+ : undefined,
17
+ pagination: {
18
+ page: isStatic(list) ? undefined : list.page,
19
+ limit: isStatic(list) ? undefined : list.limit,
20
+ },
21
+ sort: getSortParams(list),
22
+ });
23
+
24
+ if (isStatic(list)) {
25
+ list.data =
26
+ (list.categoryListPropValue.categoryIds
27
+ ?.map((cID) => {
28
+ return response.data?.data?.find((c) => c.id === cID);
29
+ })
30
+ .filter((c) => !!c) as IkasCategory[]) || [];
31
+ } else {
32
+ list.data = response.data?.data || [];
33
+ }
34
+
35
+ list.count = response.data?.count || 0;
36
+ list.initialized = true;
37
+ list.minPage = list.page;
38
+ } catch (err) {
39
+ console.error(err);
40
+ }
41
+ }
42
+
43
+ function isStatic(list: IkasCategoryList) {
44
+ return list.type === IkasCategoryListType.STATIC;
45
+ }
46
+
47
+ function getSortParams(list: IkasCategoryList) {
48
+ if (list.sort === IkasCategoryListSortType.A_Z) return "name";
49
+ else return "-name";
50
+ }
@@ -0,0 +1,5 @@
1
+ type RenderFunction = () => React.ReactNode;
2
+
3
+ export type IkasComponentRenderer = {
4
+ render: RenderFunction;
5
+ };
@@ -0,0 +1,12 @@
1
+ import { IkasCustomerReview } from "@ikas/storefront-models";
2
+
3
+ export type IkasCustomerReviewList = {
4
+ data: IkasCustomerReview[];
5
+ limit: number;
6
+ page: number;
7
+ count: number;
8
+ initialized?: boolean;
9
+ minPage?: number | null;
10
+ productId: string;
11
+ isLoading?: boolean;
12
+ };
@@ -0,0 +1,33 @@
1
+ import { listCustomerReviews } from "@ikas/storefront-api";
2
+ import { IkasStorefrontConfig } from "@ikas/storefront-config";
3
+ import { IkasCustomerReviewList } from ".";
4
+
5
+ export async function getInitial(list: IkasCustomerReviewList) {
6
+ try {
7
+ const response = await _listCustomerReviews(list, list.page, list.limit);
8
+
9
+ list.data = response.data?.data || [];
10
+ list.count = response.data?.count || 0;
11
+ list.initialized = true;
12
+ list.minPage = list.page;
13
+ } catch (err) {
14
+ console.error(err);
15
+ }
16
+ }
17
+
18
+ async function _listCustomerReviews(
19
+ list: IkasCustomerReviewList,
20
+ page: number,
21
+ limit: number
22
+ ) {
23
+ return await listCustomerReviews({
24
+ productId: list.productId,
25
+ input: {
26
+ salesChannelId: IkasStorefrontConfig.getSalesChannelId() || "",
27
+ },
28
+ pagination: {
29
+ page,
30
+ limit,
31
+ },
32
+ });
33
+ }
@@ -0,0 +1,12 @@
1
+ import { IkasCustomerReviewSummary } from "@ikas/storefront-models";
2
+
3
+ export type IkasCustomerReviewSummaryList = {
4
+ data: IkasCustomerReviewSummary[];
5
+ limit: number;
6
+ page: number;
7
+ count: number;
8
+ initialized?: boolean;
9
+ minPage?: number | null;
10
+ productId: string;
11
+ isLoading?: boolean;
12
+ };
@@ -0,0 +1,33 @@
1
+ import { listCustomerReviewSummary } from "@ikas/storefront-api";
2
+ import { IkasCustomerReviewSummaryList } from ".";
3
+
4
+ export async function getInitial(list: IkasCustomerReviewSummaryList) {
5
+ try {
6
+ const response = await _listCustomerReviewSummary(
7
+ list,
8
+ list.page,
9
+ list.limit
10
+ );
11
+
12
+ list.data = response.data?.data || [];
13
+ list.count = response.data?.count || 0;
14
+ list.initialized = true;
15
+ list.minPage = list.page;
16
+ } catch (err) {
17
+ console.error(err);
18
+ }
19
+ }
20
+
21
+ async function _listCustomerReviewSummary(
22
+ list: IkasCustomerReviewSummaryList,
23
+ page: number,
24
+ limit: number
25
+ ) {
26
+ return await listCustomerReviewSummary({
27
+ productId: { eq: list.productId },
28
+ pagination: {
29
+ page,
30
+ limit,
31
+ },
32
+ });
33
+ }
@@ -0,0 +1,12 @@
1
+ export * from "./blog-category-list";
2
+ export * from "./blog-list";
3
+ export * from "./brand-list";
4
+ export * from "./category-list";
5
+ export * from "./component-renderer";
6
+ export * from "./customer-review-list";
7
+ export * from "./customer-review-summary-list";
8
+ export * from "./navigation-link";
9
+ export * from "./product-attribute-detail";
10
+ export * from "./product-attribute-list";
11
+ export * from "./product-list";
12
+ export * from "./raffle-list";
@@ -0,0 +1,7 @@
1
+ export type IkasNavigationLink = {
2
+ href: string;
3
+ label: string;
4
+ subLinks: IkasNavigationLink[];
5
+ isExternal?: boolean | null;
6
+ itemId?: string;
7
+ };