@@ -21,24 +21,6 @@ import { Typography } from '@mui/material';
21
21
22
22
const filter = createFilterOptions ( ) ;
23
23
24
- // const contextArr = [
25
- // {
26
- // name: 'theme',
27
- // contextInputs: [
28
- // { key: 'dark', contextInput: 'black' },
29
- // { key: 'light', contextInput: 'white' }
30
- // ]
31
- // },
32
-
33
- // {
34
- // name: 'mood',
35
- // contextInputs: [
36
- // { key: 'happy', contextInput: 'rainbow' },
37
- // { key: 'sad', contextInput: 'blue' }
38
- // ]
39
- // }
40
- // ];
41
-
42
24
//START - Table styling
43
25
const StyledTableCell = styled ( TableCell ) ( ( { theme } ) => ( {
44
26
[ `&.${ tableCellClasses . head } ` ] : {
@@ -69,12 +51,24 @@ const CreatorForm = ({
69
51
//array storing all contexts
70
52
const { allContext } = contextStore ;
71
53
54
+ //a state to keep track of data in table
55
+ const [ tableState , setTableState ] = React . useState ( [
56
+ {
57
+ key : 'Enter key' ,
58
+ value : 'Enter value'
59
+ }
60
+ ] ) ;
61
+
72
62
const [ contextInput , setContextInput ] = React . useState ( null ) ;
73
63
const [ dataContext , setDataContext ] = React . useState ( {
74
64
inputKey : '' ,
75
65
inputValue : ''
76
66
} ) ;
77
67
68
+ const renderTable = targetContext => {
69
+ setTableState ( targetContext . values ) ;
70
+ } ;
71
+
78
72
const handleChange = e => {
79
73
setDataContext ( prevDataContext => {
80
74
return {
@@ -113,7 +107,7 @@ const CreatorForm = ({
113
107
} ) ;
114
108
} else {
115
109
setContextInput ( newValue ) ;
116
- console . log ( 'selected from drop down' , contextInput )
110
+ renderTable ( newValue ) ;
117
111
}
118
112
} }
119
113
filterOptions = { ( options , params ) => {
@@ -122,8 +116,8 @@ const CreatorForm = ({
122
116
const { inputValue } = params ;
123
117
// Suggest the creation of a new contextInput
124
118
const isExisting = options . some (
125
- option => inputValue === option . name
126
- // console.log(inputValue)
119
+ option => inputValue === option . name
120
+ // console.log(inputValue)
127
121
) ;
128
122
if ( inputValue !== '' && ! isExisting ) {
129
123
filtered . push ( {
@@ -156,6 +150,11 @@ const CreatorForm = ({
156
150
freeSolo
157
151
renderInput = { params => (
158
152
< TextField { ...params } label = "Create/Select Context" />
153
+ // <TextField
154
+ // {...params}
155
+ // label="Free solo with text demo"
156
+ // onKeyUp={() => console.log(params.inputProps.value)}
157
+ // />
159
158
) }
160
159
/>
161
160
< Button variant = "contained" onClick = { handleClick } >
@@ -193,7 +192,7 @@ const CreatorForm = ({
193
192
</ Button >
194
193
</ Box >
195
194
196
- { /* <ContextTable target={contextArr[0].contextInputs}/> */ }
195
+ < ContextTable target = { tableState } />
197
196
</ Fragment >
198
197
) ;
199
198
} ;
0 commit comments