tee3apps-cms-sdk-react 0.0.34 → 0.0.35

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": "tee3apps-cms-sdk-react",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "description": "Uses JSON to dynamically generate and render UI pages in a website",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/src/Page.tsx CHANGED
@@ -8,7 +8,7 @@ import GroupProductComponent, { GroupProductComponentProps } from './PageCompone
8
8
  import VideoComponent, { VideoComponentProps } from './PageComponents/Visual-Components/VideoComponent';
9
9
  import GroupBrandComponent, { GroupBrandComponentProps } from './PageComponents/Visual-Components/GroupBrandComponent';
10
10
  import LottieComponent, { LottieComponentProps } from './PageComponents/Visual-Components/LottieComponent';
11
- import { ImageComponentProps, LinkProps, TextProps } from './common.interface';
11
+ import { ImageComponentProps, LinkProps, TextProps } from './common.interface';
12
12
  import CarouselComponent, { CarouselProps } from './PageComponents/Visual-Components/CarouselComponent';
13
13
  import NavigationComponent, { NavigationProps } from './PageComponents/Visual-Components/NavigationComponent';
14
14
  import './index.css'
@@ -18,9 +18,9 @@ import GroupImageList, { GroupImageListProps } from './PageComponents/Visual-Com
18
18
  import TabComponent, { TabComponentProps } from './PageComponents/Visual-Components/TabComponent';
19
19
  import ErrorBoundary from './ErrorBoundary';
20
20
  import RichTextComponent, { RichTextComponentProps } from './PageComponents/Visual-Components/RichTextComponent';
