diff --git a/client/src/actions/index.js b/client/src/actions/index.js new file mode 100644 index 0000000..e415b37 --- /dev/null +++ b/client/src/actions/index.js @@ -0,0 +1,7 @@ +import axios from 'axios' +import { FETCH_USER } from './types' + +export const fetchUser = () => async dispatch => { + const res = await axios.get('/api/current_user') + dispatch({ type: FETCH_USER, payload: res.data }) +} diff --git a/client/src/actions/types.js b/client/src/actions/types.js new file mode 100644 index 0000000..a33d22c --- /dev/null +++ b/client/src/actions/types.js @@ -0,0 +1 @@ +export const FETCH_USER = "fetch_user"; \ No newline at end of file diff --git a/client/src/components/App.css b/client/src/components/App.css new file mode 100644 index 0000000..c5c6e8a --- /dev/null +++ b/client/src/components/App.css @@ -0,0 +1,28 @@ +.App { + text-align: center; +} + +.App-logo { + animation: App-logo-spin infinite 20s linear; + height: 80px; +} + +.App-header { + background-color: #222; + height: 150px; + padding: 20px; + color: white; +} + +.App-title { + font-size: 1.5em; +} + +.App-intro { + font-size: large; +} + +@keyframes App-logo-spin { + from { transform: rotate(0deg); } + to { transform: rotate(360deg); } +} diff --git a/client/src/components/App.js b/client/src/components/App.js new file mode 100644 index 0000000..a3644c1 --- /dev/null +++ b/client/src/components/App.js @@ -0,0 +1,37 @@ +import React, { Component } from 'react' +import { BrowserRouter, Route } from 'react-router-dom' +import { connect } from 'react-redux' +import * as actions from '../actions' +import './App.css' + +import Header from './Header' +import Landing from './Landing' +import Dashboard from './/Dashboard' +// const Dashboard = () =>

Dashboard

+const SurveyNew = () =>

SurveyNew

+ +class App extends Component { + componentDidMount () { + this.props.fetchUser() + } + + render () { + return ( +
+
+ +
+
+ + + + {/* */} +
+
+
+
+ ) + } +} + +export default connect(null, actions)(App) diff --git a/client/src/components/App.test.js b/client/src/components/App.test.js new file mode 100644 index 0000000..a754b20 --- /dev/null +++ b/client/src/components/App.test.js @@ -0,0 +1,9 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import App from './App'; + +it('renders without crashing', () => { + const div = document.createElement('div'); + ReactDOM.render(, div); + ReactDOM.unmountComponentAtNode(div); +}); diff --git a/client/src/components/Dashboard.js b/client/src/components/Dashboard.js new file mode 100644 index 0000000..33abb09 --- /dev/null +++ b/client/src/components/Dashboard.js @@ -0,0 +1,18 @@ +import React from 'react' +import FindConsumer from './findConsumer' +import Map from './map' + +const MapStart = () => { + return ( +
+
+ +
+
+ +
+
+ ) +} + +export default MapStart diff --git a/client/src/components/Header.js b/client/src/components/Header.js new file mode 100644 index 0000000..5943e75 --- /dev/null +++ b/client/src/components/Header.js @@ -0,0 +1,70 @@ +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import AppBar from '@material-ui/core/AppBar' +import Toolbar from '@material-ui/core/Toolbar' +import IconButton from '@material-ui/core/IconButton' +import MenuIcon from '@material-ui/icons/Menu' +import Button from '@material-ui/core/Button' +import Typography from '@material-ui/core/Typography' +import { withStyles } from '@material-ui/core' +import { connect } from 'react-redux' + +const styles = theme => ({ + root: { + flexGrow: 1 + }, + flex: { + flexGrow: 1 + }, + menuButton: { + marginLeft: -12, + marginRight: 20 + } +}) + +class Header extends Component { + constructor (props) { + super(props) + + this.state = {} + } + renderContent () { + switch (this.props.auth) { + case null: + return 'Verificando conexão ...' + case false: + return + default: + return + } + } + render () { + const { classes } = this.props + return ( +
+ + + + + + + NEXUS + + + {this.renderContent()} + + +
+ ) + } +} + +Header.propTypes = { + classes: PropTypes.object.isRequired +} + +function mapStateToPropos (state) { + return { auth: state.auth } +} + +export default connect(mapStateToPropos)(withStyles(styles)(Header)) diff --git a/client/src/components/Landing.js b/client/src/components/Landing.js new file mode 100644 index 0000000..b25e285 --- /dev/null +++ b/client/src/components/Landing.js @@ -0,0 +1,14 @@ +import React from 'react' + +const Landing = () => { + return ( +
+

+ Título +

+ Página inicial +
+ ) +} + +export default Landing diff --git a/client/src/reducers/authReducer.js b/client/src/reducers/authReducer.js new file mode 100644 index 0000000..4ab6ca1 --- /dev/null +++ b/client/src/reducers/authReducer.js @@ -0,0 +1,18 @@ +import { FETCH_USER } from '../actions/types' + +/** + * Records whether or not the user is logged in + * + * @export + * @param {*} [state={}] + * @param {*} action + * @returns + */ +export default function (state = null, action) { + switch (action.type) { + case FETCH_USER: + return action.payload || false; // if empty string returns false + default: + return state + } +} diff --git a/client/src/reducers/index.js b/client/src/reducers/index.js new file mode 100644 index 0000000..6475941 --- /dev/null +++ b/client/src/reducers/index.js @@ -0,0 +1,6 @@ +import { combineReducers } from 'redux'; +import authReducer from './authReducer'; + +export default combineReducers({ + auth: authReducer +}); -- libgit2 0.21.2