1
1
import { AddRoutes } from '../../interfaces/Interfaces'
2
- import React , { useContext } from 'react' ;
2
+ import React , { useContext , useState } from 'react' ;
3
3
import StateContext from '../../context/context' ;
4
4
import FormControl from '@material-ui/core/FormControl' ;
5
5
import MenuItem from '@material-ui/core/MenuItem' ;
@@ -11,6 +11,7 @@ import { styleContext } from '../../containers/AppContainer';
11
11
function AddLink ( { id } : AddRoutes ) {
12
12
const { isThemeLight } = useContext ( styleContext ) ;
13
13
const [ state , dispatch ] = useContext ( StateContext ) ;
14
+
14
15
const handleClick = ( id ) => {
15
16
dispatch ( {
16
17
type : 'ADD CHILD' ,
@@ -26,16 +27,16 @@ function AddLink({ id }: AddRoutes) {
26
27
const currComponent = state . components . find ( element => element . id === state . canvasFocus . componentId ) ;
27
28
currComponent . children . forEach ( element => {
28
29
if ( element . childId === id ) {
29
- element . attributes . compLink = event . target . value ;
30
- dispatch ( { type : 'UPDATE ATTRIBUTES' , payload : element } )
30
+ const state = JSON . parse ( JSON . stringify ( element ) ) ;
31
+ state . attributes . compLink = event . target . value ;
32
+ dispatch ( { type : 'UPDATE ATTRIBUTES' , payload : state } )
31
33
}
32
34
} ) ;
33
- // selectedPageName.compLink = event.target.value;
34
- // dispatch({ type: 'HREF TO', payload: });
35
35
}
36
36
37
37
let pagesItems = state . components . filter ( comp => state . rootComponents . includes ( comp . id ) ) ;
38
38
let dropDown = pagesItems . map ( comp => < MenuItem value = { comp . name } > { comp . name } </ MenuItem > ) ;
39
+
39
40
return (
40
41
< div style = { { paddingBottom : '1px' , float : 'right' } } >
41
42
< FormControl size = 'small' >
0 commit comments