IO-710 Export Log page & insert actions on export
This commit is contained in:
@@ -7,15 +7,24 @@ import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { auth } from "../../firebase/firebase.utils";
|
||||
import { UPDATE_JOB } from "../../graphql/jobs.queries";
|
||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||
import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import { INSERT_EXPORT_LOG } from "../../graphql/accounting.queries";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
bodyshop: selectBodyshop,
|
||||
currentUser: selectCurrentUser,
|
||||
});
|
||||
|
||||
export function JobsCloseExportButton({ bodyshop, jobId, disabled }) {
|
||||
export function JobsCloseExportButton({
|
||||
bodyshop,
|
||||
currentUser,
|
||||
jobId,
|
||||
disabled,
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [updateJob] = useMutation(UPDATE_JOB);
|
||||
const [insertExportLog] = useMutation(INSERT_EXPORT_LOG);
|
||||
@@ -77,35 +86,39 @@ export function JobsCloseExportButton({ bodyshop, jobId, disabled }) {
|
||||
failedTransactions.forEach((ft) => {
|
||||
//insert failed export log
|
||||
notification.open({
|
||||
key: "failedexports",
|
||||
// key: "failedexports",
|
||||
type: "error",
|
||||
message: t("jobs.errors.exporting", {
|
||||
error: ft.errorMessage || "",
|
||||
}),
|
||||
});
|
||||
//Call is not awaited as it is not critical to finish before proceeding.
|
||||
insertExportLog({
|
||||
variables: {
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
jobid: jobId,
|
||||
success: false,
|
||||
message: JSON.stringify(ft.errorMessage),
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
});
|
||||
} else {
|
||||
//Insert success export log.
|
||||
insertExportLog({
|
||||
|
||||
await insertExportLog({
|
||||
variables: {
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
jobid: jobId,
|
||||
success: true,
|
||||
successful: false,
|
||||
message: JSON.stringify(
|
||||
failedTransactions.map((ft) => ft.errorMessage)
|
||||
),
|
||||
useremail: currentUser.email,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
} else {
|
||||
//Insert success export log.
|
||||
await insertExportLog({
|
||||
variables: {
|
||||
logs: [
|
||||
{
|
||||
bodyshopid: bodyshop.id,
|
||||
jobid: jobId,
|
||||
successful: true,
|
||||
useremail: currentUser.email,
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -123,7 +136,7 @@ export function JobsCloseExportButton({ bodyshop, jobId, disabled }) {
|
||||
|
||||
if (!jobUpdateResponse.errors) {
|
||||
notification.open({
|
||||
type: "error",
|
||||
type: "success",
|
||||
key: "jobsuccessexport",
|
||||
message: t("jobs.successes.exported"),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user