Removed a few container pages as we will be using hooks instead. Cleaned up a few debug statements.
This commit is contained in:
@@ -48,7 +48,7 @@ class App extends React.Component {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
console.log('###Debug (app.js)| Token', token)
|
||||
//add the bearer token to the headers.
|
||||
localStorage.setItem("token", token);
|
||||
} else {
|
||||
@@ -67,7 +67,7 @@ class App extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
console.log("this.props.currentUser", this.props.currentUser.email);
|
||||
console.log("###Debug (App.js) | Props Current User: ", this.props.currentUser.email);
|
||||
return (
|
||||
<div>
|
||||
<Switch>
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
import React from "react";
|
||||
import { Switch, Route, Redirect } from "react-router";
|
||||
import { ApolloProvider } from "react-apollo";
|
||||
import { HttpLink } from "apollo-link-http";
|
||||
import ApolloClient from "apollo-client";
|
||||
import { InMemoryCache } from "apollo-cache-inmemory";
|
||||
import { resolvers, typeDefs } from "../graphql/resolvers";
|
||||
import initialState from "../graphql/initial-state";
|
||||
import { gql } from "apollo-boost";
|
||||
//Styling imports
|
||||
import "./App.css";
|
||||
|
||||
//Component Imports
|
||||
import LandingPage from "../pages/landing/landing.page";
|
||||
import Manage from "../pages/manage/manage.page";
|
||||
|
||||
import PrivateRoute from "../utils/private-route";
|
||||
import SignInContainer from "../pages/sign-in/sign-in.container";
|
||||
import Unauthorized from "../pages/unauthorized/unauthorized.component";
|
||||
|
||||
const graphqlEndpoint = process.env.REACT_APP_GRAPHQL_ENDPOINT;
|
||||
|
||||
export default function App({ authState }) {
|
||||
const isIn = authState.status === "in";
|
||||
const headers = isIn ? { Authorization: `Bearer ${authState.token}` } : {};
|
||||
const httpLink = new HttpLink({
|
||||
uri: graphqlEndpoint,
|
||||
headers
|
||||
});
|
||||
const client = new ApolloClient({
|
||||
link: httpLink,
|
||||
cache: new InMemoryCache(),
|
||||
resolvers,
|
||||
typeDefs
|
||||
});
|
||||
|
||||
//Init local state.
|
||||
client.writeData({
|
||||
data: {
|
||||
...initialState,
|
||||
currentUser: {
|
||||
__typename: null,
|
||||
email: authState.user ? authState.user.email : null,
|
||||
displayName: authState.user ? authState.user.displayName : null
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<ApolloProvider client={client}>
|
||||
<div>{authState.status}</div>
|
||||
<Switch>
|
||||
<Route exact path="/" component={LandingPage} />
|
||||
<Route exact path="/unauthorized" component={Unauthorized} />
|
||||
<Route
|
||||
exact
|
||||
path="/signin"
|
||||
render={() =>
|
||||
authState.status == "in" ? (
|
||||
<Redirect to="/manage" />
|
||||
) : (
|
||||
<SignInContainer />
|
||||
)
|
||||
}
|
||||
/>
|
||||
{/* <Route path="/signin" component={SignInContainer} /> */}
|
||||
<PrivateRoute isAuthorized={isIn} path="/manage" component={Manage} />
|
||||
</Switch>
|
||||
</ApolloProvider>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user