Implemented job upload
This commit is contained in:
16
src/ipc/ipc-estimate-utils.js
Normal file
16
src/ipc/ipc-estimate-utils.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import client from "../graphql/GraphQLClient";
|
||||
import { INSERT_NEW_JOB } from "../graphql/jobs.queries";
|
||||
import { store } from "../redux/store";
|
||||
|
||||
export async function UpsertEstimate(job) {
|
||||
const shopId = store.getState().user.bodyshop.id;
|
||||
console.log("UpsertEstimate -> shopId", shopId);
|
||||
|
||||
const result = await client.mutate({
|
||||
mutation: INSERT_NEW_JOB,
|
||||
variables: {
|
||||
job: { ...job, bodyshopid: shopId },
|
||||
},
|
||||
});
|
||||
console.log("UpsertEstimate -> result", result);
|
||||
}
|
||||
@@ -4,9 +4,15 @@ import {
|
||||
setWatcherStatus,
|
||||
} from "../redux/application/application.actions";
|
||||
import { store } from "../redux/store";
|
||||
import { message } from "antd";
|
||||
import { UpsertEstimate } from "./ipc-estimate-utils";
|
||||
|
||||
const { ipcRenderer } = window;
|
||||
|
||||
console.log("----Initializing IPC Listeners in React App.");
|
||||
ipcRenderer.on("test-toRenderer", (event, obj) => {
|
||||
console.log("test-toRenderer", obj);
|
||||
});
|
||||
|
||||
ipcRenderer.on(
|
||||
ipcTypes.default.fileWatcher.toRenderer.filepathsList,
|
||||
@@ -15,10 +21,12 @@ ipcRenderer.on(
|
||||
}
|
||||
);
|
||||
|
||||
//Filewatcher Section
|
||||
//Filewatcher Status Section
|
||||
ipcRenderer.on(
|
||||
ipcTypes.default.fileWatcher.toRenderer.startSuccess,
|
||||
(event, ...obj) => {
|
||||
console.log("Watcher ready.");
|
||||
message.success("Watcher started!");
|
||||
store.dispatch(setWatcherStatus("READY!"));
|
||||
}
|
||||
);
|
||||
@@ -28,10 +36,25 @@ ipcRenderer.on(
|
||||
store.dispatch(setWatcherStatus("STOPPED"));
|
||||
}
|
||||
);
|
||||
|
||||
ipcRenderer.on(
|
||||
ipcTypes.default.fileWatcher.toRenderer.error,
|
||||
(event, ...obj) => {
|
||||
store.dispatch(setWatcherStatus(obj));
|
||||
}
|
||||
);
|
||||
|
||||
//Estimate Section
|
||||
ipcRenderer.on(
|
||||
ipcTypes.default.estimate.toRenderer.estimateDecodeStart,
|
||||
(event, ...obj) => {
|
||||
console.log("Decoding started!");
|
||||
}
|
||||
);
|
||||
|
||||
ipcRenderer.on(
|
||||
ipcTypes.default.estimate.toRenderer.estimateDecodeSuccess,
|
||||
async (event, ...obj) => {
|
||||
console.log("Decoding success!", obj[0]);
|
||||
await UpsertEstimate(obj[0]);
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user