tee3apps-cms-sdk-react 0.0.31 → 0.0.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/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/PageComponents/BoxComponent.tsx +99 -98
- package/src/PageComponents/Visual-Components/GroupImageList.tsx +73 -71
- package/src/PageComponents/Visual-Components/GroupProductComponent.tsx +239 -238
- package/src/PageComponents/Visual-Components/Styles/ProductListViewOne.tsx +34 -33
- package/src/PageComponents/Visual-Components/Styles/ProductListViewTwo.tsx +30 -28
- package/src/PageComponents/Visual-Components/TextComponent.tsx +3 -1
|
@@ -5,12 +5,12 @@ import { Linodeurl } from '../../../const';
|
|
|
5
5
|
// Utility function to extract price value from different formats
|
|
6
6
|
const getPriceValue = (price: any): number => {
|
|
7
7
|
if (price === null || price === undefined) return 0;
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
// If it's already a number
|
|
10
10
|
if (typeof price === 'number') {
|
|
11
11
|
return isNaN(price) ? 0 : price;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
// If it's an object with $numberDecimal (but not an array)
|
|
15
15
|
if (typeof price === 'object' && price !== null && !Array.isArray(price)) {
|
|
16
16
|
if (price.$numberDecimal !== undefined && price.$numberDecimal !== null) {
|
|
@@ -18,40 +18,40 @@ const getPriceValue = (price: any): number => {
|
|
|
18
18
|
return isNaN(value) ? 0 : value;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
// If it's a string, try to parse it
|
|
23
23
|
if (typeof price === 'string') {
|
|
24
24
|
const value = parseFloat(price);
|
|
25
25
|
return isNaN(value) ? 0 : value;
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
return 0;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
// Utility function to get price from pricing array (mrp, costPrice, nlcPrice)
|
|
32
32
|
const getPriceFromPricingArray = (pricingArray: any[]): number => {
|
|
33
33
|
if (!Array.isArray(pricingArray) || pricingArray.length === 0) return 0;
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
// First, try to find the default price with default currency
|
|
36
36
|
const defaultPrice = pricingArray.find(
|
|
37
37
|
(item: any) => item.isDefault === true && item.isDefaultCurrency === true
|
|
38
38
|
);
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
if (defaultPrice && defaultPrice.price) {
|
|
41
41
|
return getPriceValue(defaultPrice.price);
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
// Fallback: find any default price
|
|
45
45
|
const anyDefault = pricingArray.find((item: any) => item.isDefault === true);
|
|
46
46
|
if (anyDefault && anyDefault.price) {
|
|
47
47
|
return getPriceValue(anyDefault.price);
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
// Fallback: use first item
|
|
51
51
|
if (pricingArray[0] && pricingArray[0].price) {
|
|
52
52
|
return getPriceValue(pricingArray[0].price);
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
return 0;
|
|
56
56
|
};
|
|
57
57
|
|
|
@@ -78,11 +78,11 @@ const ProductListViewOne = (props: any) => {
|
|
|
78
78
|
|
|
79
79
|
// Updated price extraction to use pricing object only - same logic as GroupProductComponent
|
|
80
80
|
const mrpPrice = data.pricing?.mrp ? getPriceFromPricingArray(data.pricing.mrp) : 0;
|
|
81
|
-
const finalSellingPrice = data.pricing?.nlcPrice
|
|
82
|
-
? getPriceFromPricingArray(data.pricing.nlcPrice)
|
|
83
|
-
: data.pricing?.costPrice
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
const finalSellingPrice = data.pricing?.nlcPrice
|
|
82
|
+
? getPriceFromPricingArray(data.pricing.nlcPrice)
|
|
83
|
+
: data.pricing?.costPrice
|
|
84
|
+
? getPriceFromPricingArray(data.pricing.costPrice)
|
|
85
|
+
: 0;
|
|
86
86
|
|
|
87
87
|
const calculateDiscount = (): number | null => {
|
|
88
88
|
if (!finalSellingPrice || !mrpPrice || mrpPrice <= finalSellingPrice) return null;
|
|
@@ -101,22 +101,23 @@ const ProductListViewOne = (props: any) => {
|
|
|
101
101
|
};
|
|
102
102
|
|
|
103
103
|
const variantOptions = getVariantOptions();
|
|
104
|
+
const cardColor = props.cardColor;
|
|
104
105
|
|
|
105
106
|
return (
|
|
106
|
-
<div className="card">
|
|
107
|
+
<div className="card" style={{ backgroundColor: cardColor }}>
|
|
107
108
|
<a href={`/${slug}`} target={target}>
|
|
108
109
|
<div className="card_grid">
|
|
109
110
|
<div className="card_top">
|
|
110
111
|
<img
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
src={`${Linodeurl}${data?.image?.all?.url || data?.image?.url}`}
|
|
113
|
+
alt={data?.name?.all || data?.name}
|
|
114
|
+
className="product_image"
|
|
115
|
+
/>
|
|
115
116
|
</div>
|
|
116
117
|
<div className="card_bottom">
|
|
117
118
|
<div className="cardname">
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
<h3>{data?.name?.all || data?.name}</h3>
|
|
120
|
+
<h5>{variantOptions}</h5>
|
|
120
121
|
</div>
|
|
121
122
|
<div className="card_value">
|
|
122
123
|
{finalSellingPrice !== 0 && (
|
|
@@ -133,18 +134,18 @@ const ProductListViewOne = (props: any) => {
|
|
|
133
134
|
</div>
|
|
134
135
|
)}
|
|
135
136
|
<div className="review_counts">
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
137
|
+
<svg
|
|
138
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
139
|
+
viewBox="0 0 20 20"
|
|
140
|
+
fill="#f46b27"
|
|
141
|
+
width="13"
|
|
142
|
+
height="13"
|
|
143
|
+
>
|
|
144
|
+
<path d="M10 15l-5.878 3.09 1.122-6.545L.488 6.91l6.562-.955L10 0l2.95 5.955 6.562.955-4.756 4.635 1.122 6.545z" />
|
|
145
|
+
</svg>
|
|
146
|
+
<p>{data?.starrating}</p>
|
|
147
|
+
<span>({data?.startRatingCount} Reviews)</span>
|
|
148
|
+
</div>
|
|
148
149
|
{/* {Number(data?.starrating) && Number(data?.startRatingCount) && (
|
|
149
150
|
|
|
150
151
|
)} */}
|
|
@@ -5,12 +5,12 @@ import { Linodeurl } from '../../../const';
|
|
|
5
5
|
// Utility function to extract price value from different formats
|
|
6
6
|
const getPriceValue = (price: any): number => {
|
|
7
7
|
if (price === null || price === undefined) return 0;
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
// If it's already a number
|
|
10
10
|
if (typeof price === 'number') {
|
|
11
11
|
return isNaN(price) ? 0 : price;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
// If it's an object with $numberDecimal (but not an array)
|
|
15
15
|
if (typeof price === 'object' && price !== null && !Array.isArray(price)) {
|
|
16
16
|
if (price.$numberDecimal !== undefined && price.$numberDecimal !== null) {
|
|
@@ -18,40 +18,40 @@ const getPriceValue = (price: any): number => {
|
|
|
18
18
|
return isNaN(value) ? 0 : value;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
// If it's a string, try to parse it
|
|
23
23
|
if (typeof price === 'string') {
|
|
24
24
|
const value = parseFloat(price);
|
|
25
25
|
return isNaN(value) ? 0 : value;
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
return 0;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
// Utility function to get price from pricing array (mrp, costPrice, nlcPrice)
|
|
32
32
|
const getPriceFromPricingArray = (pricingArray: any[]): number => {
|
|
33
33
|
if (!Array.isArray(pricingArray) || pricingArray.length === 0) return 0;
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
// First, try to find the default price with default currency
|
|
36
36
|
const defaultPrice = pricingArray.find(
|
|
37
37
|
(item: any) => item.isDefault === true && item.isDefaultCurrency === true
|
|
38
38
|
);
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
if (defaultPrice && defaultPrice.price) {
|
|
41
41
|
return getPriceValue(defaultPrice.price);
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
// Fallback: find any default price
|
|
45
45
|
const anyDefault = pricingArray.find((item: any) => item.isDefault === true);
|
|
46
46
|
if (anyDefault && anyDefault.price) {
|
|
47
47
|
return getPriceValue(anyDefault.price);
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
// Fallback: use first item
|
|
51
51
|
if (pricingArray[0] && pricingArray[0].price) {
|
|
52
52
|
return getPriceValue(pricingArray[0].price);
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
return 0;
|
|
56
56
|
};
|
|
57
57
|
|
|
@@ -79,11 +79,11 @@ const ProductListViewTwo = (props: any) => {
|
|
|
79
79
|
|
|
80
80
|
// Updated price extraction to use pricing object only - same logic as GroupProductComponent
|
|
81
81
|
const mrpPrice = data.pricing?.mrp ? getPriceFromPricingArray(data.pricing.mrp) : 0;
|
|
82
|
-
const finalSellingPrice = data.pricing?.nlcPrice
|
|
83
|
-
? getPriceFromPricingArray(data.pricing.nlcPrice)
|
|
84
|
-
: data.pricing?.costPrice
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
const finalSellingPrice = data.pricing?.nlcPrice
|
|
83
|
+
? getPriceFromPricingArray(data.pricing.nlcPrice)
|
|
84
|
+
: data.pricing?.costPrice
|
|
85
|
+
? getPriceFromPricingArray(data.pricing.costPrice)
|
|
86
|
+
: 0;
|
|
87
87
|
|
|
88
88
|
const calculateDiscount = () => {
|
|
89
89
|
if (!finalSellingPrice || !mrpPrice || mrpPrice <= finalSellingPrice) return null;
|
|
@@ -103,12 +103,14 @@ const ProductListViewTwo = (props: any) => {
|
|
|
103
103
|
|
|
104
104
|
// const variantOptions = getVariantOptions();
|
|
105
105
|
|
|
106
|
+
const cardColor = props.cardColor;
|
|
107
|
+
|
|
106
108
|
return (
|
|
107
|
-
<div className="card">
|
|
109
|
+
<div className="card" style={{ backgroundColor: cardColor }}>
|
|
108
110
|
<a href={`/${slug}`} target={target} rel="noopener noreferrer">
|
|
109
111
|
<div className="card_content">
|
|
110
|
-
|
|
111
|
-
|
|
112
|
+
|
|
113
|
+
|
|
112
114
|
<div className="card_middle">
|
|
113
115
|
<img
|
|
114
116
|
src={`${Linodeurl}${data?.image?.all?.url || data?.image?.url}`}
|
|
@@ -139,18 +141,18 @@ const ProductListViewTwo = (props: any) => {
|
|
|
139
141
|
</div>
|
|
140
142
|
|
|
141
143
|
<div className="review_container">
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
</div>
|
|
144
|
+
<div className="rating">
|
|
145
|
+
<svg
|
|
146
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
147
|
+
viewBox="0 0 20 20"
|
|
148
|
+
width="14"
|
|
149
|
+
height="14"
|
|
150
|
+
>
|
|
151
|
+
<path d="M10 15l-5.878 3.09 1.122-6.545L.488 6.91l6.562-.955L10 0l2.95 5.955 6.562.955-4.756 4.635 1.122 6.545z" />
|
|
152
|
+
</svg>
|
|
153
|
+
<span className="rating_value">{data?.starrating}</span>
|
|
153
154
|
</div>
|
|
155
|
+
</div>
|
|
154
156
|
</div>
|
|
155
157
|
</div>
|
|
156
158
|
</a>
|
|
@@ -80,7 +80,9 @@ const TextComponent: React.FC<{ props: ComponentProps }> = ({ props }) => {
|
|
|
80
80
|
if (url) {
|
|
81
81
|
return (
|
|
82
82
|
<div style={{
|
|
83
|
-
display: "
|
|
83
|
+
display: "flex",
|
|
84
|
+
flexDirection: "column",
|
|
85
|
+
alignItems:style?.textAlign === 'center' ? 'center' : style?.textAlign === 'right' ? 'flex-end' : 'flex-start',
|
|
84
86
|
width: "100%",
|
|
85
87
|
maxWidth: "100%",
|
|
86
88
|
wordWrap: "break-word",
|