1- import React , { useState , useRef } from 'react' ;
1+ import React , { useState , useRef } from 'react' ;
22import Modal from '@mui/material/Modal' ;
33import TableStateProps from '../StateManagement/CreateTab/components/TableStateProps' ;
44
5- function UseStateModal ( { updateAttributeWithState, attributeToChange, childId } ) {
5+ function UseStateModal ( { updateAttributeWithState, attributeToChange } ) {
66 const [ open , setOpen ] = useState ( false ) ;
77 const [ stateKey , setStateKey ] = useState ( '' ) ;
88 const [ statePropsId , setStatePropsId ] = useState ( - 1 ) ;
9- const [ componentProviderId , setComponentProviderId ] = useState ( 1 ) ;
9+ const [ componentProviderId , setComponentProviderId ] = useState ( 1 ) ;
1010 const container = useRef ( null ) ;
1111 // table to choose state from
1212 const body = (
1313 < div className = "useState-position" >
1414 < div className = "useState-header" >
1515 < span > Choose State</ span >
1616 < button
17- style = { { margin : '5px 5px' , padding : '1px' , float : 'right' } }
17+ style = { { margin : '5px 5px' , padding : '1px' , float : 'right' } }
1818 onClick = { ( ) => {
1919 setStateKey ( '' ) ;
2020 setStatePropsId ( - 1 ) ;
21- setOpen ( false ) } }
21+ setOpen ( false ) ;
22+ } }
2223 >
2324 X
24- </ button >
25+ </ button >
2526 </ div >
2627 < div className = "useState-window" >
2728 < div className = "useState-stateDisplay" >
2829 < TableStateProps
29- providerId = { componentProviderId }
30- canDeleteState = { false }
30+ providerId = { componentProviderId }
31+ canDeleteState = { false }
3132 selectHandler = { ( table ) => {
32- updateAttributeWithState ( attributeToChange , componentProviderId , statePropsId > 0 ? statePropsId : table . row . id , table . row , stateKey + table . row . key ) ;
33- setStateKey ( '' )
34- setStatePropsId ( - 1 ) ;
35- setOpen ( false ) ;
33+ updateAttributeWithState (
34+ attributeToChange ,
35+ componentProviderId ,
36+ statePropsId > 0 ? statePropsId : table . row . id ,
37+ table . row ,
38+ stateKey + table . row . key
39+ ) ;
40+ setStateKey ( '' ) ;
41+ setStatePropsId ( - 1 ) ;
42+ setOpen ( false ) ;
3643 } }
3744 isThemeLight = { true }
3845 />
@@ -43,8 +50,12 @@ function UseStateModal({ updateAttributeWithState, attributeToChange, childId })
4350
4451 return (
4552 < div ref = { container } >
46- < button className = "useState-btn" onClick = { ( ) => setOpen ( true ) } > USE STATE</ button >
47- < Modal open = { open } container = { container . current } > { body } </ Modal >
53+ < button className = "useState-btn" onClick = { ( ) => setOpen ( true ) } >
54+ USE STATE
55+ </ button >
56+ < Modal open = { open } container = { container . current } >
57+ { body }
58+ </ Modal >
4859 </ div >
4960 ) ;
5061}
0 commit comments