Reformat all project files to use the prettier config file.

This commit is contained in:
Patrick Fic
2024-03-27 15:35:07 -07:00
parent b161530381
commit e1df64d592
873 changed files with 111387 additions and 125473 deletions

View File

@@ -1,303 +1,199 @@
import {Form, Input, InputNumber, Modal, Select, Switch} from "antd";
import React, {useEffect} from "react";
import {useTranslation} from "react-i18next";
import { Form, Input, InputNumber, Modal, Select, Switch } from "antd";
import React, { useEffect } from "react";
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 {useSplitTreatments} from "@splitsoftware/splitio-react";
import { useSplitTreatments } from "@splitsoftware/splitio-react";
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
)(JobLinesUpsertModalComponent);
export default connect(mapStateToProps, mapDispatchToProps)(JobLinesUpsertModalComponent);
export function JobLinesUpsertModalComponent({
bodyshop,
open,
jobLine,
handleCancel,
handleFinish,
loading,
}) {
const {t} = useTranslation();
const [form] = Form.useForm();
export function JobLinesUpsertModalComponent({ bodyshop, open, jobLine, handleCancel, handleFinish, loading }) {
const { t } = useTranslation();
const [form] = Form.useForm();
useEffect(() => {
form.resetFields();
}, [open, form]);
useEffect(() => {
form.resetFields();
}, [open, form]);
const {
treatments: { Allow_Negative_Jobline_Price, Autohouse_Detail_line }
} = useSplitTreatments({
attributes: {},
names: ["Allow_Negative_Jobline_Price", "Autohouse_Detail_line"],
splitKey: 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 (
<Modal
title={
jobLine && jobLine.id
? t("joblines.labels.edit")
: t("joblines.labels.new")
}
forceRender
open={open}
width="60%"
okText={t("general.actions.save")}
onOk={() => form.submit()}
okButtonProps={{loading: loading}}
onCancel={handleCancel}
e
>
<Form
onFinish={handleFinish}
initialValues={jobLine}
layout="vertical"
autoComplete="off"
form={form}
return (
<Modal
title={jobLine && jobLine.id ? t("joblines.labels.edit") : t("joblines.labels.new")}
forceRender
open={open}
width="60%"
okText={t("general.actions.save")}
onOk={() => form.submit()}
okButtonProps={{ loading: loading }}
onCancel={handleCancel}
e
>
<Form onFinish={handleFinish} initialValues={jobLine} layout="vertical" autoComplete="off" form={form}>
<LayoutFormRow grow>
<Form.Item label={t("joblines.fields.line_no")} name="line_no">
<InputNumber />
</Form.Item>
<Form.Item
label={t("joblines.fields.line_desc")}
rules={[
{
required: true
//message: t("general.validation.required"),
}
]}
name="line_desc"
>
<Input />
</Form.Item>
<JoblinesPreset form={form} />
</LayoutFormRow>
<LayoutFormRow grow>
<Form.Item label={t("joblines.fields.mod_lbr_ty")} name="mod_lbr_ty">
<Select allowClear>
<Select.Option value="LAA">{t("joblines.fields.lbr_types.LAA")}</Select.Option>
<Select.Option value="LAB">{t("joblines.fields.lbr_types.LAB")}</Select.Option>
<Select.Option value="LAD">{t("joblines.fields.lbr_types.LAD")}</Select.Option>
<Select.Option value="LAE">{t("joblines.fields.lbr_types.LAE")}</Select.Option>
<Select.Option value="LAF">{t("joblines.fields.lbr_types.LAF")}</Select.Option>
<Select.Option value="LAG">{t("joblines.fields.lbr_types.LAG")}</Select.Option>
<Select.Option value="LAM">{t("joblines.fields.lbr_types.LAM")}</Select.Option>
<Select.Option value="LAR">{t("joblines.fields.lbr_types.LAR")}</Select.Option>
<Select.Option value="LAS">{t("joblines.fields.lbr_types.LAS")}</Select.Option>
<Select.Option value="LAU">{t("joblines.fields.lbr_types.LAU")}</Select.Option>
<Select.Option value="LA1">{t("joblines.fields.lbr_types.LA1")}</Select.Option>
<Select.Option value="LA2">{t("joblines.fields.lbr_types.LA2")}</Select.Option>
<Select.Option value="LA3">{t("joblines.fields.lbr_types.LA3")}</Select.Option>
<Select.Option value="LA4">{t("joblines.fields.lbr_types.LA4")}</Select.Option>
</Select>
</Form.Item>
<Form.Item label={t("joblines.fields.op_code_desc")} name="op_code_desc">
<Input />
</Form.Item>
<Form.Item
label={t("joblines.fields.mod_lb_hrs")}
name="mod_lb_hrs"
rules={[
({ getFieldValue }) => ({
validator(rule, value) {
if (!!getFieldValue("mod_lbr_ty") === (!!value || value === 0)) {
return Promise.resolve();
}
return Promise.reject(t("joblines.validations.hrsrequirediflbrtyp"));
}
})
]}
>
<InputNumber precision={1} />
</Form.Item>
{Autohouse_Detail_line.treatment === "on" && (
<Form.Item
label={t("joblines.fields.ah_detail_line")}
name="ah_detail_line"
valuePropName="checked"
dependencies={["mod_lbr_ty"]}
initialValue={false}
rules={[
({ getFieldValue }) => ({
validator(rule, value) {
if (value === false || value === undefined || value === null) return Promise.resolve();
if (value === true && ["LA1", "LA2", "LA3", "LA4", "LAU"].includes(getFieldValue("mod_lbr_ty"))) {
return Promise.resolve();
}
return Promise.reject(t("joblines.validations.ahdetailonlyonuserdefinedtypes"));
}
})
]}
>
<LayoutFormRow grow>
<Form.Item label={t("joblines.fields.line_no")} name="line_no">
<InputNumber/>
</Form.Item>
<Form.Item
label={t("joblines.fields.line_desc")}
rules={[
{
required: true,
//message: t("general.validation.required"),
},
]}
name="line_desc"
>
<Input/>
</Form.Item>
<JoblinesPreset form={form}/>
</LayoutFormRow>
<LayoutFormRow grow>
<Form.Item label={t("joblines.fields.mod_lbr_ty")} name="mod_lbr_ty">
<Select allowClear>
<Select.Option value="LAA">
{t("joblines.fields.lbr_types.LAA")}
</Select.Option>
<Select.Option value="LAB">
{t("joblines.fields.lbr_types.LAB")}
</Select.Option>
<Select.Option value="LAD">
{t("joblines.fields.lbr_types.LAD")}
</Select.Option>
<Select.Option value="LAE">
{t("joblines.fields.lbr_types.LAE")}
</Select.Option>
<Select.Option value="LAF">
{t("joblines.fields.lbr_types.LAF")}
</Select.Option>
<Select.Option value="LAG">
{t("joblines.fields.lbr_types.LAG")}
</Select.Option>
<Select.Option value="LAM">
{t("joblines.fields.lbr_types.LAM")}
</Select.Option>
<Select.Option value="LAR">
{t("joblines.fields.lbr_types.LAR")}
</Select.Option>
<Select.Option value="LAS">
{t("joblines.fields.lbr_types.LAS")}
</Select.Option>
<Select.Option value="LAU">
{t("joblines.fields.lbr_types.LAU")}
</Select.Option>
<Select.Option value="LA1">
{t("joblines.fields.lbr_types.LA1")}
</Select.Option>
<Select.Option value="LA2">
{t("joblines.fields.lbr_types.LA2")}
</Select.Option>
<Select.Option value="LA3">
{t("joblines.fields.lbr_types.LA3")}
</Select.Option>
<Select.Option value="LA4">
{t("joblines.fields.lbr_types.LA4")}
</Select.Option>
</Select>
</Form.Item>
<Form.Item
label={t("joblines.fields.op_code_desc")}
name="op_code_desc"
>
<Input/>
</Form.Item>
<Form.Item
label={t("joblines.fields.mod_lb_hrs")}
name="mod_lb_hrs"
rules={[
({getFieldValue}) => ({
validator(rule, value) {
if (
!!getFieldValue("mod_lbr_ty") === (!!value || value === 0)
) {
return Promise.resolve();
}
return Promise.reject(
t("joblines.validations.hrsrequirediflbrtyp")
);
},
}),
]}
>
<InputNumber precision={1}/>
</Form.Item>
{Autohouse_Detail_line.treatment === "on" && (
<Form.Item
label={t("joblines.fields.ah_detail_line")}
name="ah_detail_line"
valuePropName="checked"
dependencies={["mod_lbr_ty"]}
initialValue={false}
rules={[
({getFieldValue}) => ({
validator(rule, value) {
if (
value === false ||
value === undefined ||
value === null
)
return Promise.resolve();
if (
value === true &&
["LA1", "LA2", "LA3", "LA4", "LAU"].includes(
getFieldValue("mod_lbr_ty")
)
) {
return Promise.resolve();
}
return Promise.reject(
t("joblines.validations.ahdetailonlyonuserdefinedtypes")
);
},
}),
]}
>
<Switch/>
</Form.Item>
)}
</LayoutFormRow>
<LayoutFormRow>
<Form.Item label={t("joblines.fields.part_type")} name="part_type">
<Select allowClear>
<Select.Option value="PAA">
{t("joblines.fields.part_types.PAA")}
</Select.Option>
<Select.Option value="PAC">
{t("joblines.fields.part_types.PAC")}
</Select.Option>
<Select.Option value="PAE">
{t("joblines.fields.part_types.PAE")}
</Select.Option>
<Select.Option value="PAL">
{t("joblines.fields.part_types.PAL")}
</Select.Option>
<Select.Option value="PAM">
{t("joblines.fields.part_types.PAM")}
</Select.Option>
<Select.Option value="PAN">
{t("joblines.fields.part_types.PAN")}
</Select.Option>
<Select.Option value="PAO">
{t("joblines.fields.part_types.PAO")}
</Select.Option>
<Select.Option value="PAR">
{t("joblines.fields.part_types.PAR")}
</Select.Option>
<Select.Option value="PAS">
{t("joblines.fields.part_types.PAS")}
</Select.Option>
</Select>
</Form.Item>
<Form.Item label={t("joblines.fields.oem_partno")} name="oem_partno">
<Input/>
</Form.Item>
<Form.Item
label={t("joblines.fields.part_qty")}
name="part_qty"
rules={[
({getFieldValue}) => ({
validator(rule, value) {
if (!!getFieldValue("part_type") === !!value) {
return Promise.resolve();
}
return Promise.reject(
t("joblines.validations.requiredifparttype")
);
},
}),
]}
>
<InputNumber precision={0} min={0}/>
</Form.Item>
{/* <Form.Item label={t("joblines.fields.db_price")} name="db_price">
<Switch />
</Form.Item>
)}
</LayoutFormRow>
<LayoutFormRow>
<Form.Item label={t("joblines.fields.part_type")} name="part_type">
<Select allowClear>
<Select.Option value="PAA">{t("joblines.fields.part_types.PAA")}</Select.Option>
<Select.Option value="PAC">{t("joblines.fields.part_types.PAC")}</Select.Option>
<Select.Option value="PAE">{t("joblines.fields.part_types.PAE")}</Select.Option>
<Select.Option value="PAL">{t("joblines.fields.part_types.PAL")}</Select.Option>
<Select.Option value="PAM">{t("joblines.fields.part_types.PAM")}</Select.Option>
<Select.Option value="PAN">{t("joblines.fields.part_types.PAN")}</Select.Option>
<Select.Option value="PAO">{t("joblines.fields.part_types.PAO")}</Select.Option>
<Select.Option value="PAR">{t("joblines.fields.part_types.PAR")}</Select.Option>
<Select.Option value="PAS">{t("joblines.fields.part_types.PAS")}</Select.Option>
</Select>
</Form.Item>
<Form.Item label={t("joblines.fields.oem_partno")} name="oem_partno">
<Input />
</Form.Item>
<Form.Item
label={t("joblines.fields.part_qty")}
name="part_qty"
rules={[
({ getFieldValue }) => ({
validator(rule, value) {
if (!!getFieldValue("part_type") === !!value) {
return Promise.resolve();
}
return Promise.reject(t("joblines.validations.requiredifparttype"));
}
})
]}
>
<InputNumber precision={0} min={0} />
</Form.Item>
{/* <Form.Item label={t("joblines.fields.db_price")} name="db_price">
<InputCurrency precision={2} min={0} />
</Form.Item> */}
<Form.Item
label={t("joblines.fields.act_price")}
name="act_price"
rules={[
({getFieldValue}) => ({
validator(rule, value) {
if (!value || getFieldValue("part_type") !== "PAE") {
return Promise.resolve();
}
return Promise.reject(
t("joblines.validations.zeropriceexistingpart")
);
},
}),
({getFieldValue}) => ({
validator(rule, value) {
if (
!!getFieldValue("part_type") === (!!value || value === 0)
) {
return Promise.resolve();
}
return Promise.reject(
t("joblines.validations.requiredifparttype")
);
},
}),
]}
>
<InputCurrency
precision={2}
min={Allow_Negative_Jobline_Price.treatment === "on" ? null : 0}
/>
</Form.Item>
<Form.Item
label={t("joblines.fields.prt_dsmk_p")}
name="prt_dsmk_p"
initialValue={0}
>
<InputNumber precision={0} min={-100} max={100}/>
</Form.Item>
<Form.Item
label={t("joblines.fields.tax_part")}
name="tax_part"
valuePropName="checked"
initialValue={true}
>
<Switch/>
</Form.Item>
</LayoutFormRow>
</Form>
</Modal>
);
<Form.Item
label={t("joblines.fields.act_price")}
name="act_price"
rules={[
({ getFieldValue }) => ({
validator(rule, value) {
if (!value || getFieldValue("part_type") !== "PAE") {
return Promise.resolve();
}
return Promise.reject(t("joblines.validations.zeropriceexistingpart"));
}
}),
({ getFieldValue }) => ({
validator(rule, value) {
if (!!getFieldValue("part_type") === (!!value || value === 0)) {
return Promise.resolve();
}
return Promise.reject(t("joblines.validations.requiredifparttype"));
}
})
]}
>
<InputCurrency precision={2} min={Allow_Negative_Jobline_Price.treatment === "on" ? null : 0} />
</Form.Item>
<Form.Item label={t("joblines.fields.prt_dsmk_p")} name="prt_dsmk_p" initialValue={0}>
<InputNumber precision={0} min={-100} max={100} />
</Form.Item>
<Form.Item label={t("joblines.fields.tax_part")} name="tax_part" valuePropName="checked" initialValue={true}>
<Switch />
</Form.Item>
</LayoutFormRow>
</Form>
</Modal>
);
}

View File

@@ -1,146 +1,136 @@
import {useMutation} from "@apollo/client";
import {notification} from "antd";
import React, {useState} from "react";
import {useTranslation} from "react-i18next";
import {connect} from "react-redux";
import {createStructuredSelector} from "reselect";
import {INSERT_NEW_JOB_LINE, UPDATE_JOB_LINE,} from "../../graphql/jobs-lines.queries";
import {toggleModalVisible} from "../../redux/modals/modals.actions";
import {selectJobLineEditModal} from "../../redux/modals/modals.selectors";
import { useMutation } from "@apollo/client";
import { notification } from "antd";
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
import { INSERT_NEW_JOB_LINE, UPDATE_JOB_LINE } from "../../graphql/jobs-lines.queries";
import { toggleModalVisible } from "../../redux/modals/modals.actions";
import { selectJobLineEditModal } from "../../redux/modals/modals.selectors";
import UndefinedToNull from "../../utils/undefinedtonull";
import JobLinesUpdsertModal from "./job-lines-upsert-modal.component";
import Axios from "axios";
import Dinero from "dinero.js";
import CriticalPartsScan from "../../utils/criticalPartsScan";
import {selectBodyshop} from "../../redux/user/user.selectors";
import {useSplitTreatments} from "@splitsoftware/splitio-react";
import { selectBodyshop } from "../../redux/user/user.selectors";
import { useSplitTreatments } from "@splitsoftware/splitio-react";
const mapStateToProps = createStructuredSelector({
jobLineEditModal: selectJobLineEditModal,
bodyshop: selectBodyshop,
jobLineEditModal: selectJobLineEditModal,
bodyshop: selectBodyshop
});
const mapDispatchToProps = (dispatch) => ({
toggleModalVisible: () => dispatch(toggleModalVisible("jobLineEdit")),
toggleModalVisible: () => dispatch(toggleModalVisible("jobLineEdit"))
});
function JobLinesUpsertModalContainer({
jobLineEditModal,
toggleModalVisible,
bodyshop,
}) {
function JobLinesUpsertModalContainer({ jobLineEditModal, toggleModalVisible, bodyshop }) {
const {
treatments: { CriticalPartsScanning }
} = useSplitTreatments({
attributes: {},
names: ["CriticalPartsScanning"],
splitKey: bodyshop.imexshopid
});
const {treatments: {CriticalPartsScanning}} = useSplitTreatments({
attributes: {},
names: ['CriticalPartsScanning'],
splitKey: bodyshop.imexshopid,
});
const { t } = useTranslation();
const [insertJobLine] = useMutation(INSERT_NEW_JOB_LINE);
const [updateJobLine] = useMutation(UPDATE_JOB_LINE);
const [loading, setLoading] = useState(false);
const {t} = useTranslation();
const [insertJobLine] = useMutation(INSERT_NEW_JOB_LINE);
const [updateJobLine] = useMutation(UPDATE_JOB_LINE);
const [loading, setLoading] = useState(false);
const handleFinish = async (values) => {
setLoading(true);
if (!jobLineEditModal.context.id) {
const r = await insertJobLine({
variables: {
lineInput: [
{
jobid: jobLineEditModal.context.jobid,
manual_line: !(
jobLineEditModal.context && jobLineEditModal.context.id
),
...UndefinedToNull({
...values,
prt_dsmk_m: Dinero({
amount: Math.round((values.act_price || 0) * 100),
})
.percentage(Math.abs(values.prt_dsmk_p || 0))
.multiply(values.prt_dsmk_p >= 0 ? 1 : -1)
.toFormat(0.0),
}),
},
],
},
refetchQueries: ["GET_LINE_TICKET_BY_PK"],
});
if (!r.errors) {
await Axios.post("/job/totalsssu", {
id: jobLineEditModal.context.jobid,
});
if (jobLineEditModal.actions.refetch)
jobLineEditModal.actions.refetch();
//Need to recalcuate totals.
toggleModalVisible();
notification["success"]({
message: t("joblines.successes.created"),
});
} else {
notification["error"]({
message: t("joblines.errors.creating", {
message: JSON.stringify(r.errors.message),
}),
});
const handleFinish = async (values) => {
setLoading(true);
if (!jobLineEditModal.context.id) {
const r = await insertJobLine({
variables: {
lineInput: [
{
jobid: jobLineEditModal.context.jobid,
manual_line: !(jobLineEditModal.context && jobLineEditModal.context.id),
...UndefinedToNull({
...values,
prt_dsmk_m: Dinero({
amount: Math.round((values.act_price || 0) * 100)
})
.percentage(Math.abs(values.prt_dsmk_p || 0))
.multiply(values.prt_dsmk_p >= 0 ? 1 : -1)
.toFormat(0.0)
})
}
} else {
const r = await updateJobLine({
variables: {
lineId: jobLineEditModal.context.id,
line: {
...values,
prt_dsmk_m: Dinero({
amount: Math.round(values.act_price * 100),
})
.percentage(Math.abs(values.prt_dsmk_p || 0))
.multiply(values.prt_dsmk_p >= 0 ? 1 : -1)
.toFormat(0.0),
},
},
refetchQueries: ["GET_LINE_TICKET_BY_PK"],
});
if (!r.errors) {
notification["success"]({
message: t("joblines.successes.updated"),
});
} else {
notification["success"]({
message: t("joblines.errors.updating", {
message: JSON.stringify(r.errors.message),
}),
});
}
if (jobLineEditModal.actions.submit) {
jobLineEditModal.actions.submit();
} else {
if (jobLineEditModal.actions.refetch)
jobLineEditModal.actions.refetch();
}
toggleModalVisible();
}
if (CriticalPartsScanning.treatment === "on") {
CriticalPartsScan(jobLineEditModal.context.jobid);
}
setLoading(false);
};
const handleCancel = () => {
]
},
refetchQueries: ["GET_LINE_TICKET_BY_PK"]
});
if (!r.errors) {
await Axios.post("/job/totalsssu", {
id: jobLineEditModal.context.jobid
});
if (jobLineEditModal.actions.refetch) jobLineEditModal.actions.refetch();
//Need to recalcuate totals.
toggleModalVisible();
};
notification["success"]({
message: t("joblines.successes.created")
});
} else {
notification["error"]({
message: t("joblines.errors.creating", {
message: JSON.stringify(r.errors.message)
})
});
}
} else {
const r = await updateJobLine({
variables: {
lineId: jobLineEditModal.context.id,
line: {
...values,
prt_dsmk_m: Dinero({
amount: Math.round(values.act_price * 100)
})
.percentage(Math.abs(values.prt_dsmk_p || 0))
.multiply(values.prt_dsmk_p >= 0 ? 1 : -1)
.toFormat(0.0)
}
},
refetchQueries: ["GET_LINE_TICKET_BY_PK"]
});
if (!r.errors) {
notification["success"]({
message: t("joblines.successes.updated")
});
} else {
notification["success"]({
message: t("joblines.errors.updating", {
message: JSON.stringify(r.errors.message)
})
});
}
return (
<JobLinesUpdsertModal
open={jobLineEditModal.open}
jobLine={jobLineEditModal.context}
handleFinish={handleFinish}
handleCancel={handleCancel}
loading={loading}
/>
);
if (jobLineEditModal.actions.submit) {
jobLineEditModal.actions.submit();
} else {
if (jobLineEditModal.actions.refetch) jobLineEditModal.actions.refetch();
}
toggleModalVisible();
}
if (CriticalPartsScanning.treatment === "on") {
CriticalPartsScan(jobLineEditModal.context.jobid);
}
setLoading(false);
};
const handleCancel = () => {
toggleModalVisible();
};
return (
<JobLinesUpdsertModal
open={jobLineEditModal.open}
jobLine={jobLineEditModal.context}
handleFinish={handleFinish}
handleCancel={handleCancel}
loading={loading}
/>
);
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(JobLinesUpsertModalContainer);
export default connect(mapStateToProps, mapDispatchToProps)(JobLinesUpsertModalContainer);