diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 3464f1110..d658f5e37 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -15966,6 +15966,27 @@ + + unvoid + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + viewchecklist false @@ -22709,6 +22730,27 @@ + + unvoidnote + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + vehicle_info false diff --git a/client/src/components/jobs-admin-mark-reexport/jobs-admin-mark-reexport.component.jsx b/client/src/components/jobs-admin-mark-reexport/jobs-admin-mark-reexport.component.jsx index d4298dfde..f6002d144 100644 --- a/client/src/components/jobs-admin-mark-reexport/jobs-admin-mark-reexport.component.jsx +++ b/client/src/components/jobs-admin-mark-reexport/jobs-admin-mark-reexport.component.jsx @@ -55,7 +55,11 @@ export function JobAdminMarkReexport({ bodyshop, job }) { }; return ( - ); diff --git a/client/src/components/jobs-admin-unvoid/jobs-admin-unvoid.component.jsx b/client/src/components/jobs-admin-unvoid/jobs-admin-unvoid.component.jsx new file mode 100644 index 000000000..d467fe8c1 --- /dev/null +++ b/client/src/components/jobs-admin-unvoid/jobs-admin-unvoid.component.jsx @@ -0,0 +1,103 @@ +import { gql, useMutation } from "@apollo/client"; +import { Button, notification } from "antd"; +import React, { useState } from "react"; +import { useTranslation } from "react-i18next"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { + selectBodyshop, + selectCurrentUser, +} from "../../redux/user/user.selectors"; + +const mapStateToProps = createStructuredSelector({ + bodyshop: selectBodyshop, + currentUser: selectCurrentUser, +}); +const mapDispatchToProps = (dispatch) => ({ + //setUserLanguage: language => dispatch(setUserLanguage(language)) +}); +export default connect(mapStateToProps, mapDispatchToProps)(JobsAdminUnvoid); + +export function JobsAdminUnvoid({ bodyshop, job, currentUser }) { + const { t } = useTranslation(); + const [loading, setLoading] = useState(false); + const [updateJob] = useMutation(gql` +mutation UNVOID_JOB($jobId: uuid!) { + update_jobs_by_pk(pk_columns: {id: $jobId}, _set: {voided: false, status: "${ + bodyshop.md_ro_statuses.default_imported + }"}) { + id + voided + status + } + insert_notes(objects: {jobid: $jobId, audit: true, created_by: "${ + currentUser.email + }", text: "${t("jobs.labels.unvoidnote", { email: currentUser.email })}"}) { + returning { + id + } + } +} + + `); + + // const result = await voidJob({ + // variables: { + // jobId: job.id, + // job: { + // status: bodyshop.md_ro_statuses.default_void, + // voided: true, + // }, + // note: [ + // { + // jobid: job.id, + // created_by: currentUser.email, + // audit: true, + // text: t("jobs.labels.voidnote", { + // date: moment().format("MM/DD/yyy"), + // time: moment().format("hh:mm a"), + // }), + // }, + // ], + // }, + // }); + + // if (!!!result.errors) { + // notification["success"]({ + // message: t("jobs.successes.voided"), + // }); + // //go back to jobs list. + // history.push(`/manage/`); + // } else { + // notification["error"]({ + // message: t("jobs.errors.voiding", { + // error: JSON.stringify(result.errors), + // }), + // }); + // } + + const handleUpdate = async (values) => { + setLoading(true); + const result = await updateJob({ + variables: { jobId: job.id }, + }); + + if (!result.errors) { + notification["success"]({ message: t("jobs.successes.save") }); + } else { + notification["error"]({ + message: t("jobs.errors.saving", { + error: JSON.stringify(result.errors), + }), + }); + } + setLoading(false); + //Get the owner details, populate it all back into the job. + }; + + return ( + + ); +} diff --git a/client/src/pages/jobs-admin/jobs-admin.page.jsx b/client/src/pages/jobs-admin/jobs-admin.page.jsx index 2edf8afd1..beb1f1076 100644 --- a/client/src/pages/jobs-admin/jobs-admin.page.jsx +++ b/client/src/pages/jobs-admin/jobs-admin.page.jsx @@ -12,6 +12,7 @@ import JobsAdminDatesChange from "../../components/jobs-admin-dates/jobs-admin-d import JobsAdminDeleteIntake from "../../components/jobs-admin-delete-intake/jobs-admin-delete-intake.component"; import JobsAdminMarkReexport from "../../components/jobs-admin-mark-reexport/jobs-admin-mark-reexport.component"; import JobAdminOwnerReassociate from "../../components/jobs-admin-owner-reassociate/jobs-admin-owner-reassociate.component"; +import JobsAdminUnvoid from "../../components/jobs-admin-unvoid/jobs-admin-unvoid.component"; import JobAdminVehicleReassociate from "../../components/jobs-admin-vehicle-reassociate/jobs-admin-vehicle-reassociate.component"; import LoadingSpinner from "../../components/loading-spinner/loading-spinner.component"; import NotFound from "../../components/not-found/not-found.component"; @@ -88,6 +89,7 @@ export function JobsCloseContainer({ setBreadcrumbs, setSelectedHeader }) { + diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 55da35541..e6f174aac 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -999,6 +999,7 @@ "schedule": "Schedule", "sendcsi": "Send CSI", "sync": "Sync", + "unvoid": "Unvoid Job", "viewchecklist": "View Checklists", "viewdetail": "View Details" }, @@ -1343,6 +1344,7 @@ "total_repairs": "Total Repairs", "total_sales": "Total Sales", "totals": "Totals", + "unvoidnote": "This job was unvoided by {{email}}.", "vehicle_info": "Vehicle", "vehicleassociation": "Vehicle Association", "viewallocations": "View Allocations", diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index baa184397..425d4265d 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -999,6 +999,7 @@ "schedule": "Programar", "sendcsi": "", "sync": "", + "unvoid": "", "viewchecklist": "", "viewdetail": "" }, @@ -1343,6 +1344,7 @@ "total_repairs": "", "total_sales": "", "totals": "", + "unvoidnote": "", "vehicle_info": "Vehículo", "vehicleassociation": "", "viewallocations": "", diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 190d426ec..31dd7f96b 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -999,6 +999,7 @@ "schedule": "Programme", "sendcsi": "", "sync": "", + "unvoid": "", "viewchecklist": "", "viewdetail": "" }, @@ -1343,6 +1344,7 @@ "total_repairs": "", "total_sales": "", "totals": "", + "unvoidnote": "", "vehicle_info": "Véhicule", "vehicleassociation": "", "viewallocations": "",