Added copy from job to ccc IO-565
This commit is contained in:
@@ -6654,6 +6654,27 @@
|
|||||||
<folder_node>
|
<folder_node>
|
||||||
<name>errors</name>
|
<name>errors</name>
|
||||||
<children>
|
<children>
|
||||||
|
<concept_node>
|
||||||
|
<name>fetchingjobinfo</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>returning</name>
|
<name>returning</name>
|
||||||
<definition_loaded>false</definition_loaded>
|
<definition_loaded>false</definition_loaded>
|
||||||
@@ -7572,6 +7593,27 @@
|
|||||||
</translation>
|
</translation>
|
||||||
</translations>
|
</translations>
|
||||||
</concept_node>
|
</concept_node>
|
||||||
|
<concept_node>
|
||||||
|
<name>populatefromjob</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,44 @@
|
|||||||
|
import { useLazyQuery } from "@apollo/react-hooks";
|
||||||
|
import { Button, notification } from "antd";
|
||||||
|
import React, { useEffect } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { GET_JOB_FOR_CC_CONTRACT } from "../../graphql/jobs.queries";
|
||||||
|
export default function ContractCreateJobPrefillComponent({ jobId, form }) {
|
||||||
|
const [call, { loading, error, data }] = useLazyQuery(
|
||||||
|
GET_JOB_FOR_CC_CONTRACT
|
||||||
|
);
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
|
const handleClick = () => {
|
||||||
|
call({ variables: { id: jobId } });
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (data) {
|
||||||
|
form.setFieldsValue({
|
||||||
|
driver_dlst: data.jobs_by_pk.ownr_ast,
|
||||||
|
driver_fn: data.jobs_by_pk.ownr_fn,
|
||||||
|
driver_ln: data.jobs_by_pk.ownr_ln,
|
||||||
|
driver_addr1: data.jobs_by_pk.ownr_addr1,
|
||||||
|
driver_state: data.jobs_by_pk.ownr_st,
|
||||||
|
driver_city: data.jobs_by_pk.ownr_city,
|
||||||
|
driver_zip: data.jobs_by_pk.ownr_zip,
|
||||||
|
driver_ph1: data.jobs_by_pk.ownr_ph1,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [data, form]);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
notification["error"]({
|
||||||
|
message: t("contracts.errors.fetchingjobinfo", {
|
||||||
|
error: JSON.stringify(error),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Button onClick={handleClick} disabled={!jobId} loading={loading}>
|
||||||
|
{t("contracts.labels.populatefromjob")}
|
||||||
|
</Button>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -10,8 +10,12 @@ import InputPhone, {
|
|||||||
PhoneItemFormatterValidation,
|
PhoneItemFormatterValidation,
|
||||||
} from "../form-items-formatted/phone-form-item.component";
|
} from "../form-items-formatted/phone-form-item.component";
|
||||||
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||||
|
import ContractFormJobPrefill from "./contract-form-job-prefill.component";
|
||||||
export default function ContractFormComponent({ form, create = false }) {
|
export default function ContractFormComponent({
|
||||||
|
form,
|
||||||
|
create = false,
|
||||||
|
selectedJobState,
|
||||||
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -100,6 +104,9 @@ export default function ContractFormComponent({ form, create = false }) {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
)}
|
)}
|
||||||
</LayoutFormRow>
|
</LayoutFormRow>
|
||||||
|
<div>
|
||||||
|
<ContractFormJobPrefill jobId={selectedJobState[0]} form={form} />
|
||||||
|
</div>
|
||||||
<LayoutFormRow>
|
<LayoutFormRow>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("contracts.fields.driver_dlnumber")}
|
label={t("contracts.fields.driver_dlnumber")}
|
||||||
|
|||||||
@@ -1335,3 +1335,18 @@ export const DELETE_JOB = gql`
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
export const GET_JOB_FOR_CC_CONTRACT = gql`
|
||||||
|
query GET_JOB_FOR_CC_CONTRACT($id: uuid!) {
|
||||||
|
jobs_by_pk(id: $id) {
|
||||||
|
id
|
||||||
|
ownr_fn
|
||||||
|
ownr_ln
|
||||||
|
ownr_addr1
|
||||||
|
ownr_st
|
||||||
|
ownr_city
|
||||||
|
ownr_zip
|
||||||
|
ownr_ph1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|||||||
@@ -25,7 +25,11 @@ export default function ContractCreatePageComponent({
|
|||||||
<ContractJobsContainer selectedJobState={selectedJobState} />
|
<ContractJobsContainer selectedJobState={selectedJobState} />
|
||||||
<ContractCarsContainer selectedCarState={selectedCarState} form={form} />
|
<ContractCarsContainer selectedCarState={selectedCarState} form={form} />
|
||||||
<ContractLicenseDecodeButton form={form} />
|
<ContractLicenseDecodeButton form={form} />
|
||||||
<ContractFormComponent create form={form} />
|
<ContractFormComponent
|
||||||
|
create
|
||||||
|
form={form}
|
||||||
|
selectedJobState={selectedJobState}
|
||||||
|
/>
|
||||||
{CreateButton}
|
{CreateButton}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -434,6 +434,7 @@
|
|||||||
"senddltoform": "Insert Driver's License Information"
|
"senddltoform": "Insert Driver's License Information"
|
||||||
},
|
},
|
||||||
"errors": {
|
"errors": {
|
||||||
|
"fetchingjobinfo": "Error fetching job info. {{error}}.",
|
||||||
"returning": "Error returning courtesy car. {{error}}",
|
"returning": "Error returning courtesy car. {{error}}",
|
||||||
"saving": "Error saving contract. {{error}}",
|
"saving": "Error saving contract. {{error}}",
|
||||||
"selectjobandcar": "Please ensure both a car and job are selected."
|
"selectjobandcar": "Please ensure both a car and job are selected."
|
||||||
@@ -483,6 +484,7 @@
|
|||||||
},
|
},
|
||||||
"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.",
|
||||||
"noteconvertedfrom": "R.O. created from converted Courtesy Car Contract {{agreementnumber}}.",
|
"noteconvertedfrom": "R.O. created from converted Courtesy Car Contract {{agreementnumber}}.",
|
||||||
|
"populatefromjob": "Populate from Job",
|
||||||
"vehicle": "Vehicle",
|
"vehicle": "Vehicle",
|
||||||
"waitingforscan": "Please scan driver's license barcode..."
|
"waitingforscan": "Please scan driver's license barcode..."
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -434,6 +434,7 @@
|
|||||||
"senddltoform": ""
|
"senddltoform": ""
|
||||||
},
|
},
|
||||||
"errors": {
|
"errors": {
|
||||||
|
"fetchingjobinfo": "",
|
||||||
"returning": "",
|
"returning": "",
|
||||||
"saving": "",
|
"saving": "",
|
||||||
"selectjobandcar": ""
|
"selectjobandcar": ""
|
||||||
@@ -483,6 +484,7 @@
|
|||||||
},
|
},
|
||||||
"correctdataonform": "",
|
"correctdataonform": "",
|
||||||
"noteconvertedfrom": "",
|
"noteconvertedfrom": "",
|
||||||
|
"populatefromjob": "",
|
||||||
"vehicle": "",
|
"vehicle": "",
|
||||||
"waitingforscan": ""
|
"waitingforscan": ""
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -434,6 +434,7 @@
|
|||||||
"senddltoform": ""
|
"senddltoform": ""
|
||||||
},
|
},
|
||||||
"errors": {
|
"errors": {
|
||||||
|
"fetchingjobinfo": "",
|
||||||
"returning": "",
|
"returning": "",
|
||||||
"saving": "",
|
"saving": "",
|
||||||
"selectjobandcar": ""
|
"selectjobandcar": ""
|
||||||
@@ -483,6 +484,7 @@
|
|||||||
},
|
},
|
||||||
"correctdataonform": "",
|
"correctdataonform": "",
|
||||||
"noteconvertedfrom": "",
|
"noteconvertedfrom": "",
|
||||||
|
"populatefromjob": "",
|
||||||
"vehicle": "",
|
"vehicle": "",
|
||||||
"waitingforscan": ""
|
"waitingforscan": ""
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user