Removed a few container pages as we will be using hooks instead. Cleaned up a few debug statements.

This commit is contained in:
Patrick Fic
2019-12-11 15:29:04 -08:00
parent bd7e502a92
commit 51040fd455
18 changed files with 190 additions and 182 deletions

View File

@@ -48,7 +48,7 @@ class App extends React.Component {
}); });
}); });
} }
console.log('###Debug (app.js)| Token', token)
//add the bearer token to the headers. //add the bearer token to the headers.
localStorage.setItem("token", token); localStorage.setItem("token", token);
} else { } else {
@@ -67,7 +67,7 @@ class App extends React.Component {
} }
render() { render() {
console.log("this.props.currentUser", this.props.currentUser.email); console.log("###Debug (App.js) | Props Current User: ", this.props.currentUser.email);
return ( return (
<div> <div>
<Switch> <Switch>

View File

@@ -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>
);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -1,9 +1,12 @@
import React from 'react' import React from "react";
import { Row, Col } from "antd";
export default function FooterComponent() { export default function FooterComponent() {
return ( return (
<div> <Row>
Copyright Snapt Software 2019. All rights reserved. <Col span={8} offset={9}>
</div> Copyright Snapt Software 2019. All rights reserved.
) </Col>
</Row>
);
} }

View File

@@ -1,12 +1,45 @@
import React from "react"; import React from "react";
import { ApolloConsumer } from "react-apollo"; import { ApolloConsumer } from "react-apollo";
import SignInFormComponent from "./sign-in-form.component"; import SignInFormComponent from "./sign-in-form.component";
import { Row, Col, Layout, Typography } from "antd";
import FooterComponent from "../footer/footer.component";
import Logo from "../../assets/logo240.png";
const { Content, Footer } = Layout;
export default function SignInFormContainer() { export default function SignInFormContainer() {
return ( return (
<ApolloConsumer> <ApolloConsumer>
{client => { {client => {
return <SignInFormComponent apolloClient={client} />; return (
<Layout>
<Content>
<Row align="middle">
<Col span="2" offset="8">
<div>
<img
src={Logo}
height="100"
width="100"
alt="Bodyshop.app"
/>
</div>
</Col>
<Col span="6">
<Typography.Title>Bodyshop.app</Typography.Title>
</Col>
</Row>
<Row>
<Col span="8" offset="8">
<SignInFormComponent apolloClient={client} />
</Col>
</Row>
</Content>
<Footer>
<FooterComponent />
</Footer>
</Layout>
);
}} }}
</ApolloConsumer> </ApolloConsumer>
); );

View File

@@ -1,40 +1,40 @@
import ApolloClient from "apollo-client"; // import ApolloClient from "apollo-client";
import { InMemoryCache } from "apollo-cache-inmemory"; // import { InMemoryCache } from "apollo-cache-inmemory";
import { HttpLink } from "apollo-link-http"; // import { HttpLink } from "apollo-link-http";
import { setContext } from "apollo-link-context"; // import { setContext } from "apollo-link-context";
import { resolvers, typeDefs } from "./resolvers"; // import { resolvers, typeDefs } from "./resolvers";
import apolloLogger from "apollo-link-logger"; // import apolloLogger from "apollo-link-logger";
import { ApolloLink } from "apollo-boost"; // import { ApolloLink } from "apollo-boost";
const httpLink = new HttpLink({ // const httpLink = new HttpLink({
uri: process.env.REACT_APP_GRAPHQL_ENDPOINT // uri: process.env.REACT_APP_GRAPHQL_ENDPOINT
}); // });
const authLink = setContext((_, { headers }) => { // const authLink = setContext((_, { headers }) => {
// get the authentication token from local storage if it exists // // get the authentication token from local storage if it exists
const token = localStorage.getItem("token"); // const token = localStorage.getItem("token");
// return the headers to the context so httpLink can read them // // return the headers to the context so httpLink can read them
if (token) { // if (token) {
return { // return {
headers: { // headers: {
...headers, // ...headers,
authorization: token ? `Bearer ${token}` : "" // authorization: token ? `Bearer ${token}` : ""
} // }
}; // };
} else { // } else {
return { headers }; // return { headers };
} // }
}); // });
const middlewares = []; // const middlewares = [];
if (process.env.NODE_ENV === "development") { // if (process.env.NODE_ENV === "development") {
middlewares.push(apolloLogger); // middlewares.push(apolloLogger);
} // }
middlewares.push(authLink.concat(httpLink)); // middlewares.push(authLink.concat(httpLink));
export const client = new ApolloClient({ // export const client = new ApolloClient({
link: ApolloLink.from(middlewares), // link: ApolloLink.from(middlewares),
cache: new InMemoryCache({ addTypename: false }), // cache: new InMemoryCache({ addTypename: false }),
typeDefs, // typeDefs,
resolvers // resolvers
}); // });

View File

@@ -1,19 +1,24 @@
import gql from "graphql-tag"; import gql from "graphql-tag";
export const GET_ALL_OPEN_JOBS = gql` export const GET_ALL_OPEN_JOBS = gql`
{ {
jobs { jobs {
id id
ro_number est_number
status ro_number
scheduled_completion status
scheduled_delivery scheduled_completion
vehicle { scheduled_delivery
v_model_yr vehicle {
v_model_desc v_model_yr
v_make_desc v_make_desc
plate_no v_model_desc
plate_no
}
owner {
first_name
last_name
}
} }
} }
}
`; `;

View File

@@ -1,6 +0,0 @@
import React from "react";
import JobsPage from "./jobs.pages";
export default function JobsPageContainer() {
return <JobsPage />;
}

View File

@@ -0,0 +1,82 @@
import React from "react";
import { useQuery } from "@apollo/react-hooks";
//import { GET_ALL_OPEN_JOBS } from "../../graphql/jobs.queries";
import { Table, Divider, Icon } from "antd";
import { GET_ALL_OPEN_JOBS } from "../../graphql/jobs.queries";
export default function JobsPage() {
const {
loading,
error,
data: { jobs }
} = useQuery(GET_ALL_OPEN_JOBS);
const columns = [
{
title: "RO #",
dataIndex: "ro_number",
key: "ro_number"
},
{
title: "Est. #",
dataIndex: "est_number",
key: "est_number"
},
{
title: "Status",
dataIndex: "status",
key: "status"
},
{
title: "Customer",
dataIndex: "customer",
key: "customer",
render: (text, record) => {
return record.owner ? (
<div>{record.owner.first_name + " " + record.owner.last_name}</div>
) : (
"No Customer"
);
}
},
{
title: "Vehicle",
dataIndex: "vehicle",
key: "vehicle",
render: (text, record) => {
return record.vehicle ? record.vehicle.v_make_desc : "No Vehicle";
}
},
{
title: "Action",
key: "action",
render: (text, record) => (
<span>
<a>Action {record.ro_number}</a>
<Divider type="vertical" />
<a>Delete</a>
<Divider type="vertical" />
<a className="ant-dropdown-link">
More actions <Icon type="down" />
</a>
</span>
)
}
];
// if (loading) return <Spin />;
if (error) return `Error! ${error.message}`;
console.log("$$$Develop (jobs.page.jsx) | jobs", jobs);
return (
<div>
<Table
loading={loading}
pagination={{ position: "bottom" }}
columns={columns.map(item => ({ ...item }))}
rowKey="id"
dataSource={jobs ? jobs : null}
/>
</div>
);
}

View File

@@ -1,25 +0,0 @@
import React from "react";
import { useQuery } from "@apollo/react-hooks";
//import { GET_ALL_OPEN_JOBS } from "../../graphql/jobs.queries";
import { gql } from "apollo-boost";
import Spin from "../../components/loading-spinner/loading-spinner.component";
const g = gql`
{
associations {
id
shopid
useremail
active
}
}
`;
export default function JobsPage() {
const { loading, error, data } = useQuery(g);
if (loading) return <Spin />;
if (error) return `Error! ${error.message}`;
console.log(data);
return <div>Hi</div>;
}

View File

@@ -2,8 +2,8 @@ import React from "react";
import { Route } from "react-router"; import { Route } from "react-router";
//Component Imports //Component Imports
import WhiteBoardPageContainer from "../white-board/white-board.page.container"; import WhiteBoardPage from "../white-board/white-board.page";
import JobsPageContainer from "../jobs/jobs.page.container"; import JobsPage from "../jobs/jobs.page";
import JobsDetailPageContainer from "../jobs-detail/jobs-detail.page.container"; import JobsDetailPageContainer from "../jobs-detail/jobs-detail.page.container";
import HeaderComponentContainer from "../../components/header/header.container"; import HeaderComponentContainer from "../../components/header/header.container";
import FooterComponent from "../../components/footer/footer.component"; import FooterComponent from "../../components/footer/footer.component";
@@ -20,17 +20,9 @@ export default function Manage({ match }) {
</Header> </Header>
<Content> <Content>
<Route <Route exact path={`${match.path}`} component={WhiteBoardPage} />
exact
path={`${match.path}`}
component={WhiteBoardPageContainer}
/>
<Route <Route exact path={`${match.path}/jobs`} component={JobsPage} />
exact
path={`${match.path}/jobs`}
component={JobsPageContainer}
/>
<Route <Route
path={`${match.path}/jobs/:jobId`} path={`${match.path}/jobs/:jobId`}
component={JobsDetailPageContainer} component={JobsDetailPageContainer}

View File

@@ -1,7 +0,0 @@
import React from "react";
import WhiteBoardPage from "./white-board.page";
export default function WhiteBoardPageContainer() {
return <WhiteBoardPage />;
}

View File

@@ -40,6 +40,7 @@ export default function WhiteBoardPage({ whiteBoardLeftSiderVisible }) {
return ( return (
<Layout> <Layout>
<Sider <Sider
collapsible={true}
breakpoint="lg" breakpoint="lg"
collapsedWidth="0" collapsedWidth="0"
onBreakpoint={broken => { onBreakpoint={broken => {

View File

@@ -9962,7 +9962,7 @@ react-app-polyfill@^1.0.4:
regenerator-runtime "^0.13.3" regenerator-runtime "^0.13.3"
whatwg-fetch "^3.0.0" whatwg-fetch "^3.0.0"
"react-click-outside@github:tj/react-click-outside": react-click-outside@tj/react-click-outside:
version "1.1.1" version "1.1.1"
resolved "https://codeload.github.com/tj/react-click-outside/tar.gz/a833ddc5be47490307f9fcc6ed09d8c353108510" resolved "https://codeload.github.com/tj/react-click-outside/tar.gz/a833ddc5be47490307f9fcc6ed09d8c353108510"
@@ -10980,9 +10980,9 @@ slice-ansi@^2.1.0:
astral-regex "^1.0.0" astral-regex "^1.0.0"
is-fullwidth-code-point "^2.0.0" is-fullwidth-code-point "^2.0.0"
"smooth-dnd@git+https://github.com/rcdexta/smooth-dnd.git": "smooth-dnd@https://github.com/rcdexta/smooth-dnd":
version "0.6.3" version "0.6.3"
resolved "git+https://github.com/rcdexta/smooth-dnd.git#f13924c67bf6ffe4613d97bb1ee83f11d364eb1e" resolved "https://github.com/rcdexta/smooth-dnd#f13924c67bf6ffe4613d97bb1ee83f11d364eb1e"
snapdragon-node@^2.0.1: snapdragon-node@^2.0.1:
version "2.1.1" version "2.1.1"

View File

@@ -7,6 +7,7 @@
"npm": "6.11.3" "npm": "6.11.3"
}, },
"scripts": { "scripts": {
"setup": "yarn && cd firebase && yarn && cd .. && cd client && yarn ",
"client": "cd client && yarn start", "client": "cd client && yarn start",
"server": "nodemon server.js", "server": "nodemon server.js",
"build": "cd client && npm run build", "build": "cd client && npm run build",