Commit f58a0394cb21e7ad990eb69d0c4d6a3e02fa50e7

Authored by José Maria Villac Pinheiro
1 parent 9f1b0a75
Exists in master

V.0.9.1 - Added missing files from last commit

client/src/actions/index.js 0 → 100644
... ... @@ -0,0 +1,7 @@
  1 +import axios from 'axios'
  2 +import { FETCH_USER } from './types'
  3 +
  4 +export const fetchUser = () => async dispatch => {
  5 + const res = await axios.get('/api/current_user')
  6 + dispatch({ type: FETCH_USER, payload: res.data })
  7 +}
... ...
client/src/actions/types.js 0 → 100644
... ... @@ -0,0 +1 @@
  1 +export const FETCH_USER = "fetch_user";
0 2 \ No newline at end of file
... ...
client/src/components/App.css 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +.App {
  2 + text-align: center;
  3 +}
  4 +
  5 +.App-logo {
  6 + animation: App-logo-spin infinite 20s linear;
  7 + height: 80px;
  8 +}
  9 +
  10 +.App-header {
  11 + background-color: #222;
  12 + height: 150px;
  13 + padding: 20px;
  14 + color: white;
  15 +}
  16 +
  17 +.App-title {
  18 + font-size: 1.5em;
  19 +}
  20 +
  21 +.App-intro {
  22 + font-size: large;
  23 +}
  24 +
  25 +@keyframes App-logo-spin {
  26 + from { transform: rotate(0deg); }
  27 + to { transform: rotate(360deg); }
  28 +}
... ...
client/src/components/App.js 0 → 100644
... ... @@ -0,0 +1,37 @@
  1 +import React, { Component } from 'react'
  2 +import { BrowserRouter, Route } from 'react-router-dom'
  3 +import { connect } from 'react-redux'
  4 +import * as actions from '../actions'
  5 +import './App.css'
  6 +
  7 +import Header from './Header'
  8 +import Landing from './Landing'
  9 +import Dashboard from './/Dashboard'
  10 +// const Dashboard = () => <h2>Dashboard</h2>
  11 +const SurveyNew = () => <h2>SurveyNew</h2>
  12 +
  13 +class App extends Component {
  14 + componentDidMount () {
  15 + this.props.fetchUser()
  16 + }
  17 +
  18 + render () {
  19 + return (
  20 + <div className='App'>
  21 + <div>
  22 + <BrowserRouter>
  23 + <div>
  24 + <Header />
  25 + <Route exact path='/' component={Landing} />
  26 + <Route exact path='/surveys' component={Dashboard} />
  27 + <Route path='/surveys/new' component={SurveyNew} />
  28 + {/* <Route path='/mapstart' component={MapStart} /> */}
  29 + </div>
  30 + </BrowserRouter>
  31 + </div>
  32 + </div>
  33 + )
  34 + }
  35 +}
  36 +
  37 +export default connect(null, actions)(App)
... ...
client/src/components/App.test.js 0 → 100644
... ... @@ -0,0 +1,9 @@
  1 +import React from 'react';
  2 +import ReactDOM from 'react-dom';
  3 +import App from './App';
  4 +
  5 +it('renders without crashing', () => {
  6 + const div = document.createElement('div');
  7 + ReactDOM.render(<App />, div);
  8 + ReactDOM.unmountComponentAtNode(div);
  9 +});
... ...
client/src/components/Dashboard.js 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +import React from 'react'
  2 +import FindConsumer from './findConsumer'
  3 +import Map from './map'
  4 +
  5 +const MapStart = () => {
  6 + return (
  7 + <div className='App'>
  8 + <div>
  9 + <FindConsumer />
  10 + </div>
  11 + <div>
  12 + <Map />
  13 + </div>
  14 + </div>
  15 + )
  16 +}
  17 +
  18 +export default MapStart
... ...
client/src/components/Header.js 0 → 100644
... ... @@ -0,0 +1,70 @@
  1 +import React, { Component } from 'react'
  2 +import PropTypes from 'prop-types'
  3 +import AppBar from '@material-ui/core/AppBar'
  4 +import Toolbar from '@material-ui/core/Toolbar'
  5 +import IconButton from '@material-ui/core/IconButton'
  6 +import MenuIcon from '@material-ui/icons/Menu'
  7 +import Button from '@material-ui/core/Button'
  8 +import Typography from '@material-ui/core/Typography'
  9 +import { withStyles } from '@material-ui/core'
  10 +import { connect } from 'react-redux'
  11 +
  12 +const styles = theme => ({
  13 + root: {
  14 + flexGrow: 1
  15 + },
  16 + flex: {
  17 + flexGrow: 1
  18 + },
  19 + menuButton: {
  20 + marginLeft: -12,
  21 + marginRight: 20
  22 + }
  23 +})
  24 +
  25 +class Header extends Component {
  26 + constructor (props) {
  27 + super(props)
  28 +
  29 + this.state = {}
  30 + }
  31 + renderContent () {
  32 + switch (this.props.auth) {
  33 + case null:
  34 + return 'Verificando conexão ...'
  35 + case false:
  36 + return <Button color='inherit' href='/auth/google'>Login with Google</Button>
  37 + default:
  38 + return <Button color='inherit' href="/api/logout">Logout</Button>
  39 + }
  40 + }
  41 + render () {
  42 + const { classes } = this.props
  43 + return (
  44 + <div className={classes.root}>
  45 + <AppBar position='static'>
  46 + <Toolbar>
  47 + <IconButton className={classes.menuButton} color='inherit' aria-label='Menu'>
  48 + <MenuIcon />
  49 + </IconButton>
  50 + <a href='http://www.nexusbr.com' target='_blank' rel='noopener noreferrer'>
  51 + <img src='https://nexusbr.com/images/logo.png' alt='NEXUS' width='100' height='39' />
  52 + </a>
  53 + <Typography variant='title' color='inherit' className={classes.flex} />
  54 + {this.renderContent()}
  55 + </Toolbar>
  56 + </AppBar>
  57 + </div>
  58 + )
  59 + }
  60 +}
  61 +
  62 +Header.propTypes = {
  63 + classes: PropTypes.object.isRequired
  64 +}
  65 +
  66 +function mapStateToPropos (state) {
  67 + return { auth: state.auth }
  68 +}
  69 +
  70 +export default connect(mapStateToPropos)(withStyles(styles)(Header))
... ...
client/src/components/Landing.js 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +import React from 'react'
  2 +
  3 +const Landing = () => {
  4 + return (
  5 + <div style={{ textAlign: 'center' }}>
  6 + <h1>
  7 + Título
  8 + </h1>
  9 + Página inicial
  10 + </div>
  11 + )
  12 +}
  13 +
  14 +export default Landing
... ...
client/src/reducers/authReducer.js 0 → 100644
... ... @@ -0,0 +1,18 @@
  1 +import { FETCH_USER } from '../actions/types'
  2 +
  3 +/**
  4 + * Records whether or not the user is logged in
  5 + *
  6 + * @export
  7 + * @param {*} [state={}]
  8 + * @param {*} action
  9 + * @returns
  10 + */
  11 +export default function (state = null, action) {
  12 + switch (action.type) {
  13 + case FETCH_USER:
  14 + return action.payload || false; // if empty string returns false
  15 + default:
  16 + return state
  17 + }
  18 +}
... ...
client/src/reducers/index.js 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +import { combineReducers } from 'redux';
  2 +import authReducer from './authReducer';
  3 +
  4 +export default combineReducers({
  5 + auth: authReducer
  6 +});
... ...