IO-899 Contract FInd Modal
This commit is contained in:
@@ -7530,6 +7530,27 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</translations>
|
</translations>
|
||||||
</concept_node>
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>find</name>
|
||||||
|
<definition_loaded>false</definition_loaded>
|
||||||
|
<description></description>
|
||||||
|
<comment></comment>
|
||||||
|
<default_text></default_text>
|
||||||
|
<translations>
|
||||||
|
<translation>
|
||||||
|
<language>en-US</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>es-MX</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>fr-CA</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
</translations>
|
||||||
|
</concept_node>
|
||||||
<concept_node>
|
<concept_node>
|
||||||
<name>printcontract</name>
|
<name>printcontract</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
@@ -8621,6 +8642,27 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</translations>
|
</translations>
|
||||||
</concept_node>
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>findcontract</name>
|
||||||
|
<definition_loaded>false</definition_loaded>
|
||||||
|
<description></description>
|
||||||
|
<comment></comment>
|
||||||
|
<default_text></default_text>
|
||||||
|
<translations>
|
||||||
|
<translation>
|
||||||
|
<language>en-US</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>es-MX</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>fr-CA</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
</translations>
|
||||||
|
</concept_node>
|
||||||
<concept_node>
|
<concept_node>
|
||||||
<name>noteconvertedfrom</name>
|
<name>noteconvertedfrom</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
@@ -8684,6 +8726,27 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</translations>
|
</translations>
|
||||||
</concept_node>
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>time</name>
|
||||||
|
<definition_loaded>false</definition_loaded>
|
||||||
|
<description></description>
|
||||||
|
<comment></comment>
|
||||||
|
<default_text></default_text>
|
||||||
|
<translations>
|
||||||
|
<translation>
|
||||||
|
<language>en-US</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>es-MX</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
<translation>
|
||||||
|
<language>fr-CA</language>
|
||||||
|
<approved>false</approved>
|
||||||
|
</translation>
|
||||||
|
</translations>
|
||||||
|
</concept_node>
|
||||||
<concept_node>
|
<concept_node>
|
||||||
<name>vehicle</name>
|
<name>vehicle</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
|
|||||||
@@ -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 (
|
||||||
|
<div>
|
||||||
|
<Form.Item name="fleet" label={t("courtesycars.fields.fleetnumber")}>
|
||||||
|
<Input />
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
name="time"
|
||||||
|
label={t("contracts.labels.time")}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
message: t("general.validation.required"),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<FormDateTimePicker />
|
||||||
|
</Form.Item>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -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 (
|
||||||
|
<Modal
|
||||||
|
visible={visible}
|
||||||
|
width="70%"
|
||||||
|
title={t("labels.labels.findermodal")}
|
||||||
|
onCancel={() => toggleModalVisible()}
|
||||||
|
onOk={() => toggleModalVisible()}
|
||||||
|
destroyOnClose
|
||||||
|
forceRender
|
||||||
|
>
|
||||||
|
<Form
|
||||||
|
form={form}
|
||||||
|
layout="vertical"
|
||||||
|
autoComplete="no"
|
||||||
|
onFinish={handleFinish}
|
||||||
|
>
|
||||||
|
<ContractsFindModalComponent form={form} />
|
||||||
|
<Button onClick={() => form.submit()} type="primary" loading={loading}>
|
||||||
|
{t("general.labels.search")}
|
||||||
|
</Button>
|
||||||
|
{error && (
|
||||||
|
<AlertComponent type="error" message={JSON.stringify(error)} />
|
||||||
|
)}
|
||||||
|
<Table
|
||||||
|
loading={loading}
|
||||||
|
columns={[
|
||||||
|
{
|
||||||
|
title: t("contracts.fields.agreementnumber"),
|
||||||
|
dataIndex: "agreementnumber",
|
||||||
|
key: "agreementnumber",
|
||||||
|
|
||||||
|
render: (text, record) => (
|
||||||
|
<Link to={`/manage/courtesycars/contracts/${record.id}`}>
|
||||||
|
{record.agreementnumber || ""}
|
||||||
|
</Link>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t("jobs.fields.ro_number"),
|
||||||
|
dataIndex: "job.ro_number",
|
||||||
|
key: "job.ro_number",
|
||||||
|
render: (text, record) => (
|
||||||
|
<Link to={`/manage/jobs/${record.job.id}`}>
|
||||||
|
{record.job.ro_number || ""}
|
||||||
|
</Link>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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) => (
|
||||||
|
<Link to={`/manage/courtesycars/${record.courtesycar.id}`}>{`${
|
||||||
|
record.courtesycar.year
|
||||||
|
} ${record.courtesycar.make} ${record.courtesycar.model} ${
|
||||||
|
record.courtesycar.plate
|
||||||
|
? `(${record.courtesycar.plate})`
|
||||||
|
: ""
|
||||||
|
}`}</Link>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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) => (
|
||||||
|
<DateTimeFormatter>{record.start}</DateTimeFormatter>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t("contracts.fields.scheduledreturn"),
|
||||||
|
dataIndex: "scheduledreturn",
|
||||||
|
key: "scheduledreturn",
|
||||||
|
render: (text, record) => (
|
||||||
|
<DateTimeFormatter>{record.scheduledreturn}</DateTimeFormatter>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t("contracts.fields.actualreturn"),
|
||||||
|
dataIndex: "actualreturn",
|
||||||
|
key: "actualreturn",
|
||||||
|
render: (text, record) => (
|
||||||
|
<DateTimeFormatter>{record.actualreturn}</DateTimeFormatter>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
rowKey="id"
|
||||||
|
dataSource={data && data.cccontracts}
|
||||||
|
/>
|
||||||
|
</Form>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(ContractsFindModalContainer);
|
||||||
@@ -6,8 +6,28 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { Link, useHistory, useLocation } from "react-router-dom";
|
import { Link, useHistory, useLocation } from "react-router-dom";
|
||||||
import { DateTimeFormatter } from "../../utils/DateFormatter";
|
import { DateTimeFormatter } from "../../utils/DateFormatter";
|
||||||
import { alphaSort } from "../../utils/sorters";
|
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({
|
const [state, setState] = useState({
|
||||||
sortedInfo: {},
|
sortedInfo: {},
|
||||||
filteredInfo: { text: "" },
|
filteredInfo: { text: "" },
|
||||||
@@ -140,6 +160,9 @@ export default function ContractsList({ loading, contracts, refetch, total }) {
|
|||||||
</Button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
<Button onClick={() => setContractFinderContext()}>
|
||||||
|
{t("contracts.actions.find")}
|
||||||
|
</Button>
|
||||||
<Button onClick={() => refetch()}>
|
<Button onClick={() => refetch()}>
|
||||||
<SyncOutlined />
|
<SyncOutlined />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -153,6 +176,7 @@ export default function ContractsList({ loading, contracts, refetch, total }) {
|
|||||||
</Space>
|
</Space>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
<ContractsFindModalContainer />
|
||||||
<Table
|
<Table
|
||||||
loading={loading}
|
loading={loading}
|
||||||
scroll={{
|
scroll={{
|
||||||
|
|||||||
@@ -189,3 +189,45 @@ export const QUERY_ACTIVE_CONTRACTS_PAGINATED = gql`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const FIND_CONTRACT = gql`
|
||||||
|
query FIND_CONTRACT($fleet: String, $time: timestamptz!) {
|
||||||
|
cccontracts(
|
||||||
|
where: {
|
||||||
|
_or: [
|
||||||
|
{ actualreturn: { _gte: $time } }
|
||||||
|
{ actualreturn: { _is_null: true } }
|
||||||
|
]
|
||||||
|
start: { _lte: $time }
|
||||||
|
courtesycar: { fleetnumber: { _eq: $fleet } }
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
agreementnumber
|
||||||
|
courtesycarid
|
||||||
|
driver_fn
|
||||||
|
driver_ln
|
||||||
|
driver_ph1
|
||||||
|
id
|
||||||
|
jobid
|
||||||
|
job {
|
||||||
|
id
|
||||||
|
ro_number
|
||||||
|
ownr_fn
|
||||||
|
ownr_ln
|
||||||
|
ownr_co_nm
|
||||||
|
}
|
||||||
|
scheduledreturn
|
||||||
|
actualreturn
|
||||||
|
start
|
||||||
|
status
|
||||||
|
courtesycar {
|
||||||
|
id
|
||||||
|
fleetnumber
|
||||||
|
make
|
||||||
|
model
|
||||||
|
year
|
||||||
|
plate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ const INITIAL_STATE = {
|
|||||||
jobCosting: { ...baseModal },
|
jobCosting: { ...baseModal },
|
||||||
reportCenter: { ...baseModal },
|
reportCenter: { ...baseModal },
|
||||||
partsReceive: { ...baseModal },
|
partsReceive: { ...baseModal },
|
||||||
|
contractFinder: { ...baseModal },
|
||||||
};
|
};
|
||||||
|
|
||||||
const modalsReducer = (state = INITIAL_STATE, action) => {
|
const modalsReducer = (state = INITIAL_STATE, action) => {
|
||||||
|
|||||||
@@ -65,3 +65,8 @@ export const selectPartsReceive = createSelector(
|
|||||||
[selectModals],
|
[selectModals],
|
||||||
(modals) => modals.partsReceive
|
(modals) => modals.partsReceive
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const selectContractFinder = createSelector(
|
||||||
|
[selectModals],
|
||||||
|
(modals) => modals.contractFinder
|
||||||
|
);
|
||||||
|
|||||||
@@ -481,6 +481,7 @@
|
|||||||
"actions": {
|
"actions": {
|
||||||
"convertoro": "Convert to RO",
|
"convertoro": "Convert to RO",
|
||||||
"decodelicense": "Decode License",
|
"decodelicense": "Decode License",
|
||||||
|
"find": "Find Contract",
|
||||||
"printcontract": "Print Contract",
|
"printcontract": "Print Contract",
|
||||||
"senddltoform": "Insert Driver's License Information"
|
"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.",
|
"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. ",
|
"dlexpirebeforereturn": "The driver's license expires before the car is expected to return. ",
|
||||||
"driverinformation": "Driver's Information",
|
"driverinformation": "Driver's Information",
|
||||||
|
"findcontract": "Find Contract",
|
||||||
"noteconvertedfrom": "R.O. created from converted Courtesy Car Contract {{agreementnumber}}.",
|
"noteconvertedfrom": "R.O. created from converted Courtesy Car Contract {{agreementnumber}}.",
|
||||||
"populatefromjob": "Populate from Job",
|
"populatefromjob": "Populate from Job",
|
||||||
"rates": "Contract Rates",
|
"rates": "Contract Rates",
|
||||||
|
"time": "Time",
|
||||||
"vehicle": "Vehicle",
|
"vehicle": "Vehicle",
|
||||||
"waitingforscan": "Please scan driver's license barcode..."
|
"waitingforscan": "Please scan driver's license barcode..."
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -481,6 +481,7 @@
|
|||||||
"actions": {
|
"actions": {
|
||||||
"convertoro": "",
|
"convertoro": "",
|
||||||
"decodelicense": "",
|
"decodelicense": "",
|
||||||
|
"find": "",
|
||||||
"printcontract": "",
|
"printcontract": "",
|
||||||
"senddltoform": ""
|
"senddltoform": ""
|
||||||
},
|
},
|
||||||
@@ -540,9 +541,11 @@
|
|||||||
"correctdataonform": "",
|
"correctdataonform": "",
|
||||||
"dlexpirebeforereturn": "",
|
"dlexpirebeforereturn": "",
|
||||||
"driverinformation": "",
|
"driverinformation": "",
|
||||||
|
"findcontract": "",
|
||||||
"noteconvertedfrom": "",
|
"noteconvertedfrom": "",
|
||||||
"populatefromjob": "",
|
"populatefromjob": "",
|
||||||
"rates": "",
|
"rates": "",
|
||||||
|
"time": "",
|
||||||
"vehicle": "",
|
"vehicle": "",
|
||||||
"waitingforscan": ""
|
"waitingforscan": ""
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -481,6 +481,7 @@
|
|||||||
"actions": {
|
"actions": {
|
||||||
"convertoro": "",
|
"convertoro": "",
|
||||||
"decodelicense": "",
|
"decodelicense": "",
|
||||||
|
"find": "",
|
||||||
"printcontract": "",
|
"printcontract": "",
|
||||||
"senddltoform": ""
|
"senddltoform": ""
|
||||||
},
|
},
|
||||||
@@ -540,9 +541,11 @@
|
|||||||
"correctdataonform": "",
|
"correctdataonform": "",
|
||||||
"dlexpirebeforereturn": "",
|
"dlexpirebeforereturn": "",
|
||||||
"driverinformation": "",
|
"driverinformation": "",
|
||||||
|
"findcontract": "",
|
||||||
"noteconvertedfrom": "",
|
"noteconvertedfrom": "",
|
||||||
"populatefromjob": "",
|
"populatefromjob": "",
|
||||||
"rates": "",
|
"rates": "",
|
||||||
|
"time": "",
|
||||||
"vehicle": "",
|
"vehicle": "",
|
||||||
"waitingforscan": ""
|
"waitingforscan": ""
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user