IO-744 Voiding Note

This commit is contained in:
Patrick Fic
2021-03-08 14:58:03 -08:00
parent 4f92011386
commit ae4479bf43
7 changed files with 80 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
<babeledit_project be_version="2.7.1" version="1.2">
<babeledit_project version="1.2" be_version="2.7.1">
<!--
BabelEdit project file
@@ -20710,6 +20710,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>voidnote</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
</children>
</folder_node>
<folder_node>

View File

@@ -1,22 +1,28 @@
import { DownCircleFilled } from "@ant-design/icons";
import { useApolloClient, useMutation } from "@apollo/client";
import { Button, Dropdown, Menu, notification, Popconfirm } from "antd";
import moment from "moment";
import React, { useMemo } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { Link, useHistory } from "react-router-dom";
import { createStructuredSelector } from "reselect";
import { logImEXEvent } from "../../firebase/firebase.utils";
import { DELETE_JOB, UPDATE_JOB } from "../../graphql/jobs.queries";
import { DELETE_JOB, UPDATE_JOB, VOID_JOB } from "../../graphql/jobs.queries";
import { selectJobReadOnly } from "../../redux/application/application.selectors";
import { setModalContext } from "../../redux/modals/modals.actions";
import { selectBodyshop } from "../../redux/user/user.selectors";
import {
selectBodyshop,
selectCurrentUser,
} from "../../redux/user/user.selectors";
import AddToProduction from "./jobs-detail-header-actions.addtoproduction.util";
import JobsDetaiLheaderCsi from "./jobs-detail-header-actions.csi.component";
import DuplicateJob from "./jobs-detail-header-actions.duplicate.util";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
jobRO: selectJobReadOnly,
currentUser: selectCurrentUser,
});
const mapDispatchToProps = (dispatch) => ({
@@ -35,6 +41,7 @@ const mapDispatchToProps = (dispatch) => ({
export function JobsDetailHeaderActions({
job,
bodyshop,
currentUser,
refetch,
setScheduleContext,
setBillEnterContext,
@@ -48,6 +55,7 @@ export function JobsDetailHeaderActions({
const history = useHistory();
const [deleteJob] = useMutation(DELETE_JOB);
const [updateJob] = useMutation(UPDATE_JOB);
const [voidJob] = useMutation(VOID_JOB);
const jobInProduction = useMemo(() => {
return bodyshop.md_ro_statuses.production_statuses.includes(job.status);
}, [job, bodyshop.md_ro_statuses.production_statuses]);
@@ -338,13 +346,24 @@ export function JobsDetailHeaderActions({
onClick={(e) => e.stopPropagation()}
onConfirm={async () => {
//delete the job.
const result = await updateJob({
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"),
}),
},
],
},
});

View File

@@ -9,16 +9,23 @@ import { Button, Table } from "antd";
import React from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { selectJobReadOnly } from "../../redux/application/application.selectors";
import { setModalContext } from "../../redux/modals/modals.actions";
import { DateTimeFormatter } from "../../utils/DateFormatter";
import NoteUpsertModal from "../note-upsert-modal/note-upsert-modal.container";
const mapStateToProps = createStructuredSelector({
jobRO: selectJobReadOnly,
});
const mapDispatchToProps = (dispatch) => ({
setNoteUpsertContext: (context) =>
dispatch(setModalContext({ context: context, modal: "noteUpsert" })),
});
export function JobNotesComponent({
jobRO,
loading,
data,
refetch,
@@ -78,13 +85,13 @@ export function JobNotesComponent({
<span>
<Button
loading={deleteLoading}
disabled={record.audit}
disabled={record.audit || jobRO}
onClick={() => handleNoteDelete(record.id)}
>
<DeleteFilled />
</Button>
<Button
disabled={record.audit}
disabled={record.audit || jobRO}
onClick={() => {
setNoteUpsertContext({
actions: { refetch: refetch },

View File

@@ -756,6 +756,27 @@ export const UPDATE_JOB = gql`
}
`;
export const VOID_JOB = gql`
mutation VOID_JOB(
$jobId: uuid!
$job: jobs_set_input!
$note: [notes_insert_input!]!
) {
update_jobs_by_pk(_set: $job, pk_columns: { id: $jobId }) {
id
date_exported
status
alt_transport
ro_number
production_vars
lbr_adjustments
}
insert_notes(objects: $note) {
affected_rows
}
}
`;
export const UPDATE_JOBS = gql`
mutation UPDATE_JOBS($jobIds: [uuid!]!, $fields: jobs_set_input!) {
update_jobs(where: { id: { _in: $jobIds } }, _set: $fields) {

View File

@@ -1238,7 +1238,8 @@
"vehicle_info": "Vehicle",
"vehicleassociation": "Vehicle Association",
"viewallocations": "View Allocations",
"voidjob": "Are you sure you want to void this job? This cannot be easily undone. "
"voidjob": "Are you sure you want to void this job? This cannot be easily undone. ",
"voidnote": "This repair order was voided on {{date}} at {{time}}."
},
"successes": {
"addedtoproduction": "Job added to production board.",

View File

@@ -1238,7 +1238,8 @@
"vehicle_info": "Vehículo",
"vehicleassociation": "",
"viewallocations": "",
"voidjob": ""
"voidjob": "",
"voidnote": ""
},
"successes": {
"addedtoproduction": "",

View File

@@ -1238,7 +1238,8 @@
"vehicle_info": "Véhicule",
"vehicleassociation": "",
"viewallocations": "",
"voidjob": ""
"voidjob": "",
"voidnote": ""
},
"successes": {
"addedtoproduction": "",