-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add stock trader project and initial setup, basic layout for first page
- Loading branch information
1 parent
ac0c5db
commit 979952f
Showing
17 changed files
with
351 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,160 @@ | ||
import React, { Component } from 'react' | ||
import React, { Component, useEffect, useState } from 'react'; | ||
import { Switch, Route, Redirect, Link ,useHistory} from 'react-router-dom'; | ||
import {connect} from 'react-redux'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import { checkAuthState } from './selectors/authSelector'; | ||
import AppBar from '@material-ui/core/AppBar'; | ||
import Toolbar from '@material-ui/core/Toolbar'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import Button from '@material-ui/core/Button'; | ||
import IconButton from '@material-ui/core/IconButton'; | ||
import MenuIcon from '@material-ui/icons/Menu'; | ||
|
||
class App extends Component { | ||
const useStyles = makeStyles({ | ||
main: { | ||
display:'flex', | ||
justifyContent:'center', | ||
width:'100%', | ||
flexWrap: 'wrap' | ||
}, | ||
title: { | ||
flexGrow: 1 | ||
}, | ||
link: { | ||
paddingLeft:'20px', | ||
display:'flex', | ||
justifyContent:'flex-start', | ||
'&:hover': { | ||
color: 'rgb(0,180,5)' | ||
} | ||
}, | ||
primary: { | ||
color: 'inherit', | ||
backgroundColor: 'inherit' | ||
}, | ||
positionFixed: { | ||
position: 'inherit' | ||
}, | ||
signInButton: { | ||
textTransform: 'none', | ||
'&:hover': { | ||
color: 'rgb(0,180,5)', | ||
backgroundColor: 'inherit' | ||
} | ||
}, | ||
signUpButton: { | ||
textTransform: 'none', | ||
minWidth: '144px', | ||
padding: '0 16px', | ||
borderRadius: '24px', | ||
backgroundColor: 'rgba(0,200,5,1)', | ||
height: '48px', | ||
display: 'inline-flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
marginLeft: '30px', | ||
'&:hover': { | ||
backgroundColor: 'rgb(0,180,5)', | ||
backgroundBottomColor: '#000000', | ||
borderBottomWidth: '1px', | ||
borderBottomStyle: 'solid', | ||
} | ||
}, | ||
header: { | ||
width: '100%', | ||
backgroundColor:'rgba(195,245,60,1)', | ||
}, | ||
headerContainer: { | ||
margin: '0 auto', | ||
maxWidth: '1024px', | ||
padding: '100px 60px', | ||
width: '100%', | ||
}, | ||
header_left: { | ||
maxWidth: '45%', | ||
}, | ||
header_left_top: { | ||
fontSize: '60px', | ||
lineHeight: '72px', | ||
letterSpacing: '-2.4px', | ||
color: 'rgb(4,13,20)', | ||
marginBottom: '18px', | ||
whiteSpace: 'pre-line' | ||
}, | ||
header_left_mid: { | ||
marginTop: '24px', | ||
fontSize: '24px', | ||
lineHeight: '32px', | ||
letterSpacing: '-0.24px', | ||
color: '#040d14', | ||
}, | ||
header_left_button: { | ||
marginTop: '40px', | ||
display: 'flex', | ||
flexDirection:'column', | ||
alignItems: 'start' | ||
} | ||
}) | ||
const App = (props) => { | ||
const classes = useStyles(); | ||
return ( | ||
<React.Fragment> | ||
{checkAuthState()? | ||
<div className={classes.main}> | ||
Authenticated | ||
</div>: | ||
<div className={classes.main}> | ||
<AppBar classes={{colorPrimary: classes.primary, positionFixed: classes.positionFixed}}> | ||
<Toolbar> | ||
<IconButton edge="start"> | ||
<MenuIcon /> | ||
</IconButton> | ||
<div className={classes.link}> | ||
Learn | ||
</div> | ||
<div className={`${classes.title} ${classes.link}`}> | ||
Support | ||
</div> | ||
<Button classes={{root: classes.signInButton}}> | ||
<span className={'sansBold'}>Sign In</span> | ||
</Button> | ||
<Button classes={{root: classes.signUpButton}}> | ||
<span className={'sansBold'}>Sign Up</span> | ||
</Button> | ||
</Toolbar> | ||
</AppBar> | ||
<div className={classes.header}> | ||
<div className={classes.headerContainer}> | ||
<div className={classes.header_left}> | ||
<div className={classes.header_left_top}>Investing for Everyone</div> | ||
<div className={classes.header_left_mid}>Reacthood, a pioneer of commission-free investing, gives you more ways to make your money work harder.</div> | ||
<div className={classes.header_left_button}> | ||
<Button classes={{root: classes.signUpButton}} style={{marginLeft: '0', backgroundColor: '#000000', color: 'white'}}> | ||
<span className={'sansBold'}>Sign Up</span> | ||
</Button> | ||
</div> | ||
</div> | ||
<div className={classes.header_right}> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
} | ||
</React.Fragment> | ||
) | ||
} | ||
|
||
render () { | ||
return ( | ||
<h1>This is <span style={{fontWeight:'bold'}}>Stock Trader</span></h1> | ||
) | ||
const mapStateToProps = (state) => { | ||
return { | ||
auth: state.auth, | ||
} | ||
} | ||
|
||
export default App | ||
const mapDispatchToProps = (dispatch) => { | ||
return { | ||
onSignIn: (email,password)=> dispatch({type: 'SIGN_IN', data: {email, password}}), | ||
onLogout: (history) => dispatch({type: 'logout', data: history}), | ||
} | ||
} | ||
export default connect(mapStateToProps,mapDispatchToProps)(App); |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
import React, { Component } from 'react' | ||
import ReactDOM from 'react-dom' | ||
|
||
import App from './app'; | ||
import React, { Component } from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import {Provider} from 'react-redux'; | ||
import { BrowserRouter, Switch, Route } from 'react-router-dom'; | ||
import App from './App'; | ||
import './styles/App.css'; | ||
import Favicon from 'react-favicon'; | ||
import profile from './img/logo.png'; | ||
import store from './store'; | ||
|
||
ReactDOM.render( | ||
<App />, | ||
<Provider store={store}> | ||
<BrowserRouter> | ||
<Favicon url={profile} /> | ||
<App /> | ||
</BrowserRouter> | ||
</Provider>, | ||
document.getElementById("index") | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"title":"Stock Trader", | ||
"keywords":"react,multi-page,webpack,node", | ||
"description":"Stock Trader" | ||
"title":"Reacthood", | ||
"keywords":"stock market app implemented with React", | ||
"description":"Stock Market App using React" | ||
} |
33 changes: 33 additions & 0 deletions
33
inspiredblog/src/pages/stocktrader/reducers/authReducer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const initialState = { | ||
username: null, | ||
userId: null, | ||
} | ||
|
||
const authReducer = (state=initialState,action) => { | ||
switch(action.type) { | ||
case ('signin_success'): | ||
return { | ||
...state, | ||
userId: action.payload.userId, | ||
username: action.payload.username, | ||
} | ||
case ('signin_fail'): | ||
return { | ||
...state, | ||
} | ||
case ('signup_success'): | ||
return { | ||
...state, | ||
userId: action.payload.userId, | ||
username: action.payload.username, | ||
} | ||
case ('signup_fail'): | ||
return { | ||
...state, | ||
} | ||
default: | ||
return state | ||
} | ||
} | ||
|
||
export default authReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {combineReducers} from 'redux'; | ||
import authReducer from './authReducer'; | ||
|
||
const rootReducer = combineReducers( | ||
{ | ||
auth: authReducer, | ||
} | ||
); | ||
|
||
export default rootReducer; |
16 changes: 16 additions & 0 deletions
16
inspiredblog/src/pages/stocktrader/selectors/authSelector.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
// this is not a pure selector as it doesn't take state as arguement | ||
export const checkAuthState = () =>{ | ||
const expirationTime = localStorage.getItem('stock_expirationTime'); | ||
const currentDate = new Date(); | ||
if(localStorage.getItem('stock_token')){ | ||
if (currentDate >= new Date(expirationTime)){ | ||
localStorage.removeItem('stock_username'); | ||
localStorage.removeItem('stock_token'); | ||
localStorage.removeItem('stock_expirationTime'); | ||
return false; | ||
} | ||
return true; | ||
} | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import rootReducer from './reducers'; | ||
import createSagaMiddleware from 'redux-saga'; | ||
import { createStore, applyMiddleware,compose} from 'redux'; | ||
// import { rootSaga } from '../index/sagas'; | ||
// import {rootSaga} from './sagas'; | ||
|
||
const sagaMiddleware = createSagaMiddleware(); | ||
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; | ||
|
||
const store = createStore(rootReducer, composeEnhancers( | ||
applyMiddleware(sagaMiddleware) | ||
)); | ||
|
||
// sagaMiddleware.run(rootSaga); | ||
|
||
export default store; |
Oops, something went wrong.