From 25513ae5b552ebd36da311e4ab43ce345b687234 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 26 Jan 2023 11:24:53 -0800 Subject: [PATCH] IO-2151 Resolve issue removing CSR on conversion. --- .../jobs-convert-button.component.jsx | 11 ++++++-- client/src/graphql/jobs.queries.js | 27 ++----------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/client/src/components/jobs-convert-button/jobs-convert-button.component.jsx b/client/src/components/jobs-convert-button/jobs-convert-button.component.jsx index e20523880..71069e3b2 100644 --- a/client/src/components/jobs-convert-button/jobs-convert-button.component.jsx +++ b/client/src/components/jobs-convert-button/jobs-convert-button.component.jsx @@ -43,14 +43,21 @@ export function JobsConvertButton({ const { t } = useTranslation(); const [form] = Form.useForm(); - const handleConvert = async (values) => { + const handleConvert = async ({ employee_csr, ...values }) => { if (parentFormIsFieldsTouched()) { alert(t("jobs.labels.savebeforeconversion")); return; } setLoading(true); const res = await mutationConvertJob({ - variables: { jobId: job.id, ...values }, + variables: { + jobId: job.id, + job: { + converted: true, + ...(bodyshop.enforce_conversion_csr ? { employee_csr } : {}), + ...values, + }, + }, }); if (values.ca_gst_registrant) { diff --git a/client/src/graphql/jobs.queries.js b/client/src/graphql/jobs.queries.js index f416ac182..9d89d8ebc 100644 --- a/client/src/graphql/jobs.queries.js +++ b/client/src/graphql/jobs.queries.js @@ -1153,31 +1153,8 @@ export const UPDATE_JOBS = gql` `; export const CONVERT_JOB_TO_RO = gql` - mutation CONVERT_JOB_TO_RO( - $jobId: uuid! - $class: String - $ins_co_nm: String! - $ca_gst_registrant: Boolean - $driveable: Boolean - $towin: Boolean - $referral_source: String - $referral_source_extra: String - $employee_csr: uuid - ) { - update_jobs( - where: { id: { _eq: $jobId } } - _set: { - converted: true - ins_co_nm: $ins_co_nm - class: $class - ca_gst_registrant: $ca_gst_registrant - towin: $towin - driveable: $driveable - referral_source: $referral_source - referral_source_extra: $referral_source_extra - employee_csr: $employee_csr - } - ) { + mutation CONVERT_JOB_TO_RO($jobId: uuid!, $job: jobs_set_input!) { + update_jobs(where: { id: { _eq: $jobId } }, _set: $job) { returning { id ro_number