Added copy from job to ccc IO-565
This commit is contained in:
@@ -6654,6 +6654,27 @@
|
||||
<folder_node>
|
||||
<name>errors</name>
|
||||
<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>
|
||||
<name>returning</name>
|
||||
<definition_loaded>false</definition_loaded>
|
||||
@@ -7572,6 +7593,27 @@
|
||||
</translation>
|
||||
</translations>
|
||||
</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>
|
||||
<name>vehicle</name>
|
||||
<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,
|
||||
} from "../form-items-formatted/phone-form-item.component";
|
||||
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||
|
||||
export default function ContractFormComponent({ form, create = false }) {
|
||||
import ContractFormJobPrefill from "./contract-form-job-prefill.component";
|
||||
export default function ContractFormComponent({
|
||||
form,
|
||||
create = false,
|
||||
selectedJobState,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div>
|
||||
@@ -100,6 +104,9 @@ export default function ContractFormComponent({ form, create = false }) {
|
||||
</Form.Item>
|
||||
)}
|
||||
</LayoutFormRow>
|
||||
<div>
|
||||
<ContractFormJobPrefill jobId={selectedJobState[0]} form={form} />
|
||||
</div>
|
||||
<LayoutFormRow>
|
||||
<Form.Item
|
||||
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} />
|
||||
<ContractCarsContainer selectedCarState={selectedCarState} form={form} />
|
||||
<ContractLicenseDecodeButton form={form} />
|
||||
<ContractFormComponent create form={form} />
|
||||
<ContractFormComponent
|
||||
create
|
||||
form={form}
|
||||
selectedJobState={selectedJobState}
|
||||
/>
|
||||
{CreateButton}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -434,6 +434,7 @@
|
||||
"senddltoform": "Insert Driver's License Information"
|
||||
},
|
||||
"errors": {
|
||||
"fetchingjobinfo": "Error fetching job info. {{error}}.",
|
||||
"returning": "Error returning courtesy car. {{error}}",
|
||||
"saving": "Error saving contract. {{error}}",
|
||||
"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.",
|
||||
"noteconvertedfrom": "R.O. created from converted Courtesy Car Contract {{agreementnumber}}.",
|
||||
"populatefromjob": "Populate from Job",
|
||||
"vehicle": "Vehicle",
|
||||
"waitingforscan": "Please scan driver's license barcode..."
|
||||
},
|
||||
|
||||
@@ -434,6 +434,7 @@
|
||||
"senddltoform": ""
|
||||
},
|
||||
"errors": {
|
||||
"fetchingjobinfo": "",
|
||||
"returning": "",
|
||||
"saving": "",
|
||||
"selectjobandcar": ""
|
||||
@@ -483,6 +484,7 @@
|
||||
},
|
||||
"correctdataonform": "",
|
||||
"noteconvertedfrom": "",
|
||||
"populatefromjob": "",
|
||||
"vehicle": "",
|
||||
"waitingforscan": ""
|
||||
},
|
||||
|
||||
@@ -434,6 +434,7 @@
|
||||
"senddltoform": ""
|
||||
},
|
||||
"errors": {
|
||||
"fetchingjobinfo": "",
|
||||
"returning": "",
|
||||
"saving": "",
|
||||
"selectjobandcar": ""
|
||||
@@ -483,6 +484,7 @@
|
||||
},
|
||||
"correctdataonform": "",
|
||||
"noteconvertedfrom": "",
|
||||
"populatefromjob": "",
|
||||
"vehicle": "",
|
||||
"waitingforscan": ""
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user