From b2c8e45d5ed8076bef4fc8845e10abb64a88cfa2 Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Thu, 14 Dec 2023 16:27:00 -0500 Subject: [PATCH] even more updates. Signed-off-by: Dave Richer --- client/src/App/App.jsx | 2 +- .../bill-form/bill-form.component.jsx | 36 +- .../bill-form/bill-form.container.jsx | 12 +- .../bill-form/bill-form.lines.component.jsx | 15 +- .../breadcrumbs/breadcrumbs.component.jsx | 15 +- .../contract-convert-to-ro.component.jsx | 2 +- .../contracts-list.component.jsx | 2 +- .../components/header/header.component.jsx | 23 +- .../job-checklist-form.component.jsx | 4 +- .../job-create-iou.component.jsx | 14 +- .../job-lines-upsert-modal.component.jsx | 18 +- .../job-lines-upsert-modal.container.jsx | 14 +- .../job-payments/job-payments.component.jsx | 24 +- .../jobs-available-table.container.jsx | 20 +- ...bs-document-gallery.download.component.jsx | 21 +- .../loading-spinner.component.jsx | 3 +- .../parts-order-modal.component.jsx | 638 +- .../parts-order-modal.container.jsx | 715 +- .../payment-form/payment-form.component.jsx | 287 +- ...ution-list-columns.touchtime.component.jsx | 2 +- .../production-list-table.component.jsx | 573 +- .../report-center-modal.component.jsx | 2 +- .../schedule-job-modal.component.jsx | 4 +- .../scoreboard-targets-table.util.js | 8 +- .../shop-employees-form.component.jsx | 2 +- .../shop-info/shop-info.component.jsx | 162 +- .../shop-info/shop-info.general.component.jsx | 18 +- .../shop-info.orderstatus.component.jsx | 169 +- .../shop-info/shop-info.rbac.component.jsx | 1378 +-- ...p-info.responsibilitycenters.component.jsx | 9145 ++++++++--------- .../shop-info.rostatus.component.jsx | 786 +- .../tech-job-print-tickets.component.jsx | 2 +- .../time-tickets-dates-selector.component.jsx | 2 +- .../time-ticket-list.component.jsx | 2 +- ...me-tickets-summary-employees.component.jsx | 4 +- .../vendors-form/vendors-form.component.jsx | 463 +- .../pages/jobs-close/jobs-close.component.jsx | 18 +- .../pages/manage/manage.page.component.jsx | 4 +- client/src/pages/tech/tech.page.component.jsx | 4 +- client/src/utils/DatePickerRanges.js | 85 +- server/tasks/tasks.js | 16 +- 41 files changed, 7326 insertions(+), 7388 deletions(-) diff --git a/client/src/App/App.jsx b/client/src/App/App.jsx index d1a5404dc..faa8cc211 100644 --- a/client/src/App/App.jsx +++ b/client/src/App/App.jsx @@ -104,7 +104,7 @@ export function App({ /> ); - + // Any route that is not assigned and matched will default to the Landing Page component return ( }> diff --git a/client/src/components/bill-form/bill-form.component.jsx b/client/src/components/bill-form/bill-form.component.jsx index 320d6ed74..4067bef7f 100644 --- a/client/src/components/bill-form/bill-form.component.jsx +++ b/client/src/components/bill-form/bill-form.component.jsx @@ -1,6 +1,6 @@ import Icon, {UploadOutlined} from "@ant-design/icons"; import {useApolloClient} from "@apollo/client"; -import {useTreatments} from "@splitsoftware/splitio-react"; +import {useSplitTreatments} from "@splitsoftware/splitio-react"; import {Alert, Divider, Form, Input, Select, Space, Statistic, Switch, Upload,} from "antd"; import dayjs from "../../utils/day"; import React, {useEffect, useState} from "react"; @@ -27,34 +27,18 @@ const mapStateToProps = createStructuredSelector({ }); const mapDispatchToProps = (dispatch) => ({}); -export function BillFormComponent({ - bodyshop, - disabled, - form, - vendorAutoCompleteOptions, - lineData, - responsibilityCenters, - loadLines, - billEdit, - disableInvNumber, - job, - loadOutstandingReturns, - loadInventory, - preferredMake, - }) { +export function BillFormComponent({bodyshop, disabled, form, vendorAutoCompleteOptions, lineData, responsibilityCenters, loadLines, billEdit, disableInvNumber, job, loadOutstandingReturns, loadInventory, preferredMake}) { + const {t} = useTranslation(); const client = useApolloClient(); const [discount, setDiscount] = useState(0); - const {Extended_Bill_Posting} = useTreatments( - ["Extended_Bill_Posting"], - {}, - bodyshop.imexshopid - ); - const {ClosingPeriod} = useTreatments( - ["ClosingPeriod"], - {}, - bodyshop.imexshopid - ); + + const { treatments: {Extended_Bill_Posting, ClosingPeriod} } = useSplitTreatments({ + attributes: {}, + names: ["Extended_Bill_Posting", "ClosingPeriod"], + splitKey: bodyshop.imexshopid, + }); + const handleVendorSelect = (props, opt) => { setDiscount(opt.discount); diff --git a/client/src/components/bill-form/bill-form.container.jsx b/client/src/components/bill-form/bill-form.container.jsx index d77e0d29c..b241e03a1 100644 --- a/client/src/components/bill-form/bill-form.container.jsx +++ b/client/src/components/bill-form/bill-form.container.jsx @@ -1,5 +1,5 @@ import { useLazyQuery, useQuery } from "@apollo/client"; -import { useTreatments } from "@splitsoftware/splitio-react"; +import {useSplitTreatments} from "@splitsoftware/splitio-react"; import React from "react"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; @@ -23,11 +23,11 @@ export function BillFormContainer({ disabled, disableInvNumber, }) { - const { Simple_Inventory } = useTreatments( - ["Simple_Inventory"], - {}, - bodyshop && bodyshop.imexshopid - ); + const { treatments: {Simple_Inventory} } = useSplitTreatments({ + attributes: {}, + names: ["Simple_Inventory"], + splitKey: bodyshop && bodyshop.imexshopid, + }); const { data: VendorAutoCompleteData } = useQuery( SEARCH_VENDOR_AUTOCOMPLETE, diff --git a/client/src/components/bill-form/bill-form.lines.component.jsx b/client/src/components/bill-form/bill-form.lines.component.jsx index 7ce5e723e..a8db395c1 100644 --- a/client/src/components/bill-form/bill-form.lines.component.jsx +++ b/client/src/components/bill-form/bill-form.lines.component.jsx @@ -1,5 +1,5 @@ import { DeleteFilled, DollarCircleFilled } from "@ant-design/icons"; -import { useTreatments } from "@splitsoftware/splitio-react"; +import {useSplitTreatments} from "@splitsoftware/splitio-react"; import { Button, Form, Input, @@ -40,11 +40,14 @@ export function BillEnterModalLinesComponent({ }) { const { t } = useTranslation(); const { setFieldsValue, getFieldsValue, getFieldValue } = form; - const { Simple_Inventory } = useTreatments( - ["Simple_Inventory"], - {}, - bodyshop && bodyshop.imexshopid - ); + + const { treatments: {Simple_Inventory} } = useSplitTreatments({ + attributes: {}, + names: ["Simple_Inventory"], + splitKey: bodyshop && bodyshop.imexshopid, + }); + + const columns = (remove) => { return [ { diff --git a/client/src/components/breadcrumbs/breadcrumbs.component.jsx b/client/src/components/breadcrumbs/breadcrumbs.component.jsx index e74be220d..d75ca44e2 100644 --- a/client/src/components/breadcrumbs/breadcrumbs.component.jsx +++ b/client/src/components/breadcrumbs/breadcrumbs.component.jsx @@ -9,7 +9,7 @@ import { selectBodyshop } from "../../redux/user/user.selectors"; import GlobalSearch from "../global-search/global-search.component"; import GlobalSearchOs from "../global-search/global-search-os.component"; import "./breadcrumbs.styles.scss"; -import { useTreatments } from "@splitsoftware/splitio-react"; +import { useSplitTreatments } from "@splitsoftware/splitio-react"; const mapStateToProps = createStructuredSelector({ breadcrumbs: selectBreadcrumbs, @@ -17,13 +17,14 @@ const mapStateToProps = createStructuredSelector({ }); export function BreadCrumbs({ breadcrumbs, bodyshop }) { - const { OpenSearch } = useTreatments( - ["OpenSearch"], - {}, - bodyshop && bodyshop.imexshopid - ); - return ( + const { treatments: {OpenSearch} } = useSplitTreatments({ + attributes: {}, + names: ["OpenSearch"], + splitKey: bodyshop && bodyshop.imexshopid, + }); + + return ( diff --git a/client/src/components/contract-convert-to-ro/contract-convert-to-ro.component.jsx b/client/src/components/contract-convert-to-ro/contract-convert-to-ro.component.jsx index 63d0472b7..07ebb4696 100644 --- a/client/src/components/contract-convert-to-ro/contract-convert-to-ro.component.jsx +++ b/client/src/components/contract-convert-to-ro/contract-convert-to-ro.component.jsx @@ -48,7 +48,7 @@ export function ContractConvertToRo({ const contractLength = dayjs(contract.actualreturn).diff( dayjs(contract.start), - "days" + "day" ); const billingLines = []; if (contractLength > 0) diff --git a/client/src/components/contracts-list/contracts-list.component.jsx b/client/src/components/contracts-list/contracts-list.component.jsx index d309d9118..894f44327 100644 --- a/client/src/components/contracts-list/contracts-list.component.jsx +++ b/client/src/components/contracts-list/contracts-list.component.jsx @@ -153,7 +153,7 @@ export function ContractsList({ (record.actualreturn && record.start && `${dayjs(record.actualreturn) - .diff(dayjs(record.start), "days", true) + .diff(dayjs(record.start), "day", true) .toFixed(1)} days`) || "", }, diff --git a/client/src/components/header/header.component.jsx b/client/src/components/header/header.component.jsx index 3e0aed6d7..3ba45ca94 100644 --- a/client/src/components/header/header.component.jsx +++ b/client/src/components/header/header.component.jsx @@ -25,7 +25,7 @@ import Icon, { UnorderedListOutlined, UserOutlined, } from "@ant-design/icons"; -import { useTreatments } from "@splitsoftware/splitio-react"; +import {useSplitTreatments} from "@splitsoftware/splitio-react"; import { Layout, Menu } from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; @@ -87,21 +87,12 @@ function Header({ recentItems, setCardPaymentContext, }) { - const { Simple_Inventory } = useTreatments( - ["Simple_Inventory"], - {}, - bodyshop && bodyshop.imexshopid - ); - const { DmsAp } = useTreatments( - ["DmsAp"], - {}, - bodyshop && bodyshop.imexshopid - ); - const { ImEXPay } = useTreatments( - ["ImEXPay"], - {}, - bodyshop && bodyshop.imexshopid - ); + // TODO: Client Update - New Split Treatments usage example + const { treatments: {ImEXPay, DmsAp, Simple_Inventory} } = useSplitTreatments({ + attributes: {}, + names: ["ImEXPay", "DmsAp", "Simple_Inventory"], + splitKey: bodyshop && bodyshop.imexshopid, + }); const { t } = useTranslation(); 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 0b11ebb27..eadd754b8 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 @@ -89,7 +89,7 @@ export function JobChecklistForm({ bodyshop.intakechecklist.next_contact_hours > 0 && { date_next_contact: dayjs().add( bodyshop.intakechecklist.next_contact_hours, - "hours" + "hour" ), }), ...(type === "deliver" && { @@ -226,7 +226,7 @@ export function JobChecklistForm({ (job.labhrs.aggregate.sum.mod_lb_hrs || 0 + job.larhrs.aggregate.sum.mod_lb_hrs || 0) / bodyshop.target_touchtime, - "days" + "day" )), scheduled_delivery: job.scheduled_delivery && dayjs(job.scheduled_delivery), diff --git a/client/src/components/job-create-iou/job-create-iou.component.jsx b/client/src/components/job-create-iou/job-create-iou.component.jsx index 9af56d68b..925c3c2e8 100644 --- a/client/src/components/job-create-iou/job-create-iou.component.jsx +++ b/client/src/components/job-create-iou/job-create-iou.component.jsx @@ -1,5 +1,5 @@ import { useApolloClient } from "@apollo/client"; -import { useTreatments } from "@splitsoftware/splitio-react"; +import { useSplitTreatments } from "@splitsoftware/splitio-react"; import { Button, notification, Popconfirm } from "antd"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; @@ -27,11 +27,13 @@ export function JobCreateIOU({ bodyshop, currentUser, job, selectedJobLines }) { const client = useApolloClient(); const history = useNavigate(); - const { IOU_Tracking } = useTreatments( - ["IOU_Tracking"], - {}, - bodyshop.imexshopid - ); + + const { treatments: {IOU_Tracking} } = useSplitTreatments({ + attributes: {}, + names: ["IOU_Tracking"], + splitKey: bodyshop.imexshopid, + }); + if (IOU_Tracking.treatment !== "on") return null; const handleCreateIou = async () => { diff --git a/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.component.jsx b/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.component.jsx index ef5449c22..57ec7792c 100644 --- a/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.component.jsx +++ b/client/src/components/job-lines-upsert-modal/job-lines-upsert-modal.component.jsx @@ -4,7 +4,7 @@ import { useTranslation } from "react-i18next"; import InputCurrency from "../form-items-formatted/currency-form-item.component"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; import JoblinesPreset from "../job-lines-preset-button/job-lines-preset-button.component"; -import { useTreatments } from "@splitsoftware/splitio-react"; +import { useSplitTreatments } from "@splitsoftware/splitio-react"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; @@ -35,16 +35,12 @@ export function JobLinesUpsertModalComponent({ form.resetFields(); }, [visible, form]); - const { Allow_Negative_Jobline_Price } = useTreatments( - ["Allow_Negative_Jobline_Price"], - {}, - bodyshop.imexshopid - ); - const { Autohouse_Detail_line } = useTreatments( - ["Autohouse_Detail_line"], - {}, - bodyshop.imexshopid - ); + + const { treatments: {Allow_Negative_Jobline_Price, Autohouse_Detail_line} } = useSplitTreatments({ + attributes: {}, + names: ["Allow_Negative_Jobline_Price", "Autohouse_Detail_line"], + splitKey: bodyshop.imexshopid, + }); return ( ({ setMessage: (text) => dispatch(setMessage(text)), }); -export function JobPayments({ - job, - jobRO, - bodyshop, - setMessage, - openChatByPhone, - setPaymentContext, - setCardPaymentContext, - refetch, -}) { - const { ImEXPay } = useTreatments( - ["ImEXPay"], - {}, - bodyshop && bodyshop.imexshopid - ); +export function JobPayments({job, jobRO, bodyshop, setMessage, openChatByPhone, setPaymentContext, setCardPaymentContext, refetch}) { + + const { treatments: {ImEXPay} } = useSplitTreatments({ + attributes: {}, + names: ["ImEXPay"], + splitKey:bodyshop && bodyshop.imexshopid, + }); const { t } = useTranslation(); const [state, setState] = useState({ 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 87b90e8c8..655c0e2ca 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 @@ -5,7 +5,7 @@ import { useMutation, useQuery, } from "@apollo/client"; -import { useTreatments } from "@splitsoftware/splitio-react"; +import { useSplitTreatments } from "@splitsoftware/splitio-react"; import { Col, notification, Row } from "antd"; import Axios from "axios"; import Dinero from "dinero.js"; @@ -50,16 +50,14 @@ const mapDispatchToProps = (dispatch) => ({ insertAuditTrail: ({ jobid, operation }) => dispatch(insertAuditTrail({ jobid, operation })), }); -export function JobsAvailableContainer({ - bodyshop, - currentUser, - insertAuditTrail, -}) { - const { CriticalPartsScanning } = useTreatments( - ["CriticalPartsScanning"], - {}, - bodyshop.imexshopid - ); +export function JobsAvailableContainer({bodyshop, currentUser, insertAuditTrail,}) { + + const { treatments: {CriticalPartsScanning} } = useSplitTreatments({ + attributes: {}, + names: ["CriticalPartsScanning"], + splitKey: bodyshop.imexshopid, + }); + const { loading, error, data, refetch } = useQuery(QUERY_AVAILABLE_JOBS, { fetchPolicy: "network-only", nextFetchPolicy: "network-only", diff --git a/client/src/components/jobs-documents-gallery/jobs-document-gallery.download.component.jsx b/client/src/components/jobs-documents-gallery/jobs-document-gallery.download.component.jsx index 2ed2e3ec4..cbb240988 100644 --- a/client/src/components/jobs-documents-gallery/jobs-document-gallery.download.component.jsx +++ b/client/src/components/jobs-documents-gallery/jobs-document-gallery.download.component.jsx @@ -6,7 +6,7 @@ import { logImEXEvent } from "../../firebase/firebase.utils"; import cleanAxios from "../../utils/CleanAxios"; import formatBytes from "../../utils/formatbytes"; //import yauzl from "yauzl"; -import { useTreatments } from "@splitsoftware/splitio-react"; +import { useSplitTreatments } from "@splitsoftware/splitio-react"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; @@ -22,18 +22,17 @@ export default connect( mapDispatchToProps )(JobsDocumentsDownloadButton); -export function JobsDocumentsDownloadButton({ - bodyshop, - galleryImages, - identifier, -}) { +export function JobsDocumentsDownloadButton({ bodyshop, galleryImages, identifier}) { + const { t } = useTranslation(); const [download, setDownload] = useState(null); - const { Direct_Media_Download } = useTreatments( - ["Direct_Media_Download"], - {}, - bodyshop.imexshopid - ); + + const { treatments: {Direct_Media_Download} } = useSplitTreatments({ + attributes: {}, + names: ["Direct_Media_Download"], + splitKey: bodyshop.imexshopid, + }); + const imagesToDownload = [ ...galleryImages.images.filter((image) => image.isSelected), ...galleryImages.other.filter((image) => image.isSelected), diff --git a/client/src/components/loading-spinner/loading-spinner.component.jsx b/client/src/components/loading-spinner/loading-spinner.component.jsx index e66b0f1af..325bbe17a 100644 --- a/client/src/components/loading-spinner/loading-spinner.component.jsx +++ b/client/src/components/loading-spinner/loading-spinner.component.jsx @@ -13,7 +13,8 @@ export default function LoadingSpinner({ loading = true, message, ...props }) { alignContent: "center" }} delay={200} - tip={message ? message : null} + // TODO: Client Update - tip only works when there are actually children, and this component is used in a lot of places where there are no children + // tip={message ? message : null} > {props.children} diff --git a/client/src/components/parts-order-modal/parts-order-modal.component.jsx b/client/src/components/parts-order-modal/parts-order-modal.component.jsx index 7ce456280..29bb189cb 100644 --- a/client/src/components/parts-order-modal/parts-order-modal.component.jsx +++ b/client/src/components/parts-order-modal/parts-order-modal.component.jsx @@ -1,23 +1,11 @@ -import { DeleteFilled, WarningFilled, DownOutlined } from "@ant-design/icons"; -import { useTreatments } from "@splitsoftware/splitio-react"; -import { - Divider, - Form, - Input, - InputNumber, - Radio, - Space, - Tag, - Select, - Menu, - Dropdown, - Checkbox, -} from "antd"; +import {DeleteFilled, DownOutlined, WarningFilled} from "@ant-design/icons"; +import {useSplitTreatments} from "@splitsoftware/splitio-react"; +import {Checkbox, Divider, Dropdown, Form, Input, InputNumber, Menu, Radio, Select, Space, Tag,} 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 {useTranslation} from "react-i18next"; +import {connect} from "react-redux"; +import {createStructuredSelector} from "reselect"; +import {selectBodyshop} from "../../redux/user/user.selectors"; import FormDatePicker from "../form-date-picker/form-date-picker.component"; import CurrencyInput from "../form-items-formatted/currency-form-item.component"; import FormListMoveArrows from "../form-list-move-arrows/form-list-move-arrows.component"; @@ -26,329 +14,319 @@ import VendorSearchSelect from "../vendor-search-select/vendor-search-select.com import PartsOrderModalPriceChange from "./parts-order-modal-price-change.component"; const mapStateToProps = createStructuredSelector({ - bodyshop: selectBodyshop, + bodyshop: selectBodyshop, }); const mapDispatchToProps = (dispatch) => ({ - //setUserLanguage: language => dispatch(setUserLanguage(language)) + //setUserLanguage: language => dispatch(setUserLanguage(language)) }); export default connect( - mapStateToProps, - mapDispatchToProps + mapStateToProps, + mapDispatchToProps )(PartsOrderModalComponent); -export function PartsOrderModalComponent({ - bodyshop, - vendorList, - sendTypeState, - isReturn, - preferredMake, - job, - form, -}) { - const [sendType, setSendType] = sendTypeState; - const { OEConnection } = useTreatments( - ["OEConnection"], - {}, - bodyshop.imexshopid - ); - const { OEConnection_PriceChange } = useTreatments( - ["OEConnection_PriceChange"], - {}, - bodyshop.imexshopid - ); - const { t } = useTranslation(); - const handleClick = ({ item, key, keyPath }) => { - form.setFieldsValue({ comments: item.props.value }); - }; +export function PartsOrderModalComponent({bodyshop, vendorList, sendTypeState, isReturn, preferredMake, job, form,}) { + const [sendType, setSendType] = sendTypeState; - const menu = ( -
- - {bodyshop.md_parts_order_comment.map((comment, idx) => ( - - {comment.label} - - ))} - -
- ); + const {treatments: {OEConnection, OEConnection_PriceChange}} = useSplitTreatments({ + attributes: {}, + names: ["OEConnection", "OEConnection_PriceChange"], + splitKey: bodyshop.imexshopid, + }); - return ( -
- - - - - - - - - - - {job && job.special_coverage_policy && ( - - - - {t("jobs.labels.specialcoveragepolicy")} - - - )} - {!isReturn && ( - - - - )} - {OEConnection.treatment === "on" && !isReturn && ( - - - - )} - - - - {t("parts_orders.labels.parts_order")} - - - {t("parts_orders.labels.sublet_order")} - - - - - - {t("parts_orders.labels.inthisorder")} - - - {(fields, { add, remove, move }) => { - return ( -
- {fields.map((field, index) => ( - -
- - { + form.setFieldsValue({comments: item.props.value}); + }; + + const menu = ( +
+ + {bodyshop.md_parts_order_comment.map((comment, idx) => ( + + {comment.label} + + ))} + +
+ ); + + return ( +
+ + + + + - - - - - - - - - - - - { - // - // - // - } - - - - - - } - /> - - {isReturn && ( - - - - )} - - -
- { - remove(field.name); - }} - /> -
- -
-
+ }, + ]} + > +
- ))} -
- ); - }} - - - {t("parts_orders.fields.comments")} - - e.preventDefault()} - > - - - - - } - > - - + + + + {job && job.special_coverage_policy && ( + + + + {t("jobs.labels.specialcoveragepolicy")} + + + )} + {!isReturn && ( + + + + )} + {OEConnection.treatment === "on" && !isReturn && ( + + + + )} - - {() => { - const is_quote = form.getFieldValue("is_quote"); - if (is_quote) setSendType("oec"); - return ( - setSendType(e.target.value)} + + + + {t("parts_orders.labels.parts_order")} + + + {t("parts_orders.labels.sublet_order")} + + + + + + {t("parts_orders.labels.inthisorder")} + + + {(fields, {add, remove, move}) => { + return ( +
+ {fields.map((field, index) => ( + +
+ + + + + + + + + + + + + + { + // + // + // + } + + + + + + } + /> + + {isReturn && ( + + + + )} + + +
+ { + remove(field.name); + }} + /> +
+ +
+
+
+ ))} +
+ ); + }} +
+ + {t("parts_orders.fields.comments")} + + e.preventDefault()} + > + + + + + } > - - {t("general.labels.none")} - - - {t("parts_orders.labels.email")} - - - {t("parts_orders.labels.print")} - - {OEConnection.treatment === "on" && !isReturn && ( - {t("parts_orders.labels.oec")} - )} -
- ); - }} -
-
- ); + + + + + {() => { + const is_quote = form.getFieldValue("is_quote"); + if (is_quote) setSendType("oec"); + return ( + setSendType(e.target.value)} + > + + {t("general.labels.none")} + + + {t("parts_orders.labels.email")} + + + {t("parts_orders.labels.print")} + + {OEConnection.treatment === "on" && !isReturn && ( + {t("parts_orders.labels.oec")} + )} + + ); + }} + +
+ ); } diff --git a/client/src/components/parts-order-modal/parts-order-modal.container.jsx b/client/src/components/parts-order-modal/parts-order-modal.container.jsx index de37dc5da..3c381c0b1 100644 --- a/client/src/components/parts-order-modal/parts-order-modal.container.jsx +++ b/client/src/components/parts-order-modal/parts-order-modal.container.jsx @@ -1,395 +1,380 @@ -import { useMutation, useQuery, useApolloClient } from "@apollo/client"; -import { Form, Modal, notification } from "antd"; +import {useApolloClient, useMutation, useQuery} from "@apollo/client"; +import {Form, Modal, notification} from "antd"; import dayjs from "../../utils/day"; -import React, { useEffect, useState } from "react"; -import { useTranslation } from "react-i18next"; -import { connect } from "react-redux"; -import { createStructuredSelector } from "reselect"; -import { logImEXEvent, auth } from "../../firebase/firebase.utils"; -import { UPDATE_JOB_LINE_STATUS } from "../../graphql/jobs-lines.queries"; -import { - INSERT_NEW_PARTS_ORDERS, - QUERY_PARTS_ORDER_OEC, -} from "../../graphql/parts-orders.queries"; -import { QUERY_ALL_VENDORS_FOR_ORDER } from "../../graphql/vendors.queries"; -import { insertAuditTrail } from "../../redux/application/application.actions"; -import { setEmailOptions } from "../../redux/email/email.actions"; -import { - setModalContext, - toggleModalVisible, -} from "../../redux/modals/modals.actions"; -import { selectPartsOrder } from "../../redux/modals/modals.selectors"; -import { - selectBodyshop, - selectCurrentUser, -} from "../../redux/user/user.selectors"; +import React, {useEffect, useState} from "react"; +import {useTranslation} from "react-i18next"; +import {connect} from "react-redux"; +import {createStructuredSelector} from "reselect"; +import {auth, logImEXEvent} from "../../firebase/firebase.utils"; +import {UPDATE_JOB_LINE_STATUS} from "../../graphql/jobs-lines.queries"; +import {INSERT_NEW_PARTS_ORDERS, QUERY_PARTS_ORDER_OEC,} from "../../graphql/parts-orders.queries"; +import {QUERY_ALL_VENDORS_FOR_ORDER} from "../../graphql/vendors.queries"; +import {insertAuditTrail} from "../../redux/application/application.actions"; +import {setEmailOptions} from "../../redux/email/email.actions"; +import {setModalContext, toggleModalVisible,} from "../../redux/modals/modals.actions"; +import {selectPartsOrder} from "../../redux/modals/modals.selectors"; +import {selectBodyshop, selectCurrentUser,} from "../../redux/user/user.selectors"; import AuditTrailMapping from "../../utils/AuditTrailMappings"; -import { GenerateDocument } from "../../utils/RenderTemplate"; -import { TemplateList } from "../../utils/TemplateConstants"; +import {GenerateDocument} from "../../utils/RenderTemplate"; +import {TemplateList} from "../../utils/TemplateConstants"; import AlertComponent from "../alert/alert.component"; import LoadingSpinner from "../loading-spinner/loading-spinner.component"; import PartsOrderModalComponent from "./parts-order-modal.component"; import axios from "axios"; -import { useTreatments } from "@splitsoftware/splitio-react"; +import {useSplitTreatments} from "@splitsoftware/splitio-react"; import _ from "lodash"; -import { UPDATE_JOB } from "../../graphql/jobs.queries"; +import {UPDATE_JOB} from "../../graphql/jobs.queries"; const mapStateToProps = createStructuredSelector({ - currentUser: selectCurrentUser, - bodyshop: selectBodyshop, - partsOrderModal: selectPartsOrder, + currentUser: selectCurrentUser, + bodyshop: selectBodyshop, + partsOrderModal: selectPartsOrder, }); const mapDispatchToProps = (dispatch) => ({ - setEmailOptions: (e) => dispatch(setEmailOptions(e)), - toggleModalVisible: () => dispatch(toggleModalVisible("partsOrder")), - setBillEnterContext: (context) => - dispatch(setModalContext({ context: context, modal: "billEnter" })), - insertAuditTrail: ({ jobid, operation }) => - dispatch(insertAuditTrail({ jobid, operation })), + setEmailOptions: (e) => dispatch(setEmailOptions(e)), + toggleModalVisible: () => dispatch(toggleModalVisible("partsOrder")), + setBillEnterContext: (context) => + dispatch(setModalContext({context: context, modal: "billEnter"})), + insertAuditTrail: ({jobid, operation}) => + dispatch(insertAuditTrail({jobid, operation})), }); -export function PartsOrderModalContainer({ - partsOrderModal, - toggleModalVisible, - currentUser, - bodyshop, - setEmailOptions, - setBillEnterContext, - insertAuditTrail, -}) { - const { t } = useTranslation(); - const client = useApolloClient(); - const { OEConnection_PriceChange } = useTreatments( - ["OEConnection_PriceChange"], - {}, - bodyshop.imexshopid - ); - const { visible, context, actions } = partsOrderModal; - const { - jobId, - linesToOrder, - isReturn, - vendorId, - returnFromBill, - invoiceNumber, - job, - } = context; +export function PartsOrderModalContainer({partsOrderModal,toggleModalVisible,currentUser, bodyshop, setEmailOptions, setBillEnterContext, insertAuditTrail,}) { + const {t} = useTranslation(); + const client = useApolloClient(); - const { refetch } = actions; - const [form] = Form.useForm(); - const [saving, setSaving] = useState(false); - const sendTypeState = useState("e"); - const sendType = sendTypeState[0]; - - const { loading, error, data } = useQuery(QUERY_ALL_VENDORS_FOR_ORDER, { - skip: !visible, - variables: { jobId: jobId }, - fetchPolicy: "network-only", - nextFetchPolicy: "network-only", - }); - - const [insertPartOrder] = useMutation(INSERT_NEW_PARTS_ORDERS); - const [updateJobLines] = useMutation(UPDATE_JOB_LINE_STATUS); - const [updateJob] = useMutation(UPDATE_JOB); - - const handleFinish = async ({ - order_type, - removefrompartsqueue, - is_quote, - ...values - }) => { - logImEXEvent("parts_order_insert"); - setSaving(true); - let insertResult; - - insertResult = await insertPartOrder({ - variables: { - po: [ - { - ...values, - order_date: dayjs().format("YYYY-MM-DD"), - orderedby: currentUser.email, - jobid: jobId, - user_email: currentUser.email, - return: isReturn, - status: is_quote - ? bodyshop.md_order_statuses.default_quote || "Quote" - : bodyshop.md_order_statuses.default_ordered || "Ordered*", - }, - ], - }, - refetchQueries: ["QUERY_PARTS_BILLS_BY_JOBID"], - }); - if (!!insertResult.errors) { - notification["error"]({ - message: t("parts_orders.errors.creating"), - description: JSON.stringify(insertResult.errors), - }); - return; - } - notification["success"]({ - message: values.isReturn - ? t("parts_orders.successes.return_created") - : t("parts_orders.successes.created"), - }); - insertAuditTrail({ - jobid: jobId, - operation: isReturn - ? AuditTrailMapping.jobspartsreturn( - insertResult.data.insert_parts_orders.returning[0].order_number - ) - : AuditTrailMapping.jobspartsorder( - insertResult.data.insert_parts_orders.returning[0].order_number - ), + const {treatments: {OEConnection_PriceChange}} = useSplitTreatments({ + attributes: {}, + names: ["OEConnection_PriceChange"], + splitKey: bodyshop.imexshopid, }); - const jobLinesResult = await updateJobLines({ - variables: { - ids: values.parts_order_lines.data - .filter((item) => item.job_line_id) - .map((item) => item.job_line_id), - status: isReturn - ? bodyshop.md_order_statuses.default_returned || "Returned*" - : is_quote - ? bodyshop.md_order_statuses.default_quote || "Quote" - : bodyshop.md_order_statuses.default_ordered || "Ordered*", - }, + const {visible, context, actions} = partsOrderModal; + const { + jobId, + linesToOrder, + isReturn, + vendorId, + returnFromBill, + invoiceNumber, + job, + } = context; + + const {refetch} = actions; + const [form] = Form.useForm(); + const [saving, setSaving] = useState(false); + const sendTypeState = useState("e"); + const sendType = sendTypeState[0]; + + const {loading, error, data} = useQuery(QUERY_ALL_VENDORS_FOR_ORDER, { + skip: !visible, + variables: {jobId: jobId}, + fetchPolicy: "network-only", + nextFetchPolicy: "network-only", }); - if (!isReturn && removefrompartsqueue) { - await updateJob({ - variables: { - jobId: jobId, - job: { - queued_for_parts: false, - }, - }, - }); - } + const [insertPartOrder] = useMutation(INSERT_NEW_PARTS_ORDERS); + const [updateJobLines] = useMutation(UPDATE_JOB_LINE_STATUS); + const [updateJob] = useMutation(UPDATE_JOB); - if (!!jobLinesResult.errors) { - notification["error"]({ - message: t("parts_orders.errors.creating"), - description: JSON.stringify(jobLinesResult.errors), - }); - } + const handleFinish = async ({ + order_type, + removefrompartsqueue, + is_quote, + ...values + }) => { + logImEXEvent("parts_order_insert"); + setSaving(true); + let insertResult; - if (values.vendorid === bodyshop.inhousevendorid) { - setBillEnterContext({ - actions: { refetch: refetch }, - context: { - disableInvNumber: true, - job: { id: jobId }, - bill: { - vendorid: bodyshop.inhousevendorid, - invoice_number: "ih", - isinhouse: true, - date: new dayjs(), - total: 0, - billlines: values.parts_order_lines.data.map((p) => { - return { - joblineid: p.job_line_id, - actual_price: p.act_price, - actual_cost: 0, //p.act_price, - line_desc: p.line_desc, - line_remarks: p.line_remarks, - part_type: p.part_type, - quantity: p.quantity || 1, - applicable_taxes: { - local: false, - state: false, - federal: false, - }, - }; - }), - }, - }, - }); - toggleModalVisible(); - return; - } - - if (refetch) refetch(); - - const Templates = TemplateList("partsorder", context); - - if (sendType === "e") { - const matchingVendor = data.vendors.filter( - (item) => item.id === values.vendorid - )[0]; - - let vendorEmails = - matchingVendor && - matchingVendor.email && - matchingVendor.email.split(RegExp("[;,]")); - - GenerateDocument( - { - name: isReturn - ? Templates.parts_return_slip.key - : order_type === "parts_order" - ? Templates.parts_order.key - : Templates.sublet_order.key, - variables: { - id: insertResult.data.insert_parts_orders.returning[0].id, - }, - }, - { - to: matchingVendor ? vendorEmails : null, - replyTo: bodyshop.email, - subject: isReturn - ? Templates.parts_return_slip.subject - : order_type === "parts_order" - ? Templates.parts_order.subject - : Templates.sublet_order.subject, - }, - "e", - jobId - ); - } else if (sendType === "p") { - GenerateDocument( - { - name: isReturn - ? Templates.parts_return_slip.key - : order_type === "parts_order" - ? Templates.parts_order.key - : Templates.sublet_order.key, - variables: { - id: insertResult.data.insert_parts_orders.returning[0].id, - }, - }, - {}, - "p" - ); - } else if (sendType === "oec") { - //Send to Partner OEC. - try { - const partsOrder = await client.query({ - query: QUERY_PARTS_ORDER_OEC, - variables: { - id: insertResult.data.insert_parts_orders.returning[0].id, - }, - }); - let po; - //Massage the data based on the split. Should they be able to overwrite OEC pricing? - if (OEConnection_PriceChange.treatment === "on") { - //Set the flag to include the override. - po = _.cloneDeep(partsOrder.data.parts_orders_by_pk); - po.parts_order_lines.forEach((pol) => { - pol.priceChange = true; - }); - } - - const oecResponse = await axios.post( - "http://localhost:1337/oec/", - - po || partsOrder.data.parts_orders_by_pk, - { - headers: { - Authorization: `Bearer ${await auth.currentUser.getIdToken()}`, + insertResult = await insertPartOrder({ + variables: { + po: [ + { + ...values, + order_date: dayjs().format("YYYY-MM-DD"), + orderedby: currentUser.email, + jobid: jobId, + user_email: currentUser.email, + return: isReturn, + status: is_quote + ? bodyshop.md_order_statuses.default_quote || "Quote" + : bodyshop.md_order_statuses.default_ordered || "Ordered*", + }, + ], }, - } - ); - - if (oecResponse.data && oecResponse.data.success === false) { - notification.open({ - type: "error", - message: t("parts_orders.errors.oec", { - error: oecResponse.data.error, - }), - }); - } - } catch (error) { - console.log("Error OEC.", error); - notification["error"]({ - message: t("parts_orders.errors.oec", { - error: JSON.stringify(error.message), - }), + refetchQueries: ["QUERY_PARTS_BILLS_BY_JOBID"], }); - setSaving(false); - return; - } - } - setSaving(false); - toggleModalVisible(); - }; - - const initialValues = { - jobid: jobId, - return: isReturn, - deliver_by: isReturn ? dayjs(new Date()) : null, - vendorid: vendorId, - returnfrombill: returnFromBill, - - parts_order_lines: { - data: linesToOrder - ? linesToOrder.reduce((acc, value) => { - acc.push({ - line_desc: value.line_desc, - oem_partno: value.oem_partno, - db_price: value.db_price, - act_price: value.act_price, - cost: value.cost, - quantity: value.part_qty, - job_line_id: isReturn ? value.joblineid : value.id, - part_type: value.part_type, - ...(isReturn && { cm_received: false }), + if (!!insertResult.errors) { + notification["error"]({ + message: t("parts_orders.errors.creating"), + description: JSON.stringify(insertResult.errors), }); - return acc; - }, []) - : [], - }, - }; + return; + } + notification["success"]({ + message: values.isReturn + ? t("parts_orders.successes.return_created") + : t("parts_orders.successes.created"), + }); + insertAuditTrail({ + jobid: jobId, + operation: isReturn + ? AuditTrailMapping.jobspartsreturn( + insertResult.data.insert_parts_orders.returning[0].order_number + ) + : AuditTrailMapping.jobspartsorder( + insertResult.data.insert_parts_orders.returning[0].order_number + ), + }); - useEffect(() => { - if (visible && !!linesToOrder) { - form.resetFields(); - } - }, [visible, linesToOrder, form]); + const jobLinesResult = await updateJobLines({ + variables: { + ids: values.parts_order_lines.data + .filter((item) => item.job_line_id) + .map((item) => item.job_line_id), + status: isReturn + ? bodyshop.md_order_statuses.default_returned || "Returned*" + : is_quote + ? bodyshop.md_order_statuses.default_quote || "Quote" + : bodyshop.md_order_statuses.default_ordered || "Ordered*", + }, + }); - return ( - toggleModalVisible()} - onOk={() => form.submit()} - okButtonProps={{ loading: saving }} - cancelButtonProps={{ loading: saving }} - destroyOnClose - width="75%" - forceRender - > - {error ? : null} -
- {loading ? ( - - ) : ( - - )} - -
- ); + if (!isReturn && removefrompartsqueue) { + await updateJob({ + variables: { + jobId: jobId, + job: { + queued_for_parts: false, + }, + }, + }); + } + + if (!!jobLinesResult.errors) { + notification["error"]({ + message: t("parts_orders.errors.creating"), + description: JSON.stringify(jobLinesResult.errors), + }); + } + + if (values.vendorid === bodyshop.inhousevendorid) { + setBillEnterContext({ + actions: {refetch: refetch}, + context: { + disableInvNumber: true, + job: {id: jobId}, + bill: { + vendorid: bodyshop.inhousevendorid, + invoice_number: "ih", + isinhouse: true, + date: new dayjs(), + total: 0, + billlines: values.parts_order_lines.data.map((p) => { + return { + joblineid: p.job_line_id, + actual_price: p.act_price, + actual_cost: 0, //p.act_price, + line_desc: p.line_desc, + line_remarks: p.line_remarks, + part_type: p.part_type, + quantity: p.quantity || 1, + applicable_taxes: { + local: false, + state: false, + federal: false, + }, + }; + }), + }, + }, + }); + toggleModalVisible(); + return; + } + + if (refetch) refetch(); + + const Templates = TemplateList("partsorder", context); + + if (sendType === "e") { + const matchingVendor = data.vendors.filter( + (item) => item.id === values.vendorid + )[0]; + + let vendorEmails = + matchingVendor && + matchingVendor.email && + matchingVendor.email.split(RegExp("[;,]")); + + GenerateDocument( + { + name: isReturn + ? Templates.parts_return_slip.key + : order_type === "parts_order" + ? Templates.parts_order.key + : Templates.sublet_order.key, + variables: { + id: insertResult.data.insert_parts_orders.returning[0].id, + }, + }, + { + to: matchingVendor ? vendorEmails : null, + replyTo: bodyshop.email, + subject: isReturn + ? Templates.parts_return_slip.subject + : order_type === "parts_order" + ? Templates.parts_order.subject + : Templates.sublet_order.subject, + }, + "e", + jobId + ); + } else if (sendType === "p") { + GenerateDocument( + { + name: isReturn + ? Templates.parts_return_slip.key + : order_type === "parts_order" + ? Templates.parts_order.key + : Templates.sublet_order.key, + variables: { + id: insertResult.data.insert_parts_orders.returning[0].id, + }, + }, + {}, + "p" + ); + } else if (sendType === "oec") { + //Send to Partner OEC. + try { + const partsOrder = await client.query({ + query: QUERY_PARTS_ORDER_OEC, + variables: { + id: insertResult.data.insert_parts_orders.returning[0].id, + }, + }); + let po; + //Massage the data based on the split. Should they be able to overwrite OEC pricing? + if (OEConnection_PriceChange.treatment === "on") { + //Set the flag to include the override. + po = _.cloneDeep(partsOrder.data.parts_orders_by_pk); + po.parts_order_lines.forEach((pol) => { + pol.priceChange = true; + }); + } + + const oecResponse = await axios.post( + "http://localhost:1337/oec/", + + po || partsOrder.data.parts_orders_by_pk, + { + headers: { + Authorization: `Bearer ${await auth.currentUser.getIdToken()}`, + }, + } + ); + + if (oecResponse.data && oecResponse.data.success === false) { + notification.open({ + type: "error", + message: t("parts_orders.errors.oec", { + error: oecResponse.data.error, + }), + }); + } + } catch (error) { + console.log("Error OEC.", error); + notification["error"]({ + message: t("parts_orders.errors.oec", { + error: JSON.stringify(error.message), + }), + }); + setSaving(false); + return; + } + } + setSaving(false); + toggleModalVisible(); + }; + + const initialValues = { + jobid: jobId, + return: isReturn, + deliver_by: isReturn ? dayjs(new Date()) : null, + vendorid: vendorId, + returnfrombill: returnFromBill, + + parts_order_lines: { + data: linesToOrder + ? linesToOrder.reduce((acc, value) => { + acc.push({ + line_desc: value.line_desc, + oem_partno: value.oem_partno, + db_price: value.db_price, + act_price: value.act_price, + cost: value.cost, + quantity: value.part_qty, + job_line_id: isReturn ? value.joblineid : value.id, + part_type: value.part_type, + ...(isReturn && {cm_received: false}), + }); + return acc; + }, []) + : [], + }, + }; + + useEffect(() => { + if (visible && !!linesToOrder) { + form.resetFields(); + } + }, [visible, linesToOrder, form]); + + return ( + toggleModalVisible()} + onOk={() => form.submit()} + okButtonProps={{loading: saving}} + cancelButtonProps={{loading: saving}} + destroyOnClose + width="75%" + forceRender + > + {error ? : null} +
+ {loading ? ( + + ) : ( + + )} + +
+ ); } export default connect( - mapStateToProps, - mapDispatchToProps + mapStateToProps, + mapDispatchToProps )(PartsOrderModalContainer); diff --git a/client/src/components/payment-form/payment-form.component.jsx b/client/src/components/payment-form/payment-form.component.jsx index 1c3c5f42d..6cee80bb5 100644 --- a/client/src/components/payment-form/payment-form.component.jsx +++ b/client/src/components/payment-form/payment-form.component.jsx @@ -1,10 +1,10 @@ -import { useTreatments } from "@splitsoftware/splitio-react"; -import { Form, Input, Radio, Select } from "antd"; +import {useSplitTreatments} from "@splitsoftware/splitio-react"; +import {Form, Input, Radio, 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 {useTranslation} from "react-i18next"; +import {connect} from "react-redux"; +import {createStructuredSelector} from "reselect"; +import {selectBodyshop} from "../../redux/user/user.selectors"; import DatePickerFormItem from "../form-date-picker/form-date-picker.component"; import CurrencyInput from "../form-items-formatted/currency-form-item.component"; import JobSearchSelect from "../job-search-select/job-search-select.component"; @@ -12,150 +12,149 @@ import LayoutFormRow from "../layout-form-row/layout-form-row.component"; import PaymentFormTotalPayments from "./payment-form.totalpayments.component"; const mapStateToProps = createStructuredSelector({ - bodyshop: selectBodyshop, + bodyshop: selectBodyshop, }); -export function PaymentFormComponent({ - form, - bodyshop, - disabled, -}) { - const { Qb_Multi_Ar } = useTreatments( - ["Qb_Multi_Ar"], - {}, - bodyshop && bodyshop.imexshopid - ); +export function PaymentFormComponent({form, bodyshop, disabled,}) { - const { t } = useTranslation(); + const {treatments: {Qb_Multi_Ar}} = useSplitTreatments({ + attributes: {}, + names: ["Qb_Multi_Ar"], + splitKey: bodyshop && bodyshop.imexshopid, + }); - return ( -
- - - - - cur.jobid && prev.jobid !== cur.jobid} - > - {() => { - return ( - - ); - }} - - - - - - - - - - - - - - - - + const {t} = useTranslation(); - - - - + return ( +
+ + + + + cur.jobid && prev.jobid !== cur.jobid} + > + {() => { + return ( + + ); + }} + + - - - - - - - - {t("general.labels.none")} - {t("general.labels.email")} - {t("general.labels.print")} - - - -
- ); + + + + + + + + + + + + + + + + + + + + + + + + + + + + {t("general.labels.none")} + {t("general.labels.email")} + {t("general.labels.print")} + + + +
+ ); } + export default connect(mapStateToProps, null)(PaymentFormComponent); diff --git a/client/src/components/production-list-columns/prodution-list-columns.touchtime.component.jsx b/client/src/components/production-list-columns/prodution-list-columns.touchtime.component.jsx index c6ff374e7..903e07a87 100644 --- a/client/src/components/production-list-columns/prodution-list-columns.touchtime.component.jsx +++ b/client/src/components/production-list-columns/prodution-list-columns.touchtime.component.jsx @@ -23,7 +23,7 @@ export function ProductionlistColumnTouchTime({ bodyshop, job }) { const Difference_In_Days = dayjs().diff( dayjs(job.actual_in), - "days", + "day", true ); 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 6e1706d38..c107395b2 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 @@ -1,319 +1,306 @@ -import { SyncOutlined } from "@ant-design/icons"; -import { useTreatments } from "@splitsoftware/splitio-react"; -import { - Button, - Dropdown, - Input, - Menu, - Space, - Statistic, - Table, -} from "antd"; +import {SyncOutlined} from "@ant-design/icons"; +import {useSplitTreatments} from "@splitsoftware/splitio-react"; +import {Button, Dropdown, Input, Menu, Space, Statistic, Table,} from "antd"; import {PageHeader} from "@ant-design/pro-layout"; -import React, { useMemo, useState } from "react"; +import React, {useMemo, useState} from "react"; import ReactDragListView from "react-drag-listview"; -import { useTranslation } from "react-i18next"; -import { connect } from "react-redux"; -import { createStructuredSelector } from "reselect"; -import { selectTechnician } from "../../redux/tech/tech.selectors"; -import { - selectBodyshop, - selectCurrentUser, -} from "../../redux/user/user.selectors"; +import {useTranslation} from "react-i18next"; +import {connect} from "react-redux"; +import {createStructuredSelector} from "reselect"; +import {selectTechnician} from "../../redux/tech/tech.selectors"; +import {selectBodyshop, selectCurrentUser,} from "../../redux/user/user.selectors"; import ProductionListColumnsAdd from "../production-list-columns/production-list-columns.add.component"; import ProductionListColumns from "../production-list-columns/production-list-columns.data"; import ProductionListDetail from "../production-list-detail/production-list-detail.component"; -import ProductionListSaveConfigButton from "../production-list-save-config-button/production-list-save-config-button.component"; +import ProductionListSaveConfigButton + from "../production-list-save-config-button/production-list-save-config-button.component"; import ProductionListPrint from "./production-list-print.component"; import ProductionListTableViewSelect from "./production-list-table-view-select.component"; import ResizeableTitle from "./production-list-table.resizeable.component"; const mapStateToProps = createStructuredSelector({ - bodyshop: selectBodyshop, - technician: selectTechnician, - currentUser: selectCurrentUser, + bodyshop: selectBodyshop, + technician: selectTechnician, + currentUser: selectCurrentUser, }); -export function ProductionListTable({ - loading, - data, - refetch, - bodyshop, - technician, - currentUser, -}) { - const [searchText, setSearchText] = useState(""); - const { Production_List_Status_Colors } = useTreatments( - ["Production_List_Status_Colors"], - {}, - bodyshop.imexshopid - ); - const assoc = bodyshop.associations.find( - (a) => a.useremail === currentUser.email - ); +export function ProductionListTable({loading, data, refetch, bodyshop, technician, currentUser}) { - const defaultView = assoc && assoc.default_prod_list_view; + const [searchText, setSearchText] = useState(""); - const [state, setState] = useState( - (bodyshop.production_config && - bodyshop.production_config.find((p) => p.name === defaultView)?.columns - .tableState) || - bodyshop.production_config[0]?.columns.tableState || { - sortedInfo: {}, - filteredInfo: { text: "" }, - } - ); - - const { t } = useTranslation(); - - const matchingColumnConfig = useMemo(() => { - return bodyshop.production_config.find((p) => p.name === defaultView); - }, [bodyshop.production_config, defaultView]); - - const [columns, setColumns] = useState( - (state && - matchingColumnConfig && - matchingColumnConfig.columns.columnKeys.map((k) => { - return { - ...ProductionListColumns({ - bodyshop, - technician, - state, - activeStatuses: bodyshop.md_ro_statuses.active_statuses, - }).find((e) => e.key === k.key), - width: k.width ?? 100, - }; - })) || - [] - ); - - const handleTableChange = (pagination, filters, sorter) => { - setState({ - ...state, - filteredInfo: filters, - sortedInfo: { columnKey: sorter.columnKey, order: sorter.order }, + const { treatments: {Production_List_Status_Colors} } = useSplitTreatments({ + attributes: {}, + names: ["Production_List_Status_Colors"], + splitKey: bodyshop.imexshopid, }); - }; - const onDragEnd = (fromIndex, toIndex) => { - const columnsCopy = columns.slice(); - const item = columnsCopy.splice(fromIndex, 1)[0]; - columnsCopy.splice(toIndex, 0, item); - setColumns(columnsCopy); - }; - const removeColumn = (e) => { - const { key } = e; - setColumns(columns.filter((i) => i.key !== key)); - }; + const assoc = bodyshop.associations.find( + (a) => a.useremail === currentUser.email + ); - const handleResize = - (index) => - (e, { size }) => { - const nextColumns = [...columns]; - nextColumns[index] = { - ...nextColumns[index], - width: size.width, - }; - setColumns(nextColumns); + const defaultView = assoc && assoc.default_prod_list_view; + + const [state, setState] = useState( + (bodyshop.production_config && + bodyshop.production_config.find((p) => p.name === defaultView)?.columns + .tableState) || + bodyshop.production_config[0]?.columns.tableState || { + sortedInfo: {}, + filteredInfo: {text: ""}, + } + ); + + const {t} = useTranslation(); + + const matchingColumnConfig = useMemo(() => { + return bodyshop.production_config.find((p) => p.name === defaultView); + }, [bodyshop.production_config, defaultView]); + + const [columns, setColumns] = useState( + (state && + matchingColumnConfig && + matchingColumnConfig.columns.columnKeys.map((k) => { + return { + ...ProductionListColumns({ + bodyshop, + technician, + state, + activeStatuses: bodyshop.md_ro_statuses.active_statuses, + }).find((e) => e.key === k.key), + width: k.width ?? 100, + }; + })) || + [] + ); + + const handleTableChange = (pagination, filters, sorter) => { + setState({ + ...state, + filteredInfo: filters, + sortedInfo: {columnKey: sorter.columnKey, order: sorter.order}, + }); }; - const headerItem = (col) => ( - - - {t("production.actions.removecolumn")} - - - } - trigger={["contextMenu"]} - > - {col.title} - - ); + const onDragEnd = (fromIndex, toIndex) => { + const columnsCopy = columns.slice(); + const item = columnsCopy.splice(fromIndex, 1)[0]; + columnsCopy.splice(toIndex, 0, item); + setColumns(columnsCopy); + }; - const dataSource = - searchText === "" - ? data - : data.filter( - (j) => - (j.ro_number || "") - .toString() - .toLowerCase() - .includes(searchText.toLowerCase()) || - (j.ownr_co_nm || "") - .toLowerCase() - .includes(searchText.toLowerCase()) || - (j.ownr_fn || "") - .toLowerCase() - .includes(searchText.toLowerCase()) || - (j.ownr_ln || "") - .toLowerCase() - .includes(searchText.toLowerCase()) || - (j.status || "").toLowerCase().includes(searchText.toLowerCase()) || - (j.ins_co_nm || "") - .toLowerCase() - .includes(searchText.toLowerCase()) || - (j.clm_no || "").toLowerCase().includes(searchText.toLowerCase()) || - (j.v_model_desc || "") - .toLowerCase() - .includes(searchText.toLowerCase()) || - (j.v_make_desc || "") - .toLowerCase() - .includes(searchText.toLowerCase()) - ); + const removeColumn = (e) => { + const {key} = e; + setColumns(columns.filter((i) => i.key !== key)); + }; - // const handleSelectRecord = (record) => { - // if (selected !== record.id) { - // setSelected(record.id); - // } else { - // setSelected(null); - // } - // }; - - if (!!!columns) return
No columns found.
; - - const totalHrs = data - .reduce( - (acc, val) => - acc + - (val.labhrs?.aggregate?.sum?.mod_lb_hrs || 0) + - (val.larhrs?.aggregate?.sum?.mod_lb_hrs || 0), - 0 - ) - .toFixed(1); - const totalLAB = data - .reduce( - (acc, val) => acc + (val.labhrs?.aggregate?.sum?.mod_lb_hrs || 0), - 0 - ) - .toFixed(1); - const totalLAR = data - .reduce( - (acc, val) => acc + (val.larhrs?.aggregate?.sum?.mod_lb_hrs || 0), - 0 - ) - .toFixed(1); - return ( -
- - - - - - - } - extra={ - - - - - - - - setSearchText(e.target.value)} - placeholder={t("general.labels.search")} - value={searchText} - /> - - - } - /> - - - { - if (!bodyshop.md_ro_statuses.production_colors) return null; - - const color = bodyshop.md_ro_statuses.production_colors.find( - (x) => x.status === record.status - ); - - if (!color) { - if (index % 2 === 0) - return { - style: { - backgroundColor: `rgb(236, 236, 236)`, - }, - }; - - return null; - } - - return { - className: "rowWithColor", - style: { - "--bgColor": `rgb(${color.color.r},${color.color.g},${color.color.b},${color.color.a})`, - }, - }; - }, - })} - components={{ - header: { - cell: ResizeableTitle, - }, - }} - columns={columns.map((c, index) => { - return { - ...c, - filteredValue: state.filteredInfo[c.key] || null, - sortOrder: - state.sortedInfo.columnKey === c.key && state.sortedInfo.order, - title: headerItem(c), - ellipsis: true, - width: c.width ?? 100, - onHeaderCell: (column) => ({ - width: column.width, - onResize: handleResize(index), - }), + const handleResize = + (index) => + (e, {size}) => { + const nextColumns = [...columns]; + nextColumns[index] = { + ...nextColumns[index], + width: size.width, + }; + setColumns(nextColumns); }; - })} - rowKey="id" - loading={loading} - dataSource={dataSource} - scroll={{ x: 1000 }} - onChange={handleTableChange} - /> - - - ); + + const headerItem = (col) => ( + + + {t("production.actions.removecolumn")} + + + } + trigger={["contextMenu"]} + > + {col.title} + + ); + + const dataSource = + searchText === "" + ? data + : data.filter( + (j) => + (j.ro_number || "") + .toString() + .toLowerCase() + .includes(searchText.toLowerCase()) || + (j.ownr_co_nm || "") + .toLowerCase() + .includes(searchText.toLowerCase()) || + (j.ownr_fn || "") + .toLowerCase() + .includes(searchText.toLowerCase()) || + (j.ownr_ln || "") + .toLowerCase() + .includes(searchText.toLowerCase()) || + (j.status || "").toLowerCase().includes(searchText.toLowerCase()) || + (j.ins_co_nm || "") + .toLowerCase() + .includes(searchText.toLowerCase()) || + (j.clm_no || "").toLowerCase().includes(searchText.toLowerCase()) || + (j.v_model_desc || "") + .toLowerCase() + .includes(searchText.toLowerCase()) || + (j.v_make_desc || "") + .toLowerCase() + .includes(searchText.toLowerCase()) + ); + + // const handleSelectRecord = (record) => { + // if (selected !== record.id) { + // setSelected(record.id); + // } else { + // setSelected(null); + // } + // }; + + if (!!!columns) return
No columns found.
; + + const totalHrs = data + .reduce( + (acc, val) => + acc + + (val.labhrs?.aggregate?.sum?.mod_lb_hrs || 0) + + (val.larhrs?.aggregate?.sum?.mod_lb_hrs || 0), + 0 + ) + .toFixed(1); + const totalLAB = data + .reduce( + (acc, val) => acc + (val.labhrs?.aggregate?.sum?.mod_lb_hrs || 0), + 0 + ) + .toFixed(1); + const totalLAR = data + .reduce( + (acc, val) => acc + (val.larhrs?.aggregate?.sum?.mod_lb_hrs || 0), + 0 + ) + .toFixed(1); + return ( +
+ + + + + + + } + extra={ + + + + + + + + setSearchText(e.target.value)} + placeholder={t("general.labels.search")} + value={searchText} + /> + + + } + /> + + +
{ + if (!bodyshop.md_ro_statuses.production_colors) return null; + + const color = bodyshop.md_ro_statuses.production_colors.find( + (x) => x.status === record.status + ); + + if (!color) { + if (index % 2 === 0) + return { + style: { + backgroundColor: `rgb(236, 236, 236)`, + }, + }; + + return null; + } + + return { + className: "rowWithColor", + style: { + "--bgColor": `rgb(${color.color.r},${color.color.g},${color.color.b},${color.color.a})`, + }, + }; + }, + })} + components={{ + header: { + cell: ResizeableTitle, + }, + }} + columns={columns.map((c, index) => { + return { + ...c, + filteredValue: state.filteredInfo[c.key] || null, + sortOrder: + state.sortedInfo.columnKey === c.key && state.sortedInfo.order, + title: headerItem(c), + ellipsis: true, + width: c.width ?? 100, + onHeaderCell: (column) => ({ + width: column.width, + onResize: handleResize(index), + }), + }; + })} + rowKey="id" + loading={loading} + dataSource={dataSource} + scroll={{x: 1000}} + onChange={handleTableChange} + /> + + + ); } export default connect(mapStateToProps, null)(ProductionListTable); diff --git a/client/src/components/report-center-modal/report-center-modal.component.jsx b/client/src/components/report-center-modal/report-center-modal.component.jsx index d32be9e72..c4280ce1b 100644 --- a/client/src/components/report-center-modal/report-center-modal.component.jsx +++ b/client/src/components/report-center-modal/report-center-modal.component.jsx @@ -251,7 +251,7 @@ export function ReportCenterModalComponent({ reportCenterModal }) { > diff --git a/client/src/components/schedule-job-modal/schedule-job-modal.component.jsx b/client/src/components/schedule-job-modal/schedule-job-modal.component.jsx index 573c19ba2..23ea91095 100644 --- a/client/src/components/schedule-job-modal/schedule-job-modal.component.jsx +++ b/client/src/components/schedule-job-modal/schedule-job-modal.component.jsx @@ -70,7 +70,7 @@ export function ScheduleJobModalComponent({ form.setFieldsValue({ scheduled_completion: dayjs(values.start).businessAdd( totalHours / bodyshop.target_touchtime, - "days" + "day" ), }); } @@ -138,7 +138,7 @@ export function ScheduleJobModalComponent({ if (ssDate.isBefore(dayjs())) { form.setFieldsValue({ start: dayjs() }); } else { - form.setFieldsValue({ start: dayjs(d).add(8, "hours") }); + form.setFieldsValue({ start: dayjs(d).add(8, "hour") }); } handleDateBlur(); }} diff --git a/client/src/components/scoreboard-targets-table/scoreboard-targets-table.util.js b/client/src/components/scoreboard-targets-table/scoreboard-targets-table.util.js index 461775631..804d808e2 100644 --- a/client/src/components/scoreboard-targets-table/scoreboard-targets-table.util.js +++ b/client/src/components/scoreboard-targets-table/scoreboard-targets-table.util.js @@ -61,9 +61,9 @@ export const ListOfDaysInCurrentMonth = () => { const days = []; const dateStart = dayjs().startOf("month"); const dateEnd = dayjs().endOf("month"); - while (dateEnd.diff(dateStart, "days") > 0) { + while (dateEnd.diff(dateStart, "day") > 0) { days.push(dateStart.format("YYYY-MM-DD")); - dateStart.add(1, "days"); + dateStart.add(1, "day"); } days.push(dateEnd.format("YYYY-MM-DD")); return days; @@ -73,9 +73,9 @@ export const ListDaysBetween = ({ start, end }) => { const days = []; const dateStart = dayjs(start); const dateEnd = dayjs(end); - while (dateEnd.diff(dateStart, "days") > 0) { + while (dateEnd.diff(dateStart, "day") > 0) { days.push(dateStart.format("YYYY-MM-DD")); - dateStart.add(1, "days"); + dateStart.add(1, "day"); } days.push(dateEnd.format("YYYY-MM-DD")); return days; diff --git a/client/src/components/shop-employees/shop-employees-form.component.jsx b/client/src/components/shop-employees/shop-employees-form.component.jsx index 2778d00ba..63ad28f97 100644 --- a/client/src/components/shop-employees/shop-employees-form.component.jsx +++ b/client/src/components/shop-employees/shop-employees-form.component.jsx @@ -132,7 +132,7 @@ export function ShopEmployeesFormComponent({ bodyshop }) { dataIndex: "length", key: "length", render: (text, record) => - dayjs(record.end).diff(dayjs(record.start), "days", true).toFixed(1), + dayjs(record.end).diff(dayjs(record.start), "day", true).toFixed(1), }, { title: t("general.labels.actions"), diff --git a/client/src/components/shop-info/shop-info.component.jsx b/client/src/components/shop-info/shop-info.component.jsx index 7ef7c30fe..997db981f 100644 --- a/client/src/components/shop-info/shop-info.component.jsx +++ b/client/src/components/shop-info/shop-info.component.jsx @@ -1,10 +1,10 @@ -import { useTreatments } from "@splitsoftware/splitio-react"; -import { Button, Card, Tabs } from "antd"; +import {useSplitTreatments} from "@splitsoftware/splitio-react"; +import {Button, Card, Tabs} 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 {useTranslation} from "react-i18next"; +import {connect} from "react-redux"; +import {createStructuredSelector} from "reselect"; +import {selectBodyshop} from "../../redux/user/user.selectors"; import ShopInfoGeneral from "./shop-info.general.component"; import ShopInfoIntakeChecklistComponent from "./shop-info.intake.component"; import ShopInfoLaborRates from "./shop-info.laborrates.component"; @@ -15,88 +15,90 @@ 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 { useNavigate, useLocation } from "react-router-dom"; +import {useLocation, useNavigate} from "react-router-dom"; import queryString from "query-string"; const mapStateToProps = createStructuredSelector({ - bodyshop: selectBodyshop, + bodyshop: selectBodyshop, }); const mapDispatchToProps = (dispatch) => ({ - //setUserLanguage: language => dispatch(setUserLanguage(language)) + //setUserLanguage: language => dispatch(setUserLanguage(language)) }); export default connect(mapStateToProps, mapDispatchToProps)(ShopInfoComponent); -export function ShopInfoComponent({ bodyshop, form, saveLoading }) { - const { CriticalPartsScanning } = useTreatments( - ["CriticalPartsScanning"], - {}, - bodyshop.imexshopid - ); - const { t } = useTranslation(); - const history = useNavigate(); - const location = useLocation(); - const search = queryString.parse(location.search); +export function ShopInfoComponent({bodyshop, form, saveLoading}) { - return ( - form.submit()} - > - {t("general.actions.save")} - - } - > - - history({ - search: `?tab=${search.tab}&subtab=${key}`, - }) - } - > - - - - - - - - - - - - - - - - - - - - - + const { treatments: {CriticalPartsScanning} } = useSplitTreatments({ + attributes: {}, + names: ["CriticalPartsScanning"], + splitKey: bodyshop.imexshopid, + }); - - - - - - - {CriticalPartsScanning.treatment === "on" && ( - - - - )} - - - ); + const {t} = useTranslation(); + const history = useNavigate(); + const location = useLocation(); + const search = queryString.parse(location.search); + + return ( + form.submit()} + > + {t("general.actions.save")} + + } + > + + history({ + search: `?tab=${search.tab}&subtab=${key}`, + }) + } + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {CriticalPartsScanning.treatment === "on" && ( + + + + )} + + + ); } 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 546d21796..839728fa3 100644 --- a/client/src/components/shop-info/shop-info.general.component.jsx +++ b/client/src/components/shop-info/shop-info.general.component.jsx @@ -1,5 +1,5 @@ import { DeleteFilled } from "@ant-design/icons"; -import { useTreatments } from "@splitsoftware/splitio-react"; +import { useSplitTreatments } from "@splitsoftware/splitio-react"; import { Button, DatePicker, @@ -35,13 +35,14 @@ const mapDispatchToProps = (dispatch) => ({ export default connect(mapStateToProps, mapDispatchToProps)(ShopInfoGeneral); export function ShopInfoGeneral({ form, bodyshop }) { - const { t } = useTranslation(); - const { ClosingPeriod } = useTreatments( - ["ClosingPeriod"], - {}, - bodyshop && bodyshop.imexshopid - ); + const { t } = useTranslation(); + + const { treatments: {ClosingPeriod} } = useSplitTreatments({ + attributes: {}, + names: ["ClosingPeriod"], + splitKey: bodyshop && bodyshop.imexshopid, + }); return (
@@ -413,13 +414,12 @@ export function ShopInfoGeneral({ form, bodyshop }) { {ClosingPeriod.treatment === "on" && ( <> diff --git a/client/src/components/shop-info/shop-info.orderstatus.component.jsx b/client/src/components/shop-info/shop-info.orderstatus.component.jsx index 0e6fff22b..1f9f070da 100644 --- a/client/src/components/shop-info/shop-info.orderstatus.component.jsx +++ b/client/src/components/shop-info/shop-info.orderstatus.component.jsx @@ -1,94 +1,97 @@ -import { Form, Input } from "antd"; +import {Form, Input} from "antd"; import React from "react"; -import { useTranslation } from "react-i18next"; +import {useTranslation} from "react-i18next"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; -import { connect } from "react-redux"; -import { createStructuredSelector } from "reselect"; -import { selectBodyshop } from "../../redux/user/user.selectors"; -import { useTreatments } from "@splitsoftware/splitio-react"; +import {connect} from "react-redux"; +import {createStructuredSelector} from "reselect"; +import {selectBodyshop} from "../../redux/user/user.selectors"; +import {useSplitTreatments} from "@splitsoftware/splitio-react"; + const mapStateToProps = createStructuredSelector({ - bodyshop: selectBodyshop, + bodyshop: selectBodyshop, }); const mapDispatchToProps = (dispatch) => ({ - //setUserLanguage: language => dispatch(setUserLanguage(language)) + //setUserLanguage: language => dispatch(setUserLanguage(language)) }); export default connect( - mapStateToProps, - mapDispatchToProps + mapStateToProps, + mapDispatchToProps )(ShopInfoOrderStatusComponent); -export function ShopInfoOrderStatusComponent({ bodyshop, form }) { - const { t } = useTranslation(); - const { OEConnection } = useTreatments( - ["OEConnection"], - {}, - bodyshop.imexshopid - ); - return ( - - - - - - - +export function ShopInfoOrderStatusComponent({bodyshop, form}) { + const {t} = useTranslation(); - - - - - - - {OEConnection.treatment === "on" && ( - - - - )} - - ); + const {treatments: {OEConnection}} = useSplitTreatments({ + attributes: {}, + names: ["OEConnection"], + splitKey: bodyshop.imexshopid, + }); + + return ( + + + + + + + + + + + + + + + {OEConnection.treatment === "on" && ( + + + + )} + + ); } diff --git a/client/src/components/shop-info/shop-info.rbac.component.jsx b/client/src/components/shop-info/shop-info.rbac.component.jsx index fe4f80f31..1c46e6dde 100644 --- a/client/src/components/shop-info/shop-info.rbac.component.jsx +++ b/client/src/components/shop-info/shop-info.rbac.component.jsx @@ -1,698 +1,702 @@ -import { useTreatments } from "@splitsoftware/splitio-react"; -import { Form, InputNumber } from "antd"; +import {Form, InputNumber} 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 {useTranslation} from "react-i18next"; +import {connect} from "react-redux"; +import {createStructuredSelector} from "reselect"; +import {selectBodyshop} from "../../redux/user/user.selectors"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component"; +import {useSplitTreatments} from "@splitsoftware/splitio-react"; + const mapStateToProps = createStructuredSelector({ - bodyshop: selectBodyshop, + bodyshop: selectBodyshop, }); const mapDispatchToProps = (dispatch) => ({ - //setUserLanguage: language => dispatch(setUserLanguage(language)) + //setUserLanguage: language => dispatch(setUserLanguage(language)) }); export default connect( - mapStateToProps, - mapDispatchToProps + mapStateToProps, + mapDispatchToProps )(ShopInfoRbacComponent); -export function ShopInfoRbacComponent({ form, bodyshop }) { - const { t } = useTranslation(); - const { Simple_Inventory } = useTreatments( - ["Simple_Inventory"], - {}, - bodyshop && bodyshop.imexshopid - ); - return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {Simple_Inventory.treatment === "on" && ( - <> - - - - - - - - )} - - - ); +export function ShopInfoRbacComponent({form, bodyshop}) { + const {t} = useTranslation(); + + + const { treatments: {Simple_Inventory} } = useSplitTreatments({ + attributes: {}, + names: ["Simple_Inventory"], + splitKey:bodyshop && bodyshop.imexshopid, + }); + + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {Simple_Inventory.treatment === "on" && ( + <> + + + + + + + + )} + + + ); } diff --git a/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx b/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx index 75e85e88d..007d71faa 100644 --- a/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx +++ b/client/src/components/shop-info/shop-info.responsibilitycenters.component.jsx @@ -1,385 +1,374 @@ -import { DeleteFilled } from "@ant-design/icons"; -import { - Button, - Form, - Input, - InputNumber, - Select, - Switch, - Typography, -} from "antd"; -import React, { useState } from "react"; -import { useTranslation } from "react-i18next"; +import {DeleteFilled} from "@ant-design/icons"; +import {Button, Form, Input, InputNumber, Select, Switch, Typography,} from "antd"; +import React, {useState} from "react"; +import {useTranslation} from "react-i18next"; import styled from "styled-components"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; import DataLabel from "../data-label/data-label.component"; -import { selectBodyshop } from "../../redux/user/user.selectors"; -import { connect } from "react-redux"; -import { createStructuredSelector } from "reselect"; -import { useTreatments } from "@splitsoftware/splitio-react"; +import {selectBodyshop} from "../../redux/user/user.selectors"; +import {connect} from "react-redux"; +import {createStructuredSelector} from "reselect"; +import {useSplitTreatments} from "@splitsoftware/splitio-react"; const SelectorDiv = styled.div` - .ant-form-item .ant-select { - width: 125px; - } + .ant-form-item .ant-select { + width: 125px; + } `; const mapStateToProps = createStructuredSelector({ - //currentUser: selectCurrentUser - bodyshop: selectBodyshop, + //currentUser: selectCurrentUser + bodyshop: selectBodyshop, }); const mapDispatchToProps = (dispatch) => ({ - //setUserLanguage: language => dispatch(setUserLanguage(language)) + //setUserLanguage: language => dispatch(setUserLanguage(language)) }); export default connect( - mapStateToProps, - mapDispatchToProps + mapStateToProps, + mapDispatchToProps )(ShopInfoResponsibilityCenterComponent); -export function ShopInfoResponsibilityCenterComponent({ bodyshop, form }) { - const { t } = useTranslation(); - const { Qb_Multi_Ar } = useTreatments( - ["Qb_Multi_Ar"], - {}, - bodyshop && bodyshop.imexshopid - ); - const { DmsAp } = useTreatments( - ["DmsAp"], - {}, - bodyshop && bodyshop.imexshopid - ); - const [costOptions, setCostOptions] = useState( - [ - ...((form.getFieldValue(["md_responsibility_centers", "costs"]) && - form - .getFieldValue(["md_responsibility_centers", "costs"]) - .map((i) => i && i.name)) || - []), - ] || [] - ); +export function ShopInfoResponsibilityCenterComponent({bodyshop, form}) { + const {t} = useTranslation(); - const [profitOptions, setProfitOptions] = useState( - [ - ...((form.getFieldValue(["md_responsibility_centers", "profits"]) && - form - .getFieldValue(["md_responsibility_centers", "profits"]) - .map((i) => i && i.name)) || - []), - ] || [] - ); + const { treatments: {Qb_Multi_Ar,DmsAp} } = useSplitTreatments({ + attributes: {}, + names: ["Qb_Multi_Ar","DmsAp"], + splitKey: bodyshop && bodyshop.imexshopid, + }); - const handleBlur = () => { - setCostOptions([ - ...(form - .getFieldValue(["md_responsibility_centers", "costs"]) - .map((i) => i && i.name) || []), - ]); - setProfitOptions([ - ...(form - .getFieldValue(["md_responsibility_centers", "profits"]) - .map((i) => i && i.name) || []), - ]); - }; + const [costOptions, setCostOptions] = useState( + [ + ...((form.getFieldValue(["md_responsibility_centers", "costs"]) && + form + .getFieldValue(["md_responsibility_centers", "costs"]) + .map((i) => i && i.name)) || + []), + ] || [] + ); - return ( -
- {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( - <> - {bodyshop.cdk_dealerid && ( - - {form.getFieldValue("cdk_dealerid")} - - )} - {bodyshop.pbs_serialnumber && ( - - {form.getFieldValue("pbs_serialnumber")} - - )} - - - - - - - - - - - - - - - - - {bodyshop.pbs_serialnumber && ( - - - - )} - {bodyshop.pbs_serialnumber && ( - - - - )} - {bodyshop.pbs_serialnumber && ( - - - - )} - - - - {(fields, { add, remove }) => { - return ( -
- {fields.map((field, index) => ( - - - i && i.name)) || + []), + ] || [] + ); + + const handleBlur = () => { + setCostOptions([ + ...(form + .getFieldValue(["md_responsibility_centers", "costs"]) + .map((i) => i && i.name) || []), + ]); + setProfitOptions([ + ...(form + .getFieldValue(["md_responsibility_centers", "profits"]) + .map((i) => i && i.name) || []), + ]); + }; + + return ( +
+ {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( + <> + {bodyshop.cdk_dealerid && ( + + {form.getFieldValue("cdk_dealerid")} + + )} + {bodyshop.pbs_serialnumber && ( + + {form.getFieldValue("pbs_serialnumber")} + + )} + + - - - + + + - - - - - - - { - remove(field.name); - }} - /> - - - ))} - - - -
- ); - }} - -
- - - {(fields, { add, remove }) => { - return ( -
- {fields.map((field, index) => ( - - - + + + + + + - - - - - - - { - remove(field.name); - }} - /> - - - ))} - - - -
- ); - }} -
-
- - )} - - {bodyshop.pbs_serialnumber && ( - <> - - {form.getFieldValue("pbs_serialnumber")} - - - )} - - - {(fields, { add, remove }) => { - return ( -
- {fields.map((field, index) => ( - - - - - - + + + + + + {bodyshop.pbs_serialnumber && ( + + + )} - key={`${index}accountname`} - name={[field.name, "accountname"]} - rules={[ - { - required: true, - //message: t("general.validation.required"), - }, - ]} - > - - - {/* + + + )} + {bodyshop.pbs_serialnumber && ( + + + + )} + + + + {(fields, {add, remove}) => { + return ( +
+ {fields.map((field, index) => ( + + + + + + + + + + + + + { + remove(field.name); + }} + /> + + + ))} + + + +
+ ); + }} +
+
+ + + {(fields, {add, remove}) => { + return ( +
+ {fields.map((field, index) => ( + + + + + + + + + + { + remove(field.name); + }} + /> + + + ))} + + + +
+ ); + }} +
+
+ + )} + + {bodyshop.pbs_serialnumber && ( + <> + + {form.getFieldValue("pbs_serialnumber")} + + + )} + + + {(fields, {add, remove}) => { + return ( +
+ {fields.map((field, index) => ( + + + + + + + + + {/* */} - - - - {/* + + + {/* */} - {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( - - - - )} - {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( - - - - )} - {bodyshop.cdk_dealerid && ( - - - - )} + {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( + + + + )} + {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( + + + + )} + {bodyshop.cdk_dealerid && ( + + + + )} - { - remove(field.name); - }} - /> - - - ))} - - + +
+ ); }} - style={{ width: "100%" }} - > - {t("general.actions.add")} - - -
- ); - }} -
-
+ + - - - {(fields, { add, remove }) => { - return ( -
- {fields.map((field, index) => ( - - - - - - {/* + + {(fields, {add, remove}) => { + return ( +
+ {fields.map((field, index) => ( + + + + + + {/* */} - - - - - - - {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( - - - - )} - {bodyshop.cdk_dealerid && ( - - - - )} - { - remove(field.name); - }} - /> - - - ))} - - + +
+ ); }} - style={{ width: "100%" }} - > - {t("general.actions.add")} - -
-
- ); - }} -
-
+ + - - {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( - <> - - {(fields, { add, remove }) => { - return ( -
- {fields.map((field, index) => ( - -
- - - - - - - - { - remove(field.name); - }} - /> - - - ({ - validator(rule, value) { + + {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( + <> + + {(fields, {add, remove}) => { + return ( +
+ {fields.map((field, index) => ( + +
+ + + + + + + + { + remove(field.name); + }} + /> + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-ats`} + name={[field.name, "costs", "ATS"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-LAA`} + name={[field.name, "costs", "LAA"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-LAB`} + name={[field.name, "costs", "LAB"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-LAD`} + name={[field.name, "costs", "LAD"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-LAE`} + name={[field.name, "costs", "LAE"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-LAF`} + name={[field.name, "costs", "LAF"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-LAG`} + name={[field.name, "costs", "LAG"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-LAM`} + name={[field.name, "costs", "LAM"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-LAR`} + name={[field.name, "costs", "LAR"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-LAS`} + name={[field.name, "costs", "LAS"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-LAU`} + name={[field.name, "costs", "LAU"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-LA1`} + name={[field.name, "costs", "LA1"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-LA2`} + name={[field.name, "costs", "LA2"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-LA3`} + name={[field.name, "costs", "LA3"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-LA4`} + name={[field.name, "costs", "LA4"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-PAA`} + name={[field.name, "costs", "PAA"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-PAC`} + name={[field.name, "costs", "PAC"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-PAG`} + name={[field.name, "costs", "PAG"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-PAL`} + name={[field.name, "costs", "PAL"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-PAM`} + name={[field.name, "costs", "PAM"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-PAN`} + name={[field.name, "costs", "PAN"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-PAO`} + name={[field.name, "costs", "PAO"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-PAP`} + name={[field.name, "costs", "PAP"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-PAR`} + name={[field.name, "costs", "PAR"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-PAS`} + name={[field.name, "costs", "PAS"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-PASL`} + name={[field.name, "costs", "PASL"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-TOW`} + name={[field.name, "costs", "TOW"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-MAPA`} + name={[field.name, "costs", "MAPA"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}costs-MASH`} + name={[field.name, "costs", "MASH"]} + > + + + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-ATS`} + name={[field.name, "profits", "ATS"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-LAA`} + name={[field.name, "profits", "LAA"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-LAB`} + name={[field.name, "profits", "LAB"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-LAD`} + name={[field.name, "profits", "LAD"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-LAE`} + name={[field.name, "profits", "LAE"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-LAF`} + name={[field.name, "profits", "LAF"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-LAG`} + name={[field.name, "profits", "LAG"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-LAM`} + name={[field.name, "profits", "LAM"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-LAR`} + name={[field.name, "profits", "LAR"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-LAS`} + name={[field.name, "profits", "LAS"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-LAU`} + name={[field.name, "profits", "LAU"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-LA1`} + name={[field.name, "profits", "LA1"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-LA2`} + name={[field.name, "profits", "LA2"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-LA3`} + name={[field.name, "profits", "LA3"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-LA4`} + name={[field.name, "profits", "LA4"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-PAA`} + name={[field.name, "profits", "PAA"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-PAC`} + name={[field.name, "profits", "PAC"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-PAG`} + name={[field.name, "profits", "PAG"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-PAL`} + name={[field.name, "profits", "PAL"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-PAM`} + name={[field.name, "profits", "PAM"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-PAN`} + name={[field.name, "profits", "PAN"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-PAO`} + name={[field.name, "profits", "PAO"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-PAP`} + name={[field.name, "profits", "PAP"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-PAR`} + name={[field.name, "profits", "PAR"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-PAS`} + name={[field.name, "profits", "PAS"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-PASL`} + name={[field.name, "profits", "PASL"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-TOW`} + name={[field.name, "profits", "TOW"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-MAPA`} + name={[field.name, "profits", "MAPA"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + key={`${index}profits-MASH`} + name={[field.name, "profits", "MASH"]} + > + + + +
+
+ ))} + + + +
+ ); + }} +
+ + )} + + + ({ + validator(rule, value) { if (costOptions.includes(value)) { - return Promise.resolve(); + return Promise.resolve(); } return Promise.reject( - t("bodyshop.validation.centermustexist") + t("bodyshop.validation.centermustexist") ); - }, - }), - ]} - key={`${index}costs-ats`} - name={[field.name, "costs", "ATS"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-LAA`} - name={[field.name, "costs", "LAA"]} - > - + {costOptions.map((item, idx) => ( + {item} - - ))} - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-LAB`} - name={[field.name, "costs", "LAB"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-LAD`} - name={[field.name, "costs", "LAD"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-LAE`} - name={[field.name, "costs", "LAE"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-LAF`} - name={[field.name, "costs", "LAF"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-LAG`} - name={[field.name, "costs", "LAG"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-LAM`} - name={[field.name, "costs", "LAM"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-LAR`} - name={[field.name, "costs", "LAR"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-LAS`} - name={[field.name, "costs", "LAS"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-LAU`} - name={[field.name, "costs", "LAU"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-LA1`} - name={[field.name, "costs", "LA1"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-LA2`} - name={[field.name, "costs", "LA2"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-LA3`} - name={[field.name, "costs", "LA3"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-LA4`} - name={[field.name, "costs", "LA4"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-PAA`} - name={[field.name, "costs", "PAA"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-PAC`} - name={[field.name, "costs", "PAC"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-PAG`} - name={[field.name, "costs", "PAG"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-PAL`} - name={[field.name, "costs", "PAL"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-PAM`} - name={[field.name, "costs", "PAM"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-PAN`} - name={[field.name, "costs", "PAN"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-PAO`} - name={[field.name, "costs", "PAO"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-PAP`} - name={[field.name, "costs", "PAP"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-PAR`} - name={[field.name, "costs", "PAR"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-PAS`} - name={[field.name, "costs", "PAS"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-PASL`} - name={[field.name, "costs", "PASL"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-TOW`} - name={[field.name, "costs", "TOW"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-MAPA`} - name={[field.name, "costs", "MAPA"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}costs-MASH`} - name={[field.name, "costs", "MASH"]} - > - - - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-ATS`} - name={[field.name, "profits", "ATS"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-LAA`} - name={[field.name, "profits", "LAA"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-LAB`} - name={[field.name, "profits", "LAB"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-LAD`} - name={[field.name, "profits", "LAD"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-LAE`} - name={[field.name, "profits", "LAE"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-LAF`} - name={[field.name, "profits", "LAF"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-LAG`} - name={[field.name, "profits", "LAG"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-LAM`} - name={[field.name, "profits", "LAM"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-LAR`} - name={[field.name, "profits", "LAR"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-LAS`} - name={[field.name, "profits", "LAS"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-LAU`} - name={[field.name, "profits", "LAU"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-LA1`} - name={[field.name, "profits", "LA1"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-LA2`} - name={[field.name, "profits", "LA2"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-LA3`} - name={[field.name, "profits", "LA3"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-LA4`} - name={[field.name, "profits", "LA4"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-PAA`} - name={[field.name, "profits", "PAA"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-PAC`} - name={[field.name, "profits", "PAC"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-PAG`} - name={[field.name, "profits", "PAG"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-PAL`} - name={[field.name, "profits", "PAL"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-PAM`} - name={[field.name, "profits", "PAM"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-PAN`} - name={[field.name, "profits", "PAN"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-PAO`} - name={[field.name, "profits", "PAO"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-PAP`} - name={[field.name, "profits", "PAP"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-PAR`} - name={[field.name, "profits", "PAR"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-PAS`} - name={[field.name, "profits", "PAS"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-PASL`} - name={[field.name, "profits", "PASL"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-TOW`} - name={[field.name, "profits", "TOW"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-MAPA`} - name={[field.name, "profits", "MAPA"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - key={`${index}profits-MASH`} - name={[field.name, "profits", "MASH"]} - > - - - -
-
- ))} - - + + ))} + -
- ); - }} -
- - )} + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "LAA"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "LAB"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "LAD"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "LAE"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "LAF"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "LAG"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "LAM"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "LAR"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "LAS"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "LAU"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "LA1"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "LA2"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "LA3"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "LA4"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "PAA"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "PAC"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "PAG"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "PAL"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "PAM"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "PAN"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "PAO"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "PAP"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "PAR"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "PAS"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "PASL"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "TOW"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "MAPA"]} + > + + + ({ + validator(rule, value) { + if (costOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "costs", "MASH"]} + > + + + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "ATS"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "LAA"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "LAB"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "LAD"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "LAE"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "LAF"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "LAG"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "LAM"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "LAR"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "LAS"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "LAU"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "LA1"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "LA2"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "LA3"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "LA4"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "PAA"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "PAC"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "PAG"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "PAL"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "PAM"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "PAN"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "PAO"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "PAP"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "PAR"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "PAS"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "PASL"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "TOW"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "MAPA"]} + > + + + ({ + validator(rule, value) { + if (profitOptions.includes(value)) { + return Promise.resolve(); + } + return Promise.reject( + t("bodyshop.validation.centermustexist") + ); + }, + }), + ]} + name={["md_responsibility_centers", "defaults", "profits", "MASH"]} + > + + + +
- - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "ATS"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "LAA"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "LAB"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "LAD"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "LAE"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "LAF"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "LAG"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "LAM"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "LAR"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "LAS"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "LAU"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "LA1"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "LA2"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "LA3"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "LA4"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "PAA"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "PAC"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "PAG"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "PAL"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "PAM"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "PAN"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "PAO"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "PAP"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "PAR"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "PAS"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "PASL"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "TOW"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "MAPA"]} - > - - - ({ - validator(rule, value) { - if (costOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "costs", "MASH"]} - > - - - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "ATS"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "LAA"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "LAB"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "LAD"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "LAE"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "LAF"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "LAG"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "LAM"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "LAR"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "LAS"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "LAU"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "LA1"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "LA2"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "LA3"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "LA4"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "PAA"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "PAC"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "PAG"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "PAL"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "PAM"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "PAN"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "PAO"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "PAP"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "PAR"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "PAS"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "PASL"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "TOW"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "MAPA"]} - > - - - ({ - validator(rule, value) { - if (profitOptions.includes(value)) { - return Promise.resolve(); - } - return Promise.reject( - t("bodyshop.validation.centermustexist") - ); - }, - }), - ]} - name={["md_responsibility_centers", "defaults", "profits", "MASH"]} - > - - - - - - - - - - {/* - - */} - {/* - - */} - - - - - - - {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( - - - - )} - - - - - {DmsAp.treatment === "on" && ( - - - - - {/* - - */} - {/* - - */} - - - - - - - {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( - - - - )} - - - - - )} - - + + + {/* - - {/* */} + {/* + + */} + + + + + + + {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( + + + + )} + + + + + {DmsAp.treatment === "on" && ( + + + + + {/* + + */} + {/* + + */} + + + + + + + {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( + + + + )} + + + + + )} + + + + + {/* */} - - - - - - - {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( - - - - )} - - - - - - - - - {/* + + + + + + {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( + + + + )} + + + + + + + + + {/* */} - - - - - - - {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( - - - - )} - - - - - AR
} id="AR"> - {/* + + + + + + {(bodyshop.cdk_dealerid || bodyshop.pbs_serialnumber) && ( + + + + )} + + + +
+ AR
} id="AR"> + {/* */} - - - - {/* + + + {/* */} - + - {DmsAp.treatment === "on" && ( - - {/* + {/* */} - {/* */} - - - - - - - - - - - )} - Refund
} id="refund"> - {/* + + + + + + + + + + )} + Refund} id="refund"> + {/* */} - {/* */} - {/* */} - - - - - {Qb_Multi_Ar.treatment === "on" && ( - Multiple Payers Item} - id="accountitem" - > - - - - - )} - - {t("bodyshop.labels.responsibilitycenters.sales_tax_codes")} - - - {(fields, { add, remove }) => { - return ( -
- {fields.map((field, index) => ( - - - - - - - - - - - - - - - - - - { - remove(field.name); - }} - /> - - - ))} - - - -
- ); - }} -
- - ); + +
+ + {Qb_Multi_Ar.treatment === "on" && ( + Multiple Payers Item} + id="accountitem" + > + + + + + )} + + {t("bodyshop.labels.responsibilitycenters.sales_tax_codes")} + + + {(fields, {add, remove}) => { + return ( +
+ {fields.map((field, index) => ( + + + + + + + + + + + + + + + + + + { + remove(field.name); + }} + /> + + + ))} + + + +
+ ); + }} +
+ + ); } diff --git a/client/src/components/shop-info/shop-info.rostatus.component.jsx b/client/src/components/shop-info/shop-info.rostatus.component.jsx index 7fab39746..2b5225863 100644 --- a/client/src/components/shop-info/shop-info.rostatus.component.jsx +++ b/client/src/components/shop-info/shop-info.rostatus.component.jsx @@ -1,411 +1,415 @@ -import { DeleteFilled } from "@ant-design/icons"; -import { useTreatments } from "@splitsoftware/splitio-react"; -import { Button, Form, Select, Space } from "antd"; -import React, { useState } from "react"; -import { ChromePicker } from "react-color"; -import { useTranslation } from "react-i18next"; +import {DeleteFilled} from "@ant-design/icons"; +import {Button, Form, Select, Space} from "antd"; +import React, {useState} from "react"; +import {ChromePicker} from "react-color"; +import {useTranslation} from "react-i18next"; import styled from "styled-components"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; -import { connect } from "react-redux"; -import { createStructuredSelector } from "reselect"; -import { selectBodyshop } from "../../redux/user/user.selectors"; +import {connect} from "react-redux"; +import {createStructuredSelector} from "reselect"; +import {selectBodyshop} from "../../redux/user/user.selectors"; +import {useSplitTreatments} from "@splitsoftware/splitio-react"; + const mapStateToProps = createStructuredSelector({ - bodyshop: selectBodyshop, + bodyshop: selectBodyshop, }); const mapDispatchToProps = (dispatch) => ({ - //setUserLanguage: language => dispatch(setUserLanguage(language)) + //setUserLanguage: language => dispatch(setUserLanguage(language)) }); export default connect( - mapStateToProps, - mapDispatchToProps + mapStateToProps, + mapDispatchToProps )(ShopInfoROStatusComponent); const SelectorDiv = styled.div` - .ant-form-item .ant-select { - width: 200px; - } + .ant-form-item .ant-select { + width: 200px; + } `; -export function ShopInfoROStatusComponent({ bodyshop, form }) { - const { t } = useTranslation(); - const { Production_List_Status_Colors } = useTreatments( - ["Production_List_Status_Colors"], - {}, - bodyshop.imexshopid - ); - const [options, setOptions] = useState( - form.getFieldValue(["md_ro_statuses", "statuses"]) || [] - ); +export function ShopInfoROStatusComponent({bodyshop, form}) { - const handleBlur = () => { - setOptions(form.getFieldValue(["md_ro_statuses", "statuses"])); - }; + const {t} = useTranslation(); - return ( - - - - {options.map((item, idx) => ( - - {item} - - ))} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {Production_List_Status_Colors.treatment === "on" && ( - - - {(fields, { add, remove, move }) => { - return ( -
- - {fields.map((field, index) => ( - - -
- - - - { - remove(field.name); - }} - /> -
- - - -
-
+ const { treatments: {Production_List_Status_Colors} } = useSplitTreatments({ + attributes: {}, + names: ["Production_List_Status_Colors"], + splitKey: bodyshop.imexshopid, + }); + + const [options, setOptions] = useState( + form.getFieldValue(["md_ro_statuses", "statuses"]) || [] + ); + + const handleBlur = () => { + setOptions(form.getFieldValue(["md_ro_statuses", "statuses"])); + }; + + return ( + + + + {options.map((item, idx) => ( + + {item} + ))} -
- - - -
- ); - }} -
-
- )} -
- ); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {Production_List_Status_Colors.treatment === "on" && ( + + + {(fields, {add, remove, move}) => { + return ( +
+ + {fields.map((field, index) => ( + + +
+ + + + { + remove(field.name); + }} + /> +
+ + + +
+
+ ))} +
+ + + +
+ ); + }} +
+
+ )} + + ); } -export const ColorPicker = ({ value, onChange, style, ...restProps }) => { - const handleChange = (color) => { - if (onChange) onChange(color.rgb); - }; - return ( - - ); +export const ColorPicker = ({value, onChange, style, ...restProps}) => { + const handleChange = (color) => { + if (onChange) onChange(color.rgb); + }; + return ( + + ); }; diff --git a/client/src/components/tech-job-print-tickets/tech-job-print-tickets.component.jsx b/client/src/components/tech-job-print-tickets/tech-job-print-tickets.component.jsx index 4cc1b9eed..422421ec6 100644 --- a/client/src/components/tech-job-print-tickets/tech-job-print-tickets.component.jsx +++ b/client/src/components/tech-job-print-tickets/tech-job-print-tickets.component.jsx @@ -95,7 +95,7 @@ export function TechJobPrintTickets({ technician, event, attendacePrint }) { ]} > diff --git a/client/src/components/ticket-tickets-dates-selector/time-tickets-dates-selector.component.jsx b/client/src/components/ticket-tickets-dates-selector/time-tickets-dates-selector.component.jsx index c51e1a9f9..c0c83ac52 100644 --- a/client/src/components/ticket-tickets-dates-selector/time-tickets-dates-selector.component.jsx +++ b/client/src/components/ticket-tickets-dates-selector/time-tickets-dates-selector.component.jsx @@ -41,7 +41,7 @@ export default function TimeTicketsDatesSelector() { end ? dayjs(end) : dayjs().endOf("week"), ]} format="MM/DD/YYYY" - ranges={DatePickerRanges} + presets={DatePickerRanges} onCalendarChange={handleChange} /> ); 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 fb05268b3..6f1d1487c 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 @@ -187,7 +187,7 @@ export function TimeTicketList({ return (
{dayjs(record.clockoff) - .diff(dayjs(record.clockon), "hours", true) + .diff(dayjs(record.clockon), "hour", true) .toFixed(2)}
); diff --git a/client/src/components/time-tickets-summary-employees/time-tickets-summary-employees.component.jsx b/client/src/components/time-tickets-summary-employees/time-tickets-summary-employees.component.jsx index a6745aee7..d02676d6d 100644 --- a/client/src/components/time-tickets-summary-employees/time-tickets-summary-employees.component.jsx +++ b/client/src/components/time-tickets-summary-employees/time-tickets-summary-employees.component.jsx @@ -124,7 +124,7 @@ const JobRelatedTicketsTable = ({ if (!!val.clockoff && !!val.clockon) return ( acc + - dayjs(val.clockoff).diff(dayjs(val.clockon), "hours", true) + dayjs(val.clockoff).diff(dayjs(val.clockon), "hour", true) ); return acc; }, 0); @@ -251,7 +251,7 @@ const ShiftRelatedTicketsTable = ({ const clockHrs = item.tickets.reduce((acc, val) => { if (!!val.clockoff && !!val.clockon) return ( - acc + dayjs(val.clockoff).diff(dayjs(val.clockon), "hours", true) + acc + dayjs(val.clockoff).diff(dayjs(val.clockon), "hour", true) ); return acc; }, 0); diff --git a/client/src/components/vendors-form/vendors-form.component.jsx b/client/src/components/vendors-form/vendors-form.component.jsx index 487928a28..7639ad475 100644 --- a/client/src/components/vendors-form/vendors-form.component.jsx +++ b/client/src/components/vendors-form/vendors-form.component.jsx @@ -1,262 +1,249 @@ -import { DeleteFilled } from "@ant-design/icons"; -import { useApolloClient } from "@apollo/client"; -import { useTreatments } from "@splitsoftware/splitio-react"; -import { - Button, - Divider, - Form, - Input, - InputNumber, - Space, - Switch, -} from "antd"; +import {DeleteFilled} from "@ant-design/icons"; +import {useApolloClient} from "@apollo/client"; +import {useSplitTreatments} from "@splitsoftware/splitio-react"; +import {Button, Divider, Form, Input, InputNumber, Space, Switch,} from "antd"; import {PageHeader} from "@ant-design/pro-layout"; import React from "react"; -import { useTranslation } from "react-i18next"; -import { CHECK_VENDOR_NAME } from "../../graphql/vendors.queries"; +import {useTranslation} from "react-i18next"; +import {CHECK_VENDOR_NAME} from "../../graphql/vendors.queries"; import FormFieldsChanged from "../form-fields-changed-alert/form-fields-changed-alert.component"; import FormItemEmail from "../form-items-formatted/email-form-item.component"; -import PhoneFormItem, { - PhoneItemFormatterValidation, -} from "../form-items-formatted/phone-form-item.component"; +import PhoneFormItem, {PhoneItemFormatterValidation,} from "../form-items-formatted/phone-form-item.component"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; import VendorsPhonebookAdd from "../vendors-phonebook-add/vendors-phonebook-add.component"; -import { connect } from "react-redux"; -import { createStructuredSelector } from "reselect"; -import { selectBodyshop } from "../../redux/user/user.selectors"; +import {connect} from "react-redux"; +import {createStructuredSelector} from "reselect"; +import {selectBodyshop} from "../../redux/user/user.selectors"; + const mapStateToProps = createStructuredSelector({ - bodyshop: selectBodyshop, + bodyshop: selectBodyshop, }); const mapDispatchToProps = (dispatch) => ({ - //setUserLanguage: language => dispatch(setUserLanguage(language)) + //setUserLanguage: language => dispatch(setUserLanguage(language)) }); export default connect( - mapStateToProps, - mapDispatchToProps + mapStateToProps, + mapDispatchToProps )(VendorsFormComponent); -export function VendorsFormComponent({ - bodyshop, - form, - formLoading, - handleDelete, - responsibilityCenters, - selectedvendor, -}) { - const { t } = useTranslation(); - const client = useApolloClient(); - const { DmsAp } = useTreatments( - ["DmsAp"], - {}, - bodyshop && bodyshop.imexshopid - ); +export function VendorsFormComponent({bodyshop, form, formLoading, handleDelete, responsibilityCenters, selectedvendor}) { + const {t} = useTranslation(); + const client = useApolloClient(); - const { getFieldValue } = form; - return ( -
- {() => form.getFieldValue("name")} - } - extra={ - - - - - - - - - } - /> - - - ({ - async validator(rule, value) { - if (value) { - const response = await client.query({ - query: CHECK_VENDOR_NAME, - variables: { - name: value, - }, - }); + const {treatments: {DmsAp}} = useSplitTreatments({ + attributes: {}, + names: ["DmsAp"], + splitKey: bodyshop && bodyshop.imexshopid + }); - if (response.data.vendors_aggregate.aggregate.count === 0) { - return Promise.resolve(); - } else if ( - response.data.vendors_aggregate.nodes.length === 1 && - response.data.vendors_aggregate.nodes[0].id === - form.getFieldValue("id") - ) { - return Promise.resolve(); - } - return Promise.reject( - t("vendors.validation.unique_vendor_name") - ); - } else { - return Promise.resolve(); + + const {getFieldValue} = form; + return ( +
+ {() => form.getFieldValue("name")} } - }, - }), - ]} - > - - + extra={ + + + + + + - - - - - PhoneItemFormatterValidation(getFieldValue, "phone"), - ]} - > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { - // - // - // - } - - - {DmsAp.treatment === "on" && ( - - - - )} - {t("vendors.labels.preferredmakes")} - - {(fields, { add, remove }) => { - return ( -
- {fields.map((field, index) => ( - - - + + } + /> + + + - - + ({getFieldValue}) => ({ + async validator(rule, value) { + if (value) { + const response = await client.query({ + query: CHECK_VENDOR_NAME, + variables: { + name: value, + }, + }); - { - remove(field.name); - }} - /> - - - ))} - - - -
- ); - }} -
-
- ); + +
+ + + + + + PhoneItemFormatterValidation(getFieldValue, "phone"), + ]} + > + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { + // + // + // + } + + + {DmsAp.treatment === "on" && ( + + + + )} + {t("vendors.labels.preferredmakes")} + + {(fields, {add, remove}) => { + return ( +
+ {fields.map((field, index) => ( + + + + + + + { + remove(field.name); + }} + /> + + + ))} + + + +
+ ); + }} +
+
+ ); } diff --git a/client/src/pages/jobs-close/jobs-close.component.jsx b/client/src/pages/jobs-close/jobs-close.component.jsx index 6ef38b23c..7a5c2ceba 100644 --- a/client/src/pages/jobs-close/jobs-close.component.jsx +++ b/client/src/pages/jobs-close/jobs-close.component.jsx @@ -23,7 +23,7 @@ import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { connect } from "react-redux"; // import { useNavigate } from 'react-router-dom'; -import { useTreatments } from "@splitsoftware/splitio-react"; +import { useSplitTreatments } from "@splitsoftware/splitio-react"; import Dinero from "dinero.js"; import dayjs from "../../utils/day"; import { Link } from "react-router-dom"; @@ -51,16 +51,12 @@ export function JobsCloseComponent({ job, bodyshop, jobRO }) { // const history = useHistory(); const [closeJob] = useMutation(UPDATE_JOB); const [loading, setLoading] = useState(false); - const { Qb_Multi_Ar } = useTreatments( - ["Qb_Multi_Ar"], - {}, - bodyshop && bodyshop.imexshopid - ); - const { ClosingPeriod } = useTreatments( - ["ClosingPeriod"], - {}, - bodyshop && bodyshop.imexshopid - ); + + const { treatments: {Qb_Multi_Ar,ClosingPeriod} } = useSplitTreatments({ + attributes: {}, + names: ["Qb_Multi_Ar", "ClosingPeriod"], + splitKey: bodyshop && bodyshop.imexshopid, + }); const handleFinish = async ({ removefromproduction, ...values }) => { setLoading(true); diff --git a/client/src/pages/manage/manage.page.component.jsx b/client/src/pages/manage/manage.page.component.jsx index 4fc840fbb..012bb29bf 100644 --- a/client/src/pages/manage/manage.page.component.jsx +++ b/client/src/pages/manage/manage.page.component.jsx @@ -1,4 +1,4 @@ -import {BackTop, Layout} from "antd"; +import {FloatButton, Layout} from "antd"; import preval from "preval.macro"; import React, {lazy, Suspense, useEffect} from "react"; import {useTranslation} from "react-i18next"; @@ -371,7 +371,7 @@ export function Manage({conflict, bodyshop}) { {PageContent} - +
- + diff --git a/client/src/utils/DatePickerRanges.js b/client/src/utils/DatePickerRanges.js index 43cf6980e..dfb467866 100644 --- a/client/src/utils/DatePickerRanges.js +++ b/client/src/utils/DatePickerRanges.js @@ -1,27 +1,62 @@ import dayjs from "./day"; -const range = { - Today: [dayjs(), dayjs()], - "Last 14 days": [dayjs().subtract(14, "day"), dayjs()], - "Last 7 days": [dayjs().subtract(7, "day"), dayjs()], - "Next 7 days": [dayjs(), dayjs().add(7, "day")], - "Next 14 days": [dayjs(), dayjs().add(14, "day")], - "Last Month": [ - dayjs().startOf("month").subtract(1, "month"), - dayjs().startOf("month").subtract(1, "month").endOf("month"), - ], - "This Month": [dayjs().startOf("month"), dayjs().endOf("month")], - "Next Month": [ - dayjs().startOf("month").add(1, "month"), - dayjs().startOf("month").add(1, "month").endOf("month"), - ], - "Last Quarter": [ - dayjs().startOf("quarter").subtract(1, "quarter"), - dayjs().startOf("quarter").subtract(1, "day"), - ], - "This Quarter": [ - dayjs().startOf("quarter"), - dayjs().startOf("quarter").add(1, "quarter").subtract(1, "day"), - ], - "Last 90 Days": [dayjs().add(-90, "day"), dayjs()], -}; + +const range = [ + { + label: 'Today', + value: [dayjs(), dayjs()] + }, + { + label: 'Last 14 days', + value: [dayjs().subtract(14, "day"), dayjs()] + }, + { + label: 'Last 7 days', + value: [dayjs().subtract(7, "day"), dayjs()] + }, + { + label: 'Next 7 days', + value: [dayjs(), dayjs().add(7, "day")] + }, + { + label: 'Next 14 days', + value: [dayjs(), dayjs().add(14, "day")], + }, + { + label: 'Last Month', + value: [ + dayjs().startOf("month").subtract(1, "month"), + dayjs().startOf("month").subtract(1, "month").endOf("month"), + ] + }, + { + label: 'This Month', + value: [dayjs().startOf("month"), dayjs().endOf("month")] + }, + { + label: 'Next Month', + value: [ + dayjs().startOf("month").add(1, "month"), + dayjs().startOf("month").add(1, "month").endOf("month"), + ] + }, + { + label: 'Last Quarter', + value: [ + dayjs().startOf("quarter").subtract(1, "quarter"), + dayjs().startOf("quarter").subtract(1, "day"), + ] + }, + { + label: 'This Quarter', + value: [ + dayjs().startOf("quarter"), + dayjs().startOf("quarter").add(1, "quarter").subtract(1, "day"), + ] + }, + { + label: 'Last 90 Days', + value: [dayjs().add(-90, "day"), dayjs()], + } +] + export default range; diff --git a/server/tasks/tasks.js b/server/tasks/tasks.js index 74f543bea..9ba237635 100644 --- a/server/tasks/tasks.js +++ b/server/tasks/tasks.js @@ -54,27 +54,27 @@ function functionMapper(f, timezone) { case "date.yesterday": return moment().tz(timezone).subtract(1, "day").format(isoFormat); case "date.3daysago": - return moment().tz(timezone).subtract(3, "days").format(isoFormat); + return moment().tz(timezone).subtract(3, "day").format(isoFormat); case "date.7daysago": - return moment().tz(timezone).subtract(7, "days").format(isoFormat); + return moment().tz(timezone).subtract(7, "day").format(isoFormat); case "date.tomorrow": return moment().tz(timezone).add(1, "day").format(isoFormat); case "date.3daysfromnow": - return moment().tz(timezone).add(3, "days").format(isoFormat); + return moment().tz(timezone).add(3, "day").format(isoFormat); case "date.7daysfromnow": - return moment().tz(timezone).add(7, "days").format(isoFormat); + return moment().tz(timezone).add(7, "day").format(isoFormat); case "date.yesterdaytz": return moment().tz(timezone).subtract(1, "day"); case "date.3daysagotz": - return moment().tz(timezone).subtract(3, "days"); + return moment().tz(timezone).subtract(3, "day"); case "date.7daysagotz": - return moment().tz(timezone).subtract(7, "days"); + return moment().tz(timezone).subtract(7, "day"); case "date.tomorrowtz": return moment().tz(timezone).add(1, "day"); case "date.3daysfromnowtz": - return moment().tz(timezone).add(3, "days"); + return moment().tz(timezone).add(3, "day"); case "date.7daysfromnowtz": - return moment().tz(timezone).add(7, "days"); + return moment().tz(timezone).add(7, "day"); case "date.now": return moment().tz(timezone);