Adedd age calculation based on close date. RPS-75

This commit is contained in:
Patrick Fic
2021-01-12 12:01:21 -08:00
parent 96cc949295
commit ea2a3975f6
4 changed files with 28 additions and 8 deletions

View File

@@ -5,9 +5,11 @@ import moment from "moment";
import React, { useState } from "react";
import { UPDATE_JOB } from "../../../graphql/jobs.queries";
import ipcTypes from "../../../ipc.types";
import { CalculateVehicleAge } from "../../../ipc/ipc-estimate-utils";
import { DateFormat } from "../../../util/constants";
const { ipcRenderer } = window;
export default function CloseDateDisplayMolecule({ jobId, close_date }) {
export default function CloseDateDisplayMolecule({ job, jobId, close_date }) {
const [editMode, setEditMode] = useState(false);
const [value, setValue] = useState(moment(close_date));
const [loading, setLoading] = useState(false);
@@ -19,8 +21,17 @@ export default function CloseDateDisplayMolecule({ jobId, close_date }) {
});
setLoading(true);
setValue(newDate);
//Recalculate vehicle age.
const result = await updateJob({
variables: { jobId: jobId, job: { close_date: newDate } },
variables: {
jobId: jobId,
job: {
close_date: newDate,
v_age: CalculateVehicleAge({ ...job, close_date: newDate }),
},
},
});
if (!result.errors) {

View File

@@ -48,6 +48,7 @@ export default function JobsDetailDescriptionMolecule({ loading, job }) {
}
>
<CloseDateDisplayMolecule
job={job}
jobId={job.id}
close_date={job.close_date}
/>