From 7d33484294cf26a2b62019a696d32bbff9a5073c Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Mon, 23 Mar 2020 17:40:48 -0700 Subject: [PATCH] WIP on several user stories. BOD-10 BOD-52 --- client/src/App/App.container.jsx | 38 +++------------- client/src/App/App.js | 5 ++- .../global-loading-bar.component.jsx | 9 ++-- .../owner-detail-form.component.jsx | 43 ++++++++----------- .../owner-detail-jobs.component.jsx | 7 +-- .../owner-detail-update-jobs.component.jsx | 11 +++-- .../jobs-create/jobs-create.container.jsx | 7 +++ .../pages/manage/manage.page.component.jsx | 13 ++---- .../pages/manage/manage.page.container.jsx | 22 +++++----- client/yarn.lock | 2 - 10 files changed, 63 insertions(+), 94 deletions(-) diff --git a/client/src/App/App.container.jsx b/client/src/App/App.container.jsx index a302d74ed..a860694be 100644 --- a/client/src/App/App.container.jsx +++ b/client/src/App/App.container.jsx @@ -1,3 +1,4 @@ +import { ApolloProvider } from "@apollo/react-common"; import { ApolloLink } from "apollo-boost"; import { InMemoryCache } from "apollo-cache-inmemory"; import ApolloClient from "apollo-client"; @@ -8,22 +9,13 @@ import apolloLogger from "apollo-link-logger"; import { WebSocketLink } from "apollo-link-ws"; import { getMainDefinition } from "apollo-utilities"; import React, { Component } from "react"; -import { ApolloProvider } from "react-apollo"; +import GlobalLoadingBar from "../components/global-loading-bar/global-loading-bar.component"; import SpinnerComponent from "../components/loading-spinner/loading-spinner.component"; -//import { shouldRefreshToken, refreshToken } from "../graphql/middleware"; import errorLink from "../graphql/apollo-error-handling"; import App from "./App"; -import { connect } from "react-redux"; -import { - endLoading, - startLoading -} from "../redux/application/application.actions"; -const mapDispatchToProps = dispatch => ({ - startLoading: () => dispatch(startLoading()), - endLoading: () => dispatch(endLoading()) -}); -class AppContainer extends Component { + +export default class AppContainer extends Component { state = { client: null, loaded: false @@ -92,23 +84,6 @@ class AppContainer extends Component { middlewares.push(apolloLogger); } - //New - // const startLoad = new ApolloLink((operation, forward) => { - // console.log("Starting", operation); - // this.props.startLoading(); - // return forward(operation); - // }); - - // const endLoad = new ApolloLink((operation, forward) => { - // return forward(operation).map(response => { - // console.log("Completed", operation); - // this.props.endLoading(); - // return response; - // }); - // }); - // middlewares.push(startLoad, endLoad); - //End new - middlewares.push(errorLink.concat(authLink.concat(link))); const cache = new InMemoryCache(); @@ -130,15 +105,14 @@ class AppContainer extends Component { render() { const { client, loaded } = this.state; if (!loaded) { - return ; + return ; } return ( + ); } } - -export default connect(null, mapDispatchToProps)(AppContainer); diff --git a/client/src/App/App.js b/client/src/App/App.js index 475571c60..fa2bb5fd2 100644 --- a/client/src/App/App.js +++ b/client/src/App/App.js @@ -26,6 +26,7 @@ const mapStateToProps = createStructuredSelector({ const mapDispatchToProps = dispatch => ({ checkUserSession: () => dispatch(checkUserSession()) }); + export default connect( mapStateToProps, mapDispatchToProps @@ -34,6 +35,7 @@ export default connect( checkUserSession(); return () => {}; }, [checkUserSession]); + const { t } = useTranslation(); if (currentUser && currentUser.language) i18next.changeLanguage(currentUser.language, (err, t) => { @@ -49,14 +51,13 @@ export default connect(
- }> + }> + }}>
+ }}>
- - {isFieldsTouched([], true) ? ( - - ) : null} - - + - + + name='allow_text_message' + valuePropName='checked'> - + - + - + - + + ]}> - + - + - + + name='preferred_contact'> - + diff --git a/client/src/components/owner-detail-jobs/owner-detail-jobs.component.jsx b/client/src/components/owner-detail-jobs/owner-detail-jobs.component.jsx index 04de5d41c..5e4102a64 100644 --- a/client/src/components/owner-detail-jobs/owner-detail-jobs.component.jsx +++ b/client/src/components/owner-detail-jobs/owner-detail-jobs.component.jsx @@ -65,6 +65,7 @@ function OwnerDetailJobsComponent({ bodyshop, owner }) {
)} @@ -73,10 +74,10 @@ function OwnerDetailJobsComponent({ bodyshop, owner }) { rowKey='id' dataSource={owner.jobs} rowSelection={{ - onSelect: props => { - setSelectedJobs([...selectedJobs, props.id]); + onSelect: (record, selected, selectedRows) => { + setSelectedJobs(selectedRows ? selectedRows.map(i => i.id) : []); }, - // type: "radio", + selectedRowKeys: selectedJobs, getCheckboxProps: record => ({ disabled: bodyshop.md_ro_statuses.open_statuses diff --git a/client/src/components/owner-detail-update-jobs/owner-detail-update-jobs.component.jsx b/client/src/components/owner-detail-update-jobs/owner-detail-update-jobs.component.jsx index 949a92b38..889fe702f 100644 --- a/client/src/components/owner-detail-update-jobs/owner-detail-update-jobs.component.jsx +++ b/client/src/components/owner-detail-update-jobs/owner-detail-update-jobs.component.jsx @@ -6,7 +6,8 @@ import { UPDATE_JOBS } from "../../graphql/jobs.queries"; export default function OwnerDetailUpdateJobsComponent({ owner, - selectedJobs + selectedJobs, + disabled }) { const { t } = useTranslation(); const [updateJobs] = useMutation(UPDATE_JOBS); @@ -32,6 +33,10 @@ export default function OwnerDetailUpdateJobsComponent({ } }); }; - - return ; + console.log("disabled", disabled); + return ( + + ); } diff --git a/client/src/pages/jobs-create/jobs-create.container.jsx b/client/src/pages/jobs-create/jobs-create.container.jsx index d6ee278d3..6c0e21251 100644 --- a/client/src/pages/jobs-create/jobs-create.container.jsx +++ b/client/src/pages/jobs-create/jobs-create.container.jsx @@ -63,13 +63,20 @@ function JobsCreateContainer({ bodyshop }) { let ownerData; if (!!job.owner) { ownerData = job.owner.data; + ownerData.shopid = bodyshop.id; delete ownerData.allow_text_message; delete ownerData.preferred_contact; + delete job.ownerid; } else { ownerData = RemoteOwnerData.data.owners_by_pk; delete ownerData.id; delete ownerData.__typename; } + if (!!job.vehicle) { + delete job.vehicleid; + job.vehicle.data.shopid = bodyshop.id; + } + job = { ...job, ...ownerData }; runInsertJob(job); }; diff --git a/client/src/pages/manage/manage.page.component.jsx b/client/src/pages/manage/manage.page.component.jsx index 5f4567c70..7b2613dc6 100644 --- a/client/src/pages/manage/manage.page.component.jsx +++ b/client/src/pages/manage/manage.page.component.jsx @@ -43,9 +43,7 @@ const ShopVendorPageContainer = lazy(() => const EmailOverlayContainer = lazy(() => import("../../components/email-overlay/email-overlay.container.jsx") ); -const GlobalLoadingBar = lazy(() => - import("../../components/global-loading-bar/global-loading-bar.component") -); + const JobsCreateContainerPage = lazy(() => import("../jobs-create/jobs-create.container") ); @@ -66,16 +64,13 @@ export default function Manage({ match }) { - + className='content-container' + style={{ padding: "0em 4em 4em" }}> - } - > + }> diff --git a/client/src/pages/manage/manage.page.container.jsx b/client/src/pages/manage/manage.page.container.jsx index 6232001ef..20a00a5cf 100644 --- a/client/src/pages/manage/manage.page.container.jsx +++ b/client/src/pages/manage/manage.page.container.jsx @@ -1,20 +1,16 @@ +import { useQuery } from "@apollo/react-hooks"; import { notification } from "antd"; import React, { useEffect } from "react"; -import { useQuery } from "@apollo/react-hooks"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component"; import { QUERY_BODYSHOP } from "../../graphql/bodyshop.queries"; import { setBodyshop } from "../../redux/user/user.actions"; -import { - selectBodyshop, - selectCurrentUser -} from "../../redux/user/user.selectors"; +import { selectBodyshop } from "../../redux/user/user.selectors"; import ManagePage from "./manage.page.component"; const mapStateToProps = createStructuredSelector({ - currentUser: selectCurrentUser, bodyshop: selectBodyshop }); @@ -22,13 +18,11 @@ const mapDispatchToProps = dispatch => ({ setBodyshop: bs => dispatch(setBodyshop(bs)) }); -export default connect( - mapStateToProps, - mapDispatchToProps -)(function ManagePageContainer({ match, setBodyshop, bodyshop }) { +function ManagePageContainer({ match, setBodyshop, bodyshop }) { const { error, data } = useQuery(QUERY_BODYSHOP, { fetchPolicy: "network-only" }); + const { t } = useTranslation(); if (error) { notification["error"]({ message: t("bodyshop.errors.loading") }); @@ -36,10 +30,14 @@ export default connect( useEffect(() => { if (data) setBodyshop(data.bodyshops[0]); - return () => {}; }, [data, setBodyshop]); if (!bodyshop) return ; return ; -}); +} + +export default connect( + mapStateToProps, + mapDispatchToProps +)(ManagePageContainer); diff --git a/client/yarn.lock b/client/yarn.lock index e52e58d81..42a0848ed 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -12203,8 +12203,6 @@ rxjs@^6.5.3: version "6.5.4" resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.4.tgz#e0777fe0d184cec7872df147f303572d414e211c" integrity sha512-naMQXcgEo3csAEGvw/NydRA0fuS2nDZJiw1YUWFKU7aPPAPGZEsD4Iimit96qwCieH6y614MCLYwdkrWx7z/7Q== - dependencies: - tslib "^1.9.0" safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2"