Skip to content

Commit d69c744

Browse files
added netlify.toml and more eslint fixes
1 parent 2743fb1 commit d69c744

File tree

5 files changed

+43
-22
lines changed

5 files changed

+43
-22
lines changed

netlify.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[[redirects]]
2+
from = "/*"
3+
to = "/index.html"
4+
status = 200
5+
6+
[context.production.environment]
7+
REACT_APP_SVR_API = "https://stonehaven-academy.herokuapp.com/api"
8+
9+
[context.branch-deploy.environment]
10+
REACT_APP_SVR_API = "https://stonehaven-server-staging.herokuapp.com/api"
11+
12+
[context.deploy-preview.environment]
13+
REACT_APP_SVR_API = "https://stonehaven-server-staging.herokuapp.com/api"

src/App.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import { Switch, Route, Redirect } from 'react-router-dom';
44
import DUMMY_DATA from './DUMMY_DATA';
5-
import tokenServices from './utils/tokenServices';
6-
import ProtectedRoute from './utils/ProtectedRoute';
5+
import { tokenServices, ProtectedRoute } from './utils';
76
import {
87
NavBar,
98
HomePage,
@@ -38,11 +37,11 @@ class App extends React.Component {
3837
};
3938
}
4039

41-
componentWillMount = () => {
42-
const { history, location } = this.props;
43-
console.log(history);
44-
console.log(location);
45-
}
40+
// componentWillMount = () => {
41+
// const { history, location } = this.props;
42+
// console.log(history);
43+
// console.log(location);
44+
// }
4645

4746
/**
4847
* get user data from database
@@ -52,7 +51,7 @@ class App extends React.Component {
5251
if (user) {
5352
this.setState({ isAuthenticated: true, user });
5453
}
55-
}
54+
};
5655

5756
handleLogin = () => {
5857
const user = tokenServices.getToken();
@@ -61,19 +60,24 @@ class App extends React.Component {
6160
} else {
6261
this.setState({ isAuthenticated: null, user: null });
6362
}
64-
}
63+
};
6564

66-
handleLogoff = () =>{
65+
handleLogoff = () => {
6766
tokenServices.removeToken();
68-
this.setState({isAuthenticated: false, user: null});
69-
}
67+
this.setState({ isAuthenticated: false, user: null });
68+
};
7069

7170
render() {
7271
const { courses } = DUMMY_DATA;
73-
// const { user, isAuthenticated } = this.state;
72+
const { user, isAuthenticated } = this.state;
73+
7474
return (
7575
<div id="start-page">
76-
<NavBar links={links} isAuthenticated={this.state.isAuthenticated} handleLogoff={this.handleLogoff} />
76+
<NavBar
77+
links={links}
78+
isAuthenticated={isAuthenticated}
79+
handleLogoff={this.handleLogoff}
80+
/>
7781
<Switch>
7882
<Route exact path="/" component={HomePage} />
7983
<Route
@@ -85,15 +89,15 @@ class App extends React.Component {
8589
{/* Login Protected Route */}
8690
<ProtectedRoute
8791
path={links.login}
88-
isAuthenticated={!this.state.isAuthenticated}
92+
isAuthenticated={!isAuthenticated}
8993
redirectLink={links.dashboard}
9094
component={RegistrationPage}
9195
handleLogin={this.handleLogin}
9296
/>
9397
{/* Dashboard Protected Route */}
9498
<ProtectedRoute
9599
path={links.dashboard}
96-
isAuthenticated={this.state.isAuthenticated}
100+
isAuthenticated={isAuthenticated}
97101
redirectLink={links.login}
98102
component={DashboardPage}
99103
/>

src/components/registration/LogIn.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
3-
import Axios from 'axios';
3+
import axios from 'axios';
44
import '../../css/registration/LogIn.scss';
55

66
const { REACT_APP_SVR_API } = process.env;
@@ -22,7 +22,8 @@ class LogIn extends Component {
2222
password,
2323
};
2424

25-
Axios.post(`${REACT_APP_SVR_API}/user/login`, data)
25+
axios
26+
.post(`${REACT_APP_SVR_API}/user/login`, data)
2627
.then(response => {
2728
localStorage.setItem('app-token', response.data.token);
2829
// this.props.history.push("/dashboard");
@@ -68,13 +69,13 @@ class LogIn extends Component {
6869
onChange={event => this.setState({ password: event.target.value })}
6970
/>
7071
<button id="submit-button" type="button" onClick={this.LogInHandler}>
71-
Submit
72+
{`Submit`}
7273
</button>
7374
</form>
7475
<p>
75-
Don't have an account,{' '}
76+
{`Don't have an account, `}
7677
<button id="signup-button" type="button" onClick={changeToSignup()}>
77-
Sign up!
78+
{`Sign up!`}
7879
</button>
7980
</p>
8081
</div>

src/components/registration/SignUp.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class SignUp extends Component {
5353
axios
5454
.post(`${REACT_APP_SVR_API}/user/`, data)
5555
.then(response => {
56-
console.log(response);
56+
// console.log(response);
5757
// Stores token in local storeage for the time being
5858
localStorage.setItem('app-token', response.data.token);
5959
// Sweet Alert for successful registration
@@ -74,6 +74,7 @@ class SignUp extends Component {
7474
console.error('An unknown error has occurred');
7575
}
7676
} catch (ex) {
77+
alert('Something went wrong...');
7778
Promise.reject(ex);
7879
}
7980
});

src/utils/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
export { FontAwesomeIcon } from './fontAwesome';
22
export { default as userAPI } from './userAPI';
3+
export { default as tokenServices } from './tokenServices';
4+
export { default as ProtectedRoute } from './ProtectedRoute';

0 commit comments

Comments
 (0)