21
- const Page = ({data}:any) => {
22
- const [deviceMode, setDeviceMode] = useState<string>('web');
23
- const [screenSize, setScreenSize] = useState({
21
+ const Page = ({ data, showsp = true, showdiscount = true }: any) => {
22
+ const [deviceMode, setDeviceMode] = useState<string>('web');
23
+ const [screenSize, setScreenSize] = useState({
24
24
  width: 0,
25
25
  height: 0
26
26
  });
@@ -53,73 +53,93 @@ const Page = ({data}:any) => {
53
53
  return (
54
54
  <>
55
55
  <div className=''>
56
- <div className=''>
57
-
58
- <ErrorBoundary>
59
- {data.map((row: { props: any; columns: any[]; }, rowIndex: React.Key | null | undefined) => (
60
- <RowComponent key={rowIndex} props={row.props} deviceMode={deviceMode}>
61
- {row.columns.map((box, boxIndex) => (
62
- <BoxComponent
63
- key={boxIndex}
64
- props={box.props}
65
- deviceMode={deviceMode}
66
- autoAdjustForImages={false}
67
- >
68
- {box.components.map((component: { name: string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined; props: TextProps | LinkProps | ImageComponentProps | GroupProductComponentProps | VideoComponentProps | GroupBrandComponentProps | LottieComponentProps | CarouselProps | NavigationProps | GroupVideoListProps | GroupCategoryComponentProps | GroupImageListProps | TabComponentProps | RichTextComponentProps; }, compIndex: React.Key | null | undefined) => {
69
- const getCurrentBoxHeight = () => {
70
- const validModes = ['web', 'mobileweb', 'mobileapp', 'tablet'] as const;
71
- const safeDeviceMode = validModes.includes(deviceMode as any)
72
- ? deviceMode as keyof typeof box.props.mode
73
- : 'web';
74
- if(component.name==='ImageComponent') return 'auto' // add this line
75
- return box.props.mode[safeDeviceMode]?.height || 'auto';
76
- };
56
+ <div className=''>
77
57
 
78
- try {
79
- switch (component.name) {
80
- case 'TextComponent':
81
- return <TextComponent key={compIndex} props={component.props as TextProps} />;
82
- case 'LinkComponent':
83
- return <LinkComponent key={compIndex} props={component.props as LinkProps} />;
84
- case 'ImageComponent':
85
- return <ImageComponent key={compIndex} props={component.props as ImageComponentProps} deviceMode={deviceMode} boxHeight={getCurrentBoxHeight()} />;
86
- case 'GroupProductComponent':
87
- return <GroupProductComponent key={compIndex} props={component.props as GroupProductComponentProps} deviceMode={deviceMode} />;
88
- case 'VideoComponent':
89
- return <VideoComponent key={compIndex} props={component.props as VideoComponentProps} deviceMode={deviceMode} boxHeight={getCurrentBoxHeight()} />;
90
- case 'GroupBrandComponent':
91
- return <GroupBrandComponent key={compIndex} props={component.props as GroupBrandComponentProps} deviceMode={deviceMode} />;
92
- case 'LottieComponent':
93
- return <LottieComponent key={compIndex} props={component.props as LottieComponentProps} />;
94
- case 'CarouselComponent':
95
- return <CarouselComponent key={compIndex} props={component.props as CarouselProps} deviceMode={deviceMode} />;
96
- case 'NavigationComponent':
97
- return <NavigationComponent key={compIndex} props={component.props as NavigationProps} boxHeight={getCurrentBoxHeight()} />;
98
- case 'GroupVideoComponent':
99
- return <GroupVideoList key={compIndex} props={component.props as GroupVideoListProps} boxHeight={getCurrentBoxHeight()} />;
100
- case 'GroupCategoryComponent':
101
- return <GroupCategoryComponent key={compIndex} props={component.props as GroupCategoryComponentProps} deviceMode={deviceMode} />;
102
- case 'GroupImageComponent':
103
- return <GroupImageList key={compIndex} props={component.props as GroupImageListProps} deviceMode={deviceMode} />;
104
- case 'TabComponent':
105
- return <TabComponent key={compIndex} props={component.props as TabComponentProps} deviceMode={deviceMode} />;
106
- case 'RichTextBoxComponent':
107
- return <RichTextComponent key={compIndex} props={component.props as RichTextComponentProps} />;
108
- default:
109
- return null;
110
- }
111
- } catch (err) {
112
- console.error(`Error rendering component: ${component.name}`, err);
113
- return <div key={compIndex} style={{ color: 'red' }}>Failed to load component: {component.name}</div>;
114
- }
115
- })}
116
- </BoxComponent>
117
- ))}
118
- </RowComponent>
119
- ))}
120
- </ErrorBoundary>
121
- </div>
58
+ <ErrorBoundary>
59
+ {data.map((row: { props: any; columns: any[]; }, rowIndex: React.Key | null | undefined) => (
60
+ <RowComponent key={rowIndex} props={row.props} deviceMode={deviceMode}>
61
+ {row.columns.map((box, boxIndex) => (
62
+ <BoxComponent
63
+ key={boxIndex}
64
+ props={box.props}
65
+ deviceMode={deviceMode}
66
+ autoAdjustForImages={false}
67
+ >
68
+ {box.components.map((component: { name: string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined; props: TextProps | LinkProps | ImageComponentProps | GroupProductComponentProps | VideoComponentProps | GroupBrandComponentProps | LottieComponentProps | CarouselProps | NavigationProps | GroupVideoListProps | GroupCategoryComponentProps | GroupImageListProps | TabComponentProps | RichTextComponentProps; }, compIndex: React.Key | null | undefined) => {
69
+ const getCurrentBoxHeight = () => {
70
+ const validModes = ['web', 'mobileweb', 'mobileapp', 'tablet'] as const;
71
+ const safeDeviceMode = validModes.includes(deviceMode as any)
72
+ ? deviceMode as keyof typeof box.props.mode
73
+ : 'web';
74
+ if (component.name === 'ImageComponent') return 'auto' // add this line
75
+ return box.props.mode[safeDeviceMode]?.height || 'auto';
76
+ };
77
+
78
+ try {
79
+ switch (component.name) {
80
+ case 'TextComponent':
81
+ return <TextComponent key={compIndex} props={component.props as TextProps} />;
82
+ case 'LinkComponent':
83
+ return <LinkComponent key={compIndex} props={component.props as LinkProps} />;
84
+ case 'ImageComponent':
85
+ return <ImageComponent key={compIndex} props={component.props as ImageComponentProps} deviceMode={deviceMode} boxHeight={getCurrentBoxHeight()} />;
86
+ case 'GroupProductComponent':
87
+ {
88
+ const gpProps = component.props as GroupProductComponentProps;
89
+ return <GroupProductComponent
90
+ key={compIndex}
91
+ props={{
92
+ ...gpProps,
93
+ showsp: gpProps.showsp ?? showsp,
94
+ showdiscount: gpProps.showdiscount ?? showdiscount
95
+ }}
96
+ deviceMode={deviceMode} />;
97
+ }
98
+ case 'VideoComponent':
99
+ return <VideoComponent key={compIndex} props={component.props as VideoComponentProps} deviceMode={deviceMode} boxHeight={getCurrentBoxHeight()} />;
100
+ case 'GroupBrandComponent':
101
+ return <GroupBrandComponent key={compIndex} props={component.props as GroupBrandComponentProps} deviceMode={deviceMode} />;
102
+ case 'LottieComponent':
103
+ return <LottieComponent key={compIndex} props={component.props as LottieComponentProps} />;
104
+ case 'CarouselComponent':
105
+ return <CarouselComponent key={compIndex} props={component.props as CarouselProps} deviceMode={deviceMode} />;
106
+ case 'NavigationComponent':
107
+ return <NavigationComponent key={compIndex} props={component.props as NavigationProps} boxHeight={getCurrentBoxHeight()} />;
108
+ case 'GroupVideoComponent':
109
+ return <GroupVideoList key={compIndex} props={component.props as GroupVideoListProps} boxHeight={getCurrentBoxHeight()} />;
110
+ case 'GroupCategoryComponent':
111
+ return <GroupCategoryComponent key={compIndex} props={component.props as GroupCategoryComponentProps} deviceMode={deviceMode} />;
112
+ case 'GroupImageComponent':
113
+ return <GroupImageList key={compIndex} props={component.props as GroupImageListProps} deviceMode={deviceMode} />;
114
+ case 'TabComponent':
115
+ {
116
+ const tabProps = component.props as TabComponentProps;
117
+ return <TabComponent
118
+ key={compIndex}
119
+ props={{
120
+ ...tabProps,
121
+ showsp: tabProps.showsp ?? showsp,
122
+ showdiscount: tabProps.showdiscount ?? showdiscount
123
+ }}
124
+ deviceMode={deviceMode} />;
125
+ }
126
+ case 'RichTextBoxComponent':
127
+ return <RichTextComponent key={compIndex} props={component.props as RichTextComponentProps} />;
128
+ default:
129
+ return null;
130
+ }
131
+ } catch (err) {
132
+ console.error(`Error rendering component: ${component.name}`, err);
133
+ return <div key={compIndex} style={{ color: 'red' }}>Failed to load component: {component.name}</div>;
134
+ }
135
+ })}
136
+ </BoxComponent>
137
+ ))}
138
+ </RowComponent>
139
+ ))}
140
+ </ErrorBoundary>
122
141
  </div>
142
+ </div>
123
143
  </>
124
144
  )
125
145
  }
@@ -151,6 +151,8 @@ export interface GroupProductComponentProps {
151
151
  isHorizontalScroll: DeviceBooleanProps;
152
152
  headerBackground: string;
153
153
  viewAllLink?: string;
154
+ showsp?: boolean;
155
+ showdiscount?: boolean;
154
156
  }
155
157
 
156
158
  interface GroupProductComponentMainProps {
@@ -209,13 +211,13 @@ const GroupProductComponent: React.FC<GroupProductComponentMainProps> = ({
209
211
  if (currentstyle === 'STYLE1') {
210
212
  return (
211
213
  <div key={key}>
212
- <ProductListViewOne props={product} cardColor={props.cardColor} layout={currentLayout} />
214
+ <ProductListViewOne props={product} cardColor={props.cardColor} layout={currentLayout} showsp={props.showsp} showdiscount={props.showdiscount} />
213
215
  </div>
214
216
  );
215
217
  } else if (currentstyle === 'STYLE2') {
216
218
  return (
217
219
  <div key={key}>
218
- <ProductListViewTwo props={product} cardColor={props.cardColor} layout={currentLayout} />
220
+ <ProductListViewTwo props={product} cardColor={props.cardColor} layout={currentLayout} showsp={props.showsp} showdiscount={props.showdiscount} />
219
221
  </div>
220
222
  );
221
223
  } else {
@@ -313,16 +315,16 @@ const GroupProductComponent: React.FC<GroupProductComponentMainProps> = ({
313
315
 
314
316
  {(() => {
315
317
  const prices = getProductPrices(product);
316
- return prices.sellingPrice > 0 ? (
318
+ return props.showsp !== false && prices.sellingPrice > 0 ? (
317
319
  <div style={{ marginTop: '8px', textAlign: 'center' }}>
318
- <p style={{ fontSize: '14px', fontWeight: '700', color: '#333', margin: 0 }}>
319
- SP: {prices.sellingPrice.toLocaleString("en-IN")}
320
+ <p style={{ fontSize: '14px', fontWeight: '700', color: '#333', margin: 0, display: 'flex', alignItems: 'center', gap: '4px', flexWrap: 'wrap', justifyContent: 'center' }}>
321
+ <span>SP: {prices.sellingPrice.toLocaleString("en-IN")} (incl of all tax)</span>
322
+ {props.showdiscount !== false && prices.mrp > prices.sellingPrice && (
323
+ <span style={{ fontSize: '11px', color: '#666', textDecoration: 'line-through', fontWeight: 'normal' }}>
324
+ MRP: {prices.mrp.toLocaleString("en-IN")}
325
+ </span>
326
+ )}
320
327
  </p>
321
- {prices.mrp > prices.sellingPrice && (
322
- <p style={{ fontSize: '11px', color: '#666', textDecoration: 'line-through', margin: '1px 0' }}>
323
- MRP: {prices.mrp.toLocaleString("en-IN")}
324
- </p>
325
- )}
326
328
  </div>
327
329
  ) : null;
328
330
  })()}
@@ -337,13 +339,13 @@ const GroupProductComponent: React.FC<GroupProductComponentMainProps> = ({
337
339
  if (currentstyle === 'STYLE1') {
338
340
  return (
339
341
  <div key={key}>
340
- <ProductListViewOne props={product} cardColor={props.cardColor} layout={currentLayout} />
342
+ <ProductListViewOne props={product} cardColor={props.cardColor} layout={currentLayout} showsp={props.showsp} showdiscount={props.showdiscount} />
341
343
  </div>
342
344
  );
343
345
  } else if (currentstyle === 'STYLE2') {
344
346
  return (
345
347
  <div key={key}>
346
- <ProductListViewTwo props={product} cardColor={props.cardColor} layout={currentLayout} />
348
+ <ProductListViewTwo props={product} cardColor={props.cardColor} layout={currentLayout} showsp={props.showsp} showdiscount={props.showdiscount} />
347
349
  </div>
348
350
  );
349
351
  } else {
@@ -439,10 +441,15 @@ const GroupProductComponent: React.FC<GroupProductComponentMainProps> = ({
439
441
 
440
442
  {(() => {
441
443
  const prices = getProductPrices(product);
442
- return prices.sellingPrice > 0 ? (
444
+ return props.showsp !== false && prices.sellingPrice > 0 ? (
443
445
  <div style={{ marginTop: '5px', textAlign: 'center' }}>
444
- <p style={{ fontSize: '13px', fontWeight: '700', color: '#333', margin: 0 }}>
445
- SP: {prices.sellingPrice.toLocaleString("en-IN")}
446
+ <p style={{ fontSize: '13px', fontWeight: '700', color: '#333', margin: 0, display: 'flex', alignItems: 'center', gap: '3px', flexWrap: 'wrap', justifyContent: 'center' }}>
447
+ <span>SP: {prices.sellingPrice.toLocaleString("en-IN")} (incl of all tax)</span>
448
+ {props.showdiscount !== false && prices.mrp > prices.sellingPrice && (
449
+ <span style={{ fontSize: '11px', color: '#666', textDecoration: 'line-through', fontWeight: 'normal' }}>
450
+ MRP: {prices.mrp.toLocaleString("en-IN")}
451
+ </span>
452
+ )}
446
453
  </p>
447
454
  </div>
448
455
  ) : null;
@@ -157,17 +157,17 @@ const ProductListViewOne = (props: any) => {
157
157
  <h5 style={{ margin: 0, fontWeight: '400', color: '#666' }}>{variantOptions}</h5>
158
158
  </div>
159
159
  <div className="card_value" style={{ display: 'flex', justifyContent: 'center', width: '100%' }}>
160
- {finalSellingPrice !== 0 && (
160
+ {props.showsp !== false && finalSellingPrice !== 0 && (
161
161
  <div className="card_price" style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
162
- <h4 style={{ margin: 0, fontSize: '16px', fontWeight: '700' }}>SP: {finalSellingPrice.toLocaleString("en-IN")}</h4>
163
- <div className="card_right_grid" style={{ display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: '4px', justifyContent: 'center' }}>
164
- {mrpPrice > finalSellingPrice && (
165
- <p style={{ margin: 0, fontSize: '12px', color: '#666', textDecoration: 'line-through' }}>MRP: {mrpPrice.toLocaleString("en-IN")}</p>
162
+ <h4 style={{ margin: 0, fontSize: '15px', fontWeight: '700', display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap', justifyContent: 'center' }}>
163
+ <span>SP: {finalSellingPrice.toLocaleString("en-IN")} (incl of all tax)</span>
164
+ {props.showdiscount !== false && mrpPrice > finalSellingPrice && (
165
+ <span style={{ fontSize: '12px', color: '#666', textDecoration: 'line-through', fontWeight: 'normal' }}>MRP: {mrpPrice.toLocaleString("en-IN")}</span>
166
166
  )}
167
- {discount !== null && discount > 0 && (
168
- <span style={{ fontSize: '11px', color: '#28a745', fontWeight: 'bold' }}>({discount}% OFF)</span>
169
- )}
170
- </div>
167
+ </h4>
168
+ {props.showdiscount !== false && mrpPrice > finalSellingPrice && discount !== null && discount > 0 && (
169
+ <span style={{ fontSize: '11px', color: '#555a56ff', fontWeight: 'bold' }}>({discount}% OFF)</span>
170
+ )}
171
171
  </div>
172
172
  )}
173
173
  </div>
@@ -159,22 +159,24 @@ const ProductListViewTwo = (props: any) => {
159
159
  </div>
160
160
  <div className="card_bottom" style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', width: '100%' }}>
161
161
  <div className="price_container">
162
- {finalSellingPrice !== 0 && (
162
+ {props.showsp !== false && finalSellingPrice !== 0 && (
163
163
  <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', textAlign: 'center' }}>
164
164
  <div className="price_row" style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
165
- <h4 className="selling_price" style={{ margin: 0 }}>SP: {finalSellingPrice.toLocaleString("en-IN")}</h4>
166
- {mrpPrice > finalSellingPrice && (
167
- <p className="mrp_price" style={{ fontSize: '11px', color: '#666', textDecoration: 'line-through', margin: '2px 0' }}>
168
- MRP: {mrpPrice.toLocaleString("en-IN")}
169
- </p>
170
- )}
171
- {discount !== null && discount > 0 && (
172
- <span className="discounts" style={{ fontSize: '11px', color: '#28a745', fontWeight: 'bold' }}>{discount}% OFF</span>
165
+ <h4 className="selling_price" style={{ margin: 0, fontSize: '15px', fontWeight: '700', display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap', justifyContent: 'center' }}>
166
+ <span>SP: {finalSellingPrice.toLocaleString("en-IN")} (incl of all tax)</span>
167
+ {props.showdiscount !== false && mrpPrice > finalSellingPrice && (
168
+ <span style={{ fontSize: '12px', color: '#666', textDecoration: 'line-through', fontWeight: 'normal' }}>MRP: {mrpPrice.toLocaleString("en-IN")}</span>
169
+ )}
170
+ </h4>
171
+ {props.showdiscount !== false && mrpPrice > finalSellingPrice && (
172
+ <div style={{ display: 'flex', alignItems: 'center', gap: '4px', marginTop: '2px' }}>
173
+ {discount !== null && discount > 0 && (
174
+ <span className="discounts" style={{ fontSize: '11px', color: '#28a745', fontWeight: 'bold' }}>{discount}% OFF</span>
175
+ )}
176
+ <p className="save_amount" style={{ margin: 0, fontSize: '11px', fontWeight: '500' }}>Save {(mrpPrice - finalSellingPrice).toLocaleString("en-IN")}</p>
177
+ </div>
173
178
  )}
174
179
  </div>
175
- {mrpPrice > finalSellingPrice && (
176
- <p className="save_amount" style={{ margin: '2px 0 0 0', fontSize: '11px', fontWeight: '500' }}>Save {(mrpPrice - finalSellingPrice).toLocaleString("en-IN")}</p>
177
- )}
178
180
  </div>
179
181
  )}
180
182
  </div>