github.com/muhammedhassanm/blockchain@v0.0.0-20200120143007-697261defd4d/build-blockchain-insurance-app-master/web/src/shop/components/App.js (about) 1 'use strict'; 2 3 import React, { Props } from 'react'; 4 import PropTypes from 'prop-types'; 5 import { FormattedMessage } from 'react-intl'; 6 import { connect } from 'react-redux'; 7 import { withRouter } from 'react-router-dom'; 8 9 const app = ({ children, shopType }) => { 10 let shopHeadingMessage; 11 switch (shopType) { 12 case 'bikes': 13 shopHeadingMessage = <FormattedMessage id='Bike Shop' />; 14 break; 15 case 'smart-phones': 16 shopHeadingMessage = <FormattedMessage id='Smart Phone Shop' />; 17 break; 18 case 'skis': 19 shopHeadingMessage = <FormattedMessage id='Ski Shop' />; 20 break; 21 } 22 23 const shopWrapper = ( 24 <div> 25 <div className='ibm-columns'> 26 <div className='ibm-col-1-1'> 27 <h2 className='ibm-h2'>{shopHeadingMessage}</h2> 28 </div> 29 </div> 30 {children} 31 </div> 32 ); 33 34 const defaultWrapper = ( 35 <div className='main-content'> 36 {children} 37 </div> 38 ); 39 40 return shopHeadingMessage ? shopWrapper : defaultWrapper; 41 }; 42 43 app.propTypes = { 44 shopType: PropTypes.string 45 }; 46 47 function mapStateToProps(state, ownProps) { 48 return { 49 shopType: state.shop.type 50 }; 51 } 52 53 export default withRouter(connect(mapStateToProps)(app)); 54 55