From 581ccf1c435451777ce53052e544800a6b7a6bf2 Mon Sep 17 00:00:00 2001 From: leianne louis Date: Sun, 5 May 2019 12:06:17 -0400 Subject: [PATCH] pulling correct user info from query string --- .env | 1 - src/App.js | 3 ++- src/routes/Dashboards/GH/GHBreakdownView.js | 8 ++++---- src/routes/Dashboards/GH/UserDataChartComponent.js | 2 +- src/routes/Dashboards/SearchView.js | 4 ++-- src/routes/Dashboards/UsersSearch.js | 2 +- src/store/reducers/index.js | 1 + src/store/reducers/searchReducer.js | 3 ++- 8 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.env b/.env index 2d707a3..e69de29 100644 --- a/.env +++ b/.env @@ -1 +0,0 @@ -BACKEND_API=http://localhost:5000/api/auth \ No newline at end of file diff --git a/src/App.js b/src/App.js index d2b3826..c6d25c3 100644 --- a/src/App.js +++ b/src/App.js @@ -78,6 +78,7 @@ myAccountBtnClicked = (e) => { } userSelected = (e, user) => { e.preventDefault(); + console.log(user) this.props.userSearch(user) } @@ -94,7 +95,7 @@ myAccountBtnClicked = (e) => { } const mapStateToProps = state => { - console.log(state.login) + console.log(state) return { } diff --git a/src/routes/Dashboards/GH/GHBreakdownView.js b/src/routes/Dashboards/GH/GHBreakdownView.js index 19e0770..98325cd 100644 --- a/src/routes/Dashboards/GH/GHBreakdownView.js +++ b/src/routes/Dashboards/GH/GHBreakdownView.js @@ -5,7 +5,7 @@ import axios from 'axios'; import { connect } from 'react-redux'; import Loader from 'react-loader-spinner' import UserDataChartComponent from './UserDataChartComponent'; -const baseURL = 'http://localhost:5000/api/github/search'; +const baseURL = process.env.BACKEND_API || 'http://localhost:5000/api/github/search' class GHBreakdownView extends Component { state = { @@ -23,9 +23,9 @@ class GHBreakdownView extends Component { userInfo: res.data.userInfo })}) .catch(err => console.log(err)) - axios.post(`${baseURL}/commits`, user) - .then(res => console.log(res)) - .catch(err => console.log(err)) + // axios.post(`${baseURL}/commits`, user) + // .then(res => console.log(res)) + // .catch(err => console.log(err)) } render() { if(this.state.userInfo.login === ''){ diff --git a/src/routes/Dashboards/GH/UserDataChartComponent.js b/src/routes/Dashboards/GH/UserDataChartComponent.js index fbc7b68..af71de9 100644 --- a/src/routes/Dashboards/GH/UserDataChartComponent.js +++ b/src/routes/Dashboards/GH/UserDataChartComponent.js @@ -3,7 +3,7 @@ import { LineChart } from "react-easy-chart"; import Tabs from '@material-ui/core/Tabs'; import Tab from '@material-ui/core/Tab'; import axios from 'axios'; -const baseURL = 'http://localhost:5000/api/github/search'; +const baseURL = process.env.BACKEND_API || 'http://localhost:5000/api/github/search'; class UserDataChartComponent extends React.Component { state = { diff --git a/src/routes/Dashboards/SearchView.js b/src/routes/Dashboards/SearchView.js index 415c461..b92a0dd 100644 --- a/src/routes/Dashboards/SearchView.js +++ b/src/routes/Dashboards/SearchView.js @@ -6,7 +6,7 @@ import SearchComponent from './SearchComponent'; import {NotificationContainer, NotificationManager } from 'react-notifications'; import UsersSearch from './UsersSearch'; import './Dashboard.css' - +const baseURL = process.env.BACKEND_API || 'http://localhost:5000/api/github/search'; class SearchView extends Component { // STATE state = { @@ -24,7 +24,7 @@ class SearchView extends Component { } // HANDLE SUBMIT - for fuzzy searchw handleSubmit = (e) => { - const url = 'http://localhost:5000/api/github/search/users' + const url = `${baseURL}/users` e.preventDefault(); const search = this.state.search this.setState({ diff --git a/src/routes/Dashboards/UsersSearch.js b/src/routes/Dashboards/UsersSearch.js index 413b7ab..42c8b61 100644 --- a/src/routes/Dashboards/UsersSearch.js +++ b/src/routes/Dashboards/UsersSearch.js @@ -31,7 +31,7 @@ function UsersSearch(props) { - diff --git a/src/store/reducers/index.js b/src/store/reducers/index.js index fe9833a..e49d1da 100644 --- a/src/store/reducers/index.js +++ b/src/store/reducers/index.js @@ -9,4 +9,5 @@ const rootReducer = combineReducers({ search: searchReducer }); +console.log() export default rootReducer; \ No newline at end of file diff --git a/src/store/reducers/searchReducer.js b/src/store/reducers/searchReducer.js index eeda081..06fa639 100644 --- a/src/store/reducers/searchReducer.js +++ b/src/store/reducers/searchReducer.js @@ -9,7 +9,7 @@ const initialState = { const searchReducer = (state = initialState, action) => { switch (action.type) { case USER_SEARCH: - window.location.href = '/ghdashboard' + console.log(state) return { ...state, user: action.payload @@ -18,5 +18,6 @@ const searchReducer = (state = initialState, action) => { return state } } +console.log(initialState) export default searchReducer; \ No newline at end of file