@@ -15,6 +15,13 @@ const TableStateProps = props => {
15
15
const classes = useStyles ( ) ;
16
16
const [ editRowsModel ] = useState < GridEditRowsModel > ( { } ) ;
17
17
const [ gridColumns , setGridColumns ] = useState ( [ ] ) ;
18
+ const currentId = state . canvasFocus . componentId ;
19
+ const currentComponent = state . components [ currentId - 1 ] ;
20
+ const rows1 = props . rows1 ;
21
+ const setRows1 = props . setRows1 ;
22
+ console . log ( { currentComponent} )
23
+
24
+ console . log ( { rows1} )
18
25
const columnTabs = [
19
26
{
20
27
field : 'id' ,
@@ -90,56 +97,66 @@ const TableStateProps = props => {
90
97
} else {
91
98
setGridColumns ( columnTabs . slice ( 0 , gridColumns . length - 1 ) ) ;
92
99
}
100
+
93
101
} , [ state . canvasFocus . componentId ] ) ;
94
102
// rows to show are either from current component or from a given provider
103
+
95
104
let rows = [ ] ;
96
- console . log ( 'passedInProps after rows declaration' , state . components [ state . canvasFocus . componentId - 1 ] . passedInProps ?. slice ( ) [ 0 ] ) ;
97
- console . log ( 'type of passedInProps' , Array . isArray ( state . components [ state . canvasFocus . componentId - 1 ] . passedInProps ?. slice ( ) ) ) ;
98
- const passedInProps = state . components [ state . canvasFocus . componentId - 1 ] . passedInProps ?. slice ( ) ;
99
- passedInProps ?. forEach ( propObj => {
100
- rows . push ( propObj )
101
- } )
102
- console . log ( 'rows after for loop' , rows )
103
- // let passedInPropsArray = state.components[state.canvasFocus.componentId - 1].passedInProps?.slice();
104
- // console.log({passedInPropsArray})
105
- // if (passedInPropsArray[0]) rows.push(passedInPropsArray[0]);
106
- console . log ( 'rows in line 98' , rows ) ;
107
- console . log ( 'props.providerId' , props . providerId ) ;
108
- if ( ! props . providerId ) {
109
- const currentId = state . canvasFocus . componentId ;
110
- const currentComponent = state . components [ currentId - 1 ] ;
111
- rows = currentComponent . stateProps . slice ( ) ;
112
- //add parentProps to the rows array
113
- rows . concat ( currentComponent . passedInProps ?. slice ( ) ) ;
114
- } else {
115
- const providerComponent = state . components [ props . providerId - 1 ] ;
116
- // changed to get whole object
117
- if ( props . displayObject ) {
118
- const displayObject = props . displayObject ;
119
- // format for DataGrid
120
- let id = 1 ;
121
- const currentId = state . canvasFocus . componentId ;
122
- const currentComponent = state . components [ currentId - 1 ] ;
123
- for ( const key in displayObject ) {
124
- // if key is a number make it a string with brackets aroung number
125
- const newKey = isNaN ( key ) ? key : '[' + key + ']' ;
126
- const type = Array . isArray ( displayObject [ key ] ) ? 'array' : typeof ( displayObject [ key ] ) ;
127
- rows . push ( { id : id ++ , key : newKey , value : displayObject [ key ] , type : type } ) ;
128
- }
129
- } else {
130
- const currentId = state . canvasFocus . componentId ;
131
- const currentComponent = state . components [ currentId - 1 ] ;
132
- rows = providerComponent . stateProps . slice ( ) ;
133
- rows . concat ( currentComponent . passedInProps ?. slice ( ) ) ;
134
- console . log ( { rows} )
135
- }
136
- }
105
+
106
+
107
+ const passedInProps = currentComponent . passedInProps ?. slice ( ) ;
108
+ console . log ( { passedInProps} ) ;
109
+
110
+ passedInProps ?. forEach ( propObj => {
111
+ rows . push ( propObj )
112
+ } )
113
+
114
+ console . log ( "rows before pushing stateProps" , rows ) ;
115
+
116
+ currentComponent . stateProps ?. forEach ( ( prop ) => rows . push ( prop ) ) ;
117
+
118
+ console . log ( "rows after pushing stateProps" , rows ) ;
119
+
120
+ // if (!props.providerId) {
121
+
122
+ // if (rows.length < 1) {
123
+ //currentComponent.stateProps?.forEach((prop) => rows.push(prop))
124
+ // } else rows.concat(currentComponent.stateProps.slice());
125
+
126
+ //[1,1.01,2,2.02]
127
+ //[1,3,2,4]
128
+ //add current props to the rows array
129
+ //}
130
+ // else {
131
+
132
+ // /// LegacyPD: we want to delete this because state management tab shouldn't be using context
133
+
134
+ // const providerComponent = state.components[props.providerId - 1];
135
+ // // changed to get whole object
136
+ // if (props.displayObject){
137
+ // const displayObject = props.displayObject;
138
+ // // format for DataGrid
139
+ // let id=1;
140
+ // const currentId = state.canvasFocus.componentId;
141
+ // const currentComponent = state.components[currentId - 1];
142
+ // for (const key in displayObject) {
143
+ // // if key is a number make it a string with brackets aroung number
144
+ // const newKey = isNaN(key) ? key : '[' + key + ']';
145
+ // const type = Array.isArray(displayObject[key]) ? 'array' : typeof (displayObject[key]);
146
+ // rows.push({ id: id++, key: newKey, value: displayObject[key], type: type});
147
+ // }
148
+ // } else {
149
+ // const currentId = state.canvasFocus.componentId;
150
+ // const currentComponent = state.components[currentId - 1];
151
+ // rows.concat(currentComponent.stateProps.slice());
152
+ // }
153
+ // }
137
154
138
155
139
156
return (
140
157
< div className = { 'state-prop-grid' } style = { { display : 'flex' , gap : "20px" } } >
141
158
< DataGrid
142
- rows = { rows }
159
+ rows = { rows1 }
143
160
columns = { gridColumns }
144
161
pageSize = { 5 }
145
162
editRowsModel = { editRowsModel }
0 commit comments