IO-1098 Employee Assignments fix.

This commit is contained in:
Patrick Fic
2021-05-18 14:33:37 -07:00
parent 7ee2c548fb
commit 5ded2c1cc6
2 changed files with 32 additions and 6 deletions

View File

@@ -3,12 +3,12 @@ import { notification } from "antd";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { logImEXEvent } from "../../firebase/firebase.utils";
import { UPDATE_JOB } from "../../graphql/jobs.queries";
import { UPDATE_JOB_ASSIGNMENTS } from "../../graphql/jobs.queries";
import JobEmployeeAssignmentsComponent from "./job-employee-assignments.component";
export default function JobEmployeeAssignmentsContainer({ job, refetch }) {
const { t } = useTranslation();
const [updateJob] = useMutation(UPDATE_JOB);
const [updateJob] = useMutation(UPDATE_JOB_ASSIGNMENTS);
const [loading, setLoading] = useState(false);
const handleAdd = async (assignment) => {
@@ -20,8 +20,6 @@ export default function JobEmployeeAssignmentsContainer({ job, refetch }) {
const result = await updateJob({
variables: { jobId: job.id, job: { [empAssignment]: employeeid } },
refetchQueries: ["GET_JOB_BY_PK"],
awaitRefetchQueries: true,
});
if (refetch) refetch();
@@ -41,8 +39,6 @@ export default function JobEmployeeAssignmentsContainer({ job, refetch }) {
let empAssignment = determineFieldName(operation);
const result = await updateJob({
variables: { jobId: job.id, job: { [empAssignment]: null } },
refetchQueries: ["GET_JOB_BY_PK"],
awaitRefetchQueries: true,
});
if (!!result.errors) {

View File

@@ -864,6 +864,36 @@ export const UPDATE_JOB = gql`
}
`;
export const UPDATE_JOB_ASSIGNMENTS = gql`
mutation UPDATE_JOB_ASSIGNMENTS($jobId: uuid!, $job: jobs_set_input!) {
update_jobs(where: { id: { _eq: $jobId } }, _set: $job) {
returning {
id
employee_body_rel {
id
first_name
last_name
}
employee_refinish_rel {
id
first_name
last_name
}
employee_prep_rel {
id
first_name
last_name
}
employee_csr_rel {
id
first_name
last_name
}
}
}
}
`;
export const VOID_JOB = gql`
mutation VOID_JOB(
$jobId: uuid!