From 5ecd5a5a5c7f36228e371249b3989f778cc5f365 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Wed, 4 Aug 2021 09:10:23 -0700 Subject: [PATCH 1/4] IO-1122 Add permission to text to intake checklist. --- bodyshop_translations.babel | 21 ++++++++++++++ .../job-checklist-form.component.jsx | 29 +++++++++++++++++++ client/src/graphql/bodyshop.queries.js | 4 +++ client/src/translations/en_us/common.json | 1 + client/src/translations/es/common.json | 1 + client/src/translations/fr/common.json | 1 + 6 files changed, 57 insertions(+) diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 39f7c8a01..dbee40f32 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -8144,6 +8144,27 @@ + + allow_text_message + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + checklist false diff --git a/client/src/components/job-checklist/components/job-checklist-form/job-checklist-form.component.jsx b/client/src/components/job-checklist/components/job-checklist-form/job-checklist-form.component.jsx index 8c6db2e4c..cc61d1aa3 100644 --- a/client/src/components/job-checklist/components/job-checklist-form/job-checklist-form.component.jsx +++ b/client/src/components/job-checklist/components/job-checklist-form/job-checklist-form.component.jsx @@ -18,6 +18,7 @@ import DateTimePicker from "../../../form-date-time-picker/form-date-time-picker import moment from "moment-business-days"; import { insertAuditTrail } from "../../../../redux/application/application.actions"; import AuditTrailMapping from "../../../../utils/AuditTrailMappings"; +import { UPDATE_OWNER } from "../../../../graphql/owners.queries"; const mapStateToProps = createStructuredSelector({ bodyshop: selectBodyshop, @@ -41,6 +42,8 @@ export function JobChecklistForm({ const [intakeJob] = useMutation(UPDATE_JOB); const [loading, setLoading] = useState(false); const [markAptArrived] = useMutation(MARK_LATEST_APPOINTMENT_AS_ARRIVED); + const [updateOwner] = useMutation(UPDATE_OWNER); + const { jobId } = useParams(); const history = useHistory(); const search = queryString.parse(useLocation().search); @@ -114,6 +117,23 @@ export function JobChecklistForm({ }); } } + + //Updae Owner Allow to Text + const updateOwnerResult = await updateOwner({ + variables: { + ownerId: job.owner.id, + owner: { allow_text_message: values.allow_text_message }, + }, + }); + + if (!!updateOwnerResult.errors) { + notification["error"]({ + message: t("checklist.errors.complete", { + error: JSON.stringify(result.errors), + }), + }); + } + setLoading(false); if (!!!result.errors) { @@ -156,6 +176,7 @@ export function JobChecklistForm({ initialValues={{ ...(type === "intake" && { addToProduction: true, + allow_text_message: job.owner.allow_text_message, scheduled_completion: (job && job.scheduled_completion) || moment().businessAdd( @@ -191,6 +212,14 @@ export function JobChecklistForm({ > + + + Date: Wed, 4 Aug 2021 09:30:53 -0700 Subject: [PATCH 2/4] IO-1285 Resolve production not saving sort order. --- ...uction-list-table-view-select.component.jsx | 7 +++++++ .../production-list-table.component.jsx | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/client/src/components/production-list-table/production-list-table-view-select.component.jsx b/client/src/components/production-list-table/production-list-table-view-select.component.jsx index 3cc78c102..f64d1121a 100644 --- a/client/src/components/production-list-table/production-list-table-view-select.component.jsx +++ b/client/src/components/production-list-table/production-list-table-view-select.component.jsx @@ -25,6 +25,7 @@ export function ProductionListTable({ currentUser, state, setColumns, + setState, }) { const { t } = useTranslation(); const [updateDefaultProdView] = useMutation(UPDATE_ACTIVE_PROD_LIST_VIEW); @@ -43,6 +44,10 @@ export function ProductionListTable({ }; }) ); + setState( + bodyshop.production_config.filter((pc) => pc.name === value)[0].columns + .tableState + ); const assoc = bodyshop.associations.find( (a) => a.useremail === currentUser.email @@ -77,6 +82,8 @@ export function ProductionListTable({ }; }) ); + + setState(bodyshop.production_config[0].columns.tableState); }; return ( diff --git a/client/src/components/production-list-table/production-list-table.component.jsx b/client/src/components/production-list-table/production-list-table.component.jsx index 59507c593..d08c5e7a9 100644 --- a/client/src/components/production-list-table/production-list-table.component.jsx +++ b/client/src/components/production-list-table/production-list-table.component.jsx @@ -38,17 +38,26 @@ export function ProductionListTable({ ); return assoc && assoc.default_prod_list_view; }, [bodyshop.associations, currentUser.email]); + console.log( + "🚀 ~ file: production-list-table.component.jsx ~ line 41 ~ defaultView", + defaultView + ); const [state, setState] = useState( (bodyshop.production_config && - bodyshop.production_config.find((p) => p.name === defaultView) - ?.tableState) || - bodyshop.production_config[0]?.tableState || { + bodyshop.production_config.find((p) => p.name === defaultView)?.columns + .tableState) || + bodyshop.production_config[0]?.columns.tableState || { sortedInfo: {}, filteredInfo: { text: "" }, } ); + console.log( + "🚀 ~ file: production-list-table.component.jsx ~ line 51 ~ bodyshop.production_config", + bodyshop.production_config + ); + console.log("state", state); const { t } = useTranslation(); const matchingColumnConfig = useMemo(() => { @@ -155,7 +164,7 @@ export function ProductionListTable({ // } // }; - if (!!!columns) return
No columns found.
; + if (!!!columns || columns.length === 0) return
No columns found.
; return (
@@ -173,6 +182,7 @@ export function ProductionListTable({ From 69c13dd052f38efe5ccd648b99ceed15fc599bed Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Thu, 5 Aug 2021 09:10:09 -0700 Subject: [PATCH 3/4] IO-1286 Resolve supplementing issues. --- .../jobs-available-table.container.jsx | 69 +++++++++++-------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/client/src/components/jobs-available-table/jobs-available-table.container.jsx b/client/src/components/jobs-available-table/jobs-available-table.container.jsx index 9314a455e..ae3accf53 100644 --- a/client/src/components/jobs-available-table/jobs-available-table.container.jsx +++ b/client/src/components/jobs-available-table/jobs-available-table.container.jsx @@ -75,7 +75,7 @@ export function JobsAvailableContainer({ const client = useApolloClient(); const estDataLazyLoad = useLazyQuery(QUERY_AVAILABLE_NEW_JOBS_EST_DATA_BY_PK); - const [loadEstData, estData] = estDataLazyLoad; + const [loadEstData, estDataRaw] = estDataLazyLoad; const importOptionsState = useState({ overrideHeaders: false }); const importOptions = importOptionsState[0]; @@ -88,11 +88,13 @@ export function JobsAvailableContainer({ setOwnerModalVisible(false); setInsertLoading(true); + const estData = replaceEmpty(estDataRaw.data.available_jobs_by_pk); + if ( !( - estData.data && - estData.data.available_jobs_by_pk && - estData.data.available_jobs_by_pk.est_data + + estData && + estData.est_data ) ) { //We don't have the right data. Error! @@ -106,28 +108,28 @@ export function JobsAvailableContainer({ const newTotals = ( await Axios.post("/job/totals", { job: { - ...estData.data.available_jobs_by_pk.est_data, - joblines: estData.data.available_jobs_by_pk.est_data.joblines.data, + ...estData.est_data, + joblines: estData.est_data.joblines.data, }, }) ).data; let existingVehicles; if ( - estData.data.available_jobs_by_pk.est_data.vehicle && - estData.data.available_jobs_by_pk.est_data.vin + estData.est_data.vehicle && + estData.est_data.vin ) { //There's vehicle data, need to double check the VIN. existingVehicles = await client.query({ query: SEARCH_VEHICLE_BY_VIN, variables: { - vin: estData.data.available_jobs_by_pk.est_data.vehicle.data.v_vin, + vin: estData.est_data.vehicle.data.v_vin, }, }); } const newJob = { - ...estData.data.available_jobs_by_pk.est_data, + ...estData.est_data, clm_total: Dinero(newTotals.totals.total_repairs).toFormat("0.00"), owner_owing: Dinero(newTotals.totals.custPayable.total).toFormat("0.00"), job_totals: newTotals, @@ -172,7 +174,7 @@ export function JobsAvailableContainer({ }); deleteJob({ - variables: { id: estData.data.available_jobs_by_pk.id }, + variables: { id: estData.id }, }).then((r) => { refetch(); setInsertLoading(false); @@ -194,12 +196,12 @@ export function JobsAvailableContainer({ setJobModalVisible(false); setInsertLoading(true); - + const estData = replaceEmpty(estDataRaw.data.available_jobs_by_pk); if ( !( - estData.data && - estData.data.available_jobs_by_pk && - estData.data.available_jobs_by_pk.est_data + + estData && + estData.est_data ) ) { //We don't have the right data. Error! @@ -209,7 +211,7 @@ export function JobsAvailableContainer({ }); } else { //create upsert job - let supp = _.cloneDeep(estData.data.available_jobs_by_pk.est_data); + let supp = _.cloneDeep(estData.est_data); delete supp.owner; delete supp.vehicle; @@ -220,7 +222,7 @@ export function JobsAvailableContainer({ let suppDelta = await GetSupplementDelta( client, selectedJob, - estData.data.available_jobs_by_pk.est_data.joblines.data + estData.est_data.joblines.data ); delete supp.joblines; @@ -279,7 +281,7 @@ export function JobsAvailableContainer({ //Job has been inserted. Clean up the available jobs record. deleteJob({ - variables: { id: estData.data.available_jobs_by_pk.id }, + variables: { id: estData.id }, }).then((r) => { refetch(); setInsertLoading(false); @@ -305,13 +307,13 @@ export function JobsAvailableContainer({ }; const owner = - estData.data && - estData.data.available_jobs_by_pk && - estData.data.available_jobs_by_pk.est_data && - estData.data.available_jobs_by_pk.est_data.owner && - estData.data.available_jobs_by_pk.est_data.owner.data && - !estData.data.available_jobs_by_pk.issupplement - ? estData.data.available_jobs_by_pk.est_data.owner.data + estDataRaw.data && + estDataRaw.data.available_jobs_by_pk && + estDataRaw.data.available_jobs_by_pk.est_data && + estDataRaw.data.available_jobs_by_pk.est_data.owner && + estDataRaw.data.available_jobs_by_pk.est_data.owner.data && + !estDataRaw.data.available_jobs_by_pk.issupplement + ? estDataRaw.data.available_jobs_by_pk.est_data.owner.data : null; const onOwnerModalCancel = () => { @@ -349,8 +351,8 @@ export function JobsAvailableContainer({ message={t("jobs.labels.creating_new_job")} > (value === "" ? replaceValue : value); + //^ because you seem to want to replace (strings) "null" or "undefined" too + console.log(someObj) + const temp = JSON.stringify(someObj, replacer); + console.log(`temp`, temp); + return JSON.parse(temp); +} From 8c94dfce9e3773fe1ba75657975f926f094c9ec2 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Thu, 5 Aug 2021 09:11:53 -0700 Subject: [PATCH 4/4] Time ticket sort update & remove io event logging. --- .../production-list-table.component.jsx | 9 --------- .../time-ticket-list/time-ticket-list.component.jsx | 3 ++- client/src/utils/GraphQLClient.js | 2 +- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/client/src/components/production-list-table/production-list-table.component.jsx b/client/src/components/production-list-table/production-list-table.component.jsx index d08c5e7a9..0834cfa19 100644 --- a/client/src/components/production-list-table/production-list-table.component.jsx +++ b/client/src/components/production-list-table/production-list-table.component.jsx @@ -38,10 +38,6 @@ export function ProductionListTable({ ); return assoc && assoc.default_prod_list_view; }, [bodyshop.associations, currentUser.email]); - console.log( - "🚀 ~ file: production-list-table.component.jsx ~ line 41 ~ defaultView", - defaultView - ); const [state, setState] = useState( (bodyshop.production_config && @@ -52,12 +48,7 @@ export function ProductionListTable({ filteredInfo: { text: "" }, } ); - console.log( - "🚀 ~ file: production-list-table.component.jsx ~ line 51 ~ bodyshop.production_config", - bodyshop.production_config - ); - console.log("state", state); const { t } = useTranslation(); const matchingColumnConfig = useMemo(() => { diff --git a/client/src/components/time-ticket-list/time-ticket-list.component.jsx b/client/src/components/time-ticket-list/time-ticket-list.component.jsx index e60e7761c..6a7bf6b11 100644 --- a/client/src/components/time-ticket-list/time-ticket-list.component.jsx +++ b/client/src/components/time-ticket-list/time-ticket-list.component.jsx @@ -105,7 +105,8 @@ export function TimeTicketList({ title: t("jobs.fields.ro_number"), dataIndex: "ro_number", key: "ro_number", - sorter: (a, b) => alphaSort(a.job.ro_number, b.job.ro_number), + sorter: (a, b) => + alphaSort(a.job && a.job.ro_number, b.job && b.job.ro_number), sortOrder: state.sortedInfo.columnKey === "ro_number" && state.sortedInfo.order, render: (text, record) => diff --git a/client/src/utils/GraphQLClient.js b/client/src/utils/GraphQLClient.js index 269fdffe9..5840587e0 100644 --- a/client/src/utils/GraphQLClient.js +++ b/client/src/utils/GraphQLClient.js @@ -48,7 +48,7 @@ const roundTripLink = new ApolloLink((operation, forward) => { }); const TrackExecutionTime = async (operationName, time) => { - await axios.post("/ioevent", { operationName, time, dbevent: true }); + //await axios.post("/ioevent", { operationName, time, dbevent: true }); }; const subscriptionMiddleware = {