@@ -12,6 +12,8 @@ import { useDrag } from 'react-dnd';
12
12
import { IconProps } from '@mui/material' ;
13
13
import CodeIcon from '@mui/icons-material/Code' ;
14
14
import * as Icons from '@mui/icons-material' ;
15
+ import { useDispatch } from 'react-redux' ;
16
+ import { addChild } from '../../redux/reducers/slice/appStateSlice' ;
15
17
16
18
const useStyles = makeStyles ( {
17
19
HTMLPanelItem : {
@@ -118,6 +120,25 @@ const HTMLItem: React.FC<{
118
120
} )
119
121
) ;
120
122
} ;
123
+
124
+ const dispatch = useDispatch ( ) ;
125
+
126
+ const handleClick = ( ) => {
127
+ console . log ( 'Component clicked:' , name ) ;
128
+ console . log ( 'id' , id ) ;
129
+ // Dispatch action to add child
130
+ dispatch (
131
+ addChild ( {
132
+ type : 'HTML Element' ,
133
+ typeId : id ,
134
+ childId : null ,
135
+ contextParam : {
136
+ allContext : [ ]
137
+ }
138
+ } )
139
+ ) ;
140
+ } ;
141
+
121
142
// updated the id's to reflect the new element types input and label
122
143
return (
123
144
// HTML Elements
@@ -128,6 +149,9 @@ const HTMLItem: React.FC<{
128
149
style = { { borderColor : '#C6C6C6' } }
129
150
className = { `${ classes . HTMLPanelItem } ${ classes . darkThemeFontColor } ` }
130
151
id = "HTMLItem"
152
+ onClick = { ( ) => {
153
+ handleClick ( ) ;
154
+ } }
131
155
>
132
156
{ typeof IconComponent !== 'undefined' && (
133
157
< IconComponent fontSize = "small" align-items = "center" />
@@ -143,17 +167,21 @@ const HTMLItem: React.FC<{
143
167
style = { { borderColor : '#C6C6C6' } }
144
168
className = { `${ classes . HTMLPanelItem } ${ classes . darkThemeFontColor } ` }
145
169
id = "HTMLItem"
170
+ onClick = { ( ) => {
171
+ handleClick ( ) ;
172
+ } }
146
173
>
147
174
{ typeof CodeIcon !== 'undefined' && (
148
- < CodeIcon fontSize = "small" align-items = "center" /> ) }
175
+ < CodeIcon fontSize = "small" align-items = "center" />
176
+ ) }
149
177
{ name }
150
- < button
178
+ < button
151
179
id = "newElement"
152
180
style = { { color : '#C6C6C6' } }
153
181
onClick = { ( ) => deleteAllInstances ( id ) }
154
- >
155
- X
156
- </ button >
182
+ >
183
+ X
184
+ </ button >
157
185
</ div >
158
186
) }
159
187
{ modal }
0 commit comments