From 2202683876536739cf4c07ad62b8f09c73eae168 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Wed, 2 Sep 2020 09:17:00 -0700 Subject: [PATCH] Added predefined shop labor rates BOD-395 --- bodyshop_translations.babel | 189 ++++++++++ ...s-detail-rates-change-button.component.jsx | 45 +++ .../jobs-detail-rates.component.jsx | 12 +- .../shop-info/shop-info.component.jsx | 7 + .../shop-info.laborrates.component.jsx | 337 ++++++++++++++++++ client/src/graphql/bodyshop.queries.js | 2 + .../jobs-detail.page.component.jsx | 2 +- client/src/translations/en_us/common.json | 11 +- client/src/translations/es/common.json | 11 +- client/src/translations/fr/common.json | 11 +- .../down.yaml | 5 + .../up.yaml | 6 + .../down.yaml | 66 ++++ .../up.yaml | 67 ++++ .../down.yaml | 60 ++++ .../up.yaml | 61 ++++ hasura/migrations/metadata.yaml | 2 + 17 files changed, 881 insertions(+), 13 deletions(-) create mode 100644 client/src/components/jobs-detail-rates-change-button/jobs-detail-rates-change-button.component.jsx create mode 100644 client/src/components/shop-info/shop-info.laborrates.component.jsx create mode 100644 hasura/migrations/1598979671763_alter_table_public_bodyshops_add_column_md_labor_rates/down.yaml create mode 100644 hasura/migrations/1598979671763_alter_table_public_bodyshops_add_column_md_labor_rates/up.yaml create mode 100644 hasura/migrations/1598979718946_update_permission_user_public_table_bodyshops/down.yaml create mode 100644 hasura/migrations/1598979718946_update_permission_user_public_table_bodyshops/up.yaml create mode 100644 hasura/migrations/1598979729004_update_permission_user_public_table_bodyshops/down.yaml create mode 100644 hasura/migrations/1598979729004_update_permission_user_public_table_bodyshops/up.yaml diff --git a/bodyshop_translations.babel b/bodyshop_translations.babel index a2f67296b..d17061552 100644 --- a/bodyshop_translations.babel +++ b/bodyshop_translations.babel @@ -1012,6 +1012,27 @@ + + newlaborrate + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + newstatus false @@ -3962,6 +3983,27 @@ + + laborrates + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + notemplatesavailable false @@ -11130,6 +11172,27 @@ + + changelaborrate + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + changestatus false @@ -13266,6 +13329,111 @@ + + ma2s + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + ma3s + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + mabl + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + macs + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + mahw + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + mapa false @@ -13308,6 +13476,27 @@ + + matd + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + other_amount_payable false diff --git a/client/src/components/jobs-detail-rates-change-button/jobs-detail-rates-change-button.component.jsx b/client/src/components/jobs-detail-rates-change-button/jobs-detail-rates-change-button.component.jsx new file mode 100644 index 000000000..d7330544d --- /dev/null +++ b/client/src/components/jobs-detail-rates-change-button/jobs-detail-rates-change-button.component.jsx @@ -0,0 +1,45 @@ +import React from "react"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectBodyshop } from "../../redux/user/user.selectors"; +import { DownOutlined } from "@ant-design/icons"; +import { Dropdown, Menu } from "antd"; +import { useTranslation } from "react-i18next"; + +const mapStateToProps = createStructuredSelector({ + bodyshop: selectBodyshop, +}); + +export function JobsDetailRatesChangeButton({ form, bodyshop }) { + const { t } = useTranslation(); + + const handleClick = ({ item, key, keyPath }) => { + const rate = item.props.value; + console.log("handleClick -> rate", rate); + form.setFieldsValue(rate); + }; + + const menu = ( + + {bodyshop.md_labor_rates.map((rate, idx) => ( + + {rate.label} + + ))} + + ); + + return ( + + e.preventDefault()} + > + {t("jobs.actions.changelaborrate")} + + + ); +} + +export default connect(mapStateToProps, null)(JobsDetailRatesChangeButton); 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 c9251e925..86da2fe22 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 @@ -1,17 +1,11 @@ import { Form, Select } 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"; import CurrencyInput from "../form-items-formatted/currency-form-item.component"; import FormRow from "../layout-form-row/layout-form-row.component"; +import JobsDetailRatesChangeButton from "../jobs-detail-rates-change-button/jobs-detail-rates-change-button.component"; -const mapStateToProps = createStructuredSelector({ - bodyshop: selectBodyshop, -}); - -export function JobsDetailRates({ job, bodyshop }) { +export default function JobsDetailRates({ job, form }) { const { t } = useTranslation(); return ( @@ -57,6 +51,7 @@ export function JobsDetailRates({ job, bodyshop }) { + @@ -131,4 +126,3 @@ export function JobsDetailRates({ job, bodyshop }) { ); } -export default connect(mapStateToProps, null)(JobsDetailRates); diff --git a/client/src/components/shop-info/shop-info.component.jsx b/client/src/components/shop-info/shop-info.component.jsx index fabf25ae8..25e033c36 100644 --- a/client/src/components/shop-info/shop-info.component.jsx +++ b/client/src/components/shop-info/shop-info.component.jsx @@ -20,6 +20,7 @@ import ShopInfoResponsibilityCenterComponent from "./shop-info.responsibilitycen import ShopInfoROStatusComponent from "./shop-info.rostatus.component"; import ShopInfoSchedulingComponent from "./shop-info.scheduling.component"; import ShopInfoSpeedPrint from "./shop-info.speedprint.component"; +import ShopInfoLaborRates from "./shop-info.laborrates.component"; export default function ShopInfoComponent({ form, saveLoading }) { const { t } = useTranslation(); @@ -499,6 +500,12 @@ export default function ShopInfoComponent({ form, saveLoading }) { + + + ); diff --git a/client/src/components/shop-info/shop-info.laborrates.component.jsx b/client/src/components/shop-info/shop-info.laborrates.component.jsx new file mode 100644 index 000000000..27f27a522 --- /dev/null +++ b/client/src/components/shop-info/shop-info.laborrates.component.jsx @@ -0,0 +1,337 @@ +import { DeleteFilled } from "@ant-design/icons"; +import { Button, Form, Input } from "antd"; +import React from "react"; +import { useTranslation } from "react-i18next"; +import CurrencyInput from "../form-items-formatted/currency-form-item.component"; +import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component"; +import LayoutFormRow from "../layout-form-row/layout-form-row.component"; + +export default function ShopInfoLaborRates({ form }) { + const { t } = useTranslation(); + + return ( +
+ + {(fields, { add, remove, move }) => { + return ( +
+ {fields.map((field, index) => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { + remove(field.name); + }} + /> + + + + ))} + + + +
+ ); + }} +
+
+ ); +} diff --git a/client/src/graphql/bodyshop.queries.js b/client/src/graphql/bodyshop.queries.js index 3c4e51f5b..80fb94214 100644 --- a/client/src/graphql/bodyshop.queries.js +++ b/client/src/graphql/bodyshop.queries.js @@ -58,6 +58,7 @@ export const QUERY_BODYSHOP = gql` md_ins_cos md_categories enforce_class + md_labor_rates employees { id first_name @@ -122,6 +123,7 @@ export const UPDATE_SHOP = gql` md_ins_cos md_categories enforce_class + md_labor_rates employees { id first_name diff --git a/client/src/pages/jobs-detail/jobs-detail.page.component.jsx b/client/src/pages/jobs-detail/jobs-detail.page.component.jsx index 43775c021..e9e5b8467 100644 --- a/client/src/pages/jobs-detail/jobs-detail.page.component.jsx +++ b/client/src/pages/jobs-detail/jobs-detail.page.component.jsx @@ -197,7 +197,7 @@ export function JobsDetailPage({ } key="rates" > - +