@ikas/storefront-providers 4.0.0-alpha.78 → 4.0.0-alpha.8
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 +12 -13
- package/{build/index.d.ts → src/index.ts} +22 -20
- package/src/models/prop-value/attribute-list.ts +8 -0
- package/src/models/prop-value/attribute.ts +8 -0
- package/src/models/prop-value/blog-category-list.ts +9 -0
- package/src/models/prop-value/blog-category.ts +6 -0
- package/src/models/prop-value/blog-list.ts +13 -0
- package/src/models/prop-value/blog.ts +6 -0
- package/src/models/prop-value/brand-list.ts +11 -0
- package/src/models/prop-value/brand.ts +6 -0
- package/src/models/prop-value/category-list.ts +11 -0
- package/src/models/prop-value/category.ts +6 -0
- package/src/models/prop-value/link.ts +22 -0
- package/src/models/prop-value/product-list.ts +29 -0
- package/src/models/prop-value/product.ts +7 -0
- package/src/models/prop-value/raffle-list.ts +6 -0
- package/src/models/prop-value/raffle.ts +6 -0
- package/src/models/ui/blog-category-list/index.ts +19 -0
- package/src/models/ui/blog-category-list/init.ts +54 -0
- package/src/models/ui/blog-list/index.ts +21 -0
- package/src/models/ui/blog-list/init.ts +49 -0
- package/src/models/ui/brand-list/index.ts +25 -0
- package/src/models/ui/brand-list/init.ts +47 -0
- package/src/models/ui/category-list/index.ts +25 -0
- package/src/models/ui/category-list/init.ts +50 -0
- package/src/models/ui/component-renderer/index.ts +5 -0
- package/src/models/ui/customer-review-list/index.ts +12 -0
- package/src/models/ui/customer-review-list/init.ts +33 -0
- package/src/models/ui/customer-review-summary-list/index.ts +12 -0
- package/src/models/ui/customer-review-summary-list/init.ts +33 -0
- package/{build/models/ui/index.d.ts → src/models/ui/index.ts} +12 -12
- package/src/models/ui/navigation-link/index.ts +7 -0
- package/src/models/ui/product-attribute-detail/index.ts +7 -0
- package/src/models/ui/product-attribute-list/index.ts +7 -0
- package/src/models/ui/product-list/index.ts +80 -0
- package/src/models/ui/product-list/init.ts +407 -0
- package/src/models/ui/raffle-list/index.ts +17 -0
- package/src/models/ui/raffle-list/init.ts +44 -0
- package/src/providers/helpers/raffle.ts +69 -0
- package/src/providers/page-data-get.ts +708 -0
- package/src/providers/placeholders.ts +138 -0
- package/src/providers/prop-value/attribute-list.ts +75 -0
- package/src/providers/prop-value/attribute.ts +77 -0
- package/src/providers/prop-value/blog-category-list.ts +29 -0
- package/src/providers/prop-value/blog-category.ts +49 -0
- package/src/providers/prop-value/blog-list.ts +61 -0
- package/src/providers/prop-value/blog.ts +41 -0
- package/src/providers/prop-value/boolean.ts +14 -0
- package/src/providers/prop-value/brand-list.ts +30 -0
- package/src/providers/prop-value/brand.ts +46 -0
- package/src/providers/prop-value/category-list.ts +31 -0
- package/src/providers/prop-value/category.ts +45 -0
- package/src/providers/prop-value/color.ts +14 -0
- package/src/providers/prop-value/custom.ts +560 -0
- package/src/providers/prop-value/image-list.ts +16 -0
- package/src/providers/prop-value/image.ts +16 -0
- package/{build/providers/prop-value/index.d.ts → src/providers/prop-value/index.ts} +3 -3
- package/src/providers/prop-value/link.ts +259 -0
- package/src/providers/prop-value/product-detail.ts +92 -0
- package/src/providers/prop-value/product-list.ts +124 -0
- package/src/providers/prop-value/raffle-list.ts +20 -0
- package/src/providers/prop-value/raffle.ts +41 -0
- package/src/providers/prop-value/rich-text.ts +14 -0
- package/src/providers/prop-value/slider.ts +19 -0
- package/src/providers/prop-value/text.ts +14 -0
- package/src/providers/types.ts +88 -0
- package/build/ext/tslib/tslib.es6.js +0 -1
- package/build/index.js +0 -1
- package/build/models/prop-value/attribute-list.d.ts +0 -6
- package/build/models/prop-value/attribute.d.ts +0 -6
- package/build/models/prop-value/blog-category-list.d.ts +0 -6
- package/build/models/prop-value/blog-category.d.ts +0 -4
- package/build/models/prop-value/blog-list.d.ts +0 -8
- package/build/models/prop-value/blog.d.ts +0 -4
- package/build/models/prop-value/brand-list.d.ts +0 -8
- package/build/models/prop-value/brand.d.ts +0 -4
- package/build/models/prop-value/brand.js +0 -1
- package/build/models/prop-value/category-list.d.ts +0 -8
- package/build/models/prop-value/category.d.ts +0 -4
- package/build/models/prop-value/link.d.ts +0 -18
- package/build/models/prop-value/link.js +0 -1
- package/build/models/prop-value/product-list.d.ts +0 -17
- package/build/models/prop-value/product.d.ts +0 -5
- package/build/models/prop-value/raffle-list.d.ts +0 -4
- package/build/models/prop-value/raffle.d.ts +0 -4
- package/build/models/ui/blog-category-list/index.d.ts +0 -17
- package/build/models/ui/blog-category-list/index.js +0 -1
- package/build/models/ui/blog-category-list/init.d.ts +0 -2
- package/build/models/ui/blog-category-list/init.js +0 -1
- package/build/models/ui/blog-list/index.d.ts +0 -19
- package/build/models/ui/blog-list/index.js +0 -1
- package/build/models/ui/blog-list/init.d.ts +0 -2
- package/build/models/ui/blog-list/init.js +0 -1
- package/build/models/ui/brand-list/index.d.ts +0 -22
- package/build/models/ui/brand-list/index.js +0 -1
- package/build/models/ui/brand-list/init.d.ts +0 -2
- package/build/models/ui/brand-list/init.js +0 -1
- package/build/models/ui/category-list/index.d.ts +0 -22
- package/build/models/ui/category-list/index.js +0 -1
- package/build/models/ui/category-list/init.d.ts +0 -2
- package/build/models/ui/category-list/init.js +0 -1
- package/build/models/ui/component-renderer/index.d.ts +0 -6
- package/build/models/ui/customer-review-list/index.d.ts +0 -11
- package/build/models/ui/customer-review-list/init.d.ts +0 -2
- package/build/models/ui/customer-review-summary-list/index.d.ts +0 -11
- package/build/models/ui/customer-review-summary-list/init.d.ts +0 -2
- package/build/models/ui/navigation-link/index.d.ts +0 -7
- package/build/models/ui/product-attribute-detail/index.d.ts +0 -6
- package/build/models/ui/product-attribute-list/index.d.ts +0 -6
- package/build/models/ui/product-list/index.d.ts +0 -64
- package/build/models/ui/product-list/index.js +0 -1
- package/build/models/ui/product-list/init.d.ts +0 -2
- package/build/models/ui/product-list/init.js +0 -1
- package/build/models/ui/raffle-list/index.d.ts +0 -16
- package/build/models/ui/raffle-list/init.d.ts +0 -2
- package/build/models/ui/raffle-list/init.js +0 -1
- package/build/providers/helpers/raffle.d.ts +0 -3
- package/build/providers/helpers/raffle.js +0 -1
- package/build/providers/page-data-get.d.ts +0 -31
- package/build/providers/page-data-get.js +0 -1
- package/build/providers/placeholders.d.ts +0 -7
- package/build/providers/placeholders.js +0 -1
- package/build/providers/prop-value/attribute-list.d.ts +0 -8
- package/build/providers/prop-value/attribute-list.js +0 -1
- package/build/providers/prop-value/attribute.d.ts +0 -8
- package/build/providers/prop-value/attribute.js +0 -1
- package/build/providers/prop-value/blog-category-list.d.ts +0 -8
- package/build/providers/prop-value/blog-category-list.js +0 -1
- package/build/providers/prop-value/blog-category.d.ts +0 -8
- package/build/providers/prop-value/blog-category.js +0 -1
- package/build/providers/prop-value/blog-list.d.ts +0 -11
- package/build/providers/prop-value/blog-list.js +0 -1
- package/build/providers/prop-value/blog.d.ts +0 -8
- package/build/providers/prop-value/blog.js +0 -1
- package/build/providers/prop-value/boolean.d.ts +0 -6
- package/build/providers/prop-value/boolean.js +0 -1
- package/build/providers/prop-value/brand-list.d.ts +0 -8
- package/build/providers/prop-value/brand-list.js +0 -1
- package/build/providers/prop-value/brand.d.ts +0 -8
- package/build/providers/prop-value/brand.js +0 -1
- package/build/providers/prop-value/category-list.d.ts +0 -8
- package/build/providers/prop-value/category-list.js +0 -1
- package/build/providers/prop-value/category.d.ts +0 -8
- package/build/providers/prop-value/category.js +0 -1
- package/build/providers/prop-value/color.d.ts +0 -6
- package/build/providers/prop-value/color.js +0 -1
- package/build/providers/prop-value/custom.d.ts +0 -42
- package/build/providers/prop-value/custom.js +0 -1
- package/build/providers/prop-value/image-list.d.ts +0 -7
- package/build/providers/prop-value/image-list.js +0 -1
- package/build/providers/prop-value/image.d.ts +0 -7
- package/build/providers/prop-value/image.js +0 -1
- package/build/providers/prop-value/link.d.ts +0 -26
- package/build/providers/prop-value/link.js +0 -1
- package/build/providers/prop-value/product-detail.d.ts +0 -8
- package/build/providers/prop-value/product-detail.js +0 -1
- package/build/providers/prop-value/product-list.d.ts +0 -17
- package/build/providers/prop-value/product-list.js +0 -1
- package/build/providers/prop-value/raffle-list.d.ts +0 -5
- package/build/providers/prop-value/raffle-list.js +0 -1
- package/build/providers/prop-value/raffle.d.ts +0 -8
- package/build/providers/prop-value/raffle.js +0 -1
- package/build/providers/prop-value/rich-text.d.ts +0 -6
- package/build/providers/prop-value/rich-text.js +0 -1
- package/build/providers/prop-value/slider.d.ts +0 -7
- package/build/providers/prop-value/slider.js +0 -1
- package/build/providers/prop-value/text.d.ts +0 -6
- package/build/providers/prop-value/text.js +0 -1
- package/build/providers/types.d.ts +0 -66
- package/build/providers/types.js +0 -1
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IkasBlog,
|
|
3
|
+
IkasBlogCategory,
|
|
4
|
+
IkasBlogMetaData,
|
|
5
|
+
IkasBrand,
|
|
6
|
+
IkasCategory,
|
|
7
|
+
IkasProduct,
|
|
8
|
+
IkasProductType,
|
|
9
|
+
IkasRaffle,
|
|
10
|
+
IkasRaffleVerificationType,
|
|
11
|
+
} from "@ikas/storefront-models";
|
|
12
|
+
|
|
13
|
+
export function getPlaceholderProduct() {
|
|
14
|
+
const product: IkasProduct = {
|
|
15
|
+
id: "",
|
|
16
|
+
name: "",
|
|
17
|
+
type: IkasProductType.PHYSICAL,
|
|
18
|
+
description: "",
|
|
19
|
+
shortDescription: "",
|
|
20
|
+
metaData: null,
|
|
21
|
+
brand: null,
|
|
22
|
+
categories: [],
|
|
23
|
+
tags: [],
|
|
24
|
+
variants: [],
|
|
25
|
+
attributes: [],
|
|
26
|
+
variantTypes: [],
|
|
27
|
+
productOptionSetId: null,
|
|
28
|
+
};
|
|
29
|
+
return product;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getPlaceholderCategory() {
|
|
33
|
+
const category: IkasCategory = {
|
|
34
|
+
categoryPath: [],
|
|
35
|
+
description: null,
|
|
36
|
+
imageId: null,
|
|
37
|
+
name: "",
|
|
38
|
+
parentId: null,
|
|
39
|
+
metaData: null,
|
|
40
|
+
categoryPathItems: [],
|
|
41
|
+
orderType: null,
|
|
42
|
+
id: "",
|
|
43
|
+
createdAt: 0,
|
|
44
|
+
updatedAt: 0,
|
|
45
|
+
};
|
|
46
|
+
return category;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function getPlaceholderBrand() {
|
|
50
|
+
const brand: IkasBrand = {
|
|
51
|
+
description: null,
|
|
52
|
+
imageId: null,
|
|
53
|
+
metaData: null,
|
|
54
|
+
orderType: null,
|
|
55
|
+
name: "",
|
|
56
|
+
id: "",
|
|
57
|
+
createdAt: 0,
|
|
58
|
+
updatedAt: 0,
|
|
59
|
+
};
|
|
60
|
+
return brand;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function getPlaceholderBlog() {
|
|
64
|
+
const blog: IkasBlog = {
|
|
65
|
+
createdAt: 0,
|
|
66
|
+
id: "",
|
|
67
|
+
updatedAt: 0,
|
|
68
|
+
blogContent: {
|
|
69
|
+
content: "",
|
|
70
|
+
createdAt: 0,
|
|
71
|
+
id: "",
|
|
72
|
+
updatedAt: 0,
|
|
73
|
+
},
|
|
74
|
+
categoryId: "",
|
|
75
|
+
imageId: "",
|
|
76
|
+
isPublished: false,
|
|
77
|
+
locale: null,
|
|
78
|
+
metadata: getPlaceholderBlogMetaData(),
|
|
79
|
+
publishedAt: null,
|
|
80
|
+
shortDescription: "",
|
|
81
|
+
storefrontId: "",
|
|
82
|
+
tagIds: [],
|
|
83
|
+
tags: [],
|
|
84
|
+
title: "",
|
|
85
|
+
writer: {
|
|
86
|
+
firstName: "",
|
|
87
|
+
lastName: "",
|
|
88
|
+
},
|
|
89
|
+
category: getPlaceholderBlogCategory(),
|
|
90
|
+
};
|
|
91
|
+
return blog;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export function getPlaceholderBlogCategory() {
|
|
95
|
+
const blogCategory: IkasBlogCategory = {
|
|
96
|
+
createdAt: 0,
|
|
97
|
+
id: "",
|
|
98
|
+
updatedAt: 0,
|
|
99
|
+
imageId: "",
|
|
100
|
+
metadata: getPlaceholderBlogMetaData(),
|
|
101
|
+
name: "",
|
|
102
|
+
};
|
|
103
|
+
return blogCategory;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function getPlaceholderRaffle(): IkasRaffle {
|
|
107
|
+
return {
|
|
108
|
+
createdAt: 0,
|
|
109
|
+
id: "",
|
|
110
|
+
updatedAt: 0,
|
|
111
|
+
deleted: false,
|
|
112
|
+
dateRange: null,
|
|
113
|
+
metadata: null,
|
|
114
|
+
name: "",
|
|
115
|
+
participantCount: null,
|
|
116
|
+
requiredCustomerAccount: false,
|
|
117
|
+
status: false,
|
|
118
|
+
variants: [],
|
|
119
|
+
products: [],
|
|
120
|
+
verificationType: IkasRaffleVerificationType.EMAIL,
|
|
121
|
+
isCustomerWinner: false,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function getPlaceholderBlogMetaData(): IkasBlogMetaData {
|
|
126
|
+
return {
|
|
127
|
+
canonicals: [],
|
|
128
|
+
description: "",
|
|
129
|
+
disableIndex: false,
|
|
130
|
+
pageTitle: null,
|
|
131
|
+
slug: "",
|
|
132
|
+
targetId: null,
|
|
133
|
+
targetType: null,
|
|
134
|
+
createdAt: 0,
|
|
135
|
+
id: "",
|
|
136
|
+
updatedAt: 0,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import IkasPropValueProvider from ".";
|
|
2
|
+
import { IkasProduct } from "@ikas/storefront-models";
|
|
3
|
+
import { searchProducts } from "@ikas/storefront-api";
|
|
4
|
+
import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
5
|
+
import { IkasAttributeListPropValue } from "../../models/prop-value/attribute-list";
|
|
6
|
+
import { IkasProductFunctions } from "@ikas/storefront-model-functions";
|
|
7
|
+
import { IkasAttributeListPropValueData } from "../types";
|
|
8
|
+
|
|
9
|
+
export class IkasAttributeListPropValueProvider
|
|
10
|
+
implements IkasPropValueProvider<IkasAttributeListPropValueData>
|
|
11
|
+
{
|
|
12
|
+
private attributeListPropValue: IkasAttributeListPropValue;
|
|
13
|
+
|
|
14
|
+
constructor(prop: IkasAttributeListPropValue) {
|
|
15
|
+
this.attributeListPropValue = prop;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async getValue(): Promise<IkasAttributeListPropValueData> {
|
|
19
|
+
if (
|
|
20
|
+
!this.attributeListPropValue.attributeIds?.length ||
|
|
21
|
+
this.attributeListPropValue.usePageData ||
|
|
22
|
+
(!this.attributeListPropValue.usePageData &&
|
|
23
|
+
!this.attributeListPropValue.variantId)
|
|
24
|
+
) {
|
|
25
|
+
return {
|
|
26
|
+
productDetail: null,
|
|
27
|
+
attributeListPropValue: this.attributeListPropValue,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let productDetail: IkasProduct | undefined;
|
|
32
|
+
|
|
33
|
+
const productSearchResponse = await searchProducts({
|
|
34
|
+
input: {
|
|
35
|
+
productIdList: [this.attributeListPropValue.productId!],
|
|
36
|
+
priceListId: IkasStorefrontConfig.getPriceListId(),
|
|
37
|
+
salesChannelId: IkasStorefrontConfig.getSalesChannelId(),
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
if (productSearchResponse.isSuccess && productSearchResponse.data?.data) {
|
|
42
|
+
const productList = productSearchResponse.data.data;
|
|
43
|
+
const { hasVariant } = IkasProductFunctions;
|
|
44
|
+
|
|
45
|
+
if (productList.length) {
|
|
46
|
+
const product = productList[0];
|
|
47
|
+
|
|
48
|
+
if (product && hasVariant(product)) {
|
|
49
|
+
const variant = product.variants.find(
|
|
50
|
+
(v) => v.id === this.attributeListPropValue.variantId
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
if (variant) {
|
|
54
|
+
//@ts-ignore
|
|
55
|
+
product.selectedVariantValues = variant.variantValues;
|
|
56
|
+
productDetail = product;
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
const selectedVariant = product.variants.find((v) => v.isActive);
|
|
60
|
+
//@ts-ignore
|
|
61
|
+
product.selectedVariantValues = (
|
|
62
|
+
selectedVariant || product.variants[0]
|
|
63
|
+
).variantValues;
|
|
64
|
+
|
|
65
|
+
productDetail = product;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
productDetail: productDetail || null,
|
|
72
|
+
attributeListPropValue: this.attributeListPropValue,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { searchProducts } from "@ikas/storefront-api";
|
|
2
|
+
import { IkasStorefrontConfig } from "@ikas/storefront-config";
|
|
3
|
+
import { IkasProduct } from "@ikas/storefront-models";
|
|
4
|
+
import IkasPropValueProvider from ".";
|
|
5
|
+
import { IkasAttributePropValue } from "../../models/prop-value/attribute";
|
|
6
|
+
import { IkasProductFunctions } from "@ikas/storefront-model-functions";
|
|
7
|
+
import {
|
|
8
|
+
IkasAttributePropValueData,
|
|
9
|
+
IkasProductPropValueProduct,
|
|
10
|
+
} from "../types";
|
|
11
|
+
|
|
12
|
+
export class IkasAttributePropValueProvider
|
|
13
|
+
implements IkasPropValueProvider<IkasAttributePropValueData>
|
|
14
|
+
{
|
|
15
|
+
private attributePropValue: IkasAttributePropValue;
|
|
16
|
+
|
|
17
|
+
constructor(prop: IkasAttributePropValue) {
|
|
18
|
+
this.attributePropValue = prop;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async getValue(): Promise<IkasAttributePropValueData> {
|
|
22
|
+
if (
|
|
23
|
+
!this.attributePropValue.attributeId ||
|
|
24
|
+
this.attributePropValue?.usePageData ||
|
|
25
|
+
(!this.attributePropValue.usePageData &&
|
|
26
|
+
!this.attributePropValue.variantId)
|
|
27
|
+
) {
|
|
28
|
+
return {
|
|
29
|
+
productDetail: null,
|
|
30
|
+
attributePropValue: this.attributePropValue,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let productDetail: IkasProduct | undefined;
|
|
35
|
+
|
|
36
|
+
const productSearchResponse = await searchProducts({
|
|
37
|
+
input: {
|
|
38
|
+
productIdList: [this.attributePropValue.productId!],
|
|
39
|
+
priceListId: IkasStorefrontConfig.getPriceListId(),
|
|
40
|
+
salesChannelId: IkasStorefrontConfig.getSalesChannelId(),
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
if (productSearchResponse.isSuccess && productSearchResponse.data?.data) {
|
|
45
|
+
const productList: IkasProductPropValueProduct[] =
|
|
46
|
+
productSearchResponse.data.data;
|
|
47
|
+
|
|
48
|
+
if (productList.length) {
|
|
49
|
+
const product = productList[0];
|
|
50
|
+
const { hasVariant } = IkasProductFunctions;
|
|
51
|
+
|
|
52
|
+
if (product && hasVariant(product)) {
|
|
53
|
+
const variant = product.variants.find(
|
|
54
|
+
(v) => v.id === this.attributePropValue.variantId
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
if (variant) {
|
|
58
|
+
product.selectedVariantValues = variant.variantValues;
|
|
59
|
+
productDetail = product;
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
const selectedVariant = product.variants.find((v) => v.isActive);
|
|
63
|
+
product.selectedVariantValues = (
|
|
64
|
+
selectedVariant || product.variants[0]
|
|
65
|
+
).variantValues;
|
|
66
|
+
|
|
67
|
+
productDetail = product;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
productDetail: productDetail || null,
|
|
74
|
+
attributePropValue: this.attributePropValue,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import IkasPropValueProvider from ".";
|
|
2
|
+
import { IkasBlogCategoryListPropValue } from "../../models/prop-value/blog-category-list";
|
|
3
|
+
import { IkasBlogCategoryList } from "../../models/ui";
|
|
4
|
+
import { getInitial } from "../../models/ui/blog-category-list/init";
|
|
5
|
+
|
|
6
|
+
export class IkasBlogCategoryListPropValueProvider
|
|
7
|
+
implements IkasPropValueProvider<IkasBlogCategoryList>
|
|
8
|
+
{
|
|
9
|
+
private blogCategoryListPropValue: IkasBlogCategoryListPropValue;
|
|
10
|
+
|
|
11
|
+
constructor(blogCategoryListPropValue: IkasBlogCategoryListPropValue) {
|
|
12
|
+
this.blogCategoryListPropValue = blogCategoryListPropValue;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async getValue(): Promise<IkasBlogCategoryList> {
|
|
16
|
+
const blogCategoryList: IkasBlogCategoryList = {
|
|
17
|
+
data: [],
|
|
18
|
+
count: 0,
|
|
19
|
+
page: 1,
|
|
20
|
+
limit: 10,
|
|
21
|
+
blogCategoryListPropValue: this.blogCategoryListPropValue,
|
|
22
|
+
type: this.blogCategoryListPropValue.blogCategoryListType,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
await getInitial(blogCategoryList);
|
|
26
|
+
|
|
27
|
+
return blogCategoryList;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { listBlogCategory } from "@ikas/storefront-api";
|
|
2
|
+
import IkasPropValueProvider from ".";
|
|
3
|
+
import { IkasBlogCategoryPropValue } from "../../models/prop-value/blog-category";
|
|
4
|
+
import { getPlaceholderBlogCategory } from "../placeholders";
|
|
5
|
+
import { IkasBlogCategoryPropValueData } from "../types";
|
|
6
|
+
|
|
7
|
+
export class IkasBlogCategoryPropValueProvider
|
|
8
|
+
implements IkasPropValueProvider<IkasBlogCategoryPropValueData | null>
|
|
9
|
+
{
|
|
10
|
+
private blogCategoryPropValue: IkasBlogCategoryPropValue;
|
|
11
|
+
|
|
12
|
+
constructor(propValue: IkasBlogCategoryPropValue) {
|
|
13
|
+
this.blogCategoryPropValue = propValue;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async getValue(): Promise<IkasBlogCategoryPropValueData | null> {
|
|
17
|
+
if (this.blogCategoryPropValue?.usePageData) {
|
|
18
|
+
return {
|
|
19
|
+
blogCategory: null,
|
|
20
|
+
blogCategoryPropValue: this.blogCategoryPropValue,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (!this.blogCategoryPropValue.blogCategoryId) return null;
|
|
24
|
+
|
|
25
|
+
const listBlogCategoryResponse = await listBlogCategory({
|
|
26
|
+
id: { eq: this.blogCategoryPropValue.blogCategoryId },
|
|
27
|
+
pagination: {
|
|
28
|
+
page: 1,
|
|
29
|
+
limit: 1,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
if (
|
|
34
|
+
listBlogCategoryResponse.isSuccess &&
|
|
35
|
+
listBlogCategoryResponse.data?.data
|
|
36
|
+
) {
|
|
37
|
+
return {
|
|
38
|
+
blogCategory:
|
|
39
|
+
listBlogCategoryResponse.data.data[0] || getPlaceholderBlogCategory(),
|
|
40
|
+
blogCategoryPropValue: this.blogCategoryPropValue,
|
|
41
|
+
};
|
|
42
|
+
} else {
|
|
43
|
+
return {
|
|
44
|
+
blogCategory: getPlaceholderBlogCategory(),
|
|
45
|
+
blogCategoryPropValue: this.blogCategoryPropValue,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
IkasBlogCategory,
|
|
3
|
+
IkasThemeJsonPageType,
|
|
4
|
+
} from "@ikas/storefront-models";
|
|
5
|
+
import IkasPropValueProvider from ".";
|
|
6
|
+
import { IkasBlogListPropValue } from "../../models/prop-value/blog-list";
|
|
7
|
+
import { IkasBlogList, IkasBlogListType } from "../../models/ui";
|
|
8
|
+
import { getInitial } from "../../models/ui/blog-list/init";
|
|
9
|
+
|
|
10
|
+
export class IkasBlogListPropValueProvider
|
|
11
|
+
implements IkasPropValueProvider<IkasBlogList>
|
|
12
|
+
{
|
|
13
|
+
private pageType: IkasThemeJsonPageType;
|
|
14
|
+
private blogListPropValue: IkasBlogListPropValue;
|
|
15
|
+
private pageSpecificData?: any;
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
pageType: IkasThemeJsonPageType,
|
|
19
|
+
blogListPropValue: IkasBlogListPropValue,
|
|
20
|
+
pageSpecificData?: any
|
|
21
|
+
) {
|
|
22
|
+
this.pageType = pageType;
|
|
23
|
+
this.blogListPropValue = blogListPropValue;
|
|
24
|
+
this.pageSpecificData = pageSpecificData;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async getValue(): Promise<IkasBlogList> {
|
|
28
|
+
let filterCategoryId: string | null = null;
|
|
29
|
+
|
|
30
|
+
if (
|
|
31
|
+
this.blogListPropValue.blogListType === IkasBlogListType.ALL &&
|
|
32
|
+
this.blogListPropValue.usePageFilter &&
|
|
33
|
+
this.pageType === IkasThemeJsonPageType.BLOG_CATEGORY &&
|
|
34
|
+
this.pageSpecificData
|
|
35
|
+
) {
|
|
36
|
+
const blogCategory = this.pageSpecificData as IkasBlogCategory;
|
|
37
|
+
filterCategoryId = blogCategory.id;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (
|
|
41
|
+
this.blogListPropValue.blogListType === IkasBlogListType.CATEGORY &&
|
|
42
|
+
this.blogListPropValue.categoryId
|
|
43
|
+
) {
|
|
44
|
+
filterCategoryId = this.blogListPropValue.categoryId;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const blogList: IkasBlogList = {
|
|
48
|
+
data: [],
|
|
49
|
+
count: 0,
|
|
50
|
+
type: this.blogListPropValue.blogListType,
|
|
51
|
+
page: 1,
|
|
52
|
+
limit: this.blogListPropValue.initialLimit || 10,
|
|
53
|
+
blogListPropValue: this.blogListPropValue,
|
|
54
|
+
filterCategoryId,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
await getInitial(blogList);
|
|
58
|
+
|
|
59
|
+
return blogList;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { listBlog } from "@ikas/storefront-api";
|
|
2
|
+
import IkasPropValueProvider from ".";
|
|
3
|
+
import { IkasBlogPropValue } from "../../models/prop-value/blog";
|
|
4
|
+
import { getPlaceholderBlog } from "../placeholders";
|
|
5
|
+
import { IkasBlogPropValueData } from "../types";
|
|
6
|
+
|
|
7
|
+
export class IkasBlogPropValueProvider
|
|
8
|
+
implements IkasPropValueProvider<IkasBlogPropValueData | null>
|
|
9
|
+
{
|
|
10
|
+
private blogPropValue: IkasBlogPropValue;
|
|
11
|
+
|
|
12
|
+
constructor(propValue: IkasBlogPropValue) {
|
|
13
|
+
this.blogPropValue = propValue;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async getValue(): Promise<IkasBlogPropValueData | null> {
|
|
17
|
+
if (this.blogPropValue?.usePageData) {
|
|
18
|
+
return {
|
|
19
|
+
blog: null,
|
|
20
|
+
blogPropValue: this.blogPropValue,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (!this.blogPropValue.blogId) return null;
|
|
24
|
+
|
|
25
|
+
const listBlogResponse = await listBlog({
|
|
26
|
+
id: { eq: this.blogPropValue.blogId },
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
if (listBlogResponse.isSuccess && listBlogResponse.data?.data?.length) {
|
|
30
|
+
return {
|
|
31
|
+
blog: listBlogResponse.data.data[0] || getPlaceholderBlog(),
|
|
32
|
+
blogPropValue: this.blogPropValue,
|
|
33
|
+
};
|
|
34
|
+
} else {
|
|
35
|
+
return {
|
|
36
|
+
blog: getPlaceholderBlog(),
|
|
37
|
+
blogPropValue: this.blogPropValue,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import IkasPropValueProvider from ".";
|
|
2
|
+
|
|
3
|
+
export class IkasBooleanPropValueProvider
|
|
4
|
+
implements IkasPropValueProvider<boolean> {
|
|
5
|
+
private bool: boolean;
|
|
6
|
+
|
|
7
|
+
constructor(boolPropValue: boolean) {
|
|
8
|
+
this.bool = boolPropValue;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async getValue(): Promise<boolean> {
|
|
12
|
+
return this.bool || false;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import IkasPropValueProvider from ".";
|
|
2
|
+
import { IkasBrandListPropValue } from "../../models/prop-value/brand-list";
|
|
3
|
+
import { IkasBrandList, IkasBrandListSortType } from "../../models/ui";
|
|
4
|
+
import { getInitial } from "../../models/ui/brand-list/init";
|
|
5
|
+
|
|
6
|
+
export class IkasBrandListPropValueProvider
|
|
7
|
+
implements IkasPropValueProvider<IkasBrandList>
|
|
8
|
+
{
|
|
9
|
+
private brandListPropValue: IkasBrandListPropValue;
|
|
10
|
+
|
|
11
|
+
constructor(brandListPropValue: IkasBrandListPropValue) {
|
|
12
|
+
this.brandListPropValue = brandListPropValue;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async getValue(): Promise<IkasBrandList> {
|
|
16
|
+
const brandList: IkasBrandList = {
|
|
17
|
+
data: [],
|
|
18
|
+
count: 0,
|
|
19
|
+
type: this.brandListPropValue.brandListType,
|
|
20
|
+
sort: this.brandListPropValue.initialSort || IkasBrandListSortType.A_Z,
|
|
21
|
+
page: 1,
|
|
22
|
+
limit: this.brandListPropValue.initialLimit || 10,
|
|
23
|
+
brandListPropValue: this.brandListPropValue,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
await getInitial(brandList);
|
|
27
|
+
|
|
28
|
+
return brandList;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { listProductBrand } from "@ikas/storefront-api";
|
|
2
|
+
import IkasPropValueProvider from ".";
|
|
3
|
+
import { IkasBrandPropValue } from "../../models/prop-value/brand";
|
|
4
|
+
import { getPlaceholderBrand } from "../placeholders";
|
|
5
|
+
import { IkasBrandPropValueData } from "../types";
|
|
6
|
+
|
|
7
|
+
export class IkasBrandPropValueProvider
|
|
8
|
+
implements IkasPropValueProvider<IkasBrandPropValueData | null>
|
|
9
|
+
{
|
|
10
|
+
private brandPropValue: IkasBrandPropValue;
|
|
11
|
+
|
|
12
|
+
constructor(prop: IkasBrandPropValue) {
|
|
13
|
+
this.brandPropValue = prop;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async getValue(): Promise<IkasBrandPropValueData | null> {
|
|
17
|
+
if (this.brandPropValue.usePageData) {
|
|
18
|
+
return {
|
|
19
|
+
brand: null,
|
|
20
|
+
brandPropValue: this.brandPropValue,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (!this.brandPropValue.brandId) return null;
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
const listBrandResponse = await listProductBrand({
|
|
27
|
+
id: { eq: this.brandPropValue.brandId },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
if (listBrandResponse.isSuccess && listBrandResponse.data?.data) {
|
|
31
|
+
const brand = listBrandResponse.data.data.length
|
|
32
|
+
? listBrandResponse.data.data[0]
|
|
33
|
+
: getPlaceholderBrand();
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
brand,
|
|
37
|
+
brandPropValue: this.brandPropValue,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
} catch (err) {
|
|
41
|
+
console.log(err);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import IkasPropValueProvider from ".";
|
|
2
|
+
import { IkasCategoryListPropValue } from "../../models/prop-value/category-list";
|
|
3
|
+
import { IkasCategoryList, IkasCategoryListSortType } from "../../models/ui";
|
|
4
|
+
import { getInitial } from "../../models/ui/category-list/init";
|
|
5
|
+
|
|
6
|
+
export class IkasCategoryListPropValueProvider
|
|
7
|
+
implements IkasPropValueProvider<IkasCategoryList>
|
|
8
|
+
{
|
|
9
|
+
private categoryListPropValue: IkasCategoryListPropValue;
|
|
10
|
+
|
|
11
|
+
constructor(categoryListPropValue: IkasCategoryListPropValue) {
|
|
12
|
+
this.categoryListPropValue = categoryListPropValue;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async getValue(): Promise<IkasCategoryList> {
|
|
16
|
+
const categoryList: IkasCategoryList = {
|
|
17
|
+
data: [],
|
|
18
|
+
count: 0,
|
|
19
|
+
type: this.categoryListPropValue.categoryListType,
|
|
20
|
+
sort:
|
|
21
|
+
this.categoryListPropValue.initialSort || IkasCategoryListSortType.A_Z,
|
|
22
|
+
page: 1,
|
|
23
|
+
limit: this.categoryListPropValue.initialLimit || 10,
|
|
24
|
+
categoryListPropValue: this.categoryListPropValue,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
await getInitial(categoryList);
|
|
28
|
+
|
|
29
|
+
return categoryList;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { listCategory } from "@ikas/storefront-api";
|
|
2
|
+
import { IkasCategory } from "@ikas/storefront-models";
|
|
3
|
+
import IkasPropValueProvider from ".";
|
|
4
|
+
import { IkasCategoryPropValue } from "../../models/prop-value/category";
|
|
5
|
+
import { getPlaceholderCategory } from "../placeholders";
|
|
6
|
+
import { IkasCategoryPropValueData } from "../types";
|
|
7
|
+
|
|
8
|
+
export class IkasCategoryPropValueProvider
|
|
9
|
+
implements IkasPropValueProvider<IkasCategoryPropValueData | null>
|
|
10
|
+
{
|
|
11
|
+
private categoryPropValue: IkasCategoryPropValue;
|
|
12
|
+
|
|
13
|
+
constructor(prop: IkasCategoryPropValue) {
|
|
14
|
+
this.categoryPropValue = prop;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async getValue(): Promise<IkasCategoryPropValueData | null> {
|
|
18
|
+
if (this.categoryPropValue.usePageData) {
|
|
19
|
+
return {
|
|
20
|
+
category: null,
|
|
21
|
+
categoryPropValue: this.categoryPropValue,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (!this.categoryPropValue.categoryId) return null;
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const response = await listCategory({
|
|
28
|
+
id: { eq: this.categoryPropValue.categoryId },
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const category: IkasCategory = response.data?.data?.length
|
|
32
|
+
? response.data.data[0]
|
|
33
|
+
: getPlaceholderCategory();
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
category,
|
|
37
|
+
categoryPropValue: this.categoryPropValue,
|
|
38
|
+
};
|
|
39
|
+
} catch (err) {
|
|
40
|
+
console.log(err);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import IkasPropValueProvider from ".";
|
|
2
|
+
|
|
3
|
+
export class IkasColorPropValueProvider
|
|
4
|
+
implements IkasPropValueProvider<string> {
|
|
5
|
+
private color: string;
|
|
6
|
+
|
|
7
|
+
constructor(colorPropValue: string) {
|
|
8
|
+
this.color = colorPropValue;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async getValue(): Promise<string> {
|
|
12
|
+
return this.color;
|
|
13
|
+
}
|
|
14
|
+
}
|