From 7cfc984cc0f3c273cd0f56a6c677956c96000b36 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 14 Apr 2021 10:22:03 -0700 Subject: [PATCH] IO-899 Contract FInd Modal --- bodyshop_translations.babel | 63 +++++++ .../contracts-find-modal.component.jsx | 37 ++++ .../contracts-find-modal.container.jsx | 169 ++++++++++++++++++ .../contracts-list.component.jsx | 26 ++- client/src/graphql/cccontracts.queries.js | 42 +++++ client/src/redux/modals/modals.reducer.js | 1 + client/src/redux/modals/modals.selectors.js | 5 + client/src/translations/en_us/common.json | 3 + client/src/translations/es/common.json | 3 + client/src/translations/fr/common.json | 3 + 10 files changed, 351 insertions(+), 1 deletion(-) create mode 100644 client/src/components/contracts-find-modal/contracts-find-modal.component.jsx create mode 100644 client/src/components/contracts-find-modal/contracts-find-modal.container.jsx diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index b78241ce0..dd3aa0873 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -7530,6 +7530,27 @@ + + find + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + printcontract false @@ -8621,6 +8642,27 @@ + + findcontract + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + noteconvertedfrom false @@ -8684,6 +8726,27 @@ + + time + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + vehicle false diff --git a/client/src/components/contracts-find-modal/contracts-find-modal.component.jsx b/client/src/components/contracts-find-modal/contracts-find-modal.component.jsx new file mode 100644 index 000000000..d20f98fcc --- /dev/null +++ b/client/src/components/contracts-find-modal/contracts-find-modal.component.jsx @@ -0,0 +1,37 @@ +import { Form, Input } from "antd"; +import React from "react"; +import { useTranslation } from "react-i18next"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectBodyshop } from "../../redux/user/user.selectors"; +import FormDateTimePicker from "../form-date-time-picker/form-date-time-picker.component"; + +const mapStateToProps = createStructuredSelector({ + bodyshop: selectBodyshop, +}); + +export default connect(mapStateToProps, null)(PartsReceiveModalComponent); + +export function PartsReceiveModalComponent({ bodyshop, form }) { + const { t } = useTranslation(); + + return ( +
+ + + + + + +
+ ); +} diff --git a/client/src/components/contracts-find-modal/contracts-find-modal.container.jsx b/client/src/components/contracts-find-modal/contracts-find-modal.container.jsx new file mode 100644 index 000000000..31daf4a4e --- /dev/null +++ b/client/src/components/contracts-find-modal/contracts-find-modal.container.jsx @@ -0,0 +1,169 @@ +import { useLazyQuery } from "@apollo/client"; +import { Button, Form, Modal, Table } from "antd"; +import React, { useEffect } from "react"; +import { useTranslation } from "react-i18next"; +import { connect } from "react-redux"; +import { Link } from "react-router-dom"; +import { createStructuredSelector } from "reselect"; +import { logImEXEvent } from "../../firebase/firebase.utils"; +import { FIND_CONTRACT } from "../../graphql/cccontracts.queries"; +import { toggleModalVisible } from "../../redux/modals/modals.actions"; +import { selectContractFinder } from "../../redux/modals/modals.selectors"; +import { selectBodyshop } from "../../redux/user/user.selectors"; +import { DateTimeFormatter } from "../../utils/DateFormatter"; +import ContractsFindModalComponent from "./contracts-find-modal.component"; +import AlertComponent from "../alert/alert.component"; + +const mapStateToProps = createStructuredSelector({ + bodyshop: selectBodyshop, + contractFinderModal: selectContractFinder, +}); + +const mapDispatchToProps = (dispatch) => ({ + toggleModalVisible: () => dispatch(toggleModalVisible("contractFinder")), +}); + +export function ContractsFindModalContainer({ + contractFinderModal, + toggleModalVisible, + + bodyshop, +}) { + const { t } = useTranslation(); + + const { visible } = contractFinderModal; + + const [form] = Form.useForm(); + + // const [updateJobLines] = useMutation(UPDATE_JOB_LINE); + const [callSearch, { loading, error, data }] = useLazyQuery(FIND_CONTRACT); + const handleFinish = async (values) => { + logImEXEvent("contract_finder_search"); + + //Execute contract find + + callSearch({ + variables: { + fleet: + (values.fleet && values.fleet !== "" && values.fleet) || undefined, + time: values.time, + }, + }); + }; + + useEffect(() => { + if (visible) { + form.resetFields(); + } + }, [visible, form]); + + return ( + toggleModalVisible()} + onOk={() => toggleModalVisible()} + destroyOnClose + forceRender + > +
+ + + {error && ( + + )} + ( + + {record.agreementnumber || ""} + + ), + }, + { + title: t("jobs.fields.ro_number"), + dataIndex: "job.ro_number", + key: "job.ro_number", + render: (text, record) => ( + + {record.job.ro_number || ""} + + ), + }, + { + title: t("contracts.fields.driver"), + dataIndex: "driver_ln", + key: "driver_ln", + render: (text, record) => + `${record.driver_fn || ""} ${record.driver_ln || ""}`, + }, + { + title: t("contracts.labels.vehicle"), + dataIndex: "vehicle", + key: "vehicle", + render: (text, record) => ( + {`${ + record.courtesycar.year + } ${record.courtesycar.make} ${record.courtesycar.model} ${ + record.courtesycar.plate + ? `(${record.courtesycar.plate})` + : "" + }`} + ), + }, + { + title: t("contracts.fields.status"), + dataIndex: "status", + render: (text, record) => t(record.status), + }, + { + title: t("contracts.fields.start"), + dataIndex: "start", + key: "start", + render: (text, record) => ( + {record.start} + ), + }, + { + title: t("contracts.fields.scheduledreturn"), + dataIndex: "scheduledreturn", + key: "scheduledreturn", + render: (text, record) => ( + {record.scheduledreturn} + ), + }, + { + title: t("contracts.fields.actualreturn"), + dataIndex: "actualreturn", + key: "actualreturn", + render: (text, record) => ( + {record.actualreturn} + ), + }, + ]} + rowKey="id" + dataSource={data && data.cccontracts} + /> + + + ); +} + +export default connect( + mapStateToProps, + mapDispatchToProps +)(ContractsFindModalContainer); diff --git a/client/src/components/contracts-list/contracts-list.component.jsx b/client/src/components/contracts-list/contracts-list.component.jsx index 02f87dbef..d715332de 100644 --- a/client/src/components/contracts-list/contracts-list.component.jsx +++ b/client/src/components/contracts-list/contracts-list.component.jsx @@ -6,8 +6,28 @@ import { useTranslation } from "react-i18next"; import { Link, useHistory, useLocation } from "react-router-dom"; import { DateTimeFormatter } from "../../utils/DateFormatter"; import { alphaSort } from "../../utils/sorters"; +import ContractsFindModalContainer from "../contracts-find-modal/contracts-find-modal.container"; +import { setModalContext } from "../../redux/modals/modals.actions"; -export default function ContractsList({ loading, contracts, refetch, total }) { +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +const mapStateToProps = createStructuredSelector({ + //currentUser: selectCurrentUser +}); +const mapDispatchToProps = (dispatch) => ({ + //setUserLanguage: language => dispatch(setUserLanguage(language)) + setContractFinderContext: (context) => + dispatch(setModalContext({ context: context, modal: "contractFinder" })), +}); +export default connect(mapStateToProps, mapDispatchToProps)(ContractsList); + +export function ContractsList({ + loading, + contracts, + refetch, + total, + setContractFinderContext, +}) { const [state, setState] = useState({ sortedInfo: {}, filteredInfo: { text: "" }, @@ -140,6 +160,9 @@ export default function ContractsList({ loading, contracts, refetch, total }) { )} + @@ -153,6 +176,7 @@ export default function ContractsList({ loading, contracts, refetch, total }) { } > +
{ diff --git a/client/src/redux/modals/modals.selectors.js b/client/src/redux/modals/modals.selectors.js index c0a58eccb..aa642d991 100644 --- a/client/src/redux/modals/modals.selectors.js +++ b/client/src/redux/modals/modals.selectors.js @@ -65,3 +65,8 @@ export const selectPartsReceive = createSelector( [selectModals], (modals) => modals.partsReceive ); + +export const selectContractFinder = createSelector( + [selectModals], + (modals) => modals.contractFinder +); diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index fac8b0920..2963ec351 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -481,6 +481,7 @@ "actions": { "convertoro": "Convert to RO", "decodelicense": "Decode License", + "find": "Find Contract", "printcontract": "Print Contract", "senddltoform": "Insert Driver's License Information" }, @@ -540,9 +541,11 @@ "correctdataonform": "Please review the information above. If any of it is not correct, you can fix it later.", "dlexpirebeforereturn": "The driver's license expires before the car is expected to return. ", "driverinformation": "Driver's Information", + "findcontract": "Find Contract", "noteconvertedfrom": "R.O. created from converted Courtesy Car Contract {{agreementnumber}}.", "populatefromjob": "Populate from Job", "rates": "Contract Rates", + "time": "Time", "vehicle": "Vehicle", "waitingforscan": "Please scan driver's license barcode..." }, diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 71f69190e..4aeb3f0e1 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -481,6 +481,7 @@ "actions": { "convertoro": "", "decodelicense": "", + "find": "", "printcontract": "", "senddltoform": "" }, @@ -540,9 +541,11 @@ "correctdataonform": "", "dlexpirebeforereturn": "", "driverinformation": "", + "findcontract": "", "noteconvertedfrom": "", "populatefromjob": "", "rates": "", + "time": "", "vehicle": "", "waitingforscan": "" }, diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 2a2e918f1..665054000 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -481,6 +481,7 @@ "actions": { "convertoro": "", "decodelicense": "", + "find": "", "printcontract": "", "senddltoform": "" }, @@ -540,9 +541,11 @@ "correctdataonform": "", "dlexpirebeforereturn": "", "driverinformation": "", + "findcontract": "", "noteconvertedfrom": "", "populatefromjob": "", "rates": "", + "time": "", "vehicle": "", "waitingforscan": "" },