@omniumretail/component-library 1.0.26 → 1.0.27

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": "@omniumretail/component-library",
3
- "version": "1.0.26",
3
+ "version": "1.0.27",
4
4
  "private": false,
5
5
  "main": "dist/bundle.js",
6
6
  "typings": "./dist/types/index",
@@ -1,4 +1,5 @@
1
1
  import { Meta, Story } from "@storybook/react";
2
+ import { useEffect, useState } from "react";
2
3
  import { Category } from '.';
3
4
 
4
5
  export default {
@@ -6,7 +7,14 @@ export default {
6
7
  component: Category,
7
8
  } as Meta;
8
9
 
9
- const Template: Story<any> = (args) => <Category {...args}></Category>;
10
+ const Template: Story<any> = (args) => {
11
+ const [serverData, setServerData] = useState<any>();
12
+
13
+ useEffect(() => {
14
+ console.log('adsyajdha', serverData);
15
+ }, [serverData])
16
+ return <Category {...args} data={[]} serverReadyData={setServerData}></Category>
17
+ };
10
18
 
11
19
  export const Primary = Template.bind({});
12
20
  Primary.args = {
@@ -27,6 +27,7 @@ export interface DataNode {
27
27
  interface SidebarProps {
28
28
  categoryContentData: any;
29
29
  categorySidebarInfo: any;
30
+ categoryContentFinalData: any;
30
31
  data: DataNode[];
31
32
  }
32
33
 
@@ -59,6 +60,7 @@ function addPropertyByIndex(data: DataNode[], index: string | number, property:
59
60
  export const CategorySidebar = (props: SidebarProps) => {
60
61
  const {
61
62
  categoryContentData,
63
+ categoryContentFinalData,
62
64
  data
63
65
  } = props;
64
66
 
@@ -204,7 +206,6 @@ export const CategorySidebar = (props: SidebarProps) => {
204
206
  const newGData = addPropertyByIndex(gData, sidebarInfo && sidebarInfo[0], "data", categoryContentData);
205
207
 
206
208
  const updatedGData = newGData.map((category: any, index) => {
207
- console.log(category?.data);
208
209
  if(category?.data) {
209
210
  return {...category, title: `${category.data.categoryName} ${category.data.questions ? '(Q: ' + category.data.questions.length + ')' : ''} ${category.data.grade ? '(G: ' +category.data.grade + ')' : ''}`}
210
211
  }
@@ -220,7 +221,7 @@ export const CategorySidebar = (props: SidebarProps) => {
220
221
  data: get_element_by_index(gData, sidebarInfo && sidebarInfo[0])
221
222
  });
222
223
 
223
- console.log(gData);
224
+ props.categoryContentFinalData(gData);
224
225
  }, [gData]);
225
226
 
226
227
  return (
@@ -5,6 +5,7 @@ import { CategoryContent } from './CategoryContent';
5
5
 
6
6
  interface Category {
7
7
  data: DataNode;
8
+ serverReadyData: any;
8
9
  }
9
10
 
10
11
  const fakeData: any = {
@@ -37,9 +38,11 @@ export const Category = (props: Category) => {
37
38
  const [categoryContentInfo, setCategoryContentInfo] = useState<any>();
38
39
  const [categorySidebarInfo, setCategorySidebarInfo] = useState<any>();
39
40
  const [showContent, setShowContent] = useState<boolean>(false);
41
+ const [finalData, setFinalData] = useState<any>();
40
42
 
41
43
  useEffect(() => {
42
- }, [categoryContentInfo]);
44
+ props.serverReadyData(finalData)
45
+ }, [finalData]);
43
46
 
44
47
  useEffect(() => {
45
48
  setShowContent(categorySidebarInfo?.selectKey?.length > 0);
@@ -48,7 +51,7 @@ export const Category = (props: Category) => {
48
51
  return (
49
52
  <div className={styles.category}>
50
53
  <div className={styles.sidebarWrapper}>
51
- <CategorySidebar categorySidebarInfo={setCategorySidebarInfo} categoryContentData={categoryContentInfo} data={data} />
54
+ <CategorySidebar categorySidebarInfo={setCategorySidebarInfo} categoryContentData={categoryContentInfo} data={data} categoryContentFinalData={setFinalData}/>
52
55
  </div>
53
56
  <div className={styles.contentWrapper}>
54
57
  <CategoryContent categoryContentInfo={setCategoryContentInfo} categoryContentShow={showContent} categorySidebarData={categorySidebarInfo} />