From e700095551d8386f96e085e9b70e798f4ed03811 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Mon, 18 Oct 2021 20:26:57 -0700 Subject: [PATCH] IO-1492 Add estimator Presets --- bodyshop_translations.babel | 42 +++++++++ .../phone-form-item.component.jsx | 2 +- ...jobs-detail-change-estimator.component.jsx | 46 +++++++++ .../jobs-detail-general.component.jsx | 23 ++++- .../jobs-detail-rates.component.jsx | 1 - .../shop-info/shop-info.general.component.jsx | 93 ++++++++++++++++++- client/src/graphql/bodyshop.queries.js | 2 + client/src/translations/en_us/common.json | 2 + client/src/translations/es/common.json | 2 + client/src/translations/fr/common.json | 2 + hasura/metadata/tables.yaml | 2 + .../down.sql | 4 + .../up.sql | 2 + 13 files changed, 218 insertions(+), 5 deletions(-) create mode 100644 client/src/components/jobs-detail-change-estimator/jobs-detail-change-estimator.component.jsx create mode 100644 hasura/migrations/1634612257400_alter_table_public_bodyshops_add_column_md_estimators/down.sql create mode 100644 hasura/migrations/1634612257400_alter_table_public_bodyshops_add_column_md_estimators/up.sql diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index 78f8f53ed..f6215e80d 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -8019,6 +8019,27 @@ + + estimators + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + insurancecos false @@ -17449,6 +17470,27 @@ + + changestimator + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + convert false diff --git a/client/src/components/form-items-formatted/phone-form-item.component.jsx b/client/src/components/form-items-formatted/phone-form-item.component.jsx index 023e8b146..aba9e3ab8 100644 --- a/client/src/components/form-items-formatted/phone-form-item.component.jsx +++ b/client/src/components/form-items-formatted/phone-form-item.component.jsx @@ -21,7 +21,7 @@ export const PhoneItemFormatterValidation = (getFieldValue, name) => ({ return Promise.resolve(); } else { const p = parsePhoneNumber(value, "CA"); - if (p.isValid()) { + if (p && p.isValid()) { return Promise.resolve(); } else { return Promise.reject(i18n.t("general.validation.invalidphone")); diff --git a/client/src/components/jobs-detail-change-estimator/jobs-detail-change-estimator.component.jsx b/client/src/components/jobs-detail-change-estimator/jobs-detail-change-estimator.component.jsx new file mode 100644 index 000000000..58666581e --- /dev/null +++ b/client/src/components/jobs-detail-change-estimator/jobs-detail-change-estimator.component.jsx @@ -0,0 +1,46 @@ +import { DownOutlined } from "@ant-design/icons"; +import { Dropdown, Menu } from "antd"; +import React from "react"; +import { useTranslation } from "react-i18next"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectBodyshop } from "../../redux/user/user.selectors"; + +const mapStateToProps = createStructuredSelector({ + bodyshop: selectBodyshop, +}); + +export function JobsDetailChangeEstimator({ disabled, form, bodyshop }) { + const { t } = useTranslation(); + + const handleClick = ({ item, key, keyPath }) => { + const est = item.props.value; + form.setFieldsValue(est); + }; + + const menu = ( +
+ + {bodyshop.md_estimators.map((est, idx) => ( + + {`${est.est_ct_fn} ${est.est_ct_ln}`} + + ))} + +
+ ); + + return ( + + e.preventDefault()} + > + {t("jobs.actions.changestimator")} + + + ); +} + +export default connect(mapStateToProps, null)(JobsDetailChangeEstimator); diff --git a/client/src/components/jobs-detail-general/jobs-detail-general.component.jsx b/client/src/components/jobs-detail-general/jobs-detail-general.component.jsx index 3de0b40b4..c3746bde6 100644 --- a/client/src/components/jobs-detail-general/jobs-detail-general.component.jsx +++ b/client/src/components/jobs-detail-general/jobs-detail-general.component.jsx @@ -1,4 +1,14 @@ -import { Col, Form, Input, InputNumber, Row, Select, Switch } from "antd"; +import { + Col, + Divider, + Form, + Input, + InputNumber, + Row, + Select, + Space, + Switch, +} from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; @@ -12,6 +22,7 @@ import FormItemPhone, { PhoneItemFormatterValidation, } from "../form-items-formatted/phone-form-item.component"; import Car from "../job-damage-visual/job-damage-visual.component"; +import JobsDetailChangeEstimator from "../jobs-detail-change-estimator/jobs-detail-change-estimator.component"; import FormRow from "../layout-form-row/layout-form-row.component"; const mapStateToProps = createStructuredSelector({ @@ -194,8 +205,16 @@ export function JobsDetailGeneral({ bodyshop, jobRO, job, form }) { )} + + {t("jobs.forms.appraiserinfo")} + - + + diff --git a/client/src/components/jobs-detail-rates/jobs-detail-rates.component.jsx b/client/src/components/jobs-detail-rates/jobs-detail-rates.component.jsx index 1ea27d45f..7e9d9a039 100644 --- a/client/src/components/jobs-detail-rates/jobs-detail-rates.component.jsx +++ b/client/src/components/jobs-detail-rates/jobs-detail-rates.component.jsx @@ -124,7 +124,6 @@ export function JobsDetailRates({ jobRO, form, job, bodyshop }) { {t("jobs.forms.laborrates")} -
diff --git a/client/src/components/shop-info/shop-info.general.component.jsx b/client/src/components/shop-info/shop-info.general.component.jsx index 1ab1e13f5..1204aff92 100644 --- a/client/src/components/shop-info/shop-info.general.component.jsx +++ b/client/src/components/shop-info/shop-info.general.component.jsx @@ -17,6 +17,8 @@ import PhoneFormItem, { import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; import CurrencyInput from "../form-items-formatted/currency-form-item.component"; +import FormItemEmail from "../form-items-formatted/email-form-item.component"; + export default function ShopInfoGeneral({ form }) { const { t } = useTranslation(); return ( @@ -706,7 +708,7 @@ export default function ShopInfoGeneral({ form }) { > - + + + + {(fields, { add, remove, move }) => { + return ( +
+ {fields.map((field, index) => ( + + + + + + + + + + + + + PhoneItemFormatterValidation(getFieldValue, [ + field.name, + "est_ph", + ]), + ]} + > + + + + + + + { + remove(field.name); + }} + /> + + + + + ))} + + + +
+ ); + }} +
+
{(fields, { add, remove, move }) => { diff --git a/client/src/graphql/bodyshop.queries.js b/client/src/graphql/bodyshop.queries.js index b1e783bf4..b9502b9b4 100644 --- a/client/src/graphql/bodyshop.queries.js +++ b/client/src/graphql/bodyshop.queries.js @@ -94,6 +94,7 @@ export const QUERY_BODYSHOP = gql` attach_pdf_to_email tt_allow_post_to_invoiced cdk_configuration + md_estimators employees { id active @@ -184,6 +185,7 @@ export const UPDATE_SHOP = gql` attach_pdf_to_email tt_allow_post_to_invoiced cdk_configuration + md_estimators employees { id first_name diff --git a/client/src/translations/en_us/common.json b/client/src/translations/en_us/common.json index 2aae54210..740fee51d 100644 --- a/client/src/translations/en_us/common.json +++ b/client/src/translations/en_us/common.json @@ -499,6 +499,7 @@ }, "emaillater": "Email Later", "employees": "Employees", + "estimators": "Estimators", "insurancecos": "Insurance Companies", "intakechecklist": "Intake Checklist", "jobstatuses": "Job Statuses", @@ -1089,6 +1090,7 @@ "autoallocate": "Auto Allocate", "changelaborrate": "Change Labor Rate", "changestatus": "Change Status", + "changestimator": "Change Estimator", "convert": "Convert", "deliver": "Deliver", "dms": { diff --git a/client/src/translations/es/common.json b/client/src/translations/es/common.json index 27d6d6c4a..e3de458b3 100644 --- a/client/src/translations/es/common.json +++ b/client/src/translations/es/common.json @@ -499,6 +499,7 @@ }, "emaillater": "", "employees": "", + "estimators": "", "insurancecos": "", "intakechecklist": "", "jobstatuses": "", @@ -1089,6 +1090,7 @@ "autoallocate": "", "changelaborrate": "", "changestatus": "Cambiar Estado", + "changestimator": "", "convert": "Convertir", "deliver": "", "dms": { diff --git a/client/src/translations/fr/common.json b/client/src/translations/fr/common.json index 382ab5e08..f46cba160 100644 --- a/client/src/translations/fr/common.json +++ b/client/src/translations/fr/common.json @@ -499,6 +499,7 @@ }, "emaillater": "", "employees": "", + "estimators": "", "insurancecos": "", "intakechecklist": "", "jobstatuses": "", @@ -1089,6 +1090,7 @@ "autoallocate": "", "changelaborrate": "", "changestatus": "Changer le statut", + "changestimator": "", "convert": "Convertir", "deliver": "", "dms": { diff --git a/hasura/metadata/tables.yaml b/hasura/metadata/tables.yaml index dda92cdd4..f49c65402 100644 --- a/hasura/metadata/tables.yaml +++ b/hasura/metadata/tables.yaml @@ -824,6 +824,7 @@ - md_categories - md_ccc_rates - md_classes + - md_estimators - md_hour_split - md_ins_cos - md_jobline_presets @@ -900,6 +901,7 @@ - md_categories - md_ccc_rates - md_classes + - md_estimators - md_hour_split - md_ins_cos - md_jobline_presets diff --git a/hasura/migrations/1634612257400_alter_table_public_bodyshops_add_column_md_estimators/down.sql b/hasura/migrations/1634612257400_alter_table_public_bodyshops_add_column_md_estimators/down.sql new file mode 100644 index 000000000..6cd9d69e0 --- /dev/null +++ b/hasura/migrations/1634612257400_alter_table_public_bodyshops_add_column_md_estimators/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."bodyshops" add column "md_estimators" jsonb +-- null default jsonb_build_array(); diff --git a/hasura/migrations/1634612257400_alter_table_public_bodyshops_add_column_md_estimators/up.sql b/hasura/migrations/1634612257400_alter_table_public_bodyshops_add_column_md_estimators/up.sql new file mode 100644 index 000000000..db89734e3 --- /dev/null +++ b/hasura/migrations/1634612257400_alter_table_public_bodyshops_add_column_md_estimators/up.sql @@ -0,0 +1,2 @@ +alter table "public"."bodyshops" add column "md_estimators" jsonb + null default jsonb_build_array();