diff --git a/client/src/components/jobs-available-table/jobs-available-supplement.estlines.util.js b/client/src/components/jobs-available-table/jobs-available-supplement.estlines.util.js index c3cd83c54..fea46d8d9 100644 --- a/client/src/components/jobs-available-table/jobs-available-supplement.estlines.util.js +++ b/client/src/components/jobs-available-table/jobs-available-supplement.estlines.util.js @@ -37,7 +37,6 @@ export const GetSupplementDelta = async (client, jobId, newLines) => { }); //Wahtever is left in the existing lines, are lines that should be removed. - const insertQueries = linesToInsert.reduce((acc, value, idx) => { return acc + generateInsertQuery(value, idx, jobId); }, ""); @@ -49,6 +48,13 @@ export const GetSupplementDelta = async (client, jobId, newLines) => { const removeQueries = existingLines.reduce((acc, value, idx) => { return acc + generateRemoveQuery(value, idx); }, ""); + console.log(insertQueries, updateQueries, removeQueries); + + if ((insertQueries + updateQueries + removeQueries).trim() === "") { + return new Promise((resolve, reject) => { + resolve(null); + }); + } return new Promise((resolve, reject) => { resolve(gql` diff --git a/client/src/components/jobs-available-table/jobs-available-table.container.jsx b/client/src/components/jobs-available-table/jobs-available-table.container.jsx index 9f2b3fd08..1287e288c 100644 --- a/client/src/components/jobs-available-table/jobs-available-table.container.jsx +++ b/client/src/components/jobs-available-table/jobs-available-table.container.jsx @@ -220,12 +220,13 @@ export function JobsAvailableContainer({ ); delete supp.joblines; - await client.mutate({ - mutation: gql` - ${suppDelta} - `, - }); - + if (suppDelta !== null) { + await client.mutate({ + mutation: gql` + ${suppDelta} + `, + }); + } const updateResult = await updateJob({ variables: { jobId: selectedJob,