diff --git a/apollo.config.js b/apollo.config.js new file mode 100644 index 000000000..e949522fb --- /dev/null +++ b/apollo.config.js @@ -0,0 +1,11 @@ +module.exports = { + client: { + service: { + name: "Dev", + url: "https://bodyshop-dev-db.herokuapp.com/v1/graphql", + headers: { + "x-hasura-admin-secret": "Dev-BodyShopAppBySnaptSoftware!" + } + } + } +}; diff --git a/client/src/App/App.js b/client/src/App/App.js index 4d60a8be2..e8609691f 100644 --- a/client/src/App/App.js +++ b/client/src/App/App.js @@ -15,6 +15,7 @@ import Unauthorized from "../pages/unauthorized/unauthorized.component"; import { auth } from "../firebase/firebase.utils"; import { UPSERT_USER } from "../graphql/user.queries"; import { GET_CURRENT_USER } from "../graphql/local.queries"; +import { QUERY_BODYSHOP } from "../graphql/bodyshop.queries"; import LoadingSpinner from "../components/loading-spinner/loading-spinner.component"; import AlertComponent from "../components/alert/alert.component"; @@ -42,18 +43,6 @@ export default () => { }); } - apolloClient.writeData({ - data: { - currentUser: { - email: user.email, - displayName: user.displayName, - token, - uid: user.uid, - photoUrl: user.photoURL, - __typename: "currentUser" - } - } - }); //add the bearer token to the headers. localStorage.setItem("token", token); @@ -66,6 +55,36 @@ export default () => { .catch(error => { console.log("Upsert error!!!!", error); }); + + apolloClient + .query({ + query: QUERY_BODYSHOP, + fetchPolicy: "network-only" + }) + .then(r => { + const bodyShopData = r.data.bodyshops[0]; + apolloClient.writeData({ + data: { + bodyShopData: { ...bodyShopData, __typename: "bodyShopData" } + } + }); + }) + .catch(error => { + console.log("Error getting bodyshop data.", error); + }); + + apolloClient.writeData({ + data: { + currentUser: { + email: user.email, + displayName: user.displayName, + token, + uid: user.uid, + photoUrl: user.photoURL, + __typename: "currentUser" + } + } + }); } else { apolloClient.writeData({ data: { currentUser: null } }); localStorage.removeItem("token"); diff --git a/client/src/components/job-lines/job-lines.component.jsx b/client/src/components/job-lines/job-lines.component.jsx index 3117b4072..7e5fdd320 100644 --- a/client/src/components/job-lines/job-lines.component.jsx +++ b/client/src/components/job-lines/job-lines.component.jsx @@ -35,10 +35,11 @@ export default function JobLinesComponent({ loading, joblines }) { setState({ ...state, filteredInfo: filters, sortedInfo: sorter }); }; - const handleChange = event => { - const { value } = event.target; - setState({ ...state, filterinfo: { text: [value] } }); - }; + // const handleChange = event => { + // const { value } = event.target; + // setState({ ...state, filterinfo: { text: [value] } }); + // }; + console.log('joblines', joblines) return ( { + eventBus = handle; + }; + + return ( + + alert(`Card with id:${cardId} clicked. Has metadata.id: ${metadata.id}`) + } + /> + ); +} diff --git a/client/src/components/white-board-kanban/white-board-kanban.container.jsx b/client/src/components/white-board-kanban/white-board-kanban.container.jsx new file mode 100644 index 000000000..85c6cf640 --- /dev/null +++ b/client/src/components/white-board-kanban/white-board-kanban.container.jsx @@ -0,0 +1,57 @@ +import React from "react"; +import { useSubscription, useQuery } from "@apollo/react-hooks"; +import { SUBSCRIPTION_JOBS_IN_PRODUCTION } from "../../graphql/jobs.queries"; +import { GET_BODYSHOP } from "../../graphql/local.queries"; +import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component"; +import Alert from "../../components/alert/alert.component"; +import WhiteBoardKanBan from "./white-board-kanban.component"; + +export default function WhiteBoardKanBanContainer() { +// const HookBodyshopData = useQuery(GET_BODYSHOP); + const { loading, error, data } = useSubscription( + SUBSCRIPTION_JOBS_IN_PRODUCTION, + { + fetchPolicy: "network-only" + } + ); + + const static_data = { + lanes: [ + { + id: "lane1", + title: "Planned Tasks", + label: "2/2", + cards: [ + { + id: "Card1", + title: "Write Blog", + description: "Can AI make memes", + label: "30 mins" + }, + { + id: "Card2", + title: "Pay Rent", + description: "Transfer via NEFT", + label: "5 mins", + metadata: { sha: "be312a1" } + } + ] + }, + { + id: "lane2", + title: "Completed", + label: "0/0", + cards: [] + } + ] + }; + +// if (HookBodyshopData.loading) return "Local query loading"; +// if (HookBodyshopData.error) return "Local query error" + error.message; +// console.log("HookBodyshopData.data", HookBodyshopData.data); + if (loading) return ; + if (error) return ; + let eventBus; + console.log("Sub data", data); + return ; +} diff --git a/client/src/components/white-board-left-sider/white-board-left-sider.container.jsx b/client/src/components/white-board-left-sider/white-board-left-sider.container.jsx index 790f3b822..b23aad9b2 100644 --- a/client/src/components/white-board-left-sider/white-board-left-sider.container.jsx +++ b/client/src/components/white-board-left-sider/white-board-left-sider.container.jsx @@ -1,20 +1,7 @@ import React from "react"; -import { Query } from "react-apollo"; import WhiteBoardLeftSiderComponent from "./white-board-left-sider.component"; -import Spin from "../loading-spinner/loading-spinner.component"; -import { GET_WHITE_BOARD_LEFT_SIDER_VISIBLE } from "../../graphql/local.queries"; export default function WhiteBoardPageContainer() { - return ( - - {({ loading, error, data: { whiteBoardLeftSiderVisible } }) => { - if (loading) return ; - if (error) return error.message; - return ( - - ); - }} - - ); + return ; } diff --git a/client/src/graphql/bodyshop.queries.js b/client/src/graphql/bodyshop.queries.js new file mode 100644 index 000000000..82e660930 --- /dev/null +++ b/client/src/graphql/bodyshop.queries.js @@ -0,0 +1,24 @@ +import { gql } from "apollo-boost"; + +export const QUERY_BODYSHOP = gql` + query QUERY_BODYSHOP { + bodyshops(where: { associations: { active: { _eq: true } } }) { + address1 + address2 + city + country + created_at + email + federal_tax_id + id + insurance_vendor_id + logo_img_path + md_ro_statuses + shopname + state + state_tax_id + updated_at + zip_post + } + } +`; diff --git a/client/src/graphql/initial-state.js b/client/src/graphql/initial-state.js index 817a49928..671221c8b 100644 --- a/client/src/graphql/initial-state.js +++ b/client/src/graphql/initial-state.js @@ -3,5 +3,5 @@ export default { currentUser: null, selectedNavItem: "Home", recentItems: [], - whiteBoardLeftSiderVisible: true + bodyShopData: null }; diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js index dd8f3bf3b..164c2d215 100644 --- a/client/src/graphql/jobs.queries.js +++ b/client/src/graphql/jobs.queries.js @@ -47,6 +47,54 @@ export const SUBSCRIPTION_ALL_OPEN_JOBS = gql` } `; +export const QUERY_JOBS_IN_PRODUCTION = gql` + query QUERY_JOBS_IN_PRODUCTION { + jobs { + id + updated_at + est_number + ro_number + status + scheduled_completion + scheduled_delivery + vehicle { + v_model_yr + v_make_desc + v_model_desc + plate_no + } + owner { + first_name + last_name + } + } + } +`; + +export const SUBSCRIPTION_JOBS_IN_PRODUCTION = gql` + subscription SUBSCRIPTION_JOBS_IN_PRODUCTION { + jobs { + id + updated_at + est_number + ro_number + status + scheduled_completion + scheduled_delivery + vehicle { + v_model_yr + v_make_desc + v_model_desc + plate_no + } + owner { + first_name + last_name + } + } + } +`; + export const GET_JOB_BY_PK = gql` query GET_JOB_BY_PK($id: uuid!) { jobs_by_pk(id: $id) { diff --git a/client/src/graphql/local.queries.js b/client/src/graphql/local.queries.js index d0c4298c0..88ae13c4f 100644 --- a/client/src/graphql/local.queries.js +++ b/client/src/graphql/local.queries.js @@ -31,3 +31,11 @@ export const GET_WHITE_BOARD_LEFT_SIDER_VISIBLE = gql` whiteBoardLeftSiderVisible @client } `; + +export const GET_BODYSHOP = gql` + query LOCAL_GET_BODY_SHOP { + bodyShopData @client { + shopname + } + } +`; diff --git a/client/src/pages/jobs/jobs.page.jsx b/client/src/pages/jobs/jobs.page.jsx index 9a488028e..532cf576e 100644 --- a/client/src/pages/jobs/jobs.page.jsx +++ b/client/src/pages/jobs/jobs.page.jsx @@ -1,11 +1,10 @@ import React from "react"; import { useSubscription } from "@apollo/react-hooks"; import AlertComponent from "../../components/alert/alert.component"; - +import { Col } from "antd"; import { SUBSCRIPTION_ALL_OPEN_JOBS } from "../../graphql/jobs.queries"; import JobsList from "../../components/jobs-list/jobs-list.component"; -import Test from "./test"; export default function JobsPage() { const { loading, error, data } = useSubscription(SUBSCRIPTION_ALL_OPEN_JOBS, { @@ -15,9 +14,8 @@ export default function JobsPage() { if (error) return ; return ( -
+
- - + ); } diff --git a/client/src/pages/manage/manage.page.jsx b/client/src/pages/manage/manage.page.jsx index 8239a7475..b4cf8133e 100644 --- a/client/src/pages/manage/manage.page.jsx +++ b/client/src/pages/manage/manage.page.jsx @@ -8,7 +8,7 @@ import JobsDetailPage from "../jobs-detail/jobs-detail.page"; import HeaderContainer from "../../components/header/header.container"; import FooterComponent from "../../components/footer/footer.component"; -import { Layout, BackTop, Col } from "antd"; +import { Layout, BackTop } from "antd"; const { Header, Content, Footer } = Layout; //This page will handle all routing for the entire application. @@ -20,15 +20,10 @@ export default function Manage({ match }) { - - + - - - + +