save board model to localstorage
This commit is contained in:
		
							parent
							
								
									e00617ac78
								
							
						
					
					
						commit
						6fcaff9cc3
					
				| @ -3,6 +3,7 @@ import { | |||||||
| } from "./types"; | } from "./types"; | ||||||
| 
 | 
 | ||||||
| export const setBoard = (board) => (dispatch) => { | export const setBoard = (board) => (dispatch) => { | ||||||
|  |   window.localStorage.setItem("board", board); | ||||||
|   dispatch({ |   dispatch({ | ||||||
|     type: BOARD, |     type: BOARD, | ||||||
|     payload: board, |     payload: board, | ||||||
|  | |||||||
| @ -37,9 +37,7 @@ class DeviceSeclection extends Component { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   toggleDialog = () => { |   toggleDialog = () => { | ||||||
|      |  | ||||||
|     this.props.setBoard(this.state.selectedBoard) |     this.props.setBoard(this.state.selectedBoard) | ||||||
| 
 |  | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   onChange = (e) => { |   onChange = (e) => { | ||||||
| @ -57,12 +55,14 @@ class DeviceSeclection extends Component { | |||||||
|     this.setState({ selectedBoard: value }) |     this.setState({ selectedBoard: value }) | ||||||
|     this.props.setBoard(value) |     this.props.setBoard(value) | ||||||
|     this.setState({ open: !this.state }); |     this.setState({ open: !this.state }); | ||||||
|     |  | ||||||
| 
 |  | ||||||
|     |  | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   render() { |   render() { | ||||||
|  |     const board = this.props.selectedBoard; | ||||||
|  |     if (board) { | ||||||
|  |       return null; | ||||||
|  |     } | ||||||
|  |     else { | ||||||
|       return ( |       return ( | ||||||
|         <Dialog |         <Dialog | ||||||
|           style={{ zIndex: 9999999 }} |           style={{ zIndex: 9999999 }} | ||||||
| @ -90,7 +90,6 @@ class DeviceSeclection extends Component { | |||||||
|                 </IconButton> |                 </IconButton> | ||||||
|                 <p>senseBox MCU</p> |                 <p>senseBox MCU</p> | ||||||
|               </Grid> |               </Grid> | ||||||
| 
 |  | ||||||
|               {/* <Grid item xs={4}> |               {/* <Grid item xs={4}> | ||||||
|             <IconButton onClick={(e) => this.onclick(e, "esp")}> |             <IconButton onClick={(e) => this.onclick(e, "esp")}> | ||||||
|               <Avatar |               <Avatar | ||||||
| @ -143,6 +142,7 @@ class DeviceSeclection extends Component { | |||||||
|       ); |       ); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| DeviceSeclection.propTypes = { | DeviceSeclection.propTypes = { | ||||||
|   pageVisits: PropTypes.number.isRequired, |   pageVisits: PropTypes.number.isRequired, | ||||||
|  | |||||||
| @ -4,7 +4,7 @@ const initialValue = () => { | |||||||
|   if (window.localStorage.getItem("board")) { |   if (window.localStorage.getItem("board")) { | ||||||
|     return window.localStorage.getItem("board"); |     return window.localStorage.getItem("board"); | ||||||
|   } |   } | ||||||
|   return "bla"; |   return null; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const initialState = { | const initialState = { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user