Skip to content

Commit

Permalink
pulling correct user info from query string
Browse files Browse the repository at this point in the history
  • Loading branch information
leianne committed May 5, 2019
1 parent 22a488c commit 581ccf1
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 11 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
BACKEND_API=http://localhost:5000/api/auth
3 changes: 2 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ myAccountBtnClicked = (e) => {
}
userSelected = (e, user) => {
e.preventDefault();
console.log(user)
this.props.userSearch(user)
}

Expand All @@ -94,7 +95,7 @@ myAccountBtnClicked = (e) => {
}

const mapStateToProps = state => {
console.log(state.login)
console.log(state)
return {

}
Expand Down
8 changes: 4 additions & 4 deletions src/routes/Dashboards/GH/GHBreakdownView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 === ''){
Expand Down
2 changes: 1 addition & 1 deletion src/routes/Dashboards/GH/UserDataChartComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/Dashboards/SearchView.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion src/routes/Dashboards/UsersSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function UsersSearch(props) {
</CardContent>
</CardActionArea>
<CardActions>
<Button size="small" color="primary" onClick={(e) => props.userSelected(e, user)}>
<Button size="small" color="primary" href={`/ghdashboard/search=${user.login}`} >
View More
</Button>
</CardActions>
Expand Down
1 change: 1 addition & 0 deletions src/store/reducers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ const rootReducer = combineReducers({
search: searchReducer
});

console.log()
export default rootReducer;
3 changes: 2 additions & 1 deletion src/store/reducers/searchReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,5 +18,6 @@ const searchReducer = (state = initialState, action) => {
return state
}
}
console.log(initialState)

export default searchReducer;

0 comments on commit 581ccf1

Please sign in to comment.